Page MenuHomeFreeBSD

D39805.diff
No OneTemporary

D39805.diff

diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c
--- a/sys/amd64/vmm/amd/svm.c
+++ b/sys/amd64/vmm/amd/svm.c
@@ -43,6 +43,7 @@
#include <sys/sysctl.h>
#include <vm/vm.h>
+#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <machine/cpufunc.h>
@@ -123,10 +124,8 @@
/* Current ASID generation for each host cpu */
static struct asid asid[MAXCPU];
-/*
- * SVM host state saved area of size 4KB for each core.
- */
-static uint8_t hsave[MAXCPU][PAGE_SIZE] __aligned(PAGE_SIZE);
+/* SVM host state saved area of size 4KB for each physical core. */
+static uint8_t *hsave;
static VMM_STAT_AMD(VCPU_EXITINTINFO, "VM exits during event delivery");
static VMM_STAT_AMD(VCPU_INTINFO_INJECTED, "Events pending at VM entry");
@@ -167,6 +166,7 @@
{
smp_rendezvous(NULL, svm_disable, NULL, NULL);
+ kmem_free(hsave, (mp_maxid + 1) * PAGE_SIZE);
return (0);
}
@@ -214,7 +214,7 @@
efer |= EFER_SVM;
wrmsr(MSR_EFER, efer);
- wrmsr(MSR_VM_HSAVE_PA, vtophys(hsave[curcpu]));
+ wrmsr(MSR_VM_HSAVE_PA, vtophys(&hsave[curcpu * PAGE_SIZE]));
}
/*
@@ -269,6 +269,7 @@
svm_npt_init(ipinum);
/* Enable SVM on all CPUs */
+ hsave = kmem_malloc((mp_maxid + 1) * PAGE_SIZE, M_WAITOK | M_ZERO);
smp_rendezvous(NULL, svm_enable, NULL, NULL);
return (0);
diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c
--- a/sys/amd64/vmm/intel/vmx.c
+++ b/sys/amd64/vmm/intel/vmx.c
@@ -46,6 +46,7 @@
#include <sys/sysctl.h>
#include <vm/vm.h>
+#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <machine/psl.h>
@@ -134,7 +135,7 @@
NULL);
int vmxon_enabled[MAXCPU];
-static char vmxon_region[MAXCPU][PAGE_SIZE] __aligned(PAGE_SIZE);
+static uint8_t *vmxon_region;
static uint32_t pinbased_ctls, procbased_ctls, procbased_ctls2;
static uint32_t exit_ctls, entry_ctls;
@@ -618,6 +619,7 @@
nmi_flush_l1d_sw = 0;
smp_rendezvous(NULL, vmx_disable, NULL, NULL);
+ kmem_free(vmxon_region, (mp_maxid + 1) * PAGE_SIZE);
return (0);
}
@@ -638,8 +640,8 @@
load_cr4(rcr4() | CR4_VMXE);
- *(uint32_t *)vmxon_region[curcpu] = vmx_revision();
- error = vmxon(vmxon_region[curcpu]);
+ *(uint32_t *)&vmxon_region[curcpu * PAGE_SIZE] = vmx_revision();
+ error = vmxon(&vmxon_region[curcpu * PAGE_SIZE]);
if (error == 0)
vmxon_enabled[curcpu] = 1;
}
@@ -649,7 +651,7 @@
{
if (vmxon_enabled[curcpu])
- vmxon(vmxon_region[curcpu]);
+ vmxon(&vmxon_region[curcpu * PAGE_SIZE]);
}
static int
@@ -953,6 +955,8 @@
vmx_msr_init();
/* enable VMX operation */
+ vmxon_region = kmem_malloc((mp_maxid + 1) * PAGE_SIZE,
+ M_WAITOK | M_ZERO);
smp_rendezvous(NULL, vmx_enable, NULL, NULL);
vmx_initialized = 1;

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 8, 7:56 PM (2 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15726285
Default Alt Text
D39805.diff (2 KB)

Event Timeline