Skip to contentSkip to conversation

pnv/xive2: Allow indirect TIMA accesses of all sizes

PATCH Applied Frederic Barrat 4 participants 6 messages Jun 26, 2023 – Jul 1, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pnv/xive2: Allow indirect TIMA accesses of all sizes

Booting linux on the powernv10 machine logs a few errors like:

Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid write at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8)

Those errors happen when linux is resetting XIVE. We're trying to read/write the enablement bit for the hardware context and qemu doesn't allow indirect TIMA accesses of less than 8 bytes. Direct TIMA access can go through though, as well as indirect TIMA accesses on P9. So even though there are some restrictions regarding the address/size combinations for TIMA access, the example above is perfectly valid.

This patch lets indirect TIMA accesses of all sizes go through. The special operations will be intercepted and the default "raw" handlers will pick up all other requests and complain about invalid sizes as appropriate.

---
 hw/intc/pnv_xive2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/intc/pnv_xive2.c +2 -2
index ed438a20ed..e8ab176de6 100644
@@ -1644,11 +1644,11 @@ static const MemoryRegionOps pnv_xive2_ic_tm_indirect_ops = {
     .write = pnv_xive2_ic_tm_indirect_write,
     .endianness = DEVICE_BIG_ENDIAN,
     .valid = {
-        .min_access_size = 8,
+        .min_access_size = 1,
         .max_access_size = 8,
     },
     .impl = {
-        .min_access_size = 8,
+        .min_access_size = 1,
         .max_access_size = 8,
     },
 };
Signature · 1 line
2.41.0
#1 lore raw
Quoted 29 lines · Frederic Barrat

Booting linux on the powernv10 machine logs a few errors like:

Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid write at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8)

Those errors happen when linux is resetting XIVE. We're trying to read/write the enablement bit for the hardware context and qemu doesn't allow indirect TIMA accesses of less than 8 bytes. Direct TIMA access can go through though, as well as indirect TIMA accesses on P9. So even though there are some restrictions regarding the address/size combinations for TIMA access, the example above is perfectly valid.

This patch lets indirect TIMA accesses of all sizes go through. The special operations will be intercepted and the default "raw" handlers will pick up all other requests and complain about invalid sizes as appropriate.

---
  hw/intc/pnv_xive2.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
hw/intc/pnv_xive2.c +0 -0
index ed438a20ed..e8ab176de6 100644

hw/intc/pnv_xive2.c static const MemoryRegionOps pnv_xive2_ic_tm_indirect_ops = { · line 1647

Quoted 5 lines
hw/intc/pnv_xive2.c +1 -1
@@ -1644,11 +1644,11 @@ static const MemoryRegionOps pnv_xive2_ic_tm_indirect_ops = {
      .write = pnv_xive2_ic_tm_indirect_write,
      .endianness = DEVICE_BIG_ENDIAN,
      .valid = {
-        .min_access_size = 8,
+        .min_access_size = 1,

Maybe. Is there a bus involved in between?

What about other I/O regions?

hw/intc/pnv_xive2.c static const MemoryRegionOps pnv_xive2_ic_tm_indirect_ops = { · line 1651

Quoted 5 lines
hw/intc/pnv_xive2.c +1 -1
          .max_access_size = 8,
      },
      .impl = {
-        .min_access_size = 8,
+        .min_access_size = 1,

Unlikely. This is for the handler implementation, not related to HW.

Quoted 3 lines
hw/intc/pnv_xive2.c +0 -0
          .max_access_size = 8,
      },
  };
#2 lore raw
Quoted 39 lines · Philippe Mathieu-Daudé
Quoted 29 lines · Frederic Barrat

Booting linux on the powernv10 machine logs a few errors like:

Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid write at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8)

Those errors happen when linux is resetting XIVE. We're trying to read/write the enablement bit for the hardware context and qemu doesn't allow indirect TIMA accesses of less than 8 bytes. Direct TIMA access can go through though, as well as indirect TIMA accesses on P9. So even though there are some restrictions regarding the address/size combinations for TIMA access, the example above is perfectly valid.

This patch lets indirect TIMA accesses of all sizes go through. The special operations will be intercepted and the default "raw" handlers will pick up all other requests and complain about invalid sizes as appropriate.

---
  hw/intc/pnv_xive2.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
hw/intc/pnv_xive2.c +0 -0
index ed438a20ed..e8ab176de6 100644

hw/intc/pnv_xive2.c static const MemoryRegionOps · line 1648

Quoted 6 lines
hw/intc/pnv_xive2.c +1 -1
@@ -1644,11 +1644,11 @@ static const MemoryRegionOps 
 pnv_xive2_ic_tm_indirect_ops = {
       .write = pnv_xive2_ic_tm_indirect_write,
       .endianness = DEVICE_BIG_ENDIAN,
       .valid = {
-        .min_access_size = 8,
+        .min_access_size = 1,

Maybe. Is there a bus involved in between?

Quoted 1 line

What about other I/O regions?

XIVE is attached to the main system bus and the CPU can trigger 1, 2, 4 and 8-byte accesses. The TIMA is a part of XIVE which supports various size of mmio operations, all the way down to byte operations. It actually relies on it.

There are 2 memory regions where we want to allow byte-access. One, known as TIMA direct access, already allows access with min size = 1. I'm just aligning the other one, known as TIMA indirect access, to do the same, since it's what the hardware allows. This is similar to what we had on P9 and both regions are already defined with min size = 1 there. So it really looks like what I'm changing here was just an oversight.

Quoted 7 lines

hw/intc/pnv_xive2.c static const MemoryRegionOps pnv_xive2_ic_tm_indirect_ops = { · line 1651

Quoted 5 lines
hw/intc/pnv_xive2.c +1 -1
           .max_access_size = 8,
       },
       .impl = {
-        .min_access_size = 8,
+        .min_access_size = 1,

Unlikely. This is for the handler implementation, not related to HW.

The handlers for the TIMA regions are aware of the size of the access, and behave differently based on it (see xive_tm_find_op() for example). So I think this is correct. Let me know if I'm missing something here.

Fred

Quoted 4 lines
Quoted 3 lines
hw/intc/pnv_xive2.c +0 -0
           .max_access_size = 8,
       },

  };

#3 lore raw

Hi Frederic,

Quoted 40 lines · Frederic Barrat
Quoted 39 lines · Philippe Mathieu-Daudé
Quoted 29 lines · Frederic Barrat

Booting linux on the powernv10 machine logs a few errors like:

Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid write at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8)

Those errors happen when linux is resetting XIVE. We're trying to read/write the enablement bit for the hardware context and qemu doesn't allow indirect TIMA accesses of less than 8 bytes. Direct TIMA access can go through though, as well as indirect TIMA accesses on P9. So even though there are some restrictions regarding the address/size combinations for TIMA access, the example above is perfectly valid.

This patch lets indirect TIMA accesses of all sizes go through. The special operations will be intercepted and the default "raw" handlers will pick up all other requests and complain about invalid sizes as appropriate.

---
  hw/intc/pnv_xive2.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
hw/intc/pnv_xive2.c +0 -0
index ed438a20ed..e8ab176de6 100644

hw/intc/pnv_xive2.c static const MemoryRegionOps · line 1648

Quoted 6 lines
hw/intc/pnv_xive2.c +1 -1
@@ -1644,11 +1644,11 @@ static const MemoryRegionOps 
 pnv_xive2_ic_tm_indirect_ops = {
       .write = pnv_xive2_ic_tm_indirect_write,
       .endianness = DEVICE_BIG_ENDIAN,
       .valid = {
-        .min_access_size = 8,
+        .min_access_size = 1,

Maybe. Is there a bus involved in between?

Quoted 7 lines
Quoted 1 line

What about other I/O regions?

XIVE is attached to the main system bus and the CPU can trigger 1, 2, 4 and 8-byte accesses. The TIMA is a part of XIVE which supports various size of mmio operations, all the way down to byte operations. It actually relies on it.

There are 2 memory regions where we want to allow byte-access. One, known as TIMA direct access, already allows access with min size = 1. I'm just aligning the other one, known as TIMA indirect access, to do the same, since it's what the hardware allows. This is similar to what we had on P9 and both regions are already defined with min size = 1 there. So it really looks like what I'm changing here was just an oversight.

OK.

Quoted 11 lines
Quoted 8 lines

hw/intc/pnv_xive2.c static const MemoryRegionOps pnv_xive2_ic_tm_indirect_ops = { · line 1651

Quoted 6 lines
hw/intc/pnv_xive2.c +1 -1
           .max_access_size = 8,
       },
       .impl = {
-        .min_access_size = 8,
+        .min_access_size = 1,

Unlikely. This is for the handler implementation, not related to HW.

The handlers for the TIMA regions are aware of the size of the access, and behave differently based on it (see xive_tm_find_op() for example). So I think this is correct. Let me know if I'm missing something here.

I guess I got confused by the "Only 4 or 8 bytes loads are allowed" comment in xive_tm_raw_read/write(), so I was somehow expecting min_access_size = 4. I don't object to this patch however.

Thanks,

Phil.

Reviewed-by on v1 1/1
#4 lore raw
In reply to Frederic Barrat
Quoted 32 lines · Frederic Barrat

Booting linux on the powernv10 machine logs a few errors like:

Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid write at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8)

Those errors happen when linux is resetting XIVE. We're trying to read/write the enablement bit for the hardware context and qemu doesn't allow indirect TIMA accesses of less than 8 bytes. Direct TIMA access can go through though, as well as indirect TIMA accesses on P9. So even though there are some restrictions regarding the address/size combinations for TIMA access, the example above is perfectly valid.

This patch lets indirect TIMA accesses of all sizes go through. The special operations will be intercepted and the default "raw" handlers will pick up all other requests and complain about invalid sizes as appropriate.

---
  hw/intc/pnv_xive2.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
hw/intc/pnv_xive2.c +0 -0
index ed438a20ed..e8ab176de6 100644
@@ -1644,11 +1644,11 @@ static const MemoryRegionOps pnv_xive2_ic_tm_indirect_ops = {
      .write = pnv_xive2_ic_tm_indirect_write,
      .endianness = DEVICE_BIG_ENDIAN,
      .valid = {

hw/intc/pnv_xive2.c static const MemoryRegionOps pnv_xive2_ic_tm_indirect_ops = { · line 1654

Quoted 10 lines
hw/intc/pnv_xive2.c +2 -2
-        .min_access_size = 8,
+        .min_access_size = 1,
          .max_access_size = 8,
      },
      .impl = {
-        .min_access_size = 8,
+        .min_access_size = 1,
          .max_access_size = 8,
      },
  };

This makes the TM indirect ops and the TM direct ops similar on P10. Same as P9

LGTM,

Thanks,

C.

#5 lore raw
In reply to Frederic Barrat

Queued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,

Daniel

Quoted 42 lines · Frederic Barrat

Booting linux on the powernv10 machine logs a few errors like:

Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid write at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8) Invalid read at addr 0x38, size 1, region 'xive-ic-tm-indirect', reason: invalid size (min:8 max:8)

Those errors happen when linux is resetting XIVE. We're trying to read/write the enablement bit for the hardware context and qemu doesn't allow indirect TIMA accesses of less than 8 bytes. Direct TIMA access can go through though, as well as indirect TIMA accesses on P9. So even though there are some restrictions regarding the address/size combinations for TIMA access, the example above is perfectly valid.

This patch lets indirect TIMA accesses of all sizes go through. The special operations will be intercepted and the default "raw" handlers will pick up all other requests and complain about invalid sizes as appropriate.

---
  hw/intc/pnv_xive2.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
hw/intc/pnv_xive2.c +2 -2
index ed438a20ed..e8ab176de6 100644
@@ -1644,11 +1644,11 @@ static const MemoryRegionOps pnv_xive2_ic_tm_indirect_ops = {
      .write = pnv_xive2_ic_tm_indirect_write,
      .endianness = DEVICE_BIG_ENDIAN,
      .valid = {
-        .min_access_size = 8,
+        .min_access_size = 1,
          .max_access_size = 8,
      },
      .impl = {
-        .min_access_size = 8,
+        .min_access_size = 1,
          .max_access_size = 8,
      },
  };