In preparation for allowing for introspecting ARM and PV domains the old
control interface via the hvm_op hypercall is retired. A new control mechanism
is introduced via the domctl hypercall: monitor_op.
This patch aims to establish a base API on which future applications can build
on.
Suggested-by: Andrew Cooper andrew.coop...@citrix.com
Signed-off-by: Tamas K Lengyel tamas.leng...@zentific.com
Acked-by: Ian Campbell ian.campb...@citrix.com
Acked-by: Kevin Tian kevin.t...@intel.com
Acked-by: Daniel De Graaf dgde...@tycho.nsa.gov
---
v6: Convert monitor control fields to bool_t both in Xen and in libxc
Make monitor_domctl more compact by abstracting common patterns
Deprecated HVM params remain but throw error both in Xen and in libxc
Style fixes
Add another field to arch.domain that determines if mem_access emulation
is enabled and corresponding mem_access memops to enable/disable it
Add XSM check to monitor_domctl
v5: p2m_vm_event_sanity_check is moved into the monitor_op handler
v4: Style fixes
Only defining struct mov_to_cr and struct debug_event in asm-x86/domain.h
Add pause/unpause domain wrapper when enabled a monitor option.
---
MAINTAINERS | 1 +
tools/libxc/Makefile| 1 +
tools/libxc/include/xenctrl.h | 27 +
tools/libxc/xc_domain.c | 28 -
tools/libxc/xc_mem_access.c | 33 --
tools/libxc/xc_monitor.c| 115 +
tools/libxc/xc_private.h| 2 +-
tools/libxc/xc_vm_event.c | 7 +-
tools/tests/xen-access/xen-access.c | 30 +++---
xen/arch/x86/Makefile | 1 +
xen/arch/x86/hvm/emulate.c | 2 +-
xen/arch/x86/hvm/event.c| 58 ++-
xen/arch/x86/hvm/hvm.c | 33 +-
xen/arch/x86/hvm/vmx/vmcs.c | 7 +-
xen/arch/x86/hvm/vmx/vmx.c | 2 +-
xen/arch/x86/mm/p2m.c | 9 --
xen/arch/x86/monitor.c | 200
xen/common/domctl.c | 9 ++
xen/common/mem_access.c | 8 ++
xen/common/vm_event.c | 11 --
xen/include/asm-arm/monitor.h | 35 +++
xen/include/asm-arm/p2m.h | 18 +++-
xen/include/asm-x86/domain.h| 37 ++-
xen/include/asm-x86/hvm/domain.h| 1 -
xen/include/asm-x86/monitor.h | 31 ++
xen/include/asm-x86/p2m.h | 34 --
xen/include/public/domctl.h | 48 -
xen/include/public/hvm/params.h | 9 +-
xen/include/public/memory.h | 2 +
xen/include/public/vm_event.h | 2 +-
xen/xsm/flask/hooks.c | 3 +
xen/xsm/flask/policy/access_vectors | 2 +
32 files changed, 665 insertions(+), 141 deletions(-)
create mode 100644 tools/libxc/xc_monitor.c
create mode 100644 xen/arch/x86/monitor.c
create mode 100644 xen/include/asm-arm/monitor.h
create mode 100644 xen/include/asm-x86/monitor.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 1e1b6f9..3ebbc5e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -367,6 +367,7 @@ S: Supported
F: xen/common/vm_event.c
F: xen/common/mem_access.c
F: xen/arch/x86/hvm/event.c
+F: xen/arch/x86/monitor.c
XENTRACE
M: George Dunlap george.dun...@eu.citrix.com
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 22ba2a1..8b609cf 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -32,6 +32,7 @@ CTRL_SRCS-y += xc_cpu_hotplug.c
CTRL_SRCS-y += xc_resume.c
CTRL_SRCS-y += xc_tmem.c
CTRL_SRCS-y += xc_vm_event.c
+CTRL_SRCS-y += xc_monitor.c
CTRL_SRCS-y += xc_mem_paging.c
CTRL_SRCS-y += xc_mem_access.c
CTRL_SRCS-y += xc_memshr.c
diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 790db53..4d9c610 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -34,6 +34,7 @@
#include stddef.h
#include stdint.h
#include stdio.h
+#include stdbool.h
#include xen/xen.h
#include xen/domctl.h
#include xen/physdev.h
@@ -2307,6 +2308,32 @@ int xc_set_mem_access(xc_interface *xch, domid_t
domain_id,
int xc_get_mem_access(xc_interface *xch, domid_t domain_id,
uint64_t pfn, xenmem_access_t *access);
+/*
+ * Instructions causing a mem_access violation can be emulated by Xen
+ * to progress the execution without having to relax the mem_access
+ * permissions.
+ * This feature has to be first enabled, then in the vm_event
+ * response to a mem_access event it can indicated if the instruction
+ * should be emulated.
+ */
+int xc_mem_access_enable_emulate(xc_interface *xch, domid_t domain_id);
+int xc_mem_access_disable_emulate(xc_interface *xch, domid_t domain_id);
+
+/***
+ * Monitor control operations.
+ */
+int xc_monitor_mov_to_cr0(xc_interface *xch, domid_t domain_id, bool enable,
+ bool sync, bool onchangeonly);
+int