Skip to content

Commit eb83991

Browse files
Xiao Guangrongbonzini
authored andcommitted
KVM: MTRR: handle MSR_MTRRcap in kvm_mtrr_get_msr
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 <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent ff53604 commit eb83991

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

arch/x86/kvm/mtrr.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,18 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
199199
{
200200
u64 *p = (u64 *)&vcpu->arch.mtrr_state.fixed_ranges;
201201

202+
/* MSR_MTRRcap is a readonly MSR. */
203+
if (msr == MSR_MTRRcap) {
204+
/*
205+
* SMRR = 0
206+
* WC = 1
207+
* FIX = 1
208+
* VCNT = KVM_NR_VAR_MTRR
209+
*/
210+
*pdata = 0x500 | KVM_NR_VAR_MTRR;
211+
return 0;
212+
}
213+
202214
if (!msr_mtrr_valid(msr))
203215
return 1;
204216

arch/x86/kvm/x86.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,8 +2443,6 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24432443
msr_info->data = 0x100000000ULL;
24442444
break;
24452445
case MSR_MTRRcap:
2446-
msr_info->data = 0x500 | KVM_NR_VAR_MTRR;
2447-
break;
24482446
case 0x200 ... 0x2ff:
24492447
return kvm_mtrr_get_msr(vcpu, msr_info->index, &msr_info->data);
24502448
case 0xcd: /* fsb frequency */

0 commit comments

Comments
 (0)