kvm: fix cpuid eax
PATCH 1/1 kvm: fix cpuid eax
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.
Tested using -cpu host.
--- arch/x86/kvm/cpuid.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/cpuid.c +1 -1
@@ -397,7 +397,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,case KVM_CPUID_SIGNATURE : {char signature[12 ] ="KVMKVMKVM\0\0" ;u32 *sigptr = (u32 *)signature; - entry->eax =0 ; + entry->eax =KVM_CPUID_FEATURES ; entry->ebx = sigptr[0 ]; entry->ecx = sigptr[1 ]; entry->edx = sigptr[2 ];
Signature · 1 line
MST
Quoted 3 lines · Michael S. Tsirkin
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.
Not to mention it's what all the "real" CPU leaf chunks do.
Quoted 3 lines · Michael S. Tsirkin
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.
What KVM does here predates Xen and Hyper-V.
This is an ABI breaker.
Regards,
Anthony Liguori
Quoted 21 lines
Tested using -cpu host.
Signed-off-by Michael S. Tsirkin<[email protected]>--- arch/x86/kvm/cpuid.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/x86/kvm/cpuid.c +1
-1@@ -397,7 +397,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,case KVM_CPUID_SIGNATURE : {char signature[12 ] ="KVMKVMKVM\0\0" ;u32 *sigptr = (u32 *)signature; - entry->eax =0 ; + entry->eax =KVM_CPUID_FEATURES ; entry->ebx = sigptr[0 ]; entry->ecx = sigptr[1 ]; entry->edx = sigptr[2 ];
H. Peter Anvin
reviewerQuoted 9 lines · Anthony Liguori
Quoted 3 lines · Michael S. Tsirkin
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.What KVM does here predates Xen and Hyper-V.
This is an ABI breaker.
What Intel and AMD have done here predates KVM...
What exactly relies on a zero here?
-hpa
Quoted 8 lines · Anthony Liguori
Quoted 3 lines · Michael S. Tsirkin
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.What KVM does here predates Xen and Hyper-V.
This is an ABI breaker.
It is? I tested an old guest and qemu and both work fine. What breaks?
Quoted 25 lines
Regards,
Anthony Liguori
Quoted 21 lines
Tested using -cpu host.
Signed-off-by Michael S. Tsirkin<[email protected]>--- arch/x86/kvm/cpuid.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/x86/kvm/cpuid.c +1
-1@@ -397,7 +397,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,case KVM_CPUID_SIGNATURE : {char signature[12 ] ="KVMKVMKVM\0\0" ;u32 *sigptr = (u32 *)signature; - entry->eax =0 ; + entry->eax =KVM_CPUID_FEATURES ; entry->ebx = sigptr[0 ]; entry->ecx = sigptr[1 ]; entry->edx = sigptr[2 ];
Quoted 8 lines · Anthony Liguori
Quoted 3 lines · Michael S. Tsirkin
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.What KVM does here predates Xen and Hyper-V.
This is an ABI breaker.
First, I don't think we ever documented eax, so nothing can rely on it. Second, this isn't guest visible, it's just part of KVM_GET_SUPPORTED_CPUID (used by qemu's -cpu host, but doesn't affect qemu stable cpus).
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Anthony Liguori
Quoted 3 lines · Michael S. Tsirkin
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.
Quoted 6 lines
Quoted 3 lines
What KVM does here predates Xen and Hyper-V.
This is an ABI breaker.
First, I don't think we ever documented eax, so nothing can rely on it.
Actually, we did document it.
However, I think it's safe to change. The documentation in this case should say "reserved, returns zero in this implementation", rather than 0.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 11 lines · Avi Kivity
Quoted 10 lines · Avi Kivity
Quoted 8 lines · Anthony Liguori
Quoted 3 lines · Michael S. Tsirkin
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.What KVM does here predates Xen and Hyper-V.
This is an ABI breaker.
Quoted 8 lines
Quoted 2 lines
First, I don't think we ever documented eax, so nothing can rely on it.
Actually, we did document it.
However, I think it's safe to change. The documentation in this case should say "reserved, returns zero in this implementation", rather than 0.
Just a side note: whether and how it got documented is immaterial, what matters is whether any application binary that is already out there breaks. (The 'B' in ABI.)
Whether it was fully documented or it was entirly undocumented, the code obfuscated, encrypted and all this information got locked away in a safe at a military base protected by nuclear missiles is immaterial: if someone accidentally stumbled upon it and an app learned to rely on the ABI detail then tough luck.
Fortunately, this does not appear to have happened, so as a result it's *not* an Application Binary Interface (it's only a Binary Interface) and can thus be changed for the better.
Thanks,
Ingo
Quoted 7 lines · Michael S. Tsirkin
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.Tested using -cpu host.
Signed-off-by Michael S. Tsirkin <[email protected]>
Quoted 24 lines
--- arch/x86/kvm/cpuid.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/x86/kvm/cpuid.c +1
-1@@ -397,7 +397,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,case KVM_CPUID_SIGNATURE : {char signature[12 ] ="KVMKVMKVM\0\0" ;u32 *sigptr = (u32 *)signature; - entry->eax =0 ; + entry->eax =KVM_CPUID_FEATURES ; entry->ebx = sigptr[0 ]; entry->ecx = sigptr[1 ]; entry->edx = sigptr[2 ];Signature · 6 lines
MST -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
--
Gleb.
Quoted 9 lines · Michael S. Tsirkin
cpuid eax should return the max leaf so that
guests can find out the valid range.
This matches Xen et al.Tested using -cpu host.
Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/x86/kvm/cpuid.c | 2 +-
Documentation/virtual/kvm/cpuid.c | ++++
Signature · 1 line
error compiling committee.c: too many arguments to function