Xen Test Framework
sysctl.h
Go to the documentation of this file.
1/******************************************************************************
2 * sysctl.h
3 *
4 * System management operations. For use by node control stack.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Copyright (c) 2002-2006, K Fraser
25 */
26
27#ifndef __XEN_PUBLIC_SYSCTL_H__
28#define __XEN_PUBLIC_SYSCTL_H__
29
30#include "xen.h"
31#include "physdev.h"
32
33/*
34 * XEN_SYSCTL_LIVEPATCH_op
35 *
36 * Refer to the docs/unstable/misc/livepatch.markdown
37 * for the design details of this hypercall.
38 *
39 * There are four sub-ops:
40 * XEN_SYSCTL_LIVEPATCH_UPLOAD (0)
41 * XEN_SYSCTL_LIVEPATCH_GET (1)
42 * XEN_SYSCTL_LIVEPATCH_LIST (2)
43 * XEN_SYSCTL_LIVEPATCH_ACTION (3)
44 *
45 * The normal sequence of sub-ops is to:
46 * 1) XEN_SYSCTL_LIVEPATCH_UPLOAD to upload the payload. If errors STOP.
47 * 2) XEN_SYSCTL_LIVEPATCH_GET to check the `->rc`. If -XEN_EAGAIN spin.
48 * If zero go to next step.
49 * 3) XEN_SYSCTL_LIVEPATCH_ACTION with LIVEPATCH_ACTION_APPLY to apply the patch.
50 * 4) XEN_SYSCTL_LIVEPATCH_GET to check the `->rc`. If in -XEN_EAGAIN spin.
51 * If zero exit with success.
52 */
53
54#define LIVEPATCH_PAYLOAD_VERSION 1
55/*
56 * Structure describing an ELF payload. Uniquely identifies the
57 * payload. Should be human readable.
58 * Recommended length is upto XEN_LIVEPATCH_NAME_SIZE.
59 * Includes the NUL terminator.
60 */
61#define XEN_LIVEPATCH_NAME_SIZE 128
63 guest_handle_64_t name; /* IN: pointer to name. */
64 uint16_t size; /* IN: size of name. May be upto
65 XEN_LIVEPATCH_NAME_SIZE. */
66 uint16_t pad[3]; /* IN: MUST be zero. */
67};
69
70/*
71 * Upload a payload to the hypervisor. The payload is verified
72 * against basic checks and if there are any issues the proper return code
73 * will be returned. The payload is not applied at this time - that is
74 * controlled by XEN_SYSCTL_LIVEPATCH_ACTION.
75 *
76 * The return value is zero if the payload was succesfully uploaded.
77 * Otherwise an EXX return value is provided. Duplicate `name` are not
78 * supported.
79 *
80 * The payload at this point is verified against basic checks.
81 *
82 * The `payload` is the ELF payload as mentioned in the `Payload format`
83 * section in the Live Patch design document.
84 */
85#define XEN_SYSCTL_LIVEPATCH_UPLOAD 0
87 xen_livepatch_name_t name; /* IN, name of the patch. */
88 uint64_t size; /* IN, size of the ELF file. */
89 guest_handle_64_t payload; /* IN, the ELF file. */
90};
92
93/*
94 * Retrieve an status of an specific payload.
95 *
96 * Upon completion the `struct xen_livepatch_status` is updated.
97 *
98 * The return value is zero on success and XEN_EXX on failure. This operation
99 * is synchronous and does not require preemption.
100 */
101#define XEN_SYSCTL_LIVEPATCH_GET 1
102
104#define LIVEPATCH_STATE_CHECKED 1
105#define LIVEPATCH_STATE_APPLIED 2
106 uint32_t state; /* OUT: LIVEPATCH_STATE_*. */
107 int32_t rc; /* OUT: 0 if no error, otherwise -XEN_EXX. */
108};
110
112 xen_livepatch_name_t name; /* IN, name of the payload. */
113 xen_livepatch_status_t status; /* IN/OUT, state of it. */
114};
116
117/*
118 * Retrieve an array of abbreviated status and names of payloads that are
119 * loaded in the hypervisor.
120 *
121 * If the hypercall returns an positive number, it is the number (up to `nr`)
122 * of the payloads returned, along with `nr` updated with the number of remaining
123 * payloads, `version` updated (it may be the same across hypercalls. If it
124 * varies the data is stale and further calls could fail). The `status`,
125 * `name`, and `len`' are updated at their designed index value (`idx`) with
126 * the returned value of data.
127 *
128 * If the hypercall returns E2BIG the `nr` is too big and should be
129 * lowered. The upper limit of `nr` is left to the implemention.
130 *
131 * Note that due to the asynchronous nature of hypercalls the domain might have
132 * added or removed the number of payloads making this information stale. It is
133 * the responsibility of the toolstack to use the `version` field to check
134 * between each invocation. if the version differs it should discard the stale
135 * data and start from scratch. It is OK for the toolstack to use the new
136 * `version` field.
137 */
138#define XEN_SYSCTL_LIVEPATCH_LIST 2
140 uint32_t version; /* OUT: Hypervisor stamps value.
141 If varies between calls, we are
142 * getting stale data. */
143 uint32_t idx; /* IN: Index into hypervisor list. */
144 uint32_t nr; /* IN: How many status, name, and len
145 should fill out. Can be zero to get
146 amount of payloads and version.
147 OUT: How many payloads left. */
148 uint32_t pad; /* IN: Must be zero. */
149 guest_handle_64_t status; /* OUT. Must have enough
150 space allocate for nr of them. */
151 guest_handle_64_t name; /* OUT: Array of names. Each member
152 MUST XEN_LIVEPATCH_NAME_SIZE in size.
153 Must have nr of them. */
154 guest_handle_64_t len; /* OUT: Array of lengths of name's.
155 Must have nr of them. */
156};
158
159/*
160 * Perform an operation on the payload structure referenced by the `name` field.
161 * The operation request is asynchronous and the status should be retrieved
162 * by using either XEN_SYSCTL_LIVEPATCH_GET or XEN_SYSCTL_LIVEPATCH_LIST hypercall.
163 */
164#define XEN_SYSCTL_LIVEPATCH_ACTION 3
166 xen_livepatch_name_t name; /* IN, name of the patch. */
167#define LIVEPATCH_ACTION_UNLOAD 1
168#define LIVEPATCH_ACTION_REVERT 2
169#define LIVEPATCH_ACTION_APPLY 3
170#define LIVEPATCH_ACTION_REPLACE 4
171 uint32_t cmd; /* IN: LIVEPATCH_ACTION_*. */
172 uint32_t timeout; /* IN: Zero if no timeout. */
173 /* Or upper bound of time (ms) */
174 /* for operation to take. */
175};
177
179 uint32_t cmd; /* IN: XEN_SYSCTL_LIVEPATCH_*. */
180 uint32_t pad; /* IN: Always zero. */
181 union {
186 } u;
187};
189
192#define XEN_SYSCTL_livepatch_op 27
193 uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
194 union {
197 } u;
198};
200
201#endif /* __XEN_PUBLIC_SYSCTL_H__ */
202
203/*
204 * Local variables:
205 * mode: C
206 * c-file-style: "BSD"
207 * c-basic-offset: 4
208 * tab-width: 4
209 * indent-tabs-mode: nil
210 * End:
211 */
__UINT32_TYPE__ uint32_t
Definition: stdint.h:16
__INT32_TYPE__ int32_t
Definition: stdint.h:11
__UINT64_TYPE__ uint64_t
Definition: stdint.h:17
__UINT8_TYPE__ uint8_t
Definition: stdint.h:14
__UINT16_TYPE__ uint16_t
Definition: stdint.h:15
uint16_t size
Definition: sysctl.h:64
uint16_t pad[3]
Definition: sysctl.h:66
guest_handle_64_t name
Definition: sysctl.h:63
uint32_t state
Definition: sysctl.h:106
xen_livepatch_name_t name
Definition: sysctl.h:166
xen_livepatch_status_t status
Definition: sysctl.h:113
xen_livepatch_name_t name
Definition: sysctl.h:112
guest_handle_64_t status
Definition: sysctl.h:149
guest_handle_64_t len
Definition: sysctl.h:154
guest_handle_64_t name
Definition: sysctl.h:151
xen_sysctl_livepatch_get_t get
Definition: sysctl.h:184
union xen_sysctl_livepatch_op::@42 u
xen_sysctl_livepatch_action_t action
Definition: sysctl.h:185
xen_sysctl_livepatch_upload_t upload
Definition: sysctl.h:182
xen_sysctl_livepatch_list_t list
Definition: sysctl.h:183
xen_livepatch_name_t name
Definition: sysctl.h:87
guest_handle_64_t payload
Definition: sysctl.h:89
uint8_t pad[128]
Definition: sysctl.h:196
union xen_sysctl::@43 u
uint32_t cmd
Definition: sysctl.h:191
struct xen_sysctl_livepatch_op livepatch
Definition: sysctl.h:195
uint32_t interface_version
Definition: sysctl.h:193