#include <palacios/vmx_io.h>
#include <palacios/vmx_msr.h>
-static addr_t vmxon_ptr_phys;
+static addr_t host_vmcs_ptrs[CONFIG_MAX_CPUS] = {0};
+
+
extern int v3_vmx_exit_handler();
extern int v3_vmx_vmlaunch(struct v3_gprs * vm_regs, struct guest_info * info, struct v3_ctrl_regs * ctrl_regs);
int v3_is_vmx_capable() {
v3_msr_t feature_msr;
- addr_t eax = 0, ebx = 0, ecx = 0, edx = 0;
+ uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
v3_cpuid(0x1, &eax, &ebx, &ecx, &edx);
- PrintDebug("ECX: %p\n", (void*)ecx);
+ PrintDebug("ECX: 0x%x\n", ecx);
if (ecx & CPUID_1_ECX_VTXFLAG) {
v3_get_msr(VMX_FEATURE_CONTROL_MSR, &(feature_msr.hi), &(feature_msr.lo));
-void v3_init_vmx(struct v3_ctrl_ops * vm_ops) {
- extern v3_cpu_arch_t v3_cpu_type;
+void v3_init_vmx_cpu(int cpu_id) {
+ extern v3_cpu_arch_t v3_cpu_types[];
struct v3_msr tmp_msr;
uint64_t ret = 0;
// Setup VMXON Region
- vmxon_ptr_phys = allocate_vmcs();
+ host_vmcs_ptrs[cpu_id] = allocate_vmcs();
- PrintDebug("VMXON pointer: 0x%p\n", (void *)vmxon_ptr_phys);
+ PrintDebug("VMXON pointer: 0x%p\n", (void *)host_vmcs_ptrs[cpu_id]);
- if (v3_enable_vmx(vmxon_ptr_phys) == VMX_SUCCESS) {
+ if (v3_enable_vmx(host_vmcs_ptrs[cpu_id]) == VMX_SUCCESS) {
PrintDebug("VMX Enabled\n");
} else {
PrintError("VMX initialization failure\n");
if (has_vmx_nested_paging() == 1) {
- v3_cpu_type = V3_VMX_EPT_CPU;
+ v3_cpu_types[cpu_id] = V3_VMX_EPT_CPU;
} else {
- v3_cpu_type = V3_VMX_CPU;
+ v3_cpu_types[cpu_id] = V3_VMX_CPU;
}
+}
+
+
+void v3_init_vmx_hooks(struct v3_ctrl_ops * vm_ops) {
+
// Setup the VMX specific vmm operations
vm_ops->init_guest = &init_vmx_guest;
vm_ops->start_guest = &start_vmx_guest;