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