Thread (7 messages) 7 messages, 3 authors, 13d ago
COOLING13d

[PATCH BlueZ v2 4/4] tools/test-runner: Fix CPUID register clobbers

From: Pauli Virtanen <hidden>
Date: 2026-09-12 18:18:52
Subsystem: the rest · Maintainer: Linus Torvalds

CPUID modifies EAX, EBX, ECX and EDX, but the inline asm clobber list is
incomplete.  Use the __get_cpuid() intrinsic instead.

Fixes rootfs_setup(r, argv) crashing due to impossible r != &rootfs due
to clobbered registers.

Assisted-by: qwen3.8-flash-next  # finding the bug
---
 tools/test-runner.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/test-runner.c b/tools/test-runner.c
index 9eaf39d35..2de05e26d 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -33,6 +33,11 @@
 #include <sys/param.h>
 #include <sys/reboot.h>
 
+#if defined(__GNUC__) && (defined(__i386__) || defined(__amd64__))
+#include <cpuid.h>
+#define HAVE_GET_CPUID
+#endif
+
 #include "bluetooth/bluetooth.h"
 #include "bluetooth/hci.h"
 #include "bluetooth/hci_lib.h"
@@ -306,12 +311,10 @@ static char *const qemu_envp[] = {
 
 static void check_virtualization(void)
 {
-#if defined(__GNUC__) && (defined(__i386__) || defined(__amd64__))
-	uint32_t ecx;
+#ifdef HAVE_GET_CPUID
+	unsigned int eax, ebx, ecx, edx;
 
-	__asm__ __volatile__("cpuid" : "=c" (ecx) : "a" (1) : "memory");
-
-	if (!!(ecx & (1 << 5)))
+	if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx & (1 << 5)))
 		printf("Found support for Virtual Machine eXtensions\n");
 #endif
 }
-- 
2.55.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help