KVM: MTRR: handle MSR_MTRRcap in kvm_mtrr_get_msr
authorXiao Guangrong <guangrong.xiao@linux.intel.com>
Mon, 15 Jun 2015 08:55:23 +0000 (16:55 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 19 Jun 2015 15:16:27 +0000 (17:16 +0200)
MSR_MTRRcap is a MTRR msr so move the handler to the common place, also
add some comments to make the hard code more readable

Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mtrr.c
arch/x86/kvm/x86.c

index fb2f7e1..a05846a 100644 (file)
@@ -199,6 +199,18 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 {
        u64 *p = (u64 *)&vcpu->arch.mtrr_state.fixed_ranges;
 
+       /* MSR_MTRRcap is a readonly MSR. */
+       if (msr == MSR_MTRRcap) {
+               /*
+                * SMRR = 0
+                * WC = 1
+                * FIX = 1
+                * VCNT = KVM_NR_VAR_MTRR
+                */
+               *pdata = 0x500 | KVM_NR_VAR_MTRR;
+               return 0;
+       }
+
        if (!msr_mtrr_valid(msr))
                return 1;
 
Simple merge