[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z4cdShy8Cuitd44I@google.com>
Date: Tue, 14 Jan 2025 18:28:26 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Adrian Hunter <adrian.hunter@...el.com>
Cc: Chao Gao <chao.gao@...el.com>, pbonzini@...hat.com, kvm@...r.kernel.org,
dave.hansen@...ux.intel.com, rick.p.edgecombe@...el.com, kai.huang@...el.com,
reinette.chatre@...el.com, xiaoyao.li@...el.com,
tony.lindgren@...ux.intel.com, binbin.wu@...ux.intel.com, dmatlack@...gle.com,
isaku.yamahata@...el.com, nik.borisov@...e.com, linux-kernel@...r.kernel.org,
x86@...nel.org, yan.y.zhao@...el.com, weijiang.yang@...el.com
Subject: Re: [PATCH 4/7] KVM: TDX: restore host xsave state when exit from the
guest TD
On Tue, Jan 14, 2025, Adrian Hunter wrote:
> On 10/01/25 19:30, Sean Christopherson wrote:
> >> Currently the KVM selftests expect to be able to set XCR0:
> >>
> >> td_vcpu_add()
> >> vm_vcpu_add()
> >> vm_arch_vcpu_add()
> >> vcpu_init_xcrs()
> >> vcpu_xcrs_set()
> >> vcpu_ioctl(KVM_SET_XCRS)
> >> __TEST_ASSERT_VM_VCPU_IOCTL(!ret)
> >>
> >> Seems like vm->arch.has_protected_state is needed for KVM selftests?
> >
> > I doubt it's truly needed, my guess (without looking at the code) is that selftests
> > are fudging around the fact that KVM doesn't stuff arch.xcr0.
>
> Here is when it was added:
>
> commit 8b14c4d85d031f7700fa4e042aebf99d933971f0
> Author: Sean Christopherson <seanjc@...gle.com>
> Date: Thu Oct 3 16:43:31 2024 -0700
>
> KVM: selftests: Configure XCR0 to max supported value by default
>
> To play nice with compilers generating AVX instructions, set CR4.OSXSAVE
> and configure XCR0 by default when creating selftests vCPUs. Some distros
> have switched gcc to '-march=x86-64-v3' by default, and while it's hard to
> find a CPU which doesn't support AVX today, many KVM selftests fail with
Gah, sorry. I misread the callstack the first time around and didn't realize it
was the common code that was writing XCR0.
> Is below OK to avoid it?
Skipping the ioctls to set XCRs and SREGS is definitely ok. I'll hold off on
providing concrete feedback until I review the TDX selftests in its entirety,
as I'm skeptical of having td_vcpu_add() wrap vm_arch_vcpu_add() instead of the
other way around, but I don't want to cause a bunch of noise by reacting to a
sliver of the code.
Powered by blists - more mailing lists