aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/vmm/amd
diff options
context:
space:
mode:
authorPeter Grehan <grehan@FreeBSD.org>2014-06-07 23:05:12 +0000
committerPeter Grehan <grehan@FreeBSD.org>2014-06-07 23:05:12 +0000
commitdc6610d553fe231438a5bd4c0e5491ed6500b8ee (patch)
treec725848d44a9688c7d45a45953ef35f82ffce4a3 /sys/amd64/vmm/amd
parent0df5b8cb8c66af6abb758721c39c51ea1c7c7c24 (diff)
downloadsrc-dc6610d553fe231438a5bd4c0e5491ed6500b8ee.tar.gz
src-dc6610d553fe231438a5bd4c0e5491ed6500b8ee.zip
Set the guest PAT MSR in the VMCB to power-on defaults.
Linux guests accept the values in this register, while *BSD guests reprogram it. Default values of zero correspond to PAT_UNCACHEABLE, resulting in glacial performance. Thanks to Willem Jan Withagen for first reporting this and helping out with the investigation.
Notes
Notes: svn path=/projects/bhyve_svm/; revision=267217
Diffstat (limited to 'sys/amd64/vmm/amd')
-rw-r--r--sys/amd64/vmm/amd/vmcb.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/amd64/vmm/amd/vmcb.c b/sys/amd64/vmm/amd/vmcb.c
index fa7d91f6572e..9fc30b062616 100644
--- a/sys/amd64/vmm/amd/vmcb.c
+++ b/sys/amd64/vmm/amd/vmcb.c
@@ -67,10 +67,20 @@ svm_init_vmcb(struct vmcb *vmcb, uint64_t iopm_base_pa,
/* Enable nested paging */
ctrl->np_enable = 1;
ctrl->n_cr3 = np_pml4;
-
+
/* EFER_SVM must always be set when the guest is executing */
state->efer = EFER_SVM;
-
+
+ /* Set up the PAT to power-on state */
+ state->g_pat = PAT_VALUE(0, PAT_WRITE_BACK) |
+ PAT_VALUE(1, PAT_WRITE_THROUGH) |
+ PAT_VALUE(2, PAT_UNCACHED) |
+ PAT_VALUE(3, PAT_UNCACHEABLE) |
+ PAT_VALUE(4, PAT_WRITE_BACK) |
+ PAT_VALUE(5, PAT_WRITE_THROUGH) |
+ PAT_VALUE(6, PAT_UNCACHED) |
+ PAT_VALUE(7, PAT_UNCACHEABLE);
+
return (0);
}