0001
0002 #ifndef __KVM_X86_VMX_POSTED_INTR_H
0003 #define __KVM_X86_VMX_POSTED_INTR_H
0004
0005 #define POSTED_INTR_ON 0
0006 #define POSTED_INTR_SN 1
0007
0008 #define PID_TABLE_ENTRY_VALID 1
0009
0010
0011 struct pi_desc {
0012 u32 pir[8];
0013 union {
0014 struct {
0015
0016 u16 on : 1,
0017
0018 sn : 1,
0019
0020 rsvd_1 : 14;
0021
0022 u8 nv;
0023
0024 u8 rsvd_2;
0025
0026 u32 ndst;
0027 };
0028 u64 control;
0029 };
0030 u32 rsvd[6];
0031 } __aligned(64);
0032
0033 static inline bool pi_test_and_set_on(struct pi_desc *pi_desc)
0034 {
0035 return test_and_set_bit(POSTED_INTR_ON,
0036 (unsigned long *)&pi_desc->control);
0037 }
0038
0039 static inline bool pi_test_and_clear_on(struct pi_desc *pi_desc)
0040 {
0041 return test_and_clear_bit(POSTED_INTR_ON,
0042 (unsigned long *)&pi_desc->control);
0043 }
0044
0045 static inline bool pi_test_and_clear_sn(struct pi_desc *pi_desc)
0046 {
0047 return test_and_clear_bit(POSTED_INTR_SN,
0048 (unsigned long *)&pi_desc->control);
0049 }
0050
0051 static inline bool pi_test_and_set_pir(int vector, struct pi_desc *pi_desc)
0052 {
0053 return test_and_set_bit(vector, (unsigned long *)pi_desc->pir);
0054 }
0055
0056 static inline bool pi_is_pir_empty(struct pi_desc *pi_desc)
0057 {
0058 return bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS);
0059 }
0060
0061 static inline void pi_set_sn(struct pi_desc *pi_desc)
0062 {
0063 set_bit(POSTED_INTR_SN,
0064 (unsigned long *)&pi_desc->control);
0065 }
0066
0067 static inline void pi_set_on(struct pi_desc *pi_desc)
0068 {
0069 set_bit(POSTED_INTR_ON,
0070 (unsigned long *)&pi_desc->control);
0071 }
0072
0073 static inline void pi_clear_on(struct pi_desc *pi_desc)
0074 {
0075 clear_bit(POSTED_INTR_ON,
0076 (unsigned long *)&pi_desc->control);
0077 }
0078
0079 static inline void pi_clear_sn(struct pi_desc *pi_desc)
0080 {
0081 clear_bit(POSTED_INTR_SN,
0082 (unsigned long *)&pi_desc->control);
0083 }
0084
0085 static inline bool pi_test_on(struct pi_desc *pi_desc)
0086 {
0087 return test_bit(POSTED_INTR_ON,
0088 (unsigned long *)&pi_desc->control);
0089 }
0090
0091 static inline bool pi_test_sn(struct pi_desc *pi_desc)
0092 {
0093 return test_bit(POSTED_INTR_SN,
0094 (unsigned long *)&pi_desc->control);
0095 }
0096
0097 void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu);
0098 void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu);
0099 void pi_wakeup_handler(void);
0100 void __init pi_init_cpu(int cpu);
0101 bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu);
0102 int vmx_pi_update_irte(struct kvm *kvm, unsigned int host_irq,
0103 uint32_t guest_irq, bool set);
0104 void vmx_pi_start_assignment(struct kvm *kvm);
0105
0106 #endif