[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.9] x86/EFI: fix FPU state handling around runtime calls
commit e76d0f7c65d53ec6ed9b1fd8af9415efee1d14c1 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Wed Jul 4 12:36:25 2018 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Jul 4 12:36:25 2018 +0200 x86/EFI: fix FPU state handling around runtime calls There are two issues. First, the nonlazy xstates were never restored after returning from the runtime call. Secondly, with the fully_eager_fpu mitigation for XSA-267 / LazyFPU, the unilateral stts() is no longer correct, and hits an assertion later when a lazy state restore tries to occur for a fully eager vcpu. Fix both of these issues by calling vcpu_restore_fpu_eager(). As EFI runtime services can be used in the idle context, the idle assertion needs to move until after the fully_eager_fpu check. Introduce a "curr" local variable and replace other uses of "current" at the same time. Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Tested-by: Juergen Gross <jgross@xxxxxxxx> master commit: 437211cb696515ee5bd5dae0ab72866c9f382a33 master date: 2018-06-21 11:35:46 +0200 --- xen/arch/x86/i387.c | 4 ++-- xen/common/efi/runtime.c | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/i387.c b/xen/arch/x86/i387.c index c3fda8761b..c13c1147bb 100644 --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -208,12 +208,12 @@ static inline void fpu_fxsave(struct vcpu *v) /* Restore FPU state whenever VCPU is schduled in. */ void vcpu_restore_fpu_eager(struct vcpu *v) { - ASSERT(!is_idle_vcpu(v)); - /* Restore nonlazy extended state (i.e. parts not tracked by CR0.TS). */ if ( !v->arch.fully_eager_fpu && !v->arch.nonlazy_xstate_used ) return; + ASSERT(!is_idle_vcpu(v)); + /* Avoid recursion */ clts(); diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c index 61f6a7b824..9e6e101d7e 100644 --- a/xen/common/efi/runtime.c +++ b/xen/common/efi/runtime.c @@ -118,14 +118,16 @@ struct efi_rs_state efi_rs_enter(void) void efi_rs_leave(struct efi_rs_state *state) { + struct vcpu *curr = current; + if ( !state->cr3 ) return; switch_cr3_cr4(state->cr3, read_cr4()); - 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, - .base = GDT_VIRT_START(current) + .base = GDT_VIRT_START(curr) }; asm volatile ( "lgdt %0" : : "m" (gdt_desc) ); @@ -133,7 +135,7 @@ void efi_rs_leave(struct efi_rs_state *state) irq_exit(); efi_rs_on_cpu = NR_CPUS; spin_unlock(&efi_rs_lock); - stts(); + vcpu_restore_fpu_eager(curr); } bool_t efi_rs_using_pgtables(void) -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.9 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |