]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Xen ABI bits for HVM guests
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 29 Apr 2015 16:50:56 +0000 (17:50 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 28 Sep 2015 13:54:43 +0000 (14:54 +0100)
 - HVMOP_get_param
 - HVM PV Console parameters
 - Xen CPUID leaves

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/hypercall_page.S
include/xen/arch-x86/cpuid.h [new file with mode: 0644]
include/xen/arch-x86/xen.h
include/xen/hvm/hvm_op.h [new file with mode: 0644]
include/xen/hvm/params.h [new file with mode: 0644]
include/xen/xen.h
include/xtf/hypercall.h

index 5447bc126fe4254da1ecd692f866c16de7649526..81b7a2f9aa9193f5c1df18371996b119992c0c20 100644 (file)
@@ -12,3 +12,4 @@ GLOBAL(hypercall_page)
 DECLARE_HYPERCALL(console_io)
 DECLARE_HYPERCALL(sched_op)
 DECLARE_HYPERCALL(event_channel_op)
+DECLARE_HYPERCALL(hvm_op)
diff --git a/include/xen/arch-x86/cpuid.h b/include/xen/arch-x86/cpuid.h
new file mode 100644 (file)
index 0000000..048cbbe
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Xen x86 public cpuid interface
+ */
+
+#ifndef XEN_PUBLIC_ARCH_X86_CPUID_H
+#define XEN_PUBLIC_ARCH_X86_CPUID_H
+
+/*
+ * For compatibility with other hypervisor interfaces, the Xen cpuid leaves
+ * can be found at the first otherwise unused 0x100 aligned boundary starting
+ * from 0x40000000.
+ *
+ * e.g If viridian extensions are enabled for an HVM domain, the Xen cpuid
+ * leaves will start at 0x40000100
+ */
+
+#define XEN_CPUID_FIRST_LEAF 0x40000000
+
+/*
+ * Leaf 1 (0x40000x00)
+ * EAX: Largest Xen-information leaf. All leaves up to an including @EAX
+ *      are supported by the Xen host.
+ * EBX-EDX: "XenVMMXenVMM" signature, allowing positive identification
+ *      of a Xen host.
+ */
+#define XEN_CPUID_SIGNATURE_EBX 0x566e6558 /* "XenV" */
+#define XEN_CPUID_SIGNATURE_ECX 0x65584d4d /* "MMXe" */
+#define XEN_CPUID_SIGNATURE_EDX 0x4d4d566e /* "nVMM" */
+
+/*
+ * Leaf 3 (0x40000x02)
+ * EAX: Number of hypercall transfer pages. This register is always guaranteed
+ *      to specify one hypercall page.
+ * EBX: Base address of Xen-specific MSRs.
+ * ECX: Features 1. Unused bits are set to zero.
+ * EDX: Features 2. Unused bits are set to zero.
+ */
+
+#endif /* XEN_PUBLIC_ARCH_X86_CPUID_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index b9e97f813f6e297f183b27aa8b0851ee474f4a11..4ae3b9a2b1f4884d4cda249a7bddcbf36090daba 100644 (file)
@@ -13,6 +13,8 @@
 # error Bad architecture
 #endif
 
+#include "cpuid.h"
+
 #ifndef __ASSEMBLY__
 typedef unsigned long xen_pfn_t;
 #endif
diff --git a/include/xen/hvm/hvm_op.h b/include/xen/hvm/hvm_op.h
new file mode 100644 (file)
index 0000000..8c240d8
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Xen public hvmop interface
+ */
+
+#ifndef XEN_PUBLIC_HVM_HVM_OP_H
+#define XEN_PUBLIC_HVM_HVM_OP_H
+
+/* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */
+#define HVMOP_set_param           0
+#define HVMOP_get_param           1
+struct xen_hvm_param {
+    domid_t  domid;
+    uint32_t index;
+    uint64_t value;
+};
+typedef struct xen_hvm_param xen_hvm_param_t;
+
+#endif /* XEN_PUBLIC_HVM_HVM_OP_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/hvm/params.h b/include/xen/hvm/params.h
new file mode 100644 (file)
index 0000000..101a5c5
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Xen public hvm paramter index
+ */
+
+#ifndef XEN_PUBLIC_HVM_PARAMS_H
+#define XEN_PUBLIC_HVM_PARAMS_H
+
+#define HVM_PARAM_CONSOLE_PFN    17
+#define HVM_PARAM_CONSOLE_EVTCHN 18
+
+#endif /* XEN_PUBLIC_HVM_PARAMS_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index d3e226f7e1edab05ed351d638e44186d762eb955..8a2c6972f459d20805cb0a3c9e58ae9015a94f03 100644 (file)
 #define __HYPERVISOR_console_io           18
 #define __HYPERVISOR_sched_op             29
 #define __HYPERVISOR_event_channel_op     32
+#define __HYPERVISOR_hvm_op               34
+
+#ifndef __ASSEMBLY__
+typedef uint16_t domid_t;
+#endif
+
+#define DOMID_SELF (0x7ff0U)
 
 /* Commands to HYPERVISOR_console_io */
 #define CONSOLEIO_write                   0
index 6aa8b68697f9e115c617826d28b56d82b49dce79..3fc705f60bd3064d36cc1f49ed59f3fd274835f4 100644 (file)
@@ -26,6 +26,8 @@ extern uint8_t hypercall_page[PAGE_SIZE];
 #include <xen/xen.h>
 #include <xen/sched.h>
 #include <xen/event_channel.h>
+#include <xen/hvm/hvm_op.h>
+#include <xen/hvm/params.h>
 
 /*
  * Hypercall primatives, compiled for the correct bitness
@@ -40,6 +42,11 @@ static inline long hypercall_event_channel_op(unsigned int cmd, void *arg)
     return HYPERCALL2(long, event_channel_op, cmd, arg);
 }
 
+static inline long hypercall_hvm_op(unsigned int cmd, void *arg)
+{
+    return HYPERCALL2(long, hvm_op, cmd, arg);
+}
+
 /*
  * Higher level hypercall helpers
  */
@@ -63,6 +70,23 @@ static inline int hypercall_evtchn_send(evtchn_port_t port)
     return hypercall_event_channel_op(EVTCHNOP_send, &port);
 }
 
+static inline int hvm_set_param(unsigned int idx, uint64_t value)
+{
+    xen_hvm_param_t p = { .domid = DOMID_SELF, .index = idx, .value = value };
+
+    return hypercall_hvm_op(HVMOP_set_param, &p);
+}
+
+static inline int hvm_get_param(unsigned int idx, uint64_t *value)
+{
+    xen_hvm_param_t p = { .domid = DOMID_SELF, .index = idx };
+    int rc = hypercall_hvm_op(HVMOP_get_param, &p);
+
+    if ( rc == 0 )
+        *value = p.value;
+    return rc;
+}
+
 #endif /* XTF_HYPERCALL_H */
 
 /*