]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
HYPERCALL_callback infrastructure for PV guests
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 13 Apr 2017 16:40:26 +0000 (17:40 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 25 Apr 2017 13:06:50 +0000 (14:06 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/xen/arch-x86/xen-x86_32.h
include/xen/arch-x86/xen-x86_64.h
include/xen/callback.h [new file with mode: 0644]
include/xtf/hypercall.h

index 8ac5d2c48543de5cf7db956e4b8cfd0335ecad7f..d7a7ef29f0d19ee94cde0909b7f5aacc528d9029 100644 (file)
@@ -34,6 +34,12 @@ static inline unsigned int xen_cr3_to_pfn(unsigned int cr3)
     return cr3 >> 12 | cr3 << 20;
 }
 
+struct xen_callback {
+    unsigned long cs;
+    unsigned long eip;
+};
+typedef struct xen_callback xen_callback_t;
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* XEN_PUBLIC_ARCH_X86_XEN_X86_32_H */
index 293fa0dd0263dcaa51879775d8a8045d26dfa846..ef5f7a4442b9932c0e89ce79fb04c383a549f954 100644 (file)
 
 #define MACH2PHYS_VIRT_START 0xFFFF800000000000UL
 
+#ifndef __ASSEMBLY__
+
+typedef unsigned long xen_callback_t;
+
+#endif /* __ASSEMBLY__ */
+
 #endif /* XEN_PUBLIC_ARCH_X86_XEN_X86_64_H */
 
 /*
diff --git a/include/xen/callback.h b/include/xen/callback.h
new file mode 100644 (file)
index 0000000..251b695
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Xen public PV callback interface
+ */
+
+#ifndef XEN_PUBLIC_CALLBACK_H
+#define XEN_PUBLIC_CALLBACK_H
+
+#include "xen.h"
+
+/*
+ * Prototype for this hypercall is:
+ *   long callback_op(int cmd, void *extra_args)
+ * @cmd        == CALLBACKOP_??? (callback operation).
+ * @extra_args == Operation-specific extra arguments (NULL if none).
+ */
+
+/* x86: Callback for event delivery. */
+#define CALLBACKTYPE_event                 0
+
+/* x86: Failsafe callback when guest state cannot be restored by Xen. */
+#define CALLBACKTYPE_failsafe              1
+
+/* x86/64 hypervisor: Syscall by 64-bit guest app ('64-on-64-on-64'). */
+#define CALLBACKTYPE_syscall               2
+
+/*
+ * x86/32 hypervisor: Only available on x86/32 when supervisor_mode_kernel
+ *     feature is enabled. Do not use this callback type in new code.
+ */
+#define CALLBACKTYPE_sysenter_deprecated   3
+
+/* x86: Callback for NMI delivery. */
+#define CALLBACKTYPE_nmi                   4
+
+/*
+ * x86: sysenter is only available as follows:
+ * - 32-bit hypervisor: with the supervisor_mode_kernel feature enabled
+ * - 64-bit hypervisor: 32-bit guest applications on Intel CPUs
+ *                      ('32-on-32-on-64', '32-on-64-on-64')
+ *                      [nb. also 64-bit guest applications on Intel CPUs
+ *                           ('64-on-64-on-64'), but syscall is preferred]
+ */
+#define CALLBACKTYPE_sysenter              5
+
+/*
+ * x86/64 hypervisor: Syscall by 32-bit guest app on AMD CPUs
+ *                    ('32-on-32-on-64', '32-on-64-on-64')
+ */
+#define CALLBACKTYPE_syscall32             7
+
+/*
+ * Disable event deliver during callback? This flag is ignored for event and
+ * NMI callbacks: event delivery is unconditionally disabled.
+ */
+#define _CALLBACKF_mask_events             0
+#define CALLBACKF_mask_events              (1U << _CALLBACKF_mask_events)
+
+/*
+ * Register a callback.
+ */
+#define CALLBACKOP_register                0
+struct xen_callback_register {
+    uint16_t type;
+    uint16_t flags;
+    xen_callback_t address;
+};
+typedef struct xen_callback_register xen_callback_register_t;
+
+#endif /* XEN_PUBLIC_CALLBACK_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index a51b220f5867208568b644c9bf86b62455d8c3eb..aec5a12f30bece3c6c028d6cc90f6f304548cd1d 100644 (file)
@@ -29,6 +29,7 @@ extern uint8_t hypercall_page[PAGE_SIZE];
 /* All Xen ABI for includers convenience .*/
 #include <xen/xen.h>
 #include <xen/sched.h>
+#include <xen/callback.h>
 #include <xen/errno.h>
 #include <xen/event_channel.h>
 #include <xen/physdev.h>
@@ -100,6 +101,11 @@ static inline long hypercall_sched_op(unsigned int cmd, void *arg)
     return HYPERCALL2(long, __HYPERVISOR_sched_op, cmd, arg);
 }
 
+static inline long hypercall_callback_op(unsigned int cmd, const void *arg)
+{
+    return HYPERCALL2(long, __HYPERVISOR_callback_op, cmd, arg);
+}
+
 static inline long hypercall_event_channel_op(unsigned int cmd, void *arg)
 {
     return HYPERCALL2(long, __HYPERVISOR_event_channel_op, cmd, arg);
@@ -138,6 +144,11 @@ static inline void hypercall_yield(void)
     hypercall_sched_op(SCHEDOP_yield, NULL);
 }
 
+static inline int hypercall_register_callback(const xen_callback_register_t *arg)
+{
+    return hypercall_callback_op(CALLBACKOP_register, arg);
+}
+
 static inline int hypercall_evtchn_send(evtchn_port_t port)
 {
     return hypercall_event_channel_op(EVTCHNOP_send, &port);