Messages in this thread | | | Date | Mon, 13 Dec 2021 10:01:23 +0100 | Subject | Re: [PATCH 10/19] kvm: x86: Emulate WRMSR of guest IA32_XFD | From | Paolo Bonzini <> |
| |
On 12/13/21 08:51, Liu, Jing2 wrote: > On 12/11/2021 12:02 AM, Paolo Bonzini wrote: >> >> 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). > Thanks Paolo. > > msr->host_initiated handling would be added in next version. > > I'd like to ask why always allow msr->host_initiated even if XFD is not part of > CPUID, although guest doesn't care that MSR? We found some MSRs > (e.g. MSR_AMD64_OSVW_STATUS and MSR_AMD64_OSVW_ID_LENGTH ) > are specially handled so would like to know the consideration of allowing > msr->host_initiated. > > if (!msr_info->host_initiated && !guest_cpuid_has(vcpu, X86_FEATURE_XFD)) > return 1;
Because it's simpler if userspace can just take the entire list from KVM_GET_MSR_INDEX_LIST and pass it to KVM_GET/SET_MSR. See for example vcpu_save_state and vcpu_load_state in tools/testing/selftests/kvm/lib/x86_64/processor.c.
>> However, if XFD is nonzero and kvm_check_guest_realloc_fpstate >> returns true, then it should return 1. > > If XFD is nonzero, kvm_check_guest_realloc_fpstate() won't return true. So > may not need this check here?
It can't for now, because there's a single dynamic feature, but here:
+ if ((xfd & xcr0) != xcr0) { + u64 request = (xcr0 ^ xfd) & xcr0; + struct fpu_guest *guest_fpu = &vcpu->arch.guest_fpu; + + /* + * If requested features haven't been enabled, update + * the request bitmap and tell the caller to request + * dynamic buffer reallocation. + */ + if ((guest_fpu->user_xfeatures & request) != request) { + vcpu->arch.guest_fpu.realloc_request = request; + return true; + } + }
it is certainly possible to return true with nonzero XFD.
Paolo
| |