diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index 9def215b17885..9a0d8f390add5 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -5659,6 +5659,19 @@ West: - "area: Networking" - "area: Crypto / RNG" +"West project: xen": + status: maintained + maintainers: + - firscity + collaborators: + - lorc + - luca-fancellu + - soburi + files: + - modules/xen/ + labels: + - "area: Xen Platform" + "West project: zcbor": status: maintained maintainers: diff --git a/arch/arm64/core/xen/enlighten.c b/arch/arm64/core/xen/enlighten.c index 164947a09ffdc..a00c20778f6c5 100644 --- a/arch/arm64/core/xen/enlighten.c +++ b/arch/arm64/core/xen/enlighten.c @@ -7,8 +7,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/arch/arm64/core/xen/hypercall.S b/arch/arm64/core/xen/hypercall.S index 063538bae9029..24bc7df4d5870 100644 --- a/arch/arm64/core/xen/hypercall.S +++ b/arch/arm64/core/xen/hypercall.S @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include #define HYPERCALL(hypercall) \ GTEXT(HYPERVISOR_##hypercall); \ diff --git a/drivers/serial/uart_hvc_xen.c b/drivers/serial/uart_hvc_xen.c index 3283a6ec1e55b..96de27e64ce0e 100644 --- a/drivers/serial/uart_hvc_xen.c +++ b/drivers/serial/uart_hvc_xen.c @@ -9,9 +9,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/drivers/serial/uart_hvc_xen_consoleio.c b/drivers/serial/uart_hvc_xen_consoleio.c index 97d5392d750e7..293a981859d77 100644 --- a/drivers/serial/uart_hvc_xen_consoleio.c +++ b/drivers/serial/uart_hvc_xen_consoleio.c @@ -10,7 +10,7 @@ */ #include -#include +#include #include #include diff --git a/drivers/xen/dom0/domctl.c b/drivers/xen/dom0/domctl.c index 5d5178584ad80..b0e4963aca71c 100644 --- a/drivers/xen/dom0/domctl.c +++ b/drivers/xen/dom0/domctl.c @@ -7,8 +7,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 782882132a7e5..fda42320f3579 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -6,8 +6,8 @@ */ #include -#include -#include +#include +#include #include #include diff --git a/drivers/xen/gnttab.c b/drivers/xen/gnttab.c index ccf1b888e17a6..4e4ac76bda2c4 100644 --- a/drivers/xen/gnttab.c +++ b/drivers/xen/gnttab.c @@ -20,9 +20,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/drivers/xen/hvm.c b/drivers/xen/hvm.c index 5244d34d43352..a082b1e6c5f60 100644 --- a/drivers/xen/hvm.c +++ b/drivers/xen/hvm.c @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/drivers/xen/memory.c b/drivers/xen/memory.c index 6472ad74af253..da7afda3866d2 100644 --- a/drivers/xen/memory.c +++ b/drivers/xen/memory.c @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/include/zephyr/xen/dom0/domctl.h b/include/zephyr/xen/dom0/domctl.h index 6dfe90538871d..224934e05cc41 100644 --- a/include/zephyr/xen/dom0/domctl.h +++ b/include/zephyr/xen/dom0/domctl.h @@ -7,8 +7,8 @@ #define __XEN_DOM0_DOMCTL_H__ #include -#include -#include +#include +#include #include diff --git a/include/zephyr/xen/events.h b/include/zephyr/xen/events.h index cbad8162cbb3a..ec0d76a48175e 100644 --- a/include/zephyr/xen/events.h +++ b/include/zephyr/xen/events.h @@ -7,7 +7,7 @@ #ifndef __XEN_EVENTS_H__ #define __XEN_EVENTS_H__ -#include +#include #include diff --git a/include/zephyr/xen/generic.h b/include/zephyr/xen/generic.h index 756bf80d88430..65b4098c32ea2 100644 --- a/include/zephyr/xen/generic.h +++ b/include/zephyr/xen/generic.h @@ -6,7 +6,7 @@ #ifndef __XEN_GENERIC_H__ #define __XEN_GENERIC_H__ -#include +#include #define XEN_PAGE_SIZE 4096 #define XEN_PAGE_SHIFT 12 diff --git a/include/zephyr/xen/gnttab.h b/include/zephyr/xen/gnttab.h index 4cfc65e580e92..017202353fdf7 100644 --- a/include/zephyr/xen/gnttab.h +++ b/include/zephyr/xen/gnttab.h @@ -6,7 +6,7 @@ #ifndef __XEN_GNTTAB_H__ #define __XEN_GNTTAB_H__ -#include +#include /* * Assigns gref and permits access to 4K page for specific domain. diff --git a/include/zephyr/xen/hvm.h b/include/zephyr/xen/hvm.h index 1848705975a7a..d033b220a2440 100644 --- a/include/zephyr/xen/hvm.h +++ b/include/zephyr/xen/hvm.h @@ -6,8 +6,8 @@ #ifndef __XEN_HVM_H__ #define __XEN_HVM_H__ -#include -#include +#include +#include #include diff --git a/include/zephyr/xen/memory.h b/include/zephyr/xen/memory.h index 636f09988566b..82b47f41bbb4e 100644 --- a/include/zephyr/xen/memory.h +++ b/include/zephyr/xen/memory.h @@ -4,8 +4,8 @@ */ #include -#include -#include +#include +#include /** * Add mapping for specified page frame in Xen domain physmap. diff --git a/include/zephyr/xen/public/arch-arm.h b/include/zephyr/xen/public/arch-arm.h deleted file mode 100644 index c3a8afe9a92e8..0000000000000 --- a/include/zephyr/xen/public/arch-arm.h +++ /dev/null @@ -1,476 +0,0 @@ -/* SPDX-License-Identifier: MIT */ - -/****************************************************************************** - * arch-arm.h - * - * Guest OS interface to ARM Xen. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright 2011 (C) Citrix Systems - */ - -#ifndef __XEN_PUBLIC_ARCH_ARM_H__ -#define __XEN_PUBLIC_ARCH_ARM_H__ - -#include - -/* - * `incontents 50 arm_abi Hypercall Calling Convention - * - * A hypercall is issued using the ARM HVC instruction. - * - * A hypercall can take up to 5 arguments. These are passed in - * registers, the first argument in x0/r0 (for arm64/arm32 guests - * respectively irrespective of whether the underlying hypervisor is - * 32- or 64-bit), the second argument in x1/r1, the third in x2/r2, - * the forth in x3/r3 and the fifth in x4/r4. - * - * The hypercall number is passed in r12 (arm) or x16 (arm64). In both - * cases the relevant ARM procedure calling convention specifies this - * is an inter-procedure-call scratch register (e.g. for use in linker - * stubs). This use does not conflict with use during a hypercall. - * - * The HVC ISS must contain a Xen specific TAG: XEN_HYPERCALL_TAG. - * - * The return value is in x0/r0. - * - * The hypercall will clobber x16/r12 and the argument registers used - * by that hypercall (except r0 which is the return value) i.e. in - * addition to x16/r12 a 2 argument hypercall will clobber x1/r1 and a - * 4 argument hypercall will clobber x1/r1, x2/r2 and x3/r3. - * - * Parameter structs passed to hypercalls are laid out according to - * the Procedure Call Standard for the ARM Architecture (AAPCS, AKA - * EABI) and Procedure Call Standard for the ARM 64-bit Architecture - * (AAPCS64). Where there is a conflict the 64-bit standard should be - * used regardless of guest type. Structures which are passed as - * hypercall arguments are always little endian. - * - * All memory which is shared with other entities in the system - * (including the hypervisor and other guests) must reside in memory - * which is mapped as Normal Inner Write-Back Outer Write-Back Inner-Shareable. - * This applies to: - * - hypercall arguments passed via a pointer to guest memory. - * - memory shared via the grant table mechanism (including PV I/O - * rings etc). - * - memory shared with the hypervisor (struct shared_info, struct - * vcpu_info, the grant table, etc). - * - * Any cache allocation hints are acceptable. - */ - -/* - * `incontents 55 arm_hcall Supported Hypercalls - * - * Xen on ARM makes extensive use of hardware facilities and therefore - * only a subset of the potential hypercalls are required. - * - * Since ARM uses second stage paging any machine/physical addresses - * passed to hypercalls are Guest Physical Addresses (Intermediate - * Physical Addresses) unless otherwise noted. - * - * The following hypercalls (and sub operations) are supported on the - * ARM platform. Other hypercalls should be considered - * unavailable/unsupported. - * - * HYPERVISOR_memory_op - * All generic sub-operations - * - * HYPERVISOR_domctl - * All generic sub-operations, with the exception of: - * * XEN_DOMCTL_irq_permission (not yet implemented) - * - * HYPERVISOR_sched_op - * All generic sub-operations, with the exception of: - * * SCHEDOP_block -- prefer wfi hardware instruction - * - * HYPERVISOR_console_io - * All generic sub-operations - * - * HYPERVISOR_xen_version - * All generic sub-operations - * - * HYPERVISOR_event_channel_op - * All generic sub-operations - * - * HYPERVISOR_physdev_op - * No sub-operations are currently supported - * - * HYPERVISOR_sysctl - * All generic sub-operations, with the exception of: - * * XEN_SYSCTL_page_offline_op - * * XEN_SYSCTL_get_pmstat - * * XEN_SYSCTL_pm_op - * - * HYPERVISOR_hvm_op - * Exactly these sub-operations are supported: - * * HVMOP_set_param - * * HVMOP_get_param - * - * HYPERVISOR_grant_table_op - * All generic sub-operations - * - * HYPERVISOR_vcpu_op - * Exactly these sub-operations are supported: - * * VCPUOP_register_vcpu_info - * * VCPUOP_register_runstate_memory_area - * - * - * Other notes on the ARM ABI: - * - * - struct start_info is not exported to ARM guests. - * - * - struct shared_info is mapped by ARM guests using the - * HYPERVISOR_memory_op sub-op XENMEM_add_to_physmap, passing - * XENMAPSPACE_shared_info as space parameter. - * - * - All the per-cpu struct vcpu_info are mapped by ARM guests using the - * HYPERVISOR_vcpu_op sub-op VCPUOP_register_vcpu_info, including cpu0 - * struct vcpu_info. - * - * - The grant table is mapped using the HYPERVISOR_memory_op sub-op - * XENMEM_add_to_physmap, passing XENMAPSPACE_grant_table as space - * parameter. The memory range specified under the Xen compatible - * hypervisor node on device tree can be used as target gpfn for the - * mapping. - * - * - Xenstore is initialized by using the two hvm_params - * HVM_PARAM_STORE_PFN and HVM_PARAM_STORE_EVTCHN. They can be read - * with the HYPERVISOR_hvm_op sub-op HVMOP_get_param. - * - * - The paravirtualized console is initialized by using the two - * hvm_params HVM_PARAM_CONSOLE_PFN and HVM_PARAM_CONSOLE_EVTCHN. They - * can be read with the HYPERVISOR_hvm_op sub-op HVMOP_get_param. - * - * - Event channel notifications are delivered using the percpu GIC - * interrupt specified under the Xen compatible hypervisor node on - * device tree. - * - * - The device tree Xen compatible node is fully described under Linux - * at Documentation/devicetree/bindings/arm/xen.txt. - */ - -#define XEN_HYPERCALL_TAG 0XEA1 - -#define int64_aligned_t int64_t __aligned(8) -#define uint64_aligned_t uint64_t __aligned(8) - -#ifndef __ASSEMBLY__ -#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ - typedef union { type *p; unsigned long q; } \ - __guest_handle_ ## name; \ - typedef union { type *p; uint64_aligned_t q; } \ - __guest_handle_64_ ## name - -/* - * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field - * in a struct in memory. On ARM is always 8 bytes sizes and 8 bytes - * aligned. - * XEN_GUEST_HANDLE_PARAM represents a guest pointer, when passed as an - * hypercall argument. It is 4 bytes on aarch32 and 8 bytes on aarch64. - */ -#define __DEFINE_XEN_GUEST_HANDLE(name, type) \ - ___DEFINE_XEN_GUEST_HANDLE(name, type); \ - ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type) -#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name) -#define __XEN_GUEST_HANDLE(name) __guest_handle_64_ ## name -#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) -#define XEN_GUEST_HANDLE_PARAM(name) __guest_handle_ ## name -#define set_xen_guest_handle_raw(hnd, val) \ - do { \ - __typeof__(&(hnd)) _sxghr_tmp = &(hnd); \ - _sxghr_tmp->q = 0; \ - _sxghr_tmp->p = val; \ - } while (0) -#define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) - -typedef uint64_t xen_pfn_t; -#define PRI_xen_pfn PRIx64 -#define PRIu_xen_pfn PRIu64 - -/* - * Maximum number of virtual CPUs in legacy multi-processor guests. - * Only one. All other VCPUS must use VCPUOP_register_vcpu_info. - */ -#define XEN_LEGACY_MAX_VCPUS 1 - -typedef uint64_t xen_ulong_t; -#define PRI_xen_ulong PRIx64 - -#ifdef CONFIG_XEN_DOM0 -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -/* Anonymous union includes both 32- and 64-bit names (e.g., r0/x0). */ -# define __DECL_REG(n64, n32) union { \ - uint64_t n64; \ - uint32_t n32; \ -} -#else -/* Non-gcc sources must always use the proper 64-bit name (e.g., x0). */ -#define __DECL_REG(n64, n32) uint64_t n64 -#endif - -struct vcpu_guest_core_regs { - /* Aarch64 Aarch32 */ - __DECL_REG(x0, r0_usr); - __DECL_REG(x1, r1_usr); - __DECL_REG(x2, r2_usr); - __DECL_REG(x3, r3_usr); - __DECL_REG(x4, r4_usr); - __DECL_REG(x5, r5_usr); - __DECL_REG(x6, r6_usr); - __DECL_REG(x7, r7_usr); - __DECL_REG(x8, r8_usr); - __DECL_REG(x9, r9_usr); - __DECL_REG(x10, r10_usr); - __DECL_REG(x11, r11_usr); - __DECL_REG(x12, r12_usr); - - __DECL_REG(x13, sp_usr); - __DECL_REG(x14, lr_usr); - - __DECL_REG(x15, __unused_sp_hyp); - - __DECL_REG(x16, lr_irq); - __DECL_REG(x17, sp_irq); - - __DECL_REG(x18, lr_svc); - __DECL_REG(x19, sp_svc); - - __DECL_REG(x20, lr_abt); - __DECL_REG(x21, sp_abt); - - __DECL_REG(x22, lr_und); - __DECL_REG(x23, sp_und); - - __DECL_REG(x24, r8_fiq); - __DECL_REG(x25, r9_fiq); - __DECL_REG(x26, r10_fiq); - __DECL_REG(x27, r11_fiq); - __DECL_REG(x28, r12_fiq); - - __DECL_REG(x29, sp_fiq); - __DECL_REG(x30, lr_fiq); - - /* Return address and mode */ - __DECL_REG(pc64, pc32); /* ELR_EL2 */ - uint32_t cpsr; /* SPSR_EL2 */ - - union { - uint32_t spsr_el1; /* AArch64 */ - uint32_t spsr_svc; /* AArch32 */ - }; - - /* AArch32 guests only */ - uint32_t spsr_fiq, spsr_irq, spsr_und, spsr_abt; - - /* AArch64 guests only */ - uint64_t sp_el0; - uint64_t sp_el1, elr_el1; -}; -typedef struct vcpu_guest_core_regs vcpu_guest_core_regs_t; -DEFINE_XEN_GUEST_HANDLE(vcpu_guest_core_regs_t); - -#undef __DECL_REG - -struct vcpu_guest_context { -#define _VGCF_online 0 -#define VGCF_online (1 << _VGCF_online) - uint32_t flags; /* VGCF_* */ - - struct vcpu_guest_core_regs user_regs; /* Core CPU registers */ - - uint64_t sctlr; - uint64_t ttbcr, ttbr0, ttbr1; -}; -typedef struct vcpu_guest_context vcpu_guest_context_t; -DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); - -/* - * struct xen_arch_domainconfig's ABI is covered by - * XEN_DOMCTL_INTERFACE_VERSION. - */ -#define XEN_DOMCTL_CONFIG_GIC_NATIVE 0 -#define XEN_DOMCTL_CONFIG_GIC_V2 1 -#define XEN_DOMCTL_CONFIG_GIC_V3 2 - -#define XEN_DOMCTL_CONFIG_TEE_NONE 0 -#define XEN_DOMCTL_CONFIG_TEE_OPTEE 1 - -struct xen_arch_domainconfig { - /* IN/OUT */ - uint8_t gic_version; - /* IN */ - uint16_t tee_type; - /* IN */ - uint32_t nr_spis; - /* - * OUT - * Based on the property clock-frequency in the DT timer node. - * The property may be present when the bootloader/firmware doesn't - * set correctly CNTFRQ which hold the timer frequency. - * - * As it's not possible to trap this register, we have to replicate - * the value in the guest DT. - * - * = 0 => property not present - * > 0 => Value of the property - * - */ - uint32_t clock_frequency; -}; -#endif /* CONFIG_XEN_DOM0 */ - -struct arch_vcpu_info { -}; -typedef struct arch_vcpu_info arch_vcpu_info_t; - -struct arch_shared_info { -}; -typedef struct arch_shared_info arch_shared_info_t; -typedef uint64_t xen_callback_t; - -#endif /* __ASSEMBLY__ */ - -#ifdef CONFIG_XEN_DOM0 - -/* PSR bits (CPSR, SPSR) */ -#define PSR_THUMB (1 << 5) /* Thumb Mode enable */ -#define PSR_FIQ_MASK (1 << 6) /* Fast Interrupt mask */ -#define PSR_IRQ_MASK (1 << 7) /* Interrupt mask */ -#define PSR_ABT_MASK (1 << 8) /* Asynchronous Abort mask */ -#define PSR_BIG_ENDIAN (1 << 9) /* arm32: Big Endian Mode */ -#define PSR_DBG_MASK (1 << 9) /* arm64: Debug Exception mask */ -#define PSR_IT_MASK (0x0600fc00) /* Thumb If-Then Mask */ -#define PSR_JAZELLE (1<<24) /* Jazelle Mode */ - -/* 32 bit modes */ -#define PSR_MODE_USR 0x10 -#define PSR_MODE_FIQ 0x11 -#define PSR_MODE_IRQ 0x12 -#define PSR_MODE_SVC 0x13 -#define PSR_MODE_MON 0x16 -#define PSR_MODE_ABT 0x17 -#define PSR_MODE_HYP 0x1a -#define PSR_MODE_UND 0x1b -#define PSR_MODE_SYS 0x1f - -/* 64 bit modes */ -#define PSR_MODE_BIT 0x10 /* Set iff AArch32 */ -#define PSR_MODE_EL3h 0x0d -#define PSR_MODE_EL3t 0x0c -#define PSR_MODE_EL2h 0x09 -#define PSR_MODE_EL2t 0x08 -#define PSR_MODE_EL1h 0x05 -#define PSR_MODE_EL1t 0x04 -#define PSR_MODE_EL0t 0x00 - -#define PSR_GUEST32_INIT (PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_SVC) -#define PSR_GUEST64_INIT (PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_EL1h) - -#define SCTLR_GUEST_INIT xen_mk_ullong(0x00c50078) - -/* - * Virtual machine platform (memory layout, interrupts) - * - * These are defined for consistency between the tools and the - * hypervisor. Guests must not rely on these hardcoded values but - * should instead use the FDT. - */ - -/* Physical Address Space */ - -/* - * vGIC mappings: Only one set of mapping is used by the guest. - * Therefore they can overlap. - */ - -/* vGIC v2 mappings */ -#define GUEST_GICD_BASE xen_mk_ullong(0x03001000) -#define GUEST_GICD_SIZE xen_mk_ullong(0x00001000) -#define GUEST_GICC_BASE xen_mk_ullong(0x03002000) -#define GUEST_GICC_SIZE xen_mk_ullong(0x00002000) - -/* vGIC v3 mappings */ -#define GUEST_GICV3_GICD_BASE xen_mk_ullong(0x03001000) -#define GUEST_GICV3_GICD_SIZE xen_mk_ullong(0x00010000) - -#define GUEST_GICV3_RDIST_REGIONS 1 - -#define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000) /* vCPU0..127 */ -#define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) - -/* ACPI tables physical address */ -#define GUEST_ACPI_BASE xen_mk_ullong(0x20000000) -#define GUEST_ACPI_SIZE xen_mk_ullong(0x02000000) - -/* PL011 mappings */ -#define GUEST_PL011_BASE xen_mk_ullong(0x22000000) -#define GUEST_PL011_SIZE xen_mk_ullong(0x00001000) - -/* - * 16MB == 4096 pages reserved for guest to use as a region to map its - * grant table in. - */ -#define GUEST_GNTTAB_BASE xen_mk_ullong(0x38000000) -#define GUEST_GNTTAB_SIZE xen_mk_ullong(0x01000000) - -#define GUEST_MAGIC_BASE xen_mk_ullong(0x39000000) -#define GUEST_MAGIC_SIZE xen_mk_ullong(0x01000000) - -#define GUEST_RAM_BANKS 2 - -#define GUEST_RAM0_BASE xen_mk_ullong(0x40000000) /* 3GB of low RAM @ 1GB */ -#define GUEST_RAM0_SIZE xen_mk_ullong(0xc0000000) - -#define GUEST_RAM1_BASE xen_mk_ullong(0x0200000000) /* 1016GB of RAM @ 8GB */ -#define GUEST_RAM1_SIZE xen_mk_ullong(0xfe00000000) - -#define GUEST_RAM_BASE GUEST_RAM0_BASE /* Lowest RAM address */ -/* Largest amount of actual RAM, not including holes */ -#define GUEST_RAM_MAX (GUEST_RAM0_SIZE + GUEST_RAM1_SIZE) -/* Suitable for e.g. const uint64_t ramfoo[] = GUEST_RAM_BANK_FOOS; */ -#define GUEST_RAM_BANK_BASES { GUEST_RAM0_BASE, GUEST_RAM1_BASE } -#define GUEST_RAM_BANK_SIZES { GUEST_RAM0_SIZE, GUEST_RAM1_SIZE } - -/* Current supported guest VCPUs */ -#define GUEST_MAX_VCPUS 128 - -/* Interrupts */ -#define GUEST_TIMER_VIRT_PPI 27 -#define GUEST_TIMER_PHYS_S_PPI 29 -#define GUEST_TIMER_PHYS_NS_PPI 30 -#define GUEST_EVTCHN_PPI 31 - -#define GUEST_VPL011_SPI 32 - -/* PSCI functions */ -#define PSCI_cpu_suspend 0 -#define PSCI_cpu_off 1 -#define PSCI_cpu_on 2 -#define PSCI_migrate 3 - -#endif /* CONFIG_XEN_DOM0 */ - -#ifndef __ASSEMBLY__ -/* Stub definition of PMU structure */ -typedef struct xen_pmu_arch { uint8_t dummy; } xen_pmu_arch_t; -#endif /* __ASSEMBLY__ */ - -#endif /* __XEN_PUBLIC_ARCH_ARM_H__ */ diff --git a/include/zephyr/xen/public/domctl.h b/include/zephyr/xen/public/domctl.h deleted file mode 100644 index 9d856501a0983..0000000000000 --- a/include/zephyr/xen/public/domctl.h +++ /dev/null @@ -1,517 +0,0 @@ -/* SPDX-License-Identifier: MIT */ -/****************************************************************************** - * domctl.h - * - * Domain management operations. For use by node control stack. - * - * Copyright (c) 2002-2003, B Dragovic - * Copyright (c) 2002-2006, K Fraser - */ - -#ifndef __XEN_PUBLIC_DOMCTL_H__ -#define __XEN_PUBLIC_DOMCTL_H__ - -#ifndef CONFIG_XEN_DOM0 -#error "domctl operations are intended for use by node control tools only" -#endif - -#include "xen.h" -#include "event_channel.h" -#include "grant_table.h" -#include "memory.h" - -#define XEN_DOMCTL_INTERFACE_VERSION 0x00000015 - -/* - * NB. xen_domctl.domain is an IN/OUT parameter for this operation. - * If it is specified as an invalid value (0 or >= DOMID_FIRST_RESERVED), - * an id is auto-allocated and returned. - */ -/* XEN_DOMCTL_createdomain */ -struct xen_domctl_createdomain { - /* IN parameters */ - uint32_t ssidref; - xen_domain_handle_t handle; -/* Is this an HVM guest (as opposed to a PV guest)? */ -#define _XEN_DOMCTL_CDF_hvm 0 -#define XEN_DOMCTL_CDF_hvm (1U << _XEN_DOMCTL_CDF_hvm) -/* Use hardware-assisted paging if available? */ -#define _XEN_DOMCTL_CDF_hap 1 -#define XEN_DOMCTL_CDF_hap (1U << _XEN_DOMCTL_CDF_hap) -/* Should domain memory integrity be verified by tboot during Sx? */ -#define _XEN_DOMCTL_CDF_s3_integrity 2 -#define XEN_DOMCTL_CDF_s3_integrity (1U << _XEN_DOMCTL_CDF_s3_integrity) -/* Disable out-of-sync shadow page tables? */ -#define _XEN_DOMCTL_CDF_oos_off 3 -#define XEN_DOMCTL_CDF_oos_off (1U << _XEN_DOMCTL_CDF_oos_off) -/* Is this a xenstore domain? */ -#define _XEN_DOMCTL_CDF_xs_domain 4 -#define XEN_DOMCTL_CDF_xs_domain (1U << _XEN_DOMCTL_CDF_xs_domain) -/* Should this domain be permitted to use the IOMMU? */ -#define _XEN_DOMCTL_CDF_iommu 5 -#define XEN_DOMCTL_CDF_iommu (1U << _XEN_DOMCTL_CDF_iommu) -#define _XEN_DOMCTL_CDF_nested_virt 6 -#define XEN_DOMCTL_CDF_nested_virt (1U << _XEN_DOMCTL_CDF_nested_virt) -/* Should we expose the vPMU to the guest? */ -#define XEN_DOMCTL_CDF_vpmu (1U << 7) - -/* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_vpmu - - uint32_t flags; - -#define _XEN_DOMCTL_IOMMU_no_sharept 0 -#define XEN_DOMCTL_IOMMU_no_sharep (1U << _XEN_DOMCTL_IOMMU_no_sharept) - -/* Max XEN_DOMCTL_IOMMU_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_IOMMU_MAX XEN_DOMCTL_IOMMU_no_sharept - - uint32_t iommu_opts; - - /* - * Various domain limits, which impact the quantity of resources - * (global mapping space, xenheap, etc) a guest may consume. For - * max_grant_frames and max_maptrack_frames, < 0 means "use the - * default maximum value in the hypervisor". - */ - uint32_t max_vcpus; - uint32_t max_evtchn_port; - int32_t max_grant_frames; - int32_t max_maptrack_frames; - -/* Grant version, use low 4 bits. */ -#define XEN_DOMCTL_GRANT_version_mask 0xf -#define XEN_DOMCTL_GRANT_version(v) ((v) & XEN_DOMCTL_GRANT_version_mask) - - uint32_t grant_opts; - - /* Per-vCPU buffer size in bytes. 0 to disable. */ - uint32_t vmtrace_size; - - /* CPU pool to use; specify 0 or a specific existing pool */ - uint32_t cpupool_id; - - struct xen_arch_domainconfig arch; -}; - -/* XEN_DOMCTL_getdomaininfo */ -struct xen_domctl_getdomaininfo { - /* OUT variables. */ - domid_t domain; /* Also echoed in domctl.domain */ - uint16_t pad1; -/* Domain is scheduled to die. */ -#define _XEN_DOMINF_dying 0 -#define XEN_DOMINF_dying (1U << _XEN_DOMINF_dying) -/* Domain is an HVM guest (as opposed to a PV guest). */ -#define _XEN_DOMINF_hvm_guest 1 -#define XEN_DOMINF_hvm_guest (1U << _XEN_DOMINF_hvm_guest) -/* The guest OS has shut down. */ -#define _XEN_DOMINF_shutdown 2 -#define XEN_DOMINF_shutdown (1U << _XEN_DOMINF_shutdown) -/* Currently paused by control software. */ -#define _XEN_DOMINF_paused 3 -#define XEN_DOMINF_paused (1U << _XEN_DOMINF_paused) -/* Currently blocked pending an event. */ -#define _XEN_DOMINF_blocked 4 -#define XEN_DOMINF_blocked (1U << _XEN_DOMINF_blocked) -/* Domain is currently running. */ -#define _XEN_DOMINF_running 5 -#define XEN_DOMINF_running (1U << _XEN_DOMINF_running) -/* Being debugged. */ -#define _XEN_DOMINF_debugged 6 -#define XEN_DOMINF_debugged (1U << _XEN_DOMINF_debugged) -/* domain is a xenstore domain */ -#define _XEN_DOMINF_xs_domain 7 -#define XEN_DOMINF_xs_domain (1U << _XEN_DOMINF_xs_domain) -/* domain has hardware assisted paging */ -#define _XEN_DOMINF_hap 8 -#define XEN_DOMINF_hap (1U << _XEN_DOMINF_hap) -/* XEN_DOMINF_shutdown guest-supplied code. */ -#define XEN_DOMINF_shutdownmask 255 -#define XEN_DOMINF_shutdownshift 16 - uint32_t flags; /* XEN_DOMINF_* */ - uint64_aligned_t tot_pages; - uint64_aligned_t max_pages; - uint64_aligned_t outstanding_pages; - uint64_aligned_t shr_pages; - uint64_aligned_t paged_pages; - uint64_aligned_t shared_info_frame; /* GMFN of shared_info struct */ - uint64_aligned_t cpu_time; - uint32_t nr_online_vcpus; /* Number of VCPUs currently online. */ -#define XEN_INVALID_MAX_VCPU_ID (~0U) /* Domain has no vcpus? */ - uint32_t max_vcpu_id; /* Maximum VCPUID in use by this domain. */ - uint32_t ssidref; - xen_domain_handle_t handle; - uint32_t cpupool; - uint8_t gpaddr_bits; /* Guest physical address space size. */ - uint8_t pad2[7]; - struct xen_arch_domainconfig arch_config; -}; -typedef struct xen_domctl_getdomaininfo xen_domctl_getdomaininfo_t; -DEFINE_XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t); - -/* - * Control shadow pagetables operation - */ -/* XEN_DOMCTL_shadow_op */ - -/* Memory allocation accessors. */ -#define XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION 30 -#define XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION 31 - -struct xen_domctl_shadow_op_stats { - uint32_t fault_count; - uint32_t dirty_count; -}; - -struct xen_domctl_shadow_op { - /* IN variables. */ - uint32_t op; /* XEN_DOMCTL_SHADOW_OP_* */ - - /* OP_ENABLE: XEN_DOMCTL_SHADOW_ENABLE_* */ - /* OP_PEAK / OP_CLEAN: XEN_DOMCTL_SHADOW_LOGDIRTY_* */ - uint32_t mode; - - /* OP_GET_ALLOCATION / OP_SET_ALLOCATION */ - uint32_t mb; /* Shadow memory allocation in MB */ - - /* OP_PEEK / OP_CLEAN */ - XEN_GUEST_HANDLE_64(uint8_t) dirty_bitmap; - uint64_aligned_t pages; /* Size of buffer. Updated with actual size. */ - struct xen_domctl_shadow_op_stats stats; -}; - -/* XEN_DOMCTL_max_mem */ -struct xen_domctl_max_mem { - /* IN variables. */ - uint64_aligned_t max_memkb; -}; - -/* XEN_DOMCTL_setvcpucontext */ -/* XEN_DOMCTL_getvcpucontext */ -struct xen_domctl_vcpucontext { - uint32_t vcpu; /* IN */ - - XEN_GUEST_HANDLE_64(vcpu_guest_context_t) ctxt; /* IN/OUT */ -}; - -/* - * XEN_DOMCTL_max_vcpus: - * - * The parameter passed to XEN_DOMCTL_max_vcpus must match the value passed to - * XEN_DOMCTL_createdomain. This hypercall is in the process of being removed - * (once the failure paths in domain_create() have been improved), but is - * still required in the short term to allocate the vcpus themselves. - */ -struct xen_domctl_max_vcpus { - uint32_t max; /* maximum number of vcpus */ -}; - -/* XEN_DOMCTL_scheduler_op */ -/* Scheduler types. */ -/* #define XEN_SCHEDULER_SEDF 4 (Removed) */ -#define XEN_SCHEDULER_CREDIT 5 -#define XEN_SCHEDULER_CREDIT2 6 -#define XEN_SCHEDULER_ARINC653 7 -#define XEN_SCHEDULER_RTDS 8 -#define XEN_SCHEDULER_NULL 9 - -struct xen_domctl_sched_credit { - uint16_t weight; - uint16_t cap; -}; - -struct xen_domctl_sched_credit2 { - uint16_t weight; - uint16_t cap; -}; - -struct xen_domctl_sched_rtds { - uint32_t period; - uint32_t budget; -/* Can this vCPU execute beyond its reserved amount of time? */ -#define _XEN_DOMCTL_SCHEDRT_extra 0 -#define XEN_DOMCTL_SCHEDRT_extra (1U<<_XEN_DOMCTL_SCHEDRT_extra) - uint32_t flags; -}; - -typedef struct xen_domctl_schedparam_vcpu { - union { - struct xen_domctl_sched_credit credit; - struct xen_domctl_sched_credit2 credit2; - struct xen_domctl_sched_rtds rtds; - } u; - uint32_t vcpuid; -} xen_domctl_schedparam_vcpu_t; -DEFINE_XEN_GUEST_HANDLE(xen_domctl_schedparam_vcpu_t); - -/* - * Set or get info? - * For schedulers supporting per-vcpu settings (e.g., RTDS): - * XEN_DOMCTL_SCHEDOP_putinfo sets params for all vcpus; - * XEN_DOMCTL_SCHEDOP_getinfo gets default params; - * XEN_DOMCTL_SCHEDOP_put(get)vcpuinfo sets (gets) params of vcpus; - * - * For schedulers not supporting per-vcpu settings: - * XEN_DOMCTL_SCHEDOP_putinfo sets params for all vcpus; - * XEN_DOMCTL_SCHEDOP_getinfo gets domain-wise params; - * XEN_DOMCTL_SCHEDOP_put(get)vcpuinfo returns error; - */ -#define XEN_DOMCTL_SCHEDOP_putinfo 0 -#define XEN_DOMCTL_SCHEDOP_getinfo 1 -#define XEN_DOMCTL_SCHEDOP_putvcpuinfo 2 -#define XEN_DOMCTL_SCHEDOP_getvcpuinfo 3 -struct xen_domctl_scheduler_op { - uint32_t sched_id; /* XEN_SCHEDULER_* */ - uint32_t cmd; /* XEN_DOMCTL_SCHEDOP_* */ - /* IN/OUT */ - union { - struct xen_domctl_sched_credit credit; - struct xen_domctl_sched_credit2 credit2; - struct xen_domctl_sched_rtds rtds; - struct { - XEN_GUEST_HANDLE_64(xen_domctl_schedparam_vcpu_t) vcpus; - /* - * IN: Number of elements in vcpus array. - * OUT: Number of processed elements of vcpus array. - */ - uint32_t nr_vcpus; - uint32_t padding; - } v; - } u; -}; - -/* XEN_DOMCTL_iomem_permission */ -struct xen_domctl_iomem_permission { - uint64_aligned_t first_mfn;/* first page (physical page number) in range */ - uint64_aligned_t nr_mfns; /* number of pages in range (>0) */ - uint8_t allow_access; /* allow (!0) or deny (0) access to range? */ -}; - -/* XEN_DOMCTL_set_address_size */ -/* XEN_DOMCTL_get_address_size */ -struct xen_domctl_address_size { - uint32_t size; -}; - -/* Assign a device to a guest. Sets up IOMMU structures. */ -/* XEN_DOMCTL_assign_device */ -/* - * XEN_DOMCTL_test_assign_device: Pass DOMID_INVALID to find out whether the - * given device is assigned to any DomU at all. Pass a specific domain ID to - * find out whether the given device can be assigned to that domain. - */ -/* - * XEN_DOMCTL_deassign_device: The behavior of this DOMCTL differs - * between the different type of device: - * - PCI device (XEN_DOMCTL_DEV_PCI) will be reassigned to DOM0 - * - DT device (XEN_DOMCTL_DEV_DT) will left unassigned. DOM0 - * will have to call XEN_DOMCTL_assign_device in order to use the - * device. - */ -#define XEN_DOMCTL_DEV_PCI 0 -#define XEN_DOMCTL_DEV_DT 1 -struct xen_domctl_assign_device { - /* IN */ - uint32_t dev; /* XEN_DOMCTL_DEV_* */ - uint32_t flags; -#define XEN_DOMCTL_DEV_RDM_RELAXED 1 /* assign only */ - union { - struct { - uint32_t machine_sbdf; /* machine PCI ID of assigned device */ - } pci; - struct { - uint32_t size; /* Length of the path */ - - XEN_GUEST_HANDLE_64(char) path; /* path to the device tree node */ - } dt; - } u; -}; - -/* Pass-through interrupts: bind real irq -> hvm devfn. */ -/* XEN_DOMCTL_bind_pt_irq */ -/* XEN_DOMCTL_unbind_pt_irq */ -enum pt_irq_type { - PT_IRQ_TYPE_PCI, - PT_IRQ_TYPE_ISA, - PT_IRQ_TYPE_MSI, - PT_IRQ_TYPE_MSI_TRANSLATE, - PT_IRQ_TYPE_SPI, /* ARM: valid range 32-1019 */ -}; -struct xen_domctl_bind_pt_irq { - uint32_t machine_irq; - uint32_t irq_type; /* enum pt_irq_type */ - - union { - struct { - uint8_t isa_irq; - } isa; - struct { - uint8_t bus; - uint8_t device; - uint8_t intx; - } pci; - struct { - uint8_t gvec; - uint32_t gflags; -#define XEN_DOMCTL_VMSI_X86_DEST_ID_MASK 0x0000ff -#define XEN_DOMCTL_VMSI_X86_RH_MASK 0x000100 -#define XEN_DOMCTL_VMSI_X86_DM_MASK 0x000200 -#define XEN_DOMCTL_VMSI_X86_DELIV_MASK 0x007000 -#define XEN_DOMCTL_VMSI_X86_TRIG_MASK 0x008000 -#define XEN_DOMCTL_VMSI_X86_UNMASKED 0x010000 - - uint64_aligned_t gtable; - } msi; - struct { - uint16_t spi; - } spi; - } u; -}; - - -/* Bind machine I/O address range -> HVM address range. */ -/* XEN_DOMCTL_memory_mapping */ -/* Returns - * - zero success, everything done - * - -E2BIG passed in nr_mfns value too large for the implementation - * - positive partial success for the first page frames (with - * less than nr_mfns), requiring re-invocation by the - * caller after updating inputs - * - negative error; other than -E2BIG - */ -#define DPCI_ADD_MAPPING 1 -#define DPCI_REMOVE_MAPPING 0 -struct xen_domctl_memory_mapping { - uint64_aligned_t first_gfn; /* first page (hvm guest phys page) in range */ - uint64_aligned_t first_mfn; /* first page (machine page) in range */ - uint64_aligned_t nr_mfns; /* number of pages in range (>0) */ - uint32_t add_mapping; /* add or remove mapping */ - uint32_t padding; /* padding for 64-bit aligned structure */ -}; - -/* - * ARM: Clean and invalidate caches associated with given region of - * guest memory. - */ -struct xen_domctl_cacheflush { - /* IN: page range to flush. */ - xen_pfn_t start_pfn, nr_pfns; -}; - -/* - * XEN_DOMCTL_get_paging_mempool_size / XEN_DOMCTL_set_paging_mempool_size. - * - * Get or set the paging memory pool size. The size is in bytes. - * - * This is a dedicated pool of memory for Xen to use while managing the guest, - * typically containing pagetables. As such, there is an implementation - * specific minimum granularity. - * - * The set operation can fail mid-way through the request (e.g. Xen running - * out of memory, no free memory to reclaim from the pool, etc.). - */ -struct xen_domctl_paging_mempool { - uint64_aligned_t size; /* Size in bytes. */ -}; - -struct xen_domctl { - uint32_t cmd; -#define XEN_DOMCTL_createdomain 1 -#define XEN_DOMCTL_destroydomain 2 -#define XEN_DOMCTL_pausedomain 3 -#define XEN_DOMCTL_unpausedomain 4 -#define XEN_DOMCTL_getdomaininfo 5 -#define XEN_DOMCTL_setvcpuaffinity 9 -#define XEN_DOMCTL_shadow_op 10 -#define XEN_DOMCTL_max_mem 11 -#define XEN_DOMCTL_setvcpucontext 12 -#define XEN_DOMCTL_getvcpucontext 13 -#define XEN_DOMCTL_getvcpuinfo 14 -#define XEN_DOMCTL_max_vcpus 15 -#define XEN_DOMCTL_scheduler_op 16 -#define XEN_DOMCTL_setdomainhandle 17 -#define XEN_DOMCTL_setdebugging 18 -#define XEN_DOMCTL_irq_permission 19 -#define XEN_DOMCTL_iomem_permission 20 -#define XEN_DOMCTL_ioport_permission 21 -#define XEN_DOMCTL_hypercall_init 22 -#define XEN_DOMCTL_settimeoffset 24 -#define XEN_DOMCTL_getvcpuaffinity 25 -#define XEN_DOMCTL_real_mode_area 26 /* Obsolete PPC only */ -#define XEN_DOMCTL_resumedomain 27 -#define XEN_DOMCTL_sendtrigger 28 -#define XEN_DOMCTL_subscribe 29 -#define XEN_DOMCTL_gethvmcontext 33 -#define XEN_DOMCTL_sethvmcontext 34 -#define XEN_DOMCTL_set_address_size 35 -#define XEN_DOMCTL_get_address_size 36 -#define XEN_DOMCTL_assign_device 37 -#define XEN_DOMCTL_bind_pt_irq 38 -#define XEN_DOMCTL_memory_mapping 39 -#define XEN_DOMCTL_ioport_mapping 40 -#define XEN_DOMCTL_set_ext_vcpucontext 42 -#define XEN_DOMCTL_get_ext_vcpucontext 43 -#define XEN_DOMCTL_set_opt_feature 44 /* Obsolete IA64 only */ -#define XEN_DOMCTL_test_assign_device 45 -#define XEN_DOMCTL_set_target 46 -#define XEN_DOMCTL_deassign_device 47 -#define XEN_DOMCTL_unbind_pt_irq 48 -#define XEN_DOMCTL_get_device_group 50 -#define XEN_DOMCTL_debug_op 54 -#define XEN_DOMCTL_gethvmcontext_partial 55 -#define XEN_DOMCTL_vm_event_op 56 -#define XEN_DOMCTL_mem_sharing_op 57 -#define XEN_DOMCTL_gettscinfo 59 -#define XEN_DOMCTL_settscinfo 60 -#define XEN_DOMCTL_getpageframeinfo3 61 -#define XEN_DOMCTL_setvcpuextstate 62 -#define XEN_DOMCTL_getvcpuextstate 63 -#define XEN_DOMCTL_set_access_required 64 -#define XEN_DOMCTL_audit_p2m 65 -#define XEN_DOMCTL_set_virq_handler 66 -#define XEN_DOMCTL_set_broken_page_p2m 67 -#define XEN_DOMCTL_setnodeaffinity 68 -#define XEN_DOMCTL_getnodeaffinity 69 -#define XEN_DOMCTL_cacheflush 71 -#define XEN_DOMCTL_get_vcpu_msrs 72 -#define XEN_DOMCTL_set_vcpu_msrs 73 -#define XEN_DOMCTL_setvnumainfo 74 -#define XEN_DOMCTL_psr_cmt_op 75 -#define XEN_DOMCTL_monitor_op 77 -#define XEN_DOMCTL_psr_alloc 78 -#define XEN_DOMCTL_soft_reset 79 -#define XEN_DOMCTL_vuart_op 81 -#define XEN_DOMCTL_get_cpu_policy 82 -#define XEN_DOMCTL_set_cpu_policy 83 -#define XEN_DOMCTL_vmtrace_op 84 -#define XEN_DOMCTL_get_paging_mempool_size 85 -#define XEN_DOMCTL_set_paging_mempool_size 86 -#define XEN_DOMCTL_gdbsx_guestmemio 1000 -#define XEN_DOMCTL_gdbsx_pausevcpu 1001 -#define XEN_DOMCTL_gdbsx_unpausevcpu 1002 -#define XEN_DOMCTL_gdbsx_domstatus 1003 - uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */ - domid_t domain; - uint16_t _pad[3]; - union { - struct xen_domctl_createdomain createdomain; - struct xen_domctl_getdomaininfo getdomaininfo; - struct xen_domctl_max_mem max_mem; - struct xen_domctl_vcpucontext vcpucontext; - struct xen_domctl_max_vcpus max_vcpus; - struct xen_domctl_scheduler_op scheduler_op; - struct xen_domctl_iomem_permission iomem_permission; - struct xen_domctl_address_size address_size; - struct xen_domctl_assign_device assign_device; - struct xen_domctl_bind_pt_irq bind_pt_irq; - struct xen_domctl_memory_mapping memory_mapping; - struct xen_domctl_cacheflush cacheflush; - struct xen_domctl_paging_mempool paging_mempool; - uint8_t pad[128]; - } u; -}; -typedef struct xen_domctl xen_domctl_t; -DEFINE_XEN_GUEST_HANDLE(xen_domctl_t); - -#endif /* __XEN_PUBLIC_DOMCTL_H__ */ diff --git a/include/zephyr/xen/public/event_channel.h b/include/zephyr/xen/public/event_channel.h deleted file mode 100644 index 7ce1ae0d38f96..0000000000000 --- a/include/zephyr/xen/public/event_channel.h +++ /dev/null @@ -1,216 +0,0 @@ -/* SPDX-License-Identifier: MIT */ - -/****************************************************************************** - * event_channel.h - * - * Event channels between domains. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2003-2004, K A Fraser. - */ - -#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__ -#define __XEN_PUBLIC_EVENT_CHANNEL_H__ - -#include "xen.h" - -/* - * `incontents 150 evtchn Event Channels - * - * Event channels are the basic primitive provided by Xen for event - * notifications. An event is the Xen equivalent of a hardware - * interrupt. They essentially store one bit of information, the event - * of interest is signalled by transitioning this bit from 0 to 1. - * - * Notifications are received by a guest via an upcall from Xen, - * indicating when an event arrives (setting the bit). Further - * notifications are masked until the bit is cleared again (therefore, - * guests must check the value of the bit after re-enabling event - * delivery to ensure no missed notifications). - * - * Event notifications can be masked by setting a flag; this is - * equivalent to disabling interrupts and can be used to ensure - * atomicity of certain operations in the guest kernel. - * - * Event channels are represented by the evtchn_* fields in - * struct shared_info and struct vcpu_info. - */ - -#define EVTCHNOP_bind_interdomain 0 -#define EVTCHNOP_bind_virq 1 -#define EVTCHNOP_bind_pirq 2 -#define EVTCHNOP_close 3 -#define EVTCHNOP_send 4 -#define EVTCHNOP_status 5 -#define EVTCHNOP_alloc_unbound 6 -#define EVTCHNOP_bind_ipi 7 -#define EVTCHNOP_bind_vcpu 8 -#define EVTCHNOP_unmask 9 -#define EVTCHNOP_reset 10 -#define EVTCHNOP_init_control 11 -#define EVTCHNOP_expand_array 12 -#define EVTCHNOP_set_priority 13 -#ifdef __XEN__ -#define EVTCHNOP_reset_cont 14 -#endif - -typedef uint32_t evtchn_port_t; -DEFINE_XEN_GUEST_HANDLE(evtchn_port_t); - -/* - * EVTCHNOP_alloc_unbound: Allocate a port in domain and mark as - * accepting interdomain bindings from domain . A fresh port - * is allocated in and returned as . - * NOTES: - * 1. If the caller is unprivileged then must be DOMID_SELF. - * 2. may be DOMID_SELF, allowing loopback connections. - */ -struct evtchn_alloc_unbound { - /* IN parameters */ - domid_t dom, remote_dom; - /* OUT parameters */ - evtchn_port_t port; -}; -typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t; - -/* - * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between - * the calling domain and . must identify - * a port that is unbound and marked as accepting bindings from the calling - * domain. A fresh port is allocated in the calling domain and returned as - * . - * - * In case the peer domain has already tried to set our event channel - * pending, before it was bound, EVTCHNOP_bind_interdomain always sets - * the local event channel pending. - * - * The usual pattern of use, in the guest's upcall (or subsequent - * handler) is as follows: (Re-enable the event channel for subsequent - * signalling and then) check for the existence of whatever condition - * is being waited for by other means, and take whatever action is - * needed (if any). - * - * NOTES: - * 1. may be DOMID_SELF, allowing loopback connections. - */ -struct evtchn_bind_interdomain { - /* IN parameters. */ - domid_t remote_dom; - evtchn_port_t remote_port; - /* OUT parameters. */ - evtchn_port_t local_port; -}; -typedef struct evtchn_bind_interdomain evtchn_bind_interdomain_t; - -/* - * EVTCHNOP_close: Close a local event channel . If the channel is - * interdomain then the remote end is placed in the unbound state - * (EVTCHNSTAT_unbound), awaiting a new connection. - */ -struct evtchn_close { - /* IN parameters. */ - evtchn_port_t port; -}; -typedef struct evtchn_close evtchn_close_t; - -/* - * EVTCHNOP_send: Send an event to the remote end of the channel whose local - * endpoint is . - */ -struct evtchn_send { - /* IN parameters. */ - evtchn_port_t port; -}; -typedef struct evtchn_send evtchn_send_t; - -/* - * EVTCHNOP_status: Get the current status of the communication channel which - * has an endpoint at . - * NOTES: - * 1. may be specified as DOMID_SELF. - * 2. Only a sufficiently-privileged domain may obtain the status of an event - * channel for which is not DOMID_SELF. - */ -struct evtchn_status { - /* IN parameters */ - domid_t dom; - evtchn_port_t port; - /* OUT parameters */ -#define EVTCHNSTAT_closed 0 /* Channel is not in use. */ -#define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/ -#define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */ -#define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */ -#define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */ -#define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */ - uint32_t status; - uint32_t vcpu; /* VCPU to which this channel is bound. */ - union { - struct { - domid_t dom; - } unbound; /* EVTCHNSTAT_unbound */ - struct { - domid_t dom; - evtchn_port_t port; - } interdomain; /* EVTCHNSTAT_interdomain */ - uint32_t pirq; /* EVTCHNSTAT_pirq */ - uint32_t virq; /* EVTCHNSTAT_virq */ - } u; -}; -typedef struct evtchn_status evtchn_status_t; - -/* - * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver - * a notification to the appropriate VCPU if an event is pending. - */ -struct evtchn_unmask { - /* IN parameters. */ - evtchn_port_t port; -}; -typedef struct evtchn_unmask evtchn_unmask_t; - -/* - * EVTCHNOP_reset: Close all event channels associated with specified domain. - * NOTES: - * 1. may be specified as DOMID_SELF. - * 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF. - * 3. Destroys all control blocks and event array, resets event channel - * operations to 2-level ABI if called with == DOMID_SELF and FIFO - * ABI was used. Guests should not bind events during EVTCHNOP_reset call - * as these events are likely to be lost. - */ -struct evtchn_reset { - /* IN parameters. */ - domid_t dom; -}; -typedef struct evtchn_reset evtchn_reset_t; - -/* - * EVTCHNOP_set_priority: set the priority for an event channel. - */ -struct evtchn_set_priority { - /* IN parameters. */ - evtchn_port_t port; - uint32_t priority; -}; -typedef struct evtchn_set_priority evtchn_set_priority_t; - -#define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64) - -#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */ diff --git a/include/zephyr/xen/public/grant_table.h b/include/zephyr/xen/public/grant_table.h deleted file mode 100644 index 81803a1daa3f6..0000000000000 --- a/include/zephyr/xen/public/grant_table.h +++ /dev/null @@ -1,415 +0,0 @@ -/* SPDX-License-Identifier: MIT */ - -/****************************************************************************** - * grant_table.h - * - * Interface for granting foreign access to page frames, and receiving - * page-ownership transfers. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2004, K A Fraser - */ - -#ifndef __XEN_PUBLIC_GRANT_TABLE_H__ -#define __XEN_PUBLIC_GRANT_TABLE_H__ - -#include "xen.h" - -/* - * `incontents 150 gnttab Grant Tables - * - * Xen's grant tables provide a generic mechanism to memory sharing - * between domains. This shared memory interface underpins the split - * device drivers for block and network IO. - * - * Each domain has its own grant table. This is a data structure that - * is shared with Xen; it allows the domain to tell Xen what kind of - * permissions other domains have on its pages. Entries in the grant - * table are identified by grant references. A grant reference is an - * integer, which indexes into the grant table. It acts as a - * capability which the grantee can use to perform operations on the - * granter's memory. - * - * This capability-based system allows shared-memory communications - * between unprivileged domains. A grant reference also encapsulates - * the details of a shared page, removing the need for a domain to - * know the real machine address of a page it is sharing. This makes - * it possible to share memory correctly with domains running in - * fully virtualised memory. - */ - -/*********************************** - * GRANT TABLE REPRESENTATION - */ - -/* Some rough guidelines on accessing and updating grant-table entries - * in a concurrency-safe manner. For more information, Linux contains a - * reference implementation for guest OSes (drivers/xen/grant_table.c, see - * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/xen/grant-table.c;hb=HEAD - * - * NB. WMB is a no-op on current-generation x86 processors. However, a - * compiler barrier will still be required. - * - * Introducing a valid entry into the grant table: - * 1. Write ent->domid. - * 2. Write ent->frame: - * GTF_permit_access: Frame to which access is permitted. - * GTF_accept_transfer: Pseudo-phys frame slot being filled by new - * frame, or zero if none. - * 3. Write memory barrier (WMB). - * 4. Write ent->flags, inc. valid type. - * - * Invalidating an unused GTF_permit_access entry: - * 1. flags = ent->flags. - * 2. Observe that !(flags & (GTF_reading|GTF_writing)). - * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). - * NB. No need for WMB as reuse of entry is control-dependent on success of - * step 3, and all architectures guarantee ordering of ctrl-dep writes. - * - * Invalidating an in-use GTF_permit_access entry: - * This cannot be done directly. Request assistance from the domain controller - * which can set a timeout on the use of a grant entry and take necessary - * action. (NB. This is not yet implemented!). - * - * Invalidating an unused GTF_accept_transfer entry: - * 1. flags = ent->flags. - * 2. Observe that !(flags & GTF_transfer_committed). [*] - * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). - * NB. No need for WMB as reuse of entry is control-dependent on success of - * step 3, and all architectures guarantee ordering of ctrl-dep writes. - * [*] If GTF_transfer_committed is set then the grant entry is 'committed'. - * The guest must /not/ modify the grant entry until the address of the - * transferred frame is written. It is safe for the guest to spin waiting - * for this to occur (detect by observing GTF_transfer_completed in - * ent->flags). - * - * Invalidating a committed GTF_accept_transfer entry: - * 1. Wait for (ent->flags & GTF_transfer_completed). - * - * Changing a GTF_permit_access from writable to read-only: - * Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing. - * - * Changing a GTF_permit_access from read-only to writable: - * Use SMP-safe bit-setting instruction. - */ - -/* - * Reference to a grant entry in a specified domain's grant table. - */ -typedef uint32_t grant_ref_t; - -/* - * A grant table comprises a packed array of grant entries in one or more - * page frames shared between Xen and a guest. - * [XEN]: This field is written by Xen and read by the sharing guest. - * [GST]: This field is written by the guest and read by Xen. - */ - -/* - * Version 1 of the grant table entry structure is maintained purely - * for backwards compatibility. New guests should use version 2. - */ -#if CONFIG_XEN_INTERFACE_VERSION < 0x0003020a -#define grant_entry_v1 grant_entry -#define grant_entry_v1_t grant_entry_t -#endif -struct grant_entry_v1 { - /* GTF_xxx: various type and flag information. [XEN,GST] */ - uint16_t flags; - /* The domain being granted foreign privileges. [GST] */ - domid_t domid; - /* - * GTF_permit_access: GFN that @domid is allowed to map and access. [GST] - * GTF_accept_transfer: GFN that @domid is allowed to transfer into. [GST] - * GTF_transfer_completed: MFN whose ownership transferred by @domid - * (non-translated guests only). [XEN] - */ - uint32_t frame; -}; -typedef struct grant_entry_v1 grant_entry_v1_t; - -/* The first few grant table entries will be preserved across grant table - * version changes and may be pre-populated at domain creation by tools. - */ -#define GNTTAB_NR_RESERVED_ENTRIES 8 -#define GNTTAB_RESERVED_CONSOLE 0 -#define GNTTAB_RESERVED_XENSTORE 1 - -/* - * Type of grant entry. - * GTF_invalid: This grant entry grants no privileges. - * GTF_permit_access: Allow @domid to map/access @frame. - * GTF_accept_transfer: Allow @domid to transfer ownership of one page frame - * to this guest. Xen writes the page number to @frame. - * GTF_transitive: Allow @domid to transitively access a subrange of - * @trans_grant in @trans_domid. No mappings are allowed. - */ -#define GTF_invalid (0U << 0) -#define GTF_permit_access (1U << 0) -#define GTF_accept_transfer (2U << 0) -#define GTF_transitive (3U << 0) -#define GTF_type_mask (3U << 0) - -/* - * Subflags for GTF_permit_access and GTF_transitive. - * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] - * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] - * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] - * Further subflags for GTF_permit_access only. - * GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags to be used for - * mappings of the grant [GST] - * GTF_sub_page: Grant access to only a subrange of the page. @domid - * will only be allowed to copy from the grant, and not - * map it. [GST] - */ -#define _GTF_readonly (2) -#define GTF_readonly (1U << _GTF_readonly) -#define _GTF_reading (3) -#define GTF_reading (1U << _GTF_reading) -#define _GTF_writing (4) -#define GTF_writing (1U << _GTF_writing) -#define _GTF_PWT (5) -#define GTF_PWT (1U << _GTF_PWT) -#define _GTF_PCD (6) -#define GTF_PCD (1U << _GTF_PCD) -#define _GTF_PAT (7) -#define GTF_PAT (1U << _GTF_PAT) -#define _GTF_sub_page (8) -#define GTF_sub_page (1U << _GTF_sub_page) - -/* - * Subflags for GTF_accept_transfer: - * GTF_transfer_committed: Xen sets this flag to indicate that it is committed - * to transferring ownership of a page frame. When a guest sees this flag - * it must /not/ modify the grant entry until GTF_transfer_completed is - * set by Xen. - * GTF_transfer_completed: It is safe for the guest to spin-wait on this flag - * after reading GTF_transfer_committed. Xen will always write the frame - * address, followed by ORing this flag, in a timely manner. - */ -#define _GTF_transfer_committed (2) -#define GTF_transfer_committed (1U << _GTF_transfer_committed) -#define _GTF_transfer_completed (3) -#define GTF_transfer_completed (1U << _GTF_transfer_completed) - -/*********************************** - * GRANT TABLE QUERIES AND USES - */ - -/* ` enum neg_errnoval - * ` HYPERVISOR_grant_table_op(enum grant_table_op cmd, - * ` void *args, - * ` unsigned int count) - * ` - * - * @args points to an array of a per-command data structure. The array - * has @count members - */ - -/* ` enum grant_table_op { // GNTTABOP_* => struct gnttab_* */ -#define GNTTABOP_map_grant_ref 0 -#define GNTTABOP_unmap_grant_ref 1 -#define GNTTABOP_setup_table 2 -#define GNTTABOP_dump_table 3 -#define GNTTABOP_transfer 4 -#define GNTTABOP_copy 5 -#define GNTTABOP_query_size 6 -#define GNTTABOP_unmap_and_replace 7 -#if CONFIG_XEN_INTERFACE_VERSION >= 0x0003020a -#define GNTTABOP_set_version 8 -#define GNTTABOP_get_status_frames 9 -#define GNTTABOP_get_version 10 -#define GNTTABOP_swap_grant_ref 11 -#define GNTTABOP_cache_flush 12 -#endif /* CONFIG_XEN_INTERFACE_VERSION */ -/* ` } */ - -/* - * Handle to track a mapping created via a grant reference. - */ -typedef uint32_t grant_handle_t; - -/* - * GNTTABOP_map_grant_ref: Map the grant entry (,) for access - * by devices and/or host CPUs. If successful, is a tracking number - * that must be presented later to destroy the mapping(s). On error, - * is a negative status code. - * NOTES: - * 1. If GNTMAP_device_map is specified then is the address - * via which I/O devices may access the granted frame. - * 2. If GNTMAP_host_map is specified then a mapping will be added at - * either a host virtual address in the current address space, or at - * a PTE at the specified machine address. The type of mapping to - * perform is selected through the GNTMAP_contains_pte flag, and the - * address is specified in . - * 3. Mappings should only be destroyed via GNTTABOP_unmap_grant_ref. If a - * host mapping is destroyed by other means then it is *NOT* guaranteed - * to be accounted to the correct grant reference! - */ -struct gnttab_map_grant_ref { - /* IN parameters. */ - uint64_t host_addr; - uint32_t flags; /* GNTMAP_* */ - grant_ref_t ref; - domid_t dom; - /* OUT parameters. */ - int16_t status; /* => enum grant_status */ - grant_handle_t handle; - uint64_t dev_bus_addr; -}; -typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t; -DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t); - -/* - * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings - * tracked by . If or is zero, that - * field is ignored. If non-zero, they must refer to a device/host mapping - * that is tracked by - * NOTES: - * 1. The call may fail in an undefined manner if either mapping is not - * tracked by . - * 3. After executing a batch of unmaps, it is guaranteed that no stale - * mappings will remain in the device or host TLBs. - */ -struct gnttab_unmap_grant_ref { - /* IN parameters. */ - uint64_t host_addr; - uint64_t dev_bus_addr; - grant_handle_t handle; - /* OUT parameters. */ - int16_t status; /* => enum grant_status */ -}; -typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t; -DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t); - -/* - * GNTTABOP_setup_table: Set up a grant table for comprising at least - * pages. The frame addresses are written to the . - * Only addresses are written, even if the table is larger. - * NOTES: - * 1. may be specified as DOMID_SELF. - * 2. Only a sufficiently-privileged domain may specify != DOMID_SELF. - * 3. Xen may not support more than a single grant-table page per domain. - */ -struct gnttab_setup_table { - /* IN parameters. */ - domid_t dom; - uint32_t nr_frames; - - /* OUT parameters. */ - int16_t status; /* => enum grant_status */ -#if CONFIG_XEN_INTERFACE_VERSION < 0x00040300 - XEN_GUEST_HANDLE(ulong) frame_list; -#else - XEN_GUEST_HANDLE(xen_pfn_t) frame_list; -#endif -}; -typedef struct gnttab_setup_table gnttab_setup_table_t; -DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t); - -/* - * GNTTABOP_query_size: Query the current and maximum sizes of the shared - * grant table. - * NOTES: - * 1. may be specified as DOMID_SELF. - * 2. Only a sufficiently-privileged domain may specify != DOMID_SELF. - */ -struct gnttab_query_size { - /* IN parameters. */ - domid_t dom; - /* OUT parameters. */ - uint32_t nr_frames; - uint32_t max_nr_frames; - int16_t status; /* => enum grant_status */ -}; -typedef struct gnttab_query_size gnttab_query_size_t; -DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t); - -/* - * Bitfield values for gnttab_map_grant_ref.flags. - */ - /* Map the grant entry for access by I/O devices. */ -#define _GNTMAP_device_map (0) -#define GNTMAP_device_map (1<<_GNTMAP_device_map) - /* Map the grant entry for access by host CPUs. */ -#define _GNTMAP_host_map (1) -#define GNTMAP_host_map (1<<_GNTMAP_host_map) - /* Accesses to the granted frame will be restricted to read-only access. */ -#define _GNTMAP_readonly (2) -#define GNTMAP_readonly (1<<_GNTMAP_readonly) - /* - * GNTMAP_host_map subflag: - * 0 => The host mapping is usable only by the guest OS. - * 1 => The host mapping is usable by guest OS + current application. - */ -#define _GNTMAP_application_map (3) -#define GNTMAP_application_map (1<<_GNTMAP_application_map) - - /* - * GNTMAP_contains_pte subflag: - * 0 => This map request contains a host virtual address. - * 1 => This map request contains the machine address of the PTE to update. - */ -#define _GNTMAP_contains_pte (4) -#define GNTMAP_contains_pte (1<<_GNTMAP_contains_pte) - -/* - * Bits to be placed in guest kernel available PTE bits (architecture - * dependent; only supported when XENFEAT_gnttab_map_avail_bits is set). - */ -#define _GNTMAP_guest_avail0 (16) -#define GNTMAP_guest_avail_mask ((uint32_t)~0 << _GNTMAP_guest_avail0) - -/* - * Values for error status returns. All errors are -ve. - */ -/* ` enum grant_status { */ -#define GNTST_okay (0) /* Normal return */ -#define GNTST_general_error (-1) /* General undefined error */ -#define GNTST_bad_domain (-2) /* Unrecognsed domain id */ -#define GNTST_bad_gntref (-3) /* Unrecognised or inappropriate gntref */ -#define GNTST_bad_handle (-4) /* Unrecognised or inappropriate handle */ -#define GNTST_bad_virt_addr (-5) /* Inappropriate virtual address to map */ -#define GNTST_bad_dev_addr (-6) /* Inappropriate device address to unmap */ -#define GNTST_no_device_space (-7) /* Out of space in I/O MMU */ -#define GNTST_permission_denied (-8) /* Not enough privilege for operation */ -#define GNTST_bad_page (-9) /* Specified page was invalid for op */ -#define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary */ -#define GNTST_address_too_big (-11) /* transfer page address too large */ -#define GNTST_eagain (-12) /* Operation not done; try again */ -/* ` } */ - -#define GNTTABOP_error_msgs { \ - "okay", \ - "undefined error", \ - "unrecognised domain id", \ - "invalid grant reference", \ - "invalid mapping handle", \ - "invalid virtual address", \ - "invalid device address", \ - "no spare translation slot in the I/O MMU", \ - "permission denied", \ - "bad page", \ - "copy arguments cross page boundary", \ - "page address size too large", \ - "operation not done; try again" \ -} - -#endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */ diff --git a/include/zephyr/xen/public/hvm/hvm_op.h b/include/zephyr/xen/public/hvm/hvm_op.h deleted file mode 100644 index 89a63dc1291ef..0000000000000 --- a/include/zephyr/xen/public/hvm/hvm_op.h +++ /dev/null @@ -1,42 +0,0 @@ -/* SPDX-License-Identifier: MIT */ - -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2007, Keir Fraser - */ - -#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__ -#define __XEN_PUBLIC_HVM_HVM_OP_H__ - -#include "../xen.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; /* IN */ - uint16_t pad; - uint32_t index; /* IN */ - uint64_t value; /* IN/OUT */ -}; -typedef struct xen_hvm_param xen_hvm_param_t; -DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t); - -#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ diff --git a/include/zephyr/xen/public/hvm/params.h b/include/zephyr/xen/public/hvm/params.h deleted file mode 100644 index 1222b2ffdefda..0000000000000 --- a/include/zephyr/xen/public/hvm/params.h +++ /dev/null @@ -1,41 +0,0 @@ -/* SPDX-License-Identifier: MIT */ - -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2007, Keir Fraser - */ - -#ifndef __XEN_PUBLIC_HVM_PARAMS_H__ -#define __XEN_PUBLIC_HVM_PARAMS_H__ - -#include "hvm_op.h" - -/* - * These are not used by Xen. They are here for convenience of HVM-guest - * xenbus implementations. - */ -#define HVM_PARAM_STORE_PFN 1 -#define HVM_PARAM_STORE_EVTCHN 2 - -/* Console debug shared memory ring and event channel */ -#define HVM_PARAM_CONSOLE_PFN 17 -#define HVM_PARAM_CONSOLE_EVTCHN 18 - -#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */ diff --git a/include/zephyr/xen/public/io/console.h b/include/zephyr/xen/public/io/console.h deleted file mode 100644 index 5178bb086e86f..0000000000000 --- a/include/zephyr/xen/public/io/console.h +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-License-Identifier: MIT */ - -/****************************************************************************** - * console.h - * - * Console I/O interface for Xen guest OSes. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2005, Keir Fraser - */ - -#ifndef __XEN_PUBLIC_IO_CONSOLE_H__ -#define __XEN_PUBLIC_IO_CONSOLE_H__ - -typedef uint32_t XENCONS_RING_IDX; - -#define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1)) - -struct xencons_interface { - char in[1024]; - char out[2048]; - XENCONS_RING_IDX in_cons, in_prod; - XENCONS_RING_IDX out_cons, out_prod; -}; - -#ifdef XEN_WANT_FLEX_CONSOLE_RING -#include "ring.h" -DEFINE_XEN_FLEX_RING(xencons); -#endif - -#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */ diff --git a/include/zephyr/xen/public/memory.h b/include/zephyr/xen/public/memory.h deleted file mode 100644 index 2baf69ef2391a..0000000000000 --- a/include/zephyr/xen/public/memory.h +++ /dev/null @@ -1,164 +0,0 @@ -/* SPDX-License-Identifier: MIT */ - -/****************************************************************************** - * memory.h - * - * Memory reservation and information. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2005, Keir Fraser - */ - -#ifndef __XEN_PUBLIC_MEMORY_H__ -#define __XEN_PUBLIC_MEMORY_H__ - -#include "xen.h" - -#define XENMEM_populate_physmap 6 - -struct xen_memory_reservation { - - /* - * XENMEM_increase_reservation: - * OUT: MFN (*not* GMFN) bases of extents that were allocated - * XENMEM_decrease_reservation: - * IN: GMFN bases of extents to free - * XENMEM_populate_physmap: - * IN: GPFN bases of extents to populate with memory - * OUT: GMFN bases of extents that were allocated - * (NB. This command also updates the mach_to_phys translation table) - * XENMEM_claim_pages: - * IN: must be zero - */ - XEN_GUEST_HANDLE(xen_pfn_t) extent_start; - - /* Number of extents, and size/alignment of each (2^extent_order pages). */ - xen_ulong_t nr_extents; - unsigned int extent_order; - -#if CONFIG_XEN_INTERFACE_VERSION >= 0x00030209 - /* XENMEMF flags. */ - unsigned int mem_flags; -#else - unsigned int address_bits; -#endif - - /* - * Domain whose reservation is being changed. - * Unprivileged domains can specify only DOMID_SELF. - */ - domid_t domid; -}; -typedef struct xen_memory_reservation xen_memory_reservation_t; -DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t); - -/* A batched version of add_to_physmap. */ -#define XENMEM_add_to_physmap_batch 23 -struct xen_add_to_physmap_batch { - /* IN */ - /* Which domain to change the mapping for. */ - domid_t domid; - uint16_t space; /* => enum phys_map_space */ - - /* Number of pages to go through */ - uint16_t size; - -#if CONFIG_XEN_INTERFACE_VERSION < 0x00040700 - domid_t foreign_domid; /* IFF gmfn_foreign. Should be 0 for other spaces. */ -#else - union xen_add_to_physmap_batch_extra { - domid_t foreign_domid; /* gmfn_foreign */ - uint16_t res0; /* All the other spaces. Should be 0 */ - } u; -#endif - - /* Indexes into space being mapped. */ - XEN_GUEST_HANDLE(xen_ulong_t) idxs; - - /* GPFN in domid where the source mapping page should appear. */ - XEN_GUEST_HANDLE(xen_pfn_t) gpfns; - - /* OUT */ - /* Per index error code. */ - XEN_GUEST_HANDLE(int) errs; -}; -typedef struct xen_add_to_physmap_batch xen_add_to_physmap_batch_t; -DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_batch_t); - - -#define XENMAPSPACE_shared_info 0 /* shared info page */ -#define XENMAPSPACE_grant_table 1 /* grant table page */ -#define XENMAPSPACE_gmfn 2 /* GMFN */ - -/* GMFN range, XENMEM_add_to_physmap only.*/ -#define XENMAPSPACE_gmfn_range 3 - -/* GMFN from another dom, XENMEM_add_to_physmap_batch only. */ -#define XENMAPSPACE_gmfn_foreign 4 - -/* - * Device mmio region ARM only; the region is mapped in Stage-2 using the - * Normal Memory Inner/Outer Write-Back Cacheable memory attribute. - */ -#define XENMAPSPACE_dev_mmio 5 - -/* - * Sets the GPFN at which a particular page appears in the specified guest's - * physical address space (translated guests only). - * arg == addr of xen_add_to_physmap_t. - */ -#define XENMEM_add_to_physmap 7 -struct xen_add_to_physmap { - /* Which domain to change the mapping for. */ - domid_t domid; - - /* Number of pages to go through for gmfn_range */ - uint16_t size; - - unsigned int space; /* => enum phys_map_space */ - -#define XENMAPIDX_grant_table_status 0x80000000 - - /* Index into space being mapped. */ - xen_ulong_t idx; - - /* GPFN in domid where the source mapping page should appear. */ - xen_pfn_t gpfn; -}; -typedef struct xen_add_to_physmap xen_add_to_physmap_t; -DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t); - -/* - * Unmaps the page appearing at a particular GPFN from the specified guest's - * physical address space (translated guests only). - * arg == addr of xen_remove_from_physmap_t. - */ -#define XENMEM_remove_from_physmap 15 -struct xen_remove_from_physmap { - /* Which domain to change the mapping for. */ - domid_t domid; - - /* GPFN of the current mapping of the page. */ - xen_pfn_t gpfn; -}; -typedef struct xen_remove_from_physmap xen_remove_from_physmap_t; -DEFINE_XEN_GUEST_HANDLE(xen_remove_from_physmap_t); - -#endif /* __XEN_PUBLIC_MEMORY_H__ */ diff --git a/include/zephyr/xen/public/sched.h b/include/zephyr/xen/public/sched.h deleted file mode 100644 index e9a29a172df18..0000000000000 --- a/include/zephyr/xen/public/sched.h +++ /dev/null @@ -1,201 +0,0 @@ -/* SPDX-License-Identifier: MIT */ - -/****************************************************************************** - * sched.h - * - * Scheduler state interactions - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2005, Keir Fraser - */ - -#ifndef __XEN_PUBLIC_SCHED_H__ -#define __XEN_PUBLIC_SCHED_H__ - -#include "event_channel.h" - -/* - * `incontents 150 sched Guest Scheduler Operations - * - * The SCHEDOP interface provides mechanisms for a guest to interact - * with the scheduler, including yield, blocking and shutting itself - * down. - */ - -/* - * The prototype for this hypercall is: - * ` long HYPERVISOR_sched_op(enum sched_op cmd, void *arg, ...) - * - * @cmd == SCHEDOP_??? (scheduler operation). - * @arg == Operation-specific extra argument(s), as described below. - * ... == Additional Operation-specific extra arguments, described below. - * - * Versions of Xen prior to 3.0.2 provided only the following legacy version - * of this hypercall, supporting only the commands yield, block and shutdown: - * long sched_op(int cmd, unsigned long arg) - * @cmd == SCHEDOP_??? (scheduler operation). - * @arg == 0 (SCHEDOP_yield and SCHEDOP_block) - * == SHUTDOWN_* code (SCHEDOP_shutdown) - * - * This legacy version is available to new guests as: - * ` long HYPERVISOR_sched_op_compat(enum sched_op cmd, unsigned long arg) - */ - -/* - * Voluntarily yield the CPU. - * @arg == NULL. - */ -#define SCHEDOP_yield 0 - -/* - * Block execution of this VCPU until an event is received for processing. - * If called with event upcalls masked, this operation will atomically - * reenable event delivery and check for pending events before blocking the - * VCPU. This avoids a "wakeup waiting" race. - * @arg == NULL. - */ -#define SCHEDOP_block 1 - -/* - * Halt execution of this domain (all VCPUs) and notify the system controller. - * @arg == pointer to sched_shutdown_t structure. - * - * If the sched_shutdown_t reason is SHUTDOWN_suspend then - * x86 PV guests must also set RDX (EDX for 32-bit guests) to the MFN - * of the guest's start info page. RDX/EDX is the third hypercall - * argument. - * - * In addition, which reason is SHUTDOWN_suspend this hypercall - * returns 1 if suspend was cancelled or the domain was merely - * checkpointed, and 0 if it is resuming in a new domain. - */ -#define SCHEDOP_shutdown 2 - -/* - * Poll a set of event-channel ports. Return when one or more are pending. An - * optional timeout may be specified. - * @arg == pointer to sched_poll_t structure. - */ -#define SCHEDOP_poll 3 - -/* - * Declare a shutdown for another domain. The main use of this function is - * in interpreting shutdown requests and reasons for fully-virtualized - * domains. A para-virtualized domain may use SCHEDOP_shutdown directly. - * @arg == pointer to sched_remote_shutdown_t structure. - */ -#define SCHEDOP_remote_shutdown 4 - -/* - * Latch a shutdown code, so that when the domain later shuts down it - * reports this code to the control tools. - * @arg == sched_shutdown_t, as for SCHEDOP_shutdown. - */ -#define SCHEDOP_shutdown_code 5 - -/* - * Setup, poke and destroy a domain watchdog timer. - * @arg == pointer to sched_watchdog_t structure. - * With id == 0, setup a domain watchdog timer to cause domain shutdown - * after timeout, returns watchdog id. - * With id != 0 and timeout == 0, destroy domain watchdog timer. - * With id != 0 and timeout != 0, poke watchdog timer and set new timeout. - */ -#define SCHEDOP_watchdog 6 - -/* - * Override the current vcpu affinity by pinning it to one physical cpu or - * undo this override restoring the previous affinity. - * @arg == pointer to sched_pin_override_t structure. - * - * A negative pcpu value will undo a previous pin override and restore the - * previous cpu affinity. - * This call is allowed for the hardware domain only and requires the cpu - * to be part of the domain's cpupool. - */ -#define SCHEDOP_pin_override 7 - -struct sched_shutdown { - unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ -}; -typedef struct sched_shutdown sched_shutdown_t; -DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t); - -struct sched_poll { - XEN_GUEST_HANDLE(evtchn_port_t) ports; - unsigned int nr_ports; - uint64_t timeout; -}; -typedef struct sched_poll sched_poll_t; -DEFINE_XEN_GUEST_HANDLE(sched_poll_t); - -struct sched_remote_shutdown { - domid_t domain_id; /* Remote domain ID */ - unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ -}; -typedef struct sched_remote_shutdown sched_remote_shutdown_t; -DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t); - -struct sched_watchdog { - uint32_t id; /* watchdog ID */ - uint32_t timeout; /* timeout */ -}; -typedef struct sched_watchdog sched_watchdog_t; -DEFINE_XEN_GUEST_HANDLE(sched_watchdog_t); - -struct sched_pin_override { - int32_t pcpu; -}; -typedef struct sched_pin_override sched_pin_override_t; -DEFINE_XEN_GUEST_HANDLE(sched_pin_override_t); - -/* - * Reason codes for SCHEDOP_shutdown. These may be interpreted by control - * software to determine the appropriate action. For the most part, Xen does - * not care about the shutdown code. - */ -/* Domain exited normally. Clean up and kill. */ -#define SHUTDOWN_poweroff 0 - -/* Clean up, kill, and then restart. */ -#define SHUTDOWN_reboot 1 - -/* Clean up, save suspend info, kill. */ -#define SHUTDOWN_suspend 2 - -/* Tell controller we've crashed. */ -#define SHUTDOWN_crash 3 - -/* Restart because watchdog time expired. */ -#define SHUTDOWN_watchdog 4 - -/* - * Domain asked to perform 'soft reset' for it. The expected behavior is to - * reset internal Xen state for the domain returning it to the point where it - * was created but leaving the domain's memory contents and vCPU contexts - * intact. This will allow the domain to start over and set up all Xen specific - * interfaces again. - */ -#define SHUTDOWN_soft_reset 5 - -/* Maximum valid shutdown reason. */ -#define SHUTDOWN_MAX 5 - -#endif /* __XEN_PUBLIC_SCHED_H__ */ diff --git a/include/zephyr/xen/public/xen.h b/include/zephyr/xen/public/xen.h deleted file mode 100644 index 3018a92d7dc33..0000000000000 --- a/include/zephyr/xen/public/xen.h +++ /dev/null @@ -1,397 +0,0 @@ -/* SPDX-License-Identifier: MIT */ - -/****************************************************************************** - * xen.h - * - * Guest OS interface to Xen. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2004, K A Fraser - */ - -#ifndef __XEN_PUBLIC_XEN_H__ -#define __XEN_PUBLIC_XEN_H__ - -#if defined(CONFIG_ARM64) -#include "arch-arm.h" -#else -#error "Unsupported architecture" -#endif - -#ifndef __ASSEMBLY__ -/* Guest handles for primitive C types. */ -DEFINE_XEN_GUEST_HANDLE(char); -__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char); -DEFINE_XEN_GUEST_HANDLE(int); -__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int); -#if CONFIG_XEN_INTERFACE_VERSION < 0x00040300 -DEFINE_XEN_GUEST_HANDLE(long); -__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long); -#endif -DEFINE_XEN_GUEST_HANDLE(void); - -DEFINE_XEN_GUEST_HANDLE(uint8_t); -DEFINE_XEN_GUEST_HANDLE(uint64_t); -DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); -DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); - -/* Define a variable length array (depends on compiler). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define XEN_FLEX_ARRAY_DIM -#elif defined(__GNUC__) -#define XEN_FLEX_ARRAY_DIM 0 -#else -#define XEN_FLEX_ARRAY_DIM 1 /* variable size */ -#endif - -/* Turn a plain number into a C unsigned (long (long)) constant. */ -#define __xen_mk_uint(x) x ## U -#define __xen_mk_ulong(x) x ## UL -#ifndef __xen_mk_ullong -#define __xen_mk_ullong(x) x ## ULL -#endif -#define xen_mk_uint(x) __xen_mk_uint(x) -#define xen_mk_ulong(x) __xen_mk_ulong(x) -#define xen_mk_ullong(x) __xen_mk_ullong(x) - -#else - -/* In assembly code we cannot use C numeric constant suffixes. */ -#define xen_mk_uint(x) x -#define xen_mk_ulong(x) x -#define xen_mk_ullong(x) x - -#endif - -/* - * HYPERCALLS - */ - -/* `incontents 100 hcalls List of hypercalls - * ` enum hypercall_num { // __HYPERVISOR_* => HYPERVISOR_*() - */ - -#define __HYPERVISOR_set_trap_table 0 -#define __HYPERVISOR_mmu_update 1 -#define __HYPERVISOR_set_gdt 2 -#define __HYPERVISOR_stack_switch 3 -#define __HYPERVISOR_set_callbacks 4 -#define __HYPERVISOR_fpu_taskswitch 5 - -/* compat since 0x00030101 */ -#define __HYPERVISOR_sched_op_compat 6 -#define __HYPERVISOR_platform_op 7 -#define __HYPERVISOR_set_debugreg 8 -#define __HYPERVISOR_get_debugreg 9 -#define __HYPERVISOR_update_descriptor 10 -#define __HYPERVISOR_memory_op 12 -#define __HYPERVISOR_multicall 13 -#define __HYPERVISOR_update_va_mapping 14 -#define __HYPERVISOR_set_timer_op 15 - -/* compat since 0x00030202 */ -#define __HYPERVISOR_event_channel_op_compat 16 -#define __HYPERVISOR_xen_version 17 -#define __HYPERVISOR_console_io 18 - -/* compat since 0x00030202 */ -#define __HYPERVISOR_physdev_op_compat 19 -#define __HYPERVISOR_grant_table_op 20 -#define __HYPERVISOR_vm_assist 21 -#define __HYPERVISOR_update_va_mapping_otherdomain 22 - -/* x86 only */ -#define __HYPERVISOR_iret 23 -#define __HYPERVISOR_vcpu_op 24 - -/* x86/64 only */ -#define __HYPERVISOR_set_segment_base 25 -#define __HYPERVISOR_mmuext_op 26 -#define __HYPERVISOR_xsm_op 27 -#define __HYPERVISOR_nmi_op 28 -#define __HYPERVISOR_sched_op 29 -#define __HYPERVISOR_callback_op 30 -#define __HYPERVISOR_xenoprof_op 31 -#define __HYPERVISOR_event_channel_op 32 -#define __HYPERVISOR_physdev_op 33 -#define __HYPERVISOR_hvm_op 34 -#define __HYPERVISOR_sysctl 35 -#define __HYPERVISOR_domctl 36 -#define __HYPERVISOR_kexec_op 37 -#define __HYPERVISOR_tmem_op 38 -#define __HYPERVISOR_argo_op 39 -#define __HYPERVISOR_xenpmu_op 40 -#define __HYPERVISOR_dm_op 41 -#define __HYPERVISOR_hypfs_op 42 - -/* - * ` int - * ` HYPERVISOR_console_io(unsigned int cmd, - * ` unsigned int count, - * ` char buffer[]); - * - * @cmd: Command (see below) - * @count: Size of the buffer to read/write - * @buffer: Pointer in the guest memory - * - * List of commands: - * - * * CONSOLEIO_write: Write the buffer to Xen console. - * For the hardware domain, all the characters in the buffer will - * be written. Characters will be printed directly to the console. - * For all the other domains, only the printable characters will be - * written. Characters may be buffered until a newline (i.e '\n') is - * found. - * @return 0 on success, otherwise return an error code. - * * CONSOLEIO_read: Attempts to read up to @count characters from Xen - * console. The maximum buffer size (i.e. @count) supported is 2GB. - * @return the number of characters read on success, otherwise return - * an error code. - */ -#define CONSOLEIO_write 0 -#define CONSOLEIO_read 1 - -/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */ -#define DOMID_FIRST_RESERVED xen_mk_uint(0x7FF0) - -/* DOMID_SELF is used in certain contexts to refer to oneself. */ -#define DOMID_SELF xen_mk_uint(0x7FF0) - -/* - * DOMID_IO is used to restrict page-table updates to mapping I/O memory. - * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO - * is useful to ensure that no mappings to the OS's own heap are accidentally - * installed. (e.g., in Linux this could cause havoc as reference counts - * aren't adjusted on the I/O-mapping code path). - * This only makes sense as HYPERVISOR_mmu_update()'s and - * HYPERVISOR_update_va_mapping_otherdomain()'s "foreigndom" argument. For - * HYPERVISOR_mmu_update() context it can be specified by any calling domain, - * otherwise it's only permitted if the caller is privileged. - */ -#define DOMID_IO xen_mk_uint(0x7FF1) - -/* - * DOMID_XEN is used to allow privileged domains to map restricted parts of - * Xen's heap space (e.g., the machine_to_phys table). - * This only makes sense as - * - HYPERVISOR_mmu_update()'s, HYPERVISOR_mmuext_op()'s, or - * HYPERVISOR_update_va_mapping_otherdomain()'s "foreigndom" argument, - * - with XENMAPSPACE_gmfn_foreign, - * and is only permitted if the caller is privileged. - */ -#define DOMID_XEN xen_mk_uint(0x7FF2) - -/* - * DOMID_COW is used as the owner of sharable pages. - */ -#define DOMID_COW xen_mk_uint(0x7FF3) - -/* DOMID_INVALID is used to identify pages with unknown owner. */ -#define DOMID_INVALID xen_mk_uint(0x7FF4) - -/* Idle domain. */ -#define DOMID_IDLE xen_mk_uint(0x7FFF) - -/* Mask for valid domain id values */ -#define DOMID_MASK xen_mk_uint(0x7FFF) - -#ifndef __ASSEMBLY__ - -typedef uint16_t domid_t; - -#if CONFIG_XEN_INTERFACE_VERSION < 0x00040400 -/* - * Event channel endpoints per domain (when using the 2-level ABI): - * 1024 if a long is 32 bits; 4096 if a long is 64 bits. - */ -#define NR_EVENT_CHANNELS EVTCHN_2L_NR_CHANNELS -#endif - -struct vcpu_time_info { - /* - * Updates to the following values are preceded and followed by an - * increment of 'version'. The guest can therefore detect updates by - * looking for changes to 'version'. If the least-significant bit of - * the version number is set then an update is in progress and the - * guest must wait to read a consistent set of values. - * The correct way to interact with the version number is similar to - * Linux's seqlock: see the implementations of - * read_seqbegin/read_seqretry. - */ - uint32_t version; - uint32_t pad0; - uint64_t tsc_timestamp; /* TSC at last update of time vals. */ - uint64_t system_time; /* Time, in nanosecs, since boot.*/ - /* - * Current system time: - * system_time + - * ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32) - * CPU frequency (Hz): - * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift - */ - uint32_t tsc_to_system_mul; - int8_t tsc_shift; -#if CONFIG_XEN_INTERFACE_VERSION > 0x040600 - uint8_t flags; - uint8_t pad1[2]; -#else - int8_t pad1[3]; -#endif -}; /* 32 bytes */ -typedef struct vcpu_time_info vcpu_time_info_t; - -#define XEN_PVCLOCK_TSC_STABLE_BIT (1 << 0) -#define XEN_PVCLOCK_GUEST_STOPPED (1 << 1) - -struct vcpu_info { - /* - * 'evtchn_upcall_pending' is written non-zero by Xen to indicate - * a pending notification for a particular VCPU. It is then cleared - * by the guest OS /before/ checking for pending work, thus avoiding - * a set-and-check race. Note that the mask is only accessed by Xen - * on the CPU that is currently hosting the VCPU. This means that the - * pending and mask flags can be updated by the guest without special - * synchronisation (i.e., no need for the x86 LOCK prefix). - * This may seem suboptimal because if the pending flag is set by - * a different CPU then an IPI may be scheduled even when the mask - * is set. However, note: - * 1. The task of 'interrupt holdoff' is covered by the per-event- - * channel mask bits. A 'noisy' event that is continually being - * triggered can be masked at source at this very precise - * granularity. - * 2. The main purpose of the per-VCPU mask is therefore to restrict - * reentrant execution: whether for concurrency control, or to - * prevent unbounded stack usage. Whatever the purpose, we expect - * that the mask will be asserted only for short periods at a time, - * and so the likelihood of a 'spurious' IPI is suitably small. - * The mask is read before making an event upcall to the guest: a - * non-zero mask therefore guarantees that the VCPU will not receive - * an upcall activation. The mask is cleared when the VCPU requests - * to block: this avoids wakeup-waiting races. - */ - uint8_t evtchn_upcall_pending; -#ifdef XEN_HAVE_PV_UPCALL_MASK - uint8_t evtchn_upcall_mask; -#else /* XEN_HAVE_PV_UPCALL_MASK */ - uint8_t pad0; -#endif /* XEN_HAVE_PV_UPCALL_MASK */ - xen_ulong_t evtchn_pending_sel; - struct arch_vcpu_info arch; - vcpu_time_info_t time; -}; /* 64 bytes (x86) */ -#ifndef __XEN__ -typedef struct vcpu_info vcpu_info_t; -#endif - -/* - * `incontents 200 startofday_shared Start-of-day shared data structure - * Xen/kernel shared data -- pointer provided in start_info. - * - * This structure is defined to be both smaller than a page, and the - * only data on the shared page, but may vary in actual size even within - * compatible Xen versions; guests should not rely on the size - * of this structure remaining constant. - */ -struct shared_info { - struct vcpu_info vcpu_info[XEN_LEGACY_MAX_VCPUS]; - - /* - * A domain can create "event channels" on which it can send and receive - * asynchronous event notifications. There are three classes of event that - * are delivered by this mechanism: - * 1. Bi-directional inter- and intra-domain connections. Domains must - * arrange out-of-band to set up a connection (usually by allocating - * an unbound 'listener' port and advertising that via a storage service - * such as xenstore). - * 2. Physical interrupts. A domain with suitable hardware-access - * privileges can bind an event-channel port to a physical interrupt - * source. - * 3. Virtual interrupts ('events'). A domain can bind an event-channel - * port to a virtual interrupt source, such as the virtual-timer - * device or the emergency console. - * - * Event channels are addressed by a "port index". Each channel is - * associated with two bits of information: - * 1. PENDING -- notifies the domain that there is a pending notification - * to be processed. This bit is cleared by the guest. - * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING - * will cause an asynchronous upcall to be scheduled. This bit is only - * updated by the guest. It is read-only within Xen. If a channel - * becomes pending while the channel is masked then the 'edge' is lost - * (i.e., when the channel is unmasked, the guest must manually handle - * pending notifications as no upcall will be scheduled by Xen). - * - * To expedite scanning of pending notifications, any 0->1 pending - * transition on an unmasked channel causes a corresponding bit in a - * per-vcpu selector word to be set. Each bit in the selector covers a - * 'C long' in the PENDING bitfield array. - */ - xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8]; - xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8]; - - /* - * Wallclock time: updated by control software or RTC emulation. - * Guests should base their gettimeofday() syscall on this - * wallclock-base value. - * The values of wc_sec and wc_nsec are offsets from the Unix epoch - * adjusted by the domain's 'time offset' (in seconds) as set either - * by XEN_DOMCTL_settimeoffset, or adjusted via a guest write to the - * emulated RTC. - */ - uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */ - uint32_t wc_sec; - uint32_t wc_nsec; -#if !defined(__i386__) - uint32_t wc_sec_hi; -# define xen_wc_sec_hi wc_sec_hi -#elif !defined(__XEN__) && !defined(__XEN_TOOLS__) -# define xen_wc_sec_hi arch.wc_sec_hi -#endif - - struct arch_shared_info arch; - -}; -#ifndef __XEN__ -typedef struct shared_info shared_info_t; -#endif - -typedef uint8_t xen_domain_handle_t[16]; - -#ifndef int64_aligned_t -#define int64_aligned_t int64_t -#endif -#ifndef uint64_aligned_t -#define uint64_aligned_t uint64_t -#endif -#ifndef XEN_GUEST_HANDLE_64 -#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name) -#endif - -#ifndef __ASSEMBLY__ -struct xenctl_bitmap { - XEN_GUEST_HANDLE_64(uint8_t) bitmap; - uint32_t nr_bits; -}; -typedef struct xenctl_bitmap xenctl_bitmap_t; -#endif - -#endif /* !__ASSEMBLY__ */ - -#endif /* __XEN_PUBLIC_XEN_H__ */ diff --git a/modules/xen/CMakeLists.txt b/modules/xen/CMakeLists.txt new file mode 100644 index 0000000000000..df75c346a2d42 --- /dev/null +++ b/modules/xen/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2025 TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +if(CONFIG_XEN) + set(XEN_DIR ${ZEPHYR_CURRENT_MODULE_DIR}) + + zephyr_include_directories(${XEN_DIR}/include) +endif() diff --git a/west.yml b/west.yml index 10c1ca7c664e4..798ec49ec32ec 100644 --- a/west.yml +++ b/west.yml @@ -23,6 +23,8 @@ manifest: url-base: https://github.com/zephyrproject-rtos - name: babblesim url-base: https://github.com/BabbleSim + - name: soburi + url-base: https://github.com/soburi group-filter: [-babblesim, -optional] @@ -367,6 +369,10 @@ manifest: - name: uoscore-uedhoc revision: 54abc109c9c0adfd53c70077744c14e454f04f4a path: modules/lib/uoscore-uedhoc + - name: xen + revision: 2aed8da0734432d22f81666cb6136013b99262d4 + path: modules/lib/xen + remote: soburi - name: zcbor revision: 9b07780aca6fb21f82a241ba386ad9b379809337 path: modules/lib/zcbor