[RFC PATCH 1/3] target/arm: Implement FEAT_NMI to support Non-maskable Interrupt

2024-02-20 Thread Jinjie Ruan via
Enable Non-maskable Interrupt feature. Enable HCRX register feature to support TALLINT read/write. Add support for enable/disable NMI at qemu startup as below: qemu-system-aarch64 -cpu cortex-a53/a57/a72/a76,nmi=[on/off] Add support for allint read/write as follow: mrs ,

[RFC PATCH 3/3] hw/intc/arm_gicv3: Implement FEAT_GICv3_NMI feature to support FEAT_NMI

2024-02-20 Thread Jinjie Ruan via
Connect NMI wire from GICv3 to every Arm PE. +-+ | Distributor | +-+ | NMI | NMI

[RFC PATCH 2/3] target/arm: Add NMI exception and handle PSTATE.ALLINT on taking an exception

2024-02-20 Thread Jinjie Ruan via
Add a new exception called NMI for Arm PE. Set/clear PSTATE.ALLINT on taking an exception to ELx according to the SCTLR_ELx.SPINTMASK bit. Mask IRQ/FIQ/NMI with ALLINT and PSTATE.SP & SCTLR_SPINTMASK in addition to PSTATE.DAIF. Save to and restore from SPSR_ELx with PSTATE.ALLINT on taking an

[RFC PATCH 0/3] target/arm: Implement FEAT_NMI and FEAT_GICv3_NMI

2024-02-20 Thread Jinjie Ruan via
This patch set implements FEAT_NMI and FEAT_GICv3_NMI for armv8. These introduce support for a new category of interrupts in the architecture which we can use to provide NMI like functionality. There are two modes for using this FEAT_NMI. When PSTATE.ALLINT or PSTATE.SP &

Re: [RFC PATCH 1/3] target/arm: Implement FEAT_NMI to support Non-maskable Interrupt

2024-02-20 Thread Jinjie Ruan via
On 2024/2/20 20:31, Peter Maydell wrote: > On Tue, 20 Feb 2024 at 12:19, Jinjie Ruan wrote: >> >> Enable Non-maskable Interrupt feature. >> >> Enable HCRX register feature to support TALLINT read/write. >> >> Add support for enable/disable NMI at qemu startup as below: >> >>

[RFC PATCH v2 03/22] target/arm: Add PSTATE.ALLINT

2024-02-21 Thread Jinjie Ruan via
The ALLINT bit in PSTATE is used to mask all IRQ or FIQ interrupts. Place this in its own field within ENV, as that will make it easier to reset from within TCG generated code. With the change to pstate_read/write, exception entry and return are automatically handled. Signed-off-by: Jinjie Ruan

[RFC PATCH v2 21/22] hw/intc/arm_gicv3: Implement NMI interrupt prioirty

2024-02-21 Thread Jinjie Ruan via
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI prioirty is higher than 0x80, otherwise it is higher than 0x0. And save NMI super prioirty information in hppi.superprio to deliver NMI exception. Since both GICR and GICD can deliver NMI, it is both necessary to check whether the

[RFC PATCH v2 18/22] hw/arm/virt: Add FEAT_GICv3_NMI feature support in virt GIC

2024-02-21 Thread Jinjie Ruan via
Included support FEAT_GICv3_NMI feature as part of virt platform GIC initialization. Signed-off-by: Jinjie Ruan --- hw/arm/virt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index c442652d0f..0359dbd8bd 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@

[RFC PATCH v2 14/22] target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()

2024-02-21 Thread Jinjie Ruan via
The NMI exception trap entry behave like IRQ or FIQ which depends on the NMI interrupt type. Signed-off-by: Jinjie Ruan --- target/arm/helper.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 952ea7c02a..ac5f998e32 100644 ---

[RFC PATCH v2 00/22] target/arm: Implement FEAT_NMI and FEAT_GICv3_NMI

2024-02-21 Thread Jinjie Ruan via
This patch set implements FEAT_NMI and FEAT_GICv3_NMI for armv8. These introduce support for a new category of interrupts in the architecture which we can use to provide NMI like functionality. There are two modes for using this FEAT_NMI. When PSTATE.ALLINT or PSTATE.SP &

[RFC PATCH v2 05/22] target/arm: Support MSR access to ALLINT

2024-02-21 Thread Jinjie Ruan via
Support ALLINT msr access as follow: mrs , ALLINT// read allint msr ALLINT, // write allint with imm Signed-off-by: Jinjie Ruan --- target/arm/helper.c | 32 1 file changed, 32 insertions(+) diff --git a/target/arm/helper.c

[RFC PATCH v2 20/22] hw/intc/arm_gicv3: Add NMI handling CPU interface registers

2024-02-21 Thread Jinjie Ruan via
Add the NMIAR CPU interface registers which deal with acknowledging NMI. When introduce NMI interrupt, there are some updates to the semantics for the register ICC_IAR1_EL1 and ICC_HPPIR1_EL1. For ICC_IAR1_EL1 register, it should return 1022 if the intid has super priority. And for ICC_NMIAR1_EL1

[RFC PATCH v2 13/22] hw/intc/arm_gicv3: Add external IRQ lines for NMI

2024-02-21 Thread Jinjie Ruan via
Augment the GICv3's QOM device interface by adding one new set of sysbus IRQ line, to signal NMI to each CPU. Signed-off-by: Jinjie Ruan --- hw/intc/arm_gicv3_common.c | 3 +++ include/hw/intc/arm_gic_common.h | 1 + include/hw/intc/arm_gicv3_common.h | 1 + 3 files changed, 5

[RFC PATCH v2 17/22] hw/intc: Enable FEAT_GICv3_NMI Feature

2024-02-21 Thread Jinjie Ruan via
Added properties to enable FEAT_GICv3_NMI feature, setup distributor and redistributor registers to indicate NMI support. Signed-off-by: Jinjie Ruan --- hw/intc/arm_gicv3_common.c | 1 + hw/intc/arm_gicv3_dist.c | 2 ++ hw/intc/gicv3_internal.h | 1 +

[RFC PATCH v2 15/22] hw/intc/arm_gicv3_redist: Implement GICR_INMIR0

2024-02-21 Thread Jinjie Ruan via
Add GICR_INMIR0 register and support access GICR_INMIR0. Signed-off-by: Jinjie Ruan --- hw/intc/arm_gicv3_redist.c | 23 +++ hw/intc/gicv3_internal.h | 1 + 2 files changed, 24 insertions(+) diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c index

[RFC PATCH v2 10/22] target/arm: Handle PSTATE.ALLINT on taking an exception

2024-02-21 Thread Jinjie Ruan via
Set or clear PSTATE.ALLINT on taking an exception to ELx according to the SCTLR_ELx.SPINTMASK bit. Signed-off-by: Jinjie Ruan --- target/arm/helper.c | 9 + 1 file changed, 9 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 62c8e5d611..952ea7c02a 100644 ---

[RFC PATCH v2 04/22] target/arm: Implement ALLINT MSR (immediate)

2024-02-21 Thread Jinjie Ruan via
Add ALLINT MSR (immediate) to decodetree. And the EL0 check is necessary to ALLINT. Avoid the unconditional write to pc and use raise_exception_ra to unwind. Signed-off-by: Jinjie Ruan --- target/arm/tcg/a64.decode | 1 + target/arm/tcg/helper-a64.c| 24

[RFC PATCH v2 11/22] target/arm: Set pstate.ALLINT in arm_cpu_reset_hold

2024-02-21 Thread Jinjie Ruan via
Set pstate.ALLINT in arm_cpu_reset_hold as daif do it. Signed-off-by: Jinjie Ruan --- target/arm/cpu.c | 4 1 file changed, 4 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 055670343e..e850763158 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -357,6 +357,10

[RFC PATCH v2 12/22] hw/arm/virt: Wire NMI irq line from GIC to CPU

2024-02-21 Thread Jinjie Ruan via
Wire the new NMI interrupt line from the GIC to each CPU. Signed-off-by: Jinjie Ruan --- hw/arm/virt.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0af1943697..c442652d0f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -804,7

[RFC PATCH v2 16/22] hw/intc/arm_gicv3: Implement GICD_INMIR

2024-02-21 Thread Jinjie Ruan via
Add GICD_INMIR0, GICD_INMIRnE register and support access GICD_INMIR0. Signed-off-by: Jinjie Ruan --- hw/intc/arm_gicv3_dist.c | 38 ++ hw/intc/gicv3_internal.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/hw/intc/arm_gicv3_dist.c

[RFC PATCH v2 02/22] target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI

2024-02-21 Thread Jinjie Ruan via
FEAT_NMI defines another new bit in HCRX_EL2: TALLINT. When the feature is enabled, allow this bit to be written in HCRX_EL2. Signed-off-by: Jinjie Ruan --- target/arm/cpu-features.h | 5 + target/arm/helper.c | 5 + 2 files changed, 10 insertions(+) diff --git

[RFC PATCH v2 07/22] target/arm: Add support for NMI event state

2024-02-21 Thread Jinjie Ruan via
The NMI exception state include whether the interrupt with super priority is IRQ or FIQ, so add a nmi_is_irq flag in CPUARMState to distinguish it. Signed-off-by: Jinjie Ruan --- target/arm/cpu.h| 2 ++ target/arm/helper.c | 9 + 2 files changed, 11 insertions(+) diff --git

[RFC PATCH v2 09/22] target/arm: Add support for FEAT_NMI, Non-maskable Interrupt

2024-02-21 Thread Jinjie Ruan via
Add support for FEAT_NMI. NMI (FEAT_NMI) is an mandatory feature in ARMv8.8-A and ARM v9.3-A. Signed-off-by: Jinjie Ruan --- target/arm/internals.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/internals.h b/target/arm/internals.h index 50bff44549..fee65caba5 100644 ---

[RFC PATCH v2 06/22] target/arm: Add support for Non-maskable Interrupt

2024-02-21 Thread Jinjie Ruan via
This only implements the external delivery method via the GICv3. Signed-off-by: Jinjie Ruan --- target/arm/cpu-qom.h | 3 ++- target/arm/cpu.c | 39 ++- target/arm/cpu.h | 2 ++ target/arm/helper.c | 1 + 4 files changed, 39 insertions(+), 6

[RFC PATCH v2 01/22] target/arm: Add FEAT_NMI to max

2024-02-21 Thread Jinjie Ruan via
Enable FEAT_NMI on the 'max' CPU. Signed-off-by: Jinjie Ruan --- docs/system/arm/emulation.rst | 1 + target/arm/tcg/cpu64.c| 1 + 2 files changed, 2 insertions(+) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index f67aea2d83..91baf7ad69 100644 ---

[RFC PATCH v2 22/22] hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()

2024-02-21 Thread Jinjie Ruan via
In CPU Interface, if the IRQ or FIQ has the superpriority property, report NMI to the corresponding PE and record the NMI interrupt type. Signed-off-by: Jinjie Ruan --- hw/intc/arm_gicv3_cpuif.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv3_cpuif.c

[RFC PATCH v2 19/22] hw/intc/arm_gicv3: Add irq superpriority information

2024-02-21 Thread Jinjie Ruan via
A SPI, PPI or SGI interrupt can have a superpriority property. So maintain superpriority information in PendingIrq and GICR/GICD. Signed-off-by: Jinjie Ruan --- include/hw/intc/arm_gicv3_common.h | 4 1 file changed, 4 insertions(+) diff --git a/include/hw/intc/arm_gicv3_common.h

[RFC PATCH v2 08/22] target/arm: Handle IS/FS in ISR_EL1 for NMI

2024-02-21 Thread Jinjie Ruan via
Add IS and FS bit in ISR_EL1 and handle the read according to whether the NMI is IRQ or FIQ. Signed-off-by: Jinjie Ruan --- target/arm/cpu.h| 2 ++ target/arm/helper.c | 9 + 2 files changed, 11 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index

Re: [RFC PATCH v2 03/22] target/arm: Add PSTATE.ALLINT

2024-02-21 Thread Jinjie Ruan via
On 2024/2/22 2:50, Richard Henderson wrote: > On 2/21/24 03:08, Jinjie Ruan via wrote: >> The ALLINT bit in PSTATE is used to mask all IRQ or FIQ interrupts. >> >> Place this in its own field within ENV, as that will >> make it easier to reset fro

Re: [RFC PATCH v2 01/22] target/arm: Add FEAT_NMI to max

2024-02-21 Thread Jinjie Ruan via
On 2024/2/22 5:22, Richard Henderson wrote: > On 2/21/24 03:08, Jinjie Ruan via wrote: >> Enable FEAT_NMI on the 'max' CPU. >> >> Signed-off-by: Jinjie Ruan >> --- >>   docs/system/arm/emulation.rst | 1 + >>   target/arm/tcg/cpu64.c    |

Re: [RFC PATCH v2 04/22] target/arm: Implement ALLINT MSR (immediate)

2024-02-21 Thread Jinjie Ruan via
On 2024/2/22 4:41, Richard Henderson wrote: > On 2/21/24 09:09, Richard Henderson wrote: >> On 2/21/24 03:08, Jinjie Ruan via wrote: >>> Add ALLINT MSR (immediate) to decodetree. And the EL0 check is necessary >>> to ALLINT. Avoid the unconditional write to pc and

Re: [RFC PATCH v2 04/22] target/arm: Implement ALLINT MSR (immediate)

2024-02-21 Thread Jinjie Ruan via
On 2024/2/22 3:09, Richard Henderson wrote: > On 2/21/24 03:08, Jinjie Ruan via wrote: >> Add ALLINT MSR (immediate) to decodetree. And the EL0 check is necessary >> to ALLINT. Avoid the unconditional write to pc and use raise_exception_ra >> to unwind. >> &g

Re: [RFC PATCH v2 06/22] target/arm: Add support for Non-maskable Interrupt

2024-02-21 Thread Jinjie Ruan via
On 2024/2/22 4:06, Richard Henderson wrote: > On 2/21/24 03:08, Jinjie Ruan via wrote: >> This only implements the external delivery method via the GICv3. >> >> Signed-off-by: Jinjie Ruan >> --- >>   target/arm/cpu-qom.h |  3 +

Re: [RFC PATCH v2 05/22] target/arm: Support MSR access to ALLINT

2024-02-21 Thread Jinjie Ruan via
On 2024/2/22 3:28, Richard Henderson wrote: > On 2/21/24 03:08, Jinjie Ruan via wrote: >> Support ALLINT msr access as follow: >> mrs , ALLINT    // read allint >> msr ALLINT,     // write allint with imm >> >> Signed-off-by: Jinjie Ruan >

Re: [RFC PATCH v2 06/22] target/arm: Add support for Non-maskable Interrupt

2024-02-22 Thread Jinjie Ruan via
On 2024/2/22 4:06, Richard Henderson wrote: > On 2/21/24 03:08, Jinjie Ruan via wrote: >> This only implements the external delivery method via the GICv3. >> >> Signed-off-by: Jinjie Ruan >> --- >>   target/arm/cpu-qom.h |  3 +

Re: [RFC PATCH v2 06/22] target/arm: Add support for Non-maskable Interrupt

2024-02-22 Thread Jinjie Ruan via
On 2024/2/22 5:23, Richard Henderson wrote: > On 2/21/24 03:08, Jinjie Ruan via wrote: >> This only implements the external delivery method via the GICv3. >> >> Signed-off-by: Jinjie Ruan >> --- >>   target/arm/cpu-qom.h |  3 +

[RFC PATCH v3 04/21] target/arm: Implement ALLINT MSR (immediate)

2024-02-23 Thread Jinjie Ruan via
Add ALLINT MSR (immediate) to decodetree. And the EL0 check is necessary to ALLINT. Avoid the unconditional write to pc and use raise_exception_ra to unwind. Signed-off-by: Jinjie Ruan --- v3: - Remove EL0 check in allint_check(). - Add TALLINT check for EL1 in allint_check(). - Remove

[RFC PATCH v3 16/21] hw/intc: Enable FEAT_GICv3_NMI Feature

2024-02-23 Thread Jinjie Ruan via
Added properties to enable FEAT_GICv3_NMI feature, setup distributor and redistributor registers to indicate NMI support. Signed-off-by: Jinjie Ruan --- hw/intc/arm_gicv3_common.c | 1 + hw/intc/arm_gicv3_dist.c | 2 ++ hw/intc/gicv3_internal.h | 1 +

[RFC PATCH v3 14/21] hw/intc/arm_gicv3_redist: Implement GICR_INMIR0

2024-02-23 Thread Jinjie Ruan via
Add GICR_INMIR0 register and support access GICR_INMIR0. Signed-off-by: Jinjie Ruan --- hw/intc/arm_gicv3_redist.c | 23 +++ hw/intc/gicv3_internal.h | 1 + 2 files changed, 24 insertions(+) diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c index

[RFC PATCH v3 01/21] target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI

2024-02-23 Thread Jinjie Ruan via
FEAT_NMI defines another thress new bits in HCRX_EL2: TALLINT, HCRX_VINMI and HCRX_VFNMI. When the feature is enabled, allow these bits to be written in HCRX_EL2. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v3: - Add Reviewed-by. - Add HCRX_VINMI and HCRX_VFNMI support in

[RFC PATCH v3 11/21] hw/intc/arm_gicv3: Add external IRQ lines for NMI

2024-02-23 Thread Jinjie Ruan via
Augment the GICv3's QOM device interface by adding one new set of sysbus IRQ line, to signal NMI to each CPU. Signed-off-by: Jinjie Ruan --- v3: - Add support for VNMI. --- hw/intc/arm_gicv3_common.c | 6 ++ include/hw/intc/arm_gic_common.h | 2 ++

[RFC PATCH v3 18/21] hw/intc/arm_gicv3: Implement NMI interrupt prioirty

2024-02-23 Thread Jinjie Ruan via
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI prioirty is higher than 0x80, otherwise it is higher than 0x0. And save NMI super prioirty information in hppi.superprio to deliver NMI exception. Since both GICR and GICD can deliver NMI, it is both necessary to check whether the

Re: [RFC PATCH v2 07/22] target/arm: Add support for NMI event state

2024-02-22 Thread Jinjie Ruan via
On 2024/2/22 5:25, Richard Henderson wrote: > On 2/21/24 10:10, Richard Henderson wrote: >> On 2/21/24 03:08, Jinjie Ruan via wrote: >>> The NMI exception state include whether the interrupt with super >>> priority >>> is IRQ or FIQ, so add a nmi_is_ir

Re: [RFC PATCH v2 08/22] target/arm: Handle IS/FS in ISR_EL1 for NMI

2024-02-22 Thread Jinjie Ruan via
On 2024/2/22 5:36, Richard Henderson wrote: > On 2/21/24 03:08, Jinjie Ruan via wrote: >> Add IS and FS bit in ISR_EL1 and handle the read according to whether the >> NMI is IRQ or FIQ. >> >> Signed-off-by: Jinjie Ruan >> --- >>   target/arm/cpu.h

Re: [RFC PATCH v2 11/22] target/arm: Set pstate.ALLINT in arm_cpu_reset_hold

2024-02-22 Thread Jinjie Ruan via
On 2024/2/22 4:43, Richard Henderson wrote: > On 2/21/24 03:08, Jinjie Ruan via wrote: >> Set pstate.ALLINT in arm_cpu_reset_hold as daif do it. >> >> Signed-off-by: Jinjie Ruan >> --- >>   target/arm/cpu.c | 4 >>   1 file changed, 4 insertions(+

Re: [RFC PATCH v3 06/21] target/arm: Add support for Non-maskable Interrupt

2024-02-25 Thread Jinjie Ruan via
On 2024/2/24 3:55, Richard Henderson wrote: > On 2/23/24 00:32, Jinjie Ruan via wrote: >> This only implements the external delivery method via the GICv3. >> >> Signed-off-by: Jinjie Ruan >> --- >> v3: >> - Not include CPU_INTERRUPT_NMI when FEA

Re: [RFC PATCH v5 12/22] target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()

2024-02-29 Thread Jinjie Ruan via
On 2024/3/1 7:09, Richard Henderson wrote: > On 2/29/24 03:10, Jinjie Ruan via wrote: >> According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt >> with superpriority is always IRQ, never FIQ, so the NMI exception trap >> entry >> behave like IR

[RFC PATCH v4 18/22] hw/intc/arm_gicv3: Implement NMI interrupt prioirty

2024-02-28 Thread Jinjie Ruan via
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI prioirty is higher than 0x80, otherwise it is higher than 0x0. And save NMI super prioirty information in hppi.superprio to deliver NMI exception. Since both GICR and GICD can deliver NMI, it is both necessary to check whether the

[RFC PATCH v4 09/22] target/arm: Handle PSTATE.ALLINT on taking an exception

2024-02-28 Thread Jinjie Ruan via
Set or clear PSTATE.ALLINT on taking an exception to ELx according to the SCTLR_ELx.SPINTMASK bit. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v3: - Add Reviewed-by. --- target/arm/helper.c | 9 + 1 file changed, 9 insertions(+) diff --git a/target/arm/helper.c

[RFC PATCH v4 06/22] target/arm: Add support for Non-maskable Interrupt

2024-02-28 Thread Jinjie Ruan via
This only implements the external delivery method via the GICv3. Signed-off-by: Jinjie Ruan --- v4: - Accept NMI unconditionally for arm_cpu_has_work() but add comment. - Change from & to && for EXCP_IRQ or EXCP_FIQ. - Refator nmi mask in arm_excp_unmasked(). - Also handle VNMI in

[RFC PATCH v4 16/22] hw/intc: Enable FEAT_GICv3_NMI Feature

2024-02-28 Thread Jinjie Ruan via
Added properties to enable FEAT_GICv3_NMI feature, setup distributor and redistributor registers to indicate NMI support. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Add Reviewed-by. --- hw/intc/arm_gicv3_common.c | 1 + hw/intc/arm_gicv3_dist.c | 2 ++

[RFC PATCH v4 05/22] target/arm: Support MSR access to ALLINT

2024-02-28 Thread Jinjie Ruan via
Support ALLINT msr access as follow: mrs , ALLINT// read allint msr ALLINT, // write allint with imm Signed-off-by: Jinjie Ruan --- v4: - Remove arm_is_el2_enabled() check in allint_check(). - Change to env->pstate instead of env->allint. v3: - Remove EL0 check in

[RFC PATCH v4 10/22] hw/arm/virt: Wire NMI and VNMI irq lines from GIC to CPU

2024-02-28 Thread Jinjie Ruan via
Wire the new NMI and VNMI interrupt line from the GIC to each CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Add Reviewed-by. v3: - Also add VNMI wire. --- hw/arm/virt.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c

[RFC PATCH v4 22/22] hw/arm/virt: Add FEAT_GICv3_NMI feature support in virt GIC

2024-02-28 Thread Jinjie Ruan via
A PE that implements FEAT_NMI and FEAT_GICv3 also implements FEAT_GICv3_NMI. A PE that does not implement FEAT_NMI, does not implement FEAT_GICv3_NMI So included support FEAT_GICv3_NMI feature as part of virt platform GIC initialization if FEAT_NMI and FEAT_GICv3 supported. Signed-off-by: Jinjie

[RFC PATCH v4 11/22] hw/intc/arm_gicv3: Add external IRQ lines for NMI

2024-02-28 Thread Jinjie Ruan via
Augment the GICv3's QOM device interface by adding one new set of sysbus IRQ line, to signal NMI to each CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Add Reviewed-by. v3: - Add support for VNMI. --- hw/intc/arm_gicv3_common.c | 6 ++

[RFC PATCH v4 17/22] hw/intc/arm_gicv3: Add NMI handling CPU interface registers

2024-02-28 Thread Jinjie Ruan via
Add the NMIAR CPU interface registers which deal with acknowledging NMI. When introduce NMI interrupt, there are some updates to the semantics for the register ICC_IAR1_EL1 and ICC_HPPIR1_EL1. For ICC_IAR1_EL1 register, it should return 1022 if the intid has super priority. And for ICC_NMIAR1_EL1

[RFC PATCH v4 19/22] hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()

2024-02-28 Thread Jinjie Ruan via
In CPU Interface, if the IRQ has the superpriority property, report NMI to the corresponding PE. Signed-off-by: Jinjie Ruan --- v4: - Swap the ordering of the IFs. v3: - Remove handling nmi_is_irq flag. --- hw/intc/arm_gicv3_cpuif.c | 4 1 file changed, 4 insertions(+) diff --git

[RFC PATCH v4 07/22] target/arm: Add support for NMI in arm_phys_excp_target_el()

2024-02-28 Thread Jinjie Ruan via
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt with superpriority is always IRQ, never FIQ, so handle NMI same as IRQ in arm_phys_excp_target_el(). Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Add Reviewed-by. v3: - Remove nmi_is_irq flag in

[RFC PATCH v4 02/22] target/arm: Add PSTATE.ALLINT

2024-02-28 Thread Jinjie Ruan via
When PSTATE.ALLINT is set, an IRQ or FIQ interrupt that is targeted to ELx, with or without superpriority is masked. As Richard suggested, place ALLINT bit in PSTATE in env->pstate. With the change to pstate_read/write, exception entry and return are automatically handled. Signed-off-by: Jinjie

[RFC PATCH v4 03/22] target/arm: Add support for FEAT_NMI, Non-maskable Interrupt

2024-02-28 Thread Jinjie Ruan via
Add support for FEAT_NMI. NMI (FEAT_NMI) is an mandatory feature in ARMv8.8-A and ARM v9.3-A. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v3: - Add Reviewed-by. - Adjust to before the MSR patches. --- target/arm/internals.h | 3 +++ 1 file changed, 3 insertions(+) diff --git

[RFC PATCH v4 12/22] target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()

2024-02-28 Thread Jinjie Ruan via
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt with superpriority is always IRQ, never FIQ, so the NMI exception trap entry behave like IRQ. However, VNMI can be IRQ or FIQ, FIQ can only come from hcrx_el2.HCRX_VFNMI bit, IRQ can be raised from the GIC or come from the

[RFC PATCH v4 15/22] hw/intc/arm_gicv3: Implement GICD_INMIR

2024-02-28 Thread Jinjie Ruan via
Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Make the GICD_INMIR implementation more clearer. - Udpate the commit message. v3: - Add Reviewed-by. --- hw/intc/arm_gicv3_dist.c | 34

[RFC PATCH v4 08/22] target/arm: Handle IS/FS in ISR_EL1 for NMI

2024-02-28 Thread Jinjie Ruan via
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or CPU_INTERRUPT_VNMI, both CPSR_I and ISR_IS must be set. With CPU_INTERRUPT_VFIQ and HCRX_EL2.VFNMI set, both CPSR_F and ISR_FS must be set. Signed-off-by: Jinjie Ruan --- v4; - Also handle VNMI. v3: - CPU_INTERRUPT_NMI

[RFC PATCH v4 20/22] hw/intc/arm_gicv3: Report the VNMI interrupt

2024-02-28 Thread Jinjie Ruan via
In vCPU Interface, if the vIRQ has the superpriority property, report vNMI to the corresponding vPE. Signed-off-by: Jinjie Ruan --- hw/intc/arm_gicv3_cpuif.c | 14 -- hw/intc/gicv3_internal.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git

[RFC PATCH v4 04/22] target/arm: Implement ALLINT MSR (immediate)

2024-02-28 Thread Jinjie Ruan via
Add ALLINT MSR (immediate) to decodetree, in which the CRm is 0b000x. The EL0 check is necessary to ALLINT, and the EL1 check is necessary when imm == 1. So implement it inline for EL2/3, or EL1 with imm==0. Avoid the unconditional write to pc and use raise_exception_ra to unwind. Signed-off-by:

[RFC PATCH v4 21/22] target/arm: Add FEAT_NMI to max

2024-02-28 Thread Jinjie Ruan via
Enable FEAT_NMI on the 'max' CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v3: - Add Reviewed-by. - Sorted to last. --- docs/system/arm/emulation.rst | 1 + target/arm/tcg/cpu64.c| 1 + 2 files changed, 2 insertions(+) diff --git a/docs/system/arm/emulation.rst

[RFC PATCH v4 14/22] hw/intc/arm_gicv3_redist: Implement GICR_INMIR0

2024-02-28 Thread Jinjie Ruan via
Add GICR_INMIR0 register and support access GICR_INMIR0. Signed-off-by: Jinjie Ruan --- v4: - Make the GICR_INMIR0 implementation more clearer. --- hw/intc/arm_gicv3_redist.c | 19 +++ hw/intc/gicv3_internal.h | 1 + 2 files changed, 20 insertions(+) diff --git

[RFC PATCH v4 13/22] hw/intc/arm_gicv3: Add irq superpriority information

2024-02-28 Thread Jinjie Ruan via
A SPI, PPI or SGI interrupt can have a superpriority property. So maintain superpriority information in PendingIrq and GICR/GICD. Signed-off-by: Jinjie Ruan Acked-by: Richard Henderson --- v3: - Place this ahead of implement GICR_INMIR. - Add Acked-by. --- include/hw/intc/arm_gicv3_common.h |

[RFC PATCH v4 01/22] target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI

2024-02-28 Thread Jinjie Ruan via
FEAT_NMI defines another three new bits in HCRX_EL2: TALLINT, HCRX_VINMI and HCRX_VFNMI. When the feature is enabled, allow these bits to be written in HCRX_EL2. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Update the comment for FEAT_NMI in hcrx_write(). - Update the

Re: [RFC PATCH v5 18/22] hw/intc/arm_gicv3: Implement NMI interrupt prioirty

2024-03-04 Thread Jinjie Ruan via
On 2024/3/1 7:50, Richard Henderson wrote: > On 2/29/24 03:10, Jinjie Ruan via wrote: >> If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI prioirty >> is higher than 0x80, otherwise it is higher than 0x0. And save NMI >> super prioirty information in hppi.sup

Re: [RFC PATCH v5 18/22] hw/intc/arm_gicv3: Implement NMI interrupt prioirty

2024-03-04 Thread Jinjie Ruan via
On 2024/3/1 7:50, Richard Henderson wrote: > On 2/29/24 03:10, Jinjie Ruan via wrote: >> If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI prioirty >> is higher than 0x80, otherwise it is higher than 0x0. And save NMI >> super prioirty information in hppi.sup

[RFC PATCH v5 02/22] target/arm: Add PSTATE.ALLINT

2024-02-29 Thread Jinjie Ruan via
When PSTATE.ALLINT is set, an IRQ or FIQ interrupt that is targeted to ELx, with or without superpriority is masked. As Richard suggested, place ALLINT bit in PSTATE in env->pstate. With the change to pstate_read/write, exception entry and return are automatically handled. Signed-off-by: Jinjie

[RFC PATCH v5 03/22] target/arm: Add support for FEAT_NMI, Non-maskable Interrupt

2024-02-29 Thread Jinjie Ruan via
Add support for FEAT_NMI. NMI (FEAT_NMI) is an mandatory feature in ARMv8.8-A and ARM v9.3-A. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v3: - Add Reviewed-by. - Adjust to before the MSR patches. --- target/arm/internals.h | 3 +++ 1 file changed, 3 insertions(+) diff --git

[RFC PATCH v5 15/22] hw/intc/arm_gicv3: Implement GICD_INMIR

2024-02-29 Thread Jinjie Ruan via
Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Make the GICD_INMIR implementation more clearer. - Udpate the commit message. v3: - Add Reviewed-by. --- hw/intc/arm_gicv3_dist.c | 34

[RFC PATCH v5 18/22] hw/intc/arm_gicv3: Implement NMI interrupt prioirty

2024-02-29 Thread Jinjie Ruan via
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI prioirty is higher than 0x80, otherwise it is higher than 0x0. And save NMI super prioirty information in hppi.superprio to deliver NMI exception. Since both GICR and GICD can deliver NMI, it is both necessary to check whether the

[RFC PATCH v5 01/22] target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI

2024-02-29 Thread Jinjie Ruan via
FEAT_NMI defines another three new bits in HCRX_EL2: TALLINT, HCRX_VINMI and HCRX_VFNMI. When the feature is enabled, allow these bits to be written in HCRX_EL2. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Update the comment for FEAT_NMI in hcrx_write(). - Update the

[RFC PATCH v5 11/22] hw/intc/arm_gicv3: Add external IRQ lines for NMI

2024-02-29 Thread Jinjie Ruan via
Augment the GICv3's QOM device interface by adding one new set of sysbus IRQ line, to signal NMI to each CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Add Reviewed-by. v3: - Add support for VNMI. --- hw/intc/arm_gicv3_common.c | 6 ++

[RFC PATCH v5 07/22] target/arm: Add support for NMI in arm_phys_excp_target_el()

2024-02-29 Thread Jinjie Ruan via
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt with superpriority is always IRQ, never FIQ, so handle NMI same as IRQ in arm_phys_excp_target_el(). Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Add Reviewed-by. v3: - Remove nmi_is_irq flag in

[RFC PATCH v5 20/22] hw/intc/arm_gicv3: Report the VNMI interrupt

2024-02-29 Thread Jinjie Ruan via
In vCPU Interface, if the vIRQ has the superpriority property, report vNMI to the corresponding vPE. Signed-off-by: Jinjie Ruan --- hw/intc/arm_gicv3_cpuif.c | 14 -- hw/intc/gicv3_internal.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git

[RFC PATCH v5 21/22] target/arm: Add FEAT_NMI to max

2024-02-29 Thread Jinjie Ruan via
Enable FEAT_NMI on the 'max' CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v3: - Add Reviewed-by. - Sorted to last. --- docs/system/arm/emulation.rst | 1 + target/arm/tcg/cpu64.c| 1 + 2 files changed, 2 insertions(+) diff --git a/docs/system/arm/emulation.rst

[RFC PATCH v5 05/22] target/arm: Support MSR access to ALLINT

2024-02-29 Thread Jinjie Ruan via
Support ALLINT msr access as follow: mrs , ALLINT// read allint msr ALLINT, // write allint with imm Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v5: - Add Reviewed-by. v4: - Remove arm_is_el2_enabled() check in allint_check(). - Change to

[RFC PATCH v5 19/22] hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()

2024-02-29 Thread Jinjie Ruan via
In CPU Interface, if the IRQ has the superpriority property, report NMI to the corresponding PE. Signed-off-by: Jinjie Ruan --- v4: - Swap the ordering of the IFs. v3: - Remove handling nmi_is_irq flag. --- hw/intc/arm_gicv3_cpuif.c | 4 1 file changed, 4 insertions(+) diff --git

[RFC PATCH v5 17/22] hw/intc/arm_gicv3: Add NMI handling CPU interface registers

2024-02-29 Thread Jinjie Ruan via
Add the NMIAR CPU interface registers which deal with acknowledging NMI. When introduce NMI interrupt, there are some updates to the semantics for the register ICC_IAR1_EL1 and ICC_HPPIR1_EL1. For ICC_IAR1_EL1 register, it should return 1022 if the intid has super priority. And for ICC_NMIAR1_EL1

[RFC PATCH v5 12/22] target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()

2024-02-29 Thread Jinjie Ruan via
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt with superpriority is always IRQ, never FIQ, so the NMI exception trap entry behave like IRQ. However, VNMI can be IRQ or FIQ, FIQ can only come from hcrx_el2.HCRX_VFNMI bit, IRQ can be raised from the GIC or come from the

[RFC PATCH v5 09/22] target/arm: Handle PSTATE.ALLINT on taking an exception

2024-02-29 Thread Jinjie Ruan via
Set or clear PSTATE.ALLINT on taking an exception to ELx according to the SCTLR_ELx.SPINTMASK bit. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v3: - Add Reviewed-by. --- target/arm/helper.c | 9 + 1 file changed, 9 insertions(+) diff --git a/target/arm/helper.c

[RFC PATCH v5 16/22] hw/intc: Enable FEAT_GICv3_NMI Feature

2024-02-29 Thread Jinjie Ruan via
Added properties to enable FEAT_GICv3_NMI feature, setup distributor and redistributor registers to indicate NMI support. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Add Reviewed-by. --- hw/intc/arm_gicv3_common.c | 1 + hw/intc/arm_gicv3_dist.c | 2 ++

[RFC PATCH v5 04/22] target/arm: Implement ALLINT MSR (immediate)

2024-02-29 Thread Jinjie Ruan via
Add ALLINT MSR (immediate) to decodetree, in which the CRm is 0b000x. The EL0 check is necessary to ALLINT, and the EL1 check is necessary when imm == 1. So implement it inline for EL2/3, or EL1 with imm==0. Avoid the unconditional write to pc and use raise_exception_ra to unwind. Signed-off-by:

[RFC PATCH v5 10/22] hw/arm/virt: Wire NMI and VNMI irq lines from GIC to CPU

2024-02-29 Thread Jinjie Ruan via
Wire the new NMI and VNMI interrupt line from the GIC to each CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Add Reviewed-by. v3: - Also add VNMI wire. --- hw/arm/virt.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c

[RFC PATCH v5 14/22] hw/intc/arm_gicv3_redist: Implement GICR_INMIR0

2024-02-29 Thread Jinjie Ruan via
Add GICR_INMIR0 register and support access GICR_INMIR0. Signed-off-by: Jinjie Ruan --- v4: - Make the GICR_INMIR0 implementation more clearer. --- hw/intc/arm_gicv3_redist.c | 19 +++ hw/intc/gicv3_internal.h | 1 + 2 files changed, 20 insertions(+) diff --git

[RFC PATCH v5 06/22] target/arm: Add support for Non-maskable Interrupt

2024-02-29 Thread Jinjie Ruan via
This only implements the external delivery method via the GICv3. Signed-off-by: Jinjie Ruan --- v4: - Accept NMI unconditionally for arm_cpu_has_work() but add comment. - Change from & to && for EXCP_IRQ or EXCP_FIQ. - Refator nmi mask in arm_excp_unmasked(). - Also handle VNMI in

[RFC PATCH v5 13/22] hw/intc/arm_gicv3: Add irq superpriority information

2024-02-29 Thread Jinjie Ruan via
A SPI, PPI or SGI interrupt can have a superpriority property. So maintain superpriority information in PendingIrq and GICR/GICD. Signed-off-by: Jinjie Ruan Acked-by: Richard Henderson --- v3: - Place this ahead of implement GICR_INMIR. - Add Acked-by. --- include/hw/intc/arm_gicv3_common.h |

[RFC PATCH v5 22/22] hw/arm/virt: Add FEAT_GICv3_NMI feature support in virt GIC

2024-02-29 Thread Jinjie Ruan via
A PE that implements FEAT_NMI and FEAT_GICv3 also implements FEAT_GICv3_NMI. A PE that does not implement FEAT_NMI, does not implement FEAT_GICv3_NMI So included support FEAT_GICv3_NMI feature as part of virt platform GIC initialization if FEAT_NMI and FEAT_GICv3 supported. Signed-off-by: Jinjie

[RFC PATCH v5 08/22] target/arm: Handle IS/FS in ISR_EL1 for NMI

2024-02-29 Thread Jinjie Ruan via
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or CPU_INTERRUPT_VNMI, both CPSR_I and ISR_IS must be set. With CPU_INTERRUPT_VFIQ and HCRX_EL2.VFNMI set, both CPSR_F and ISR_FS must be set. Signed-off-by: Jinjie Ruan --- v4; - Also handle VNMI. v3: - CPU_INTERRUPT_NMI

[RFC PATCH v6 05/23] target/arm: Support MSR access to ALLINT

2024-03-04 Thread Jinjie Ruan via
Support ALLINT msr access as follow: mrs , ALLINT// read allint msr ALLINT, // write allint with imm Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v5: - Add Reviewed-by. v4: - Remove arm_is_el2_enabled() check in allint_check(). - Change to

[RFC PATCH v6 10/23] hw/arm/virt: Wire NMI and VNMI irq lines from GIC to CPU

2024-03-04 Thread Jinjie Ruan via
Wire the new NMI and VNMI interrupt line from the GIC to each CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Add Reviewed-by. v3: - Also add VNMI wire. --- hw/arm/virt.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c

[RFC PATCH v6 22/23] target/arm: Add FEAT_NMI to max

2024-03-04 Thread Jinjie Ruan via
Enable FEAT_NMI on the 'max' CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v3: - Add Reviewed-by. - Sorted to last. --- docs/system/arm/emulation.rst | 1 + target/arm/tcg/cpu64.c| 1 + 2 files changed, 2 insertions(+) diff --git a/docs/system/arm/emulation.rst

[RFC PATCH v6 01/23] target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI

2024-03-04 Thread Jinjie Ruan via
FEAT_NMI defines another three new bits in HCRX_EL2: TALLINT, HCRX_VINMI and HCRX_VFNMI. When the feature is enabled, allow these bits to be written in HCRX_EL2. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v4: - Update the comment for FEAT_NMI in hcrx_write(). - Update the

[RFC PATCH v6 18/23] hw/intc/arm_gicv3: Handle icv_nmiar1_read() for icc_nmiar1_read()

2024-03-04 Thread Jinjie Ruan via
Implement icv_nmiar1_read() for icc_nmiar1_read(), so add definition for ICH_LR_EL2.NMI and ICH_AP1R_EL2.NMI bit. If FEAT_GICv3_NMI is supported, ich_ap_write() should consider ICH_AP1R_EL2.NMI bit. In icv_activate_irq() and icv_eoir_write(), the ICH_AP1R_EL2.NMI bit should be set or clear

[RFC PATCH v6 23/23] hw/arm/virt: Add FEAT_GICv3_NMI feature support in virt GIC

2024-03-04 Thread Jinjie Ruan via
A PE that implements FEAT_NMI and FEAT_GICv3 also implements FEAT_GICv3_NMI. A PE that does not implement FEAT_NMI, does not implement FEAT_GICv3_NMI So included support FEAT_GICv3_NMI feature as part of virt platform GIC initialization if FEAT_NMI and FEAT_GICv3 supported. Signed-off-by: Jinjie

[RFC PATCH v6 04/23] target/arm: Implement ALLINT MSR (immediate)

2024-03-04 Thread Jinjie Ruan via
Add ALLINT MSR (immediate) to decodetree, in which the CRm is 0b000x. The EL0 check is necessary to ALLINT, and the EL1 check is necessary when imm == 1. So implement it inline for EL2/3, or EL1 with imm==0. Avoid the unconditional write to pc and use raise_exception_ra to unwind. Signed-off-by:

  1   2   3   4   >