From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 94D6D3858280 for ; Tue, 5 Jul 2022 18:12:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 94D6D3858280 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 804B798564; Tue, 5 Jul 2022 18:12:23 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LcrP32zRdz3CMV; Tue, 5 Jul 2022 18:12:23 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657044743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fo2W8Z1F98nTyCFK8Ne15S0djQh327NHj+QoRMr5iEg=; b=bSOdGF0yCh5NLtqDkZEZh7z8vquWFrFztOFbA+Q0F0BNL88RJI+XRrT5lyLbOyRFd8qXqf TlO2NQwj5Sa+7lNMcSsC2r5qqJ4eeMQvu3Qtfv+/K8urOFE3/FgI5WQMabBSOSGsdPRHSs sceAzN/zfiscuBx6PEICt6l0+cITelVZ9fRD35Jv/bPO4r17Vh3+/o4PojqNUP6kn6h02y q6R434EbZ0kxcbUXMgzdThQ9IBVU7j8mVfkAj8wZZDITxe4CRDCkVfGY/qp+ZAuTemFJnH 7T+T1pmwRCfdDbFGIk79i70wzND3ZVXRa3WxUKiK2uPHsYlmb/bJX9ekD2CbtQ== Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 006AB2C926; Tue, 5 Jul 2022 18:12:22 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <5eb7ed29-f4fc-83ba-61bc-ceb6b127c8dc@FreeBSD.org> Date: Tue, 5 Jul 2022 11:12:21 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] [AArch64] Fix removal of non-address bits for PAuth Content-Language: en-US To: Luis Machado , gdb-patches@sourceware.org References: <20220705140037.135012-1-luis.machado@arm.com> From: John Baldwin In-Reply-To: <20220705140037.135012-1-luis.machado@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657044743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fo2W8Z1F98nTyCFK8Ne15S0djQh327NHj+QoRMr5iEg=; b=Cvc72knUKhajM9Y91V+jdY43L55HBW9Eo8DgkDDEcx+RmTWmYa8iQUq+/woiS7kV3YEppx vu1C13njcDtRiDQCYfRbcYd8aE+/XdC8t/IrgS8O4poCFyoa4Gs1m4qIh5GlXVgRvIjiZ1 YRZgAScpC8vPXr/33jUsDCzZeB3Y7o/t/ItgiW45jgwff0ghvin9yP/Ag31jNN+nsXFxqA naOTPd1LzLkdFhVwfpDLyRffkVTzcFEgNTFM+MTlzGy+xvJz/GDtOaE1FIXbHCv7mZ3C1C ZiHMvymOvsxH9IOBGBOz7W8DGPema3P1mmLAQGU6mqtJS4wb59lTI0bZ9ayEOA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657044743; a=rsa-sha256; cv=none; b=o9GanY/Nq5V4lfzCmK73107um6HnkLR0kq50v2p5MRisWVEwr7HEvJbbwHF5pM8iLD9gf4 ftSX67B7J/+Ipo+I1q/ePthEDRKS4WAac+SanH8AiMF30YR9NJjmTVfesjg4I7a3QxGcad R38iBwCw9A1ZEAXnjHvPQuDOLBg77vDLYQlsCoUYXbCkb7PK40AmOS+c7I6UvaCbI/rbcg JHqkCsPzwmvZ8RWY2STghf9JoegfMpuqlDpHYfFXe6uzzIJl2+9hP2u+gVBWk+cu/zrVEJ uri3OaAkPdy2CzkI5Frn0mN8R9/RalwBt9NWynZRCpu6UsNd947OL/yPO4cYPQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2022 18:12:25 -0000 On 7/5/22 7:00 AM, Luis Machado via Gdb-patches wrote: > The address_significant gdbarch setting was introduced as a way to remove > non-address bits from pointers, and it is specified by a constant. This > constant represents the number of address bits in a pointer. > > Right now AArch64 is the only architecture that uses it, and 56 was a > correct option so far. > > But if we are using Pointer Authentication (PAuth), we might use up to 2 bytes > from the address space to store the required information. We could also have > cases where we're using both PAuth and MTE. > > We could adjust the constant to 48 to cover those cases, but this doesn't > cover the case where GDB needs to sign-extend kernel addresses after removal > of the non-address bits. > > This has worked so far because bit 55 is used to select between kernel-space > and user-space addresses. But trying to clear a range of bits crossing the > bit 55 boundary requires the hook to be smarter. > > The following patch renames the gdbarch hook from significant_addr_bit to > remove_non_address_bits and passes a pointer as opposed to the number of > bits. The hook is now responsible for removing the required non-address bits > and sign-extending the address if needed. > > While at it, make GDB and GDBServer share some more code for AArch64. This LGTM. I agree that changing around the gdbarch methods this way makes sense. -- John Baldwin