Skip to content

Commit b587cbe

Browse files
committed
xenvm: include: add some of Xen public headers
This commit adds few Xen public headers, which are needed for further development of Xen features in Zephyr. Headers were taken from include/public directory of Xen RELEASE-4.15.0 branch, filtered and cleaned up to leave only parts, which are now required. Directory structure were saved (public, public/io, public/hvm), so public headers content can be supplemented if nessesary. Signed-off-by: Dmytro Firsov <[email protected]>
1 parent 36f907e commit b587cbe

File tree

8 files changed

+1101
-0
lines changed

8 files changed

+1101
-0
lines changed

include/xen/public/arch-arm.h

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
/* SPDX-License-Identifier: MIT */
2+
3+
/******************************************************************************
4+
* arch-arm.h
5+
*
6+
* Guest OS interface to ARM Xen.
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to
10+
* deal in the Software without restriction, including without limitation the
11+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12+
* sell copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24+
* DEALINGS IN THE SOFTWARE.
25+
*
26+
* Copyright 2011 (C) Citrix Systems
27+
*/
28+
29+
#ifndef __XEN_PUBLIC_ARCH_ARM_H__
30+
#define __XEN_PUBLIC_ARCH_ARM_H__
31+
32+
#include <kernel.h>
33+
34+
/*
35+
* `incontents 50 arm_abi Hypercall Calling Convention
36+
*
37+
* A hypercall is issued using the ARM HVC instruction.
38+
*
39+
* A hypercall can take up to 5 arguments. These are passed in
40+
* registers, the first argument in x0/r0 (for arm64/arm32 guests
41+
* respectively irrespective of whether the underlying hypervisor is
42+
* 32- or 64-bit), the second argument in x1/r1, the third in x2/r2,
43+
* the forth in x3/r3 and the fifth in x4/r4.
44+
*
45+
* The hypercall number is passed in r12 (arm) or x16 (arm64). In both
46+
* cases the relevant ARM procedure calling convention specifies this
47+
* is an inter-procedure-call scratch register (e.g. for use in linker
48+
* stubs). This use does not conflict with use during a hypercall.
49+
*
50+
* The HVC ISS must contain a Xen specific TAG: XEN_HYPERCALL_TAG.
51+
*
52+
* The return value is in x0/r0.
53+
*
54+
* The hypercall will clobber x16/r12 and the argument registers used
55+
* by that hypercall (except r0 which is the return value) i.e. in
56+
* addition to x16/r12 a 2 argument hypercall will clobber x1/r1 and a
57+
* 4 argument hypercall will clobber x1/r1, x2/r2 and x3/r3.
58+
*
59+
* Parameter structs passed to hypercalls are laid out according to
60+
* the Procedure Call Standard for the ARM Architecture (AAPCS, AKA
61+
* EABI) and Procedure Call Standard for the ARM 64-bit Architecture
62+
* (AAPCS64). Where there is a conflict the 64-bit standard should be
63+
* used regardless of guest type. Structures which are passed as
64+
* hypercall arguments are always little endian.
65+
*
66+
* All memory which is shared with other entities in the system
67+
* (including the hypervisor and other guests) must reside in memory
68+
* which is mapped as Normal Inner Write-Back Outer Write-Back Inner-Shareable.
69+
* This applies to:
70+
* - hypercall arguments passed via a pointer to guest memory.
71+
* - memory shared via the grant table mechanism (including PV I/O
72+
* rings etc).
73+
* - memory shared with the hypervisor (struct shared_info, struct
74+
* vcpu_info, the grant table, etc).
75+
*
76+
* Any cache allocation hints are acceptable.
77+
*/
78+
79+
/*
80+
* `incontents 55 arm_hcall Supported Hypercalls
81+
*
82+
* Xen on ARM makes extensive use of hardware facilities and therefore
83+
* only a subset of the potential hypercalls are required.
84+
*
85+
* Since ARM uses second stage paging any machine/physical addresses
86+
* passed to hypercalls are Guest Physical Addresses (Intermediate
87+
* Physical Addresses) unless otherwise noted.
88+
*
89+
* The following hypercalls (and sub operations) are supported on the
90+
* ARM platform. Other hypercalls should be considered
91+
* unavailable/unsupported.
92+
*
93+
* HYPERVISOR_memory_op
94+
* All generic sub-operations
95+
*
96+
* HYPERVISOR_domctl
97+
* All generic sub-operations, with the exception of:
98+
* * XEN_DOMCTL_irq_permission (not yet implemented)
99+
*
100+
* HYPERVISOR_sched_op
101+
* All generic sub-operations, with the exception of:
102+
* * SCHEDOP_block -- prefer wfi hardware instruction
103+
*
104+
* HYPERVISOR_console_io
105+
* All generic sub-operations
106+
*
107+
* HYPERVISOR_xen_version
108+
* All generic sub-operations
109+
*
110+
* HYPERVISOR_event_channel_op
111+
* All generic sub-operations
112+
*
113+
* HYPERVISOR_physdev_op
114+
* No sub-operations are currenty supported
115+
*
116+
* HYPERVISOR_sysctl
117+
* All generic sub-operations, with the exception of:
118+
* * XEN_SYSCTL_page_offline_op
119+
* * XEN_SYSCTL_get_pmstat
120+
* * XEN_SYSCTL_pm_op
121+
*
122+
* HYPERVISOR_hvm_op
123+
* Exactly these sub-operations are supported:
124+
* * HVMOP_set_param
125+
* * HVMOP_get_param
126+
*
127+
* HYPERVISOR_grant_table_op
128+
* All generic sub-operations
129+
*
130+
* HYPERVISOR_vcpu_op
131+
* Exactly these sub-operations are supported:
132+
* * VCPUOP_register_vcpu_info
133+
* * VCPUOP_register_runstate_memory_area
134+
*
135+
*
136+
* Other notes on the ARM ABI:
137+
*
138+
* - struct start_info is not exported to ARM guests.
139+
*
140+
* - struct shared_info is mapped by ARM guests using the
141+
* HYPERVISOR_memory_op sub-op XENMEM_add_to_physmap, passing
142+
* XENMAPSPACE_shared_info as space parameter.
143+
*
144+
* - All the per-cpu struct vcpu_info are mapped by ARM guests using the
145+
* HYPERVISOR_vcpu_op sub-op VCPUOP_register_vcpu_info, including cpu0
146+
* struct vcpu_info.
147+
*
148+
* - The grant table is mapped using the HYPERVISOR_memory_op sub-op
149+
* XENMEM_add_to_physmap, passing XENMAPSPACE_grant_table as space
150+
* parameter. The memory range specified under the Xen compatible
151+
* hypervisor node on device tree can be used as target gpfn for the
152+
* mapping.
153+
*
154+
* - Xenstore is initialized by using the two hvm_params
155+
* HVM_PARAM_STORE_PFN and HVM_PARAM_STORE_EVTCHN. They can be read
156+
* with the HYPERVISOR_hvm_op sub-op HVMOP_get_param.
157+
*
158+
* - The paravirtualized console is initialized by using the two
159+
* hvm_params HVM_PARAM_CONSOLE_PFN and HVM_PARAM_CONSOLE_EVTCHN. They
160+
* can be read with the HYPERVISOR_hvm_op sub-op HVMOP_get_param.
161+
*
162+
* - Event channel notifications are delivered using the percpu GIC
163+
* interrupt specified under the Xen compatible hypervisor node on
164+
* device tree.
165+
*
166+
* - The device tree Xen compatible node is fully described under Linux
167+
* at Documentation/devicetree/bindings/arm/xen.txt.
168+
*/
169+
170+
#define XEN_HYPERCALL_TAG 0XEA1
171+
172+
#define int64_aligned_t int64_t __aligned(8)
173+
#define uint64_aligned_t uint64_t __aligned(8)
174+
175+
#ifndef __ASSEMBLY__
176+
#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
177+
typedef union { type *p; unsigned long q; } \
178+
__guest_handle_ ## name; \
179+
typedef union { type *p; uint64_aligned_t q; } \
180+
__guest_handle_64_ ## name
181+
182+
/*
183+
* XEN_GUEST_HANDLE represents a guest pointer, when passed as a field
184+
* in a struct in memory. On ARM is always 8 bytes sizes and 8 bytes
185+
* aligned.
186+
* XEN_GUEST_HANDLE_PARAM represents a guest pointer, when passed as an
187+
* hypercall argument. It is 4 bytes on aarch32 and 8 bytes on aarch64.
188+
*/
189+
#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
190+
___DEFINE_XEN_GUEST_HANDLE(name, type); \
191+
___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
192+
#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
193+
#define __XEN_GUEST_HANDLE(name) __guest_handle_64_ ## name
194+
#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name)
195+
#define XEN_GUEST_HANDLE_PARAM(name) __guest_handle_ ## name
196+
#define set_xen_guest_handle_raw(hnd, val) \
197+
do { \
198+
__typeof__(&(hnd)) _sxghr_tmp = &(hnd); \
199+
_sxghr_tmp->q = 0; \
200+
_sxghr_tmp->p = val; \
201+
} while (0)
202+
#define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val)
203+
204+
typedef uint64_t xen_pfn_t;
205+
#define PRI_xen_pfn PRIx64
206+
#define PRIu_xen_pfn PRIu64
207+
208+
typedef uint64_t xen_ulong_t;
209+
#define PRI_xen_ulong PRIx64
210+
211+
/*
212+
* Maximum number of virtual CPUs in legacy multi-processor guests.
213+
* Only one. All other VCPUS must use VCPUOP_register_vcpu_info.
214+
*/
215+
#define XEN_LEGACY_MAX_VCPUS 1
216+
217+
struct arch_vcpu_info {
218+
};
219+
typedef struct arch_vcpu_info arch_vcpu_info_t;
220+
221+
struct arch_shared_info {
222+
};
223+
typedef struct arch_shared_info arch_shared_info_t;
224+
typedef uint64_t xen_callback_t;
225+
226+
#endif /* __ASSEMBLY__ */
227+
228+
#endif /* __XEN_PUBLIC_ARCH_ARM_H__ */

include/xen/public/event_channel.h

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/* SPDX-License-Identifier: MIT */
2+
3+
/******************************************************************************
4+
* event_channel.h
5+
*
6+
* Event channels between domains.
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to
10+
* deal in the Software without restriction, including without limitation the
11+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12+
* sell copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24+
* DEALINGS IN THE SOFTWARE.
25+
*
26+
* Copyright (c) 2003-2004, K A Fraser.
27+
*/
28+
29+
#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
30+
#define __XEN_PUBLIC_EVENT_CHANNEL_H__
31+
32+
#include "xen.h"
33+
34+
/*
35+
* `incontents 150 evtchn Event Channels
36+
*
37+
* Event channels are the basic primitive provided by Xen for event
38+
* notifications. An event is the Xen equivalent of a hardware
39+
* interrupt. They essentially store one bit of information, the event
40+
* of interest is signalled by transitioning this bit from 0 to 1.
41+
*
42+
* Notifications are received by a guest via an upcall from Xen,
43+
* indicating when an event arrives (setting the bit). Further
44+
* notifications are masked until the bit is cleared again (therefore,
45+
* guests must check the value of the bit after re-enabling event
46+
* delivery to ensure no missed notifications).
47+
*
48+
* Event notifications can be masked by setting a flag; this is
49+
* equivalent to disabling interrupts and can be used to ensure
50+
* atomicity of certain operations in the guest kernel.
51+
*
52+
* Event channels are represented by the evtchn_* fields in
53+
* struct shared_info and struct vcpu_info.
54+
*/
55+
56+
#define EVTCHNOP_bind_interdomain 0
57+
#define EVTCHNOP_bind_virq 1
58+
#define EVTCHNOP_bind_pirq 2
59+
#define EVTCHNOP_close 3
60+
#define EVTCHNOP_send 4
61+
#define EVTCHNOP_status 5
62+
#define EVTCHNOP_alloc_unbound 6
63+
#define EVTCHNOP_bind_ipi 7
64+
#define EVTCHNOP_bind_vcpu 8
65+
#define EVTCHNOP_unmask 9
66+
#define EVTCHNOP_reset 10
67+
#define EVTCHNOP_init_control 11
68+
#define EVTCHNOP_expand_array 12
69+
#define EVTCHNOP_set_priority 13
70+
#ifdef __XEN__
71+
#define EVTCHNOP_reset_cont 14
72+
#endif
73+
74+
typedef uint32_t evtchn_port_t;
75+
DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
76+
77+
/*
78+
* EVTCHNOP_send: Send an event to the remote end of the channel whose local
79+
* endpoint is <port>.
80+
*/
81+
struct evtchn_send {
82+
/* IN parameters. */
83+
evtchn_port_t port;
84+
};
85+
typedef struct evtchn_send evtchn_send_t;
86+
87+
#define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)
88+
89+
#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */

include/xen/public/hvm/hvm_op.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* SPDX-License-Identifier: MIT */
2+
3+
/*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to
6+
* deal in the Software without restriction, including without limitation the
7+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
* sell copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
* DEALINGS IN THE SOFTWARE.
21+
*
22+
* Copyright (c) 2007, Keir Fraser
23+
*/
24+
25+
#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__
26+
#define __XEN_PUBLIC_HVM_HVM_OP_H__
27+
28+
#include "../xen.h"
29+
30+
/* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */
31+
#define HVMOP_set_param 0
32+
#define HVMOP_get_param 1
33+
struct xen_hvm_param {
34+
domid_t domid; /* IN */
35+
uint16_t pad;
36+
uint32_t index; /* IN */
37+
uint64_t value; /* IN/OUT */
38+
};
39+
typedef struct xen_hvm_param xen_hvm_param_t;
40+
DEFINE_XEN_GUEST_HANDLE(xen_hvm_param_t);
41+
42+
#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */

0 commit comments

Comments
 (0)