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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240604170437.2362545-4-paulmck@kernel.org>
Date: Tue,  4 Jun 2024 10:04:37 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: linux-arch@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
	kernel-team@...a.com,
	elver@...gle.com,
	akpm@...ux-foundation.org,
	tglx@...utronix.de,
	peterz@...radead.org,
	dianders@...omium.org,
	pmladek@...e.com,
	torvalds@...ux-foundation.org,
	arnd@...db.de,
	"Paul E. McKenney" <paulmck@...nel.org>,
	Mark Brown <broonie@...nel.org>,
	Naresh Kamboju <naresh.kamboju@...aro.org>,
	Nathan Chancellor <nathan@...nel.org>,
	"Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
	Andrew Davis <afd@...com>,
	Linus Walleij <linus.walleij@...aro.org>,
	Eric DeVolder <eric.devolder@...cle.com>,
	Rob Herring <robh@...nel.org>,
	linux-arm-kernel@...ts.infradead.org
Subject: [PATCH v3 cmpxchg 4/4] ARM: Emulate one-byte cmpxchg

Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on ARM systems
with ARCH < ARMv6K.

[ paulmck: Apply Arnd Bergmann and Nathan Chancellor feedback. ]

Reported-by: Mark Brown <broonie@...nel.org>
Closes: https://lore.kernel.org/all/54798f68-48f7-4c65-9cba-47c0bf175143@sirena.org.uk/
Reported-by: Naresh Kamboju <naresh.kamboju@...aro.org>
Closes: https://lore.kernel.org/all/CA+G9fYuZ+pf6p8AXMZWtdFtX-gbG8HMaBKp=XbxcdzA_QeLkxQ@mail.gmail.com/
Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
Tested-by: Nathan Chancellor <nathan@...nel.org>
Cc: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Andrew Davis <afd@...com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Linus Walleij <linus.walleij@...aro.org>
Cc: Eric DeVolder <eric.devolder@...cle.com>
Cc: Rob Herring <robh@...nel.org>
Cc: <linux-arm-kernel@...ts.infradead.org>
---
 arch/arm/Kconfig               | 1 +
 arch/arm/include/asm/cmpxchg.h | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ee5115252aac4..a867a7d967aa5 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -34,6 +34,7 @@ config ARM
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7
+	select ARCH_NEED_CMPXCHG_1_EMU if CPU_V6
 	select ARCH_SUPPORTS_ATOMIC_RMW
 	select ARCH_SUPPORTS_CFI_CLANG
 	select ARCH_SUPPORTS_HUGETLBFS if ARM_LPAE
diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
index 44667bdb4707a..a428e06fe94ee 100644
--- a/arch/arm/include/asm/cmpxchg.h
+++ b/arch/arm/include/asm/cmpxchg.h
@@ -5,6 +5,7 @@
 #include <linux/irqflags.h>
 #include <linux/prefetch.h>
 #include <asm/barrier.h>
+#include <linux/cmpxchg-emu.h>
 
 #if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
 /*
@@ -162,7 +163,11 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
 	prefetchw((const void *)ptr);
 
 	switch (size) {
-#ifndef CONFIG_CPU_V6	/* min ARCH >= ARMv6K */
+#ifdef CONFIG_CPU_V6	/* min ARCH < ARMv6K */
+	case 1:
+		oldval = cmpxchg_emu_u8((volatile u8 *)ptr, old, new);
+		break;
+#else /* min ARCH >= ARMv6K */
 	case 1:
 		do {
 			asm volatile("@ __cmpxchg1\n"
-- 
2.40.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ