hvm.h 1.3 KB

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