lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240319171714.76342-1-ubizjak@gmail.com>
Date: Tue, 19 Mar 2024 18:16:46 +0100
From: Uros Bizjak <ubizjak@...il.com>
To: x86@...nel.org,
	linux-kernel@...r.kernel.org
Cc: Uros Bizjak <ubizjak@...il.com>,
	Yu-cheng Yu <yu-cheng.yu@...el.com>,
	Rick Edgecombe <rick.p.edgecombe@...el.com>,
	Borislav Petkov <bp@...en8.de>,
	Kees Cook <keescook@...omium.org>,
	Mike Rapoport <rppt@...nel.org>,
	Ingo Molnar <mingo@...nel.org>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	Andy Lutomirski <luto@...nel.org>,
	"H . Peter Anvin" <hpa@...or.com>
Subject: [PATCH] x86/asm: Use "m" operand constraint in WRUSSQ asm template

The WRUSSQ instruction uses a memory operand, so use "m"
operand constraint instead of forcing usage of pointer
register using "r" constraint. The generated assembly
code improves from:

   6ece3:	48 8d 43 f8          	lea    -0x8(%rbx),%rax
   ...
   6eceb:	66 48 0f 38 f5 18    	wrussq %rbx,(%rax)

to:

   6ecea:	66 48 0f 38 f5 43 f8 	wrussq %rax,-0x8(%rbx)

Signed-off-by: Uros Bizjak <ubizjak@...il.com>
Cc: Yu-cheng Yu <yu-cheng.yu@...el.com>
Cc: Rick Edgecombe <rick.p.edgecombe@...el.com>
Cc: Borislav Petkov (AMD) <bp@...en8.de>
Cc: Kees Cook <keescook@...omium.org>
Cc: Mike Rapoport (IBM) <rppt@...nel.org>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: H. Peter Anvin <hpa@...or.com>
---
 arch/x86/include/asm/special_insns.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
index 0ee2ba589492..aec6e2d3aa1d 100644
--- a/arch/x86/include/asm/special_insns.h
+++ b/arch/x86/include/asm/special_insns.h
@@ -205,9 +205,9 @@ static inline void clwb(volatile void *__p)
 #ifdef CONFIG_X86_USER_SHADOW_STACK
 static inline int write_user_shstk_64(u64 __user *addr, u64 val)
 {
-	asm goto("1: wrussq %[val], (%[addr])\n"
+	asm goto("1: wrussq %[val], %[addr]\n"
 			  _ASM_EXTABLE(1b, %l[fail])
-			  :: [addr] "r" (addr), [val] "r" (val)
+			  :: [addr] "m" (*addr), [val] "r" (val)
 			  :: fail);
 	return 0;
 fail:
-- 
2.42.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ