x86: vmm: Fix number of CPU detection from cpuid
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 17 Apr 2017 19:04:58 +0000 (15:04 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 17 Apr 2017 19:04:58 +0000 (15:04 -0400)
Cpuid leaf 0x1, ebx, was reporting the number of logical processors from
the host OS.  We should be reporting the number of guest cores.

Similarly, I added a masking of the APIC core id to one byte, in the off
chance that would cause a problem.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/trap.c

index 3e7e5b7..aa73e6e 100644 (file)
@@ -896,8 +896,9 @@ static bool handle_vmexit_cpuid(struct vm_trapframe *tf)
                        ecx &= ~(1 << 15);
 
                        /* Set the guest pcore id into the apic ID field in CPUID. */
-                       ebx &= 0x00ffffff;
-                       ebx |= tf->tf_guest_pcoreid << 24;
+                       ebx &= 0x0000ffff;
+                       ebx |= (current->vmm.nr_guest_pcores & 0xff) << 16;
+                       ebx |= (tf->tf_guest_pcoreid & 0xff) << 24;
                        break;
                case 0x0A:
                        eax = 0;