* [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
@ 2014-06-04 1:10 Jidong Xiao
2014-06-04 7:09 ` Paolo Bonzini
0 siblings, 1 reply; 10+ messages in thread
From: Jidong Xiao @ 2014-06-04 1:10 UTC (permalink / raw)
To: qemu-devel, KVM
Hi,
Since Linux kernel 3.5, KVM has set eax to KVM_CPUID_FEATURES, for
leaf 0x40000000, see this:
https://github.com/torvalds/linux/commit/57c22e5f35aa4b9b2fe11f73f3e62bbf9ef36190
But qemu still tries to set it to 0. It would be better to make qemu
and kvm consistent. This patch just fixes this issue.
Signed-off-by: Jidong Xiao <jidong.xiao@gmail.com>
---
diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c
index 4389959..b8b282d 100644
--- a/qemu-2.0.0/target-i386/kvm.c.orig
+++ b/qemu-2.0.0/target-i386/kvm.c
@@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
c = &cpuid_data.entries[cpuid_i++];
c->function = KVM_CPUID_SIGNATURE | kvm_base;
- c->eax = 0;
+ c->eax = KVM_CPUID_FEATURES;
c->ebx = signature[0];
c->ecx = signature[1];
c->edx = signature[2];
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
2014-06-04 1:10 [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000 Jidong Xiao
@ 2014-06-04 7:09 ` Paolo Bonzini
2014-06-04 7:17 ` Jidong Xiao
0 siblings, 1 reply; 10+ messages in thread
From: Paolo Bonzini @ 2014-06-04 7:09 UTC (permalink / raw)
To: Jidong Xiao, qemu-devel, KVM
Il 04/06/2014 03:10, Jidong Xiao ha scritto:
> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c
> index 4389959..b8b282d 100644
> --- a/qemu-2.0.0/target-i386/kvm.c.orig
> +++ b/qemu-2.0.0/target-i386/kvm.c
> @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
> memcpy(signature, "KVMKVMKVM\0\0\0", 12);
> c = &cpuid_data.entries[cpuid_i++];
> c->function = KVM_CPUID_SIGNATURE | kvm_base;
> - c->eax = 0;
> + c->eax = KVM_CPUID_FEATURES;
> c->ebx = signature[0];
> c->ecx = signature[1];
> c->edx = signature[2];
This should actually be "KVM_CPUID_FEATURES | kvm_base", in case Hyper-V
leaves are available too. But it is a good catch!
Paolo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
2014-06-04 7:09 ` Paolo Bonzini
@ 2014-06-04 7:17 ` Jidong Xiao
2014-06-04 19:08 ` Bandan Das
2014-08-12 18:55 ` Eduardo Habkost
0 siblings, 2 replies; 10+ messages in thread
From: Jidong Xiao @ 2014-06-04 7:17 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, KVM
On Wed, Jun 4, 2014 at 3:09 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 04/06/2014 03:10, Jidong Xiao ha scritto:
>
>> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig
>> b/qemu-2.0.0/target-i386/kvm.c
>> index 4389959..b8b282d 100644
>> --- a/qemu-2.0.0/target-i386/kvm.c.orig
>> +++ b/qemu-2.0.0/target-i386/kvm.c
>> @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
>> memcpy(signature, "KVMKVMKVM\0\0\0", 12);
>> c = &cpuid_data.entries[cpuid_i++];
>> c->function = KVM_CPUID_SIGNATURE | kvm_base;
>> - c->eax = 0;
>> + c->eax = KVM_CPUID_FEATURES;
>> c->ebx = signature[0];
>> c->ecx = signature[1];
>> c->edx = signature[2];
>
>
> This should actually be "KVM_CPUID_FEATURES | kvm_base", in case Hyper-V
> leaves are available too. But it is a good catch!
>
> Paolo
>
Thanks Paolo. I have just added that and resend the patch as following:
-Jidong
===
Signed-off-by: Jidong Xiao <jidong.xiao@gmail.com>
---
diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c
index 4389959..fe49a75 100644
--- a/qemu-2.0.0/target-i386/kvm.c.orig
+++ b/qemu-2.0.0/target-i386/kvm.c
@@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
c = &cpuid_data.entries[cpuid_i++];
c->function = KVM_CPUID_SIGNATURE | kvm_base;
- c->eax = 0;
+ c->eax = KVM_CPUID_FEATURES | kvm_base;
c->ebx = signature[0];
c->ecx = signature[1];
c->edx = signature[2];
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
2014-06-04 7:17 ` Jidong Xiao
@ 2014-06-04 19:08 ` Bandan Das
2014-06-04 19:47 ` Jidong Xiao
2014-08-12 18:55 ` Eduardo Habkost
1 sibling, 1 reply; 10+ messages in thread
From: Bandan Das @ 2014-06-04 19:08 UTC (permalink / raw)
To: Jidong Xiao; +Cc: Paolo Bonzini, qemu-devel, KVM
Jidong Xiao <jidong.xiao@gmail.com> writes:
> On Wed, Jun 4, 2014 at 3:09 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> Il 04/06/2014 03:10, Jidong Xiao ha scritto:
>>
>>> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig
>>> b/qemu-2.0.0/target-i386/kvm.c
>>> index 4389959..b8b282d 100644
>>> --- a/qemu-2.0.0/target-i386/kvm.c.orig
>>> +++ b/qemu-2.0.0/target-i386/kvm.c
>>> @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
>>> memcpy(signature, "KVMKVMKVM\0\0\0", 12);
>>> c = &cpuid_data.entries[cpuid_i++];
>>> c->function = KVM_CPUID_SIGNATURE | kvm_base;
>>> - c->eax = 0;
>>> + c->eax = KVM_CPUID_FEATURES;
>>> c->ebx = signature[0];
>>> c->ecx = signature[1];
>>> c->edx = signature[2];
>>
>>
>> This should actually be "KVM_CPUID_FEATURES | kvm_base", in case Hyper-V
>> leaves are available too. But it is a good catch!
>>
>> Paolo
>>
> Thanks Paolo. I have just added that and resend the patch as following:
>
> -Jidong
>
> ===
> Signed-off-by: Jidong Xiao <jidong.xiao@gmail.com>
Did you mean to send this as the new version of your patch ?
Please send the revised version in a separate email and add
"[PATCH v2]" to the subject.
> ---
> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c
> index 4389959..fe49a75 100644
> --- a/qemu-2.0.0/target-i386/kvm.c.orig
> +++ b/qemu-2.0.0/target-i386/kvm.c
> @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
> memcpy(signature, "KVMKVMKVM\0\0\0", 12);
> c = &cpuid_data.entries[cpuid_i++];
> c->function = KVM_CPUID_SIGNATURE | kvm_base;
> - c->eax = 0;
> + c->eax = KVM_CPUID_FEATURES | kvm_base;
Looks like this is not four spaces
> c->ebx = signature[0];
> c->ecx = signature[1];
> c->edx = signature[2];
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
2014-06-04 19:08 ` Bandan Das
@ 2014-06-04 19:47 ` Jidong Xiao
2014-06-04 21:26 ` Bandan Das
0 siblings, 1 reply; 10+ messages in thread
From: Jidong Xiao @ 2014-06-04 19:47 UTC (permalink / raw)
To: Bandan Das; +Cc: Paolo Bonzini, qemu-devel, KVM
On Wed, Jun 4, 2014 at 3:08 PM, Bandan Das <bsd@redhat.com> wrote:
> Jidong Xiao <jidong.xiao@gmail.com> writes:
>
>> On Wed, Jun 4, 2014 at 3:09 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>> Il 04/06/2014 03:10, Jidong Xiao ha scritto:
>>>
>>>> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig
>>>> b/qemu-2.0.0/target-i386/kvm.c
>>>> index 4389959..b8b282d 100644
>>>> --- a/qemu-2.0.0/target-i386/kvm.c.orig
>>>> +++ b/qemu-2.0.0/target-i386/kvm.c
>>>> @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
>>>> memcpy(signature, "KVMKVMKVM\0\0\0", 12);
>>>> c = &cpuid_data.entries[cpuid_i++];
>>>> c->function = KVM_CPUID_SIGNATURE | kvm_base;
>>>> - c->eax = 0;
>>>> + c->eax = KVM_CPUID_FEATURES;
>>>> c->ebx = signature[0];
>>>> c->ecx = signature[1];
>>>> c->edx = signature[2];
>>>
>>>
>>> This should actually be "KVM_CPUID_FEATURES | kvm_base", in case Hyper-V
>>> leaves are available too. But it is a good catch!
>>>
>>> Paolo
>>>
>> Thanks Paolo. I have just added that and resend the patch as following:
>>
>> -Jidong
>>
>> ===
>> Signed-off-by: Jidong Xiao <jidong.xiao@gmail.com>
>
> Did you mean to send this as the new version of your patch ?
> Please send the revised version in a separate email and add
> "[PATCH v2]" to the subject.
>
Hi, Bandan,
Thanks for the advice. I think Paolo has incorporated this patch into
his patch sets, and he sent the revised version in a separate email
earlier today with the subject "[PULL 11/11] kvm: Fix eax for cpuid
leaf 0x40000000".
-Jidong
>> ---
>> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c
>> index 4389959..fe49a75 100644
>> --- a/qemu-2.0.0/target-i386/kvm.c.orig
>> +++ b/qemu-2.0.0/target-i386/kvm.c
>> @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
>> memcpy(signature, "KVMKVMKVM\0\0\0", 12);
>> c = &cpuid_data.entries[cpuid_i++];
>> c->function = KVM_CPUID_SIGNATURE | kvm_base;
>> - c->eax = 0;
>> + c->eax = KVM_CPUID_FEATURES | kvm_base;
>
> Looks like this is not four spaces
>
>> c->ebx = signature[0];
>> c->ecx = signature[1];
>> c->edx = signature[2];
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
2014-06-04 19:47 ` Jidong Xiao
@ 2014-06-04 21:26 ` Bandan Das
0 siblings, 0 replies; 10+ messages in thread
From: Bandan Das @ 2014-06-04 21:26 UTC (permalink / raw)
To: Jidong Xiao; +Cc: Paolo Bonzini, qemu-devel, KVM
Jidong Xiao <jidong.xiao@gmail.com> writes:
..
>>
> Hi, Bandan,
>
> Thanks for the advice. I think Paolo has incorporated this patch into
> his patch sets, and he sent the revised version in a separate email
> earlier today with the subject "[PULL 11/11] kvm: Fix eax for cpuid
> leaf 0x40000000".
Oops! Sorry, must have missed it. Thanks for the heads-up.
> -Jidong
>
>>> ---
>>> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c
>>> index 4389959..fe49a75 100644
>>> --- a/qemu-2.0.0/target-i386/kvm.c.orig
>>> +++ b/qemu-2.0.0/target-i386/kvm.c
>>> @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
>>> memcpy(signature, "KVMKVMKVM\0\0\0", 12);
>>> c = &cpuid_data.entries[cpuid_i++];
>>> c->function = KVM_CPUID_SIGNATURE | kvm_base;
>>> - c->eax = 0;
>>> + c->eax = KVM_CPUID_FEATURES | kvm_base;
>>
>> Looks like this is not four spaces
>>
>>> c->ebx = signature[0];
>>> c->ecx = signature[1];
>>> c->edx = signature[2];
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
2014-06-04 7:17 ` Jidong Xiao
2014-06-04 19:08 ` Bandan Das
@ 2014-08-12 18:55 ` Eduardo Habkost
2014-08-12 19:12 ` Paolo Bonzini
1 sibling, 1 reply; 10+ messages in thread
From: Eduardo Habkost @ 2014-08-12 18:55 UTC (permalink / raw)
To: Jidong Xiao; +Cc: Paolo Bonzini, qemu-devel, KVM
On Wed, Jun 04, 2014 at 03:17:56AM -0400, Jidong Xiao wrote:
> On Wed, Jun 4, 2014 at 3:09 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > Il 04/06/2014 03:10, Jidong Xiao ha scritto:
> >
> >> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig
> >> b/qemu-2.0.0/target-i386/kvm.c
> >> index 4389959..b8b282d 100644
> >> --- a/qemu-2.0.0/target-i386/kvm.c.orig
> >> +++ b/qemu-2.0.0/target-i386/kvm.c
> >> @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
> >> memcpy(signature, "KVMKVMKVM\0\0\0", 12);
> >> c = &cpuid_data.entries[cpuid_i++];
> >> c->function = KVM_CPUID_SIGNATURE | kvm_base;
> >> - c->eax = 0;
> >> + c->eax = KVM_CPUID_FEATURES;
> >> c->ebx = signature[0];
> >> c->ecx = signature[1];
> >> c->edx = signature[2];
> >
> >
> > This should actually be "KVM_CPUID_FEATURES | kvm_base", in case Hyper-V
> > leaves are available too. But it is a good catch!
> >
> > Paolo
> >
> Thanks Paolo. I have just added that and resend the patch as following:
>
> -Jidong
>
> ===
> Signed-off-by: Jidong Xiao <jidong.xiao@gmail.com>
>
> ---
> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig b/qemu-2.0.0/target-i386/kvm.c
> index 4389959..fe49a75 100644
> --- a/qemu-2.0.0/target-i386/kvm.c.orig
> +++ b/qemu-2.0.0/target-i386/kvm.c
> @@ -530,7 +530,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
> memcpy(signature, "KVMKVMKVM\0\0\0", 12);
> c = &cpuid_data.entries[cpuid_i++];
> c->function = KVM_CPUID_SIGNATURE | kvm_base;
> - c->eax = 0;
> + c->eax = KVM_CPUID_FEATURES | kvm_base;
This makes the CPUID data change under the guest's feet during
live-migration.
Adding compat code to ensure older machine-types keep the old behavior
is necessary, but in this specific case it is mostly harmless because
0x0 is documented as being equivalent to 0x40000001.
(But I don't know how guests are supposed to behave when they see
CPUID[KVM_CPUID_SIGNATURE_NEXT].EAX==0.)
--
Eduardo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
2014-08-12 18:55 ` Eduardo Habkost
@ 2014-08-12 19:12 ` Paolo Bonzini
2014-08-12 19:29 ` Eduardo Habkost
0 siblings, 1 reply; 10+ messages in thread
From: Paolo Bonzini @ 2014-08-12 19:12 UTC (permalink / raw)
To: Eduardo Habkost, Jidong Xiao; +Cc: qemu-devel, KVM
Il 12/08/2014 20:55, Eduardo Habkost ha scritto:
> This makes the CPUID data change under the guest's feet during
> live-migration.
>
> Adding compat code to ensure older machine-types keep the old behavior
> is necessary, but in this specific case it is mostly harmless because
> 0x0 is documented as being equivalent to 0x40000001.
>
> (But I don't know how guests are supposed to behave when they see
> CPUID[KVM_CPUID_SIGNATURE_NEXT].EAX==0.)
The only obvious thing to do would be to treat it as 0x40000101.
Paolo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
2014-08-12 19:12 ` Paolo Bonzini
@ 2014-08-12 19:29 ` Eduardo Habkost
2014-08-13 12:18 ` Paolo Bonzini
0 siblings, 1 reply; 10+ messages in thread
From: Eduardo Habkost @ 2014-08-12 19:29 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Jidong Xiao, qemu-devel, KVM
On Tue, Aug 12, 2014 at 09:12:00PM +0200, Paolo Bonzini wrote:
> Il 12/08/2014 20:55, Eduardo Habkost ha scritto:
> > This makes the CPUID data change under the guest's feet during
> > live-migration.
> >
> > Adding compat code to ensure older machine-types keep the old behavior
> > is necessary, but in this specific case it is mostly harmless because
> > 0x0 is documented as being equivalent to 0x40000001.
> >
> > (But I don't know how guests are supposed to behave when they see
> > CPUID[KVM_CPUID_SIGNATURE_NEXT].EAX==0.)
>
> The only obvious thing to do would be to treat it as 0x40000101.
I just want to be sure the guests really do that. If we know guests
won't do anything different with the CPUID change, I won't mind having
no compat code for this.
--
Eduardo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000
2014-08-12 19:29 ` Eduardo Habkost
@ 2014-08-13 12:18 ` Paolo Bonzini
0 siblings, 0 replies; 10+ messages in thread
From: Paolo Bonzini @ 2014-08-13 12:18 UTC (permalink / raw)
To: Eduardo Habkost; +Cc: Jidong Xiao, qemu-devel, KVM
Il 12/08/2014 21:29, Eduardo Habkost ha scritto:
> On Tue, Aug 12, 2014 at 09:12:00PM +0200, Paolo Bonzini wrote:
>> Il 12/08/2014 20:55, Eduardo Habkost ha scritto:
>>> This makes the CPUID data change under the guest's feet during
>>> live-migration.
>>>
>>> Adding compat code to ensure older machine-types keep the old behavior
>>> is necessary, but in this specific case it is mostly harmless because
>>> 0x0 is documented as being equivalent to 0x40000001.
>>>
>>> (But I don't know how guests are supposed to behave when they see
>>> CPUID[KVM_CPUID_SIGNATURE_NEXT].EAX==0.)
>>
>> The only obvious thing to do would be to treat it as 0x40000101.
>
> I just want to be sure the guests really do that. If we know guests
> won't do anything different with the CPUID change, I won't mind having
> no compat code for this.
>
Considering that only two leaves are defined for KVM, and both are
mandatory I don't think current guests have any reason to look at
CPUID[KVM_CPUID_SIGNATURE | kvm_base].EAX at all.
Paolo
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-08-13 12:20 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-04 1:10 [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000 Jidong Xiao
2014-06-04 7:09 ` Paolo Bonzini
2014-06-04 7:17 ` Jidong Xiao
2014-06-04 19:08 ` Bandan Das
2014-06-04 19:47 ` Jidong Xiao
2014-06-04 21:26 ` Bandan Das
2014-08-12 18:55 ` Eduardo Habkost
2014-08-12 19:12 ` Paolo Bonzini
2014-08-12 19:29 ` Eduardo Habkost
2014-08-13 12:18 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).