From patchwork Tue Jul 11 14:53:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Ovidiu PIRCALABU X-Patchwork-Id: 9834925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B2677602BD for ; Tue, 11 Jul 2017 14:55:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A04AC26212 for ; Tue, 11 Jul 2017 14:55:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 946DE28487; Tue, 11 Jul 2017 14:55:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 6500228479 for ; Tue, 11 Jul 2017 14:55:31 +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 1dUwXK-0006MS-BK; Tue, 11 Jul 2017 14:53:14 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dUwXI-0006MM-NQ for xen-devel@lists.xen.org; Tue, 11 Jul 2017 14:53:12 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id A3/3D-09901-756E4695; Tue, 11 Jul 2017 14:53:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsUSfTyjVTf8WUq kwfT3HBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bqKZEFh1sZK2ZMfcrewPg6q4uRk4NZwFqi 918zYxcjFweLQDOLxPW+XjYI5yezxLRDF9lAqoQEPCR6vneDJYQEFjBKNGy5wAyT2HdnMSNEY jGjxMJXa1lBEmwCRhJLlr1lB7FFBKQlrn2+DFbELDCFUeJo/w2wscICbhJbtv0EK2IRUJVonf MVLM4r4Cnx8PclJhBbQkBO4ua5TuYJjHwLGBlWMWoUpxaVpRbpGhvoJRVlpmeU5CZm5ugaGpj p5aYWFyemp+YkJhXrJefnbmIEhgsDEOxg/Ls28BCjJAeTkihvUGxKpBBfUn5KZUZicUZ8UWlO avEhRhkODiUJ3sNPgHKCRanpqRVpmTnAwIVJS3DwKInwaj4ESvMWFyTmFmemQ6ROMRpzbFi9/ gsTx6sJ/78xCbHk5eelSonz/gWZJABSmlGaBzcIFlGXGGWlhHkZgU4T4ilILcrNLEGVf8Uozs GoJMy7F2QKT2ZeCdy+V0CnMAGdsiYb7JSSRISUVAMjZ02+1/3yA08XMSdUq1+fMjMoameEw+4 JjorF0QrV+wozdAvnSchJKjx0DvAvZfDnsfnBtrtL1cwj89nP2qbObPaLGS/Wb5nI+S9wVlcy 47Kni6t40v43BizhWtq+dTU7t5CFc8S5jFbHzI7T/lWC/Zty7kzgFmLOnTz7a2b44zWx/bxTs 5VYijMSDbWYi4oTAU6MH2OjAgAA X-Env-Sender: ppircalabu@bitdefender.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1499784790!72768018!1 X-Originating-IP: [91.199.104.133] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63036 invoked from network); 11 Jul 2017 14:53:11 -0000 Received: from mx02.bbu.dsd.mx.bitdefender.com (HELO mx02.buh.bitdefender.com) (91.199.104.133) by server-7.tower-21.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 11 Jul 2017 14:53:11 -0000 Comment: DomainKeys? See http://domainkeys.sourceforge.net/ DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=PN0D81zweHIqY2Qnn22zcuD1Z1AD19MDL4O75knQN487j46LNUCcgbWjz3PxcaxGFLDODAFFMvt+NE+2tw/8mDQH7vGxfg4oMoZs3Nq69yFQKM6b9ZdBbcpmEx9G7bo461WY8j85aLLI8JiiWmetxdY09VhOHUb3uREPXysPu7XuF2qlBGg7yknjT8UNEfVr2GOvJccNfCklmDwmFkB0aTnJgBwLFehVQMUUTswFxO8+jk0YZu0Y+hY44AcEWsRBGZ69UpV7tHsm9t5PGAHa8tscaXDbpEpQkGXfgZSF++0lmfmf/hvlPVTS/AZ1zU8pY3cJtSzaaLkCSwdX5Y5vIw==; h=Received:Received:Received:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer; DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bitdefender.com; h=from:to :cc:subject:date:message-id; s=default; bh=WPY1csk5rgSTXjji5sZbZ ut6D6g=; b=XMJgtewejLQntTsb7rxm+FnSKZehxLpIO7fch/VXopHzHc4TY8uBS 5NhrgIbNGyNteMvtQlRjVmBuvSqpcdWrga8vuat5InVViNfd1qKBZgBd7q6VLOG9 kg+TgWJq7hJLPobVVVkoV0maNuWnmxpYkkWLetZgayNTGKI16ffNGl+KZz2S1VX3 BjTcHpTNBO/OcQKnuztnQezu0PW4Hx71TnFQaJdGvKkzsj9KAT4mcXH1oD7NJr3G zLGfTAX8+T9qsLi+fQsZzaSl1s7d3PRrVHKE0YXY+NtHMHVSe9Zerwy6bSlkxVuH B/GEZShkodQE1j0HJ9EyIyj6KAQtIS4jQ== Received: (qmail 10910 invoked from network); 11 Jul 2017 17:53:09 +0300 Received: from mx01robo.bbu.dsd.mx.bitdefender.com (10.17.80.60) by mx02.buh.bitdefender.com with AES128-GCM-SHA256 encrypted SMTP; 11 Jul 2017 17:53:09 +0300 Received: (qmail 21102 invoked from network); 11 Jul 2017 17:53:09 +0300 Received: from unknown (HELO pepi-OptiPlex-9020.dsd.bitdefender.biz) (10.10.194.146) by mx01robo.bbu.dsd.mx.bitdefender.com with SMTP; 11 Jul 2017 17:53:09 +0300 From: Petre Pircalabu To: xen-devel@lists.xen.org Date: Tue, 11 Jul 2017 17:53:06 +0300 Message-Id: <1499784786-8585-1-git-send-email-ppircalabu@bitdefender.com> X-Mailer: git-send-email 2.7.4 Cc: Petre Pircalabu , wei.liu2@citrix.com, tamas@tklengyel.com, ian.jackson@eu.citrix.com, rcojocaru@bitdefender.com Subject: [Xen-devel] [PATCH v2] x86/monitor: Notify monitor if an emulation fails. 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-Virus-Scanned: ClamAV using ClamSMTP If case of a vm_event with the emulate_flags set, if the instruction cannot be emulated, the monitor should be notified instead of directly injecting a hw exception. This behavior can be used to re-execute an instruction not supported by the emulator using the real processor (e.g. altp2m) instead of just crashing. Signed-off-by: Petre Pircalabu --- Changed since v1: * Removed the emulation kind check when calling hvm_inject_hw_exception --- tools/libxc/include/xenctrl.h | 2 + tools/libxc/xc_monitor.c | 14 ++ ...itor-Notify-monitor-if-an-emulation-fails.patch | 212 +++++++++++++++++++++ xen/arch/x86/hvm/emulate.c | 5 +- xen/arch/x86/hvm/monitor.c | 19 ++ xen/arch/x86/monitor.c | 12 ++ xen/include/asm-x86/domain.h | 1 + xen/include/asm-x86/hvm/monitor.h | 1 + xen/include/asm-x86/monitor.h | 3 +- xen/include/public/domctl.h | 1 + xen/include/public/vm_event.h | 2 + 11 files changed, 270 insertions(+), 2 deletions(-) create mode 100644 tools/tests/xen-access/0001-x86-monitor-Notify-monitor-if-an-emulation-fails.patch diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index c51bb3b..8deb5ac 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2029,6 +2029,8 @@ int xc_monitor_debug_exceptions(xc_interface *xch, domid_t domain_id, int xc_monitor_cpuid(xc_interface *xch, domid_t domain_id, bool enable); int xc_monitor_privileged_call(xc_interface *xch, domid_t domain_id, bool enable); +int xc_monitor_emul_unhandleable(xc_interface *xch, domid_t domain_id, + bool enable); /** * 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 b44ce93..8e72c6c 100644 --- a/tools/libxc/xc_monitor.c +++ b/tools/libxc/xc_monitor.c @@ -216,6 +216,20 @@ int xc_monitor_privileged_call(xc_interface *xch, domid_t domain_id, return do_domctl(xch, &domctl); } +int xc_monitor_emul_unhandleable(xc_interface *xch, domid_t domain_id, + bool enable) +{ + 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_EMUL_UNHANDLEABLE; + + return do_domctl(xch, &domctl); +} + /* * Local variables: * mode: C diff --git a/tools/tests/xen-access/0001-x86-monitor-Notify-monitor-if-an-emulation-fails.patch b/tools/tests/xen-access/0001-x86-monitor-Notify-monitor-if-an-emulation-fails.patch new file mode 100644 index 0000000..7a0d091 --- /dev/null +++ b/tools/tests/xen-access/0001-x86-monitor-Notify-monitor-if-an-emulation-fails.patch @@ -0,0 +1,212 @@ +From 97b3e9c22c7c6a0e49bde4e1bb6866a02ad43007 Mon Sep 17 00:00:00 2001 +From: Petre Pircalabu +Date: Thu, 29 Jun 2017 20:40:46 +0300 +Subject: [PATCH] x86/monitor: Notify monitor if an emulation fails. + +If case of a vm_event with the emulate_flags set, if the instruction +cannot be emulated, the monitor should be notified instead of directly +injecting a hw exception. +This behavior can be used to re-execute an instruction not supported by +the emulator using the real processor (e.g. altp2m) instead of just +crashing. + +Signed-off-by: Petre Pircalabu +--- + tools/libxc/include/xenctrl.h | 2 ++ + tools/libxc/xc_monitor.c | 14 ++++++++++++++ + xen/arch/x86/hvm/emulate.c | 5 ++++- + xen/arch/x86/hvm/monitor.c | 19 +++++++++++++++++++ + xen/arch/x86/monitor.c | 12 ++++++++++++ + xen/include/asm-x86/domain.h | 1 + + xen/include/asm-x86/hvm/monitor.h | 1 + + xen/include/asm-x86/monitor.h | 3 ++- + xen/include/public/domctl.h | 1 + + xen/include/public/vm_event.h | 2 ++ + 10 files changed, 58 insertions(+), 2 deletions(-) + +diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h +index c51bb3b..8deb5ac 100644 +--- a/tools/libxc/include/xenctrl.h ++++ b/tools/libxc/include/xenctrl.h +@@ -2029,6 +2029,8 @@ int xc_monitor_debug_exceptions(xc_interface *xch, domid_t domain_id, + int xc_monitor_cpuid(xc_interface *xch, domid_t domain_id, bool enable); + int xc_monitor_privileged_call(xc_interface *xch, domid_t domain_id, + bool enable); ++int xc_monitor_emul_unhandleable(xc_interface *xch, domid_t domain_id, ++ bool enable); + /** + * 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 b44ce93..8e72c6c 100644 +--- a/tools/libxc/xc_monitor.c ++++ b/tools/libxc/xc_monitor.c +@@ -216,6 +216,20 @@ int xc_monitor_privileged_call(xc_interface *xch, domid_t domain_id, + return do_domctl(xch, &domctl); + } + ++int xc_monitor_emul_unhandleable(xc_interface *xch, domid_t domain_id, ++ bool enable) ++{ ++ 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_EMUL_UNHANDLEABLE; ++ ++ return do_domctl(xch, &domctl); ++} ++ + /* + * Local variables: + * mode: C +diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c +index e97aa69..083a38a 100644 +--- a/xen/arch/x86/hvm/emulate.c ++++ b/xen/arch/x86/hvm/emulate.c +@@ -14,12 +14,14 @@ + #include + #include + #include ++#include + #include + #include + #include + #include + #include + #include ++#include + #include + #include + #include +@@ -2101,7 +2103,8 @@ void hvm_emulate_one_vm_event(enum emul_kind kind, unsigned int trapnr, + return; + case X86EMUL_UNHANDLEABLE: + hvm_dump_emulation_state(XENLOG_G_DEBUG, "Mem event", &ctx); +- hvm_inject_hw_exception(trapnr, errcode); ++ if ( (kind != EMUL_KIND_NORMAL) || !hvm_monitor_emul_unhandleable() ) ++ hvm_inject_hw_exception(trapnr, errcode); + break; + case X86EMUL_EXCEPTION: + hvm_inject_event(&ctx.ctxt.event); +diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c +index a7ccfc4..02e0ba5 100644 +--- a/xen/arch/x86/hvm/monitor.c ++++ b/xen/arch/x86/hvm/monitor.c +@@ -57,6 +57,25 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old + return 0; + } + ++ ++bool hvm_monitor_emul_unhandleable(void) ++{ ++ struct vcpu *curr = current; ++ struct domain *d = curr->domain; ++ ++ /* ++ * Send a vm_event to the monitor to signal that the current ++ * instruction couldn't be emulated. ++ */ ++ vm_event_request_t req = { ++ .reason = VM_EVENT_REASON_EMUL_UNHANDLEABLE, ++ .vcpu_id = curr->vcpu_id, ++ }; ++ ++ return ( d->arch.monitor.emul_unhandleable && ++ monitor_traps(curr, true, &req) ); ++} ++ + void hvm_monitor_msr(unsigned int msr, uint64_t value) + { + struct vcpu *curr = current; +diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c +index 706454f..51252fe 100644 +--- a/xen/arch/x86/monitor.c ++++ b/xen/arch/x86/monitor.c +@@ -283,6 +283,18 @@ int arch_monitor_domctl_event(struct domain *d, + break; + } + ++ case XEN_DOMCTL_MONITOR_EVENT_EMUL_UNHANDLEABLE: ++ { ++ bool old_status = ad->monitor.emul_unhandleable; ++ if ( unlikely(old_status == requested_status) ) ++ return -EEXIST; ++ ++ domain_pause(d); ++ ad->monitor.emul_unhandleable = requested_status; ++ domain_unpause(d); ++ break; ++ } ++ + default: + /* + * Should not be reached unless arch_monitor_get_capabilities() is +diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h +index c10522b..7f3b54c 100644 +--- a/xen/include/asm-x86/domain.h ++++ b/xen/include/asm-x86/domain.h +@@ -405,6 +405,7 @@ struct arch_domain + unsigned int debug_exception_sync : 1; + unsigned int cpuid_enabled : 1; + unsigned int descriptor_access_enabled : 1; ++ unsigned int emul_unhandleable : 1; + struct monitor_msr_bitmap *msr_bitmap; + uint64_t write_ctrlreg_mask[4]; + } monitor; +diff --git a/xen/include/asm-x86/hvm/monitor.h b/xen/include/asm-x86/hvm/monitor.h +index d9efb35..4030be7 100644 +--- a/xen/include/asm-x86/hvm/monitor.h ++++ b/xen/include/asm-x86/hvm/monitor.h +@@ -47,6 +47,7 @@ int hvm_monitor_cpuid(unsigned long insn_length, unsigned int leaf, + unsigned int subleaf); + void hvm_monitor_interrupt(unsigned int vector, unsigned int type, + unsigned int err, uint64_t cr2); ++bool hvm_monitor_emul_unhandleable(void); + + #endif /* __ASM_X86_HVM_MONITOR_H__ */ + +diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h +index c5c323b..38ba0ff 100644 +--- a/xen/include/asm-x86/monitor.h ++++ b/xen/include/asm-x86/monitor.h +@@ -77,7 +77,8 @@ static inline uint32_t arch_monitor_get_capabilities(struct domain *d) + (1U << XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST) | + (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) | + (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) | +- (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT); ++ (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) | ++ (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNHANDLEABLE); + + /* 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 ff39762..6bd8666 100644 +--- a/xen/include/public/domctl.h ++++ b/xen/include/public/domctl.h +@@ -1083,6 +1083,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cmt_op_t); + #define XEN_DOMCTL_MONITOR_EVENT_PRIVILEGED_CALL 7 + #define XEN_DOMCTL_MONITOR_EVENT_INTERRUPT 8 + #define XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS 9 ++#define XEN_DOMCTL_MONITOR_EVENT_EMUL_UNHANDLEABLE 10 + + struct xen_domctl_monitor_op { + uint32_t op; /* XEN_DOMCTL_MONITOR_OP_* */ +diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h +index f01e471..5548afb 100644 +--- a/xen/include/public/vm_event.h ++++ b/xen/include/public/vm_event.h +@@ -148,6 +148,8 @@ + #define VM_EVENT_REASON_INTERRUPT 12 + /* A descriptor table register was accessed. */ + #define VM_EVENT_REASON_DESCRIPTOR_ACCESS 13 ++/* Current instruction couldn't be emulated */ ++#define VM_EVENT_REASON_EMUL_UNHANDLEABLE 14 + + /* Supported values for the vm_event_write_ctrlreg index. */ + #define VM_EVENT_X86_CR0 0 +-- +2.7.4 + diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index e97aa69..f52aa87 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -14,12 +14,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -2101,7 +2103,8 @@ void hvm_emulate_one_vm_event(enum emul_kind kind, unsigned int trapnr, return; case X86EMUL_UNHANDLEABLE: hvm_dump_emulation_state(XENLOG_G_DEBUG, "Mem event", &ctx); - hvm_inject_hw_exception(trapnr, errcode); + if ( !hvm_monitor_emul_unhandleable() ) + hvm_inject_hw_exception(trapnr, errcode); break; case X86EMUL_EXCEPTION: hvm_inject_event(&ctx.ctxt.event); diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c index a7ccfc4..02e0ba5 100644 --- a/xen/arch/x86/hvm/monitor.c +++ b/xen/arch/x86/hvm/monitor.c @@ -57,6 +57,25 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long value, unsigned long old return 0; } + +bool hvm_monitor_emul_unhandleable(void) +{ + struct vcpu *curr = current; + struct domain *d = curr->domain; + + /* + * Send a vm_event to the monitor to signal that the current + * instruction couldn't be emulated. + */ + vm_event_request_t req = { + .reason = VM_EVENT_REASON_EMUL_UNHANDLEABLE, + .vcpu_id = curr->vcpu_id, + }; + + return ( d->arch.monitor.emul_unhandleable && + monitor_traps(curr, true, &req) ); +} + void hvm_monitor_msr(unsigned int msr, uint64_t value) { struct vcpu *curr = current; diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c index 706454f..51252fe 100644 --- a/xen/arch/x86/monitor.c +++ b/xen/arch/x86/monitor.c @@ -283,6 +283,18 @@ int arch_monitor_domctl_event(struct domain *d, break; } + case XEN_DOMCTL_MONITOR_EVENT_EMUL_UNHANDLEABLE: + { + bool old_status = ad->monitor.emul_unhandleable; + if ( unlikely(old_status == requested_status) ) + return -EEXIST; + + domain_pause(d); + ad->monitor.emul_unhandleable = requested_status; + domain_unpause(d); + break; + } + default: /* * Should not be reached unless arch_monitor_get_capabilities() is diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index c10522b..7f3b54c 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -405,6 +405,7 @@ struct arch_domain unsigned int debug_exception_sync : 1; unsigned int cpuid_enabled : 1; unsigned int descriptor_access_enabled : 1; + unsigned int emul_unhandleable : 1; struct monitor_msr_bitmap *msr_bitmap; uint64_t write_ctrlreg_mask[4]; } monitor; diff --git a/xen/include/asm-x86/hvm/monitor.h b/xen/include/asm-x86/hvm/monitor.h index d9efb35..4030be7 100644 --- a/xen/include/asm-x86/hvm/monitor.h +++ b/xen/include/asm-x86/hvm/monitor.h @@ -47,6 +47,7 @@ int hvm_monitor_cpuid(unsigned long insn_length, unsigned int leaf, unsigned int subleaf); void hvm_monitor_interrupt(unsigned int vector, unsigned int type, unsigned int err, uint64_t cr2); +bool hvm_monitor_emul_unhandleable(void); #endif /* __ASM_X86_HVM_MONITOR_H__ */ diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h index c5c323b..38ba0ff 100644 --- a/xen/include/asm-x86/monitor.h +++ b/xen/include/asm-x86/monitor.h @@ -77,7 +77,8 @@ static inline uint32_t arch_monitor_get_capabilities(struct domain *d) (1U << XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST) | (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) | (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) | - (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT); + (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) | + (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNHANDLEABLE); /* 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 ff39762..6bd8666 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1083,6 +1083,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cmt_op_t); #define XEN_DOMCTL_MONITOR_EVENT_PRIVILEGED_CALL 7 #define XEN_DOMCTL_MONITOR_EVENT_INTERRUPT 8 #define XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS 9 +#define XEN_DOMCTL_MONITOR_EVENT_EMUL_UNHANDLEABLE 10 struct xen_domctl_monitor_op { uint32_t op; /* XEN_DOMCTL_MONITOR_OP_* */ diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h index f01e471..5548afb 100644 --- a/xen/include/public/vm_event.h +++ b/xen/include/public/vm_event.h @@ -148,6 +148,8 @@ #define VM_EVENT_REASON_INTERRUPT 12 /* A descriptor table register was accessed. */ #define VM_EVENT_REASON_DESCRIPTOR_ACCESS 13 +/* Current instruction couldn't be emulated */ +#define VM_EVENT_REASON_EMUL_UNHANDLEABLE 14 /* Supported values for the vm_event_write_ctrlreg index. */ #define VM_EVENT_X86_CR0 0