Re: [PATCH 14/19] x86/fpu: Prepare for KVM XFD_ERR handling

Paolo Bonzini
2021-12-10T16:16:53Z

On 12/8/21 01:03, Yang Zhong wrote:
>
> The guest XFD_ERR value is saved in fpu_guest::xfd_err. There is
> no need to save host XFD_ERR because it's always cleared to ZERO
> by the host #NM handler (which cannot be preempted by a vCPU
> thread to observe a non-zero value).
>
> The lower two bits in fpu_guest::xfd_err is borrowed for special
> purposes. The state components (FP and SSE) covered by the two
> bits are not XSAVE-enabled feature, thus not XFD-enabled either.
> It's impossible to see hardware setting them in XFD_ERR:
>
> - XFD_ERR_GUEST_DISABLED (bit 0)
>
> Indicate that XFD extension is not exposed to the guest thus
> no need to save/restore it.

Can this instead just check if xfeatures includes any dynamic-save features?

Paolo

> - XFD_ERR_GUEST_SAVED (bit 1)
>
> Indicate fpu_guest::xfd_err already contains a saved value
> thus no need for duplicated saving (e.g. when the vCPU thread
> is preempted multiple times before re-enter the guest).