efi: Skip FPU save / restore if using idle vCPU
PATCH 1/1 efi: Skip FPU save / restore if using idle vCPU
The recent changes to remove lazy FPU support mean that vcpu_{save,restore}_fpu perform the action unconditionally. This trips the assert when calling these functions from an idle vCPU as might happen when calling an EFI runtime function. There is no need to save/restore the FPU in that case so skip the calls if using the idle vCPU.
---
Anythony, can you check if this fixes boot on your machine?
xen/common/efi/runtime.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
xen/common/efi/runtime.c +6 -3
@@ -88,6 +88,7 @@ struct efi_rs_state efi_rs_enter(void)static const u16 fcw =FCW_DEFAULT ;static const u32 mxcsr =MXCSR_DEFAULT ;struct efi_rs_state state = { .cr3 =0 }; +struct vcpu *curr = current;if (mfn_eq (efi_l4_mfn,INVALID_MFN ) )return state;
@@ -98,7 +99,8 @@ struct efi_rs_state efi_rs_enter(void)*/ sync_local_execstate (); state.cr3 =read_cr3 (); -vcpu_save_fpu (current); +if ( !is_idle_vcpu (curr) ) +vcpu_save_fpu (curr); asmvolatile ("fnclex; fldcw %0" ::"m" (fcw) ); asmvolatile ("ldmxcsr %0" ::"m" (mxcsr) );
@@ -107,7 +109,7 @@ struct efi_rs_state efi_rs_enter(void)/* prevent fixup_page_fault() from doing anything */ irq_enter (); -if (is_pv_vcpu (current) && !is_idle_vcpu (current) ) +if (is_pv_vcpu (curr) && !is_idle_vcpu (curr) ) {struct desc_ptr gdt_desc = { .limit =LAST_RESERVED_GDT_BYTE ,
@@ -159,7 +161,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 )
Signature · 1 line
2.53.0
Le 16/06/2026 à 15:04, Ross Lagerwall a écrit :
Quoted 51 lines
The recent changes to remove lazy FPU support mean that vcpu_{save,restore}_fpu perform the action unconditionally. This trips the assert when calling these functions from an idle vCPU as might happen when calling an EFI runtime function. There is no need to save/restore the FPU in that case so skip the calls if using the idle vCPU.
Fixes dba44e051209 ("x86: Remove fully_eager_fpu")Fixes 4b9851c64522 ("x86: Remove fpu_initialised/fpu_dirty")Reported-by Anthony PERARD <[email protected]>Suggested-by Jan Beulich <[email protected]>Signed-off-by Ross Lagerwall <[email protected]>---
Anythony, can you check if this fixes boot on your machine?
xen/common/efi/runtime.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)xen/common/efi/runtime.c +4
-2@@ -88,6 +88,7 @@ struct efi_rs_state efi_rs_enter(void)static const u16 fcw =FCW_DEFAULT ;static const u32 mxcsr =MXCSR_DEFAULT ;struct efi_rs_state state = { .cr3 =0 }; +struct vcpu *curr = current;if (mfn_eq (efi_l4_mfn,INVALID_MFN ) )return state;@@ -98,7 +99,8 @@ struct efi_rs_state efi_rs_enter(void)*/ sync_local_execstate (); state.cr3 =read_cr3 (); -vcpu_save_fpu (current); +if ( !is_idle_vcpu (curr) ) +vcpu_save_fpu (curr); asmvolatile ("fnclex; fldcw %0" ::"m" (fcw) ); asmvolatile ("ldmxcsr %0" ::"m" (mxcsr) );@@ -107,7 +109,7 @@ struct efi_rs_state efi_rs_enter(void)/* prevent fixup_page_fault() from doing anything */ irq_enter (); -if (is_pv_vcpu (current) && !is_idle_vcpu (current) ) +if (is_pv_vcpu (curr) && !is_idle_vcpu (curr) ) {struct desc_ptr gdt_desc = { .limit =LAST_RESERVED_GDT_BYTE ,
xen/common/efi/runtime.c void efi_rs_leave(struct efi_rs_state *state) · line 168
Quoted 9 lines
xen/common/efi/runtime.c +2
-1@@ -159,7 +161,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 )
Teddy
Le 16/06/2026 à 15:04, Ross Lagerwall a écrit :
Quoted 51 lines
The recent changes to remove lazy FPU support mean that vcpu_{save,restore}_fpu perform the action unconditionally. This trips the assert when calling these functions from an idle vCPU as might happen when calling an EFI runtime function. There is no need to save/restore the FPU in that case so skip the calls if using the idle vCPU.
Fixes dba44e051209 ("x86: Remove fully_eager_fpu")Fixes 4b9851c64522 ("x86: Remove fpu_initialised/fpu_dirty")Reported-by Anthony PERARD <[email protected]>Suggested-by Jan Beulich <[email protected]>Signed-off-by Ross Lagerwall <[email protected]>---
Anythony, can you check if this fixes boot on your machine?
xen/common/efi/runtime.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)xen/common/efi/runtime.c +4
-2@@ -88,6 +88,7 @@ struct efi_rs_state efi_rs_enter(void)static const u16 fcw =FCW_DEFAULT ;static const u32 mxcsr =MXCSR_DEFAULT ;struct efi_rs_state state = { .cr3 =0 }; +struct vcpu *curr = current;if (mfn_eq (efi_l4_mfn,INVALID_MFN ) )return state;@@ -98,7 +99,8 @@ struct efi_rs_state efi_rs_enter(void)*/ sync_local_execstate (); state.cr3 =read_cr3 (); -vcpu_save_fpu (current); +if ( !is_idle_vcpu (curr) ) +vcpu_save_fpu (curr); asmvolatile ("fnclex; fldcw %0" ::"m" (fcw) ); asmvolatile ("ldmxcsr %0" ::"m" (mxcsr) );@@ -107,7 +109,7 @@ struct efi_rs_state efi_rs_enter(void)/* prevent fixup_page_fault() from doing anything */ irq_enter (); -if (is_pv_vcpu (current) && !is_idle_vcpu (current) ) +if (is_pv_vcpu (curr) && !is_idle_vcpu (curr) ) {struct desc_ptr gdt_desc = { .limit =LAST_RESERVED_GDT_BYTE ,
xen/common/efi/runtime.c void efi_rs_leave(struct efi_rs_state *state) · line 168
Quoted 9 lines
xen/common/efi/runtime.c +2
-1@@ -159,7 +161,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 )
No issues with the patch content, though it's the same as [1].
Quoted 60 lines · Teddy Astie
Le 16/06/2026 à 15:04, Ross Lagerwall a écrit :
Quoted 48 lines
The recent changes to remove lazy FPU support mean that vcpu_{save,restore}_fpu perform the action unconditionally. This trips the assert when calling these functions from an idle vCPU as might happen when calling an EFI runtime function. There is no need to save/restore the FPU in that case so skip the calls if using the idle vCPU.
Fixes dba44e051209 ("x86: Remove fully_eager_fpu")Fixes 4b9851c64522 ("x86: Remove fpu_initialised/fpu_dirty")Reported-by Anthony PERARD <[email protected]>Suggested-by Jan Beulich <[email protected]>Signed-off-by Ross Lagerwall <[email protected]>---
Anythony, can you check if this fixes boot on your machine?
xen/common/efi/runtime.c| 9 ++++++---1 file changed, 6 insertions(+), 3 deletions(-)xen/common/efi/runtime.c +4
-2@@ -88,6 +88,7 @@ struct efi_rs_state efi_rs_enter(void) static const u16 fcw = FCW_DEFAULT; static const u32 mxcsr = MXCSR_DEFAULT; struct efi_rs_state state = { .cr3 = 0 }; + struct vcpu *curr = current; if ( mfn_eq(efi_l4_mfn, INVALID_MFN) ) return state;@@ -98,7 +99,8 @@ struct efi_rs_state efi_rs_enter(void)*/ sync_local_execstate(); state.cr3 = read_cr3(); - vcpu_save_fpu(current); + if ( !is_idle_vcpu(curr) ) + vcpu_save_fpu(curr); asm volatile ( "fnclex; fldcw %0" :: "m" (fcw) ); asm volatile ( "ldmxcsr %0" :: "m" (mxcsr) );@@ -107,7 +109,7 @@ struct efi_rs_state efi_rs_enter(void) /* prevent fixup_page_fault() from doing anything */ irq_enter(); - if ( is_pv_vcpu(current) && !is_idle_vcpu(current) ) + if ( is_pv_vcpu(curr) && !is_idle_vcpu(curr) ) { struct desc_ptr gdt_desc = { .limit = LAST_RESERVED_GDT_BYTE,xen/common/efi/runtime.c void efi_rs_leave(struct efi_rs_state *state) · line 167
Quoted 8 lines
xen/common/efi/runtime.c +2
-1@@ -159,7 +161,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)No issues with the patch content, though it's the same as [1].
Quoted 1 line
Sorry, I wasn't CC'ed and missed that.
Ross