Skip to contentSkip to conversation

UAPI: Add QEMU linux-user emulation flag

RFC PATCH New Helge Deller 2 participants 2 messages Jul 31 – Aug 4 Personality handling

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 UAPI: Add QEMU linux-user emulation flag

From: Helge Deller <[email protected]>

For some userspace applications it's useful to know if they currently run on QEMU's linux-user emulation. Such programs are for example the LTP testsuite, which could avoid testing specific testcases, or systemd which should avoid use of specific syscalls.

This RFC is about adding a QEMU_LINUX_USER flag to the personality() syscall which would be injected by qemu-user binary. Applications may then call personality(-1), and check the QEMU_LINUX_USER flag to determine if they are running on qemu-user. Adding this flag seems for me to be the least invasive change. No changes to uname strings which would need to be parsed or other modifications to the emulation.

As this patch is just an RFC, maybe people come up with other ideas?

---
 include/uapi/linux/personality.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/personality.h +1 -0
index 243f5f80a7b8..ba6ddaef8954 100644
@@ -9,6 +9,7 @@
  * These occupy the top three bytes.
  */
 enum {
+	QEMU_LINUX_USER =	0x0010000,	/* Qemu linux-user emulation */
 	UNAME26	=               0x0020000,
 	ADDR_NO_RANDOMIZE = 	0x0040000,	/* disable randomization of VA space */
 	FDPIC_FUNCPTRS =	0x0080000,	/* userspace function ptrs point to descriptors
Signature · 1 line
2.54.0
#1 lore raw

RFC PATCH 1/1 UAPI: Add QEMU linux-user emulation flag

-------- Forwarded Message --------
Subject: [PATCH] [RFC] UAPI: Add QEMU linux-user emulation flag
Date: Fri, 31 Jul 2026 17:09:49 +0200
From: Helge Deller <[email protected]>
To: Christoph Hellwig <[email protected]>, [email protected], [email protected], [email protected]
CC: [email protected]

From: Helge Deller <[email protected]>

For some userspace applications it's useful to know if they currently run on QEMU's linux-user emulation. Such programs are for example the LTP testsuite, which could avoid testing specific testcases, or systemd which should avoid use of specific syscalls.

This RFC is about adding a QEMU_LINUX_USER flag to the personality() syscall which would be injected by qemu-user binary. Applications may then call personality(-1), and check the QEMU_LINUX_USER flag to determine if they are running on qemu-user. Adding this flag seems for me to be the least invasive change. No changes to uname strings which would need to be parsed or other modifications to the emulation.

As this patch is just an RFC, maybe people come up with other ideas?

---
 include/uapi/linux/personality.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/personality.h +1 -0
index 243f5f80a7b8..ba6ddaef8954 100644
@@ -9,6 +9,7 @@
  * These occupy the top three bytes.
  */
 enum {
+	QEMU_LINUX_USER =	0x0010000,	/* Qemu linux-user emulation */
 	UNAME26	=               0x0020000,
 	ADDR_NO_RANDOMIZE = 	0x0040000,	/* disable randomization of VA space */
 	FDPIC_FUNCPTRS =	0x0080000,	/* userspace function ptrs point to descriptors
Signature · 1 line
2.54.0