xref: /onnv-gate/usr/src/uts/common/xen/public/callback.h (revision 10175:dd9708d1f561)
15084Sjohnlev /******************************************************************************
25084Sjohnlev  * callback.h
35084Sjohnlev  *
45084Sjohnlev  * Register guest OS callbacks with Xen.
55084Sjohnlev  *
65084Sjohnlev  * Permission is hereby granted, free of charge, to any person obtaining a copy
75084Sjohnlev  * of this software and associated documentation files (the "Software"), to
85084Sjohnlev  * deal in the Software without restriction, including without limitation the
95084Sjohnlev  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
105084Sjohnlev  * sell copies of the Software, and to permit persons to whom the Software is
115084Sjohnlev  * furnished to do so, subject to the following conditions:
125084Sjohnlev  *
135084Sjohnlev  * The above copyright notice and this permission notice shall be included in
145084Sjohnlev  * all copies or substantial portions of the Software.
155084Sjohnlev  *
165084Sjohnlev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
175084Sjohnlev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
185084Sjohnlev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
195084Sjohnlev  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
205084Sjohnlev  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
215084Sjohnlev  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
225084Sjohnlev  * DEALINGS IN THE SOFTWARE.
235084Sjohnlev  *
245084Sjohnlev  * Copyright (c) 2006, Ian Campbell
255084Sjohnlev  */
265084Sjohnlev 
275084Sjohnlev #ifndef __XEN_PUBLIC_CALLBACK_H__
285084Sjohnlev #define __XEN_PUBLIC_CALLBACK_H__
295084Sjohnlev 
305084Sjohnlev #include "xen.h"
315084Sjohnlev 
325084Sjohnlev /*
335084Sjohnlev  * Prototype for this hypercall is:
345084Sjohnlev  *   long callback_op(int cmd, void *extra_args)
355084Sjohnlev  * @cmd        == CALLBACKOP_??? (callback operation).
365084Sjohnlev  * @extra_args == Operation-specific extra arguments (NULL if none).
375084Sjohnlev  */
385084Sjohnlev 
39*10175SStuart.Maybee@Sun.COM /* ia64, x86: Callback for event delivery. */
405084Sjohnlev #define CALLBACKTYPE_event                 0
41*10175SStuart.Maybee@Sun.COM 
42*10175SStuart.Maybee@Sun.COM /* x86: Failsafe callback when guest state cannot be restored by Xen. */
435084Sjohnlev #define CALLBACKTYPE_failsafe              1
44*10175SStuart.Maybee@Sun.COM 
45*10175SStuart.Maybee@Sun.COM /* x86/64 hypervisor: Syscall by 64-bit guest app ('64-on-64-on-64'). */
46*10175SStuart.Maybee@Sun.COM #define CALLBACKTYPE_syscall               2
47*10175SStuart.Maybee@Sun.COM 
485084Sjohnlev /*
49*10175SStuart.Maybee@Sun.COM  * x86/32 hypervisor: Only available on x86/32 when supervisor_mode_kernel
50*10175SStuart.Maybee@Sun.COM  *     feature is enabled. Do not use this callback type in new code.
515084Sjohnlev  */
52*10175SStuart.Maybee@Sun.COM #define CALLBACKTYPE_sysenter_deprecated   3
53*10175SStuart.Maybee@Sun.COM 
54*10175SStuart.Maybee@Sun.COM /* x86: Callback for NMI delivery. */
555084Sjohnlev #define CALLBACKTYPE_nmi                   4
565084Sjohnlev 
575084Sjohnlev /*
58*10175SStuart.Maybee@Sun.COM  * x86: sysenter is only available as follows:
59*10175SStuart.Maybee@Sun.COM  * - 32-bit hypervisor: with the supervisor_mode_kernel feature enabled
60*10175SStuart.Maybee@Sun.COM  * - 64-bit hypervisor: 32-bit guest applications on Intel CPUs
61*10175SStuart.Maybee@Sun.COM  *                      ('32-on-32-on-64', '32-on-64-on-64')
62*10175SStuart.Maybee@Sun.COM  *                      [nb. also 64-bit guest applications on Intel CPUs
63*10175SStuart.Maybee@Sun.COM  *                           ('64-on-64-on-64'), but syscall is preferred]
64*10175SStuart.Maybee@Sun.COM  */
65*10175SStuart.Maybee@Sun.COM #define CALLBACKTYPE_sysenter              5
66*10175SStuart.Maybee@Sun.COM 
67*10175SStuart.Maybee@Sun.COM /*
68*10175SStuart.Maybee@Sun.COM  * x86/64 hypervisor: Syscall by 32-bit guest app on AMD CPUs
69*10175SStuart.Maybee@Sun.COM  *                    ('32-on-32-on-64', '32-on-64-on-64')
70*10175SStuart.Maybee@Sun.COM  */
71*10175SStuart.Maybee@Sun.COM #define CALLBACKTYPE_syscall32             7
72*10175SStuart.Maybee@Sun.COM 
73*10175SStuart.Maybee@Sun.COM /*
745084Sjohnlev  * Disable event deliver during callback? This flag is ignored for event and
755084Sjohnlev  * NMI callbacks: event delivery is unconditionally disabled.
765084Sjohnlev  */
775084Sjohnlev #define _CALLBACKF_mask_events             0
785084Sjohnlev #define CALLBACKF_mask_events              (1U << _CALLBACKF_mask_events)
795084Sjohnlev 
805084Sjohnlev /*
815084Sjohnlev  * Register a callback.
825084Sjohnlev  */
835084Sjohnlev #define CALLBACKOP_register                0
845084Sjohnlev struct callback_register {
855084Sjohnlev     uint16_t type;
865084Sjohnlev     uint16_t flags;
875084Sjohnlev     xen_callback_t address;
885084Sjohnlev };
895084Sjohnlev typedef struct callback_register callback_register_t;
905084Sjohnlev DEFINE_XEN_GUEST_HANDLE(callback_register_t);
915084Sjohnlev 
925084Sjohnlev /*
935084Sjohnlev  * Unregister a callback.
945084Sjohnlev  *
955084Sjohnlev  * Not all callbacks can be unregistered. -EINVAL will be returned if
965084Sjohnlev  * you attempt to unregister such a callback.
975084Sjohnlev  */
985084Sjohnlev #define CALLBACKOP_unregister              1
995084Sjohnlev struct callback_unregister {
1005084Sjohnlev     uint16_t type;
1015084Sjohnlev     uint16_t _unused;
1025084Sjohnlev };
1035084Sjohnlev typedef struct callback_unregister callback_unregister_t;
1045084Sjohnlev DEFINE_XEN_GUEST_HANDLE(callback_unregister_t);
1055084Sjohnlev 
106*10175SStuart.Maybee@Sun.COM #if __XEN_INTERFACE_VERSION__ < 0x00030207
107*10175SStuart.Maybee@Sun.COM #undef CALLBACKTYPE_sysenter
108*10175SStuart.Maybee@Sun.COM #define CALLBACKTYPE_sysenter CALLBACKTYPE_sysenter_deprecated
109*10175SStuart.Maybee@Sun.COM #endif
110*10175SStuart.Maybee@Sun.COM 
1115084Sjohnlev #endif /* __XEN_PUBLIC_CALLBACK_H__ */
1125084Sjohnlev 
1135084Sjohnlev /*
1145084Sjohnlev  * Local variables:
1155084Sjohnlev  * mode: C
1165084Sjohnlev  * c-set-style: "BSD"
1175084Sjohnlev  * c-basic-offset: 4
1185084Sjohnlev  * tab-width: 4
1195084Sjohnlev  * indent-tabs-mode: nil
1205084Sjohnlev  * End:
1215084Sjohnlev  */
122