Skip to content

Commit 7a8f7c1

Browse files
Maxim Levitskybonzini
authored andcommitted
KVM: x86: nSVM: always intercept x2apic msrs
As a preparation for x2avic, this patch ensures that x2apic msrs are always intercepted for the nested guest. Reviewed-by: Suravee Suthikulpanit <[email protected]> Tested-by: Suravee Suthikulpanit <[email protected]> Signed-off-by: Maxim Levitsky <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 05c4fe8 commit 7a8f7c1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

arch/x86/kvm/svm/nested.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
230230
break;
231231

232232
p = msrpm_offsets[i];
233+
234+
/* x2apic msrs are intercepted always for the nested guest */
235+
if (is_x2apic_msrpm_offset(p))
236+
continue;
237+
233238
offset = svm->nested.ctl.msrpm_base_pa + (p * 4);
234239

235240
if (kvm_vcpu_read_guest(&svm->vcpu, offset, &value, 4))

arch/x86/kvm/svm/svm.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,15 @@ static inline bool nested_npt_enabled(struct vcpu_svm *svm)
521521
return svm->nested.ctl.nested_ctl & SVM_NESTED_CTL_NP_ENABLE;
522522
}
523523

524+
static inline bool is_x2apic_msrpm_offset(u32 offset)
525+
{
526+
/* 4 msrs per u8, and 4 u8 in u32 */
527+
u32 msr = offset * 16;
528+
529+
return (msr >= APIC_BASE_MSR) &&
530+
(msr < (APIC_BASE_MSR + 0x100));
531+
}
532+
524533
/* svm.c */
525534
#define MSR_INVALID 0xffffffffU
526535

0 commit comments

Comments
 (0)