Skip to content

Commit 2e69f86

Browse files
rkrcmarbonzini
authored andcommitted
KVM: VMX: join functions that disable x2apic msr intercepts
vmx_disable_intercept_msr_read_x2apic() and vmx_disable_intercept_msr_write_x2apic() differed only in the type. Pass the type to a new function. [Ordered and commented TPR intercept according to Paolo's suggestion.] Signed-off-by: Radim Krčmář <[email protected]>
1 parent 40d8338 commit 2e69f86

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

arch/x86/kvm/vmx.c

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4630,33 +4630,18 @@ static void vmx_disable_intercept_for_msr(u32 msr, bool longmode_only)
46304630
msr, MSR_TYPE_R | MSR_TYPE_W);
46314631
}
46324632

4633-
static void vmx_disable_intercept_msr_read_x2apic(u32 msr, bool apicv_active)
4633+
static void vmx_disable_intercept_msr_x2apic(u32 msr, int type, bool apicv_active)
46344634
{
46354635
if (apicv_active) {
46364636
__vmx_disable_intercept_for_msr(vmx_msr_bitmap_legacy_x2apic_apicv,
4637-
msr, MSR_TYPE_R);
4637+
msr, type);
46384638
__vmx_disable_intercept_for_msr(vmx_msr_bitmap_longmode_x2apic_apicv,
4639-
msr, MSR_TYPE_R);
4639+
msr, type);
46404640
} else {
46414641
__vmx_disable_intercept_for_msr(vmx_msr_bitmap_legacy_x2apic,
4642-
msr, MSR_TYPE_R);
4642+
msr, type);
46434643
__vmx_disable_intercept_for_msr(vmx_msr_bitmap_longmode_x2apic,
4644-
msr, MSR_TYPE_R);
4645-
}
4646-
}
4647-
4648-
static void vmx_disable_intercept_msr_write_x2apic(u32 msr, bool apicv_active)
4649-
{
4650-
if (apicv_active) {
4651-
__vmx_disable_intercept_for_msr(vmx_msr_bitmap_legacy_x2apic_apicv,
4652-
msr, MSR_TYPE_W);
4653-
__vmx_disable_intercept_for_msr(vmx_msr_bitmap_longmode_x2apic_apicv,
4654-
msr, MSR_TYPE_W);
4655-
} else {
4656-
__vmx_disable_intercept_for_msr(vmx_msr_bitmap_legacy_x2apic,
4657-
msr, MSR_TYPE_W);
4658-
__vmx_disable_intercept_for_msr(vmx_msr_bitmap_longmode_x2apic,
4659-
msr, MSR_TYPE_W);
4644+
msr, type);
46604645
}
46614646
}
46624647

@@ -6437,29 +6422,23 @@ static __init int hardware_setup(void)
64376422

64386423
set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */
64396424

6440-
/*
6441-
* enable_apicv && kvm_vcpu_apicv_active()
6442-
*/
64436425
for (msr = 0x800; msr <= 0x8ff; msr++) {
64446426
if (msr == 0x839 /* TMCCT */)
64456427
continue;
6446-
vmx_disable_intercept_msr_read_x2apic(msr, true);
6428+
vmx_disable_intercept_msr_x2apic(msr, MSR_TYPE_R, true);
64476429
}
64486430

6449-
/* TPR */
6450-
vmx_disable_intercept_msr_write_x2apic(0x808, true);
6451-
/* EOI */
6452-
vmx_disable_intercept_msr_write_x2apic(0x80b, true);
6453-
/* SELF-IPI */
6454-
vmx_disable_intercept_msr_write_x2apic(0x83f, true);
6455-
64566431
/*
6457-
* (enable_apicv && !kvm_vcpu_apicv_active()) ||
6458-
* !enable_apicv
6432+
* TPR reads and writes can be virtualized even if virtual interrupt
6433+
* delivery is not in use.
64596434
*/
6460-
/* TPR */
6461-
vmx_disable_intercept_msr_read_x2apic(0x808, false);
6462-
vmx_disable_intercept_msr_write_x2apic(0x808, false);
6435+
vmx_disable_intercept_msr_x2apic(0x808, MSR_TYPE_W, true);
6436+
vmx_disable_intercept_msr_x2apic(0x808, MSR_TYPE_R | MSR_TYPE_W, false);
6437+
6438+
/* EOI */
6439+
vmx_disable_intercept_msr_x2apic(0x80b, MSR_TYPE_W, true);
6440+
/* SELF-IPI */
6441+
vmx_disable_intercept_msr_x2apic(0x83f, MSR_TYPE_W, true);
64636442

64646443
if (enable_ept) {
64656444
kvm_mmu_set_mask_ptes(VMX_EPT_READABLE_MASK,

0 commit comments

Comments
 (0)