From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Jan Kiszka <jan.kiszka@web.de>,
Paolo Bonzini <pbonzini@redhat.com>, kvm <kvm@vger.kernel.org>
Cc: Jim Mattson <jmattson@google.com>
Subject: Re: [PATCH] kvm: x86: Make traced and returned value of kvm_cpuid consistent again
Date: Sun, 1 Mar 2020 20:25:30 +0800 [thread overview]
Message-ID: <b9244d91-93a6-e663-6497-e91c1dca49ef@intel.com> (raw)
In-Reply-To: <dd33df29-2c17-2dc8-cb8f-56686cd583ad@web.de>
On 3/1/2020 6:47 PM, 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. This is currently harmless for the return
> value because the only caller evaluating it passes leaf 0x80000008.
Nice catch!
> 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.
BTW, the trace lacks subleaf(ECX) info, it's meaning for the the leaf
does have a subleaf, maybe we'd better add it?
> 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;
> bool found;
>
> entry = kvm_find_cpuid_entry(vcpu, function, index);
> - found = entry;
> /*
> * Intel CPUID semantics treats any query for an out-of-range
> * leaf as if the highest basic leaf (i.e. CPUID.0H:EAX) were
> @@ -1049,7 +1048,8 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
> }
> }
> }
> - trace_kvm_cpuid(function, *eax, *ebx, *ecx, *edx, found);
> + found = entry;
> + trace_kvm_cpuid(orig_function, *eax, *ebx, *ecx, *edx, found);
> return found;
> }
> EXPORT_SYMBOL_GPL(kvm_cpuid);
> --
> 2.16.4
>
next prev parent reply other threads:[~2020-03-01 12:25 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 [this message]
2020-03-02 6:19 ` Jan Kiszka
2020-03-02 16:11 ` Paolo Bonzini
2020-03-02 16:38 ` Sean Christopherson
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=b9244d91-93a6-e663-6497-e91c1dca49ef@intel.com \
--to=xiaoyao.li@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.