OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1] x86/traps: emulate CPUID faults for user tasks in exc_general_protection()
@ 2026-10-06  8:30 Konstantin Khorenko
  2026-10-06  8:32 ` no-reply
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-10-06  8:30 UTC (permalink / raw)
  To: Vasileios Almpanis; +Cc: Denis V. Lunev, devel

A non-empty /proc/vz/cpuid_override table makes ve_setup_task() set
TIF_CPUID_OVERRIDE on every task entering a VE, so the CPU raises #GP
on each CPUID the task executes and check_cpuid_fault() is supposed
to emulate the instruction with the table values.

The call sits after the user-mode branch of exc_general_protection(),
which ends in gp_user_force_sig_segv() and goto exit, so it is reached
only for a kernel-mode #GP, where CPUID never faults. Every Container
task dies with SIGSEGV on the first CPUID of glibc init_cpu_features()
instead of getting the override:

  traps: bash[179661] general protection fault ip:7fa8b470357f ... in
  ld-linux-x86-64.so.2[1857f,...]

The original vz8 patch was written for 4.18, where do_general_protection()
handled kernel mode first and the call landed on the user path. The vz9
port kept the relative position after upstream had reversed the order of
the two branches.

Move the call into the user-mode branch, before the signal is sent.
check_cpuid_fault() still declines tasks with TIF_NOCPUID, so
arch_prctl(ARCH_SET_CPUID, 0) keeps its SIGSEGV semantics.

Fixes: 1033fe455434 ("arch/x86: introduce cpuid override")
https://virtuozzo.atlassian.net/browse/VSTOR-148656

Feature: x86: cpu pools (cpuid override)
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
During this bug investigation i have found several other issues relarted
to cpuid virtualization, so thye will be covered by another series, and
this particular patch fixes the blocker alone and in the minimal way.
---
 arch/x86/kernel/traps.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 7c2320c46abf0..8074387bf4f43 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -798,6 +798,9 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection)
 		if (fixup_vdso_exception(regs, X86_TRAP_GP, error_code, 0))
 			goto exit;
 
+		if (check_cpuid_fault(regs, error_code))
+			goto exit;
+
 		gp_user_force_sig_segv(regs, X86_TRAP_GP, error_code, desc);
 		goto exit;
 	}
@@ -805,9 +808,6 @@ DEFINE_IDTENTRY_ERRORCODE(exc_general_protection)
 	if (gp_try_fixup_and_notify(regs, X86_TRAP_GP, error_code, desc, 0))
 		goto exit;
 
-	if (check_cpuid_fault(regs, error_code))
-		goto exit;
-
 	if (error_code)
 		snprintf(desc, sizeof(desc), "segment-related " GPFSTR);
 	else

---
base-commit: dcd9000e6b239a27d1450a9ac7927a41596733e8
change-id: 20261006-b4-prep-khorenko-vstor-148656-just-cpuid-7aa2f694408c

Best regards,
--  
Konstantin Khorenko <khorenko@virtuozzo.com>

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-06  9:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-06  8:30 [Devel] [PATCH hci-8.1] x86/traps: emulate CPUID faults for user tasks in exc_general_protection() Konstantin Khorenko
2026-10-06  8:32 ` no-reply
2026-10-06  9:30 ` Vasileios Almpanis
2026-10-06  9:36 ` Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox