^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Guest OS interface to ARM Xen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Citrix, 2012
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef _ASM_ARM_XEN_INTERFACE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define _ASM_ARM_XEN_INTERFACE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define uint64_aligned_t uint64_t __attribute__((aligned(8)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define __DEFINE_GUEST_HANDLE(name, type) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) typedef struct { union { type *p; uint64_aligned_t q; }; } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) __guest_handle_ ## name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define DEFINE_GUEST_HANDLE_STRUCT(name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) __DEFINE_GUEST_HANDLE(name, struct name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define GUEST_HANDLE(name) __guest_handle_ ## name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define set_xen_guest_handle(hnd, val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) if (sizeof(hnd) == 8) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *(uint64_t *)&(hnd) = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) (hnd).p = val; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define __HYPERVISOR_platform_op_raw __HYPERVISOR_platform_op
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /* Explicitly size integers that represent pfns in the interface with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * Xen so that we can have one ABI that works for 32 and 64 bit guests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * Note that this means that the xen_pfn_t type may be capable of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * representing pfn's which the guest cannot represent in its own pfn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * type. However since pfn space is controlled by the guest this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * fine since it simply wouldn't be able to create any sure pfns in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * the first place.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) typedef uint64_t xen_pfn_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define PRI_xen_pfn "llx"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) typedef uint64_t xen_ulong_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define PRI_xen_ulong "llx"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) typedef int64_t xen_long_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define PRI_xen_long "llx"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* Guest handles for primitive C types. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) __DEFINE_GUEST_HANDLE(uchar, unsigned char);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) __DEFINE_GUEST_HANDLE(uint, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) DEFINE_GUEST_HANDLE(char);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) DEFINE_GUEST_HANDLE(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) DEFINE_GUEST_HANDLE(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) DEFINE_GUEST_HANDLE(uint64_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) DEFINE_GUEST_HANDLE(uint32_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) DEFINE_GUEST_HANDLE(xen_pfn_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) DEFINE_GUEST_HANDLE(xen_ulong_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /* Maximum number of virtual CPUs in multi-processor guests. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define MAX_VIRT_CPUS 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct arch_vcpu_info { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct arch_shared_info { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /* TODO: Move pvclock definitions some place arch independent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct pvclock_vcpu_time_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u32 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u32 pad0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) u64 tsc_timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) u64 system_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) u32 tsc_to_system_mul;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) s8 tsc_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) u8 pad[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) } __attribute__((__packed__)); /* 32 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* It is OK to have a 12 bytes struct with no padding because it is packed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct pvclock_wall_clock {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) u32 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) u32 sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) u32 nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) u32 sec_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) } __attribute__((__packed__));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #endif /* _ASM_ARM_XEN_INTERFACE_H */