1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __KVM_X86_VMX_POSTED_INTR_H
3 #define __KVM_X86_VMX_POSTED_INTR_H
5 #define POSTED_INTR_ON 0
6 #define POSTED_INTR_SN 1
8 /* Posted-Interrupt Descriptor */
10 u32 pir[8]; /* Posted interrupt requested */
13 /* bit 256 - Outstanding Notification */
15 /* bit 257 - Suppress Notification */
17 /* bit 271:258 - Reserved */
19 /* bit 279:272 - Notification Vector */
21 /* bit 287:280 - Reserved */
23 /* bit 319:288 - Notification Destination */
31 static inline bool pi_test_and_set_on(struct pi_desc *pi_desc)
33 return test_and_set_bit(POSTED_INTR_ON,
34 (unsigned long *)&pi_desc->control);
37 static inline bool pi_test_and_clear_on(struct pi_desc *pi_desc)
39 return test_and_clear_bit(POSTED_INTR_ON,
40 (unsigned long *)&pi_desc->control);
43 static inline int pi_test_and_set_pir(int vector, struct pi_desc *pi_desc)
45 return test_and_set_bit(vector, (unsigned long *)pi_desc->pir);
48 static inline bool pi_is_pir_empty(struct pi_desc *pi_desc)
50 return bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS);
53 static inline void pi_set_sn(struct pi_desc *pi_desc)
55 set_bit(POSTED_INTR_SN,
56 (unsigned long *)&pi_desc->control);
59 static inline void pi_set_on(struct pi_desc *pi_desc)
61 set_bit(POSTED_INTR_ON,
62 (unsigned long *)&pi_desc->control);
65 static inline void pi_clear_on(struct pi_desc *pi_desc)
67 clear_bit(POSTED_INTR_ON,
68 (unsigned long *)&pi_desc->control);
71 static inline void pi_clear_sn(struct pi_desc *pi_desc)
73 clear_bit(POSTED_INTR_SN,
74 (unsigned long *)&pi_desc->control);
77 static inline int pi_test_on(struct pi_desc *pi_desc)
79 return test_bit(POSTED_INTR_ON,
80 (unsigned long *)&pi_desc->control);
83 static inline int pi_test_sn(struct pi_desc *pi_desc)
85 return test_bit(POSTED_INTR_SN,
86 (unsigned long *)&pi_desc->control);
89 void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu);
90 void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu);
91 int pi_pre_block(struct kvm_vcpu *vcpu);
92 void pi_post_block(struct kvm_vcpu *vcpu);
93 void pi_wakeup_handler(void);
94 void __init pi_init_cpu(int cpu);
95 bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu);
96 int pi_update_irte(struct kvm *kvm, unsigned int host_irq, uint32_t guest_irq,
98 void vmx_pi_start_assignment(struct kvm *kvm);
100 #endif /* __KVM_X86_VMX_POSTED_INTR_H */