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: <20250506165227.158932-1-ubizjak@gmail.com>
Date: Tue,  6 May 2025 18:52:06 +0200
From: Uros Bizjak <ubizjak@...il.com>
To: x86@...nel.org,
	linux-kernel@...r.kernel.org
Cc: Uros Bizjak <ubizjak@...il.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...nel.org>,
	Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	"H. Peter Anvin" <hpa@...or.com>
Subject: [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions

Use inout "+" constraint modifier where appropriate and declare
temporary variable using __auto_type, similar to what x86_64 does.

No functional changes intended.

Signed-off-by: Uros Bizjak <ubizjak@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
---
 arch/x86/include/asm/string_32.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h
index e9cce169bb4c..9152d2c0f60e 100644
--- a/arch/x86/include/asm/string_32.h
+++ b/arch/x86/include/asm/string_32.h
@@ -164,12 +164,12 @@ extern void *memchr(const void *cs, int c, size_t count);
 
 static inline void *__memset_generic(void *s, char c, size_t count)
 {
-	int d0, d1;
+	const __auto_type s0 = s;
 	asm volatile("rep stosb"
-		     : "=&c" (d0), "=&D" (d1)
-		     : "a" (c), "1" (s), "0" (count)
+		     : "+D" (s), "+c" (count)
+		     : "a" (c)
 		     : "memory");
-	return s;
+	return s0;
 }
 
 /* we might want to write optimized versions of these later */
@@ -197,23 +197,23 @@ extern void *memset(void *, int, size_t);
 #define __HAVE_ARCH_MEMSET16
 static inline void *memset16(uint16_t *s, uint16_t v, size_t n)
 {
-	int d0, d1;
+	const __auto_type s0 = s;
 	asm volatile("rep stosw"
-		     : "=&c" (d0), "=&D" (d1)
-		     : "a" (v), "1" (s), "0" (n)
+		     : "+D" (s), "+c" (n)
+		     : "a" (v)
 		     : "memory");
-	return s;
+	return s0;
 }
 
 #define __HAVE_ARCH_MEMSET32
 static inline void *memset32(uint32_t *s, uint32_t v, size_t n)
 {
-	int d0, d1;
+	const __auto_type s0 = s;
 	asm volatile("rep stosl"
-		     : "=&c" (d0), "=&D" (d1)
-		     : "a" (v), "1" (s), "0" (n)
+		     : "+D" (s), "+c" (n)
+		     : "a" (v)
 		     : "memory");
-	return s;
+	return s0;
 }
 
 /*
-- 
2.49.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ