[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] x86/EFI: further correct FPU state handling around runtime calls
>>> On 22.06.18 at 04:18, <andrew.cooper3@xxxxxxxxxx> wrote: > On 21/06/18 19:53, Jan Beulich wrote: >> We must not leave a vCPU with CR0.TS clear when it is not in fully eager >> mode and has not touched non-lazy state. Instead of adding a 3rd >> invocation of stts() to vcpu_restore_fpu_eager(), consolidate all of >> them into a single one done at the end of the function. >> >> The new function parameter is not really well named, but >> "need_stts_if_not_fully_eager" seemed excessive to me. Suggestions >> welcome. > > I think "maybe_stts" is reasonable here. At least it is accurate. I had considered this name, and discarded it as specifically not accurate: The call site in efi_rs_leave() absolutely wants the stts() in not-fully-eager mode. > OTOH, as we're changing all callsites, can we please rename the function > to vcpu_restore_fpu_nonlazy() to match the rest of the terminology, and > avoid this function looking like it restores all state. Indeed, I could (and hence should) do this. >> --- a/xen/arch/x86/i387.c >> +++ b/xen/arch/x86/i387.c >> @@ -206,11 +206,11 @@ static inline void fpu_fxsave(struct vcp >> /* VCPU FPU Functions */ >> /*******************************/ >> /* Restore FPU state whenever VCPU is schduled in. */ >> -void vcpu_restore_fpu_eager(struct vcpu *v) >> +void vcpu_restore_fpu_eager(struct vcpu *v, bool need_stts) >> { >> /* Restore nonlazy extended state (i.e. parts not tracked by CR0.TS). > */ >> if ( !v->arch.fully_eager_fpu && !v->arch.nonlazy_xstate_used ) >> - return; >> + goto maybe_stts; > > This surely needs to be is_pv_vcpu(v) && (v->arch.pv_vcpu.ctrlreg[0] & > X86_CR0_TS); ? > > Otherwise, this patch reintroduces the path which unconditionally uses > stts() around an EFI RS call. We want an uncondtional stts() here unless in fully eager mode. That's the crux with the parameter name: In fully eager mode, we clearly do not want stts(), but otherwise and without doing anything in the function here, this specific call path needs it. The other two paths don't: - __context_switch() assumes CR0.TS is still set from the most recent vcpu_save_fpu() (i.e. it is simply an optimization to avoid the stts()), - hvmemul_put_fpu() invokes the function only for fully-eager vCPU-s. Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |