^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * callback.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Register guest OS callbacks with Xen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Permission is hereby granted, free of charge, to any person obtaining a copy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * of this software and associated documentation files (the "Software"), to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * deal in the Software without restriction, including without limitation the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * sell copies of the Software, and to permit persons to whom the Software is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * furnished to do so, subject to the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * The above copyright notice and this permission notice shall be included in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * all copies or substantial portions of the Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * DEALINGS IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * Copyright (c) 2006, Ian Campbell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #ifndef __XEN_PUBLIC_CALLBACK_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define __XEN_PUBLIC_CALLBACK_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <xen/interface/xen.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * Prototype for this hypercall is:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * long callback_op(int cmd, void *extra_args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * @cmd == CALLBACKOP_??? (callback operation).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * @extra_args == Operation-specific extra arguments (NULL if none).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* x86: Callback for event delivery. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define CALLBACKTYPE_event 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* x86: Failsafe callback when guest state cannot be restored by Xen. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define CALLBACKTYPE_failsafe 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* x86/64 hypervisor: Syscall by 64-bit guest app ('64-on-64-on-64'). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define CALLBACKTYPE_syscall 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * x86/32 hypervisor: Only available on x86/32 when supervisor_mode_kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * feature is enabled. Do not use this callback type in new code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define CALLBACKTYPE_sysenter_deprecated 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /* x86: Callback for NMI delivery. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define CALLBACKTYPE_nmi 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * x86: sysenter is only available as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * - 32-bit hypervisor: with the supervisor_mode_kernel feature enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * - 64-bit hypervisor: 32-bit guest applications on Intel CPUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * ('32-on-32-on-64', '32-on-64-on-64')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * [nb. also 64-bit guest applications on Intel CPUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * ('64-on-64-on-64'), but syscall is preferred]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define CALLBACKTYPE_sysenter 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * x86/64 hypervisor: Syscall by 32-bit guest app on AMD CPUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * ('32-on-32-on-64', '32-on-64-on-64')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define CALLBACKTYPE_syscall32 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * Disable event deliver during callback? This flag is ignored for event and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * NMI callbacks: event delivery is unconditionally disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define _CALLBACKF_mask_events 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define CALLBACKF_mask_events (1U << _CALLBACKF_mask_events)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * Register a callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define CALLBACKOP_register 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct callback_register {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) uint16_t type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) uint16_t flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) xen_callback_t address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * Unregister a callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * Not all callbacks can be unregistered. -EINVAL will be returned if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * you attempt to unregister such a callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define CALLBACKOP_unregister 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct callback_unregister {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) uint16_t type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) uint16_t _unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #endif /* __XEN_PUBLIC_CALLBACK_H__ */