On Thu, Jul 20, 2023 at 07:22:08AM +0200, Peter Zijlstra wrote: > > I'm not sure that would be worth the trouble / cleverness. The hint is > > straightforward IMO. > > I tried, it doesn't work, clearly I missed something. FWIW, I tried the below. That should make user_mode() true for the kernel thread regset, and while the kernel did boot, it still fails the livepatch self-test. The difference seems to be that END_OF_STACK terminates it right there, while REGS thinks its a valid frame and only terminates on user_mode() when unwinding one more frame. The frame at REGS clearly isn't very sane. diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 72015dba72ab..45a400b16b80 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -232,6 +232,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) * It does the same kernel frame setup to return to a kernel * function that a kernel thread does. */ + childregs->cs = 3; childregs->sp = 0; childregs->ip = 0; kthread_frame_init(frame, args->fn, args->fn_arg);