Lines Matching refs:msr
28 static bool is_mtrr_base_msr(unsigned int msr) in is_mtrr_base_msr() argument
31 return !(msr & 0x1); in is_mtrr_base_msr()
35 unsigned int msr) in var_mtrr_msr_to_range() argument
37 int index = (msr - MTRRphysBase_MSR(0)) / 2; in var_mtrr_msr_to_range()
42 static bool msr_mtrr_valid(unsigned msr) in msr_mtrr_valid() argument
44 switch (msr) { in msr_mtrr_valid()
68 static bool kvm_mtrr_valid(struct kvm_vcpu *vcpu, u32 msr, u64 data) in kvm_mtrr_valid() argument
73 if (!msr_mtrr_valid(msr)) in kvm_mtrr_valid()
76 if (msr == MSR_MTRRdefType) { in kvm_mtrr_valid()
80 } else if (msr >= MSR_MTRRfix64K_00000 && msr <= MSR_MTRRfix4K_F8000) { in kvm_mtrr_valid()
88 WARN_ON(!(msr >= MTRRphysBase_MSR(0) && in kvm_mtrr_valid()
89 msr <= MTRRphysMask_MSR(KVM_NR_VAR_MTRR - 1))); in kvm_mtrr_valid()
92 if ((msr & 1) == 0) { in kvm_mtrr_valid()
194 static bool fixed_msr_to_seg_unit(u32 msr, int *seg, int *unit) in fixed_msr_to_seg_unit() argument
196 switch (msr) { in fixed_msr_to_seg_unit()
204 msr - MSR_MTRRfix16K_80000, in fixed_msr_to_seg_unit()
210 msr - MSR_MTRRfix4K_C0000, in fixed_msr_to_seg_unit()
250 static bool fixed_msr_to_range(u32 msr, u64 *start, u64 *end) in fixed_msr_to_range() argument
254 if (!fixed_msr_to_seg_unit(msr, &seg, &unit)) in fixed_msr_to_range()
261 static int fixed_msr_to_range_index(u32 msr) in fixed_msr_to_range_index() argument
265 if (!fixed_msr_to_seg_unit(msr, &seg, &unit)) in fixed_msr_to_range_index()
318 static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) in update_mtrr() argument
326 if (!mtrr_is_enabled(mtrr_state) && msr != MSR_MTRRdefType) in update_mtrr()
330 if (fixed_msr_to_range(msr, &start, &end)) { in update_mtrr()
333 } else if (msr == MSR_MTRRdefType) { in update_mtrr()
338 var_mtrr_range(var_mtrr_msr_to_range(vcpu, msr), &start, &end); in update_mtrr()
349 static void set_var_mtrr_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data) in set_var_mtrr_msr() argument
354 cur = var_mtrr_msr_to_range(vcpu, msr); in set_var_mtrr_msr()
364 if (is_mtrr_base_msr(msr)) in set_var_mtrr_msr()
378 int kvm_mtrr_set_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data) in kvm_mtrr_set_msr() argument
382 if (!kvm_mtrr_valid(vcpu, msr, data)) in kvm_mtrr_set_msr()
385 index = fixed_msr_to_range_index(msr); in kvm_mtrr_set_msr()
388 else if (msr == MSR_MTRRdefType) in kvm_mtrr_set_msr()
391 set_var_mtrr_msr(vcpu, msr, data); in kvm_mtrr_set_msr()
393 update_mtrr(vcpu, msr); in kvm_mtrr_set_msr()
397 int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata) in kvm_mtrr_get_msr() argument
402 if (msr == MSR_MTRRcap) { in kvm_mtrr_get_msr()
413 if (!msr_mtrr_valid(msr)) in kvm_mtrr_get_msr()
416 index = fixed_msr_to_range_index(msr); in kvm_mtrr_get_msr()
419 } else if (msr == MSR_MTRRdefType) { in kvm_mtrr_get_msr()
423 if (is_mtrr_base_msr(msr)) in kvm_mtrr_get_msr()
424 *pdata = var_mtrr_msr_to_range(vcpu, msr)->base; in kvm_mtrr_get_msr()
426 *pdata = var_mtrr_msr_to_range(vcpu, msr)->mask; in kvm_mtrr_get_msr()