hvm.h 1.3 KB

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