Re: [PATCH 1/3] KVM: x86: Clear XTILE_CFG if XTILE_DATA is clear

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 27, 2022 at 10:38 AM Aaron Lewis <aaronlewis@xxxxxxxxxx> wrote:
>
> Be good citizens by clearing both
> CPUID.(EAX=0DH,ECX=0):EAX.XTILECFG[bit-17] and
> CPUID.(EAX=0DH,ECX=0):EAX.XTILEDATA[bit-18] if they are both not set.
> That way userspace or a guest doesn't fail if it attempts to set XCR0
> with the user xfeature bits, i.e. EDX:EAX of CPUID.(EAX=0DH,ECX=0).
>
> Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> Signed-off-by: Aaron Lewis <aaronlewis@xxxxxxxxxx>
> ---
>  arch/x86/kvm/cpuid.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 0b5bf013fcb8e..2d9910847786a 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -977,6 +977,10 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
>                 u64 permitted_xcr0 = kvm_caps.supported_xcr0 & xstate_get_guest_group_perm();
>                 u64 permitted_xss = kvm_caps.supported_xss;
>
> +               if (!(permitted_xcr0 & XFEATURE_MASK_XTILE_CFG) ||
> +                   !(permitted_xcr0 & XFEATURE_MASK_XTILE_DATA))
> +                       permitted_xcr0 &= ~XFEATURE_MASK_XTILE;
> +
>                 entry->eax &= permitted_xcr0;
>                 entry->ebx = xstate_required_size(permitted_xcr0, false);
>                 entry->ecx = entry->ebx;
> --
> 2.39.0.314.g84b9a713c41-goog
>

Two questions:

1) Under what circumstances would this happen?
2) Shouldn't we also clear XFEATURE_MASK_CFG if both bits are not set?



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux