History

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.

Yuan Yao committed 5 years ago

Commit e87e46d1 parent bedd9192 files · +3 −5Browse files

Unified · Split

2 files
  1. arch/x86/kvm/vmx/vmx.c +2 −3
  2. arch/x86/kvm/x86.c +1 −2
arch/x86/kvm/vmx/vmx.c+2−3
@@ -4843,7 +4843,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu) · 4842 unmodified lines
4843 struct vcpu_vmx *vmx = to_vmx(vcpu);4843 struct vcpu_vmx *vmx = to_vmx(vcpu);
4844 struct kvm_run *kvm_run = vcpu->run;4844 struct kvm_run *kvm_run = vcpu->run;
4845 u32 intr_info, ex_no, error_code;4845 u32 intr_info, ex_no, error_code;
4846 unsigned long cr2, rip, dr6;4846 unsigned long cr2, dr6;
4847 u32 vect_info;4847 u32 vect_info;
4848 4848
4849 vect_info = vmx->idt_vectoring_info;4849 vect_info = vmx->idt_vectoring_info;
@@ -4933,8 +4933,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu) · 83 unmodified lines
4933 vmx->vcpu.arch.event_exit_inst_len =4933 vmx->vcpu.arch.event_exit_inst_len =
4934 vmcs_read32(VM_EXIT_INSTRUCTION_LEN);4934 vmcs_read32(VM_EXIT_INSTRUCTION_LEN);
4935 kvm_run->exit_reason = KVM_EXIT_DEBUG;4935 kvm_run->exit_reason = KVM_EXIT_DEBUG;
4936 rip = kvm_rip_read(vcpu);4936 kvm_run->debug.arch.pc = kvm_get_linear_rip(vcpu);
4937 kvm_run->debug.arch.pc = vmcs_readl(GUEST_CS_BASE) + rip;
4938 kvm_run->debug.arch.exception = ex_no;4937 kvm_run->debug.arch.exception = ex_no;
4939 break;4938 break;
4940 case AC_VECTOR:4939 case AC_VECTOR:
arch/x86/kvm/x86.c+1−2
@@ -10120,8 +10120,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, · 10119 unmodified lines
10120 kvm_update_dr7(vcpu);10120 kvm_update_dr7(vcpu);
10121 10121
10122 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)10122 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
10123 vcpu->arch.singlestep_rip = kvm_rip_read(vcpu) +10123 vcpu->arch.singlestep_rip = kvm_get_linear_rip(vcpu);
10124 get_segment_base(vcpu, VCPU_SREG_CS);
10125 10124
10126 /*10125 /*
10127 * Trigger an rflags update that will inject or remove the trace10126 * Trigger an rflags update that will inject or remove the trace

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t