Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 2 | /* Simple wrappers around HVM functions */ |
| 3 | #ifndef XEN_HVM_H__ |
| 4 | #define XEN_HVM_H__ |
| 5 | |
| 6 | #include <xen/interface/hvm/params.h> |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 7 | #include <asm/xen/hypercall.h> |
Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 8 | |
Konrad Rzeszutek Wilk | 6d877e6 | 2012-10-19 15:01:46 -0400 | [diff] [blame] | 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 | } |
Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 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) { |
Joe Perches | 283c097 | 2013-06-28 03:21:41 -0700 | [diff] [blame] | 48 | pr_err("Cannot get hvm parameter %s (%d): %d!\n", |
| 49 | param_name(idx), idx, r); |
Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 50 | return r; |
| 51 | } |
| 52 | *value = xhv.value; |
| 53 | return r; |
| 54 | } |
| 55 | |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 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 | |
Jeremy Fitzhardinge | 18f19aa | 2010-05-14 12:38:24 +0100 | [diff] [blame] | 61 | #endif /* XEN_HVM_H__ */ |