|
|
4ec855 |
From c31315e765df0137cb7dfedb3869db72d6d2ca57 Mon Sep 17 00:00:00 2001
|
|
|
4ec855 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4ec855 |
Date: Mon, 22 Jul 2019 18:22:10 +0100
|
|
|
4ec855 |
Subject: [PATCH 29/39] target/i386: kvm: Re-inject #DB to guest with updated
|
|
|
4ec855 |
DR6
|
|
|
4ec855 |
|
|
|
4ec855 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4ec855 |
Message-id: <20190722182220.19374-9-pbonzini@redhat.com>
|
|
|
4ec855 |
Patchwork-id: 89626
|
|
|
4ec855 |
O-Subject: [RHEL-8.1.0 PATCH qemu-kvm v3 08/18] target/i386: kvm: Re-inject #DB to guest with updated DR6
|
|
|
4ec855 |
Bugzilla: 1689269
|
|
|
4ec855 |
RH-Acked-by: Peter Xu <zhexu@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
4ec855 |
|
|
|
4ec855 |
From: Liran Alon <liran.alon@oracle.com>
|
|
|
4ec855 |
|
|
|
4ec855 |
If userspace (QEMU) debug guest, when #DB is raised in guest and
|
|
|
4ec855 |
intercepted by KVM, KVM forwards information on #DB to userspace
|
|
|
4ec855 |
instead of injecting #DB to guest.
|
|
|
4ec855 |
While doing so, KVM don't update vCPU DR6 but instead report the #DB DR6
|
|
|
4ec855 |
value to userspace for further handling.
|
|
|
4ec855 |
See KVM's handle_exception() DB_VECTOR handler.
|
|
|
4ec855 |
|
|
|
4ec855 |
QEMU handler for this case is kvm_handle_debug(). This handler basically
|
|
|
4ec855 |
checks if #DB is related to one of user set hardware breakpoints and if
|
|
|
4ec855 |
not, it re-inject #DB into guest.
|
|
|
4ec855 |
The re-injection is done by setting env->exception_injected to #DB which
|
|
|
4ec855 |
will later be passed as events.exception.nr to KVM_SET_VCPU_EVENTS ioctl
|
|
|
4ec855 |
by kvm_put_vcpu_events().
|
|
|
4ec855 |
|
|
|
4ec855 |
However, in case userspace re-injects #DB, KVM expects userspace to set
|
|
|
4ec855 |
vCPU DR6 as reported to userspace when #DB was intercepted! Otherwise,
|
|
|
4ec855 |
KVM_REQ_EVENT handler will inject #DB with wrong DR6 to guest.
|
|
|
4ec855 |
|
|
|
4ec855 |
Fix this issue by updating vCPU DR6 appropriately when re-inject #DB to
|
|
|
4ec855 |
guest.
|
|
|
4ec855 |
|
|
|
4ec855 |
Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
|
|
|
4ec855 |
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
|
|
|
4ec855 |
Signed-off-by: Liran Alon <liran.alon@oracle.com>
|
|
|
4ec855 |
Message-Id: <20190619162140.133674-5-liran.alon@oracle.com>
|
|
|
4ec855 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4ec855 |
(cherry picked from commit bceeeef9e7544057659118688243260c390eceb9)
|
|
|
4ec855 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
4ec855 |
---
|
|
|
4ec855 |
target/i386/kvm.c | 3 +++
|
|
|
4ec855 |
1 file changed, 3 insertions(+)
|
|
|
4ec855 |
|
|
|
4ec855 |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
|
4ec855 |
index 4138fe9..1a4ff3c 100644
|
|
|
4ec855 |
--- a/target/i386/kvm.c
|
|
|
4ec855 |
+++ b/target/i386/kvm.c
|
|
|
4ec855 |
@@ -3363,6 +3363,9 @@ static int kvm_handle_debug(X86CPU *cpu,
|
|
|
4ec855 |
/* pass to guest */
|
|
|
4ec855 |
env->exception_injected = arch_info->exception;
|
|
|
4ec855 |
env->has_error_code = 0;
|
|
|
4ec855 |
+ if (arch_info->exception == EXCP01_DB) {
|
|
|
4ec855 |
+ env->dr[6] = arch_info->dr6;
|
|
|
4ec855 |
+ }
|
|
|
4ec855 |
}
|
|
|
4ec855 |
|
|
|
4ec855 |
return ret;
|
|
|
4ec855 |
--
|
|
|
4ec855 |
1.8.3.1
|
|
|
4ec855 |
|