From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id W9RSDUMtpGc91iUAWB0awg (envelope-from ) for ; Wed, 05 Feb 2025 22:32:19 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Ip7HclAS; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2CF6F1E105; Wed, 5 Feb 2025 22:32:19 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 84CB21E05C for ; Wed, 5 Feb 2025 22:32:18 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 386103858431 for ; Thu, 6 Feb 2025 03:32:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 386103858431 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Ip7HclAS Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id CC7A53858C51 for ; Thu, 6 Feb 2025 03:31:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC7A53858C51 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CC7A53858C51 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738812705; cv=none; b=YECDrB1PhQ3gfpOXtPPRbJR/yxLn1yPXx9p4yROTQKljK/kcZbRaakKglXlZZKeXwz7fGmayaoFUkydx/H+xgWbGMh3l+Lq+PQi+Q5+9zi4oYwBp6HUE0sl7QfkymoZRZiBAxQ+01/4xdnLwxYDplJsePBayRr0Np+6vKBhj+nY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738812705; c=relaxed/simple; bh=CIAF7hXCpf4sfAlO2D8SbM4n8De6R/RrosFs1wTyRdA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KKZJgDFF9tAPJT6pD6tWd699Pa9Z4EQd2xknzVS8oBFsJuTmApJNeDbVrKW/r9GTPZTBf9JZyXN9zF24JXdRT1oI3TEf8ILO+Uy9JzaiD45vODQ7WdiEjvCe5bdg59/6CfE/U56SFFtwstlWlTDuwpvzq4Et9f36ChNSQthXSNY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC7A53858C51 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-21f08b44937so7135365ad.1 for ; Wed, 05 Feb 2025 19:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738812704; x=1739417504; darn=sourceware.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=OaKaSS0uzdHdcrvzbmCbZlyAPNBaRd5FQnWMoVlxfKM=; b=Ip7HclASthgnuXBl7fs3TQI5jTBMj/9rxAM26Q/t8AfIaXmAGoQt+ZTS15T4lushZI fNNB4vQefhLehgkgcaADE5qJXxL2MXeDp4RJLdWQaJGLguEBpqyrfb8AVgehw9naxj98 OfXx1girgIC8BCFVs44gG2jQCcVP/6S0MiLy6O87OauP4mBYx8UqlDwevPfV/JMPPQaO zQE0wSalrehXEN8RqQRN8eMxWggCqwQdOCU2lv3eUa00nFZVhIlKaU8hYc/P3TVkShek nBb94c7xr/9CCrC4lzdFGc4wpxJp3kQ+3iEBNAfGLj5YzK1WC7AVAICEHT8AJa4ShRFu I8HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738812704; x=1739417504; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OaKaSS0uzdHdcrvzbmCbZlyAPNBaRd5FQnWMoVlxfKM=; b=rdokDKkRb+1vf3zSKDQ2txOsJ0rvHU5lMy08DmzpormguaxDCAkOUYK/cfHQFYqAAt rcErXInllAzFNIJavggafiQK32Rmc+hXRWmxwD9hVGuIm7z+59GERLuug3PIxiUCiJae NYOW5+ZmF6omSrDE2YP6mPptuKLc+Lp22Ywf29blwSDT2VpxtFUG3JetW3vxSe1JUc4v UXElNqqojNa3ELir8gjqri21blgCoVDmUHiYir/y4At27d9EM1oQ6X4e6dgoFbWkF34A lsH/yNWrqBCziRzMUquY2k2z/Vlrr0/595ownWhbBUm6xK1Xt+jrnfQJriO36h4prW5Y LGUQ== X-Gm-Message-State: AOJu0YwAmh0LSFfJLKBCfvF6oFXIsv0CY8qkGTNdwaObKrhIOED+j3gh KisDDW2SaHnZ7gVpXFUElOqc/2HVeHv2umuAgGU7vSf0DwJtH+XXuJWNaflwv+FEvkoCYya3hKf n X-Gm-Gg: ASbGncvTwGVFhrHF0q8O1TtiqShmIPbNIwOUboMecjof/Ks2pXYOZxdSFb+Sy1kSm/G tb6wrLUVB/txENUNnxoOYkdMHynyn0CFIC8e2dqYtelYKYhkG22rViV7s/uKS7yigNH7M2NCZjN Dz168eYh4jaVT6P6Lqhjgw/Bjbxh6HPACZ4VT9eb5JC+UBR5RZ26I18NPMTwZSw5ZSf8GV9+SPc VPUeZtR1cU7AhKPXGngdxQPQ6J0SM83rTDY+ZuRti53s2Wy4V3IE/PLJooogRQaOLnHwYfk007v h0yxfUtPfIZAqUIm8W9ap68= X-Google-Smtp-Source: AGHT+IGSrNY4C4G0XFuqna8aVFa3pG5I14Za11PmJHqNefCeu6qaQDGubL5T4M5bP1Is3BLsyglFJw== X-Received: by 2002:a17:902:f686:b0:21a:8769:302e with SMTP id d9443c01a7336-21f17e47727mr90132915ad.14.1738812703835; Wed, 05 Feb 2025 19:31:43 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:7e5:16be:a0c6:ff7]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21f3683dabbsm1632405ad.137.2025.02.05.19.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 19:31:43 -0800 (PST) From: Thiago Jung Bauermann To: "Schimpe, Christina" Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 09/12] gdb, gdbarch: Enable inferior calls for shadow stack support. In-Reply-To: <20241220200501.324191-10-christina.schimpe@intel.com> (Christina Schimpe's message of "Fri, 20 Dec 2024 20:04:58 +0000") References: <20241220200501.324191-1-christina.schimpe@intel.com> <20241220200501.324191-10-christina.schimpe@intel.com> User-Agent: mu4e 1.12.8; emacs 29.4 Date: Thu, 06 Feb 2025 00:31:40 -0300 Message-ID: <87tt97hhpf.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org "Schimpe, Christina" writes: > diff --git a/gdb/infcall.c b/gdb/infcall.c > index 6399278c6ae..3a4f1e35a2f 100644 > --- a/gdb/infcall.c > +++ b/gdb/infcall.c > @@ -1453,6 +1453,12 @@ call_function_by_hand_dummy (struct value *function, > bp_addr, args.size (), args.data (), > sp, return_method, struct_addr); > > + /* Push the return address of the inferior (bp_addr) on the shadow stack > + and update the shadow stack pointer. As we don't execute a call > + instruction to start the inferior we need to handle this manually. */ > + if (gdbarch_shadow_stack_push_p (gdbarch)) > + gdbarch_shadow_stack_push (gdbarch, bp_addr); > + For AArch64's Guarded Control Stack, instead of adding a new gdbarch method I added this change to aarch64_push_dummy_call: if (aarch64_gcs_is_enabled (regcache)) aarch64_push_gcs_entry (regcache, bp_addr); To implement aarch64_gcs_is_enabled I did add a new method to aarch64_gdbarch_tdep so that OS-independent code in aarch64-tdep.c could call Linux-specific logic in aarch64-linux-tdep.c: static bool aarch64_gcs_is_enabled (regcache *regs) { gdbarch *arch = regs->arch (); aarch64_gdbarch_tdep *tdep = gdbarch_tdep (arch); if (tdep->gcs_is_enabled == nullptr) return false; return tdep->gcs_is_enabled (regs); } Wouldn't a similar approach work for amd64? -- Thiago