Re: [PATCH v13 00/24] target/arm: Implement FEAT_NMI and FEAT_GICv3_NMI

2024-04-21 Thread Jinjie Ruan via
On 2024/4/19 21:41, Peter Maydell wrote: > On Sun, 7 Apr 2024 at 09:19, Jinjie Ruan wrote: >> >> 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

Re: [PATCH v13 00/24] target/arm: Implement FEAT_NMI and FEAT_GICv3_NMI

2024-04-10 Thread Jinjie Ruan via
On 2024/4/10 20:58, Peter Maydell wrote: > On Wed, 10 Apr 2024 at 07:19, Jinjie Ruan via wrote: >> >> Ping. > > As I said in my reply on the previous version, we're in > freeze at the moment, so this patchset is not going anywhere > until 9.0 releases. I think i

Re: [PATCH v13 00/24] target/arm: Implement FEAT_NMI and FEAT_GICv3_NMI

2024-04-10 Thread Jinjie Ruan via
Ping. On 2024/4/7 16:17, Jinjie Ruan wrote: > 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.

[PATCH v13 09/24] target/arm: Handle PSTATE.ALLINT on taking an exception

2024-04-07 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 Reviewed-by: Peter Maydell --- v13: - Add Reviewed-by. v9: - Not check SCTLR_NMI in arm_cpu_do_interrupt_aarch64(). v3: - Add

[PATCH v13 22/24] hw/intc/arm_gicv3: Report the VINMI interrupt

2024-04-07 Thread Jinjie Ruan via
In vCPU Interface, if the vIRQ has the non-maskable property, report vINMI to the corresponding vPE. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v12: - Do not check nmi_support repetitively. - Add Reviewed-by. v10: - Update the commit message,

[PATCH v13 11/24] hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU

2024-04-07 Thread Jinjie Ruan via
Wire the new NMI and VINMI interrupt line from the GIC to each CPU if it is not GICv2. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v13: - Adjust to after "hw/intc/arm_gicv3: Add external IRQ lines for NMI" to fix the unexpected error with patchseries at this point. - Only

[PATCH v13 19/24] hw/intc/arm_gicv3: Handle icv_nmiar1_read() for icc_nmiar1_read()

2024-04-07 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 ICV_AP1R_EL1.NMI bit. In icv_activate_irq() and icv_eoir_write(), the ICV_AP1R_EL1.NMI bit should be set or clear

[PATCH v13 13/24] hw/intc/arm_gicv3: Add has-nmi property to GICv3 device

2024-04-07 Thread Jinjie Ruan via
Add a property has-nmi to the GICv3 device, and use this to set the NMI bit in the GICD_TYPER register. This isn't visible to guests yet because the property defaults to false and we won't set it in the board code until we've landed all of the changes needed to implement FEAT_GICV3_NMI.

[PATCH v13 23/24] target/arm: Add FEAT_NMI to max

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

[PATCH v13 10/24] hw/intc/arm_gicv3: Add external IRQ lines for NMI

2024-04-07 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 Reviewed-by: Peter Maydell --- v11: - Add new Reviewed-by. v4: - Add Reviewed-by. v3: - Add support for VNMI. ---

[PATCH v13 04/24] target/arm: Implement ALLINT MSR (immediate)

2024-04-07 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:

[PATCH v13 15/24] hw/intc/arm_gicv3: Add irq non-maskable property

2024-04-07 Thread Jinjie Ruan via
A SPI, PPI or SGI interrupt can have non-maskable property. So maintain non-maskable property in PendingIrq and GICR/GICD. Since add new device state, it also needs to be migrated, so also save NMI info in vmstate_gicv3_cpu and vmstate_gicv3. Signed-off-by: Jinjie Ruan Acked-by: Richard

[PATCH v13 20/24] hw/intc/arm_gicv3: Implement NMI interrupt priority

2024-04-07 Thread Jinjie Ruan via
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI priority is higher than 0x80, otherwise it is higher than 0x0. And save the interrupt non-maskable property in hppi.nmi to deliver NMI exception. Since both GICR and GICD can deliver NMI, it is both necessary to check whether the

[PATCH v13 18/24] hw/intc/arm_gicv3: Add NMI handling CPU interface registers

2024-04-07 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 non-maskable property. And for

[PATCH v13 05/24] target/arm: Support MSR access to ALLINT

2024-04-07 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 Reviewed-by: Peter Maydell --- v13: - Add Reviewed-by. v9: - Move nmi_reginfo and related functions

[PATCH v13 03/24] target/arm: Add support for FEAT_NMI, Non-maskable Interrupt

2024-04-07 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 Reviewed-by: Peter Maydell --- v13: - Add Reviewed-by. v3: - Add Reviewed-by. - Adjust to before the MSR patches. --- target/arm/internals.h

[PATCH v13 08/24] target/arm: Handle IS/FS in ISR_EL1 for NMI, VINMI and VFNMI

2024-04-07 Thread Jinjie Ruan via
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or CPU_INTERRUPT_VINMI, both CPSR_I and ISR_IS must be set. With CPU_INTERRUPT_VFNMI, both CPSR_F and ISR_FS must be set. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v13: - Add

[PATCH v13 12/24] target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()

2024-04-07 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. And VINMI(vIRQ with Superpriority) can be raised from the GIC or come from the hcrx_el2.HCRX_VINMI bit, VFNMI(vFIQ with

[PATCH v13 17/24] hw/intc/arm_gicv3: Implement GICD_INMIR

2024-04-07 Thread Jinjie Ruan via
Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v11: - Add new Reviewed-by. v10: - superprio -> nmi. v4: - Make the GICD_INMIR implementation more clearer. - Udpate the commit

[PATCH v13 01/24] target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI

2024-04-07 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 Reviewed-by: Peter Maydell --- v13: - Add Reviewed-by. v12: - Remove the

[PATCH v13 06/24] target/arm: Add support for Non-maskable Interrupt

2024-04-07 Thread Jinjie Ruan via
This only implements the external delivery method via the GICv3. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v13: - Add Reviewed-by. v12: - Correct the comment style in arm_cpu_initfn(). v10: - In arm_cpu_exec_interrupt(), if SCTLR_ELx.NMI is 0, NMI

[PATCH v13 02/24] target/arm: Add PSTATE.ALLINT

2024-04-07 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. In the pseudocode, AArch64.ExceptionReturn() calls SetPSTATEFromPSR(), which treats PSTATE.ALLINT as one of the

[PATCH v13 07/24] target/arm: Add support for NMI in arm_phys_excp_target_el()

2024-04-07 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 Reviewed-by: Peter Maydell --- v13: - Add Reviewed-by. v4: -

[PATCH v13 24/24] hw/arm/virt: Add FEAT_GICv3_NMI feature support in virt GIC

2024-04-07 Thread Jinjie Ruan via
FEAT_GICv3_NMI introduces GIC support for non-maskable interrupts (NMIs). 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

[PATCH v13 16/24] hw/intc/arm_gicv3_redist: Implement GICR_INMIR0

2024-04-07 Thread Jinjie Ruan via
Add GICR_INMIR0 register and support access GICR_INMIR0. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v11: - Add new Reviewed-by. v10: - gicr_isuperprio -> gicr_inmir0. v6: - Add Reviewed-by. v4: - Make the GICR_INMIR0 implementation more clearer.

[PATCH v13 14/24] hw/intc/arm_gicv3_kvm: Not set has-nmi=true for the KVM GICv3

2024-04-07 Thread Jinjie Ruan via
So far, there is no FEAT_GICv3_NMI support in the in-kernel GIC, so make it an error to try to set has-nmi=true for the KVM GICv3. Signed-off-by: Jinjie Ruan Suggested-by: Peter Maydell --- hw/intc/arm_gicv3_kvm.c | 5 + 1 file changed, 5 insertions(+) diff --git a/hw/intc/arm_gicv3_kvm.c

[PATCH v13 21/24] hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()

2024-04-07 Thread Jinjie Ruan via
In CPU Interface, if the IRQ has the non-maskable property, report NMI to the corresponding PE. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v12: - Add Reviewed-by. v10: - superprio -> nmi. - Update the commit message, superpriority -> non-maskable.

[PATCH v13 00/24] target/arm: Implement FEAT_NMI and FEAT_GICv3_NMI

2024-04-07 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: [PATCH v12 23/23] hw/arm/virt: Add FEAT_GICv3_NMI feature support in virt GIC

2024-04-07 Thread Jinjie Ruan via
On 2024/4/5 21:48, Peter Maydell wrote: > On Wed, 3 Apr 2024 at 11:18, Jinjie Ruan wrote: >> >> 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 > > This is true but not really relevant

Re: [PATCH v12 10/23] hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU

2024-04-06 Thread Jinjie Ruan via
On 2024/4/4 22:47, Peter Maydell wrote: > On Wed, 3 Apr 2024 at 11:18, Jinjie Ruan wrote: >> >> Wire the new NMI and VINMI interrupt line from the GIC to each CPU. >> >> Signed-off-by: Jinjie Ruan >> Reviewed-by: Richard Henderson >> --- >> v9: >> - Rename ARM_CPU_VNMI to ARM_CPU_VINMI. >> -

[PATCH v12 20/23] hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()

2024-04-03 Thread Jinjie Ruan via
In CPU Interface, if the IRQ has the non-maskable property, report NMI to the corresponding PE. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v12: - Add Reviewed-by. v10: - superprio -> nmi. - Update the commit message, superpriority -> non-maskable.

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

2024-04-03 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 ICV_AP1R_EL1.NMI bit. In icv_activate_irq() and icv_eoir_write(), the ICV_AP1R_EL1.NMI bit should be set or clear

[PATCH v12 12/23] target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()

2024-04-03 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. And VINMI(vIRQ with Superpriority) can be raised from the GIC or come from the hcrx_el2.HCRX_VINMI bit, VFNMI(vFIQ with

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

2024-04-03 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 --- v12: - Remove the redundant blank line. v9: - Declare cpu variable to

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

2024-04-03 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

[PATCH v12 08/23] target/arm: Handle IS/FS in ISR_EL1 for NMI, VINMI and VFNMI

2024-04-03 Thread Jinjie Ruan via
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or CPU_INTERRUPT_VINMI, both CPSR_I and ISR_IS must be set. With CPU_INTERRUPT_VFNMI, both CPSR_F and ISR_FS must be set. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v9: - CPU_INTERRUPT_VNMI ->

[PATCH v12 14/23] hw/intc/arm_gicv3: Add irq non-maskable property

2024-04-03 Thread Jinjie Ruan via
A SPI, PPI or SGI interrupt can have non-maskable property. So maintain non-maskable property in PendingIrq and GICR/GICD. Since add new device state, it also needs to be migrated, so also save NMI info in vmstate_gicv3_cpu and vmstate_gicv3. Signed-off-by: Jinjie Ruan Acked-by: Richard

[PATCH v12 21/23] hw/intc/arm_gicv3: Report the VINMI interrupt

2024-04-03 Thread Jinjie Ruan via
In vCPU Interface, if the vIRQ has the non-maskable property, report vINMI to the corresponding vPE. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v12: - Do not check nmi_support repetitively. - Add Reviewed-by. v10: - Update the commit message,

[PATCH v12 06/23] target/arm: Add support for Non-maskable Interrupt

2024-04-03 Thread Jinjie Ruan via
This only implements the external delivery method via the GICv3. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v12: - Correct the comment style in arm_cpu_initfn(). v10: - In arm_cpu_exec_interrupt(), if SCTLR_ELx.NMI is 0, NMI -> IRQ, VINMI -> VIRQ, VFNMI -> VFIQ. - Make

[PATCH v12 15/23] hw/intc/arm_gicv3_redist: Implement GICR_INMIR0

2024-04-03 Thread Jinjie Ruan via
Add GICR_INMIR0 register and support access GICR_INMIR0. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v11: - Add new Reviewed-by. v10: - gicr_isuperprio -> gicr_inmir0. v6: - Add Reviewed-by. v4: - Make the GICR_INMIR0 implementation more clearer.

[PATCH v12 10/23] hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU

2024-04-03 Thread Jinjie Ruan via
Wire the new NMI and VINMI interrupt line from the GIC to each CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v9: - Rename ARM_CPU_VNMI to ARM_CPU_VINMI. - Update the commit message. v4: - Add Reviewed-by. v3: - Also add VNMI wire. --- hw/arm/virt.c | 7 ++- 1 file

[PATCH v12 13/23] hw/intc/arm_gicv3: Add has-nmi property to GICv3 device

2024-04-03 Thread Jinjie Ruan via
Add a property has-nmi to the GICv3 device, and use this to set the NMI bit in the GICD_TYPER register. This isn't visible to guests yet because the property defaults to false and we won't set it in the board code until we've landed all of the changes needed to implement FEAT_GICV3_NMI.

[PATCH v12 09/23] target/arm: Handle PSTATE.ALLINT on taking an exception

2024-04-03 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 --- v9: - Not check SCTLR_NMI in arm_cpu_do_interrupt_aarch64(). v3: - Add Reviewed-by. --- target/arm/helper.c | 8 1 file

[PATCH v12 17/23] hw/intc/arm_gicv3: Add NMI handling CPU interface registers

2024-04-03 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 non-maskable property. And for

[PATCH v12 16/23] hw/intc/arm_gicv3: Implement GICD_INMIR

2024-04-03 Thread Jinjie Ruan via
Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v11: - Add new Reviewed-by. v10: - superprio -> nmi. v4: - Make the GICD_INMIR implementation more clearer. - Udpate the commit

[PATCH v12 03/23] target/arm: Add support for FEAT_NMI, Non-maskable Interrupt

2024-04-03 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

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

2024-04-03 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 --- v9: - Move nmi_reginfo and related functions inside an existing ifdef TARGET_AARCH64 to solve the

[PATCH v12 19/23] hw/intc/arm_gicv3: Implement NMI interrupt priority

2024-04-03 Thread Jinjie Ruan via
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI priority is higher than 0x80, otherwise it is higher than 0x0. And save the interrupt non-maskable property in hppi.nmi to deliver NMI exception. Since both GICR and GICD can deliver NMI, it is both necessary to check whether the

[PATCH v12 11/23] hw/intc/arm_gicv3: Add external IRQ lines for NMI

2024-04-03 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 Reviewed-by: Peter Maydell --- v11: - Add new Reviewed-by. v4: - Add Reviewed-by. v3: - Add support for VNMI. ---

[PATCH v12 02/23] target/arm: Add PSTATE.ALLINT

2024-04-03 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

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

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

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

2024-04-03 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:

[PATCH v12 00/23] target/arm: Implement FEAT_NMI and FEAT_GICv3_NMI

2024-04-03 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 &

[PATCH v12 07/23] target/arm: Add support for NMI in arm_phys_excp_target_el()

2024-04-03 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

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

2024-04-02 Thread Jinjie Ruan via
On 2024/4/3 0:12, Peter Maydell wrote: > On Sat, 30 Mar 2024 at 10:33, Jinjie Ruan wrote: >> >> 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 >>

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

2024-04-02 Thread Jinjie Ruan via
On 2024/4/3 0:12, Peter Maydell wrote: > On Sat, 30 Mar 2024 at 10:33, Jinjie Ruan wrote: >> >> 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 >>

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

2024-03-30 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

[PATCH v11 17/23] hw/intc/arm_gicv3: Add NMI handling CPU interface registers

2024-03-30 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 non-maskable property. And for

[PATCH v11 00/23] target/arm: Implement FEAT_NMI and FEAT_GICv3_NMI

2024-03-30 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 &

[PATCH v11 10/23] hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU

2024-03-30 Thread Jinjie Ruan via
Wire the new NMI and VINMI interrupt line from the GIC to each CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v9: - Rename ARM_CPU_VNMI to ARM_CPU_VINMI. - Update the commit message. v4: - Add Reviewed-by. v3: - Also add VNMI wire. --- hw/arm/virt.c | 7 ++- 1 file

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

2024-03-30 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

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

2024-03-30 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 --- v9: - Move nmi_reginfo and related functions inside an existing ifdef TARGET_AARCH64 to solve the

[PATCH v11 06/23] target/arm: Add support for Non-maskable Interrupt

2024-03-30 Thread Jinjie Ruan via
This only implements the external delivery method via the GICv3. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v10: - In arm_cpu_exec_interrupt(), if SCTLR_ELx.NMI is 0, NMI -> IRQ, VINMI -> VIRQ, VFNMI -> VFIQ. - Make arm_cpu_update_virq() and arm_cpu_update_vfiq() check that

[PATCH v11 19/23] hw/intc/arm_gicv3: Implement NMI interrupt prioirty

2024-03-30 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

[PATCH v11 16/23] hw/intc/arm_gicv3: Implement GICD_INMIR

2024-03-30 Thread Jinjie Ruan via
Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v11: - Add new Reviewed-by. v10: - superprio -> nmi. v4: - Make the GICD_INMIR implementation more clearer. - Udpate the commit

[PATCH v11 03/23] target/arm: Add support for FEAT_NMI, Non-maskable Interrupt

2024-03-30 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

[PATCH v11 20/23] hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()

2024-03-30 Thread Jinjie Ruan via
In CPU Interface, if the IRQ has the non-maskable property, report NMI to the corresponding PE. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v10: - superprio -> nmi. - Update the commit message, superpriority -> non-maskable. v6: - Add Reviewed-by. v4: - Swap the ordering of

[PATCH v11 12/23] target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()

2024-03-30 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. And VINMI(vIRQ with Superpriority) can be raised from the GIC or come from the hcrx_el2.HCRX_VINMI bit, VFNMI(vFIQ with

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

2024-03-30 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 --- v9: - Declare cpu variable to reuse latter. v4: - Update the comment

[PATCH v11 13/23] hw/intc: Enable FEAT_GICv3_NMI Feature

2024-03-30 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 --- v10: - Adjust to before add irq non-maskable property. v4: - Add Reviewed-by. --- hw/intc/arm_gicv3_common.c

[PATCH v11 08/23] target/arm: Handle IS/FS in ISR_EL1 for NMI, VINMI and VFNMI

2024-03-30 Thread Jinjie Ruan via
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or CPU_INTERRUPT_VINMI, both CPSR_I and ISR_IS must be set. With CPU_INTERRUPT_VFNMI, both CPSR_F and ISR_FS must be set. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v9: - CPU_INTERRUPT_VNMI ->

[PATCH v11 09/23] target/arm: Handle PSTATE.ALLINT on taking an exception

2024-03-30 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 --- v9: - Not check SCTLR_NMI in arm_cpu_do_interrupt_aarch64(). v3: - Add Reviewed-by. --- target/arm/helper.c | 8 1 file

[PATCH v11 07/23] target/arm: Add support for NMI in arm_phys_excp_target_el()

2024-03-30 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

[PATCH v11 11/23] hw/intc/arm_gicv3: Add external IRQ lines for NMI

2024-03-30 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 Reviewed-by: Peter Maydell --- v11: - Add new Reviewed-by. v4: - Add Reviewed-by. v3: - Add support for VNMI. ---

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

2024-03-30 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 ICV_AP1R_EL1.NMI bit. In icv_activate_irq() and icv_eoir_write(), the ICV_AP1R_EL1.NMI bit should be set or clear

[PATCH v11 14/23] hw/intc/arm_gicv3: Add irq non-maskable property

2024-03-30 Thread Jinjie Ruan via
A SPI, PPI or SGI interrupt can have non-maskable property. So maintain non-maskable property in PendingIrq and GICR/GICD. Since add new device state, it also needs to be migrated, so also save NMI info in vmstate_gicv3_cpu and vmstate_gicv3. Signed-off-by: Jinjie Ruan Acked-by: Richard

[PATCH v11 15/23] hw/intc/arm_gicv3_redist: Implement GICR_INMIR0

2024-03-30 Thread Jinjie Ruan via
Add GICR_INMIR0 register and support access GICR_INMIR0. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- v11: - Add new Reviewed-by. v10: - gicr_isuperprio -> gicr_inmir0. v6: - Add Reviewed-by. v4: - Make the GICR_INMIR0 implementation more clearer.

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

2024-03-30 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:

[PATCH v11 21/23] hw/intc/arm_gicv3: Report the VINMI interrupt

2024-03-30 Thread Jinjie Ruan via
In vCPU Interface, if the vIRQ has the non-maskable property, report vINMI to the corresponding vPE. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v10: - Update the commit message, superpriority -> non-maskable. v9: - Update the commit subject and message, vNMI -> vINMI. v6: -

[PATCH v11 02/23] target/arm: Add PSTATE.ALLINT

2024-03-30 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

Re: [PATCH v10 17/23] hw/intc/arm_gicv3: Add NMI handling CPU interface registers

2024-03-29 Thread Jinjie Ruan via
On 2024/3/28 22:50, Peter Maydell wrote: > On Mon, 25 Mar 2024 at 08:53, Jinjie Ruan wrote: >> >> 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

Re: [PATCH v10 14/23] hw/intc/arm_gicv3: Add irq non-maskable property

2024-03-29 Thread Jinjie Ruan via
On 2024/3/28 22:54, Peter Maydell wrote: > On Mon, 25 Mar 2024 at 08:52, Jinjie Ruan wrote: >> >> A SPI, PPI or SGI interrupt can have non-maskable property. So maintain >> non-maskable property in PendingIrq and GICR/GICD. Since add new device >> state, it also needs to be migrated, so also

Re: [RFC PATCH v8 09/23] target/arm: Handle PSTATE.ALLINT on taking an exception

2024-03-28 Thread Jinjie Ruan via
On 2024/3/20 0:47, Peter Maydell wrote: > On Mon, 18 Mar 2024 at 09:37, Jinjie Ruan wrote: >> >> 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

[PATCH v10 08/23] target/arm: Handle IS/FS in ISR_EL1 for NMI, VINMI and VFNMI

2024-03-25 Thread Jinjie Ruan via
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or CPU_INTERRUPT_VINMI, both CPSR_I and ISR_IS must be set. With CPU_INTERRUPT_VFNMI, both CPSR_F and ISR_FS must be set. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v9: - CPU_INTERRUPT_VNMI ->

[PATCH v10 14/23] hw/intc/arm_gicv3: Add irq non-maskable property

2024-03-25 Thread Jinjie Ruan via
A SPI, PPI or SGI interrupt can have non-maskable property. So maintain non-maskable property in PendingIrq and GICR/GICD. Since add new device state, it also needs to be migrated, so also save NMI info in vmstate_gicv3_cpu and vmstate_gicv3. Signed-off-by: Jinjie Ruan Acked-by: Richard

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

2024-03-25 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 --- v9: - Declare cpu variable to reuse latter. v4: - Update the comment

[PATCH v10 17/23] hw/intc/arm_gicv3: Add NMI handling CPU interface registers

2024-03-25 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 non-maskable property. And for

[PATCH v10 09/23] target/arm: Handle PSTATE.ALLINT on taking an exception

2024-03-25 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 --- v9: - Not check SCTLR_NMI in arm_cpu_do_interrupt_aarch64(). v3: - Add Reviewed-by. --- target/arm/helper.c | 8 1 file

[PATCH v10 16/23] hw/intc/arm_gicv3: Implement GICD_INMIR

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

[PATCH v10 19/23] hw/intc/arm_gicv3: Implement NMI interrupt prioirty

2024-03-25 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

[PATCH v10 21/23] hw/intc/arm_gicv3: Report the VINMI interrupt

2024-03-25 Thread Jinjie Ruan via
In vCPU Interface, if the vIRQ has the non-maskable property, report vINMI to the corresponding vPE. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v10: - Update the commit message, superpriority -> non-maskable. v9: - Update the commit subject and message, vNMI -> vINMI. v6: -

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

2024-03-25 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:

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

2024-03-25 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

[PATCH v10 11/23] hw/intc/arm_gicv3: Add external IRQ lines for NMI

2024-03-25 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 ++

[PATCH v10 10/23] hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU

2024-03-25 Thread Jinjie Ruan via
Wire the new NMI and VINMI interrupt line from the GIC to each CPU. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v9: - Rename ARM_CPU_VNMI to ARM_CPU_VINMI. - Update the commit message. v4: - Add Reviewed-by. v3: - Also add VNMI wire. --- hw/arm/virt.c | 7 ++- 1 file

[PATCH v10 15/23] hw/intc/arm_gicv3_redist: Implement GICR_INMIR0

2024-03-25 Thread Jinjie Ruan via
Add GICR_INMIR0 register and support access GICR_INMIR0. Signed-off-by: Jinjie Ruan Reviewed-by: Richard Henderson --- v10: - gicr_isuperprio -> gicr_inmir0. v6: - Add Reviewed-by. v4: - Make the GICR_INMIR0 implementation more clearer. --- hw/intc/arm_gicv3_redist.c | 19 +++

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

2024-03-25 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 ICV_AP1R_EL1.NMI bit. In icv_activate_irq() and icv_eoir_write(), the ICV_AP1R_EL1.NMI bit should be set or clear

[PATCH v10 13/23] hw/intc: Enable FEAT_GICv3_NMI Feature

2024-03-25 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 --- v10: - Adjust to before add irq non-maskable property. v4: - Add Reviewed-by. --- hw/intc/arm_gicv3_common.c

[PATCH v10 12/23] target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()

2024-03-25 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. And VINMI(vIRQ with Superpriority) can be raised from the GIC or come from the hcrx_el2.HCRX_VINMI bit, VFNMI(vFIQ with

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

2024-03-25 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

  1   2   3   4   >