xref: /linux/include/xen/hvm.h (revision 283c0972d53769ee44750cad4c27e3f5fa26ec1f)
118f19aa6SJeremy Fitzhardinge /* Simple wrappers around HVM functions */
218f19aa6SJeremy Fitzhardinge #ifndef XEN_HVM_H__
318f19aa6SJeremy Fitzhardinge #define XEN_HVM_H__
418f19aa6SJeremy Fitzhardinge 
518f19aa6SJeremy Fitzhardinge #include <xen/interface/hvm/params.h>
638e20b07SSheng Yang #include <asm/xen/hypercall.h>
718f19aa6SJeremy Fitzhardinge 
86d877e6bSKonrad Rzeszutek Wilk static const char *param_name(int op)
96d877e6bSKonrad Rzeszutek Wilk {
106d877e6bSKonrad Rzeszutek Wilk #define PARAM(x) [HVM_PARAM_##x] = #x
116d877e6bSKonrad Rzeszutek Wilk 	static const char *const names[] = {
126d877e6bSKonrad Rzeszutek Wilk 		PARAM(CALLBACK_IRQ),
136d877e6bSKonrad Rzeszutek Wilk 		PARAM(STORE_PFN),
146d877e6bSKonrad Rzeszutek Wilk 		PARAM(STORE_EVTCHN),
156d877e6bSKonrad Rzeszutek Wilk 		PARAM(PAE_ENABLED),
166d877e6bSKonrad Rzeszutek Wilk 		PARAM(IOREQ_PFN),
176d877e6bSKonrad Rzeszutek Wilk 		PARAM(BUFIOREQ_PFN),
186d877e6bSKonrad Rzeszutek Wilk 		PARAM(TIMER_MODE),
196d877e6bSKonrad Rzeszutek Wilk 		PARAM(HPET_ENABLED),
206d877e6bSKonrad Rzeszutek Wilk 		PARAM(IDENT_PT),
216d877e6bSKonrad Rzeszutek Wilk 		PARAM(DM_DOMAIN),
226d877e6bSKonrad Rzeszutek Wilk 		PARAM(ACPI_S_STATE),
236d877e6bSKonrad Rzeszutek Wilk 		PARAM(VM86_TSS),
246d877e6bSKonrad Rzeszutek Wilk 		PARAM(VPT_ALIGN),
256d877e6bSKonrad Rzeszutek Wilk 		PARAM(CONSOLE_PFN),
266d877e6bSKonrad Rzeszutek Wilk 		PARAM(CONSOLE_EVTCHN),
276d877e6bSKonrad Rzeszutek Wilk 	};
286d877e6bSKonrad Rzeszutek Wilk #undef PARAM
296d877e6bSKonrad Rzeszutek Wilk 
306d877e6bSKonrad Rzeszutek Wilk 	if (op >= ARRAY_SIZE(names))
316d877e6bSKonrad Rzeszutek Wilk 		return "unknown";
326d877e6bSKonrad Rzeszutek Wilk 
336d877e6bSKonrad Rzeszutek Wilk 	if (!names[op])
346d877e6bSKonrad Rzeszutek Wilk 		return "reserved";
356d877e6bSKonrad Rzeszutek Wilk 
366d877e6bSKonrad Rzeszutek Wilk 	return names[op];
376d877e6bSKonrad Rzeszutek Wilk }
3818f19aa6SJeremy Fitzhardinge static inline int hvm_get_parameter(int idx, uint64_t *value)
3918f19aa6SJeremy Fitzhardinge {
4018f19aa6SJeremy Fitzhardinge 	struct xen_hvm_param xhv;
4118f19aa6SJeremy Fitzhardinge 	int r;
4218f19aa6SJeremy Fitzhardinge 
4318f19aa6SJeremy Fitzhardinge 	xhv.domid = DOMID_SELF;
4418f19aa6SJeremy Fitzhardinge 	xhv.index = idx;
4518f19aa6SJeremy Fitzhardinge 	r = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv);
4618f19aa6SJeremy Fitzhardinge 	if (r < 0) {
47*283c0972SJoe Perches 		pr_err("Cannot get hvm parameter %s (%d): %d!\n",
486d877e6bSKonrad Rzeszutek Wilk 		       param_name(idx), idx, r);
4918f19aa6SJeremy Fitzhardinge 		return r;
5018f19aa6SJeremy Fitzhardinge 	}
5118f19aa6SJeremy Fitzhardinge 	*value = xhv.value;
5218f19aa6SJeremy Fitzhardinge 	return r;
5318f19aa6SJeremy Fitzhardinge }
5418f19aa6SJeremy Fitzhardinge 
5538e20b07SSheng Yang #define HVM_CALLBACK_VIA_TYPE_VECTOR 0x2
5638e20b07SSheng Yang #define HVM_CALLBACK_VIA_TYPE_SHIFT 56
5738e20b07SSheng Yang #define HVM_CALLBACK_VECTOR(x) (((uint64_t)HVM_CALLBACK_VIA_TYPE_VECTOR)<<\
5838e20b07SSheng Yang 		HVM_CALLBACK_VIA_TYPE_SHIFT | (x))
5938e20b07SSheng Yang 
6018f19aa6SJeremy Fitzhardinge #endif /* XEN_HVM_H__ */
61