| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ | 
|  | 2 | /* Simple wrappers around HVM functions */ | 
|  | 3 | #ifndef XEN_HVM_H__ | 
|  | 4 | #define XEN_HVM_H__ | 
|  | 5 |  | 
|  | 6 | #include <xen/interface/hvm/params.h> | 
|  | 7 | #include <asm/xen/hypercall.h> | 
|  | 8 |  | 
|  | 9 | static const char *param_name(int op) | 
|  | 10 | { | 
|  | 11 | #define PARAM(x) [HVM_PARAM_##x] = #x | 
|  | 12 | static const char *const names[] = { | 
|  | 13 | PARAM(CALLBACK_IRQ), | 
|  | 14 | PARAM(STORE_PFN), | 
|  | 15 | PARAM(STORE_EVTCHN), | 
|  | 16 | PARAM(PAE_ENABLED), | 
|  | 17 | PARAM(IOREQ_PFN), | 
|  | 18 | PARAM(BUFIOREQ_PFN), | 
|  | 19 | PARAM(TIMER_MODE), | 
|  | 20 | PARAM(HPET_ENABLED), | 
|  | 21 | PARAM(IDENT_PT), | 
|  | 22 | PARAM(DM_DOMAIN), | 
|  | 23 | PARAM(ACPI_S_STATE), | 
|  | 24 | PARAM(VM86_TSS), | 
|  | 25 | PARAM(VPT_ALIGN), | 
|  | 26 | PARAM(CONSOLE_PFN), | 
|  | 27 | PARAM(CONSOLE_EVTCHN), | 
|  | 28 | }; | 
|  | 29 | #undef PARAM | 
|  | 30 |  | 
|  | 31 | if (op >= ARRAY_SIZE(names)) | 
|  | 32 | return "unknown"; | 
|  | 33 |  | 
|  | 34 | if (!names[op]) | 
|  | 35 | return "reserved"; | 
|  | 36 |  | 
|  | 37 | return names[op]; | 
|  | 38 | } | 
|  | 39 | static inline int hvm_get_parameter(int idx, uint64_t *value) | 
|  | 40 | { | 
|  | 41 | struct xen_hvm_param xhv; | 
|  | 42 | int r; | 
|  | 43 |  | 
|  | 44 | xhv.domid = DOMID_SELF; | 
|  | 45 | xhv.index = idx; | 
|  | 46 | r = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv); | 
|  | 47 | if (r < 0) { | 
|  | 48 | pr_err("Cannot get hvm parameter %s (%d): %d!\n", | 
|  | 49 | param_name(idx), idx, r); | 
|  | 50 | return r; | 
|  | 51 | } | 
|  | 52 | *value = xhv.value; | 
|  | 53 | return r; | 
|  | 54 | } | 
|  | 55 |  | 
|  | 56 | #define HVM_CALLBACK_VIA_TYPE_VECTOR 0x2 | 
|  | 57 | #define HVM_CALLBACK_VIA_TYPE_SHIFT 56 | 
|  | 58 | #define HVM_CALLBACK_VECTOR(x) (((uint64_t)HVM_CALLBACK_VIA_TYPE_VECTOR)<<\ | 
|  | 59 | HVM_CALLBACK_VIA_TYPE_SHIFT | (x)) | 
|  | 60 |  | 
|  | 61 | #endif /* XEN_HVM_H__ */ |