summaryrefslogtreecommitdiffstats
path: root/sys/amd64/vmm/vmm_lapic.c
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2014-02-20 01:48:25 +0000
committerneel <neel@FreeBSD.org>2014-02-20 01:48:25 +0000
commit4626d164b84dea9d2eb544118119180724c0f483 (patch)
tree37dff768027a85ed7316d1b5ebfad48a7dc4cc6e /sys/amd64/vmm/vmm_lapic.c
parentef25a6c63e4275bebb4cbeaf0ff6dfd32136d879 (diff)
downloadFreeBSD-src-4626d164b84dea9d2eb544118119180724c0f483.zip
FreeBSD-src-4626d164b84dea9d2eb544118119180724c0f483.tar.gz
Simplify APIC mode switching from MMIO to x2APIC. In part this is done to
simplify the implementation of the x2APIC virtualization assist in VT-x. Prior to this change the vlapic allowed the guest to change its mode from xAPIC to x2APIC. We don't allow that any more and the vlapic mode is locked when the virtual machine is created. This is not very constraining because operating systems already have to deal with BIOS setting up the APIC in x2APIC mode at boot. Fix a bug in the CPUID emulation where the x2APIC capability was leaking from the host to the guest. Ignore MMIO reads and writes to the vlapic in x2APIC mode. Similarly, ignore MSR accesses to the vlapic when it is in xAPIC mode. The default configuration of the vlapic is xAPIC. The "-x" option to bhyve(8) can be used to change the mode to x2APIC instead. Discussed with: grehan@
Diffstat (limited to 'sys/amd64/vmm/vmm_lapic.c')
-rw-r--r--sys/amd64/vmm/vmm_lapic.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/amd64/vmm/vmm_lapic.c b/sys/amd64/vmm/vmm_lapic.c
index 47e04da..640c779 100644
--- a/sys/amd64/vmm/vmm_lapic.c
+++ b/sys/amd64/vmm/vmm_lapic.c
@@ -172,7 +172,7 @@ lapic_rdmsr(struct vm *vm, int cpu, u_int msr, uint64_t *rval, bool *retu)
error = 0;
} else {
offset = x2apic_msr_to_regoff(msr);
- error = vlapic_read(vlapic, offset, rval, retu);
+ error = vlapic_read(vlapic, 0, offset, rval, retu);
}
return (error);
@@ -188,11 +188,10 @@ lapic_wrmsr(struct vm *vm, int cpu, u_int msr, uint64_t val, bool *retu)
vlapic = vm_lapic(vm, cpu);
if (msr == MSR_APICBASE) {
- vlapic_set_apicbase(vlapic, val);
- error = 0;
+ error = vlapic_set_apicbase(vlapic, val);
} else {
offset = x2apic_msr_to_regoff(msr);
- error = vlapic_write(vlapic, offset, val, retu);
+ error = vlapic_write(vlapic, 0, offset, val, retu);
}
return (error);
@@ -216,7 +215,7 @@ lapic_mmio_write(void *vm, int cpu, uint64_t gpa, uint64_t wval, int size,
return (EINVAL);
vlapic = vm_lapic(vm, cpu);
- error = vlapic_write(vlapic, off, wval, arg);
+ error = vlapic_write(vlapic, 1, off, wval, arg);
return (error);
}
@@ -238,6 +237,6 @@ lapic_mmio_read(void *vm, int cpu, uint64_t gpa, uint64_t *rval, int size,
return (EINVAL);
vlapic = vm_lapic(vm, cpu);
- error = vlapic_read(vlapic, off, rval, arg);
+ error = vlapic_read(vlapic, 1, off, rval, arg);
return (error);
}
OpenPOWER on IntegriCloud