xref: /openbmc/linux/include/xen/interface/callback.h (revision c4c3c32d)
1 /* SPDX-License-Identifier: MIT */
2 /******************************************************************************
3  * callback.h
4  *
5  * Register guest OS callbacks with Xen.
6  *
7  * Copyright (c) 2006, Ian Campbell
8  */
9 
10 #ifndef __XEN_PUBLIC_CALLBACK_H__
11 #define __XEN_PUBLIC_CALLBACK_H__
12 
13 #include <xen/interface/xen.h>
14 
15 /*
16  * Prototype for this hypercall is:
17  *   long callback_op(int cmd, void *extra_args)
18  * @cmd        == CALLBACKOP_??? (callback operation).
19  * @extra_args == Operation-specific extra arguments (NULL if none).
20  */
21 
22 /* x86: Callback for event delivery. */
23 #define CALLBACKTYPE_event                 0
24 
25 /* x86: Failsafe callback when guest state cannot be restored by Xen. */
26 #define CALLBACKTYPE_failsafe              1
27 
28 /* x86/64 hypervisor: Syscall by 64-bit guest app ('64-on-64-on-64'). */
29 #define CALLBACKTYPE_syscall               2
30 
31 /*
32  * x86/32 hypervisor: Only available on x86/32 when supervisor_mode_kernel
33  *     feature is enabled. Do not use this callback type in new code.
34  */
35 #define CALLBACKTYPE_sysenter_deprecated   3
36 
37 /* x86: Callback for NMI delivery. */
38 #define CALLBACKTYPE_nmi                   4
39 
40 /*
41  * x86: sysenter is only available as follows:
42  * - 32-bit hypervisor: with the supervisor_mode_kernel feature enabled
43  * - 64-bit hypervisor: 32-bit guest applications on Intel CPUs
44  *                      ('32-on-32-on-64', '32-on-64-on-64')
45  *                      [nb. also 64-bit guest applications on Intel CPUs
46  *                           ('64-on-64-on-64'), but syscall is preferred]
47  */
48 #define CALLBACKTYPE_sysenter              5
49 
50 /*
51  * x86/64 hypervisor: Syscall by 32-bit guest app on AMD CPUs
52  *                    ('32-on-32-on-64', '32-on-64-on-64')
53  */
54 #define CALLBACKTYPE_syscall32             7
55 
56 /*
57  * Disable event deliver during callback? This flag is ignored for event and
58  * NMI callbacks: event delivery is unconditionally disabled.
59  */
60 #define _CALLBACKF_mask_events             0
61 #define CALLBACKF_mask_events              (1U << _CALLBACKF_mask_events)
62 
63 /*
64  * Register a callback.
65  */
66 #define CALLBACKOP_register                0
67 struct callback_register {
68 	uint16_t type;
69 	uint16_t flags;
70 	xen_callback_t address;
71 };
72 
73 /*
74  * Unregister a callback.
75  *
76  * Not all callbacks can be unregistered. -EINVAL will be returned if
77  * you attempt to unregister such a callback.
78  */
79 #define CALLBACKOP_unregister              1
80 struct callback_unregister {
81     uint16_t type;
82     uint16_t _unused;
83 };
84 
85 #endif /* __XEN_PUBLIC_CALLBACK_H__ */
86