Re: [PATCH] kvm: x86: Make traced and returned value of kvm_cpuid consistent again

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

 



On Mon, Mar 02, 2020 at 05:46:01PM +0100, Jan Kiszka wrote:
> On 02.03.20 17:38, Sean Christopherson wrote:
> >On Mon, Mar 02, 2020 at 05:11:57PM +0100, Paolo Bonzini wrote:
> >>Queued, thanks.
> >
> >Too fast, too fast!
> >
> >On Sun, Mar 01, 2020 at 11:47:20AM +0100, Jan Kiszka wrote:
> >>From: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
> >>
> >>After 43561123ab37, found is not set correctly in case of leaves 0BH,
> >>1FH, or anything out-of-range.
> >
> >No, found is set correctly, kvm_cpuid() should return true if and only if
> >an exact match for the requested function is found, and that's the original
> >tracing behavior of "found" (pre-43561123ab37).
> >
> >>This is currently harmless for the return value because the only caller
> >>evaluating it passes leaf 0x80000008.
> >
> >No, it's 100% correct.  Well, technically it's irrelevant because the only
> >caller, check_cr_write(), passes %false for check_limit, i.e. found will be
> >true if and only if entry 0x80000008 exists.  But, in a purely hypothetical
> >scenario where the emulator passed check_limit=%true, the intent of "found"
> >is to report that the exact leaf was found, not if some random entry was
> >found.
> 
> Nicely non-intuitive semantics. Should definitely be documented.
> 
> And then it's questionable to me what value tracing such a return code has.

There's value in knowing the the output came from the actual requested leaf
as opposed to the max basic leaf, e.g. if the guest is seeing weird CPUID
output in the guest, knowing whether it was explicitly configured by the
userspace VMM versus coming from KVM's emulation of Intel's wonderful CPUID
behavior.

> At the bare minimum, "found" should be renamed to something like
> "exact_match".

I can do something along these lines.  kvm_cpuid() really doesn't need to
be returning a value, i.e. the emulator shouldn't be manually calculating
maxphyaddr anyways.



[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