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.
Unified · Split
| @@ -4843,7 +4843,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu) · 4842 unmodified lines | ||
| 4843 | 4843 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
| 4844 | 4844 | struct kvm_run *kvm_run = vcpu->run; |
| 4845 | 4845 | u32 intr_info, ex_no, error_code; |
| 4846 | − unsigned long cr2, rip, dr6; | |
| 4846 | + unsigned long cr2, dr6; | |
| 4847 | 4847 | u32 vect_info; |
| 4848 | 4848 | |
| 4849 | 4849 | vect_info = vmx->idt_vectoring_info; |
| @@ -4933,8 +4933,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu) · 83 unmodified lines | ||
| 4933 | 4933 | vmx->vcpu.arch.event_exit_inst_len = |
| 4934 | 4934 | vmcs_read32(VM_EXIT_INSTRUCTION_LEN); |
| 4935 | 4935 | 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); | |
| 4938 | 4937 | kvm_run->debug.arch.exception = ex_no; |
| 4939 | 4938 | break; |
| 4940 | 4939 | case AC_VECTOR: |
| @@ -10120,8 +10120,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, · 10119 unmodified lines | ||
| 10120 | 10120 | kvm_update_dr7(vcpu); |
| 10121 | 10121 | |
| 10122 | 10122 | 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); | |
| 10125 | 10124 | |
| 10126 | 10125 | /* |
| 10127 | 10126 | * Trigger an rflags update that will inject or remove the trace |