mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
KVM: VMX: Avoid to rdmsrl(MSR_IA32_SYSENTER_ESP)
The value of host MSR_IA32_SYSENTER_ESP is known to be constant for each CPU: (cpu_entry_stack(cpu) + 1) when 32 bit syscall is enabled or NULL is 32 bit syscall is not enabled. So rdmsrl() can be avoided for the first case and both rdmsrl() and vmcs_writel() can be avoided for the second case. Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com> Message-Id: <20211118110814.2568-3-jiangshanlai@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
24cd19a28c
commit
6ab8a4053f
1 changed files with 11 additions and 3 deletions
|
@ -1271,7 +1271,6 @@ void vmx_vcpu_load_vmcs(struct kvm_vcpu *vcpu, int cpu,
|
||||||
|
|
||||||
if (!already_loaded) {
|
if (!already_loaded) {
|
||||||
void *gdt = get_current_gdt_ro();
|
void *gdt = get_current_gdt_ro();
|
||||||
unsigned long sysenter_esp;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flush all EPTP/VPID contexts, the new pCPU may have stale
|
* Flush all EPTP/VPID contexts, the new pCPU may have stale
|
||||||
|
@ -1287,8 +1286,11 @@ void vmx_vcpu_load_vmcs(struct kvm_vcpu *vcpu, int cpu,
|
||||||
(unsigned long)&get_cpu_entry_area(cpu)->tss.x86_tss);
|
(unsigned long)&get_cpu_entry_area(cpu)->tss.x86_tss);
|
||||||
vmcs_writel(HOST_GDTR_BASE, (unsigned long)gdt); /* 22.2.4 */
|
vmcs_writel(HOST_GDTR_BASE, (unsigned long)gdt); /* 22.2.4 */
|
||||||
|
|
||||||
rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
|
if (IS_ENABLED(CONFIG_IA32_EMULATION) || IS_ENABLED(CONFIG_X86_32)) {
|
||||||
vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
|
/* 22.2.3 */
|
||||||
|
vmcs_writel(HOST_IA32_SYSENTER_ESP,
|
||||||
|
(unsigned long)(cpu_entry_stack(cpu) + 1));
|
||||||
|
}
|
||||||
|
|
||||||
vmx->loaded_vmcs->cpu = cpu;
|
vmx->loaded_vmcs->cpu = cpu;
|
||||||
}
|
}
|
||||||
|
@ -4026,6 +4028,12 @@ void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
|
||||||
|
|
||||||
rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
|
rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
|
||||||
vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
|
vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If 32-bit syscall is enabled, vmx_vcpu_load_vcms rewrites
|
||||||
|
* HOST_IA32_SYSENTER_ESP.
|
||||||
|
*/
|
||||||
|
vmcs_writel(HOST_IA32_SYSENTER_ESP, 0);
|
||||||
rdmsrl(MSR_IA32_SYSENTER_EIP, tmpl);
|
rdmsrl(MSR_IA32_SYSENTER_EIP, tmpl);
|
||||||
vmcs_writel(HOST_IA32_SYSENTER_EIP, tmpl); /* 22.2.3 */
|
vmcs_writel(HOST_IA32_SYSENTER_EIP, tmpl); /* 22.2.3 */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue