Skip to content

Commit e87e46d

Browse files
YuanYao0329bonzini
authored andcommitted
KVM: X86: Use kvm_get_linear_rip() in single-step and #DB/#BP interception
The kvm_get_linear_rip() handles x86/long mode cases well and has better readability, __kvm_set_rflags() also use the paired function kvm_is_linear_rip() to check the vcpu->arch.singlestep_rip set in kvm_arch_vcpu_ioctl_set_guest_debug(), so change the "CS.BASE + RIP" code in kvm_arch_vcpu_ioctl_set_guest_debug() and handle_exception_nmi() to this one. Signed-off-by: Yuan Yao <[email protected]> Message-Id: <[email protected]> Reviewed-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent bedd919 commit e87e46d

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4843,7 +4843,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu)
48434843
struct vcpu_vmx *vmx = to_vmx(vcpu);
48444844
struct kvm_run *kvm_run = vcpu->run;
48454845
u32 intr_info, ex_no, error_code;
4846-
unsigned long cr2, rip, dr6;
4846+
unsigned long cr2, dr6;
48474847
u32 vect_info;
48484848

48494849
vect_info = vmx->idt_vectoring_info;
@@ -4933,8 +4933,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu)
49334933
vmx->vcpu.arch.event_exit_inst_len =
49344934
vmcs_read32(VM_EXIT_INSTRUCTION_LEN);
49354935
kvm_run->exit_reason = KVM_EXIT_DEBUG;
4936-
rip = kvm_rip_read(vcpu);
4937-
kvm_run->debug.arch.pc = vmcs_readl(GUEST_CS_BASE) + rip;
4936+
kvm_run->debug.arch.pc = kvm_get_linear_rip(vcpu);
49384937
kvm_run->debug.arch.exception = ex_no;
49394938
break;
49404939
case AC_VECTOR:

arch/x86/kvm/x86.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10120,8 +10120,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
1012010120
kvm_update_dr7(vcpu);
1012110121

1012210122
if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
10123-
vcpu->arch.singlestep_rip = kvm_rip_read(vcpu) +
10124-
get_segment_base(vcpu, VCPU_SREG_CS);
10123+
vcpu->arch.singlestep_rip = kvm_get_linear_rip(vcpu);
1012510124

1012610125
/*
1012710126
* Trigger an rflags update that will inject or remove the trace

0 commit comments

Comments
 (0)