162306a36Sopenharmony_ci/* SPDX-License-Identifier: MIT */ 262306a36Sopenharmony_ci/****************************************************************************** 362306a36Sopenharmony_ci * callback.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Register guest OS callbacks with Xen. 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (c) 2006, Ian Campbell 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef __XEN_PUBLIC_CALLBACK_H__ 1162306a36Sopenharmony_ci#define __XEN_PUBLIC_CALLBACK_H__ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <xen/interface/xen.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* 1662306a36Sopenharmony_ci * Prototype for this hypercall is: 1762306a36Sopenharmony_ci * long callback_op(int cmd, void *extra_args) 1862306a36Sopenharmony_ci * @cmd == CALLBACKOP_??? (callback operation). 1962306a36Sopenharmony_ci * @extra_args == Operation-specific extra arguments (NULL if none). 2062306a36Sopenharmony_ci */ 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci/* x86: Callback for event delivery. */ 2362306a36Sopenharmony_ci#define CALLBACKTYPE_event 0 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci/* x86: Failsafe callback when guest state cannot be restored by Xen. */ 2662306a36Sopenharmony_ci#define CALLBACKTYPE_failsafe 1 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci/* x86/64 hypervisor: Syscall by 64-bit guest app ('64-on-64-on-64'). */ 2962306a36Sopenharmony_ci#define CALLBACKTYPE_syscall 2 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci/* 3262306a36Sopenharmony_ci * x86/32 hypervisor: Only available on x86/32 when supervisor_mode_kernel 3362306a36Sopenharmony_ci * feature is enabled. Do not use this callback type in new code. 3462306a36Sopenharmony_ci */ 3562306a36Sopenharmony_ci#define CALLBACKTYPE_sysenter_deprecated 3 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci/* x86: Callback for NMI delivery. */ 3862306a36Sopenharmony_ci#define CALLBACKTYPE_nmi 4 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci/* 4162306a36Sopenharmony_ci * x86: sysenter is only available as follows: 4262306a36Sopenharmony_ci * - 32-bit hypervisor: with the supervisor_mode_kernel feature enabled 4362306a36Sopenharmony_ci * - 64-bit hypervisor: 32-bit guest applications on Intel CPUs 4462306a36Sopenharmony_ci * ('32-on-32-on-64', '32-on-64-on-64') 4562306a36Sopenharmony_ci * [nb. also 64-bit guest applications on Intel CPUs 4662306a36Sopenharmony_ci * ('64-on-64-on-64'), but syscall is preferred] 4762306a36Sopenharmony_ci */ 4862306a36Sopenharmony_ci#define CALLBACKTYPE_sysenter 5 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci/* 5162306a36Sopenharmony_ci * x86/64 hypervisor: Syscall by 32-bit guest app on AMD CPUs 5262306a36Sopenharmony_ci * ('32-on-32-on-64', '32-on-64-on-64') 5362306a36Sopenharmony_ci */ 5462306a36Sopenharmony_ci#define CALLBACKTYPE_syscall32 7 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci/* 5762306a36Sopenharmony_ci * Disable event deliver during callback? This flag is ignored for event and 5862306a36Sopenharmony_ci * NMI callbacks: event delivery is unconditionally disabled. 5962306a36Sopenharmony_ci */ 6062306a36Sopenharmony_ci#define _CALLBACKF_mask_events 0 6162306a36Sopenharmony_ci#define CALLBACKF_mask_events (1U << _CALLBACKF_mask_events) 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci/* 6462306a36Sopenharmony_ci * Register a callback. 6562306a36Sopenharmony_ci */ 6662306a36Sopenharmony_ci#define CALLBACKOP_register 0 6762306a36Sopenharmony_cistruct callback_register { 6862306a36Sopenharmony_ci uint16_t type; 6962306a36Sopenharmony_ci uint16_t flags; 7062306a36Sopenharmony_ci xen_callback_t address; 7162306a36Sopenharmony_ci}; 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci/* 7462306a36Sopenharmony_ci * Unregister a callback. 7562306a36Sopenharmony_ci * 7662306a36Sopenharmony_ci * Not all callbacks can be unregistered. -EINVAL will be returned if 7762306a36Sopenharmony_ci * you attempt to unregister such a callback. 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ci#define CALLBACKOP_unregister 1 8062306a36Sopenharmony_cistruct callback_unregister { 8162306a36Sopenharmony_ci uint16_t type; 8262306a36Sopenharmony_ci uint16_t _unused; 8362306a36Sopenharmony_ci}; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci#endif /* __XEN_PUBLIC_CALLBACK_H__ */ 86