From: Andre Przywara <andre.przywara@amd.com>
To: Avi Kivity <avi@redhat.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH 2/2] kvm/x86: move and fix substitue search for missing CPUID entries
Date: Thu, 31 Mar 2011 16:50:54 +0200 [thread overview]
Message-ID: <4D9494CE.3040606@amd.com> (raw)
In-Reply-To: <4D947ED4.50407@redhat.com>
Avi Kivity wrote:
> On 03/31/2011 03:13 PM, Andre Przywara wrote:
>> If KVM cannot find an exact match for a requested CPUID leaf, the
>> code will try to find the closest match instead of simply confessing
>> it's failure.
>> The implementation was meant to satisfy the CPUID specification, but
>> did not properly check for extended and standard leaves and also
>> didn't account for the index subleaf.
>> Beside that this rule only applies to CPUID intercepts, which is not
>> the only user of the kvm_find_cpuid_entry() function.
>>
>> So fix this algorithm and move it into kvm_emulate_cpuid().
>> This fixes a crash of newer Linux kernels as KVM guests on
>> AMD Bulldozer CPUs, where bogus values were returned in response to
>> a CPUID intercept.
>>
>> @@ -4996,6 +4990,19 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
>> kvm_register_write(vcpu, VCPU_REGS_RCX, 0);
>> kvm_register_write(vcpu, VCPU_REGS_RDX, 0);
>> best = kvm_find_cpuid_entry(vcpu, function, index);
>> +
>> + /* if no match is found, check whether we exceed the vCPU's limit
>> + * and return the content of the highest valid standard leaf instead.
>> + * This is to satisfy the CPUID specification.
>> + */
>> + if (!best) {
>> + best = kvm_find_cpuid_entry(vcpu, function& 0x80000000, 0);
>
> "highest valid standard leaf" means the second argument should be zero, no?
Weird, but somehow true. I fixed this is in a another version (following).
Thanks for spotting this.
Andre.
>
>> + if (best&& best->eax< function)
>> + best = kvm_find_cpuid_entry(vcpu, best->eax, index);
>> + else
>> + best = NULL;
>> + }
>> +
>> if (best) {
>> kvm_register_write(vcpu, VCPU_REGS_RAX, best->eax);
>> kvm_register_write(vcpu, VCPU_REGS_RBX, best->ebx);
>
>
--
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
next prev parent reply other threads:[~2011-03-31 14:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-30 13:01 [PATCH 1/2] kvm/x86: fix XSAVE bit scanning Andre Przywara
2011-03-30 13:01 ` [PATCH 2/2] kvm/x86: remove unneeded substitute search for missing CPUID entries Andre Przywara
2011-03-30 13:26 ` Avi Kivity
2011-03-30 13:33 ` Avi Kivity
2011-03-31 10:12 ` Andre Przywara
2011-03-31 10:32 ` Avi Kivity
2011-03-31 13:13 ` [PATCH 2/2] kvm/x86: move and fix substitue " Andre Przywara
2011-03-31 13:17 ` Avi Kivity
2011-03-31 14:50 ` Andre Przywara [this message]
2011-03-31 14:58 ` [PATCH 2/2 v3] " Andre Przywara
2011-04-03 12:32 ` Avi Kivity
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=4D9494CE.3040606@amd.com \
--to=andre.przywara@amd.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/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.