From patchwork Wed Mar 6 13:33:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 31734 Received: (qmail 35394 invoked by alias); 6 Mar 2019 13:33:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 35248 invoked by uid 89); 6 Mar 2019 13:33:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=accessed X-HELO: EUR04-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr70055.outbound.protection.outlook.com (HELO EUR04-HE1-obe.outbound.protection.outlook.com) (40.107.7.55) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Mar 2019 13:33:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KTSbK3XvOgWW2s04+RhAC+gkkEDqUpYvw5//Sn406Wg=; b=HNJNdAGcOOl/sthUNf0WwNVYFivm3SQzLtM5BLes5lGOlQk0gnn497j6ZJzgrnsgIfArjM2iWOGrmd/aGMjL+0RHXwCHKrvg3SZj32KobZJWxwc5aERFaLanz47M9osBf6yNbRJkv+TTtzpMh7hX4b4NnTmBxsoBuAiuovTtg+c= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2262.eurprd08.prod.outlook.com (10.172.227.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.19; Wed, 6 Mar 2019 13:33:36 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::e974:35a7:c83c:e5b7]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::e974:35a7:c83c:e5b7%3]) with mapi id 15.20.1686.018; Wed, 6 Mar 2019 13:33:36 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [PATCH v2 4/8] AArch64: gdbserver: read pauth registers Date: Wed, 6 Mar 2019 13:33:35 +0000 Message-ID: <20190306133325.2531-5-alan.hayward@arm.com> References: <20190306133325.2531-1-alan.hayward@arm.com> In-Reply-To: <20190306133325.2531-1-alan.hayward@arm.com> received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-IsSubscribed: yes Add the pauth registers to the regset lists. Add a new regset type OPTIONAL_REGS which allows for the regset read to fail. Once the read fails, it will not be checked again. This allows targets with optional features to keep a single static regset_info structure. gdb/ChangeLog: 2019-03-06 Alan Hayward Jiong Wang * arch/aarch64.h (AARCH64_PAUTH_REGS_SIZE): New define. gdb/gdbserver/ChangeLog: 2019-03-06 Alan Hayward Jiong Wang * linux-aarch64-low.c (aarch64_store_pauthregset): New function. * linux-low.c (regsets_store_inferior_registers): Allow optional reads to fail. * linux-low.h (enum regset_type): Add OPTIONAL_REGS. --- gdb/arch/aarch64.h | 1 + gdb/gdbserver/linux-aarch64-low.c | 23 +++++++++++++++++++++++ gdb/gdbserver/linux-low.c | 14 ++++++++------ gdb/gdbserver/linux-low.h | 1 + 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h index 8c80b7be62..309fe75273 100644 --- a/gdb/arch/aarch64.h +++ b/gdb/arch/aarch64.h @@ -68,6 +68,7 @@ enum aarch64_regnum #define AARCH64_PAUTH_DMASK_REGNUM(pauth_reg_base) (pauth_reg_base) #define AARCH64_PAUTH_CMASK_REGNUM(pauth_reg_base) (pauth_reg_base + 1) +#define AARCH64_PAUTH_REGS_SIZE (16) #define AARCH64_X_REGS_NUM 31 #define AARCH64_V_REGS_NUM 32 diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index e2e25f0e27..20c75493b0 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -135,6 +135,23 @@ aarch64_store_fpregset (struct regcache *regcache, const void *buf) supply_register (regcache, AARCH64_FPCR_REGNUM, ®set->fpcr); } +/* Store the pauth registers to regcache. */ + +static void +aarch64_store_pauthregset (struct regcache *regcache, const void *buf) +{ + uint64_t *pauth_regset = (uint64_t *) buf; + int pauth_base = find_regno (regcache->tdesc, "pauth_dmask"); + + if (pauth_base == 0) + return; + + supply_register (regcache, AARCH64_PAUTH_DMASK_REGNUM (pauth_base), + &pauth_regset[0]); + supply_register (regcache, AARCH64_PAUTH_CMASK_REGNUM (pauth_base), + &pauth_regset[1]); +} + /* Enable miscellaneous debugging output. The name is historical - it was originally used to debug LinuxThreads support. */ extern int debug_threads; @@ -564,6 +581,9 @@ static struct regset_info aarch64_regsets[] = sizeof (struct user_fpsimd_state), FP_REGS, aarch64_fill_fpregset, aarch64_store_fpregset }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK, + AARCH64_PAUTH_REGS_SIZE, OPTIONAL_REGS, + NULL, aarch64_store_pauthregset }, NULL_REGSET }; @@ -590,6 +610,9 @@ static struct regset_info aarch64_sve_regsets[] = SVE_PT_SIZE (AARCH64_MAX_SVE_VQ, SVE_PT_REGS_SVE), EXTENDED_REGS, aarch64_sve_regs_copy_from_regcache, aarch64_sve_regs_copy_to_regcache }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK, + AARCH64_PAUTH_REGS_SIZE, OPTIONAL_REGS, + NULL, aarch64_store_pauthregset }, NULL_REGSET }; diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 8c5a51f23c..e1cb7fcfbc 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -5359,10 +5359,11 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, #endif if (res < 0) { - if (errno == EIO) + if (errno == EIO + || (errno == EINVAL && regset->type == OPTIONAL_REGS)) { - /* If we get EIO on a regset, do not try it again for - this process mode. */ + /* If we get EIO on a regset, or an EINVAL and the regset is + optional, do not try it again for this process mode. */ disable_regset (regsets_info, regset); } else if (errno == ENODATA) @@ -5457,10 +5458,11 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info, if (res < 0) { - if (errno == EIO) + if (errno == EIO + || (errno == EINVAL && regset->type == OPTIONAL_REGS)) { - /* If we get EIO on a regset, do not try it again for - this process mode. */ + /* If we get EIO on a regset, or an EINVAL and the regset is + optional, do not try it again for this process mode. */ disable_regset (regsets_info, regset); } else if (errno == ESRCH) diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index d09390dd99..1ade35d648 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -40,6 +40,7 @@ enum regset_type { GENERAL_REGS, FP_REGS, EXTENDED_REGS, + OPTIONAL_REGS, /* Do not error if the regset cannot be accessed. */ }; /* The arch's regsets array initializer must be terminated with a NULL