From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Jan Kiszka <jan.kiszka@web.de>, kvm <kvm@vger.kernel.org>,
Jim Mattson <jmattson@google.com>
Subject: Re: [PATCH] kvm: x86: Make traced and returned value of kvm_cpuid consistent again
Date: Mon, 2 Mar 2020 08:38:34 -0800 [thread overview]
Message-ID: <20200302163834.GA6244@linux.intel.com> (raw)
In-Reply-To: <688edd4d-81ad-bb6b-f166-4fb26a90bb9e@redhat.com>
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@siemens.com>
>
> 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.
> However, the trace entry is now misleading due to this inaccuracy. It is
> furthermore misleading because it reports the effective function, not
> the originally passed one. Fix that as well.
>
> Fixes: 43561123ab37 ("kvm: x86: Improve emulation of CPUID leaves 0BH and 1FH")
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> arch/x86/kvm/cpuid.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index b1c469446b07..79a738f313f8 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -1000,13 +1000,12 @@ static bool cpuid_function_in_range(struct kvm_vcpu *vcpu, u32 function)
> bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
> u32 *ecx, u32 *edx, bool check_limit)
> {
> - u32 function = *eax, index = *ecx;
> + u32 orig_function = *eax, function = *eax, index = *ecx;
> struct kvm_cpuid_entry2 *entry;
> struct kvm_cpuid_entry2 *max;
Rather than add another variable, this can be cleaned up to remove "max".
cpuid_function_in_range() also has a bug. I've got patches, in the process
of whipping up a unit test.
next prev parent reply other threads:[~2020-03-02 16:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-01 10:47 [PATCH] kvm: x86: Make traced and returned value of kvm_cpuid consistent again Jan Kiszka
2020-03-01 12:25 ` Xiaoyao Li
2020-03-02 6:19 ` Jan Kiszka
2020-03-02 16:11 ` Paolo Bonzini
2020-03-02 16:38 ` Sean Christopherson [this message]
2020-03-02 16:46 ` Jan Kiszka
2020-03-02 17:55 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200302163834.GA6244@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=jan.kiszka@web.de \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.