From patchwork Wed Apr 27 20:33:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 8962641 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C12A4BF29F for ; Wed, 27 Apr 2016 20:36:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4572D2025A for ; Wed, 27 Apr 2016 20:36:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24A78200E1 for ; Wed, 27 Apr 2016 20:36:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avW9N-00057D-RD; Wed, 27 Apr 2016 20:33:33 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avW9M-000577-FZ for xen-devel@lists.xenproject.org; Wed, 27 Apr 2016 20:33:32 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 46/12-07120-B1221275; Wed, 27 Apr 2016 20:33:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeJIrShJLcpLzFFi42K5GHpLR1dKSTH cYNkeQ4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNePJ1cfsBUe7GSuuzjjF3sC4M7mLkYtDSGAG o8TT35eZuxg5OSQE3rFIfD0t3cXIAWTHSLReNoQIV0ocPdbKAmILCWhI3L7ZyA7R28Ukcf90N ytIgk1AW6Lt9S4wW0RASeLeqslMIEXMAn1MEu/mrGYCGSosYC6x9FcFSA2LgKrE4lWbmEBsXg EnidfTJkDdICdx/vhP5gmMvAsYGVYxqhenFpWlFuka6yUVZaZnlOQmZuboGhqY6eWmFhcnpqf mJCYV6yXn525iBIYDAxDsYOz453SIUZKDSUmUd8MfhXAhvqT8lMqMxOKM+KLSnNTiQ4wyHBxK EryHFBTDhQSLUtNTK9Iyc4CBCZOW4OBREuF1AEnzFhck5hZnpkOkTjEac2z5fW0tE8e2qffWM gmx5OXnpUqJ87aClAqAlGaU5sENgkXMJUZZKWFeRqDThHgKUotyM0tQ5V8xinMwKgnz3gKZwp OZVwK37xXQKUxAp1w+JAtySkkiQkqqgbFi43Y750ATvh3t2YwrpinvP+X/VOPYuk1Tul0/mhX zPX576/AK6xt3MvSP7Dhj/sJN8vdno/Y53lpP1gQ3BBys3rl7c3juRimN2xxcQZsnzruwPpSh 4pXZC3vx80LebzRdeaISbym8s5sidKUh7IDm2qT/aU5nvs/aYcmm75JpMMF0qrzI+QAlluKMR EMt5qLiRABJdeZOkwIAAA== X-Env-Sender: tamas.k.lengyel@gmail.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1461789209!11628867!1 X-Originating-IP: [209.85.218.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41493 invoked from network); 27 Apr 2016 20:33:30 -0000 Received: from mail-oi0-f44.google.com (HELO mail-oi0-f44.google.com) (209.85.218.44) by server-5.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 27 Apr 2016 20:33:30 -0000 Received: by mail-oi0-f44.google.com with SMTP id x19so62106059oix.2 for ; Wed, 27 Apr 2016 13:33:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=D5sMmGykFZjahukyRZx3rmjeX60RkAQB+BpPsZLLXBs=; b=NyMridKyNh5eXhdnBZuucY68OePSB1MOt08rxXRo6+WYfj4SEuvL/jFjWRPcfE4ys0 42oDcq6LNdINDSzB7y8Oc7EV3egzIg3HOypU/quHZwuv7S/7qeCKGYCBJeclnB9AOU3P frM2tbMzwcQrL3mmAwXD0dP0PIcPmqcVWsNvYGJpT4AK8l3ctgA8ry46fS4MEDlBJzve 5RAsE1S7FySaRazDRsF/cTLF/7BHZV+5Mlh3kkDJsAs894kFEMavzujCeViDP9J+E6xc aDapHbdpU347NdnAlCAn22NIMv3prryHC4RBbwq4HPO26bXLSGbw+TcE30VJg6ibsUCd hGVA== X-Gm-Message-State: AOPr4FVp6r9T3/KZODdocV2FdL+sL9NJq2MIH0XiS+L6OqZ+AimG5w0zrGGV6MuOesfzJw== X-Received: by 10.157.49.118 with SMTP id v51mr4923774otd.97.1461789209168; Wed, 27 Apr 2016 13:33:29 -0700 (PDT) Received: from l1.lan (c-73-14-35-59.hsd1.co.comcast.net. [73.14.35.59]) by smtp.gmail.com with ESMTPSA id a10sm1810812obj.21.2016.04.27.13.33.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Apr 2016 13:33:27 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Wed, 27 Apr 2016 14:33:24 -0600 Message-Id: <1461789204-3099-1-git-send-email-tamas@tklengyel.com> X-Mailer: git-send-email 2.1.4 Cc: Kevin Tian , Tamas K Lengyel , Keir Fraser , Jan Beulich , Razvan Cojocaru , Andrew Cooper , Jun Nakajima Subject: [Xen-devel] [PATCH] x86/hvm: Add debug exception vm_events X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since in-guest debug exceptions are now unconditionally trapped to Xen, adding a hook for vm_event subscribers to tap into this new always-on guest event. We rename along the way hvm_event_breakpoint_type to hvm_event_type to better match the various events that can be passed with it. We also introduce the necessary monitor_op domctl's to enable subscribing to the events. Signed-off-by: Tamas K Lengyel --- Cc: Razvan Cojocaru Cc: Keir Fraser Cc: Jan Beulich Cc: Andrew Cooper Cc: Jun Nakajima Cc: Kevin Tian --- tools/libxc/include/xenctrl.h | 3 +- tools/libxc/xc_monitor.c | 15 +++++++++ tools/tests/xen-access/xen-access.c | 61 +++++++++++++++++++++++++++++++++---- xen/arch/x86/hvm/event.c | 26 ++++++++++++++-- xen/arch/x86/hvm/vmx/vmx.c | 24 ++++++++++++--- xen/arch/x86/monitor.c | 16 ++++++++++ xen/include/asm-x86/domain.h | 2 ++ xen/include/asm-x86/hvm/event.h | 7 +++-- xen/include/asm-x86/vm_event.h | 3 +- xen/include/public/domctl.h | 6 ++++ xen/include/public/vm_event.h | 12 +++++++- 11 files changed, 156 insertions(+), 19 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index f5a034a..8d70fed 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2190,7 +2190,8 @@ int xc_monitor_software_breakpoint(xc_interface *xch, domid_t domain_id, bool enable); int xc_monitor_guest_request(xc_interface *xch, domid_t domain_id, bool enable, bool sync); - +int xc_monitor_debug_exceptions(xc_interface *xch, domid_t domain_id, + bool enable, bool sync); /** * This function enables / disables emulation for each REP for a * REP-compatible instruction. diff --git a/tools/libxc/xc_monitor.c b/tools/libxc/xc_monitor.c index b1705dd..e33b40b 100644 --- a/tools/libxc/xc_monitor.c +++ b/tools/libxc/xc_monitor.c @@ -156,3 +156,18 @@ int xc_monitor_emulate_each_rep(xc_interface *xch, domid_t domain_id, return do_domctl(xch, &domctl); } + +int xc_monitor_debug_exceptions(xc_interface *xch, domid_t domain_id, + bool enable, bool sync) +{ + DECLARE_DOMCTL; + + domctl.cmd = XEN_DOMCTL_monitor_op; + domctl.domain = domain_id; + domctl.u.monitor_op.op = enable ? XEN_DOMCTL_MONITOR_OP_ENABLE + : XEN_DOMCTL_MONITOR_OP_DISABLE; + domctl.u.monitor_op.event = XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION; + domctl.u.monitor_op.u.debug_exception.sync = sync; + + return do_domctl(xch, &domctl); +} diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index f26e723..cb18a85 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -53,6 +53,10 @@ #define ERROR(a, b...) fprintf(stderr, a "\n", ## b) #define PERROR(a, b...) fprintf(stderr, a ": %s\n", ## b, strerror(errno)) +/* From xen/include/asm-x86/processor.h */ +#define X86_TRAP_DEBUG 1 +#define X86_TRAP_INT3 3 + typedef struct vm_event { domid_t domain_id; xenevtchn_handle *xce_handle; @@ -333,7 +337,7 @@ void usage(char* progname) { fprintf(stderr, "Usage: %s [-m] write|exec", progname); #if defined(__i386__) || defined(__x86_64__) - fprintf(stderr, "|breakpoint|altp2m_write|altp2m_exec"); + fprintf(stderr, "|breakpoint|altp2m_write|altp2m_exec|debug"); #endif fprintf(stderr, "\n" @@ -354,10 +358,12 @@ int main(int argc, char *argv[]) xc_interface *xch; xenmem_access_t default_access = XENMEM_access_rwx; xenmem_access_t after_first_access = XENMEM_access_rwx; + int memaccess = 0; int required = 0; int breakpoint = 0; int shutting_down = 0; int altp2m = 0; + int debug = 0; uint16_t altp2m_view_id = 0; char* progname = argv[0]; @@ -391,11 +397,13 @@ int main(int argc, char *argv[]) { default_access = XENMEM_access_rx; after_first_access = XENMEM_access_rwx; + memaccess = 1; } else if ( !strcmp(argv[0], "exec") ) { default_access = XENMEM_access_rw; after_first_access = XENMEM_access_rwx; + memaccess = 1; } #if defined(__i386__) || defined(__x86_64__) else if ( !strcmp(argv[0], "breakpoint") ) @@ -406,11 +414,17 @@ int main(int argc, char *argv[]) { default_access = XENMEM_access_rx; altp2m = 1; + memaccess = 1; } else if ( !strcmp(argv[0], "altp2m_exec") ) { default_access = XENMEM_access_rw; altp2m = 1; + memaccess = 1; + } + else if ( !strcmp(argv[0], "debug") ) + { + debug = 1; } #endif else @@ -446,7 +460,7 @@ int main(int argc, char *argv[]) } /* With altp2m we just create a new, restricted view of the memory */ - if ( altp2m ) + if ( memaccess && altp2m ) { xen_pfn_t gfn = 0; unsigned long perm_set = 0; @@ -493,7 +507,7 @@ int main(int argc, char *argv[]) } } - if ( !altp2m ) + if ( memaccess && !altp2m ) { /* Set the default access type and convert all pages to it */ rc = xc_set_mem_access(xch, domain_id, default_access, ~0ull, 0); @@ -524,6 +538,16 @@ int main(int argc, char *argv[]) } } + if ( debug ) + { + rc = xc_monitor_debug_exceptions(xch, domain_id, 1, 1); + if ( rc < 0 ) + { + ERROR("Error %d setting debug exception listener with vm_event\n", rc); + goto exit; + } + } + /* Wait for access */ for (;;) { @@ -535,6 +559,9 @@ int main(int argc, char *argv[]) if ( breakpoint ) rc = xc_monitor_software_breakpoint(xch, domain_id, 0); + if ( debug ) + rc = xc_monitor_debug_exceptions(xch, domain_id, 0, 0); + if ( altp2m ) { rc = xc_altp2m_switch_to_view( xch, domain_id, 0 ); @@ -641,9 +668,10 @@ int main(int argc, char *argv[]) req.vcpu_id); /* Reinject */ - rc = xc_hvm_inject_trap( - xch, domain_id, req.vcpu_id, 3, - HVMOP_TRAP_sw_exc, -1, 0, 0); + rc = xc_hvm_inject_trap(xch, domain_id, req.vcpu_id, + X86_TRAP_INT3, + req.u.software_breakpoint.type, -1, + req.u.software_breakpoint.insn_length, 0); if (rc < 0) { ERROR("Error %d injecting breakpoint\n", rc); @@ -669,6 +697,27 @@ int main(int argc, char *argv[]) rsp.flags |= VM_EVENT_FLAG_TOGGLE_SINGLESTEP; break; + case VM_EVENT_REASON_DEBUG_EXCEPTION: + printf("Debug exception: rip=%016"PRIx64", vcpu %d. Type: %u. Length: %u\n", + req.data.regs.x86.rip, + req.vcpu_id, + req.u.debug_exception.type, + req.u.debug_exception.insn_length); + + /* Reinject */ + rc = xc_hvm_inject_trap(xch, domain_id, req.vcpu_id, + X86_TRAP_DEBUG, + req.u.debug_exception.type, -1, + req.u.debug_exception.insn_length, + req.data.regs.x86.cr2); + if (rc < 0) + { + ERROR("Error %d injecting breakpoint\n", rc); + interrupted = -1; + continue; + } + + break; default: fprintf(stderr, "UNKNOWN REASON CODE %d\n", req.reason); } diff --git a/xen/arch/x86/hvm/event.c b/xen/arch/x86/hvm/event.c index 56c5514..0251d7d 100644 --- a/xen/arch/x86/hvm/event.c +++ b/xen/arch/x86/hvm/event.c @@ -87,12 +87,14 @@ static inline unsigned long gfn_of_rip(unsigned long rip) return paging_gva_to_gfn(curr, sreg.base + rip, &pfec); } -int hvm_event_breakpoint(unsigned long rip, - enum hvm_event_breakpoint_type type) +int hvm_monitor_event(unsigned long rip, enum hvm_event_type type, + unsigned long trap_type, unsigned long insn_length) { struct vcpu *curr = current; struct arch_domain *ad = &curr->domain->arch; vm_event_request_t req = {}; + bool_t sync; + int rc; switch ( type ) { @@ -101,6 +103,9 @@ int hvm_event_breakpoint(unsigned long rip, return 0; req.reason = VM_EVENT_REASON_SOFTWARE_BREAKPOINT; req.u.software_breakpoint.gfn = gfn_of_rip(rip); + req.u.software_breakpoint.type = trap_type; + req.u.software_breakpoint.insn_length = insn_length; + sync = 1; break; case HVM_EVENT_SINGLESTEP_BREAKPOINT: @@ -108,6 +113,17 @@ int hvm_event_breakpoint(unsigned long rip, return 0; req.reason = VM_EVENT_REASON_SINGLESTEP; req.u.singlestep.gfn = gfn_of_rip(rip); + sync = 1; + break; + + case HVM_EVENT_DEBUG_EXCEPTION: + if ( !ad->monitor.debug_exception_enabled ) + return 0; + req.reason = VM_EVENT_REASON_DEBUG_EXCEPTION; + req.u.debug_exception.gfn = gfn_of_rip(rip); + req.u.debug_exception.type = trap_type; + req.u.debug_exception.insn_length = insn_length; + sync = !!ad->monitor.debug_exception_sync; break; default: @@ -116,7 +132,11 @@ int hvm_event_breakpoint(unsigned long rip, req.vcpu_id = curr->vcpu_id; - return vm_event_monitor_traps(curr, 1, &req); + rc = vm_event_monitor_traps(curr, sync, &req); + if ( rc == 1 && type == HVM_EVENT_DEBUG_EXCEPTION && !sync ) + rc = 0; + + return rc; } /* diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index bc4410f..38788ad 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3373,9 +3373,24 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) HVMTRACE_1D(TRAP_DEBUG, exit_qualification); write_debugreg(6, exit_qualification | DR_STATUS_RESERVED_ONE); if ( !v->domain->debugger_attached ) - vmx_propagate_intr(intr_info); + { + unsigned long insn_length = 0; + int handled; + unsigned long trap_type = MASK_EXTR(intr_info, + INTR_INFO_INTR_TYPE_MASK); + + if( trap_type >= X86_EVENTTYPE_SW_INTERRUPT ) + __vmread(VM_EXIT_INSTRUCTION_LEN, &insn_length); + + handled = hvm_monitor_event(regs->eip, HVM_EVENT_DEBUG_EXCEPTION, + trap_type, insn_length); + if ( handled <= 0 ) + vmx_propagate_intr(intr_info); + + } else domain_pause_for_debugger(); + break; case TRAP_int3: { @@ -3389,8 +3404,9 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) } else { int handled = - hvm_event_breakpoint(regs->eip, - HVM_EVENT_SOFTWARE_BREAKPOINT); + hvm_monitor_event(regs->eip, + HVM_EVENT_SOFTWARE_BREAKPOINT, + X86_EVENTTYPE_SW_EXCEPTION, 1); if ( handled < 0 ) { @@ -3717,7 +3733,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) vmx_update_cpu_exec_control(v); if ( v->arch.hvm_vcpu.single_step ) { - hvm_event_breakpoint(regs->eip, HVM_EVENT_SINGLESTEP_BREAKPOINT); + hvm_monitor_event(regs->eip, HVM_EVENT_SINGLESTEP_BREAKPOINT, 0, 0); if ( v->domain->debugger_attached ) domain_pause_for_debugger(); } diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c index 1fec412..36ccb11 100644 --- a/xen/arch/x86/monitor.c +++ b/xen/arch/x86/monitor.c @@ -124,6 +124,22 @@ int arch_monitor_domctl_event(struct domain *d, break; } + case XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION: + { + bool_t old_status = ad->monitor.debug_exception_enabled; + + if ( unlikely(old_status == requested_status) ) + return -EEXIST; + + domain_pause(d); + ad->monitor.debug_exception_enabled = requested_status; + ad->monitor.debug_exception_sync = requested_status ? + mop->u.debug_exception.sync : + 0; + domain_unpause(d); + break; + } + default: /* * Should not be reached unless vm_event_monitor_get_capabilities() is diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 165e533..1cf97c3 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -405,6 +405,8 @@ struct arch_domain unsigned int mov_to_msr_extended : 1; unsigned int singlestep_enabled : 1; unsigned int software_breakpoint_enabled : 1; + unsigned int debug_exception_enabled : 1; + unsigned int debug_exception_sync : 1; } monitor; /* Mem_access emulation control */ diff --git a/xen/include/asm-x86/hvm/event.h b/xen/include/asm-x86/hvm/event.h index 03f7fee..a8f5909 100644 --- a/xen/include/asm-x86/hvm/event.h +++ b/xen/include/asm-x86/hvm/event.h @@ -23,10 +23,11 @@ #include #include -enum hvm_event_breakpoint_type +enum hvm_event_type { HVM_EVENT_SOFTWARE_BREAKPOINT, HVM_EVENT_SINGLESTEP_BREAKPOINT, + HVM_EVENT_DEBUG_EXCEPTION, }; /* @@ -39,8 +40,8 @@ bool_t hvm_event_cr(unsigned int index, unsigned long value, #define hvm_event_crX(cr, new, old) \ hvm_event_cr(VM_EVENT_X86_##cr, new, old) void hvm_event_msr(unsigned int msr, uint64_t value); -int hvm_event_breakpoint(unsigned long rip, - enum hvm_event_breakpoint_type type); +int hvm_monitor_event(unsigned long rip, enum hvm_event_type type, + unsigned long trap_type, unsigned long insn_length); #endif /* __ASM_X86_HVM_EVENT_H__ */ diff --git a/xen/include/asm-x86/vm_event.h b/xen/include/asm-x86/vm_event.h index 0470240..be6ac28 100644 --- a/xen/include/asm-x86/vm_event.h +++ b/xen/include/asm-x86/vm_event.h @@ -58,7 +58,8 @@ static inline uint32_t vm_event_monitor_get_capabilities(struct domain *d) capabilities = (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG) | (1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR) | (1U << XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT) | - (1U << XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST); + (1U << XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST) | + (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION); /* Since we know this is on VMX, we can just call the hvm func */ if ( hvm_is_singlestep_supported() ) diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 2457698..2050441 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1080,6 +1080,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cmt_op_t); #define XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP 2 #define XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT 3 #define XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST 4 +#define XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION 5 struct xen_domctl_monitor_op { uint32_t op; /* XEN_DOMCTL_MONITOR_OP_* */ @@ -1115,6 +1116,11 @@ struct xen_domctl_monitor_op { /* Pause vCPU until response */ uint8_t sync; } guest_request; + + struct { + /* Pause vCPU until response */ + uint8_t sync; + } debug_exception; } u; }; typedef struct xen_domctl_monitor_op xen_domctl_monitor_op_t; diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h index 9270d52..67387fc 100644 --- a/xen/include/public/vm_event.h +++ b/xen/include/public/vm_event.h @@ -119,6 +119,8 @@ #define VM_EVENT_REASON_SINGLESTEP 7 /* An event has been requested via HVMOP_guest_request_vm_event. */ #define VM_EVENT_REASON_GUEST_REQUEST 8 +/* A debug exception was caught */ +#define VM_EVENT_REASON_DEBUG_EXCEPTION 9 /* Supported values for the vm_event_write_ctrlreg index. */ #define VM_EVENT_X86_CR0 0 @@ -203,8 +205,15 @@ struct vm_event_write_ctrlreg { uint64_t old_value; }; +struct vm_event_singlestep { + uint64_t gfn; +}; + struct vm_event_debug { uint64_t gfn; + uint8_t type; /* HVMOP_TRAP_* */ + uint8_t insn_length; + uint8_t _pad[6]; }; struct vm_event_mov_to_msr { @@ -248,7 +257,8 @@ typedef struct vm_event_st { struct vm_event_write_ctrlreg write_ctrlreg; struct vm_event_mov_to_msr mov_to_msr; struct vm_event_debug software_breakpoint; - struct vm_event_debug singlestep; + struct vm_event_singlestep singlestep; + struct vm_event_debug debug_exception; } u; union {