public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PULL 00/17] riscv-to-apply queue
@ 2026-03-19 23:25 alistair23
  2026-03-19 23:25 ` [PULL 01/17] hw/riscv: Fix integer overflow in cm_base calculation alistair23
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair23, Alistair Francis

From: Alistair Francis <alistair.francis@wdc.com>

The following changes since commit 5a68a3add61208aad34d47134fdcfd3f407d2ce4:

  Update version for v11.0.0-rc0 release (2026-03-18 15:56:51 +0000)

are available in the Git repository at:

  https://github.com/alistair23/qemu.git tags/pull-riscv-to-apply-20260320

for you to fetch changes up to 38937473da3ebdd89bbe6bbc3effc0b153ceb414:

  target/riscv: Fix scountovf CSR behavior in VS-mode and M-mode (2026-03-20 08:41:15 +1000)

----------------------------------------------------------------
RISC-V PR for 11.

* Fix integer overflow in cm_base calculation
* Fix null pointer dereference in cpu_set_exception_base
* Update Daniel Henrique Barboza's email
* Add Chao Liu as reviewer
* Set SiFive PDMA done bit upon completion
* Remove deprecated 'riscv, delegate' device-tree property
* Fix OCP FP8 E4M3 conversion issues
* Fix IOMMU instance_init allocations in instance_finalize
* Support Smpmpmt extension
* Fix SiFive UART spurious IRQ issue and misc updates
* Fix missing flags merge in probe_pages for cross-page accesses
* Fix page probe issues in vext_ldff
* Fix scountovf CSR behavior in VS-mode and M-mode

----------------------------------------------------------------
Chao Liu (1):
      MAINTAINERS: Add myself as a reviewer for RISC-V TCG CPUs

Daniel Henrique Barboza (1):
      MAINTAINERS: update my email

Djordje Todorovic (2):
      hw/riscv: Fix integer overflow in cm_base calculation
      target/riscv: Fix null pointer dereference in cpu_set_exception_base

Frank Chang (4):
      hw/char: sifive_uart: Implement txctrl.txen and rxctrl.rxen
      hw/char: sifive_uart: Sync txwm interrupt pending status after TX FIFO enqueue
      hw/char: sifive_uart: Update IRQ when rxctrl is written
      hw/char: sifive_uart: Remove ip variable

Jay Chang (2):
      hw/dma: sifive_pdma: Set done bit upon completion
      target/riscv: Support Smpmpmt extension

Jim Shu (1):
      target/riscv: Fix scountovf CSR behavior in VS-mode and M-mode

Max Chou (4):
      fpu: Fix repacking issues in the uncanonical step for E4M3 overflow
      fpu: Fix unexpected exception flags when converting infinity to OCP E4M3
      target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses
      target/riscv: rvv: Fix page probe issues in vext_ldff

Peter Maydell (1):
      hw/riscv/riscv-iommu: Free instance_init allocations in instance_finalize

Philippe Mathieu-Daudé (1):
      hw/riscv: Remove deprecated 'riscv, delegate' device-tree property

 MAINTAINERS                       |  4 +++-
 docs/about/deprecated.rst         | 11 ----------
 docs/about/removed-features.rst   | 11 ++++++++++
 include/hw/char/sifive_uart.h     |  3 ++-
 include/hw/riscv/cps.h            |  2 +-
 target/riscv/pmp.h                |  1 +
 target/riscv/cpu_cfg_fields.h.inc |  1 +
 hw/char/sifive_uart.c             | 46 +++++++++++++++++++++++++++++++--------
 hw/dma/sifive_pdma.c              |  1 +
 hw/riscv/riscv-iommu.c            | 16 +++++++++++---
 hw/riscv/virt.c                   |  9 --------
 target/riscv/cpu.c                |  3 +++
 target/riscv/csr.c                | 16 ++++++++++++--
 target/riscv/pmp.c                | 16 ++++++++++++++
 target/riscv/vector_helper.c      | 23 ++++++--------------
 fpu/softfloat-parts.c.inc         |  4 +++-
 16 files changed, 113 insertions(+), 54 deletions(-)


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PULL 01/17] hw/riscv: Fix integer overflow in cm_base calculation
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 02/17] target/riscv: Fix null pointer dereference in cpu_set_exception_base alistair23
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: alistair23, Djordje Todorovic, Djordje Todorovic,
	Philippe Mathieu-Daudé, Alistair Francis

From: Djordje Todorovic <Djordje.Todorovic@htecgroup.com>

Ensure 64-bit arithmetic is used when computing cm_base,
avoiding potential integer overflow.

Resolves: Coverity CID 1644076

Signed-off-by: Djordje Todorovic <djordje.todorovic@htecgroup.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260115130110.2825796-2-djordje.todorovic@htecgroup.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 include/hw/riscv/cps.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/riscv/cps.h b/include/hw/riscv/cps.h
index f33fd7ac86..39029bca8f 100644
--- a/include/hw/riscv/cps.h
+++ b/include/hw/riscv/cps.h
@@ -27,7 +27,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(RISCVCPSState, RISCV_CPS)
 /* The global CM base for the boston-aia model. */
 #define GLOBAL_CM_BASE 0x16100000
 /* The CM block is 512 KiB. */
-#define CM_SIZE (1 << 19)
+#define CM_SIZE (1ULL << 19)
 
 /*
  * The mhartid bits has cluster at bit 16, core at bit 4, and hart at
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 02/17] target/riscv: Fix null pointer dereference in cpu_set_exception_base
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
  2026-03-19 23:25 ` [PULL 01/17] hw/riscv: Fix integer overflow in cm_base calculation alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 03/17] MAINTAINERS: update my email alistair23
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: alistair23, Djordje Todorovic, Djordje Todorovic,
	Philippe Mathieu-Daudé, Alistair Francis

From: Djordje Todorovic <Djordje.Todorovic@htecgroup.com>

Add missing return statement after logging the error when cs is NULL.
Without this, the function continues to dereference the null pointer.

Resolves: Coverity CID 1644077

Signed-off-by: Djordje Todorovic <djordje.todorovic@htecgroup.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260115130110.2825796-3-djordje.todorovic@htecgroup.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/cpu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index e56470a374..9be79622f4 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -83,6 +83,7 @@ void cpu_set_exception_base(int vp_index, target_ulong address)
         qemu_log_mask(LOG_GUEST_ERROR,
                       "cpu_set_exception_base: invalid vp_index: %u",
                       vp_index);
+        return;
     }
     cpu = RISCV_CPU(cs);
     cpu->env.resetvec = address;
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 03/17] MAINTAINERS: update my email
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
  2026-03-19 23:25 ` [PULL 01/17] hw/riscv: Fix integer overflow in cm_base calculation alistair23
  2026-03-19 23:25 ` [PULL 02/17] target/riscv: Fix null pointer dereference in cpu_set_exception_base alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 04/17] MAINTAINERS: Add myself as a reviewer for RISC-V TCG CPUs alistair23
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: alistair23, Daniel Henrique Barboza, Philippe Mathieu-Daudé,
	Alistair Francis

From: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>

Also add myself as a "RISC-V TCG target" reviewer.

Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251217191726.194767-1-daniel.barboza@oss.qualcomm.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 97f2759138..62fb18d125 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -341,7 +341,7 @@ RISC-V TCG CPUs
 M: Palmer Dabbelt <palmer@dabbelt.com>
 M: Alistair Francis <alistair.francis@wdc.com>
 R: Weiwei Li <liwei1518@gmail.com>
-R: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
+R: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
 R: Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
 L: qemu-riscv@nongnu.org
 S: Supported
@@ -4134,6 +4134,7 @@ F: tcg/ppc64/
 RISC-V TCG target
 M: Palmer Dabbelt <palmer@dabbelt.com>
 M: Alistair Francis <Alistair.Francis@wdc.com>
+R: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
 L: qemu-riscv@nongnu.org
 S: Maintained
 F: tcg/riscv64/
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 04/17] MAINTAINERS: Add myself as a reviewer for RISC-V TCG CPUs
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (2 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 03/17] MAINTAINERS: update my email alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 05/17] hw/dma: sifive_pdma: Set done bit upon completion alistair23
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: alistair23, Chao Liu, Bin Meng, Daniel Henrique Barboza,
	LIU Zhiwei, Alistair Francis

From: Chao Liu <chao.liu.zevorn@gmail.com>

Add myself as a reviewer for RISC-V TCG CPU related code to better
participate in patch review.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Message-ID: <20260226102008.146928-1-chao.liu.zevorn@gmail.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 62fb18d125..25fb621c30 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -343,6 +343,7 @@ M: Alistair Francis <alistair.francis@wdc.com>
 R: Weiwei Li <liwei1518@gmail.com>
 R: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
 R: Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
+R: Chao Liu <chao.liu.zevorn@gmail.com>
 L: qemu-riscv@nongnu.org
 S: Supported
 F: configs/targets/riscv*
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 05/17] hw/dma: sifive_pdma: Set done bit upon completion
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (3 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 04/17] MAINTAINERS: Add myself as a reviewer for RISC-V TCG CPUs alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 06/17] hw/riscv: Remove deprecated 'riscv, delegate' device-tree property alistair23
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair23, Jay Chang, Frank Chang, Alistair Francis

From: Jay Chang <jay.chang@sifive.com>

Ensure that the 'done' bit is set upon transfer completion, even if
an error occurs, since all transfers are considered completed regardless
of success or failure.

Signed-off-by: Jay Chang <jay.chang@sifive.com>
Reviewed-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260304030816.33209-1-jay.chang@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 hw/dma/sifive_pdma.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/dma/sifive_pdma.c b/hw/dma/sifive_pdma.c
index 6d06ec0375..7b22e51492 100644
--- a/hw/dma/sifive_pdma.c
+++ b/hw/dma/sifive_pdma.c
@@ -153,6 +153,7 @@ done:
 error:
     s->chan[ch].state = DMA_CHAN_STATE_ERROR;
     s->chan[ch].control |= CONTROL_ERR;
+    s->chan[ch].control |= CONTROL_DONE;
 }
 
 static inline void sifive_pdma_update_irq(SiFivePDMAState *s, int ch)
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 06/17] hw/riscv: Remove deprecated 'riscv, delegate' device-tree property
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (4 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 05/17] hw/dma: sifive_pdma: Set done bit upon completion alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 07/17] fpu: Fix repacking issues in the uncanonical step for E4M3 overflow alistair23
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: alistair23, Philippe Mathieu-Daudé, Alistair Francis,
	Chao Liu, Daniel Henrique Barboza

From: Philippe Mathieu-Daudé <philmd@linaro.org>

The "riscv,delegate" DT property was added in QEMU 7.0 as part of
the AIA APLIC support.  The property changed name during the
review process in Linux and the correct name ended up being
"riscv,delegation". The incorrect name was added as alias, and
deprecated in v9.1 (commit 38facfa8432), so can be removed for
v11.0.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com>
Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Message-ID: <20260227232838.23392-1-philmd@linaro.org>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 docs/about/deprecated.rst       | 11 -----------
 docs/about/removed-features.rst | 11 +++++++++++
 hw/riscv/virt.c                 |  9 ---------
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index c37643548d..a6d6a71326 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -481,17 +481,6 @@ versions, aliases will point to newer CPU model versions
 depending on the machine type, so management software must
 resolve CPU model aliases before starting a virtual machine.
 
-RISC-V "virt" board "riscv,delegate" DT property (since 9.1)
-''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
-The "riscv,delegate" DT property was added in QEMU 7.0 as part of
-the AIA APLIC support.  The property changed name during the review
-process in Linux and the correct name ended up being
-"riscv,delegation".  Changing the DT property name will break all
-available firmwares that are using the current (wrong) name.  The
-property is kept as is in 9.1, together with "riscv,delegation", to
-give more time for firmware developers to change their code.
-
 x86 "isapc" board use of modern x86 CPUs (since 10.2)
 '''''''''''''''''''''''''''''''''''''''''''''''''''''
 
diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
index 6f4447993c..557a24679a 100644
--- a/docs/about/removed-features.rst
+++ b/docs/about/removed-features.rst
@@ -1239,6 +1239,17 @@ converting to using TCG plugins they should contact the qemu-devel
 mailing list.
 
 
+Firmware, ACPI, Device Tree
+---------------------------
+
+RISC-V "virt" board "riscv,delegate" DT property (removed in 11.0)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+The "riscv,delegate" DT property was added in QEMU 7.0 as part of
+the AIA APLIC support.  The property changed name during the review
+process in Linux and the correct name ended up being "riscv,delegation".
+
+
 System emulator devices
 -----------------------
 
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index bbce2fb667..a1c323e66d 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -666,15 +666,6 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int socket,
         qemu_fdt_setprop_cells(ms->fdt, aplic_name, "riscv,delegation",
                                aplic_child_phandle, 0x1,
                                VIRT_IRQCHIP_NUM_SOURCES);
-        /*
-         * DEPRECATED_9.1: Compat property kept temporarily
-         * to allow old firmwares to work with AIA. Do *not*
-         * use 'riscv,delegate' in new code: use
-         * 'riscv,delegation' instead.
-         */
-        qemu_fdt_setprop_cells(ms->fdt, aplic_name, "riscv,delegate",
-                               aplic_child_phandle, 0x1,
-                               VIRT_IRQCHIP_NUM_SOURCES);
     }
 
     riscv_socket_fdt_write_id(ms, aplic_name, socket);
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 07/17] fpu: Fix repacking issues in the uncanonical step for E4M3 overflow
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (5 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 06/17] hw/riscv: Remove deprecated 'riscv, delegate' device-tree property alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 08/17] fpu: Fix unexpected exception flags when converting infinity to OCP E4M3 alistair23
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: alistair23, Max Chou, Richard Henderson, Chao Liu,
	Alistair Francis

From: Max Chou <max.chou@sifive.com>

In the uncanonical step, the input FloatParts will be repacked to the
target FloatFmt. This commit fixes following issues after calling
uncanon_e4m3_overflow in the uncanon/uncanon_normal functions.

- Add the local exp update after calling uncanon_e4m3_overflow in the
  parts_uncanon_normal function.
- Add the fraction shift after calling uncanon_e4m3_overflow in the
  parts_uncanon function.

Fixes: 27e989f99c ("fpu: Add conversion routines for OCP FP8 E4M3")
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com>
Signed-off-by: Max Chou <max.chou@sifive.com>
Message-ID: <20260226071817.1417875-2-max.chou@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 fpu/softfloat-parts.c.inc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index 61b07307bf..a738758aee 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -387,6 +387,7 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
             case float_expmax_e4m3:
                 if (exp > exp_max || p->frac_hi > E4M3_NORMAL_FRAC_MAX) {
                     partsN(uncanon_e4m3_overflow)(p, s, fmt, overflow_norm);
+                    exp = p->exp;
                 }
                 break;
 
@@ -496,6 +497,7 @@ static void partsN(uncanon)(FloatPartsN *p, float_status *s,
                 break;
             case float_expmax_e4m3:
                 partsN(uncanon_e4m3_overflow)(p, s, fmt, saturate);
+                frac_shr(p, fmt->frac_shift);
                 break;
             case float_expmax_normal:
             default:
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 08/17] fpu: Fix unexpected exception flags when converting infinity to OCP E4M3
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (6 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 07/17] fpu: Fix repacking issues in the uncanonical step for E4M3 overflow alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 09/17] hw/riscv/riscv-iommu: Free instance_init allocations in instance_finalize alistair23
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: alistair23, Max Chou, Chao Liu, Richard Henderson,
	Alistair Francis

From: Max Chou <max.chou@sifive.com>

Infinity is a special case distinct from numeric overflow:
- Numeric overflow: finite value exceeds format's max normal
  -> overflow|inexact
- Infinity conversion: input is already infinite
  -> no flags

This commit fixes the unexpect exception flags by relocating the float
exception flag update flow to be outside the uncanon_e4m3_overflow.
And raising the overflow|inexact for numeric overflow in uncanon_normal.

Fixes: 27e989f99c ("fpu: Add conversion routines for OCP FP8 E4M3")
Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Max Chou <max.chou@sifive.com>
Message-ID: <20260226071817.1417875-3-max.chou@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 fpu/softfloat-parts.c.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index a738758aee..3c323c0cec 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -277,7 +277,6 @@ static void partsN(uncanon_e4m3_overflow)(FloatPartsN *p, float_status *s,
                                           const FloatFmt *fmt, bool saturate)
 {
     assert(N == 64);
-    float_raise(float_flag_overflow | float_flag_inexact, s);
     if (saturate) {
         p->exp = fmt->exp_max;
         p->frac_hi = E4M3_NORMAL_FRAC_MAX;
@@ -388,6 +387,7 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
                 if (exp > exp_max || p->frac_hi > E4M3_NORMAL_FRAC_MAX) {
                     partsN(uncanon_e4m3_overflow)(p, s, fmt, overflow_norm);
                     exp = p->exp;
+                    flags |= (float_flag_overflow | float_flag_inexact);
                 }
                 break;
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 09/17] hw/riscv/riscv-iommu: Free instance_init allocations in instance_finalize
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (7 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 08/17] fpu: Fix unexpected exception flags when converting infinity to OCP E4M3 alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 10/17] target/riscv: Support Smpmpmt extension alistair23
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: alistair23, Peter Maydell, Alistair Francis, Chao Liu,
	Philippe Mathieu-Daudé

From: Peter Maydell <peter.maydell@linaro.org>

The riscv-iommu device makes various allocations in its
instance_init method. These will leak when QMP inits an
object of this type to introspect it, as can be seen if you
run 'make check' with the address sanitizer enabled:

Direct leak of 4096 byte(s) in 1 object(s) allocated from:
    #0 0x5d8415b6ed9d in calloc (/home/pm215/qemu/build/san/qemu-system-riscv32+0x1832d9d) (BuildId: fedcc313e48ba803d63837329c37fd609dd50849)
    #1 0x75c0502f1771 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x63771) (BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
    #2 0x5d8416d09391 in riscv_iommu_instance_init /home/pm215/qemu/build/san/../../hw/riscv/riscv-iommu.c:2463:18
    #3 0x5d841710483f in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5
    #4 0x5d8417104ee9 in object_initialize /home/pm215/qemu/build/san/../../qom/object.c:578:5
    #5 0x5d8417104ee9 in object_initialize_child_with_propsv /home/pm215/qemu/build/san/../../qom/object.c:608:5
    #6 0x5d8417104db1 in object_initialize_child_with_props /home/pm215/qemu/build/san/../../qom/object.c:591:10
    #7 0x5d8417106506 in object_initialize_child_internal /home/pm215/qemu/build/san/../../qom/object.c:645:5
    #8 0x5d8416d16a12 in riscv_iommu_sys_init /home/pm215/qemu/build/san/../../hw/riscv/riscv-iommu-sys.c:199:5
    #9 0x5d841710483f in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5
    #10 0x5d841710661f in object_new_with_type /home/pm215/qemu/build/san/../../qom/object.c:774:5
    #11 0x5d841755d956 in qmp_device_list_properties /home/pm215/qemu/build/san/../../qom/qom-qmp-cmds.c:206:11

(and other similar backtraces).

Fix these by freeing the resources we allocate in instance_init in
instance_finalize.  In some cases we were freeing these in unrealize,
and in some cases not at all.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260307125222.3656140-1-peter.maydell@linaro.org>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 hw/riscv/riscv-iommu.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c
index 98345b1280..225394ea83 100644
--- a/hw/riscv/riscv-iommu.c
+++ b/hw/riscv/riscv-iommu.c
@@ -2479,6 +2479,18 @@ static void riscv_iommu_instance_init(Object *obj)
     QLIST_INIT(&s->spaces);
 }
 
+static void riscv_iommu_instance_finalize(Object *obj)
+{
+    RISCVIOMMUState *s = RISCV_IOMMU(obj);
+
+    g_free(s->regs_rw);
+    g_free(s->regs_ro);
+    g_free(s->regs_wc);
+
+    g_hash_table_unref(s->ctx_cache);
+    g_hash_table_unref(s->iot_cache);
+}
+
 static void riscv_iommu_realize(DeviceState *dev, Error **errp)
 {
     RISCVIOMMUState *s = RISCV_IOMMU(dev);
@@ -2597,9 +2609,6 @@ static void riscv_iommu_unrealize(DeviceState *dev)
 {
     RISCVIOMMUState *s = RISCV_IOMMU(dev);
 
-    g_hash_table_unref(s->iot_cache);
-    g_hash_table_unref(s->ctx_cache);
-
     if (s->cap & RISCV_IOMMU_CAP_HPM) {
         g_hash_table_unref(s->hpm_event_ctr_map);
         timer_free(s->hpm_timer);
@@ -2675,6 +2684,7 @@ static const TypeInfo riscv_iommu_info = {
     .parent = TYPE_DEVICE,
     .instance_size = sizeof(RISCVIOMMUState),
     .instance_init = riscv_iommu_instance_init,
+    .instance_finalize = riscv_iommu_instance_finalize,
     .class_init = riscv_iommu_class_init,
 };
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 10/17] target/riscv: Support Smpmpmt extension
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (8 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 09/17] hw/riscv/riscv-iommu: Free instance_init allocations in instance_finalize alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 11/17] hw/char: sifive_uart: Implement txctrl.txen and rxctrl.rxen alistair23
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: alistair23, Jay Chang, Daniel Henrique Barboza, Frank Chang,
	Alistair Francis

From: Jay Chang <jay.chang@sifive.com>

The Smpmpmt extension provides a mechanism to control memory attributes
at the granularity of PMP (Physical Memory Protection) registers, similar
to how Svpbmt controls memory attributes at the page level.

Version 0.6
https://github.com/riscv/riscv-isa-manual/blob/smpmpmt/src/smpmpmt.adoc#svpbmt

Signed-off-by: Jay Chang <jay.chang@sifive.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Frank Chang <frank.chang@sifive.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260305034429.74739-1-jay.chang@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/pmp.h                |  1 +
 target/riscv/cpu_cfg_fields.h.inc |  1 +
 target/riscv/cpu.c                |  2 ++
 target/riscv/pmp.c                | 16 ++++++++++++++++
 4 files changed, 20 insertions(+)

diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h
index 271cf24169..467fb6b4b1 100644
--- a/target/riscv/pmp.h
+++ b/target/riscv/pmp.h
@@ -29,6 +29,7 @@ typedef enum {
     PMP_WRITE = 1 << 1,
     PMP_EXEC  = 1 << 2,
     PMP_AMATCH = (3 << 3),
+    PMP_MTMATCH = (3 << 5),
     PMP_LOCK  = 1 << 7
 } pmp_priv_t;
 
diff --git a/target/riscv/cpu_cfg_fields.h.inc b/target/riscv/cpu_cfg_fields.h.inc
index 70ec650abf..cd1a5ec56b 100644
--- a/target/riscv/cpu_cfg_fields.h.inc
+++ b/target/riscv/cpu_cfg_fields.h.inc
@@ -59,6 +59,7 @@ BOOL_FIELD(ext_svadu)
 BOOL_FIELD(ext_svinval)
 BOOL_FIELD(ext_svnapot)
 BOOL_FIELD(ext_svpbmt)
+BOOL_FIELD(ext_smpmpmt)
 BOOL_FIELD(ext_svrsw60t59b)
 BOOL_FIELD(ext_svvptc)
 BOOL_FIELD(ext_svukte)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 9be79622f4..8ac935ac06 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -223,6 +223,7 @@ const RISCVIsaExtData isa_edata_arr[] = {
     ISA_EXT_DATA_ENTRY(smcsrind, PRIV_VERSION_1_13_0, ext_smcsrind),
     ISA_EXT_DATA_ENTRY(smdbltrp, PRIV_VERSION_1_13_0, ext_smdbltrp),
     ISA_EXT_DATA_ENTRY(smepmp, PRIV_VERSION_1_12_0, ext_smepmp),
+    ISA_EXT_DATA_ENTRY(smpmpmt, PRIV_VERSION_1_12_0, ext_smpmpmt),
     ISA_EXT_DATA_ENTRY(smrnmi, PRIV_VERSION_1_12_0, ext_smrnmi),
     ISA_EXT_DATA_ENTRY(smmpm, PRIV_VERSION_1_13_0, ext_smmpm),
     ISA_EXT_DATA_ENTRY(smnpm, PRIV_VERSION_1_13_0, ext_smnpm),
@@ -1276,6 +1277,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {
     MULTI_EXT_CFG_BOOL("smaia", ext_smaia, false),
     MULTI_EXT_CFG_BOOL("smdbltrp", ext_smdbltrp, false),
     MULTI_EXT_CFG_BOOL("smepmp", ext_smepmp, false),
+    MULTI_EXT_CFG_BOOL("smpmpmt", ext_smpmpmt, false),
     MULTI_EXT_CFG_BOOL("smrnmi", ext_smrnmi, false),
     MULTI_EXT_CFG_BOOL("smmpm", ext_smmpm, false),
     MULTI_EXT_CFG_BOOL("smnpm", ext_smnpm, false),
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
index 3ef62d26ad..5391caa59c 100644
--- a/target/riscv/pmp.c
+++ b/target/riscv/pmp.c
@@ -165,6 +165,18 @@ static bool pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val)
                           "ignoring pmpcfg write - invalid\n");
         } else {
             uint8_t a_field = pmp_get_a_field(val);
+
+            if (!riscv_cpu_cfg(env)->ext_smpmpmt) {
+                /* If smpmpmt not supported, clear the MTMATCH bit */
+                val &= ~PMP_MTMATCH;
+            } else if ((val & PMP_MTMATCH) == PMP_MTMATCH) {
+                /*
+                 * If trying to set reserved value (0x3) for MT field,
+                 * preserve the original MT field from current config.
+                 */
+                val = (val & ~PMP_MTMATCH) |
+                    (env->pmp_state.pmp[pmp_index].cfg_reg & PMP_MTMATCH);
+            }
             /*
              * When granularity g >= 1 (i.e., granularity > 4 bytes),
              * the NA4 (Naturally Aligned 4-byte) mode is not selectable
@@ -355,6 +367,10 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, pmp_priv_t privs,
  * Check if the address has required RWX privs to complete desired operation
  * Return true if a pmp rule match or default match
  * Return false if no match
+ *
+ * Note: The MT (Memory Type) field from Smpmpmt extension is stored in
+ * pmpcfg but is not acted upon during access checks. Cache attributes
+ * have no functional impact in QEMU emulation.
  */
 bool pmp_hart_has_privs(CPURISCVState *env, hwaddr addr,
                         target_ulong size, pmp_priv_t privs,
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 11/17] hw/char: sifive_uart: Implement txctrl.txen and rxctrl.rxen
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (9 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 10/17] target/riscv: Support Smpmpmt extension alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 12/17] hw/char: sifive_uart: Sync txwm interrupt pending status after TX FIFO enqueue alistair23
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair23, Frank Chang, Alistair Francis

From: Frank Chang <frank.chang@sifive.com>

Implement txctrl.txen and rxctrl.rxen as follows:

* txctrl.txen
  The txen bit controls whether the Tx channel is active. When cleared,
  transmission of Tx FIFO contents is suppressed, and the txd pin is
  driven high.

* rxctrl.rxen:
  The rxen bit controls whether the Rx channel is active. When cleared,
  the state of the rxd pin is ignored, and no characters will be
  enqueued into the Rx FIFO.

Therefore, the Tx FIFO should not be dequeued when txctrl.txen is
cleared, and the Rx FIFO should not be enqueued when rxctrl.rxen is
cleared.

Signed-off-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260312033201.1619554-2-frank.chang@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 include/hw/char/sifive_uart.h |  2 ++
 hw/char/sifive_uart.c         | 27 ++++++++++++++++++++-------
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/include/hw/char/sifive_uart.h b/include/hw/char/sifive_uart.h
index 414564b026..c78d9bd1fc 100644
--- a/include/hw/char/sifive_uart.h
+++ b/include/hw/char/sifive_uart.h
@@ -51,6 +51,8 @@ enum {
 
 #define SIFIVE_UART_TXFIFO_FULL    0x80000000
 
+#define SIFIVE_UART_TXEN(txctrl)        (txctrl & 0x1)
+#define SIFIVE_UART_RXEN(rxctrl)        (rxctrl & 0x1)
 #define SIFIVE_UART_GET_TXCNT(txctrl)   ((txctrl >> 16) & 0x7)
 #define SIFIVE_UART_GET_RXCNT(rxctrl)   ((rxctrl >> 16) & 0x7)
 
diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c
index af17cf9a6c..3ce6a4ee76 100644
--- a/hw/char/sifive_uart.c
+++ b/hw/char/sifive_uart.c
@@ -78,6 +78,11 @@ static gboolean sifive_uart_xmit(void *do_not_use, GIOCondition cond,
         return G_SOURCE_REMOVE;
     }
 
+    /* Don't pop the FIFO if transmit is disabled. */
+    if (!SIFIVE_UART_TXEN(s->txctrl)) {
+        return G_SOURCE_REMOVE;
+    }
+
     /* Don't pop the FIFO in case the write fails */
     characters = fifo8_peek_bufptr(&s->tx_fifo,
                                    fifo8_num_used(&s->tx_fifo), &numptr);
@@ -106,11 +111,19 @@ static gboolean sifive_uart_xmit(void *do_not_use, GIOCondition cond,
     return G_SOURCE_REMOVE;
 }
 
-static void sifive_uart_write_tx_fifo(SiFiveUARTState *s, const uint8_t *buf,
-                                      int size)
+static void sifive_uart_trigger_tx_fifo(SiFiveUARTState *s)
 {
     uint64_t current_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
 
+    if (!timer_pending(s->fifo_trigger_handle)) {
+        timer_mod(s->fifo_trigger_handle, current_time +
+            TX_INTERRUPT_TRIGGER_DELAY_NS);
+    }
+}
+
+static void sifive_uart_write_tx_fifo(SiFiveUARTState *s, const uint8_t *buf,
+                                      int size)
+{
     if (size > fifo8_num_free(&s->tx_fifo)) {
         size = fifo8_num_free(&s->tx_fifo);
         qemu_log_mask(LOG_GUEST_ERROR, "sifive_uart: TX FIFO overflow.\n");
@@ -124,10 +137,7 @@ static void sifive_uart_write_tx_fifo(SiFiveUARTState *s, const uint8_t *buf,
         s->txfifo |= SIFIVE_UART_TXFIFO_FULL;
     }
 
-    if (!timer_pending(s->fifo_trigger_handle)) {
-        timer_mod(s->fifo_trigger_handle, current_time +
-                      TX_INTERRUPT_TRIGGER_DELAY_NS);
-    }
+    sifive_uart_trigger_tx_fifo(s);
 }
 
 static uint64_t
@@ -184,6 +194,9 @@ sifive_uart_write(void *opaque, hwaddr addr,
         return;
     case SIFIVE_UART_TXCTRL:
         s->txctrl = val64;
+        if (SIFIVE_UART_TXEN(s->txctrl) && !fifo8_is_empty(&s->tx_fifo)) {
+            sifive_uart_trigger_tx_fifo(s);
+        }
         return;
     case SIFIVE_UART_RXCTRL:
         s->rxctrl = val64;
@@ -231,7 +244,7 @@ static int sifive_uart_can_rx(void *opaque)
 {
     SiFiveUARTState *s = opaque;
 
-    return s->rx_fifo_len < sizeof(s->rx_fifo);
+    return SIFIVE_UART_RXEN(s->rxctrl) && (s->rx_fifo_len < sizeof(s->rx_fifo));
 }
 
 static void sifive_uart_event(void *opaque, QEMUChrEvent event)
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 12/17] hw/char: sifive_uart: Sync txwm interrupt pending status after TX FIFO enqueue
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (10 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 11/17] hw/char: sifive_uart: Implement txctrl.txen and rxctrl.rxen alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 13/17] hw/char: sifive_uart: Update IRQ when rxctrl is written alistair23
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair23, Frank Chang, Alistair Francis

From: Frank Chang <frank.chang@sifive.com>

Currently, the txwm interrupt pending status is only updated when the
asynchronous transmit handler runs. This can cause the txwm interrupt
state to become unsynchronized between the SiFive UART and the
interrupt controller.

For example, when a txwm interrupt is raised, the corresponding APLIC
pending bit is also set. However, if software later enqueues additional
characters into the TX FIFO exceeding the transmit watermark, the
APLIC pending bit may remain set because the txwm interrupt pending
status is not updated at enqueue time.

This issue has been observed on resource-constrained machines, where
Linux reports spurious IRQ errors. In these cases, the asynchronous
transmit handler is unable to drain the TX FIFO quickly enough to update
the txwm pending status before software reads the ip register, which
derives the txwm pending state directly from the actual number of
characters in the TX FIFO.

This commit fixes the issue by updating the txwm interrupt pending
status immediately after enqueuing data into the TX FIFO, ensuring that
the interrupt pending status between the SiFive UART and the interrupt
controller remains synchronized.

Signed-off-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260312033201.1619554-3-frank.chang@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 hw/char/sifive_uart.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c
index 3ce6a4ee76..ae71a15a2a 100644
--- a/hw/char/sifive_uart.c
+++ b/hw/char/sifive_uart.c
@@ -124,12 +124,20 @@ static void sifive_uart_trigger_tx_fifo(SiFiveUARTState *s)
 static void sifive_uart_write_tx_fifo(SiFiveUARTState *s, const uint8_t *buf,
                                       int size)
 {
+    uint32_t txcnt = SIFIVE_UART_GET_TXCNT(s->txctrl);
+    bool update_irq = false;
+
     if (size > fifo8_num_free(&s->tx_fifo)) {
         size = fifo8_num_free(&s->tx_fifo);
         qemu_log_mask(LOG_GUEST_ERROR, "sifive_uart: TX FIFO overflow.\n");
     }
 
     if (size > 0) {
+        if (fifo8_num_used(&s->tx_fifo) < txcnt &&
+            (fifo8_num_used(&s->tx_fifo) + size) >= txcnt) {
+            update_irq = true;
+        }
+
         fifo8_push_all(&s->tx_fifo, buf, size);
     }
 
@@ -137,6 +145,14 @@ static void sifive_uart_write_tx_fifo(SiFiveUARTState *s, const uint8_t *buf,
         s->txfifo |= SIFIVE_UART_TXFIFO_FULL;
     }
 
+    /*
+     * Update txwm interrupt pending status when the number of entries
+     * in the transmit FIFO crosses or reaches the watermark.
+     */
+    if (update_irq) {
+        sifive_uart_update_irq(s);
+    }
+
     sifive_uart_trigger_tx_fifo(s);
 }
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 13/17] hw/char: sifive_uart: Update IRQ when rxctrl is written
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (11 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 12/17] hw/char: sifive_uart: Sync txwm interrupt pending status after TX FIFO enqueue alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 14/17] hw/char: sifive_uart: Remove ip variable alistair23
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair23, Frank Chang, Alistair Francis

From: Frank Chang <frank.chang@sifive.com>

When rxctl is updated, we also need to check whether the IRQ should be
raised, as the user may activate the Rx channel or change the Rx FIFO
watermark level.

Signed-off-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260312033201.1619554-4-frank.chang@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 hw/char/sifive_uart.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c
index ae71a15a2a..f255cca960 100644
--- a/hw/char/sifive_uart.c
+++ b/hw/char/sifive_uart.c
@@ -216,6 +216,7 @@ sifive_uart_write(void *opaque, hwaddr addr,
         return;
     case SIFIVE_UART_RXCTRL:
         s->rxctrl = val64;
+        sifive_uart_update_irq(s);
         return;
     case SIFIVE_UART_DIV:
         s->div = val64;
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 14/17] hw/char: sifive_uart: Remove ip variable
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (12 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 13/17] hw/char: sifive_uart: Update IRQ when rxctrl is written alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 15/17] target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses alistair23
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair23, Frank Chang, Alistair Francis

From: Frank Chang <frank.chang@sifive.com>

The ip variable is no longer used in the code. Remove it from the
codebase.

Signed-off-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260312033201.1619554-5-frank.chang@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 include/hw/char/sifive_uart.h | 1 -
 hw/char/sifive_uart.c         | 6 ++----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/include/hw/char/sifive_uart.h b/include/hw/char/sifive_uart.h
index c78d9bd1fc..5f3b1327de 100644
--- a/include/hw/char/sifive_uart.h
+++ b/include/hw/char/sifive_uart.h
@@ -73,7 +73,6 @@ struct SiFiveUARTState {
 
     uint32_t txfifo;
     uint32_t ie;
-    uint32_t ip;
     uint32_t txctrl;
     uint32_t rxctrl;
     uint32_t div;
diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c
index f255cca960..4c30fbf568 100644
--- a/hw/char/sifive_uart.c
+++ b/hw/char/sifive_uart.c
@@ -285,7 +285,6 @@ static void sifive_uart_reset_enter(Object *obj, ResetType type)
 
     s->txfifo = 0;
     s->ie = 0;
-    s->ip = 0;
     s->txctrl = 0;
     s->rxctrl = 0;
     s->div = 0;
@@ -343,14 +342,13 @@ static void sifive_uart_reset_hold(Object *obj, ResetType type)
 
 static const VMStateDescription vmstate_sifive_uart = {
     .name = TYPE_SIFIVE_UART,
-    .version_id = 2,
-    .minimum_version_id = 2,
+    .version_id = 3,
+    .minimum_version_id = 3,
     .fields = (const VMStateField[]) {
         VMSTATE_UINT8_ARRAY(rx_fifo, SiFiveUARTState,
                             SIFIVE_UART_RX_FIFO_SIZE),
         VMSTATE_UINT8(rx_fifo_len, SiFiveUARTState),
         VMSTATE_UINT32(ie, SiFiveUARTState),
-        VMSTATE_UINT32(ip, SiFiveUARTState),
         VMSTATE_UINT32(txctrl, SiFiveUARTState),
         VMSTATE_UINT32(rxctrl, SiFiveUARTState),
         VMSTATE_UINT32(div, SiFiveUARTState),
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 15/17] target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (13 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 14/17] hw/char: sifive_uart: Remove ip variable alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 16/17] target/riscv: rvv: Fix page probe issues in vext_ldff alistair23
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair23, Max Chou, Alistair Francis

From: Max Chou <max.chou@sifive.com>

When probe_pages probes a memory region that spans two pages, it calls
probe_access_flags twice - once for each page. However, the flags from
the second page probe were overwriting the flags from the first page
instead of being merged together.

Signed-off-by: Max Chou <max.chou@sifive.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260318013805.1920377-2-max.chou@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/vector_helper.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index caa8dd9c12..e60248d6d3 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -151,9 +151,9 @@ static void probe_pages(CPURISCVState *env, target_ulong addr, target_ulong len,
         addr += curlen;
         curlen = len - curlen;
         if (flags != NULL) {
-            *flags = probe_access_flags(env, adjust_addr(env, addr), curlen,
-                                        access_type, mmu_index, nonfault,
-                                        host, ra);
+            *flags |= probe_access_flags(env, adjust_addr(env, addr), curlen,
+                                         access_type, mmu_index, nonfault,
+                                         host, ra);
         } else {
             probe_access(env, adjust_addr(env, addr), curlen, access_type,
                          mmu_index, ra);
@@ -161,7 +161,6 @@ static void probe_pages(CPURISCVState *env, target_ulong addr, target_ulong len,
     }
 }
 
-
 static inline void vext_set_elem_mask(void *v0, int index,
                                       uint8_t value)
 {
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 16/17] target/riscv: rvv: Fix page probe issues in vext_ldff
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (14 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 15/17] target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-19 23:25 ` [PULL 17/17] target/riscv: Fix scountovf CSR behavior in VS-mode and M-mode alistair23
  2026-03-20 11:49 ` [PULL 00/17] riscv-to-apply queue Peter Maydell
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair23, Max Chou, Alistair Francis

From: Max Chou <max.chou@sifive.com>

Commit 17288e38bebf ("optimize the memory probing for vector
fault-only-first loads") introduced an optimization that moved from
per-element probing to a fast-path broad probe. Unfortunately it
introduced following bugs in cross-page handling:

- Wrong condition for second page probing: checked "env->vl > elems"
  instead of "env->vl > elems + env->vstart", failing to account for
  the vstart offset.

- Incorrect second page address calculation: used
  "addr + (elems << log2_esz)" instead of "addr + page_split".
  For segment loads (nf > 1), this would probe the wrong address,not
  at the page boundary.

- Wrong second page probe size: used "elems * msize" (the first page
  size) instead of calculating the remaining size as
  "(env->vl - env->vstart) * msize - page_split". This would probe
  too little memory and could miss faults.

This commit fixes these bugs by leveraging the probe_pages helper
which automatically handles cross-page memory accesses correctly.

Fixes: 17288e38bebf ("optimize the memory probing for vector fault-only-first loads.")

Signed-off-by: Max Chou <max.chou@sifive.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260318013805.1920377-3-max.chou@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/vector_helper.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index e60248d6d3..83dd26314d 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -658,9 +658,9 @@ vext_ldff(void *vd, void *v0, target_ulong base, CPURISCVState *env,
     uint32_t esz = 1 << log2_esz;
     uint32_t msize = nf * esz;
     uint32_t vma = vext_vma(desc);
-    target_ulong addr, addr_probe, addr_i, offset, remain, page_split, elems;
+    target_ulong addr, addr_i, offset, remain, page_split, elems;
     int mmu_index = riscv_env_mmu_index(env, false);
-    int flags, probe_flags;
+    int flags;
     void *host;
 
     VSTART_CHECK_EARLY_EXIT(env, env->vl);
@@ -674,16 +674,8 @@ vext_ldff(void *vd, void *v0, target_ulong base, CPURISCVState *env,
     }
 
     /* Check page permission/pmp/watchpoint/etc. */
-    probe_pages(env, addr, elems * msize, ra, MMU_DATA_LOAD, mmu_index, &host,
-                &flags, true);
-
-    /* If we are crossing a page check also the second page. */
-    if (env->vl > elems) {
-        addr_probe = addr + (elems << log2_esz);
-        probe_pages(env, addr_probe, elems * msize, ra, MMU_DATA_LOAD,
-                    mmu_index, &host, &probe_flags, true);
-        flags |= probe_flags;
-    }
+    probe_pages(env, addr, (env->vl - env->vstart) * msize, ra, MMU_DATA_LOAD,
+                mmu_index, &host, &flags, true);
 
     if (flags & ~TLB_WATCHPOINT) {
         /* probe every access */
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PULL 17/17] target/riscv: Fix scountovf CSR behavior in VS-mode and M-mode
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (15 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 16/17] target/riscv: rvv: Fix page probe issues in vext_ldff alistair23
@ 2026-03-19 23:25 ` alistair23
  2026-03-20 11:49 ` [PULL 00/17] riscv-to-apply queue Peter Maydell
  17 siblings, 0 replies; 19+ messages in thread
From: alistair23 @ 2026-03-19 23:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair23, Jim Shu, Max Chou, Alistair Francis

From: Jim Shu <jim.shu@sifive.com>

From Sscofpmf spec [1]:
- In M-mode, scountovf bit X is always readable.
- in VS mode, scountovf bit X is readable when mcounteren bit X and
  hcounteren bit X are both set, and otherwise reads as zero.

[1] https://github.com/riscv/riscv-isa-manual/blob/main/src/sscofpmf.adoc

Signed-off-by: Jim Shu <jim.shu@sifive.com>
Signed-off-by: Max Chou <max.chou@sifive.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260318024234.2772480-1-jim.shu@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 target/riscv/csr.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index 5064483917..a75281539b 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -1599,6 +1599,7 @@ static RISCVException read_scountovf(CPURISCVState *env, int csrno,
     int mhpmevt_start = CSR_MHPMEVENT3 - CSR_MCOUNTINHIBIT;
     int i;
     *val = 0;
+    bool virt = env->virt_enabled;
 
     /* Virtualize scountovf for counter delegation */
     if (riscv_cpu_cfg(env)->ext_sscofpmf &&
@@ -1609,8 +1610,19 @@ static RISCVException read_scountovf(CPURISCVState *env, int csrno,
     }
 
     for (i = mhpmevt_start; i < RV_MAX_MHPMEVENTS; i++) {
-        if ((get_field(env->mcounteren, BIT(i))) &&
-            (env->mhpmevent_val[i] & MHPMEVENT_BIT_OF)) {
+        if (env->priv < PRV_M) {
+            if (!get_field(env->mcounteren, BIT(i))) {
+                /* no mcounteren in S/HS-mode */
+                continue;
+            }
+
+            if (virt && !get_field(env->hcounteren, BIT(i))) {
+                /* no hcounteren in VS-mode */
+                continue;
+            }
+        }
+
+        if (env->mhpmevent_val[i] & MHPMEVENT_BIT_OF) {
             *val |= BIT(i);
         }
     }
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PULL 00/17] riscv-to-apply queue
  2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
                   ` (16 preceding siblings ...)
  2026-03-19 23:25 ` [PULL 17/17] target/riscv: Fix scountovf CSR behavior in VS-mode and M-mode alistair23
@ 2026-03-20 11:49 ` Peter Maydell
  17 siblings, 0 replies; 19+ messages in thread
From: Peter Maydell @ 2026-03-20 11:49 UTC (permalink / raw)
  To: alistair23; +Cc: qemu-devel, Alistair Francis

On Thu, 19 Mar 2026 at 23:27, <alistair23@gmail.com> wrote:
>
> From: Alistair Francis <alistair.francis@wdc.com>
>
> The following changes since commit 5a68a3add61208aad34d47134fdcfd3f407d2ce4:
>
>   Update version for v11.0.0-rc0 release (2026-03-18 15:56:51 +0000)
>
> are available in the Git repository at:
>
>   https://github.com/alistair23/qemu.git tags/pull-riscv-to-apply-20260320
>
> for you to fetch changes up to 38937473da3ebdd89bbe6bbc3effc0b153ceb414:
>
>   target/riscv: Fix scountovf CSR behavior in VS-mode and M-mode (2026-03-20 08:41:15 +1000)
>
> ----------------------------------------------------------------
> RISC-V PR for 11.
>
> * Fix integer overflow in cm_base calculation
> * Fix null pointer dereference in cpu_set_exception_base
> * Update Daniel Henrique Barboza's email
> * Add Chao Liu as reviewer
> * Set SiFive PDMA done bit upon completion
> * Remove deprecated 'riscv, delegate' device-tree property
> * Fix OCP FP8 E4M3 conversion issues
> * Fix IOMMU instance_init allocations in instance_finalize
> * Support Smpmpmt extension
> * Fix SiFive UART spurious IRQ issue and misc updates
> * Fix missing flags merge in probe_pages for cross-page accesses
> * Fix page probe issues in vext_ldff
> * Fix scountovf CSR behavior in VS-mode and M-mode
>
> ----------------------------------------------------------------



Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/11.0
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-03-20 11:50 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 23:25 [PULL 00/17] riscv-to-apply queue alistair23
2026-03-19 23:25 ` [PULL 01/17] hw/riscv: Fix integer overflow in cm_base calculation alistair23
2026-03-19 23:25 ` [PULL 02/17] target/riscv: Fix null pointer dereference in cpu_set_exception_base alistair23
2026-03-19 23:25 ` [PULL 03/17] MAINTAINERS: update my email alistair23
2026-03-19 23:25 ` [PULL 04/17] MAINTAINERS: Add myself as a reviewer for RISC-V TCG CPUs alistair23
2026-03-19 23:25 ` [PULL 05/17] hw/dma: sifive_pdma: Set done bit upon completion alistair23
2026-03-19 23:25 ` [PULL 06/17] hw/riscv: Remove deprecated 'riscv, delegate' device-tree property alistair23
2026-03-19 23:25 ` [PULL 07/17] fpu: Fix repacking issues in the uncanonical step for E4M3 overflow alistair23
2026-03-19 23:25 ` [PULL 08/17] fpu: Fix unexpected exception flags when converting infinity to OCP E4M3 alistair23
2026-03-19 23:25 ` [PULL 09/17] hw/riscv/riscv-iommu: Free instance_init allocations in instance_finalize alistair23
2026-03-19 23:25 ` [PULL 10/17] target/riscv: Support Smpmpmt extension alistair23
2026-03-19 23:25 ` [PULL 11/17] hw/char: sifive_uart: Implement txctrl.txen and rxctrl.rxen alistair23
2026-03-19 23:25 ` [PULL 12/17] hw/char: sifive_uart: Sync txwm interrupt pending status after TX FIFO enqueue alistair23
2026-03-19 23:25 ` [PULL 13/17] hw/char: sifive_uart: Update IRQ when rxctrl is written alistair23
2026-03-19 23:25 ` [PULL 14/17] hw/char: sifive_uart: Remove ip variable alistair23
2026-03-19 23:25 ` [PULL 15/17] target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses alistair23
2026-03-19 23:25 ` [PULL 16/17] target/riscv: rvv: Fix page probe issues in vext_ldff alistair23
2026-03-19 23:25 ` [PULL 17/17] target/riscv: Fix scountovf CSR behavior in VS-mode and M-mode alistair23
2026-03-20 11:49 ` [PULL 00/17] riscv-to-apply queue Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox