1 /* SPDX-License-Identifier: GPL-2.0-only */ 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 2 /* 3 * Copyright (C) 2016,2017 ARM Limited, All Ri 3 * Copyright (C) 2016,2017 ARM Limited, All Rights Reserved. 4 * Author: Marc Zyngier <marc.zyngier@arm.com> 4 * Author: Marc Zyngier <marc.zyngier@arm.com> 5 */ 5 */ 6 6 7 #ifndef __LINUX_IRQCHIP_ARM_GIC_V4_H 7 #ifndef __LINUX_IRQCHIP_ARM_GIC_V4_H 8 #define __LINUX_IRQCHIP_ARM_GIC_V4_H 8 #define __LINUX_IRQCHIP_ARM_GIC_V4_H 9 9 10 struct its_vpe; 10 struct its_vpe; 11 11 12 /* 12 /* 13 * Maximum number of ITTs when GITS_TYPER.VMOV 13 * Maximum number of ITTs when GITS_TYPER.VMOVP == 0, using the 14 * ITSList mechanism to perform inter-ITS sync 14 * ITSList mechanism to perform inter-ITS synchronization. 15 */ 15 */ 16 #define GICv4_ITS_LIST_MAX 16 16 #define GICv4_ITS_LIST_MAX 16 17 17 18 /* Embedded in kvm.arch */ 18 /* Embedded in kvm.arch */ 19 struct its_vm { 19 struct its_vm { 20 struct fwnode_handle *fwnode; 20 struct fwnode_handle *fwnode; 21 struct irq_domain *domain; 21 struct irq_domain *domain; 22 struct page *vprop_page; 22 struct page *vprop_page; 23 struct its_vpe **vpes; 23 struct its_vpe **vpes; 24 int nr_vpes; 24 int nr_vpes; 25 irq_hw_number_t db_lpi_base; 25 irq_hw_number_t db_lpi_base; 26 unsigned long *db_bitmap; 26 unsigned long *db_bitmap; 27 int nr_db_lpis; 27 int nr_db_lpis; 28 /* << 29 * Ensures mutual exclusion between up << 30 * and map/unmap when using the ITSLis << 31 * << 32 * The lock order for any sequence inv << 33 * vmapp_lock -> vpe_lock ->vmovp_lock << 34 */ << 35 raw_spinlock_t vmapp_lock; << 36 u32 vlpi_count[GIC 28 u32 vlpi_count[GICv4_ITS_LIST_MAX]; 37 }; 29 }; 38 30 39 /* Embedded in kvm_vcpu.arch */ 31 /* Embedded in kvm_vcpu.arch */ 40 struct its_vpe { 32 struct its_vpe { 41 struct page *vpt_page; 33 struct page *vpt_page; 42 struct its_vm *its_vm; 34 struct its_vm *its_vm; 43 /* per-vPE VLPI tracking */ 35 /* per-vPE VLPI tracking */ 44 atomic_t vlpi_count; 36 atomic_t vlpi_count; 45 /* Doorbell interrupt */ 37 /* Doorbell interrupt */ 46 int irq; 38 int irq; 47 irq_hw_number_t vpe_db_lpi; 39 irq_hw_number_t vpe_db_lpi; 48 /* VPE resident */ 40 /* VPE resident */ 49 bool resident; 41 bool resident; 50 /* VPT parse complete */ 42 /* VPT parse complete */ 51 bool ready; 43 bool ready; 52 union { 44 union { 53 /* GICv4.0 implementations */ 45 /* GICv4.0 implementations */ 54 struct { 46 struct { 55 /* VPE proxy mapping * 47 /* VPE proxy mapping */ 56 int vpe_proxy_even 48 int vpe_proxy_event; 57 /* Implementation Defi 49 /* Implementation Defined Area Invalid */ 58 bool idai; 50 bool idai; 59 }; 51 }; 60 /* GICv4.1 implementations */ 52 /* GICv4.1 implementations */ 61 struct { 53 struct { 62 struct fwnode_handle 54 struct fwnode_handle *fwnode; 63 struct irq_domain 55 struct irq_domain *sgi_domain; 64 struct { 56 struct { 65 u8 priori 57 u8 priority; 66 bool enable 58 bool enabled; 67 bool group; 59 bool group; 68 } 60 } sgi_config[16]; 69 }; 61 }; 70 }; 62 }; 71 63 72 /* Track the VPE being mapped */ 64 /* Track the VPE being mapped */ 73 atomic_t vmapp_count; 65 atomic_t vmapp_count; 74 66 75 /* 67 /* 76 * Ensures mutual exclusion between af 68 * Ensures mutual exclusion between affinity setting of the 77 * vPE and vLPI operations using vpe-> 69 * vPE and vLPI operations using vpe->col_idx. 78 */ 70 */ 79 raw_spinlock_t vpe_lock; 71 raw_spinlock_t vpe_lock; 80 /* 72 /* 81 * This collection ID is used to indir 73 * This collection ID is used to indirect the target 82 * redistributor for this VPE. The ID 74 * redistributor for this VPE. The ID itself isn't involved in 83 * programming of the ITS. 75 * programming of the ITS. 84 */ 76 */ 85 u16 col_idx; 77 u16 col_idx; 86 /* Unique (system-wide) VPE identifier 78 /* Unique (system-wide) VPE identifier */ 87 u16 vpe_id; 79 u16 vpe_id; 88 /* Pending VLPIs on schedule out? */ 80 /* Pending VLPIs on schedule out? */ 89 bool pending_last; 81 bool pending_last; 90 }; 82 }; 91 83 92 /* 84 /* 93 * struct its_vlpi_map: structure describing t 85 * struct its_vlpi_map: structure describing the mapping of a 94 * VLPI. Only to be interpreted in the context 86 * VLPI. Only to be interpreted in the context of a physical interrupt 95 * it complements. To be used as the vcpu_inf 87 * it complements. To be used as the vcpu_info passed to 96 * irq_set_vcpu_affinity(). 88 * irq_set_vcpu_affinity(). 97 * 89 * 98 * @vm: Pointer to the GICv4 notion of 90 * @vm: Pointer to the GICv4 notion of a VM 99 * @vpe: Pointer to the GICv4 notion of 91 * @vpe: Pointer to the GICv4 notion of a virtual CPU (VPE) 100 * @vintid: Virtual LPI number 92 * @vintid: Virtual LPI number 101 * @properties: Priority and enable bits (as w 93 * @properties: Priority and enable bits (as written in the prop table) 102 * @db_enabled: Is the VPE doorbell to be gene 94 * @db_enabled: Is the VPE doorbell to be generated? 103 */ 95 */ 104 struct its_vlpi_map { 96 struct its_vlpi_map { 105 struct its_vm *vm; 97 struct its_vm *vm; 106 struct its_vpe *vpe; 98 struct its_vpe *vpe; 107 u32 vintid; 99 u32 vintid; 108 u8 properties; 100 u8 properties; 109 bool db_enabled; 101 bool db_enabled; 110 }; 102 }; 111 103 112 enum its_vcpu_info_cmd_type { 104 enum its_vcpu_info_cmd_type { 113 MAP_VLPI, 105 MAP_VLPI, 114 GET_VLPI, 106 GET_VLPI, 115 PROP_UPDATE_VLPI, 107 PROP_UPDATE_VLPI, 116 PROP_UPDATE_AND_INV_VLPI, 108 PROP_UPDATE_AND_INV_VLPI, 117 SCHEDULE_VPE, 109 SCHEDULE_VPE, 118 DESCHEDULE_VPE, 110 DESCHEDULE_VPE, 119 COMMIT_VPE, 111 COMMIT_VPE, 120 INVALL_VPE, 112 INVALL_VPE, 121 PROP_UPDATE_VSGI, 113 PROP_UPDATE_VSGI, 122 }; 114 }; 123 115 124 struct its_cmd_info { 116 struct its_cmd_info { 125 enum its_vcpu_info_cmd_type cmd_ty 117 enum its_vcpu_info_cmd_type cmd_type; 126 union { 118 union { 127 struct its_vlpi_map *map; 119 struct its_vlpi_map *map; 128 u8 config 120 u8 config; 129 bool req_db 121 bool req_db; 130 struct { 122 struct { 131 bool g0en; 123 bool g0en; 132 bool g1en; 124 bool g1en; 133 }; 125 }; 134 struct { 126 struct { 135 u8 priori 127 u8 priority; 136 bool group; 128 bool group; 137 }; 129 }; 138 }; 130 }; 139 }; 131 }; 140 132 141 int its_alloc_vcpu_irqs(struct its_vm *vm); 133 int its_alloc_vcpu_irqs(struct its_vm *vm); 142 void its_free_vcpu_irqs(struct its_vm *vm); 134 void its_free_vcpu_irqs(struct its_vm *vm); 143 int its_make_vpe_resident(struct its_vpe *vpe, 135 int its_make_vpe_resident(struct its_vpe *vpe, bool g0en, bool g1en); 144 int its_make_vpe_non_resident(struct its_vpe * 136 int its_make_vpe_non_resident(struct its_vpe *vpe, bool db); 145 int its_commit_vpe(struct its_vpe *vpe); 137 int its_commit_vpe(struct its_vpe *vpe); 146 int its_invall_vpe(struct its_vpe *vpe); 138 int its_invall_vpe(struct its_vpe *vpe); 147 int its_map_vlpi(int irq, struct its_vlpi_map 139 int its_map_vlpi(int irq, struct its_vlpi_map *map); 148 int its_get_vlpi(int irq, struct its_vlpi_map 140 int its_get_vlpi(int irq, struct its_vlpi_map *map); 149 int its_unmap_vlpi(int irq); 141 int its_unmap_vlpi(int irq); 150 int its_prop_update_vlpi(int irq, u8 config, b 142 int its_prop_update_vlpi(int irq, u8 config, bool inv); 151 int its_prop_update_vsgi(int irq, u8 priority, 143 int its_prop_update_vsgi(int irq, u8 priority, bool group); 152 144 153 struct irq_domain_ops; 145 struct irq_domain_ops; 154 int its_init_v4(struct irq_domain *domain, 146 int its_init_v4(struct irq_domain *domain, 155 const struct irq_domain_ops *v 147 const struct irq_domain_ops *vpe_ops, 156 const struct irq_domain_ops *s 148 const struct irq_domain_ops *sgi_ops); 157 149 158 bool gic_cpuif_has_vsgi(void); 150 bool gic_cpuif_has_vsgi(void); 159 151 160 #endif 152 #endif 161 153
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.