KVM: VMX: Remove redundant handling of bus lock vmexit
PATCH v3 1/1 KVM: VMX: Remove redundant handling of bus lock vmexit
Hardware may or may not set exit_reason.bus_lock_detected on BUS_LOCK VM-Exits. Dealing with KVM_RUN_X86_BUS_LOCK in handle_bus_lock_vmexit could be redundant when exit_reason.basic is EXIT_REASON_BUS_LOCK.
We can remove redundant handling of bus lock vmexit. Unconditionally Set exit_reason.bus_lock_detected in handle_bus_lock_vmexit(), and deal with KVM_RUN_X86_BUS_LOCK only in vmx_handle_exit().
---
v1 -> v2: a little modifications of comments
v2 -> v3: addressed the review comments
arch/x86/kvm/vmx/vmx.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
arch/x86/kvm/vmx/vmx.c +9 -6
@@ -5562,9 +5562,13 @@ static int handle_encls(struct kvm_vcpu *vcpu)static int handle_bus_lock_vmexit (struct kvm_vcpu *vcpu) { - vcpu->run->exit_reason =KVM_EXIT_X86_BUS_LOCK ; - vcpu->run->flags |=KVM_RUN_X86_BUS_LOCK ; -return 0 ; +/* +* Hardware may or may not set the BUS_LOCK_DETECTED flag on BUS_LOCK +* VM-Exits. Unconditionally set the flag here and leave the handling to +* vmx_handle_exit(). +*/ +to_vmx (vcpu)->exit_reason.bus_lock_detected = true; +return 1 ; }/*
@@ -6051,9 +6055,8 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)int ret =__vmx_handle_exit (vcpu, exit_fastpath);/* -* Even when current exit reason is handled by KVM internally, we -* still need to exit to user space when bus lock detected to inform -* that there is a bus lock in guest. +* Exit to user space when bus lock detected to inform that there is +* a bus lock in guest. */ if (to_vmx (vcpu)->exit_reason.bus_lock_detected) {if (ret >0 )
Signature · 1 line
1.8.3.1
Sean Christopherson
maintainerQuoted 9 lines · Hao Xiang
Hardware may or may not set exit_reason.bus_lock_detected on
BUS_LOCKVM-Exits. Dealing withKVM_RUN_X86_BUS_LOCKinhandle_bus_lock_vmexitcould be redundant when exit_reason.basic isEXIT_REASON_BUS_LOCK.We can remove redundant handling of bus lock vmexit. Unconditionally Set exit_reason.bus_lock_detected in
handle_bus_lock_vmexit(), and deal withKVM_RUN_X86_BUS_LOCKonly invmx_handle_exit().Suggested-by Xiaoyao Li <[email protected]>
Code review feedback generally doesn't warrant a Suggested-by. The intent of Suggested-by is to give credit to the idea/approach of a patch, so unless the review feedback suggests a completely different, noting the input in the delta (as you did below) is sufficient. And then that way you don't need to juggle the Suggested-by vs Co-developed-by for me.
Quoted 16 lines
Co-developed-by Sean Christopherson <[email protected]>Signed-off-by Sean Christopherson <[email protected]>Signed-off-by Hao Xiang <[email protected]>---
v1 -> v2: a little modifications of comments
v2 -> v3: addressed the review commentsarch/x86/kvm/vmx/vmx.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)arch/x86/kvm/vmx/vmx.c +0
-0
arch/x86/kvm/vmx/vmx.c static int handle_encls(struct kvm_vcpu *vcpu) · line 5568
Quoted 10 lines
arch/x86/kvm/vmx/vmx.c +4
-3@@ -5562,9 +5562,13 @@ static int handle_encls(struct kvm_vcpu *vcpu)static int handle_bus_lock_vmexit (struct kvm_vcpu *vcpu) { - vcpu->run->exit_reason =KVM_EXIT_X86_BUS_LOCK ; - vcpu->run->flags |=KVM_RUN_X86_BUS_LOCK ; -return 0 ; +/* +* Hardware may or may not set the BUS_LOCK_DETECTED flag on BUS_LOCK +* VM-Exits. Unconditionally set the flag here and leave the handling to +* vmx_handle_exit().
+1 for "Unconditionally" instead of "Force". Any objection to rewording the second half slightly?
/*
* Hardware may or may not set the BUS_LOCK_DETECTED flag on BUS_LOCK
* VM-Exits. Unconditionally set the flag here and let vmx_handle_exit()
* handle all flavors of bus-lock exits.
*/
Not a big deal in this case, but in the future please give reviewers a chance to respond and wait for discussion to settle before sending a new version, e.g. I would happily have replied to Xiaoyao's suggestion in v2.
Quoted 43 lines · Hao Xiang
Hardware may or may not set exit_reason.bus_lock_detected on
BUS_LOCKVM-Exits. Dealing withKVM_RUN_X86_BUS_LOCKinhandle_bus_lock_vmexitcould be redundant when exit_reason.basic isEXIT_REASON_BUS_LOCK.We can remove redundant handling of bus lock vmexit. Unconditionally Set exit_reason.bus_lock_detected in
handle_bus_lock_vmexit(), and deal withKVM_RUN_X86_BUS_LOCKonly invmx_handle_exit().Suggested-by Xiaoyao Li <[email protected]>Co-developed-by Sean Christopherson <[email protected]>Signed-off-by Sean Christopherson <[email protected]>Signed-off-by Hao Xiang <[email protected]>---
v1 -> v2: a little modifications of comments
v2 -> v3: addressed the review commentsarch/x86/kvm/vmx/vmx.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)arch/x86/kvm/vmx/vmx.c +7
-3@@ -5562,9 +5562,13 @@ static int handle_encls(struct kvm_vcpu *vcpu)static int handle_bus_lock_vmexit (struct kvm_vcpu *vcpu) { - vcpu->run->exit_reason =KVM_EXIT_X86_BUS_LOCK ; - vcpu->run->flags |=KVM_RUN_X86_BUS_LOCK ; -return 0 ; +/* +* Hardware may or may not set the BUS_LOCK_DETECTED flag on BUS_LOCK +* VM-Exits. Unconditionally set the flag here and leave the handling to +* vmx_handle_exit(). +*/ +to_vmx (vcpu)->exit_reason.bus_lock_detected = true; +return 1 ; }/* @@ -6051,9 +6055,8 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)int ret =__vmx_handle_exit (vcpu, exit_fastpath);
arch/x86/kvm/vmx/vmx.c static int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath) · line 6062
Quoted 10 lines
arch/x86/kvm/vmx/vmx.c +2
-3/* -* Even when current exit reason is handled by KVM internally, we -* still need to exit to user space when bus lock detected to inform -* that there is a bus lock in guest. +* Exit to user space when bus lock detected to inform that there is +* a bus lock in guest. */ if (to_vmx (vcpu)->exit_reason.bus_lock_detected) {if (ret >0 )
Queued, with extra *-by tags removed. Thanks,
Paolo