arm-gic-v4.h 3.5 KB

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