From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0D85C433E0 for ; Wed, 27 Jan 2021 15:18:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51FE9207FB for ; Wed, 27 Jan 2021 15:18:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51FE9207FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=63xjAvNttiRE4k0rhJDPs92BKLmClRIBvd/fdZO76+I=; b=nIQDqyzyisElTD7/v73RiwJLL 1QsYtkPvH3UkZtuAUxheMd0/5+VwBdC4IoKgUKAtAqEBlTFSlf8SaTaIZgRpS+rFRJLNg9375R2ye 9vRWCcN+z3mJJklejCE1XGFtgwM1woXqieH5kM1owtQeNSLBTbXGrmKogFduUihxQ1QoE3cP7P1yf 6+YZMYyruEoLlFRp0e9esMcftT46/qfFVdNMSlPV6VEJtUtaD8EhmMCRgrBiU7spOH2z6/DW642lF bm4xQIrFRHcpJf33Tw2Cy3Z5U9CBo5vMCn7Y9Gvd97wVuCF1aAirAPUkdPEPdEUAsxlBtgpcRnzEI qBNKqd6iA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4mY7-0004SN-Ij; Wed, 27 Jan 2021 15:16:03 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4mXs-0003b1-Qj for linux-arm-kernel@merlin.infradead.org; Wed, 27 Jan 2021 15:15:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5zCrkt/FpHlReuReVOjjtDBOpSHFFx2z5GAf+V8UuRA=; b=rhRrmQrq7jsb9gqfwtzwA269TS Z0p2BHfNq4i4Tzu0i3bNy0qIErbltXt8AvrqZu5uDv6Qw8LY8KmFl8DQmebwhAETivsD4UGpNrGOq mvRbZzNubPwl3u05Q9DW6QvFyKFWRXXuKk9jDzp9UJH558b1oIduOb2ScNkxkyMnXtVlwKZcnJ/+I iKYfoygzrBl0kmyYGdp66ndvA6DMKBBzBnNpVkb/BtRd4kYQh50E0dXsdBKGGNVWIBJ+0bhC+MkRD zFYIqPqU2aEAZ+iTQJ4hI5eYooo65keMQ1lH+WyEF4VGB6M9UeHw+d9wcs12nKwhQhdznS1KGregk HHCCmZkQ==; Received: from foss.arm.com ([217.140.110.172]) by casper.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1l4mFc-0078ku-7o for linux-arm-kernel@lists.infradead.org; Wed, 27 Jan 2021 14:57:06 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7B90631B; Wed, 27 Jan 2021 06:53:26 -0800 (PST) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 932273F66B; Wed, 27 Jan 2021 06:53:25 -0800 (PST) Date: Wed, 27 Jan 2021 14:53:07 +0000 From: Dave Martin To: Andrei Vagin Subject: Re: [PATCH 2/3] arm64/ptrace: introduce NT_ARM_PRSTATUS to get a full set of registers Message-ID: <20210127145304.GC13952@arm.com> References: <20210119220637.494476-1-avagin@gmail.com> <20210119220637.494476-3-avagin@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210119220637.494476-3-avagin@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210127_145706_582459_B88C5A26 X-CRM114-Status: GOOD ( 23.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Will Deacon , Oleg Nesterov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jan 19, 2021 at 02:06:36PM -0800, Andrei Vagin wrote: > This is an alternative to NT_PRSTATUS that clobbers ip/r12 on AArch32, > x7 on AArch64 when a tracee is stopped in syscall entry or syscall exit > traps. > > Signed-off-by: Andrei Vagin This approach looks like it works, though I still think adding an option for this under PTRACE_SETOPTIONS would be less intrusive. Adding a shadow regset like this also looks like it would cause the gp regs to be pointlessly be dumped twice in a core dump. Avoiding that might require hacks in the core code... > --- > arch/arm64/kernel/ptrace.c | 39 ++++++++++++++++++++++++++++++++++++++ > include/uapi/linux/elf.h | 1 + > 2 files changed, 40 insertions(+) > > diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c > index 1863f080cb07..b8e4c2ddf636 100644 > --- a/arch/arm64/kernel/ptrace.c > +++ b/arch/arm64/kernel/ptrace.c > @@ -591,6 +591,15 @@ static int gpr_get(struct task_struct *target, > return ret; > } > > +static int gpr_get_full(struct task_struct *target, > + const struct user_regset *regset, > + struct membuf to) > +{ > + struct user_pt_regs *uregs = &task_pt_regs(target)->user_regs; > + > + return membuf_write(&to, uregs, sizeof(*uregs)); > +} > + > static int gpr_set(struct task_struct *target, const struct user_regset *regset, > unsigned int pos, unsigned int count, > const void *kbuf, const void __user *ubuf) > @@ -1088,6 +1097,7 @@ static int tagged_addr_ctrl_set(struct task_struct *target, const struct > > enum aarch64_regset { > REGSET_GPR, > + REGSET_GPR_FULL, If we go with this approach, "REGSET_GPR_RAW" might be a preferable name. Both regs represent all the regs ("full"), but REGSET_GPR is mangled by the kernel. > REGSET_FPR, > REGSET_TLS, > #ifdef CONFIG_HAVE_HW_BREAKPOINT > @@ -1119,6 +1129,14 @@ static const struct user_regset aarch64_regsets[] = { > .regset_get = gpr_get, > .set = gpr_set > }, > + [REGSET_GPR_FULL] = { > + .core_note_type = NT_ARM_PRSTATUS, Similarly, something like NT_ARM_PRSTATUS_RAW or similar. > + .n = sizeof(struct user_pt_regs) / sizeof(u64), > + .size = sizeof(u64), > + .align = sizeof(u64), > + .regset_get = gpr_get_full, > + .set = gpr_set > + }, > [REGSET_FPR] = { > .core_note_type = NT_PRFPREG, > .n = sizeof(struct user_fpsimd_state) / sizeof(u32), > @@ -1225,6 +1243,7 @@ static const struct user_regset_view user_aarch64_view = { > #ifdef CONFIG_COMPAT > enum compat_regset { > REGSET_COMPAT_GPR, > + REGSET_COMPAT_GPR_FULL, > REGSET_COMPAT_VFP, > }; > > @@ -1285,6 +1304,18 @@ static int compat_gpr_get(struct task_struct *target, > return 0; > } > > +/* compat_gpr_get_full doesn't overwrite x12 like compat_gpr_get. */ > +static int compat_gpr_get_full(struct task_struct *target, > + const struct user_regset *regset, > + struct membuf to) > +{ > + int i = 0; > + > + while (to.left) > + membuf_store(&to, compat_get_user_reg(target, i++)); > + return 0; > +} > + > static int compat_gpr_set(struct task_struct *target, > const struct user_regset *regset, > unsigned int pos, unsigned int count, > @@ -1435,6 +1466,14 @@ static const struct user_regset aarch32_regsets[] = { > .regset_get = compat_gpr_get, > .set = compat_gpr_set > }, > + [REGSET_COMPAT_GPR_FULL] = { > + .core_note_type = NT_ARM_PRSTATUS, > + .n = COMPAT_ELF_NGREG, > + .size = sizeof(compat_elf_greg_t), > + .align = sizeof(compat_elf_greg_t), > + .regset_get = compat_gpr_get_full, > + .set = compat_gpr_set > + }, > [REGSET_COMPAT_VFP] = { > .core_note_type = NT_ARM_VFP, > .n = VFP_STATE_SIZE / sizeof(compat_ulong_t), > diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h > index 30f68b42eeb5..a2086d19263a 100644 > --- a/include/uapi/linux/elf.h > +++ b/include/uapi/linux/elf.h > @@ -426,6 +426,7 @@ typedef struct elf64_shdr { > #define NT_ARM_PACA_KEYS 0x407 /* ARM pointer authentication address keys */ > #define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication generic key */ > #define NT_ARM_TAGGED_ADDR_CTRL 0x409 /* arm64 tagged address control (prctl()) */ What happened to 0x40a..0x40f? [...] Cheers ---Dave _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel