x86/efi: Skip FPU save/restore for idle vCPU in EFI runtime path

Anthony reported a boot-time assertion in init_xen_time() via efi_get_time()
-> efi_rs_enter() in vcpu_save_fpu() on a Broadwell-D system:

  Assertion '!is_idle_vcpu(v)' failed at arch/x86/i387.c:195

This became fragile after the lazy-FPU removal cleanup series:

In 1792bb9a99 ("x86: Cleanup cr0.TS flag handling"),
efi_rs_enter() was changed from save_fpu_enable() to vcpu_save_fpu(curr),
which unconditionally asserts !is_idle_vcpu(v)
so an EFI runtime call in idle context now asserts.

Likewise, in dba44e0512 ("x86: Remove fully_eager_fpu"),
efi_rs_leave() was changed to call vcpu_restore_fpu(curr),
which has the same assertion and can fail for the same reason.

Guard both EFI runtime FPU calls with !is_idle_vcpu() to skip save/restore
for idle vCPUs, which don't have an FPU context to save/restore,
much like the calls are guarded in __context_switch(),
where save/restore is done only for non-idle vCPUs.

Fixes: 1792bb9a99 ("x86: Cleanup cr0.TS flag handling")
Fixes: dba44e0512 ("x86: Remove fully_eager_fpu")
Reported-by: Anthony PERARD <anthony.perard@vates.tech>
Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@citrix.com>
Tested-by: Anthony PERARD <anthony.perard@vates.tech>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
This commit is contained in:
Bernhard Kaindl authored and Jan Beulich committed 2026-06-16 14:15:30 +02:00
1 parent 1cfceee62d
commit 5740b8b0f3
1 file changed
+4 -2
+4 -2
View File
@@ -98,7 +98,8 @@ struct efi_rs_state efi_rs_enter(void)
*/
sync_local_execstate();
state.cr3 = read_cr3();
vcpu_save_fpu(current);
if ( !is_idle_vcpu(current) )
vcpu_save_fpu(current);
asm volatile ( "fnclex; fldcw %0" :: "m" (fcw) );
asm volatile ( "ldmxcsr %0" :: "m" (mxcsr) );
@@ -159,7 +160,8 @@ void efi_rs_leave(struct efi_rs_state *state)
}
irq_exit();
spin_unlock(&efi_rs_lock);
vcpu_restore_fpu(curr);
if ( !is_idle_vcpu(curr) )
vcpu_restore_fpu(curr);
}
unsigned long efi_get_time(void)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.