1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 218f19aa6SJeremy Fitzhardinge /* Simple wrappers around HVM functions */ 318f19aa6SJeremy Fitzhardinge #ifndef XEN_HVM_H__ 418f19aa6SJeremy Fitzhardinge #define XEN_HVM_H__ 518f19aa6SJeremy Fitzhardinge 618f19aa6SJeremy Fitzhardinge #include <xen/interface/hvm/params.h> 738e20b07SSheng Yang #include <asm/xen/hypercall.h> 818f19aa6SJeremy Fitzhardinge 96d877e6bSKonrad Rzeszutek Wilk static const char *param_name(int op) 106d877e6bSKonrad Rzeszutek Wilk { 116d877e6bSKonrad Rzeszutek Wilk #define PARAM(x) [HVM_PARAM_##x] = #x 126d877e6bSKonrad Rzeszutek Wilk static const char *const names[] = { 136d877e6bSKonrad Rzeszutek Wilk PARAM(CALLBACK_IRQ), 146d877e6bSKonrad Rzeszutek Wilk PARAM(STORE_PFN), 156d877e6bSKonrad Rzeszutek Wilk PARAM(STORE_EVTCHN), 166d877e6bSKonrad Rzeszutek Wilk PARAM(PAE_ENABLED), 176d877e6bSKonrad Rzeszutek Wilk PARAM(IOREQ_PFN), 186d877e6bSKonrad Rzeszutek Wilk PARAM(BUFIOREQ_PFN), 196d877e6bSKonrad Rzeszutek Wilk PARAM(TIMER_MODE), 206d877e6bSKonrad Rzeszutek Wilk PARAM(HPET_ENABLED), 216d877e6bSKonrad Rzeszutek Wilk PARAM(IDENT_PT), 226d877e6bSKonrad Rzeszutek Wilk PARAM(DM_DOMAIN), 236d877e6bSKonrad Rzeszutek Wilk PARAM(ACPI_S_STATE), 246d877e6bSKonrad Rzeszutek Wilk PARAM(VM86_TSS), 256d877e6bSKonrad Rzeszutek Wilk PARAM(VPT_ALIGN), 266d877e6bSKonrad Rzeszutek Wilk PARAM(CONSOLE_PFN), 276d877e6bSKonrad Rzeszutek Wilk PARAM(CONSOLE_EVTCHN), 286d877e6bSKonrad Rzeszutek Wilk }; 296d877e6bSKonrad Rzeszutek Wilk #undef PARAM 306d877e6bSKonrad Rzeszutek Wilk 316d877e6bSKonrad Rzeszutek Wilk if (op >= ARRAY_SIZE(names)) 326d877e6bSKonrad Rzeszutek Wilk return "unknown"; 336d877e6bSKonrad Rzeszutek Wilk 346d877e6bSKonrad Rzeszutek Wilk if (!names[op]) 356d877e6bSKonrad Rzeszutek Wilk return "reserved"; 366d877e6bSKonrad Rzeszutek Wilk 376d877e6bSKonrad Rzeszutek Wilk return names[op]; 386d877e6bSKonrad Rzeszutek Wilk } 3918f19aa6SJeremy Fitzhardinge static inline int hvm_get_parameter(int idx, uint64_t *value) 4018f19aa6SJeremy Fitzhardinge { 4118f19aa6SJeremy Fitzhardinge struct xen_hvm_param xhv; 4218f19aa6SJeremy Fitzhardinge int r; 4318f19aa6SJeremy Fitzhardinge 4418f19aa6SJeremy Fitzhardinge xhv.domid = DOMID_SELF; 4518f19aa6SJeremy Fitzhardinge xhv.index = idx; 4618f19aa6SJeremy Fitzhardinge r = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv); 4718f19aa6SJeremy Fitzhardinge if (r < 0) { 48283c0972SJoe Perches pr_err("Cannot get hvm parameter %s (%d): %d!\n", 496d877e6bSKonrad Rzeszutek Wilk param_name(idx), idx, r); 5018f19aa6SJeremy Fitzhardinge return r; 5118f19aa6SJeremy Fitzhardinge } 5218f19aa6SJeremy Fitzhardinge *value = xhv.value; 5318f19aa6SJeremy Fitzhardinge return r; 5418f19aa6SJeremy Fitzhardinge } 5518f19aa6SJeremy Fitzhardinge 5638e20b07SSheng Yang #define HVM_CALLBACK_VIA_TYPE_VECTOR 0x2 5738e20b07SSheng Yang #define HVM_CALLBACK_VIA_TYPE_SHIFT 56 5838e20b07SSheng Yang #define HVM_CALLBACK_VECTOR(x) (((uint64_t)HVM_CALLBACK_VIA_TYPE_VECTOR)<<\ 5938e20b07SSheng Yang HVM_CALLBACK_VIA_TYPE_SHIFT | (x)) 6038e20b07SSheng Yang 61998c2034SVitaly Kuznetsov void xen_setup_callback_vector(void); 62998c2034SVitaly Kuznetsov 63*b1c3497eSJane Malalane int xen_set_upcall_vector(unsigned int cpu); 64*b1c3497eSJane Malalane 6518f19aa6SJeremy Fitzhardinge #endif /* XEN_HVM_H__ */ 66