From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id u0/+LPKY/2KcwykAWB0awg (envelope-from ) for ; Fri, 19 Aug 2022 10:06:42 -0400 Received: by simark.ca (Postfix, from userid 112) id AD3B31E4A7; Fri, 19 Aug 2022 10:06:42 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=nArCkSy+; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4E6551E13B for ; Fri, 19 Aug 2022 10:06:42 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 819543858413 for ; Fri, 19 Aug 2022 14:06:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 819543858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660918001; bh=sDoe6+hz0tyc3LTGmpyTAlAAtnr0mZkIxojNwLfB+pI=; h=References:To:Subject:In-reply-to:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=nArCkSy+A/LdRm63rpH9F9Yjx87Xo7DbuTnpm30AnP3w70yuETki+FgvRa9ShKbAG 96KdK/UsCCkIjQ4dTTw/QGVVzXSIrO4589vk8VJgxrasGYY7b1FefYn5XKbMGVNuCA 5xhX6AzBUI/6qrDsUne38fnt4/QgndZujozitwc4= Received: from mail-vk1-xa29.google.com (mail-vk1-xa29.google.com [IPv6:2607:f8b0:4864:20::a29]) by sourceware.org (Postfix) with ESMTPS id DFA7A385841D for ; Fri, 19 Aug 2022 14:06:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DFA7A385841D Received: by mail-vk1-xa29.google.com with SMTP id d6so157571vko.7 for ; Fri, 19 Aug 2022 07:06:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc; bh=sDoe6+hz0tyc3LTGmpyTAlAAtnr0mZkIxojNwLfB+pI=; b=brUiLIXwCjNwNfT09y3XsWFw0ef4dNUc+k1seIWPGzK3kThil20LWQDHvnWxBrN51+ CuKd9S4FK8Y3+CUEqZhCncJjJLpSqvR+RaQaJEMSFfJJPvrYQoxk9iI4b/A5w5TSo29p qFWh5xwDhu9zFi7TLElpw7avW5PLEJwdL8X8h5gG0wTjlaNHv0McqIhTlALKz/mp4RG0 9g5zQXLR+xCjkXGazwUELiYMxz8rbJ6JFCxAzsGciheJhQ0Eefwacrmsp6I9INPOghhN CjTM6HmposLPx1+QvInEMB70tnxPD+BbuET1TdX8E7gNrNkt6Pd6xJLzPFQgH5AlaMlb 7LCQ== X-Gm-Message-State: ACgBeo2U5U/WG//T8dO8bgCqZWUPDCQ8jOmAuUD0cDZH+057oMiatEl3 UPD7qPbK+gQWQiNDm5ElLkGwIujjkEQQjA== X-Google-Smtp-Source: AA6agR5IAVtuaOMdAyGgA6VBSlaLUwiG/tFKiiqNss/I/v6fa9YuHCNcgZhTHZ6eV4IKu+wO7UX+Hw== X-Received: by 2002:a1f:fc03:0:b0:387:8a47:c713 with SMTP id a3-20020a1ffc03000000b003878a47c713mr1388443vki.30.1660917981159; Fri, 19 Aug 2022 07:06:21 -0700 (PDT) Received: from localhost ([2804:14c:8780:89d8:1a66:1fb7:d31f:d5e7]) by smtp.gmail.com with ESMTPSA id v9-20020a05610205c900b003885a2f7a36sm2611226vsf.5.2022.08.19.07.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 07:06:20 -0700 (PDT) References: <20220705140037.135012-1-luis.machado@arm.com> <20220711115534.23810-1-luis.machado@arm.com> <87o7wh2jy2.fsf@linaro.org> User-agent: mu4e 1.8.8; emacs 28.1 To: Luis Machado Subject: Re: [PATCH,v2] [aarch64] Fix removal of non-address bits for PAuth In-reply-to: Date: Fri, 19 Aug 2022 14:06:18 +0000 Message-ID: <87h7282uqt.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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: , From: Thiago Jung Bauermann via Gdb-patches Reply-To: Thiago Jung Bauermann Cc: lsix@lancelotsix.com, gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Luis Machado writes: > On 8/19/22 00:47, Thiago Jung Bauermann wrote: >> Hello Luis, >> The patch looks great to me, FWIW. >> I have just a few small comments. >> Luis Machado via Gdb-patches writes: >> >>> While at it, make GDB and GDBServer share some more code for aarch64 >> Nice! >> >>> +/* AArch64 implementation of the remove_non_address_bits gdbarch hook. Remove >>> + non address bits from a pointer value. */ >>> + >>> +static CORE_ADDR >>> +aarch64_remove_non_address_bits (struct gdbarch *gdbarch, CORE_ADDR pointer) >>> +{ >>> + aarch64_gdbarch_tdep *tdep >>> + = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); >>> + >>> + /* By default, we assume TBI and discard the top 8 bits plus the VA range >>> + select bit (55). */ >>> + CORE_ADDR mask = (((CORE_ADDR) 1) << (64 - 9)) - 1; >>> + mask = ~mask; >> One suggestion is to put the above in gdb/arch/aarch64.h as: >> /* By default, we assume TBI and discard the top 8 bits plus the VA range >> select bit (55). */ >> #define AARCH64_TOP_BITS_MASK (~((((CORE_ADDR) 1) << (64 - 9)) - 1)) >> and then use it here and in gdbserver's version of this function so that >> there's a little bit more code shared between them. >> > > That makes sense, but I wonder if it will fit gdb/arch/aarch64.h. The VA bit is > a generic ISA thing, but the TBI is OS-specific I think. Right, an OS may or may not support TBI. > Maybe a gdb/arch/aarch64-pauth.h header that gets shared between gdb and gdbserver > then? Sounds good to me. >>> diff --git a/gdb/gdbarch-components.py b/gdb/gdbarch-components.py >>> index fc10e8600ba..c6836b63c50 100644 >>> --- a/gdb/gdbarch-components.py >>> +++ b/gdb/gdbarch-components.py >>> @@ -1116,15 +1116,21 @@ possible it should be in TARGET_READ_PC instead). >>> invalid=False, >>> ) >>> -Value( >>> +Method( >>> comment=""" >>> -On some machines, not all bits of an address word are significant. >>> -For example, on AArch64, the top bits of an address known as the "tag" >>> -are ignored by the kernel, the hardware, etc. and can be regarded as >>> -additional data associated with the address. >>> +On some architectures, not all bits of a pointer are significant. >>> +On AArch64, for example, the top bits of a pointer may carry a "tag", which >>> +can be ignored by the kernel and the hardware. The "tag" can be regarded as >>> +additional data associated with the pointer, but it is not part of the address. >>> + >>> +Given a pointer for the architecture, this hook removes all the >>> +non-significant bits and sign-extends things as needed. It is used mostly >>> +for data pointers, as opposed to code pointers. >> Is the last sentence just FYI or does it imply some consequence for the >> GDB user or even GDB itself? >> > > More a FYI really. This was documented somewhere in the code, and I wanted to > bring it to the manual. I'll clarify it. Thanks. The reason I asked is that if I were trying to use gdbarch_remove_non_address_bits, I didn't know whether there was something I should be aware of, or account for. -- Thiago