Re: [PATCH 10/19] kvm: x86: Emulate WRMSR of guest IA32_XFD

From: Yang Zhong
Date: Tue Dec 14 2021 - 05:41:23 EST


On Fri, Dec 10, 2021 at 05:02:49PM +0100, Paolo Bonzini wrote:
> First, the MSR should be added to msrs_to_save_all and
> kvm_cpu_cap_has(X86_FEATURE_XFD) should be checked in
> kvm_init_msr_list.
>
> It seems that RDMSR support is missing, too.
>
> More important, please include:
>
> - documentation for the new KVM_EXIT_* value
>
> - a selftest that explains how userspace should react to it.
>
> This is a strong requirement for any new API (the first has been for
> years; but the latter is also almost always respected these days).
> This series should not have been submitted without documentation.
>
> Also:
>
> On 12/8/21 01:03, Yang Zhong wrote:
> >
> >+ if (!guest_cpuid_has(vcpu, X86_FEATURE_XFD))
> >+ return 1;
>
> This should allow msr->host_initiated always (even if XFD is not
> part of CPUID). However, if XFD is nonzero and
> kvm_check_guest_realloc_fpstate returns true, then it should return
> 1.
>
> The selftest should also cover using KVM_GET_MSR/KVM_SET_MSR.
>

Paolo, Seems we do not need new KVM_EXIT_* again from below thomas' new patchset:
git://git.kernel.org/pub/scm/linux/kernel/git/people/tglx/devel.git x86/fpu-kvm

So the selftest stll need support KVM_GET_MSR/KVM_SET_MSR for MSR_IA32_XFD
and MSR_IA32_XFD_ERR? If yes, we only do some read/write test with vcpu_set_msr()/
vcpu_get_msr() from new selftest tool? or do wrmsr from guest side and check this value
from selftest side?

I checked some msr selftest reference code, tsc_msrs_test.c, which maybe better for this
reference. If you have better suggestion, please share it to me. thanks!

Yang