Skip to content

Commit 40d8338

Browse files
rkrcmarbonzini
authored andcommitted
KVM: VMX: remove functions that enable msr intercepts
All intercepts are enabled at the beginning, so they can only be used if we disabled an intercept that we wanted to have enabled. This was done for TMCCT to simplify a loop that disables all x2APIC MSR intercepts, but just keeping TMCCT enabled yields better results. Signed-off-by: Radim Krčmář <[email protected]>
1 parent 83bafef commit 40d8338

File tree

1 file changed

+4
-53
lines changed

1 file changed

+4
-53
lines changed

arch/x86/kvm/vmx.c

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4575,41 +4575,6 @@ static void __vmx_disable_intercept_for_msr(unsigned long *msr_bitmap,
45754575
}
45764576
}
45774577

4578-
static void __vmx_enable_intercept_for_msr(unsigned long *msr_bitmap,
4579-
u32 msr, int type)
4580-
{
4581-
int f = sizeof(unsigned long);
4582-
4583-
if (!cpu_has_vmx_msr_bitmap())
4584-
return;
4585-
4586-
/*
4587-
* See Intel PRM Vol. 3, 20.6.9 (MSR-Bitmap Address). Early manuals
4588-
* have the write-low and read-high bitmap offsets the wrong way round.
4589-
* We can control MSRs 0x00000000-0x00001fff and 0xc0000000-0xc0001fff.
4590-
*/
4591-
if (msr <= 0x1fff) {
4592-
if (type & MSR_TYPE_R)
4593-
/* read-low */
4594-
__set_bit(msr, msr_bitmap + 0x000 / f);
4595-
4596-
if (type & MSR_TYPE_W)
4597-
/* write-low */
4598-
__set_bit(msr, msr_bitmap + 0x800 / f);
4599-
4600-
} else if ((msr >= 0xc0000000) && (msr <= 0xc0001fff)) {
4601-
msr &= 0x1fff;
4602-
if (type & MSR_TYPE_R)
4603-
/* read-high */
4604-
__set_bit(msr, msr_bitmap + 0x400 / f);
4605-
4606-
if (type & MSR_TYPE_W)
4607-
/* write-high */
4608-
__set_bit(msr, msr_bitmap + 0xc00 / f);
4609-
4610-
}
4611-
}
4612-
46134578
/*
46144579
* If a msr is allowed by L0, we should check whether it is allowed by L1.
46154580
* The corresponding bit will be cleared unless both of L0 and L1 allow it.
@@ -4665,21 +4630,6 @@ static void vmx_disable_intercept_for_msr(u32 msr, bool longmode_only)
46654630
msr, MSR_TYPE_R | MSR_TYPE_W);
46664631
}
46674632

4668-
static void vmx_enable_intercept_msr_read_x2apic(u32 msr, bool apicv_active)
4669-
{
4670-
if (apicv_active) {
4671-
__vmx_enable_intercept_for_msr(vmx_msr_bitmap_legacy_x2apic_apicv,
4672-
msr, MSR_TYPE_R);
4673-
__vmx_enable_intercept_for_msr(vmx_msr_bitmap_longmode_x2apic_apicv,
4674-
msr, MSR_TYPE_R);
4675-
} else {
4676-
__vmx_enable_intercept_for_msr(vmx_msr_bitmap_legacy_x2apic,
4677-
msr, MSR_TYPE_R);
4678-
__vmx_enable_intercept_for_msr(vmx_msr_bitmap_longmode_x2apic,
4679-
msr, MSR_TYPE_R);
4680-
}
4681-
}
4682-
46834633
static void vmx_disable_intercept_msr_read_x2apic(u32 msr, bool apicv_active)
46844634
{
46854635
if (apicv_active) {
@@ -6490,11 +6440,12 @@ static __init int hardware_setup(void)
64906440
/*
64916441
* enable_apicv && kvm_vcpu_apicv_active()
64926442
*/
6493-
for (msr = 0x800; msr <= 0x8ff; msr++)
6443+
for (msr = 0x800; msr <= 0x8ff; msr++) {
6444+
if (msr == 0x839 /* TMCCT */)
6445+
continue;
64946446
vmx_disable_intercept_msr_read_x2apic(msr, true);
6447+
}
64956448

6496-
/* TMCCT */
6497-
vmx_enable_intercept_msr_read_x2apic(0x839, true);
64986449
/* TPR */
64996450
vmx_disable_intercept_msr_write_x2apic(0x808, true);
65006451
/* EOI */

0 commit comments

Comments
 (0)