From patchwork Fri Nov 24 16:35:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13467933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFFF8C61DF4 for ; Fri, 24 Nov 2023 16:36:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E8156B030A; Fri, 24 Nov 2023 11:36:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 798A96B030B; Fri, 24 Nov 2023 11:36:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C3B46B030C; Fri, 24 Nov 2023 11:36:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 46D986B030A for ; Fri, 24 Nov 2023 11:36:09 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2CB9516081A for ; Fri, 24 Nov 2023 16:36:09 +0000 (UTC) X-FDA: 81493400058.18.95ED3F7 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 73DB4180020 for ; Fri, 24 Nov 2023 16:36:07 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700843767; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KQg1S9SBa+etKovpoUsRwjUZF7axhk62vnYRSJEkciQ=; b=tTPj5EtkQtIDm4Kv/BR000pdJgeBlFqGQ0/1Mb+xiqCLAoius6gUhsms3FDFOSzXeN8try X7cNrMs/8Mi4PDGPxua17y11jU6YdsHFsZ9MV50HCgwOMWtfV6ESbhOj4QWNwpQ736Fqt8 S8pxY79y2bZeYJy+2C76D7i7YBZZ+Wo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700843767; a=rsa-sha256; cv=none; b=1zlsIaObZ1+pUw+OSlX9WtDyQiNozz3h0p9BJSv2U+UvQMJtc2ChOFaAXk5jkXwB9QReBu VjCWWb978xnVpx+QhepltlA/8/ytCX+EerkGh/2/9Pqf7KGMXb/dyh3q8Wy5jz/okNNafu YYsrXNVTYLOUfQnjqgcEGouVvTvI9wc= 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 213D01BCA; Fri, 24 Nov 2023 08:36:53 -0800 (PST) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 718883F73F; Fri, 24 Nov 2023 08:36:04 -0800 (PST) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@linux.ibm.com, broonie@kernel.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, joey.gouly@arm.com, maz@kernel.org, oliver.upton@linux.dev, shuah@kernel.org, will@kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu Subject: [PATCH v3 18/25] arm64/ptrace: add support for FEAT_POE Date: Fri, 24 Nov 2023 16:35:03 +0000 Message-Id: <20231124163510.1835740-19-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231124163510.1835740-1-joey.gouly@arm.com> References: <20231124163510.1835740-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 73DB4180020 X-Stat-Signature: 1pa6ta8ggm6mmbs4r85r8yibdrhaen6r X-HE-Tag: 1700843767-501274 X-HE-Meta: U2FsdGVkX1+k8HJNda8u/Qzo+1KQM9htgRITOCmEgdazVM8DhFJUgXdb0uN0GRIiEdX/hzpDvWsaJI31beyduxMikjEVcgDFEGfMLHC5wrRPNhDueFYu1P4G/S6wKQFSYRauD14Xr+Xs+GG2zQlbKiPebUyDPHZjjMoGno8w9CPv7n30QEK6CJK0YZHlsbJw4+pswPIHTFqo0JssHNDyBhvqacNu3vb4IpjwnxXXzGY1JeYYSRGG4BVA/XaEjfXxsVFIYxIZejxvAw9VMej90O6OSEpVcw87aX6WDR/6YlvyJ+QAcEFQ8++FVWByyvj4JeoqDeV3s7Ka4t7mj31GzZZ9eAYw5whPIpp5vdkGaS07zCRCiASfFLLnWUEK9vhUe3GqQWHRiYiMYKYDaVlIfiwSQKLUfr+O1SFSZBOvVuNA7v13JCVMdOwOv833DYGPPJOjK74PO/ulICjog9ZXVgU7PFR4aWye+qH01ruxp/JNyNUE+BCYoaCfOJDj1X0Wvdw03YEaztcj5/of0mJwzZz1LIVHf/bwYLpSlYUckqi7Xi10h8K/DMwpjmsWTyysRrklGN6c4Hs5s6WasGqT9v0kfKo77EIsf0JqyeGzfRLoRQDuF/2dnoBoGzFuDdOoN/6TOAC5o9wRH+cJkp6j4HBSrmZ7s/z0vinfAnAyP+BeYLrGOyhqMJqLr2KTWXFTOzz+pfaul219sg9xR7xP2AavPLv3Nov/FFbJXyti73I6lUELhCh23LBefHWqiFQBx+Va1TSICD2e7Prxs+MibHE5jQYGwaNLxu8IxKgjL9caATRl9chxcoHHYCT4KR5n3iOv8OUP2d64aMOuNOlI/E2XlQpzY1zhTfYyPJTmSyFiWqDy6r8/aHROwJl3Y8yKM4tizUugyCm/Sxn0ns+WvUYUaF7/iUXgmiVkQTpNdWiHEtG+CTohe7hakxqmGvZbeGxi3dHFFRfOdI058A2 AyOOWlrj LUgM8mNXOUijGaLAbahA1aYnRziQI1t9D6yuPt3cfadgZ6TqG/f7NdHhQBsfMnn9bJ1Ekj/+AmCp7CTwoN/vKQUcV/E/wgzBYVpoHoaB5h1tShjfDpEP2FEgwtt9LQzp5yMI/8a/DRD8asAiRE/566EvnncPR0erySfmDhExSb1w047B6NNfojHwl2QkKdcoUdaHoYMwU43TwPVdmIpAKFsxDTVtRQxY1ie7b1pS7UurI5PkK9EgvxjOUc1cD2Sn1uxlahF6ixmFhpsk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a regset for POE containing POR_EL0. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Mark Brown Reviewed-by: Catalin Marinas --- arch/arm64/kernel/ptrace.c | 46 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/elf.h | 1 + 2 files changed, 47 insertions(+) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 20d7ef82de90..c3257a5c97f1 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1409,6 +1409,39 @@ static int tagged_addr_ctrl_set(struct task_struct *target, const struct } #endif +#ifdef CONFIG_ARM64_POE +static int poe_get(struct task_struct *target, + const struct user_regset *regset, + struct membuf to) +{ + if (!system_supports_poe()) + return -EINVAL; + + return membuf_write(&to, &target->thread.por_el0, + sizeof(target->thread.por_el0)); +} + +static int poe_set(struct task_struct *target, const struct + user_regset *regset, unsigned int pos, + unsigned int count, const void *kbuf, const + void __user *ubuf) +{ + int ret; + long ctrl; + + if (!system_supports_poe()) + return -EINVAL; + + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl, 0, -1); + if (ret) + return ret; + + target->thread.por_el0 = ctrl; + + return 0; +} +#endif + enum aarch64_regset { REGSET_GPR, REGSET_FPR, @@ -1437,6 +1470,9 @@ enum aarch64_regset { #ifdef CONFIG_ARM64_TAGGED_ADDR_ABI REGSET_TAGGED_ADDR_CTRL, #endif +#ifdef CONFIG_ARM64_POE + REGSET_POE +#endif }; static const struct user_regset aarch64_regsets[] = { @@ -1587,6 +1623,16 @@ static const struct user_regset aarch64_regsets[] = { .set = tagged_addr_ctrl_set, }, #endif +#ifdef CONFIG_ARM64_POE + [REGSET_POE] = { + .core_note_type = NT_ARM_POE, + .n = 1, + .size = sizeof(long), + .align = sizeof(long), + .regset_get = poe_get, + .set = poe_set, + }, +#endif }; static const struct user_regset_view user_aarch64_view = { diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index 9417309b7230..f2713efcd81b 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -440,6 +440,7 @@ typedef struct elf64_shdr { #define NT_ARM_SSVE 0x40b /* ARM Streaming SVE registers */ #define NT_ARM_ZA 0x40c /* ARM SME ZA registers */ #define NT_ARM_ZT 0x40d /* ARM SME ZT registers */ +#define NT_ARM_POE 0x40f /* ARM POE registers */ #define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */ #define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note */ #define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */