From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (vps-42846194.vps.ovh.net [IPv6:2001:41d0:801:2000::2400]) by sourceware.org (Postfix) with ESMTPS id 7B7D23858D39 for ; Wed, 6 Jul 2022 11:39:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7B7D23858D39 Received: from ubuntu.lan (unknown [IPv6:2a02:390:9086::635]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 58C418905D; Wed, 6 Jul 2022 11:39:05 +0000 (UTC) Date: Wed, 6 Jul 2022 11:38:57 +0000 From: Lancelot SIX To: Luis Machado Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] [AArch64] Fix removal of non-address bits for PAuth Message-ID: <20220706113857.a6gfmmlaeprg5uyq@ubuntu.lan> References: <20220705140037.135012-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220705140037.135012-1-luis.machado@arm.com> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Wed, 06 Jul 2022 11:39:05 +0000 (UTC) X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_ABUSEAT, RCVD_IN_XBL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: Wed, 06 Jul 2022 11:39:08 -0000 > + > +/* See arch/aarch64.h. */ > + > +CORE_ADDR > +aarch64_remove_top_bytes (CORE_ADDR pointer, CORE_ADDR mask) Hi, Shouldn't this function be called aarch64_remove_top_bits (note the s/bytes/bits)? This function does not work at the byte grain. > +{ > + /* The VA range select bit is 55. This bit tells us if we have a > + kernel-space address or a user-space address. */ > + bool kernel_address = (pointer & VA_RANGE_SELECT_BIT_MASK)? true : false; You could drop the ternary operator by using bool kernel_address = (pointer & VA_RANGE_SELECT_BIT_MASK) != 0; which I find a "more canonical" way to write it, but I guess it is mostly a matter of taste. Best, Lancelot. > +/* Given a pointer value POINTER and a MASK of non-address bits, remove the > + non-address bits from the pointer and sign-extend the result if required. > + The sign-extension is required so we can handle kernel addresses > + correctly. */ > +CORE_ADDR aarch64_remove_top_bytes (CORE_ADDR pointer, CORE_ADDR mask);