Skip to contentSkip to conversation

kvm: reset MSR_IA32_CR_PAT correctly

PATCH Applied Avi Kivity 2 participants 3 messages Sep 7, 2010 – Sep 8, 2010 KVM

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 kvm: reset MSR_IA32_CR_PAT correctly

The power-on value of MSR_IA32_CR_PAT is not 0 - that disables cacheing and makes everything dog slow.

Fix to reset MSR_IA32_CR_PAT to the correct value.

---
 qemu-kvm-x86.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
qemu-kvm-x86.c +10 -1
index 4c32771..e02e896 100644
@@ -1289,12 +1289,21 @@ static int kvm_reset_msrs(CPUState *env)
     } msr_data;
     int n;
     struct kvm_msr_entry *msrs = msr_data.entries;
+    uint32_t index;
+    uint64_t data;
 
     if (!kvm_msr_list)
         return -1;
 
     for (n = 0; n < kvm_msr_list->nmsrs; n++) {
-        kvm_msr_entry_set(&msrs[n], kvm_msr_list->indices[n], 0);
+        index = kvm_msr_list->indices[n];
+        switch (index) {
+        case MSR_PAT:
+            data = 0x0007040600070406ULL;
+        default:
+            data = 0;
+        }
+        kvm_msr_entry_set(&msrs[n], index, data);
     }
 
     msr_data.info.nmsrs = n;
Signature · 1 line
1.7.1
author
#1 lore raw
Quoted 25 lines · Avi Kivity

The power-on value of MSR_IA32_CR_PAT is not 0 - that disables cacheing and makes everything dog slow.

Fix to reset MSR_IA32_CR_PAT to the correct value.

---
  qemu-kvm-x86.c |   11 ++++++++++-
  1 files changed, 10 insertions(+), 1 deletions(-)
qemu-kvm-x86.c +2 -0
index 4c32771..e02e896 100644
@@ -1289,12 +1289,21 @@ static int kvm_reset_msrs(CPUState *env)
      } msr_data;
      int n;
      struct kvm_msr_entry *msrs = msr_data.entries;
+    uint32_t index;
+    uint64_t data;
 
      if (!kvm_msr_list)
          return -1;
 
      for (n = 0; n<  kvm_msr_list->nmsrs; n++) {

qemu-kvm-x86.c static int kvm_reset_msrs(CPUState *env) · line 1307

Quoted 10 lines
qemu-kvm-x86.c +8 -1
-        kvm_msr_entry_set(&msrs[n], kvm_msr_list->indices[n], 0);
+        index = kvm_msr_list->indices[n];
+        switch (index) {
+        case MSR_PAT:
+            data = 0x0007040600070406ULL;
+        default:
+            data = 0;
+        }
+        kvm_msr_entry_set(&msrs[n], index, data);
      }

Note: a better fix is to read all msr values during vm creation, so we get the kernel reset values instead of making up our own. This is more future proof wrt newer msrs. But let's start with the simple fix first.

Signature · 1 line
error compiling committee.c: too many arguments to function
#2 lore raw
In reply to Avi Kivity
Quoted 9 lines · Avi Kivity

The power-on value of MSR_IA32_CR_PAT is not 0 - that disables cacheing and makes everything dog slow.

Fix to reset MSR_IA32_CR_PAT to the correct value.

---
 qemu-kvm-x86.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

Applied, thanks.