Current KVM head crashes on startup
When I try to run KVM built off the current head, it crashes with a Segmentation fault. KVM-84 does not. Seems to be dealing with the CPUID changes:
0x081a5c70 in host_cpuid ()
at /home/kressb/kvm/src/qemu/target-i386/helper.c:1426
1426 asm volatile("pusha \n\t"At a guess, it's this commit:
commit b9bacf8975c5db7b6f14cabcae98130913f2d013
Author: aliguori <aliguori>
Date: Mon Feb 9 15:50:08 2009 +0000
KVM: CPUID takes ecx as input value for some functions (Amit Shah)
The CPUID instruction takes the value of ECX as an input parameter in addition to the value of EAX as the count for functions 4, 0xb and 0xd. Make sure we pass the value to the instruction.
Also convert to the qemu-style whitespace for the surrounding code.
In case it matters, the host CPU is:
Intel(R) Core(TM)2 CPU 6420 @ 2.13GHz
Quoted 8 lines · Brian Kress
When I try to run KVM built off the current head, it crashes with a Segmentation fault. KVM-84 does
not. Seems to be dealing with the CPUID changes:0x081a5c70 in host_cpuid () at /home/kressb/kvm/src/qemu/target-i386/helper.c:1426 1426 asm volatile("pusha \n\t"
This looks like some kind of stack corruption on 32-bit:
1472 if (kvm_enabled())
(gdb)
1473 host_cpuid(0, 0, NULL, ebx, ecx, edx);
(gdb)
Program received signal SIGSEGV, Segmentation fault.0x081a2d60 in host_cpuid (function=10, count=1231384169, eax=0x0, ebx=0xadfc1914,
ecx=0xadfc1910, edx=0xadfc190c)
at /home/amit/src/kvm-userspace/qemu/target-i386/helper.c:14261426 asm volatile("pusha \n\t"
I don't see this on 64-bit. Investigating.
Amit
Quoted 17 lines · Amit Shah
Quoted 8 lines · Brian Kress
When I try to run KVM built off the current head, it crashes with a Segmentation fault. KVM-84 does
not. Seems to be dealing with the CPUID changes:0x081a5c70 in host_cpuid () at /home/kressb/kvm/src/qemu/target-i386/helper.c:1426 1426 asm volatile("pusha \n\t"This looks like some kind of stack corruption on 32-bit:
1472 if (
kvm_enabled())
(gdb)
1473host_cpuid(0, 0, NULL, ebx, ecx, edx);
(gdb)
Quoted 7 lines
Program received signal SIGSEGV, Segmentation fault.
0x081a2d60inhost_cpuid(function=10, count=1231384169, eax=0x0, ebx=0xadfc1914,ecx=0xadfc1910, edx=0xadfc190c) at /home/amit/src/kvm-userspace/qemu/target-i386/helper.c:14261426 asm volatile("pusha \n\t"
I don't see this on 64-bit. Investigating.
Avi, what's the reason for doing this in the host_cpuid code? As I see it, the first version should work for both 64-bit and 32-bit code.
#ifdef __x86_64__
asm volatile("cpuid"
: "=a"(vec[0]), "=b"(vec[1]),
"=c"(vec[2]), "=d"(vec[3])
: "0"(function), "c"(count) : "cc");
#else
asm volatile("pusha \n\t"
"cpuid \n\t"
"mov %%eax, 0(%1) \n\t"
"mov %%ebx, 4(%1) \n\t"
"mov %%ecx, 8(%1) \n\t"
"mov %%edx, 12(%1) \n\t"
"popa"
: : "a"(function), "c"(count), "S"(vec)
: "memory", "cc");#endif
Amit
Quoted 46 lines · Amit Shah
Quoted 17 lines · Amit Shah
Quoted 8 lines · Brian Kress
When I try to run KVM built off the current head, it crashes with a Segmentation fault. KVM-84 does not. Seems to be dealing with the CPUID changes:
0x081a5c70 in host_cpuid () at /home/kressb/kvm/src/qemu/target-i386/helper.c:1426 1426 asm volatile("pusha \n\t"This looks like some kind of stack corruption on 32-bit:
1472 if (
kvm_enabled())
(gdb)
1473host_cpuid(0, 0, NULL, ebx, ecx, edx);
(gdb)Quoted 8 lines
Program received signal SIGSEGV, Segmentation fault.
0x081a2d60inhost_cpuid(function=10, count=1231384169, eax=0x0, ebx=0xadfc1914,ecx=0xadfc1910, edx=0xadfc190c) at /home/amit/src/kvm-userspace/qemu/target-i386/helper.c:14261426 asm volatile("pusha \n\t"
I don't see this on 64-bit. Investigating.
Avi, what's the reason for doing this in the
host_cpuidcode? As I see it, the first version should work for both 64-bit and 32-bit code.#ifdef __x86_64__ asm volatile("cpuid" : "=a"(vec[0]), "=b"(vec[1]), "=c"(vec[2]), "=d"(vec[3]) : "0"(function), "c"(count) : "cc"); #else asm volatile("pusha \n\t" "cpuid \n\t" "mov %%eax, 0(%1) \n\t" "mov %%ebx, 4(%1) \n\t" "mov %%ecx, 8(%1) \n\t" "mov %%edx, 12(%1) \n\t" "popa" : : "a"(function), "c"(count), "S"(vec) : "memory", "cc");
Quoted 2 lines
#endif
The first version generates too much register pressure for some compilers on i386, leading to compilation failures. The second version is surely wrong, though? Counting from zero, the "vec" parameter would be %2, not %1.
(copied Anthony)
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Quoted 51 lines · Avi Kivity
Quoted 47 lines · Amit Shah
Quoted 18 lines · Amit Shah
Quoted 9 lines · Brian Kress
When I try to run KVM built off the current head, it crashes with a
Segmentation fault. KVM-84 does
not. Seems to be dealing with the CPUID changes:0x081a5c70 in host_cpuid () at /home/kressb/kvm/src/qemu/target-i386/helper.c:1426 1426 asm volatile("pusha \n\t"This looks like some kind of stack corruption on 32-bit:
1472 if (
kvm_enabled())
(gdb)
1473host_cpuid(0, 0, NULL, ebx, ecx, edx);
(gdb)Quoted 8 lines
Program received signal SIGSEGV, Segmentation fault.
0x081a2d60inhost_cpuid(function=10, count=1231384169, eax=0x0, ebx=0xadfc1914,ecx=0xadfc1910, edx=0xadfc190c) at /home/amit/src/kvm-userspace/qemu/target-i386/helper.c:14261426 asm volatile("pusha \n\t"
I don't see this on 64-bit. Investigating.
Avi, what's the reason for doing this in the
host_cpuidcode? As I see it, the first version should work for both 64-bit and 32-bit code.#ifdef __x86_64__ asm volatile("cpuid" : "=a"(vec[0]), "=b"(vec[1]), "=c"(vec[2]), "=d"(vec[3]) : "0"(function), "c"(count) : "cc"); #else asm volatile("pusha \n\t" "cpuid \n\t" "mov %%eax, 0(%1) \n\t" "mov %%ebx, 4(%1) \n\t" "mov %%ecx, 8(%1) \n\t" "mov %%edx, 12(%1) \n\t" "popa" : : "a"(function), "c"(count), "S"(vec) : "memory", "cc");Quoted 2 lines
#endif
Quoted 2 lines
The first version generates too much register pressure for some compilers on i386, leading to compilation failures. The second version
Is it still valid? I tried with gcc-4.1.2 and that worked fine with the first version. Should we just use that version instead?
Quoted 2 lines
is surely wrong, though? Counting from zero, the "vec" parameter would be %2, not %1.
Looks like I missed out updating that when I introduced 'count'. Fixing that fixes the problem.
Amit
Quoted 7 lines · Amit Shah
Quoted 2 lines
The first version generates too much register pressure for some compilers on i386, leading to compilation failures. The second version
Is it still valid? I tried with gcc-4.1.2 and that worked fine with the first version. Should we just use that version instead?
I don't see why it would change, unless you can destroy all copies of the compilers that fail with it.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Quoted 8 lines · Avi Kivity
Quoted 4 lines · Amit Shah
Quoted 3 lines
The first version generates too much register pressure for some compilers on i386, leading to compilation failures. The second version
Quoted 7 lines
Quoted 4 lines
Is it still valid? I tried with gcc-4.1.2 and that worked fine with the first version. Should we just use that version instead?
I don't see why it would change, unless you can destroy all copies of the compilers that fail with it.
I'd like to know which compilers fail to compile it -- maintaining specific code can introduce such regressions.
qemu too doesn't have a dependency on gcc-3 anymore.
Also, softwares do periodically bump up the minimum required versions of their dependencies.
Amit
Quoted 6 lines · Amit Shah
Quoted 4 lines
Quoted 2 lines
I don't see why it would change, unless you can destroy all copies of the compilers that fail with it.
I'd like to know which compilers fail to compile it
I don't recall, it probably depends on whether frame pointers are used or not as well.
Quoted 3 lines
-- maintaining
specific code can introduce such regressions.
That's a problem with assembly. x86 and x86_64 are different instruction sets.
Quoted 2 lines
qemu too doesn't have a dependency on gcc-3 anymore.
We aren't forcing users to use gcc 4.
Quoted 2 lines
Also, softwares do periodically bump up the minimum required versions of their dependencies.
Not for this kind of bug.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Quoted 10 lines · Avi Kivity
Quoted 6 lines · Amit Shah
Quoted 4 lines
Quoted 1 line
I don't see why it would change, unless you can destroy all copies of
the compilers that fail with it.I'd like to know which compilers fail to compile it
I don't recall, it probably depends on whether frame pointers are used or not as well.
As far as I know, kvm-userspace build arguments have remained the same for quite some time. Also, we still pass the -g flag for userspace compilations.
Quoted 6 lines
Quoted 3 lines
-- maintaining
specific code can introduce such regressions.That's a problem with assembly. x86 and
x86_64are different instruction sets.
But the code in question isn't different on the two architectures. Just a cpuid call that hasn't changed.
Quoted 9 lines
Quoted 2 lines
qemu too doesn't have a dependency on gcc-3 anymore.
We aren't forcing users to use gcc 4.
Quoted 2 lines
Also, softwares do periodically bump up the minimum required versions of their dependencies.
Not for this kind of bug.
Just enumerating why just destroying all the copies isn't the only option :-)
OK, given a patch to have just one version of the cpuid call, would you be willing to take the risk of finding out which users it breaks for? I'll send patches to revert and restore correct behaviour for 32-bit if that does happen.
Quoted 8 lines · Amit Shah
Quoted 2 lines
I don't recall, it probably depends on whether frame pointers are used or not as well.
As far as I know, kvm-userspace build arguments have remained the same for quite some time. Also, we still pass the -g flag for userspace compilations.
Some distros change CFLAGS.
Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
-- maintaining
specific code can introduce such regressions.That's a problem with assembly. x86 and
x86_64are different instruction sets.But the code in question isn't different on the two architectures. Just a cpuid call that hasn't changed.
The amount of available registers is different, as is the specification of which registers may be clobbered.
Quoted 5 lines
OK, given a patch to have just one version of the cpuid call, would you be willing to take the risk of finding out which users it breaks for? I'll send patches to revert and restore correct behaviour for 32-bit if that does happen.
This is in upstream qemu so it's not my call but I wouldn't recommend breaking the build when a trivial one liner is possible.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Quoted 7 lines · Brian Kress
When I try to run KVM built off the current head, it crashes with a Segmentation fault. KVM-84 does not. Seems to be dealing with the CPUID changes:
0x081a5c70 in host_cpuid () at /home/kressb/kvm/src/qemu/target-i386/helper.c:1426 1426 asm volatile("pusha \n\t"
I've pushed a fix for this.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.