posted_intr.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __KVM_X86_VMX_POSTED_INTR_H
  3. #define __KVM_X86_VMX_POSTED_INTR_H
  4. #define POSTED_INTR_ON 0
  5. #define POSTED_INTR_SN 1
  6. #define PID_TABLE_ENTRY_VALID 1
  7. /* Posted-Interrupt Descriptor */
  8. struct pi_desc {
  9. u32 pir[8]; /* Posted interrupt requested */
  10. union {
  11. struct {
  12. /* bit 256 - Outstanding Notification */
  13. u16 on : 1,
  14. /* bit 257 - Suppress Notification */
  15. sn : 1,
  16. /* bit 271:258 - Reserved */
  17. rsvd_1 : 14;
  18. /* bit 279:272 - Notification Vector */
  19. u8 nv;
  20. /* bit 287:280 - Reserved */
  21. u8 rsvd_2;
  22. /* bit 319:288 - Notification Destination */
  23. u32 ndst;
  24. };
  25. u64 control;
  26. };
  27. u32 rsvd[6];
  28. } __aligned(64);
  29. static inline bool pi_test_and_set_on(struct pi_desc *pi_desc)
  30. {
  31. return test_and_set_bit(POSTED_INTR_ON,
  32. (unsigned long *)&pi_desc->control);
  33. }
  34. static inline bool pi_test_and_clear_on(struct pi_desc *pi_desc)
  35. {
  36. return test_and_clear_bit(POSTED_INTR_ON,
  37. (unsigned long *)&pi_desc->control);
  38. }
  39. static inline bool pi_test_and_clear_sn(struct pi_desc *pi_desc)
  40. {
  41. return test_and_clear_bit(POSTED_INTR_SN,
  42. (unsigned long *)&pi_desc->control);
  43. }
  44. static inline bool pi_test_and_set_pir(int vector, struct pi_desc *pi_desc)
  45. {
  46. return test_and_set_bit(vector, (unsigned long *)pi_desc->pir);
  47. }
  48. static inline bool pi_is_pir_empty(struct pi_desc *pi_desc)
  49. {
  50. return bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS);
  51. }
  52. static inline void pi_set_sn(struct pi_desc *pi_desc)
  53. {
  54. set_bit(POSTED_INTR_SN,
  55. (unsigned long *)&pi_desc->control);
  56. }
  57. static inline void pi_set_on(struct pi_desc *pi_desc)
  58. {
  59. set_bit(POSTED_INTR_ON,
  60. (unsigned long *)&pi_desc->control);
  61. }
  62. static inline void pi_clear_on(struct pi_desc *pi_desc)
  63. {
  64. clear_bit(POSTED_INTR_ON,
  65. (unsigned long *)&pi_desc->control);
  66. }
  67. static inline void pi_clear_sn(struct pi_desc *pi_desc)
  68. {
  69. clear_bit(POSTED_INTR_SN,
  70. (unsigned long *)&pi_desc->control);
  71. }
  72. static inline bool pi_test_on(struct pi_desc *pi_desc)
  73. {
  74. return test_bit(POSTED_INTR_ON,
  75. (unsigned long *)&pi_desc->control);
  76. }
  77. static inline bool pi_test_sn(struct pi_desc *pi_desc)
  78. {
  79. return test_bit(POSTED_INTR_SN,
  80. (unsigned long *)&pi_desc->control);
  81. }
  82. void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu);
  83. void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu);
  84. void pi_wakeup_handler(void);
  85. void __init pi_init_cpu(int cpu);
  86. bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu);
  87. int vmx_pi_update_irte(struct kvm *kvm, unsigned int host_irq,
  88. uint32_t guest_irq, bool set);
  89. void vmx_pi_start_assignment(struct kvm *kvm);
  90. #endif /* __KVM_X86_VMX_POSTED_INTR_H */