diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2010-02-23 11:47:53 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2010-03-01 10:36:14 -0500 |
commit | c573cd22939e54fc1b8e672054a505048987a7cb (patch) | |
tree | fdfb036f42f93c97cc06b1c505ad02963dfb7b82 /arch | |
parent | e54cfa97a9ca9a544a7257b89b530b505ae1b892 (diff) |
KVM: VMX: Update instruction length on intercepted BP
We intercept #BP while in guest debugging mode. As VM exits due to
intercepted exceptions do not necessarily come with valid
idt_vectoring, we have to update event_exit_inst_len explicitly in such
cases. At least in the absence of migration, this ensures that
re-injections of #BP will find and use the correct instruction length.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Cc: stable@kernel.org (2.6.32, 2.6.33)
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/vmx.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f82b0723afa5..14873b9f8430 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -2775,6 +2775,12 @@ static int handle_rmode_exception(struct kvm_vcpu *vcpu, | |||
2775 | kvm_queue_exception(vcpu, vec); | 2775 | kvm_queue_exception(vcpu, vec); |
2776 | return 1; | 2776 | return 1; |
2777 | case BP_VECTOR: | 2777 | case BP_VECTOR: |
2778 | /* | ||
2779 | * Update instruction length as we may reinject the exception | ||
2780 | * from user space while in guest debugging mode. | ||
2781 | */ | ||
2782 | to_vmx(vcpu)->vcpu.arch.event_exit_inst_len = | ||
2783 | vmcs_read32(VM_EXIT_INSTRUCTION_LEN); | ||
2778 | if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) | 2784 | if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) |
2779 | return 0; | 2785 | return 0; |
2780 | /* fall through */ | 2786 | /* fall through */ |
@@ -2897,6 +2903,13 @@ static int handle_exception(struct kvm_vcpu *vcpu) | |||
2897 | kvm_run->debug.arch.dr7 = vmcs_readl(GUEST_DR7); | 2903 | kvm_run->debug.arch.dr7 = vmcs_readl(GUEST_DR7); |
2898 | /* fall through */ | 2904 | /* fall through */ |
2899 | case BP_VECTOR: | 2905 | case BP_VECTOR: |
2906 | /* | ||
2907 | * Update instruction length as we may reinject #BP from | ||
2908 | * user space while in guest debugging mode. Reading it for | ||
2909 | * #DB as well causes no harm, it is not used in that case. | ||
2910 | */ | ||
2911 | vmx->vcpu.arch.event_exit_inst_len = | ||
2912 | vmcs_read32(VM_EXIT_INSTRUCTION_LEN); | ||
2900 | kvm_run->exit_reason = KVM_EXIT_DEBUG; | 2913 | kvm_run->exit_reason = KVM_EXIT_DEBUG; |
2901 | kvm_run->debug.arch.pc = vmcs_readl(GUEST_CS_BASE) + rip; | 2914 | kvm_run->debug.arch.pc = vmcs_readl(GUEST_CS_BASE) + rip; |
2902 | kvm_run->debug.arch.exception = ex_no; | 2915 | kvm_run->debug.arch.exception = ex_no; |