From patchwork Thu Aug 22 15:11:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13773690 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 5AF21C3DA4A for ; Thu, 22 Aug 2024 15:12:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D412D6B0327; Thu, 22 Aug 2024 11:12:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF0556B0328; Thu, 22 Aug 2024 11:12:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B42E56B0329; Thu, 22 Aug 2024 11:12:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 947EA6B0327 for ; Thu, 22 Aug 2024 11:12:53 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4DCC214161D for ; Thu, 22 Aug 2024 15:12:53 +0000 (UTC) X-FDA: 82480223826.21.C09AD16 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf08.hostedemail.com (Postfix) with ESMTP id 885D3160025 for ; Thu, 22 Aug 2024 15:12:51 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724339490; 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=Q2RRx8rLkC5P4E8tx9Rk6lKwVPDwmtzasYWwFlURekc=; b=QZluXv6GRHc+EGU+ack24AzTIlp7mUfUStddBnOy/WgrmcleWec8/BD1eFjOAaxSblmo2+ FwiKrwJCGxCqPp/UVZWTTPcwPLYriVTc/N6SkNgh2xgRSHOEqxElWEpVZXkiXXkbzyAFAo OWi4ANmMTZ90Dr1d6SOqWiirYoMvIYw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724339490; a=rsa-sha256; cv=none; b=y+m0GYSgGcM36JAolNcaOHkBPzc9sNxyfOMlGvwFuh7vuwZKS5TX7igBj1Sm/sO2c37w86 1KUK2Fz2adtvKJMqaXyQmJjcsDGYvrP5rdxZwXmxzpccZxQBdxdef2wYWon79zjhX/YvXd D1nOFoQaUsShxU1O1S8v3rg20XlRZBc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 E136A1595; Thu, 22 Aug 2024 08:13:16 -0700 (PDT) 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 C28523F58B; Thu, 22 Aug 2024 08:12:46 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: nd@arm.com, akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, anshuman.khandual@arm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, skhan@linuxfoundation.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org Subject: [PATCH v5 20/30] arm64/ptrace: add support for FEAT_POE Date: Thu, 22 Aug 2024 16:11:03 +0100 Message-Id: <20240822151113.1479789-21-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240822151113.1479789-1-joey.gouly@arm.com> References: <20240822151113.1479789-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: h4nirgr18jmjqr8is465pcoftou98mhx X-Rspamd-Queue-Id: 885D3160025 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724339571-286971 X-HE-Meta: U2FsdGVkX18azekxLq7TcfXhmPqENdChPoXM60sPm1TmnQTmCx6jqZ6gOxQNgOdT9cAgvTQwVQg5WZmxDJAEzXrGbF6SOX4Ymgrl4hzbVAI5SvdvTFZwmeMDsPJJs+KAErCKI2lD4ZIH+1iRwH+FH8qMcdyHIMnCel337TsjEuEV14CNtOEJpdpdYzyX1Crp6szDfrBmYLxw3nop5g7sEwO6ytD4mG1OJUVBvV7A1FAgFJ2qyfDjnWWrNTpmlnq1JHs/0W/TwhtIcmUCoy/GXK5r9L5tk0GIpTP1l3vNZqKXJU3U2HXp8Spht5jWHLSKkIlJLZWvOkmGnHpvMPrnWN5uy0EVvESKgdxfzixq5/By5SHldEaG5GEu00oaQp9mbEaNJ7BJCBkgHpnOKbJ92jObI6dfXR+lkSoG3XYiX7Gs5KOGOZcBWcwElbvA3gfMk4oaf2P2U4NLBC6HJZk+DelbWUmgcbYnYcM99cgHZk7s2vDuzJHmX5n4sDPGzzEov4d3YJLlu7MOWMMY1wAA/mzv+E+godIAjjsnLDoljoDz5RfgsLbMgDGtuXrLnaMbti7AEz35uN3fOnpAAnVoBllX723WqsV8tm3gmO3Dd4MVvhGGgC2xe0rsLECuD88vi6+cjAZHmHI3Dv7kyDQePoSdyWcVzRcWc/G9+wnHpV72utHKZZPinDhNOk43sL7IBwNH7wrZ7fBPQiGcOQ4WI9ZX4/PIUbA6/86RhdOFCoCRimn8akYTMCH9mpjEaZPuto4wvueLsAhhsNR7urhBtzQg03mMMnlNvn3CuSueLQjqArZ/0pH6weiluDM7tt/BmJz3780d4eK4jfl6pgNa+ciyZG5e9RUGRSxPGzNygFvQtRFwd/LVduxT1Q9agWq5xRLtFYZXrQAj2RWHB7QioVSupGhrmETRGABywtubUGo69WduMWej3zFmEchupmHxLKS99AHvTWNAVZHjgZA iR2/MxpO dqduHslUx8wPPN5IBWLblZxspHh9I0m1m1tcRXTjRT570uBJWFM9LB8isGzvOhMi1h8Z3/EtwAjrrlnbVKL/YIdVNJlb1M0EfHh4fAUfsbtKJUXaNW7YOBJP0mry+wXOgk2C++7RNEfGJJiOSOPAHhbmWAfeIvoW4oJaZiotEK5JN77Z/TuBipkGudqt6pgJWfaZHeb9iXbbSzq67PPu3S0rjMM0VqPQhZdt1PfG/6qdoga2bpFp/+RFXJnRXMzVOexo9cZq5CuGEIXg= 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 Reviewed-by: Anshuman Khandual --- arch/arm64/kernel/ptrace.c | 46 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/elf.h | 1 + 2 files changed, 47 insertions(+) diff --git arch/arm64/kernel/ptrace.c arch/arm64/kernel/ptrace.c index 0d022599eb61..b756578aeaee 100644 --- arch/arm64/kernel/ptrace.c +++ arch/arm64/kernel/ptrace.c @@ -1440,6 +1440,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, @@ -1469,6 +1502,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[] = { @@ -1628,6 +1664,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 include/uapi/linux/elf.h include/uapi/linux/elf.h index b54b313bcf07..81762ff3c99e 100644 --- include/uapi/linux/elf.h +++ include/uapi/linux/elf.h @@ -441,6 +441,7 @@ typedef struct elf64_shdr { #define NT_ARM_ZA 0x40c /* ARM SME ZA registers */ #define NT_ARM_ZT 0x40d /* ARM SME ZT registers */ #define NT_ARM_FPMR 0x40e /* ARM floating point mode register */ +#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 */