Skip to contentSkip to conversation

ARM GICv3 ITS DeviceID modification implementation

PATCH In review Nabih Estefan 2 participants 5 messages Feb 21, 2024 – Feb 23, 2024

lore
Share & tools
lore
#0 lore raw

cover ARM GICv3 ITS DeviceID modification implementation

This patch series modifies the ARM GICv3 ITS to use the already existing send_msi virtual function when writing the GITS_TRANSLATER in order to be able to modify the final DeviceID to an implementation specific version that requires extra information besides the BDF that comes in the requester_id. This is achieved by using inheritance and redefinition of the send_msi while the parent's send_msi could still be used to inject the modified DeviceID.

Roque Arcudia Hernandez (2):
hw/intc/arm_gicv3_its_common: Increase DeviceID to 32 bits hw/intc/arm_gicv3_its: Use send_msi in the GITS_TRANSLATER write

 hw/intc/arm_gicv3_its.c                | 20 +++++++++-----------
 hw/intc/arm_gicv3_its_kvm.c            |  2 +-
 include/hw/intc/arm_gicv3_its_common.h | 15 ++++++++++++---
 3 files changed, 22 insertions(+), 15 deletions(-)
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
#1 lore raw

PATCH 1/2 hw/intc/arm_gicv3_its_common: Increase DeviceID to 32 bits

From: Roque Arcudia Hernandez <[email protected]>

According to the “GICv3 and GICv4 Software Overview” the DeviceID is IMPLEMENTATION DEFINED. This patch increases the DeviceID in send_msi virtual function to 32 bits to allow the possibility of a redefinition of it with a bigger DeviceID.

---
 hw/intc/arm_gicv3_its_kvm.c            | 2 +-
 include/hw/intc/arm_gicv3_its_common.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/intc/arm_gicv3_its_kvm.c +1 -1
index 3befc960db..4eaf1cfcad 100644
@@ -42,7 +42,7 @@ struct KVMARMITSClass {
 };
 
 
-static int kvm_its_send_msi(GICv3ITSState *s, uint32_t value, uint16_t devid)
+static int kvm_its_send_msi(GICv3ITSState *s, uint32_t value, uint32_t devid)
 {
     struct kvm_msi msi;
 
include/hw/intc/arm_gicv3_its_common.h +1 -1
index 7dc712b38d..e072c36cca 100644
@@ -117,7 +117,7 @@ struct GICv3ITSCommonClass {
     SysBusDeviceClass parent_class;
     /*< public >*/
 
-    int (*send_msi)(GICv3ITSState *s, uint32_t data, uint16_t devid);
+    int (*send_msi)(GICv3ITSState *s, uint32_t data, uint32_t devid);
     void (*pre_save)(GICv3ITSState *s);
     void (*post_load)(GICv3ITSState *s);
 };
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
#2 lore raw

Re: [PATCH 1/2] hw/intc/arm_gicv3_its_common: Increase DeviceID to 32 bits

Quoted 7 lines · Nabih Estefan

From: Roque Arcudia Hernandez <[email protected]>

According to the “GICv3 and GICv4 Software Overview” the DeviceID is IMPLEMENTATION DEFINED. This patch increases the DeviceID in send_msi virtual function to 32 bits to allow the possibility of a redefinition of it with a bigger DeviceID.

It's IMPLEMENTATION DEFINED, and our implementation defines it to be 16 bits (see the ITS_DEVBITS #define). So uint16_t is fine.

Again, this change is missing any context that would motivate it, and needs to be upstreamed along with whatever the actual code is that needs it, not as a single thing on its own.

thanks
-- PMM

#3 lore raw

PATCH 2/2 hw/intc/arm_gicv3_its: Use send_msi in the GITS_TRANSLATER write

In reply to Nabih Estefan

From: Roque Arcudia Hernandez <[email protected]>

This is trying to achieve 2 things: To be able to redefine the send_msi in a derived class of arm_gicv3_its and/or to expose a method call interface to inject interrupts from another device.

---
 hw/intc/arm_gicv3_its.c                | 20 +++++++++-----------
 include/hw/intc/arm_gicv3_its_common.h | 13 +++++++++++--
 2 files changed, 20 insertions(+), 13 deletions(-)
hw/intc/arm_gicv3_its.c +9 -11
index 52e9aca9c6..9342e96be3 100644
@@ -20,16 +20,6 @@
 #include "qom/object.h"
 #include "qapi/error.h"
 
-typedef struct GICv3ITSClass GICv3ITSClass;
-/* This is reusing the GICv3ITSState typedef from ARM_GICV3_ITS_COMMON */
-DECLARE_OBJ_CHECKERS(GICv3ITSState, GICv3ITSClass,
-                     ARM_GICV3_ITS, TYPE_ARM_GICV3_ITS)
-
-struct GICv3ITSClass {
-    GICv3ITSCommonClass parent_class;
-    ResettablePhases parent_phases;
-};
-
 /*
  * This is an internal enum used to distinguish between LPI triggered
  * via command queue and LPI triggered via gits_translater write.
@@ -1561,7 +1551,8 @@ static MemTxResult gicv3_its_translation_write(void *opaque, hwaddr offset,
     switch (offset) {
     case GITS_TRANSLATER:
         if (s->ctlr & R_GITS_CTLR_ENABLED_MASK) {
-            result = do_process_its_cmd(s, attrs.requester_id, data, NONE);
+            GICv3ITSCommonClass *c = ARM_GICV3_ITS_COMMON_GET_CLASS(s);
+            result = c->send_msi(s, data, attrs.requester_id);
         }
         break;
     default:
@@ -1994,6 +1985,12 @@ static void gicv3_its_reset_hold(Object *obj)
     }
 }
 
+static int gicv3_its_send_msi(GICv3ITSState *s, uint32_t eventid,
+                              uint32_t devid)
+{
+    return do_process_its_cmd(s, devid, eventid, NONE);
+}
+
 static void gicv3_its_post_load(GICv3ITSState *s)
 {
     if (s->ctlr & R_GITS_CTLR_ENABLED_MASK) {
@@ -2020,6 +2017,7 @@ static void gicv3_its_class_init(ObjectClass *klass, void *data)
     resettable_class_set_parent_phases(rc, NULL, gicv3_its_reset_hold, NULL,
                                        &ic->parent_phases);
     icc->post_load = gicv3_its_post_load;
+    icc->send_msi = gicv3_its_send_msi;
 }
 
 static const TypeInfo gicv3_its_info = {
include/hw/intc/arm_gicv3_its_common.h +11 -2
index e072c36cca..c81bd0b26e 100644
@@ -25,8 +25,6 @@
 #include "hw/intc/arm_gicv3_common.h"
 #include "qom/object.h"
 
-#define TYPE_ARM_GICV3_ITS "arm-gicv3-its"
-
 #define ITS_CONTROL_SIZE 0x10000
 #define ITS_TRANS_SIZE   0x10000
 #define ITS_SIZE         (ITS_CONTROL_SIZE + ITS_TRANS_SIZE)
@@ -132,4 +130,15 @@ struct GICv3ITSCommonClass {
  */
 const char *its_class_name(void);
 
+#define TYPE_ARM_GICV3_ITS "arm-gicv3-its"
+typedef struct GICv3ITSClass GICv3ITSClass;
+/* This is reusing the GICv3ITSState typedef from ARM_GICV3_ITS_COMMON */
+DECLARE_OBJ_CHECKERS(GICv3ITSState, GICv3ITSClass,
+                     ARM_GICV3_ITS, TYPE_ARM_GICV3_ITS)
+
+struct GICv3ITSClass {
+    GICv3ITSCommonClass parent_class;
+    ResettablePhases parent_phases;
+};
+
 #endif
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
#4 lore raw

Re: [PATCH 2/2] hw/intc/arm_gicv3_its: Use send_msi in the GITS_TRANSLATER write

Quoted 6 lines · Nabih Estefan

From: Roque Arcudia Hernandez <[email protected]>

This is trying to achieve 2 things: To be able to redefine the send_msi in a derived class of arm_gicv3_its and/or to expose a method call interface to inject interrupts from another device.

But there is no such derived class, so what's the purpose of this infrastructure? If you have a specific device model you want to upstream that uses this, you should include this in the patchset adding that device model, so that we have the context to see what the change is trying to and whether it's the best way to do it.

thanks
-- PMM