From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id lC/xHhafdmEYcwAAWB0awg (envelope-from ) for ; Mon, 25 Oct 2021 08:12:06 -0400 Received: by simark.ca (Postfix, from userid 112) id 6E46C1F0BD; Mon, 25 Oct 2021 08:12:06 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.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 9067E1ECEB for ; Mon, 25 Oct 2021 08:12:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3EE83858435 for ; Mon, 25 Oct 2021 12:12:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3EE83858435 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1635163924; bh=vetnfeOOORAzv0OMZX4kpwyTJv2kmVFp4FVosacqSJs=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Sx0bTNNUhsVrgqx/8RDKMP48agwXCjlgMZjJ+jPcadlNY/YCNeyzRjjcBUYka7TBz x+ODNj//anP7ZO024JSkrKu1kS1l/TtcJvTojbl1PVjGX2lZZyIXT7k0Esp0A38sxU EqCZVqxRvQtaxzOiS104QdVlBjXX21kKbxx8KvF4= Received: from mail-vk1-xa31.google.com (mail-vk1-xa31.google.com [IPv6:2607:f8b0:4864:20::a31]) by sourceware.org (Postfix) with ESMTPS id D70D1385843E for ; Mon, 25 Oct 2021 12:07:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D70D1385843E Received: by mail-vk1-xa31.google.com with SMTP id o64so271230vke.5 for ; Mon, 25 Oct 2021 05:07:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vetnfeOOORAzv0OMZX4kpwyTJv2kmVFp4FVosacqSJs=; b=rd6vqbJUFd7JCrjfGT5fYhf1u4COGQ0r3JeQH9M9Ab/E0e9FDuEeUNv/CtTfw/LLRq nzMQ2hKCmDkdIiOjthSMDMc3eS8GZ38yspXptQR/sbp50mnlDOyocRVO/GRsAxAuX9zt /SyuzXbYlZOhVPCjAWJ/fNW0ADQ8J094VmOJegSYHRaVcgpSc5ou0twGJRuIyqnFY1Ih c1nU202CORnoxi4BPqj9c0hMr54CcNqk5O14Hyy1SC0K4/v1WVtw/oNyOGnDT1muN4Yl mQRZ8WP08A6xM1InX9KUrfQ7e3hrNsn7QzDOMBcJUrKGW/gKYZshFNL36SGPgmwlqZ4W Bg5g== X-Gm-Message-State: AOAM530ztYHBbna8N+wCcNvpqKYF3PQVosH9/AiZ3z5MZcM6ARsg5ehc fR9/PGk6Un6pIqrFCxZF7UZDfA== X-Google-Smtp-Source: ABdhPJxJj8hW7Rgc94m2kic/CGYKWfItqjh/3cpbxW8yRINnTYgjR7VG3NSto9M+/KOu2+21tknfKQ== X-Received: by 2002:a05:6122:da0:: with SMTP id bc32mr14001576vkb.4.1635163667456; Mon, 25 Oct 2021 05:07:47 -0700 (PDT) Received: from ?IPv6:2804:7f0:4841:3c03:600e:1e80:b8eb:fa4? ([2804:7f0:4841:3c03:600e:1e80:b8eb:fa4]) by smtp.gmail.com with ESMTPSA id t76sm9594108vkt.0.2021.10.25.05.07.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Oct 2021 05:07:47 -0700 (PDT) Subject: Re: [PATCH] AArch64 pauth: Indicate addresses in backtrace for kernel To: Kuan-Ying Lee , gdb-patches@sourceware.org References: <20211025114705.32548-1-Kuan-Ying.Lee@mediatek.com> Message-ID: Date: Mon, 25 Oct 2021 09:07:43 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211025114705.32548-1-Kuan-Ying.Lee@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Luis Machado via Gdb-patches Reply-To: Luis Machado Cc: james.hsu@mediatek.com, nicholas.tang@mediatek.com, zhiyong.wang@mediatek.com, chinwen.chang@mediatek.com Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 10/25/21 8:47 AM, Kuan-Ying Lee via Gdb-patches wrote: > Armv8.3-a Pointer Authentication cause the function return address to > be changed. GDB need to use address bit[55] to know which mode is active > and mask/unmask the link register in order to get backtrace. > > If address is in kernel mode, we mask the address. If address is in user mode, > we need to unmask the address. > --- > gdb/aarch64-tdep.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > index 4b5af4616af..d4bb4305cea 100644 > --- a/gdb/aarch64-tdep.c > +++ b/gdb/aarch64-tdep.c > @@ -257,7 +257,10 @@ aarch64_frame_unmask_lr (struct gdbarch_tdep *tdep, > { > int cmask_num = AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base); > CORE_ADDR cmask = frame_unwind_register_unsigned (this_frame, cmask_num); > - addr = addr & ~cmask; > + if (addr & 0x0080000000000000ULL) > + addr = addr | cmask; > + else > + addr = addr & ~cmask; > > /* Record in the frame that the link register required unmasking. */ > set_frame_previous_pc_masked (this_frame); > Could you please share more information about this problem? Why is it GDB needs to do things differently for a kernel mode and user mode address? What is the test setup? If we entered the above conditional block, that means DWARF has told GDB that LR is masked (ra_state_regnum), and so it needs to be unmasked. Given this is generic AArch64 code, we don't want to risk breaking existing use cases, and I'd like to understand what is not being handled properly. We have another gdbarch method that handles sign-extending kernel mode addresses (gdbarch_significant_addr_bit), but it is not clear if that could be used here without some examples. Thanks, Luis