2022-03-11 15:51:08

by Duan, Zhenzhong

[permalink] [raw]
Subject: [PATCH v2 0/2] minor cleanups on efer emulation

These two patches remove some redundant code related to mode switch
and EFER emulation.

Sanity tested with kernel in L0, L1 and L2 all patched.

v2: Split to two patches and use comments from Sean to explain why
it's secure to remove them, suggested by Sean.

Zhenzhong Duan (2):
KVM: x86: Remove unnecessory assignment to uret->data
KVM: x86: Remove redundant vm_entry_controls_clearbit() call

arch/x86/kvm/vmx/vmx.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)

--
2.25.1


2022-03-11 16:48:17

by Duan, Zhenzhong

[permalink] [raw]
Subject: [PATCH v2 2/2] KVM: x86: Remove redundant vm_entry_controls_clearbit() call

When emulating exit from long mode, EFER_LMA is cleared which lead to
efer writing emulation, which will unset VM_ENTRY_IA32E_MODE control
bit as requested by SDM. So no need to unset VM_ENTRY_IA32E_MODE again
in exit_lmode() explicitly.

In fact benefited from shadow controls mechanism, this change doesn't
eliminate vmread or vmwrite.

In case EFER isn't supported by hardware, long mode isn't supported,
so this will no break.

Signed-off-by: Zhenzhong Duan <[email protected]>
---
arch/x86/kvm/vmx/vmx.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index cadb3769031c..70717f56a2a2 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2907,7 +2907,6 @@ static void enter_lmode(struct kvm_vcpu *vcpu)

static void exit_lmode(struct kvm_vcpu *vcpu)
{
- vm_entry_controls_clearbit(to_vmx(vcpu), VM_ENTRY_IA32E_MODE);
vmx_set_efer(vcpu, vcpu->arch.efer & ~EFER_LMA);
}

--
2.25.1

2022-03-25 19:33:10

by Paolo Bonzini

[permalink] [raw]