diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2008-12-15 07:52:10 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-03-24 05:02:49 -0400 |
commit | d0bfb940ecabf0b44fb1fd80d8d60594e569e5ec (patch) | |
tree | b5927d44937a54ec23d2a28d59db06a0262c0412 /include/linux/kvm.h | |
parent | 8ab2d2e231062814bd89bba2d6d92563190aa2bb (diff) |
KVM: New guest debug interface
This rips out the support for KVM_DEBUG_GUEST and introduces a new IOCTL
instead: KVM_SET_GUEST_DEBUG. The IOCTL payload consists of a generic
part, controlling the "main switch" and the single-step feature. The
arch specific part adds an x86 interface for intercepting both types of
debug exceptions separately and re-injecting them when the host was not
interested. Moveover, the foundation for guest debugging via debug
registers is layed.
To signal breakpoint events properly back to userland, an arch-specific
data block is now returned along KVM_EXIT_DEBUG. For x86, the arch block
contains the PC, the debug exception, and relevant debug registers to
tell debug events properly apart.
The availability of this new interface is signaled by
KVM_CAP_SET_GUEST_DEBUG. Empty stubs for not yet supported archs are
provided.
Note that both SVM and VTX are supported, but only the latter was tested
yet. Based on the experience with all those VTX corner case, I would be
fairly surprised if SVM will work out of the box.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'include/linux/kvm.h')
-rw-r--r-- | include/linux/kvm.h | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 0424326f1679..429a2ce202f9 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
@@ -126,6 +126,7 @@ struct kvm_run { | |||
126 | __u64 data_offset; /* relative to kvm_run start */ | 126 | __u64 data_offset; /* relative to kvm_run start */ |
127 | } io; | 127 | } io; |
128 | struct { | 128 | struct { |
129 | struct kvm_debug_exit_arch arch; | ||
129 | } debug; | 130 | } debug; |
130 | /* KVM_EXIT_MMIO */ | 131 | /* KVM_EXIT_MMIO */ |
131 | struct { | 132 | struct { |
@@ -217,21 +218,6 @@ struct kvm_interrupt { | |||
217 | __u32 irq; | 218 | __u32 irq; |
218 | }; | 219 | }; |
219 | 220 | ||
220 | struct kvm_breakpoint { | ||
221 | __u32 enabled; | ||
222 | __u32 padding; | ||
223 | __u64 address; | ||
224 | }; | ||
225 | |||
226 | /* for KVM_DEBUG_GUEST */ | ||
227 | struct kvm_debug_guest { | ||
228 | /* int */ | ||
229 | __u32 enabled; | ||
230 | __u32 pad; | ||
231 | struct kvm_breakpoint breakpoints[4]; | ||
232 | __u32 singlestep; | ||
233 | }; | ||
234 | |||
235 | /* for KVM_GET_DIRTY_LOG */ | 221 | /* for KVM_GET_DIRTY_LOG */ |
236 | struct kvm_dirty_log { | 222 | struct kvm_dirty_log { |
237 | __u32 slot; | 223 | __u32 slot; |
@@ -292,6 +278,17 @@ struct kvm_s390_interrupt { | |||
292 | __u64 parm64; | 278 | __u64 parm64; |
293 | }; | 279 | }; |
294 | 280 | ||
281 | /* for KVM_SET_GUEST_DEBUG */ | ||
282 | |||
283 | #define KVM_GUESTDBG_ENABLE 0x00000001 | ||
284 | #define KVM_GUESTDBG_SINGLESTEP 0x00000002 | ||
285 | |||
286 | struct kvm_guest_debug { | ||
287 | __u32 control; | ||
288 | __u32 pad; | ||
289 | struct kvm_guest_debug_arch arch; | ||
290 | }; | ||
291 | |||
295 | #define KVM_TRC_SHIFT 16 | 292 | #define KVM_TRC_SHIFT 16 |
296 | /* | 293 | /* |
297 | * kvm trace categories | 294 | * kvm trace categories |
@@ -396,6 +393,7 @@ struct kvm_trace_rec { | |||
396 | #ifdef __KVM_HAVE_USER_NMI | 393 | #ifdef __KVM_HAVE_USER_NMI |
397 | #define KVM_CAP_USER_NMI 22 | 394 | #define KVM_CAP_USER_NMI 22 |
398 | #endif | 395 | #endif |
396 | #define KVM_CAP_SET_GUEST_DEBUG 23 | ||
399 | 397 | ||
400 | /* | 398 | /* |
401 | * ioctls for VM fds | 399 | * ioctls for VM fds |
@@ -440,7 +438,8 @@ struct kvm_trace_rec { | |||
440 | #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) | 438 | #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) |
441 | #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation) | 439 | #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation) |
442 | #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) | 440 | #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) |
443 | #define KVM_DEBUG_GUEST _IOW(KVMIO, 0x87, struct kvm_debug_guest) | 441 | /* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */ |
442 | #define KVM_DEBUG_GUEST __KVM_DEPRECATED_DEBUG_GUEST | ||
444 | #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) | 443 | #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) |
445 | #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) | 444 | #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) |
446 | #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) | 445 | #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) |
@@ -469,6 +468,26 @@ struct kvm_trace_rec { | |||
469 | #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) | 468 | #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) |
470 | /* Available with KVM_CAP_NMI */ | 469 | /* Available with KVM_CAP_NMI */ |
471 | #define KVM_NMI _IO(KVMIO, 0x9a) | 470 | #define KVM_NMI _IO(KVMIO, 0x9a) |
471 | /* Available with KVM_CAP_SET_GUEST_DEBUG */ | ||
472 | #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) | ||
473 | |||
474 | /* | ||
475 | * Deprecated interfaces | ||
476 | */ | ||
477 | struct kvm_breakpoint { | ||
478 | __u32 enabled; | ||
479 | __u32 padding; | ||
480 | __u64 address; | ||
481 | }; | ||
482 | |||
483 | struct kvm_debug_guest { | ||
484 | __u32 enabled; | ||
485 | __u32 pad; | ||
486 | struct kvm_breakpoint breakpoints[4]; | ||
487 | __u32 singlestep; | ||
488 | }; | ||
489 | |||
490 | #define __KVM_DEPRECATED_DEBUG_GUEST _IOW(KVMIO, 0x87, struct kvm_debug_guest) | ||
472 | 491 | ||
473 | #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) | 492 | #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) |
474 | #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) | 493 | #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) |