From patchwork Wed Jan 15 11:13:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Celeste Liu X-Patchwork-Id: 13940318 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38127C02185 for ; Wed, 15 Jan 2025 11:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h3Jg2ovBupT+AAq+B5pIhqBQ4huPbgD1dFJomP0YtKo=; b=InQLg59TeYU4Vp VosT5gZ3sUCkg3xdIVHOq3LWf/xZYR5gmkHY9FykXy0rpJdH4WvUrgzZk8hx8NSdds7wDHH+vt/9f yKMeYZNYF6rwm7h4fD+eEeqoFUUoXZon6imJ+c8OvyYNdKEhtT9bz00A0igkhzp7XmIdlt2+hYb+X zGhJpFxPkRRtRfIf1csMVVijGNKIqtON+cmN7YiXgp7pmWqmZUNvE1llaRdBapdbWPIgdhk1pQE9j +i/7p54O3vlGmq+wxi6K8bHUWmAVQOAa/Xx/aAl2rTp4Nyaojw24Qfj+g9Uw3xh0Y2iftsXHoch7n SuLVU+FVuajHAeGZNobQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tY1Po-0000000Be3I-3Z0P; Wed, 15 Jan 2025 11:18:28 +0000 Received: from flow-a3-smtp.messagingengine.com ([103.168.172.138]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tY1Ll-0000000BdAt-2NYJ for linux-riscv@lists.infradead.org; Wed, 15 Jan 2025 11:14:19 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailflow.phl.internal (Postfix) with ESMTP id EB8BD200F84; Wed, 15 Jan 2025 06:14:16 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Wed, 15 Jan 2025 06:14:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= coelacanthus.name; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1736939656; x=1736946856; bh=WfiGYnphGq vudtD6RXFjAbGTohKPfJnsfNrRsHzlEL4=; b=bMtaM99wg2t0sGsWBBr9DRK+d4 6ElpWK4uVOU6I3S3fC5DrwS6XS5Bop4pBipUtYzdgo4tTPDBqilV9gQjblb7pgKW ZThERb5+upl9p5jRj57trl5UY5G6X2fdNebgjKdTBbk3bj83Kam9brdokLXr8JZ8 sm/eCiITI9F33g6DwKwtci7MDQ3jW5GpP8Vq0mtdZYzxCQqwass2ShGCvnRPmesg XbYrGe0uVK1I6L/cI3kppZskPKPTdMOvWypAUCdu3h7I+FB5NF/w884oue9CZ61/ 7q8cgJu5xGBsC4KeuTZaxkZCi6zyvvQ20ysPThLy0CZU5UqFks8YOFrG2z0Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1736939656; x= 1736946856; bh=WfiGYnphGqvudtD6RXFjAbGTohKPfJnsfNrRsHzlEL4=; b=v wKAEsDy3E1Ykbo7zHQnkulDZ0dw9Uq6wZLJvdF2P1jPNEiKelP0sTZHWecUpSK4E bZStqGKG+BWi+Jjfx5jbblUqXArW/EGqqg14euV5qQYyzba7tFTFLGOSeQb/hO2w BhJ/RVMEp3kiuEfKLJNM3uARulwsZNbAZ7MMiV+QizNSIKk76aOoNQ5bxToWdwJe 5o41MBSDvENrjJidvtEzU66HcKY8fRr5if0H+hCPb+OwmayemsQU48Q5BuaJM2wR ju6vialqhZEfzvRe44PPV3Y3senx75wSOtZz2WJsQh2SJV8sZWdQfOAjzh4hBWXP mi+rHqlywRwL0ECEM7ydg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudehlecutefuodetggdotefrodftvfcurf hrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffrtefo kffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsuc dlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfh rhhomhepvegvlhgvshhtvgcunfhiuhcuoehufihusegtohgvlhgrtggrnhhthhhushdrnh grmhgvqeenucggtffrrghtthgvrhhnpeeuiefgudffleffgeeiffeffeefieelveejgfeh hfejffeutedvffeiudevtdelgeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepuhifuhestgho vghlrggtrghnthhhuhhsrdhnrghmvgdpnhgspghrtghpthhtohepvdejpdhmohguvgepsh hmthhpohhuthdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghr nhgvlhdrohhrghdprhgtphhtthhopehlughvsehsthhrrggtvgdrihhopdhrtghpthhtoh eptghhrghrlhhivgesrhhivhhoshhinhgtrdgtohhmpdhrtghpthhtohepsghjohhrnhes khgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhhuhgrhheskhgvrhhnvghlrdhorhhgpd hrtghpthhtoheprhgvseifiehriidrnhgvthdprhgtphhtthhopegvsghivgguvghrmhes gihmihhsshhiohhnrdgtohhmpdhrtghpthhtohepiihhohhuqhhurghnsehishgtrghsrd grtgdrtghnpdhrtghpthhtoheplhhinhhugidqkhhsvghlfhhtvghsthesvhhgvghrrdhk vghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i95c648bc:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 15 Jan 2025 06:14:14 -0500 (EST) From: Celeste Liu Date: Wed, 15 Jan 2025 19:13:27 +0800 Subject: [PATCH v6 1/3] riscv/ptrace: add new regset to access original a0 register MIME-Version: 1.0 Message-Id: <20250115-riscv-new-regset-v6-1-59bfddd33525@coelacanthus.name> References: <20250115-riscv-new-regset-v6-0-59bfddd33525@coelacanthus.name> In-Reply-To: <20250115-riscv-new-regset-v6-0-59bfddd33525@coelacanthus.name> To: Oleg Nesterov , Paul Walmsley , Palmer Dabbelt , Eric Biederman , Kees Cook , Shuah Khan , Albert Ou Cc: Alexandre Ghiti , "Dmitry V. Levin" , Andrea Bolognani , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Ron Economos , Charlie Jenkins , Andrew Jones , Quan Zhou , Felix Yan , Ruizhe Pan , Guo Ren , Yao Zi , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Celeste Liu , stable@vger.kernel.org, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3197; i=uwu@coelacanthus.name; h=from:subject:message-id; bh=Bd0I0lIMKMC4KxEOjUIKWSGVerkNEic9IL2ALFZ+R48=; b=owJ4nJvAy8zAJeafov85RWVtBeNptSSG9PYZ5VutbCad5Tn5ndOR38uJYV7Dv+6vnvq+FfPTO Y/NcE6L4e4oZWEQ42KQFVNkySth+cl56Wz33o7tXTBzWJlAhjBwcQrAROaGMTI8d991KlKo4aFX I19XSsrdpJofD4xDWCJfvDU3FFGb/7qL4X8Ux5rc0wu8ddemZqSnL2Bb/XjS3wA172m/l4Umzts xwZIDAL8wRz0= X-Developer-Key: i=uwu@coelacanthus.name; a=openpgp; fpr=892EBC7DC392DFF9C9C03F1D15F4180E73787863 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250115_031417_743003_8F6DF995 X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The orig_a0 is missing in struct user_regs_struct of riscv, and there is no way to add it without breaking UAPI. (See Link tag below) Like NT_ARM_SYSTEM_CALL do, we add a new regset name NT_RISCV_ORIG_A0 to access original a0 register from userspace via ptrace API. Fixes: e2c0cdfba7f6 ("RISC-V: User-facing API") Link: https://lore.kernel.org/all/59505464-c84a-403d-972f-d4b2055eeaac@gmail.com/ Cc: stable@vger.kernel.org Reviewed-by: Björn Töpel Signed-off-by: Celeste Liu --- arch/riscv/kernel/ptrace.c | 32 ++++++++++++++++++++++++++++++++ include/uapi/linux/elf.h | 1 + 2 files changed, 33 insertions(+) diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c index ea67e9fb7a583683b922fe2c017ea61f3bc848db..ef9ab74c8575a5c440155973b1c625c06a867c97 100644 --- a/arch/riscv/kernel/ptrace.c +++ b/arch/riscv/kernel/ptrace.c @@ -31,6 +31,7 @@ enum riscv_regset { #ifdef CONFIG_RISCV_ISA_SUPM REGSET_TAGGED_ADDR_CTRL, #endif + REGSET_ORIG_A0, }; static int riscv_gpr_get(struct task_struct *target, @@ -184,6 +185,29 @@ static int tagged_addr_ctrl_set(struct task_struct *target, } #endif +static int riscv_orig_a0_get(struct task_struct *target, + const struct user_regset *regset, + struct membuf to) +{ + return membuf_store(&to, task_pt_regs(target)->orig_a0); +} + +static int riscv_orig_a0_set(struct task_struct *target, + const struct user_regset *regset, + unsigned int pos, unsigned int count, + const void *kbuf, const void __user *ubuf) +{ + unsigned long orig_a0 = task_pt_regs(target)->orig_a0; + int ret; + + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &orig_a0, 0, -1); + if (ret) + return ret; + + task_pt_regs(target)->orig_a0 = orig_a0; + return 0; +} + static const struct user_regset riscv_user_regset[] = { [REGSET_X] = { .core_note_type = NT_PRSTATUS, @@ -224,6 +248,14 @@ static const struct user_regset riscv_user_regset[] = { .set = tagged_addr_ctrl_set, }, #endif + [REGSET_ORIG_A0] = { + .core_note_type = NT_RISCV_ORIG_A0, + .n = 1, + .size = sizeof(elf_greg_t), + .align = sizeof(elf_greg_t), + .regset_get = riscv_orig_a0_get, + .set = riscv_orig_a0_set, + }, }; static const struct user_regset_view riscv_user_native_view = { diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index b44069d29cecc0f9de90ee66bfffd2137f4275a8..390060229601631da2fb27030d9fa2142e676c14 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -452,6 +452,7 @@ typedef struct elf64_shdr { #define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */ #define NT_RISCV_VECTOR 0x901 /* RISC-V vector registers */ #define NT_RISCV_TAGGED_ADDR_CTRL 0x902 /* RISC-V tagged address control (prctl()) */ +#define NT_RISCV_ORIG_A0 0x903 /* RISC-V original a0 register */ #define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */ #define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and status registers */ #define NT_LOONGARCH_LSX 0xa02 /* LoongArch Loongson SIMD Extension registers */ From patchwork Wed Jan 15 11:13:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Celeste Liu X-Patchwork-Id: 13940320 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DD55C02185 for ; Wed, 15 Jan 2025 11:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1w/NuckK+Ga2kL7jHyO3YS7SxFB/21+vKjb5J8qerqc=; b=gJipb/ONjk0TD7 TVSu3bN5vvNS1GlZuRQv/Ia5Iob6xe5GM2y6zLX1FJWGbgAKwAGTojPU8DSsUmyYE3tSBr4VKMadg 89dEt2xZxZHi9FNzDDwkEfaoG8jni60P2AUcuEXf2/VO5TzKtBvjvtDOBCXNS7ML6Vfon4+HbswwT 943qgR92Vhj9YNB/fp+Z7XA0lE0oW18fHuhmyq2TJCco28L+N6gVihnlw01VI4h1s4p5jTFw3GWvU gCNPVBvrL9NF9/+yowuQ62wGqzOmYBqxy5EwSARwW4inbkI+aj1LcuVssCui6qQ0i55tOjhXmGQya dkm4xJJTDwExDHVU6VXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tY1Pp-0000000Be3N-1npa; Wed, 15 Jan 2025 11:18:29 +0000 Received: from flow-a3-smtp.messagingengine.com ([103.168.172.138]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tY1Lp-0000000BdDm-0iZm for linux-riscv@lists.infradead.org; Wed, 15 Jan 2025 11:14:22 +0000 Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailflow.phl.internal (Postfix) with ESMTP id 92B7F200FE6; Wed, 15 Jan 2025 06:14:20 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Wed, 15 Jan 2025 06:14:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= coelacanthus.name; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1736939660; x=1736946860; bh=cefyME3vts v5sxq1SOu8UxjoNujymAivw3tNwb5ahHc=; b=oRHyd1GLCtmaP88DZ05pDtICaK OXw8OwHKrV8RGJieDIm5D9l6iNnei/l4hT99f4K8RrtFscZE6ICqqnnLU+ZfQ3MU uruFIOmMbeQN0voNVhU+se82GeGFwSzrV8lY+yHw/KdaQCTIrl9uTyqP1r+OwLPu xXcpeWGpLHTZ23FFOUKh/Xy0aAj18F793ZXbThyN0dxM2NOZloQ7P4gxeMXMgCbn siNJlN3Aq0SbrlqJJNZgsa1Qq0E1u/VG0+pnUT2MRdYtHE8rlvxwbewJXdbA1B4R +Tbpbj79cJg8NRFyqaTWdirdQqnDQHlYVHkepAorS9CVeJvPngCgxZSljYLg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1736939660; x= 1736946860; bh=cefyME3vtsv5sxq1SOu8UxjoNujymAivw3tNwb5ahHc=; b=i LhZEEsE7v4/MIZ3/8d3eXsH7iCiNgXMU3vV3irR8cGwgPliFyOSWdZKRyITcV5ZX eX8lLYDKBG2uB5SqnUsCdlNrRGrYoWCnFZqy8PJeQ8d3ECqs1sxktl9oSgbF3/N2 kDWKqpFRkzqWl945myxuK6xbmVhNYChPxQpmOo8PCU/VPrGE24ruw0hsPNd6xVkB pTwhSFPAQte67aj4lyF9Fp5RW67iYRNYXMNnXUxnjbC/5boKWoEnA2omvs3D9uf1 Jtc5zrNPWAXSiF/YgiAFRPiwkKZ7b4wzCRQWozO+WOxFv4RTgogUj2aMS7n9+jUp 0UtHD1+TMLJgS4kJXiOfg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudehlecutefuodetggdotefrodftvfcurf hrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffrtefo kffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsuc dlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfh rhhomhepvegvlhgvshhtvgcunfhiuhcuoehufihusegtohgvlhgrtggrnhhthhhushdrnh grmhgvqeenucggtffrrghtthgvrhhnpeeiteejtdevjeffgfehkeegfeelkeekvdehtdeg leevhfetheejheejiedtjeegteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehufihusegtohgvlhgrtggrnhhthhhushdrnhgrmhgvpdhnsggp rhgtphhtthhopedvhedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheplhhinhhugi dqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhguvhes shhtrhgrtggvrdhiohdprhgtphhtthhopegthhgrrhhlihgvsehrihhvohhsihhntgdrtg homhdprhgtphhtthhopegsjhhorhhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehs hhhurghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrvgesfieirhiirdhnvghtpd hrtghpthhtohepvggsihgvuggvrhhmseigmhhishhsihhonhdrtghomhdprhgtphhtthho peiihhhouhhquhgrnhesihhstggrshdrrggtrdgtnhdprhgtphhtthhopehlihhnuhigqd hkshgvlhhfthgvshhtsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i95c648bc:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 15 Jan 2025 06:14:19 -0500 (EST) From: Celeste Liu Date: Wed, 15 Jan 2025 19:13:28 +0800 Subject: [PATCH v6 2/3] tools: copy include/linux/stddef.h to tools/include MIME-Version: 1.0 Message-Id: <20250115-riscv-new-regset-v6-2-59bfddd33525@coelacanthus.name> References: <20250115-riscv-new-regset-v6-0-59bfddd33525@coelacanthus.name> In-Reply-To: <20250115-riscv-new-regset-v6-0-59bfddd33525@coelacanthus.name> To: Oleg Nesterov , Paul Walmsley , Palmer Dabbelt , Eric Biederman , Kees Cook , Shuah Khan , Albert Ou Cc: Alexandre Ghiti , "Dmitry V. Levin" , Andrea Bolognani , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Ron Economos , Charlie Jenkins , Andrew Jones , Quan Zhou , Felix Yan , Ruizhe Pan , Guo Ren , Yao Zi , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Celeste Liu X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4577; i=uwu@coelacanthus.name; h=from:subject:message-id; bh=WV0NqvqtTK1mWkN78Oo6GA0cv0m8xWUUF/b/ZrqzqEo=; b=owJ4nJvAy8zAJeafov85RWVtBeNptSSG9PYZFdHJnxQvWgTnrrt4QWqTwV/zbd1fOHm+8piqL H7LlzfPIKCjlIVBjItBVkyRJa+E5SfnpbPdezu2d8HMYWUCGcLAxSkAE6ncz8iw/93V6o+mZ8wn SyYeMDt4u+nxizae6PPGbtsbv/s84zRlZPif1tGg3LzHjPPH7vwT/EXzzTbECkmeEP4343DKkhA j9i9cANkLSSY= X-Developer-Key: i=uwu@coelacanthus.name; a=openpgp; fpr=892EBC7DC392DFF9C9C03F1D15F4180E73787863 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250115_031421_287417_44C9436A X-CRM114-Status: GOOD ( 16.98 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Some macro defined in stddef.h are useful and have been used in many code in selftests. Copy them to tools/include so developers needn't create their copy in every files. Remove some definitions like NULL and true/false to be suitable to non-kernel environment. Signed-off-by: Celeste Liu Reviewed-by: Andrew Jones --- tools/include/linux/stddef.h | 85 +++++++++++++++++++++++++++++++++++++++ tools/include/uapi/linux/stddef.h | 6 +-- 2 files changed, 87 insertions(+), 4 deletions(-) diff --git a/tools/include/linux/stddef.h b/tools/include/linux/stddef.h new file mode 100644 index 0000000000000000000000000000000000000000..55f3964d9a3d9f9f9345a75248eec027c56faef9 --- /dev/null +++ b/tools/include/linux/stddef.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_STDDEF_H +#define _LINUX_STDDEF_H + +#include + +/** + * sizeof_field() - Report the size of a struct field in bytes + * + * @TYPE: The structure containing the field of interest + * @MEMBER: The field to return the size of + */ +#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) + +/** + * offsetofend() - Report the offset of a struct field within the struct + * + * @TYPE: The type of the structure + * @MEMBER: The member within the structure to get the end offset of + */ +#define offsetofend(TYPE, MEMBER) \ + (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) + +/** + * struct_group() - Wrap a set of declarations in a mirrored struct + * + * @NAME: The identifier name of the mirrored sub-struct + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical + * layout and size: one anonymous and one named. The former can be + * used normally without sub-struct naming, and the latter can be + * used to reason about the start, end, and size of the group of + * struct members. + */ +#define struct_group(NAME, MEMBERS...) \ + __struct_group(/* no tag */, NAME, /* no attrs */, MEMBERS) + +/** + * struct_group_attr() - Create a struct_group() with trailing attributes + * + * @NAME: The identifier name of the mirrored sub-struct + * @ATTRS: Any struct attributes to apply + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical + * layout and size: one anonymous and one named. The former can be + * used normally without sub-struct naming, and the latter can be + * used to reason about the start, end, and size of the group of + * struct members. Includes structure attributes argument. + */ +#define struct_group_attr(NAME, ATTRS, MEMBERS...) \ + __struct_group(/* no tag */, NAME, ATTRS, MEMBERS) + +/** + * struct_group_tagged() - Create a struct_group with a reusable tag + * + * @TAG: The tag name for the named sub-struct + * @NAME: The identifier name of the mirrored sub-struct + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical + * layout and size: one anonymous and one named. The former can be + * used normally without sub-struct naming, and the latter can be + * used to reason about the start, end, and size of the group of + * struct members. Includes struct tag argument for the named copy, + * so the specified layout can be reused later. + */ +#define struct_group_tagged(TAG, NAME, MEMBERS...) \ + __struct_group(TAG, NAME, /* no attrs */, MEMBERS) + +/** + * DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union + * + * @TYPE: The type of each flexible array element + * @NAME: The name of the flexible array member + * + * In order to have a flexible array member in a union or alone in a + * struct, it needs to be wrapped in an anonymous struct with at least 1 + * named member, but that member can be empty. + */ +#define DECLARE_FLEX_ARRAY(TYPE, NAME) \ + __DECLARE_FLEX_ARRAY(TYPE, NAME) + +#endif diff --git a/tools/include/uapi/linux/stddef.h b/tools/include/uapi/linux/stddef.h index bb6ea517efb51177a7983fadad9b590b12b786e5..f2548fd95f6e1d8cb218d52918bb81a3317d10b1 100644 --- a/tools/include/uapi/linux/stddef.h +++ b/tools/include/uapi/linux/stddef.h @@ -1,8 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _LINUX_STDDEF_H -#define _LINUX_STDDEF_H - - +#ifndef _UAPI_LINUX_STDDEF_H +#define _UAPI_LINUX_STDDEF_H #ifndef __always_inline #define __always_inline __inline__ From patchwork Wed Jan 15 11:13:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Celeste Liu X-Patchwork-Id: 13940319 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A7BEC02183 for ; Wed, 15 Jan 2025 11:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/YL6pT2UPLvLfYk6wbKFVn+HCfXiWhr73S9kGxm7xko=; b=t62WJcYWG0CB2U PmFJs5izIfO115nJBvLW6bXn/1CVi64RpJX4rkBvr/utXfl6BP4ZJv1Uiyqi9QE904YM58frPqUli BuuWJ1LgogJxgFoZ+p1wdpHpUfmJafNOA29oau2aUSKKcnZwE1f4dxr2ETj2K84LCb+6ppSnRRCmx JaCzCD0RzuMBl+Y6Qy2oGRPENYd+FKzCm2jT6puffeqvIIdwjtZs3Gr3LlQdfRPM9rM2O3nxp7oNp PHju0UZ8spcnnxl4yutl+e07vI4LGD5pbuznUUpcw/V3yCgZlNZHGTKHD3SZPTABNAtRdmaRinnmz zmR2RyK88pjmDQ16UX/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tY1Pq-0000000Be4A-08GR; Wed, 15 Jan 2025 11:18:30 +0000 Received: from flow-a3-smtp.messagingengine.com ([103.168.172.138]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tY1Lt-0000000BdHK-38t2 for linux-riscv@lists.infradead.org; Wed, 15 Jan 2025 11:14:27 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailflow.phl.internal (Postfix) with ESMTP id 238A0200B08; Wed, 15 Jan 2025 06:14:25 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Wed, 15 Jan 2025 06:14:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= coelacanthus.name; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1736939665; x=1736946865; bh=4xCU5bJlFw 3YObn7QvVHHfcB2ZV7lt3TH8aNCek14IU=; b=F/A5egxhBf5H3gcxEqys0v01xj uVyinEXETnAltCxxWZU85mI8e/whH+DU31DMgdN9kBPjcUoIUOGkEX8qScIyYMr1 o597TwbWRDnmhKbE17LnPZ1G6h69VLo35mF4F4qJc1jbEKfaNx0rulED7YXGhvkx Mx2/8lysPtvN3AAE/BHbvO1DtPAXtLWMTCDHsvFy2SOutkJqhsnXzv/OdViq8Ef6 WhMc3z5vhzXv4ZXBM6TKHbBmGTAT23NJndqYjN4R/ZwgErdK6b2+/5miKQUTQqjp M/2ePhRfhTRGiJQuny59l1mcDLXLudxDVxgoB1Nn1QHUu0fwya/RjUBUDG7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1736939665; x= 1736946865; bh=4xCU5bJlFw3YObn7QvVHHfcB2ZV7lt3TH8aNCek14IU=; b=U XYZP7upwfhpYO7b3Bh0t3mFHFa7oQGx7lAlPGvJotwmleotu9axflSo31Y9Vwe4g jJDZvLbDji/myJ8bL/YqrK68ypkYLDD9D39im6DqtXjM++sL73cKmG/Q/emt7FPj uxgl2TtjqfFQTX0D2R0TCP4IrwjoAl+8Kk67MkF204xb1OAzz5J72e/0KY+/tI+5 zMfNn4ZV/eUPj59TFnOwpAtBsACpuePm2dKirPh4Ti9HxXGJezQ9x5MXP0SgYVeg kWZX4Em6bQD2IG4I91wPOVzsdXZx1PBbMtdX6GwoDNhKehe2mN5eqau4mGX2V6iY 52hFjwpJN6sUeUg/R+eSw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudehlecutefuodetggdotefrodftvfcurf hrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffrtefo kffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsuc dlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfh rhhomhepvegvlhgvshhtvgcunfhiuhcuoehufihusegtohgvlhgrtggrnhhthhhushdrnh grmhgvqeenucggtffrrghtthgvrhhnpeeiudegfffhtdeuuddufefhfefhheejjefhueek hefffeeugfeuveetieeuvddtfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehufihusegtohgvlhgrtggrnhhthhhushdrnhgrmhgvpdhnsggp rhgtphhtthhopedviedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheplhhinhhugi dqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhguvhes shhtrhgrtggvrdhiohdprhgtphhtthhopegthhgrrhhlihgvsehrihhvohhsihhntgdrtg homhdprhgtphhtthhopegsjhhorhhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehs hhhurghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrvgesfieirhiirdhnvghtpd hrtghpthhtohepvggsihgvuggvrhhmseigmhhishhsihhonhdrtghomhdprhgtphhtthho peiihhhouhhquhgrnhesihhstggrshdrrggtrdgtnhdprhgtphhtthhopehlihhnuhigqd hkshgvlhhfthgvshhtsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i95c648bc:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 15 Jan 2025 06:14:23 -0500 (EST) From: Celeste Liu Date: Wed, 15 Jan 2025 19:13:29 +0800 Subject: [PATCH v6 3/3] riscv: selftests: Add a ptrace test to verify a0 and orig_a0 access MIME-Version: 1.0 Message-Id: <20250115-riscv-new-regset-v6-3-59bfddd33525@coelacanthus.name> References: <20250115-riscv-new-regset-v6-0-59bfddd33525@coelacanthus.name> In-Reply-To: <20250115-riscv-new-regset-v6-0-59bfddd33525@coelacanthus.name> To: Oleg Nesterov , Paul Walmsley , Palmer Dabbelt , Eric Biederman , Kees Cook , Shuah Khan , Albert Ou Cc: Alexandre Ghiti , "Dmitry V. Levin" , Andrea Bolognani , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Ron Economos , Charlie Jenkins , Andrew Jones , Quan Zhou , Felix Yan , Ruizhe Pan , Guo Ren , Yao Zi , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Celeste Liu , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7629; i=uwu@coelacanthus.name; h=from:subject:message-id; bh=Esi60fF9RlKXqJX1LQ4xzxGmVZGZ6ydahIA2pcSWvhk=; b=owJ4nJvAy8zAJeafov85RWVtBeNptSSG9PYZlZrxmZzfjuzXVKn/fO+kRYvi076gR63iJmvSN N7W8G/6ta+jlIVBjItBVkyRJa+E5SfnpbPdezu2d8HMYWUCGcLAxSkAE2mZzsiw+3jzJa4sGe2F bwRa+Sa1zQhjKtudc51ratgxmQnM2SrZjAx7y1cGS02MvfnwCWfmuzl7Zl5glPNXPx3obrbG08x apoMfAL2mRho= X-Developer-Key: i=uwu@coelacanthus.name; a=openpgp; fpr=892EBC7DC392DFF9C9C03F1D15F4180E73787863 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250115_031425_930983_4BA9118A X-CRM114-Status: GOOD ( 19.95 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This test checks that orig_a0 and a0 can be modified and accessed independently. Co-developed-by: Quan Zhou Signed-off-by: Quan Zhou Co-developed-by: Charlie Jenkins Signed-off-by: Charlie Jenkins Reviewed-by: Björn Töpel Signed-off-by: Celeste Liu Reviewed-by: Andrew Jones --- tools/testing/selftests/riscv/abi/.gitignore | 1 + tools/testing/selftests/riscv/abi/Makefile | 6 +- tools/testing/selftests/riscv/abi/ptrace.c | 193 +++++++++++++++++++++++++++ 3 files changed, 199 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/riscv/abi/.gitignore b/tools/testing/selftests/riscv/abi/.gitignore index b38358f91c4d2240ae64892871d9ca98bda1ae58..378c605919a3b3d58eec2701eb7af430cfe315d6 100644 --- a/tools/testing/selftests/riscv/abi/.gitignore +++ b/tools/testing/selftests/riscv/abi/.gitignore @@ -1 +1,2 @@ pointer_masking +ptrace diff --git a/tools/testing/selftests/riscv/abi/Makefile b/tools/testing/selftests/riscv/abi/Makefile index ed82ff9c664e7eb3f760cbab81fb957ff72579c5..359a082c88a401883fb3776b35e4dacf69beaaaa 100644 --- a/tools/testing/selftests/riscv/abi/Makefile +++ b/tools/testing/selftests/riscv/abi/Makefile @@ -1,10 +1,14 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -I$(top_srcdir)/tools/include +CFLAGS += $(KHDR_INCLUDES) -TEST_GEN_PROGS := pointer_masking +TEST_GEN_PROGS := pointer_masking ptrace include ../../lib.mk $(OUTPUT)/pointer_masking: pointer_masking.c $(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^ + +$(OUTPUT)/ptrace: ptrace.c + $(CC) -static -o$@ $(CFLAGS) $(LDFLAGS) $^ diff --git a/tools/testing/selftests/riscv/abi/ptrace.c b/tools/testing/selftests/riscv/abi/ptrace.c new file mode 100644 index 0000000000000000000000000000000000000000..cbd60462021165ca2bcc38be24b8423c96047b93 --- /dev/null +++ b/tools/testing/selftests/riscv/abi/ptrace.c @@ -0,0 +1,193 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../kselftest_harness.h" + +#define ORIG_A0_MODIFY 0x01 +#define A0_MODIFY 0x02 +#define A0_OLD 0xbadbeefbeeff +#define A0_NEW 0xffeebfeebdab + + +struct a0_regs { + __s64 orig_a0; + __u64 a0; +}; + +#define perr_and_exit(fmt, ...) \ + ({ \ + char buf[256]; \ + snprintf(buf, sizeof(buf), "%s:%d:" fmt ": %m\n", \ + __func__, __LINE__, ##__VA_ARGS__); \ + ksft_exit_fail_perror(buf); \ + }) + +static void ptrace_test(int opt, struct a0_regs result[]) +{ + int status; + long rc; + pid_t pid; + struct user_regs_struct regs; + struct iovec iov = { + .iov_base = ®s, + .iov_len = sizeof(regs), + }; + + unsigned long orig_a0; + struct iovec a0_iov = { + .iov_base = &orig_a0, + .iov_len = sizeof(orig_a0), + }; + struct ptrace_syscall_info syscall_info = { + .op = 0xff, + }; + const unsigned int expected_sci_entry_size = + offsetofend(struct ptrace_syscall_info, entry.args); + const unsigned int expected_sci_exit_size = + offsetofend(struct ptrace_syscall_info, exit.is_error); + + pid = fork(); + if (pid == 0) { + /* Mark oneself being traced */ + long val = ptrace(PTRACE_TRACEME, 0, 0, 0); + + if (val < 0) + perr_and_exit("failed to request for tracer to trace me: %ld", val); + + kill(getpid(), SIGSTOP); + + /* Perform chdir syscall that will be intercepted */ + syscall(__NR_chdir, A0_OLD); + + exit(0); + } + + if (pid < 0) + ksft_exit_fail_perror("failed to fork"); + + for (int i = 0; i < 3; i++) { + if (waitpid(pid, &status, 0) != pid) + perr_and_exit("failed to wait for the tracee %d", pid); + if (WIFSTOPPED(status)) { + switch (WSTOPSIG(status)) { + case SIGSTOP: + if (ptrace(PTRACE_SETOPTIONS, pid, 0, PTRACE_O_TRACESYSGOOD) < 0) + perr_and_exit("failed to set PTRACE_O_TRACESYSGOOD"); + break; + case SIGTRAP|0x80: + /* Modify twice so GET_SYSCALL_INFO get modified a0 and orig_a0 */ + if (ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov)) + perr_and_exit("failed to get tracee registers"); + if (ptrace(PTRACE_GETREGSET, pid, NT_RISCV_ORIG_A0, &a0_iov)) + perr_and_exit("failed to get tracee registers"); + + /* Modify a0/orig_a0 for the syscall */ + switch (opt) { + case A0_MODIFY: + regs.a0 = A0_NEW; + break; + case ORIG_A0_MODIFY: + orig_a0 = A0_NEW; + break; + } + + if (ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, &iov)) + perr_and_exit("failed to set tracee registers"); + if (ptrace(PTRACE_SETREGSET, pid, NT_RISCV_ORIG_A0, &a0_iov)) + perr_and_exit("failed to set tracee registers"); + switch (i) { + case 1: + /* Stop at the beginning of syscall */ + rc = ptrace(PTRACE_GET_SYSCALL_INFO, pid, + sizeof(syscall_info), &syscall_info); + if (rc < 0) + perr_and_exit("failed to get syscall info of entry"); + if (rc < expected_sci_entry_size + || syscall_info.op != PTRACE_SYSCALL_INFO_ENTRY) + perr_and_exit("stop position of entry mismatched"); + result[0].orig_a0 = syscall_info.entry.args[0]; + break; + + case 2: + /* Stop at the end of syscall */ + rc = ptrace(PTRACE_GET_SYSCALL_INFO, pid, + sizeof(syscall_info), &syscall_info); + if (rc < 0) + perr_and_exit("failed to get syscall info of entry"); + if (rc < expected_sci_exit_size + || syscall_info.op != PTRACE_SYSCALL_INFO_EXIT) + perr_and_exit("stop position of exit mismatched"); + result[0].a0 = syscall_info.exit.rval; + + if (ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov)) + perr_and_exit("failed to get tracee registers"); + result[1].a0 = regs.a0; + if (ptrace(PTRACE_GETREGSET, pid, NT_RISCV_ORIG_A0, + &a0_iov)) + perr_and_exit("failed to get tracee registers"); + result[1].orig_a0 = orig_a0; + } + } + if (ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) + perr_and_exit("failed to resume tracee"); + } + } + + /* Resume the tracee */ + ptrace(PTRACE_CONT, pid, 0, 0); + if (waitpid(pid, &status, 0) != pid) + perr_and_exit("failed to wait for the tracee"); + +} + +TEST(ptrace_access_a0) +{ + struct a0_regs result[2]; + + ptrace_test(A0_MODIFY, result); + + /* Verify PTRACE_SETREGSET */ + /* The modification of a0 cannot affect the first argument of the syscall */ + EXPECT_EQ(A0_OLD, result[0].orig_a0); + EXPECT_EQ(A0_NEW, result[0].a0); + + /* Verify PTRACE_GETREGSET */ + EXPECT_EQ(result[1].orig_a0, result[0].orig_a0); + EXPECT_EQ(result[1].a0, result[0].a0); +} + +TEST(ptrace_access_orig_a0) +{ + struct a0_regs result[2]; + + ptrace_test(ORIG_A0_MODIFY, result); + + /* Verify PTRACE_SETREGSET */ + /* Only modify orig_a0 to change the first argument of the syscall */ + EXPECT_EQ(A0_NEW, result[0].orig_a0); + /* a0 will not be affected */ + EXPECT_NE(A0_NEW, result[0].a0); + + /* Verify PTRACE_GETREGSET */ + EXPECT_EQ(result[1].orig_a0, result[0].orig_a0); + EXPECT_EQ(result[1].a0, result[0].a0); +} + +TEST_HARNESS_MAIN