From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09991436BF4 for ; Thu, 30 Jul 2026 13:27:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785418023; cv=none; b=q9ezwhmtQ1wURN20ZK5DG3rSa2amSAkQDKeFwFWfMEuncnODrz/XdwaZSQ8gXuuGPXM5PlkIm0OCLh8m0EOqVesy76svR0g3TJvHIHih8l0DQDEZXbPFWN0/FHEFoziSs3G1e10qH6GabXVlOcP3YmS5/ZUQm2RV6TgXe71bM3k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785418023; c=relaxed/simple; bh=8hd+AyhdmKYLAhHq+PWKmQlY4ieK11tAF8Fh8rfFSWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CiFEz4zUxJHPGD2zW/CoFgET37cGzh9hrLSDyJvaqFfczvDGL9D2eXjcJn3k9VLe119KFbZDUxhqMZBbwCmwvYYB4TET8FEVF81IhrH7ze19looXN0CZHryV8/gLUo5K/TMBhqGkFbWpYqBowiJBSoQm5NxxNRDFcXdXCI4+dtk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EU/Sx5QV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EU/Sx5QV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EE491F000E9; Thu, 30 Jul 2026 13:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785418021; bh=mXptIvD3yImJlDeKXQJCzH7xA2WLNgQI67OtSBoKL1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EU/Sx5QVqNfdlnf76o8KYIiD9/vSjv6k3QuEFUHlqdha3wKQ8tNw55N0lWbpEx8i4 ZxTENCn7Na/UqPPzfbbTMCmDs1vzc4HiK2jmGYas6lpJfEsT/ub1TqSnq9YcE4iUcc /dpfovu2RKwzvjV4850HIBoUFa7bqRuVVLUZDcxaKrhJzv71BjkbeMy4fdpq/q8PT/ eTswDURsoHASai4mrDMrvLcEHka3KUnwM4X1kYqsPTysTC7hHC6zj3bjnSWGysJoYb KGOp3SD/zw3AFs06tY+JkT8vuO/CtedvGNGU5IbWwFFz6TQDH40j5/GESZiSeQIt9U MIQEyiAqXMg2A== From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Will Deacon , Kees Cook , Jinjie Ruan , Mark Rutland Subject: [PATCH v4 2/2] arm64: syscall: Pass 'orig_x0' as first argument to native system call Date: Thu, 30 Jul 2026 14:26:51 +0100 Message-ID: <20260730132651.25993-3-will@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260730132651.25993-1-will@kernel.org> References: <20260730132651.25993-1-will@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit syscall_get_arguments() returns 'regs->orig_x0' for the first system call argument so as to avoid aliasing with the syscall return value in 'regs->regs[0]' on the return path, however the actual syscall invocation passes 'regs->regs[0]' as the first parameter. Although the two registers should be kept in sync during syscall entry for native tasks, pass 'regs->orig_x0' as the first syscall parameter for consistency with the syscall argument APIs. Compat tasks continue to use 'regs->regs[0]' for compatibility with the behaviour of the 32-bit kernel. Suggested-by: Jinjie Ruan Signed-off-by: Will Deacon --- arch/arm64/include/asm/syscall_wrapper.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/syscall_wrapper.h b/arch/arm64/include/asm/syscall_wrapper.h index abb57bc54305..395152ef5372 100644 --- a/arch/arm64/include/asm/syscall_wrapper.h +++ b/arch/arm64/include/asm/syscall_wrapper.h @@ -10,13 +10,13 @@ #include -#define SC_ARM64_REGS_TO_ARGS(x, ...) \ +#ifdef CONFIG_COMPAT + +#define COMPAT_SC_ARM64_REGS_TO_ARGS(x, ...) \ __MAP(x,__SC_ARGS \ ,,regs->regs[0],,regs->regs[1],,regs->regs[2] \ ,,regs->regs[3],,regs->regs[4],,regs->regs[5]) -#ifdef CONFIG_COMPAT - #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs); \ ALLOW_ERROR_INJECTION(__arm64_compat_sys##name, ERRNO); \ @@ -24,7 +24,7 @@ static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs) \ { \ - return __se_compat_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \ + return __se_compat_sys##name(COMPAT_SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \ } \ static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ { \ @@ -46,6 +46,11 @@ #endif /* CONFIG_COMPAT */ +#define SC_ARM64_REGS_TO_ARGS(x, ...) \ + __MAP(x,__SC_ARGS \ + ,,regs->orig_x0,,regs->regs[1],,regs->regs[2] \ + ,,regs->regs[3],,regs->regs[4],,regs->regs[5]) + #define __SYSCALL_DEFINEx(x, name, ...) \ asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \ ALLOW_ERROR_INJECTION(__arm64_sys##name, ERRNO); \ -- 2.55.0.508.g3f0d502094-goog