Skip to contentSkip to conversation

aspeed queue

GIT PULL Applied Cédric Le Goater 3 participants 9 messages Mar 23, 2025 – Mar 25, 2025 Arm/Aspeed machine support

lore
Share & tools
lore
#1 lore raw

[PULL 2/3] hw/intc/aspeed: Fix IRQ handler mask check

In reply to Cédric Le Goater

From: Steven Lee <[email protected]>

Updated the IRQ handler mask check to AND with select variable. This ensures that the interrupt service routine is correctly triggered for the interrupts within the same irq group.

For example, both eth0 and the debug UART are handled in GICINT132. Without this fix, the debug console may hang if the eth0 ISR is not handled.

Change-Id Ic3609eb72218dfd68be6057d78b8953b18828709
Fixes d831c5fd8682 ("aspeed/intc: Add AST2700 support")
---
 hw/intc/aspeed_intc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/aspeed_intc.c +1 -1
index 3fd417084f5b..f17bf439256a 100644
@@ -111,7 +111,7 @@ static void aspeed_intc_set_irq_handler(AspeedINTCState *s,
     outpin_idx = intc_irq->outpin_idx;
     inpin_idx = intc_irq->inpin_idx;
 
-    if (s->mask[inpin_idx] || s->regs[status_reg]) {
+    if ((s->mask[inpin_idx] & select) || (s->regs[status_reg] & select)) {
         /*
          * a. mask is not 0 means in ISR mode
          * sources interrupt routine are executing.
Signature · 1 line
2.49.0
#0 lore raw

The following changes since commit 527dede083d3e3e5a13ee996776926e0a0c4e258:

Merge tag 'pull-request-2025-03-19' of https://gitlab.com/thuth/qemu into staging (2025-03-20 08:41:25 -0400)

are available in the Git repository at:

https://github.com/legoater/qemu/ tags/pull-aspeed-20250323

for you to fetch changes up to 78877b2e06464f49f777e086845e094ea7bc82ef:

hw/misc/aspeed_hace: Fix buffer overflow in has_padding function (2025-03-23 18:42:16 +0100)

----------------------------------------------------------------
aspeed queue:

* Fix AST2700 SoC model

----------------------------------------------------------------
Jamin Lin (1):
hw/misc/aspeed_hace: Fix buffer overflow in has_padding function

Steven Lee (1):
hw/intc/aspeed: Fix IRQ handler mask check

Troy Lee (1):
aspeed: Fix maximum number of spi controller

 include/hw/arm/aspeed_soc.h | 2 +-
 hw/intc/aspeed_intc.c       | 2 +-
 hw/misc/aspeed_hace.c       | 5 +++++
 3 files changed, 7 insertions(+), 2 deletions(-)
#2 lore raw

[PULL 1/3] aspeed: Fix maximum number of spi controller

From: Troy Lee <[email protected]>

Commit 6de4aa8dc544 ("hw/arm/aspeed_ast27x0: Add SoC Support for AST2700 A1") extends ast2700a1 spis_num to 3, but ASPEED_SPIS_NUM defines the maximum number of spi controller to 2, result in ehci[0] is being overwritten in runtime.

Fixes 6de4aa8dc544 ("hw/arm/aspeed_ast27x0: Add SoC Support for AST2700 A1")
---
 include/hw/arm/aspeed_soc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/arm/aspeed_soc.h +1 -1
index f899356ed94c..f069d17d1629 100644
@@ -42,7 +42,7 @@
 #include "hw/char/serial-mm.h"
 #include "hw/intc/arm_gicv3.h"
 
-#define ASPEED_SPIS_NUM  2
+#define ASPEED_SPIS_NUM  3
 #define ASPEED_EHCIS_NUM 2
 #define ASPEED_WDTS_NUM  8
 #define ASPEED_CPUS_NUM  4
Signature · 1 line
2.49.0
#3 lore raw

[PULL 3/3] hw/misc/aspeed_hace: Fix buffer overflow in has_padding function

In reply to Cédric Le Goater

From: Jamin Lin <[email protected]>

The maximum padding size is either 64 or 128 bytes and should always be smaller than "req_len". If "padding_size" exceeds "req_len", then
"req_len - padding_size" underflows due to "uint32_t" data type, leading to a large incorrect value (e.g., 0xFFXXXXXX). This causes an out-of-bounds memory access, potentially leading to a buffer overflow.

Added a check to ensure "padding_size" does not exceed "req_len" before computing "pad_offset". This prevents "req_len - padding_size" from underflowing and avoids accessing invalid memory.

Fixes 5cd7d8564a8b563da724b9e6264c967f0a091afa ("aspeed/hace: Support AST2600 HACE ")
---
 hw/misc/aspeed_hace.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/misc/aspeed_hace.c +5 -0
index 32a5dbded3c6..d75da3335336 100644
@@ -128,6 +128,11 @@ static bool has_padding(AspeedHACEState *s, struct iovec *iov,
     if (*total_msg_len <= s->total_req_len) {
         uint32_t padding_size = s->total_req_len - *total_msg_len;
         uint8_t *padding = iov->iov_base;
+
+        if (padding_size > req_len) {
+            return false;
+        }
+
         *pad_offset = req_len - padding_size;
         if (padding[*pad_offset] == 0x80) {
             return true;
Signature · 1 line
2.49.0
#5 lore raw
In reply to Cédric Le Goater
Quoted 8 lines · Cédric Le Goater

Jamin Lin (1):
hw/misc/aspeed_hace: Fix buffer overflow in has_padding function

Steven Lee (1):
hw/intc/aspeed: Fix IRQ handler mask check

Troy Lee (1):
aspeed: Fix maximum number of spi controller

Is there anything in there worth to pick up for stable series?

Thanks,

/mjt

#6 lore raw
Quoted 11 lines · Michael Tokarev
Quoted 8 lines · Cédric Le Goater

Jamin Lin (1):
       hw/misc/aspeed_hace: Fix buffer overflow in has_padding function

Steven Lee (1):
       hw/intc/aspeed: Fix IRQ handler mask check

Troy Lee (1):
       aspeed: Fix maximum number of spi controller

Is there anything in there worth to pick up for stable series?

you are fast !

- "aspeed: Fix maximum number of spi controller" is QEMU 10.0 material.
- "hw/intc/aspeed: Fix IRQ handler mask check" was merged in QEMU 9.1
- "hw/misc/aspeed_hace: Fix buffer overflow in has_padding function" was merged in QEMU 7.1

The last 2 deserve to be backported IMO. They will need some massaging.

Thanks,

C.

Reviewed-by Cédric Le Goater
#7 lore raw
Quoted 3 lines · Cédric Le Goater
Quoted 1 line

Is there anything in there worth to pick up for stable series?

you are fast !

I was just about to send final announcements for a bunch of next stable releases, and noticed another pull request has been merged.. :)

Quoted 6 lines

- "aspeed: Fix maximum number of spi controller" is QEMU 10.0 material.
- "hw/intc/aspeed: Fix IRQ handler mask check" was merged in QEMU 9.1
- "hw/misc/aspeed_hace: Fix buffer overflow in has_padding function" was merged in QEMU 7.1

The last 2 deserve to be backported IMO. They will need some massaging.

The "buffer overflow" fix seems to be okay for 9.2, 8.2 and 7.2.

The "IRQ handler mask check" seems to be this (for 9.2). Does it look sane?

Author: Steven Lee <[email protected]>
Date:   Thu Mar 20 17:25:43 2025 +0800

hw/intc/aspeed: Fix IRQ handler mask check

Updated the IRQ handler mask check to AND with select variable. This ensures that the interrupt service routine is correctly triggered for the interrupts within the same irq group.

For example, both eth0 and the debug UART are handled in GICINT132. Without this fix, the debug console may hang if the eth0 ISR is not handled.

Change-Id Ic3609eb72218dfd68be6057d78b8953b18828709
Fixes d831c5fd8682 ("aspeed/intc: Add AST2700 support")
(cherry picked from commit 7b8cbe5162e69ad629c5326bf3c158b81857955d)

(Mjt: update for before v9.2.0-2466-g5824e8bf6beb
"hw/intc/aspeed: Introduce IRQ handler function to reduce code duplication")

hw/intc/aspeed_intc.c +1 -1
index 126b711b94..495fd2bdfa 100644
@@ -92,7 +92,7 @@ static void aspeed_intc_set_irq(void *opaque, int irq, int level)
 
     trace_aspeed_intc_select(select);
 
-    if (s->mask[irq] || s->regs[status_addr]) {
+    if ((s->mask[irq] & select) || (s->regs[status_addr] & select)) {
         /*
          * a. mask is not 0 means in ISR mode
          * sources interrupt routine are executing.
#8 lore raw
Quoted 15 lines · Michael Tokarev
Quoted 3 lines · Cédric Le Goater
Quoted 1 line

Is there anything in there worth to pick up for stable series?

you are fast !

I was just about to send final announcements for a bunch of next stable releases, and noticed another pull request has been merged.. :)

Quoted 5 lines

- "aspeed: Fix maximum number of spi controller" is QEMU 10.0 material.
- "hw/intc/aspeed: Fix IRQ handler mask check" was merged in QEMU 9.1
- "hw/misc/aspeed_hace: Fix buffer overflow in has_padding function" was merged in QEMU 7.1

Quoted 5 lines
Quoted 1 line

The last 2 deserve to be backported IMO. They will need some massaging.

The "buffer overflow" fix seems to be okay for 9.2, 8.2 and 7.2.

The "IRQ handler mask check" seems to be this (for 9.2). Does it look sane?

It does.

Thanks,

C.

Quoted 38 lines

Author: Steven Lee <[email protected]>
Date:   Thu Mar 20 17:25:43 2025 +0800

    hw/intc/aspeed: Fix IRQ handler mask check

    Updated the IRQ handler mask check to AND with select variable. This ensures that the interrupt service routine is correctly triggered for the interrupts within the same irq group.

    For example, both eth0 and the debug UART are handled in GICINT132. Without this fix, the debug console may hang if the eth0 ISR is not handled.

Change-Id Ic3609eb72218dfd68be6057d78b8953b18828709
Fixes d831c5fd8682 ("aspeed/intc: Add AST2700 support")
    (cherry picked from commit 7b8cbe5162e69ad629c5326bf3c158b81857955d)

    (Mjt: update for before v9.2.0-2466-g5824e8bf6beb "hw/intc/aspeed: Introduce IRQ handler function to reduce code duplication")

hw/intc/aspeed_intc.c +1 -1
index 126b711b94..495fd2bdfa 100644
@@ -92,7 +92,7 @@ static void aspeed_intc_set_irq(void *opaque, int irq, int level)
 
      trace_aspeed_intc_select(select);
 
-    if (s->mask[irq] || s->regs[status_addr]) {
+    if ((s->mask[irq] & select) || (s->regs[status_addr] & select)) {
          /*
           * a. mask is not 0 means in ISR mode
           * sources interrupt routine are executing.