@@ -8,7 +8,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
{
switch(d_config->c_info.type) {
case LIBXL_DOMAIN_TYPE_HVM:
- config->arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+ config->arch.emulation_flags = (XEN_X86_EMU__ALL & ~XEN_X86_EMU_VPCI);
if (!libxl_defbool_val(d_config->b_info.u.hvm.pirq))
config->arch.emulation_flags &= ~XEN_X86_EMU_USE_PIRQ;
break;
@@ -24,7 +24,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
config->arch.misc_flags = 0;
if (libxl_defbool_val(d_config->b_info.arch_x86.msr_relaxed))
- config->arch.misc_flags |= XEN_X86_MSR_RELAXED;
+ config->arch.misc_flags |= XEN_X86_MISC_MSR_RELAXED;
return 0;
}
@@ -260,12 +260,12 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
cfg.arch.emulation_flags = ocaml_list_to_c_bitmap
/* ! x86_arch_emulation_flags X86_EMU_ none */
- /* ! XEN_X86_EMU_ XEN_X86_EMU_ALL all */
+ /* ! XEN_X86_EMU_ XEN_X86_EMU__ALL all */
(VAL_EMUL_FLAGS);
cfg.arch.misc_flags = ocaml_list_to_c_bitmap
/* ! x86_arch_misc_flags X86_ none */
- /* ! XEN_X86_ XEN_X86_MSR_RELAXED all */
+ /* ! XEN_X86_ XEN_X86_MISC__ALL all */
(VAL_MISC_FLAGS);
#undef VAL_MISC_FLAGS
new file mode 100644
@@ -0,0 +1,87 @@
+[[bitmaps]]
+name = "xen_x86_emu"
+description = "Content of the `emulation_flags` field of the domain creation hypercall."
+typ = { tag = "u32" }
+
+[[bitmaps.bits]]
+name = "lapic"
+description = "Emulate Local APICs."
+shift = 0
+
+[[bitmaps.bits]]
+name = "hpet"
+description = "Emulate a HPET timer."
+shift = 1
+
+[[bitmaps.bits]]
+name = "pm"
+description = "Emulate the ACPI PM timer."
+shift = 2
+
+[[bitmaps.bits]]
+name = "rtc"
+description = "Emulate the RTC clock."
+shift = 3
+
+[[bitmaps.bits]]
+name = "ioapic"
+description = "Emulate an IOAPIC device."
+shift = 4
+
+[[bitmaps.bits]]
+name = "pic"
+description = "Emulate PIC devices."
+shift = 5
+
+[[bitmaps.bits]]
+name = "vga"
+description = "Emulate standard VGA."
+shift = 6
+
+[[bitmaps.bits]]
+name = "iommu"
+description = "Emulate an IOMMU."
+shift = 7
+
+[[bitmaps.bits]]
+name = "pit"
+description = "Emulate a PIT timer."
+shift = 8
+
+[[bitmaps.bits]]
+name = "use_pirq"
+description = "Route physical IRQs over event channels."
+shift = 9
+
+[[bitmaps.bits]]
+name = "vpci"
+description = "Handle PCI configuration space traps from within Xen."
+shift = 10
+
+################################################################################
+
+[[bitmaps]]
+name = "xen_x86_misc"
+description = "Contents of the `misc_flags` field of the domain creation hypercall"
+typ = { tag = "u32" }
+
+[[bitmaps.bits]]
+name = "msr_relaxed"
+description = "Grants access to the real physical MSR registers of the host."
+shift = 0
+
+################################################################################
+
+[[structs]]
+name = "xen_arch_domainconfig"
+description = "x86-specific domain settings."
+
+[[structs.fields]]
+name = "emulation_flags"
+description = "IN: Bitmap of devices to emulate."
+typ = { tag = "bitmap", args = "xen_x86_emu" }
+
+[[structs.fields]]
+name = "misc_flags"
+description = "IN: Miscellaneous x86-specific toggles."
+typ = { tag = "bitmap", args = "xen_x86_misc" }
@@ -1,3 +1,9 @@
+[[includes]]
+from = "arch"
+imports = ["xen_arch_domainconfig"]
+
+################################################################################
+
[[enums]]
name = "xen_domctl_altp2m_mode"
description = "Content of the `altp2m_mode` field of the domain creation hypercall."
@@ -708,7 +708,7 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
}
}
- if ( config->arch.misc_flags & ~XEN_X86_MSR_RELAXED )
+ if ( config->arch.misc_flags & ~XEN_X86_MISC_MSR_RELAXED )
{
dprintk(XENLOG_INFO, "Invalid arch misc flags %#x\n",
config->arch.misc_flags);
@@ -735,7 +735,7 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
{
#ifdef CONFIG_HVM
/* This doesn't catch !CONFIG_HVM case but it is better than nothing */
- BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL);
+ BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU__ALL);
#endif
if ( is_hvm_domain(d) )
@@ -800,7 +800,7 @@ int arch_domain_create(struct domain *d,
if ( is_hardware_domain(d) && is_pv_domain(d) )
emflags |= XEN_X86_EMU_PIT;
- if ( emflags & ~XEN_X86_EMU_ALL )
+ if ( emflags & ~XEN_X86_EMU__ALL )
{
printk(XENLOG_G_ERR "d%d: Invalid emulation bitmap: %#x\n",
d->domain_id, emflags);
@@ -887,7 +887,7 @@ int arch_domain_create(struct domain *d,
domain_cpu_policy_changed(d);
- d->arch.msr_relaxed = config->arch.misc_flags & XEN_X86_MSR_RELAXED;
+ d->arch.msr_relaxed = config->arch.misc_flags & XEN_X86_MISC_MSR_RELAXED;
return 0;
@@ -12,6 +12,8 @@
#include <public/vcpu.h>
#include <public/hvm/hvm_info_table.h>
+#include <public/autogen/arch_x86.h>
+
#define has_32bit_shinfo(d) ((d)->arch.has_32bit_shinfo)
/*
@@ -486,7 +488,7 @@ struct arch_domain
#define X86_EMU_PIT XEN_X86_EMU_PIT
-/* This must match XEN_X86_EMU_ALL in xen.h */
+/* This must match XEN_X86_EMU__ALL */
#define X86_EMU_ALL (X86_EMU_LAPIC | X86_EMU_HPET | \
X86_EMU_PM | X86_EMU_RTC | \
X86_EMU_IOAPIC | X86_EMU_PIC | \
@@ -967,7 +967,7 @@ static struct domain *__init create_dom0(const module_t *image,
.max_grant_version = opt_gnttab_max_version,
.max_vcpus = dom0_max_vcpus(),
.arch = {
- .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0,
+ .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MISC_MSR_RELAXED : 0,
},
};
struct domain *d;
@@ -255,57 +255,6 @@ struct arch_shared_info {
};
typedef struct arch_shared_info arch_shared_info_t;
-#if defined(__XEN__) || defined(__XEN_TOOLS__)
-/*
- * struct xen_arch_domainconfig's ABI is covered by
- * XEN_DOMCTL_INTERFACE_VERSION.
- */
-struct xen_arch_domainconfig {
-#define _XEN_X86_EMU_LAPIC 0
-#define XEN_X86_EMU_LAPIC (1U<<_XEN_X86_EMU_LAPIC)
-#define _XEN_X86_EMU_HPET 1
-#define XEN_X86_EMU_HPET (1U<<_XEN_X86_EMU_HPET)
-#define _XEN_X86_EMU_PM 2
-#define XEN_X86_EMU_PM (1U<<_XEN_X86_EMU_PM)
-#define _XEN_X86_EMU_RTC 3
-#define XEN_X86_EMU_RTC (1U<<_XEN_X86_EMU_RTC)
-#define _XEN_X86_EMU_IOAPIC 4
-#define XEN_X86_EMU_IOAPIC (1U<<_XEN_X86_EMU_IOAPIC)
-#define _XEN_X86_EMU_PIC 5
-#define XEN_X86_EMU_PIC (1U<<_XEN_X86_EMU_PIC)
-#define _XEN_X86_EMU_VGA 6
-#define XEN_X86_EMU_VGA (1U<<_XEN_X86_EMU_VGA)
-#define _XEN_X86_EMU_IOMMU 7
-#define XEN_X86_EMU_IOMMU (1U<<_XEN_X86_EMU_IOMMU)
-#define _XEN_X86_EMU_PIT 8
-#define XEN_X86_EMU_PIT (1U<<_XEN_X86_EMU_PIT)
-#define _XEN_X86_EMU_USE_PIRQ 9
-#define XEN_X86_EMU_USE_PIRQ (1U<<_XEN_X86_EMU_USE_PIRQ)
-#define _XEN_X86_EMU_VPCI 10
-#define XEN_X86_EMU_VPCI (1U<<_XEN_X86_EMU_VPCI)
-
-#define XEN_X86_EMU_ALL (XEN_X86_EMU_LAPIC | XEN_X86_EMU_HPET | \
- XEN_X86_EMU_PM | XEN_X86_EMU_RTC | \
- XEN_X86_EMU_IOAPIC | XEN_X86_EMU_PIC | \
- XEN_X86_EMU_VGA | XEN_X86_EMU_IOMMU | \
- XEN_X86_EMU_PIT | XEN_X86_EMU_USE_PIRQ |\
- XEN_X86_EMU_VPCI)
- uint32_t emulation_flags;
-
-/*
- * Select whether to use a relaxed behavior for accesses to MSRs not explicitly
- * handled by Xen instead of injecting a #GP to the guest. Note this option
- * doesn't allow the guest to read or write to the underlying MSR.
- */
-#define XEN_X86_MSR_RELAXED (1u << 0)
- uint32_t misc_flags;
-};
-
-/* Max XEN_X86_* constant. Used for ABI checking. */
-#define XEN_X86_MISC_FLAGS_MAX XEN_X86_MSR_RELAXED
-
-#endif
-
/*
* Representations of architectural CPUID and MSR information. Used as the
* serialised version of Xen's internal representation.
new file mode 100644
@@ -0,0 +1,52 @@
+/*
+ * arch-x86
+ *
+ * AUTOGENERATED. DO NOT MODIFY
+ */
+#ifndef __XEN_AUTOGEN_ARCH_X86_H
+#define __XEN_AUTOGEN_ARCH_X86_H
+
+/* Content of the `emulation_flags` field of the domain creation hypercall. */
+struct xen_x86_emu {}; /* GREP FODDER */
+/* Emulate Local APICs. */
+#define XEN_X86_EMU_LAPIC (1U << 0)
+/* Emulate a HPET timer. */
+#define XEN_X86_EMU_HPET (1U << 1)
+/* Emulate the ACPI PM timer. */
+#define XEN_X86_EMU_PM (1U << 2)
+/* Emulate the RTC clock. */
+#define XEN_X86_EMU_RTC (1U << 3)
+/* Emulate an IOAPIC device. */
+#define XEN_X86_EMU_IOAPIC (1U << 4)
+/* Emulate PIC devices. */
+#define XEN_X86_EMU_PIC (1U << 5)
+/* Emulate standard VGA. */
+#define XEN_X86_EMU_VGA (1U << 6)
+/* Emulate an IOMMU. */
+#define XEN_X86_EMU_IOMMU (1U << 7)
+/* Emulate a PIT timer. */
+#define XEN_X86_EMU_PIT (1U << 8)
+/* Route physical IRQs over event channels. */
+#define XEN_X86_EMU_USE_PIRQ (1U << 9)
+/* Handle PCI configuration space traps from within Xen. */
+#define XEN_X86_EMU_VPCI (1U << 10)
+/* Mask covering all defined bits */
+#define XEN_X86_EMU__ALL (0x7FFU)
+
+/* Contents of the `misc_flags` field of the domain creation hypercall */
+struct xen_x86_misc {}; /* GREP FODDER */
+/* Grants access to the real physical MSR registers of the host. */
+#define XEN_X86_MISC_MSR_RELAXED (1U << 0)
+/* Mask covering all defined bits */
+#define XEN_X86_MISC__ALL (0x1U)
+
+/* x86-specific domain settings. */
+struct xen_arch_domainconfig {
+ /* IN: Bitmap of devices to emulate. */
+ uint32_t emulation_flags /* See xen_x86_emu */;
+ /* IN: Miscellaneous x86-specific toggles. */
+ uint32_t misc_flags /* See xen_x86_misc */;
+};
+
+#endif /* __XEN_AUTOGEN_ARCH_X86_H */
+
@@ -6,6 +6,19 @@
#ifndef __XEN_AUTOGEN_DOMCTL_H
#define __XEN_AUTOGEN_DOMCTL_H
+/* for xen_arch_domainconfig */
+#if defined(__i386__) || defined(__x86_64__)
+#include "arch_x86.h"
+#elif defined(__arm__) || defined(__aarch64__)
+#include "arch_arm.h"
+#elif defined(__powerpc64__)
+#include "arch_ppc.h"
+#elif defined(__riscv)
+#include "arch_riscv.h"
+#else
+#error "Unsupported architecture"
+#endif
+
/* Content of the `altp2m_mode` field of the domain creation hypercall. */
enum xen_domctl_altp2m_mode {
/* Keep altp2m disabled */
Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com> --- tools/libs/light/libxl_x86.c | 4 +- tools/ocaml/libs/xc/xenctrl_stubs.c | 4 +- .../extra/arch-x86/domainconfig.toml | 87 +++++++++++++++++++ .../xenbindgen/extra/domctl/createdomain.toml | 6 ++ xen/arch/x86/domain.c | 8 +- xen/arch/x86/include/asm/domain.h | 4 +- xen/arch/x86/setup.c | 2 +- xen/include/public/arch-x86/xen.h | 51 ----------- xen/include/public/autogen/arch_x86.h | 52 +++++++++++ xen/include/public/autogen/domctl.h | 13 +++ 10 files changed, 170 insertions(+), 61 deletions(-) create mode 100644 tools/rust/xenbindgen/extra/arch-x86/domainconfig.toml create mode 100644 xen/include/public/autogen/arch_x86.h