From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150079.outbound.protection.outlook.com [40.107.15.79]) by sourceware.org (Postfix) with ESMTPS id 27B7B3858D1E for ; Tue, 4 Oct 2022 09:24:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 27B7B3858D1E ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=U7gQcpbGEAM6nTW694OkLOCq1MBvVLKYlb+w4YcDoewqTH9SEkIU0bpWpoBABOZOKm4W03v8rOf7cxL64oHbXZAqfdnn5iHeFlOPuIekoP1gO2wgOEyT9eSVAbWS5ooyOtAXV1lygyKQ6eWuTVQFZbFaInXr5oJIhuQXRS1b91LpWewHinugnTWc1DMMvqFa7+IE5QlYuYBD/Z04fuonWdL04H8Xk5AF3OoG3XkP6b1sEriF8Gg2csomO8NTYx45CvlZlc2anYHdgjyyNKg52giT8TecUdyxnhuIogGX6M1hAl0+KSUeSxzCOVpSd1qZU+YrW5nMnmVWHEwJ2RoIqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hWJ2IVnOob6f4FRevc0w+29cpMidUhYjmLHdT4uVcfU=; b=PfZMCEE4O5eT3XBvAk/q+BbqBk0Sxqb2WED7QEtcBxSIdiZBt9K2NnA5mRV2KYxcBj5xtcN4SeRgeIePnkwHbtgz/c9ihZnEUeF+d3Xc/48xfVAv3REier5AJdIS36SUOCld+JvUt33gspqMZF0nPMZWdzk0yfXr3oi46q788OKVSzcdA2/EiwDv+ZQ4bd8GkjeMYJUs6Od7TjFc13S0GE3RcOEkAi6xKdiGMcTdKREruVeCRM/1/SbDDX6TFL8M8/5afTr3g8aCWDf5w2gB/6D+m9Nf39TnNzez3dMVbidzBWiHNIIP+XVEDjNt+NCkoj9vBldPFw0AqcmFA6AyNg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from DB8PR06CA0025.eurprd06.prod.outlook.com (2603:10a6:10:100::38) by AS8PR08MB6629.eurprd08.prod.outlook.com (2603:10a6:20b:319::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Tue, 4 Oct 2022 09:24:24 +0000 Received: from DBAEUR03FT006.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:100:cafe::c7) by DB8PR06CA0025.outlook.office365.com (2603:10a6:10:100::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28 via Frontend Transport; Tue, 4 Oct 2022 09:24:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT006.mail.protection.outlook.com (100.127.142.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17 via Frontend Transport; Tue, 4 Oct 2022 09:24:24 +0000 Received: ("Tessian outbound 99ee3885c6d5:v128"); Tue, 04 Oct 2022 09:24:24 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 99c3a06a0cb4341d X-CR-MTA-TID: 64aa7808 Received: from 2b29d2cffee3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4BBF8317-FC35-4463-A501-B4A1AC0FA4EE.1; Tue, 04 Oct 2022 09:24:18 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2b29d2cffee3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 04 Oct 2022 09:24:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ScaffEXvZ1R6WkOQyQ+/6ul9WGE4HsF6FaV4RY+aeO4m93/XKY/P4Lv4KWsCz9iC7/th1LGbSqoHBavFCTuvY6aevytjn8qeAHqaYW+4vbEigp4TCpeIwd+hl1W4aIcO1zk/mPTEyiE1Ltw1HDSpkeui76rPo8UKeT70g8t+Z8weEdfxUMNjC8EPzMuQpUR9/7gZ+rtYpWCtYEdvq6KjXctCdF9pU5n8miIDz59Ar7Jhhbt3Xm4Tov6K4fcHURDt8xDY2+3T0J0oUFXJJYm3Ex1Y4q7xF5G0UTD9SHaf3LZFuej8SatefO1/01vdGXQw6x9l2gMJkw/JHcZcZiw4qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hWJ2IVnOob6f4FRevc0w+29cpMidUhYjmLHdT4uVcfU=; b=Y0YmwWnAp6xWuUH8CSpr2WMQPK7GqS/Q3JUKWhw3s04mi7tnrCJ7nN9vSUofRkCcgm1iZYPFMx0I0CJPpeJFVOuKgroYi1m4CTZC/fErnclkuCswhLK2OugqHTSvKz4K9FQxTZUbrGVylAudpCdECOU+XQ7Ae3wpDpkomeo5vpftHu44rhKkgQC5MOkPvlK7adJjKmLhv36YtmrgW7232vL2R9Vx7v4+lNCUpRDxKUckRb19c1sUvcNAq4tFQIwXG1W8MJOGMBq1+fARnh10RdiyhQckBuys3mDd5Dy3ibLt+c0ca3kC40funQhPgWXbIKaY2e54Zz4t2fV1Qoim6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by DU0PR08MB8469.eurprd08.prod.outlook.com (2603:10a6:10:407::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Tue, 4 Oct 2022 09:24:14 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::c5f9:a25b:a5f2:6094]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::c5f9:a25b:a5f2:6094%5]) with mapi id 15.20.5676.028; Tue, 4 Oct 2022 09:24:13 +0000 Message-ID: Date: Tue, 4 Oct 2022 10:24:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] AArch64 pauth: Support backtrace in EL1 (kernel space) Content-Language: en-US To: Koudai Iwahori , gdb-patches@sourceware.org References: <20220928025909.190260-1-koudai@google.com> From: Luis Machado In-Reply-To: <20220928025909.190260-1-koudai@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0124.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::21) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|DU0PR08MB8469:EE_|DBAEUR03FT006:EE_|AS8PR08MB6629:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b32e2aa-88f7-4ca4-d100-08daa5ea3a5c x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: CwwJu6U6CvfkDH8o8D9jci85NPTcfGKDNw7MHD0+/QcMjmEQZ/v/shhPswBH8nYJk5F/QnxgpuFFNwp6nJ894a0mHlZiF+ofC4xoTbab6JA8Q912d/AQ4RQ5EQmJOPeberybYmxZCcrCuBDhY6G3dU4h/lC6ZSFIpgJ8tqALRKjd5JwZ6yrKbbemX/3WC0uoBn3IxnuVZl+B/QyctHBQDLawWWd25n4Qw2xDSc50Pk3Zz3wKttuydWJWpHC5pFgHrNeAiJBxk0GbjzHztKncIhRgB3jMWEpDsLSsQ09VMYlZl11NQo2SV/mFAVvPMzJi/Gn6V/gcZgu4rjFMg+VJabzb441HUlMvpQ8TC/c7ETxJzl1krnG8Ib6YMEeS/9/wlGtoGW/87amoZeNNHX/1jZgz4Ps4fCU7TBv9L4QSw6hBlN6To9QzVuUqnDvsKxytL0o5aCBgmXO47uOFB6pTO2iZKLqED3zQVTS+ToxNtv7dHFOQ4at6vx3R9FCU/btfEItMXI5zM32To5hwF/RpTgyDnbIG+qVOZ8rjyH+AH5OBpdYyj3yzOZVJww4Yxjcl+wiIx+HAoUwpx8hpjhyfDIS0LMe6gdj2wU1IKcK5SBrGDTkvvC/XfkbJLvilFlSQkOVvvEhheCIKpHxJbKDRDNqHj7C4+7gB8e7jRuBkxswTB+bWU6tqMWHaG4U3224IPi1QTCvDkMhUcf4F5k0xP5eAJEYouzjiEsjchM/iDt4ufDtt1CPojNfA++yc2M5L3ZARmBAZmb/mGpSHtX+NCnWA5CrqSGfmX437VjiSE62+9xpwKVJvYwNlaA6LyGuzoUE+GsTTb8qdTZpB+wc3tIN+9BTNfk88mTX4At/JYL0= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB3919.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(346002)(376002)(39860400002)(396003)(366004)(136003)(451199015)(66556008)(6486002)(8676002)(38100700002)(66946007)(6512007)(2616005)(316002)(83380400001)(26005)(53546011)(186003)(6506007)(478600001)(36756003)(31696002)(86362001)(8936002)(31686004)(66476007)(966005)(44832011)(5660300002)(2906002)(41300700001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8469 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: cf4b8a38-334f-45c5-a73f-08daa5ea3379 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jo8UsEPn16TRwmMX2wIS5R4dbDQLgI0w+uHQN874UQ3nd/ZiXmuAxvmaZBPsQhIL2QU1H2lkgcK+NZRPFgio42p9OWhbRUeDp4ThMdJEqiDfNd6pg7ntzAzvYo6EfqywYvrrXmhng06HrNFjtFVcyhF6Vi2H4ejIdoyWPttVxbAErHEHf8Z1mQlu3yZPaDbbsrERslt2oPqdmgKrUSPzva2M4BhEiIELly8/R3fWjMD200MsTFKz0Ar+0QYDs643ttzsVZBo/yDgPm/wa3DT4YLztPczu4AMy18PqK2jfbCPFh91cu78mnychibgcrK2Muv+pOkq7kzc0SwZlk2pfZnDshRE2BsD8JIfsqhXkOQMPd4GJOKilROS0R6LfNd6+XVw/UDOmndJR0oQaex1nfn4N6ewsp6zsDpoCEyM1WVJfh/ER/BL0EfPp9qH3dFGOs4Z93wgE6Y/gDoOHMbHfvnzuO1nCQGVZtcYwvLHWbKaoKwH4S2ccvtggLoe/pF9nNmp73Yyg9MyBOu5gfRR+dhx5H85GPKYhQtmYxBMf/iEqpXS7lm0gCs7o6kxzEwNkVvu1mZK7Tcy1url+bsXIUr16SuOK10fIyGwTr34Dqe8zwcFmSpyF26sPCHJTDQNUX5KqYhJAGzgRZ+m2aJdYuPKhiOTV+PHymMPJm8fYoQvCeDyAPzJLEgNRsGyaBbbugHX1Ae6gO28mmSIkuF0obIhSx5Pb7ndUezlrl2nRmanHPhpIxQZqHdStWTugF++dQrKauCZLnO0tKx7QBQ9LPlYgKQaoZ7SoVMfJ8TRjgIWP6ET99pp4nvJMHk2/7HfTT6Gb4rDACJuGxcJ/n+k7/JLbzG1r6E+5gtctb3DBXk= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(346002)(396003)(376002)(451199015)(46966006)(40470700004)(36840700001)(44832011)(5660300002)(31686004)(41300700001)(2906002)(86362001)(31696002)(336012)(47076005)(186003)(2616005)(26005)(6512007)(316002)(40480700001)(356005)(8676002)(81166007)(70206006)(70586007)(36756003)(40460700003)(8936002)(82740400003)(83380400001)(82310400005)(53546011)(966005)(6486002)(6506007)(478600001)(36860700001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2022 09:24:24.6438 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b32e2aa-88f7-4ca4-d100-08daa5ea3a5c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6629 X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY 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, 04 Oct 2022 09:24:33 -0000 Hi, On 9/28/22 03:59, Koudai Iwahori via Gdb-patches wrote: > The way to remove the signature bits from the address depends on the > 55th bit of the address. If 55th bit is zero, the signature bits should > be all cleared. If the 55th bit is one, the signature bits should be all > set. > --- > I found very similar patches after fixing this issue: > https://sourceware.org/pipermail/gdb-patches/2022-July/190507.html > https://sourceware.org/pipermail/gdb-patches/2021-October/182859.html > If this issue will be fixed in the near future, I can wait for it Yes, it should be fixed by the first link above. It is pending approval from maintainers, which should hopefully happen soon. I also have an upcoming patch (that relies on the above patch) to support pauth for user-mode QEMU. See https://sourceware.org/bugzilla/show_bug.cgi?id=29421. > > gdb/aarch64-tdep.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > index d0387044934..16d1e44e903 100644 > --- a/gdb/aarch64-tdep.c > +++ b/gdb/aarch64-tdep.c > @@ -244,6 +244,20 @@ class instruction_reader : public abstract_instruction_reader > > } // namespace > > +/* removes the pauth signature bits from the address. */ > + > +static CORE_ADDR > +aarch64_remove_pauth_signature (CORE_ADDR addr, CORE_ADDR mask) > +{ > + /* 55th bit in address determines whether the address comes from the top > + address range or the bottom address range. */ > + constexpr CORE_ADDR pauth_va_range_select_mask = CORE_ADDR(1) << 55; > + if (addr & pauth_va_range_select_mask) > + return addr | mask; > + else > + return addr & ~mask; > +} > + > /* If address signing is enabled, mask off the signature bits from the link > register, which is passed by value in ADDR, using the register values in > THIS_FRAME. */ > @@ -258,7 +272,7 @@ aarch64_frame_unmask_lr (aarch64_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; > + addr = aarch64_remove_pauth_signature(addr, cmask); > > /* Record in the frame that the link register required unmasking. */ > set_frame_previous_pc_masked (this_frame);