@samitouri / QOSamiQemu / commits / c489b04fbc

hw/s390x/virtio-ccw: Always inject NMI to first CPU

We can trigger NMI from HMP or QMP. QEMU maps the NMI to the s390x per-CPU 'RESTART' interrupt. Linux guests usually setup this interrupt to trigger kdump or crash. Such crashdump can be triggered in QEMU by HMP "nmi" or QMP "inject-nmi" commands. Using QMP, since we can not select a particular CPU, the first CPU is used (CPU#0). See the documentation from commit 795dc6e4 ("watchdog: Add new Virtual Watchdog action INJECT-NMI"): @inject-nmi: a non-maskable interrupt is injected into the first VCPU (all VCPUS on x86) (since 2.4) While we can select a particular CPU on HMP, the guest behavior is expected to be the same if using CPU #N or CPU #0. Since always using CPU#0 simplifies API maintenance , update s390_nmi() to inject NMI to the first CPU. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Eric Farman <farman@linux.ibm.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20260812121232.71958-3-philmd@oss.qualcomm.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>

Philippe Mathieu-Daudé committed Feb 20, 2024 at 14:28 UTC c489b04fbc94e7f738704b2b85e88d92ecf5cc6f
4 files changed +12 -10
hmp-commands.hx
+3 -2
@@ -865,12 +865,13 @@ ERST
865 .name = "nmi",
866 .args_type = "",
867 .params = "",
868 - .help = "inject an NMI",
868 + .help = "Inject an NMI, in a machine-specific way",
869 .cmd = hmp_nmi,
870 },
871 SRST
872 ``nmi`` *cpu*
873 - Inject an NMI on the default CPU (x86/s390) or all CPUs (ppc64).
873 + Inject an NMI, in a machine-specific way.
874 + Not all machines implement NMI handling.
875 ERST
876
877 {
hw/s390x/s390-virtio-ccw.c
+1 -3
@@ -727,9 +727,7 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
727
728 static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
729 {
730 - CPUState *cs = qemu_get_cpu(cpu_index);
731 -
732 - s390_cpu_restart(S390_CPU(cs));
730 + s390_cpu_restart(S390_CPU(first_cpu));
731 }
732
733 static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp)
qapi/machine.json
+4 -3
@@ -432,9 +432,10 @@
432 ##
433 # @inject-nmi:
434 #
435 -# Injects a Non-Maskable Interrupt into the default CPU (x86/s390) or
436 -# all CPUs (ppc64). The command fails when the guest doesn't support
437 -# injecting.
435 +# Injects a Non-Maskable Interrupt (machine specific: for example on
436 +# s390x CCW only the first vCPU receives the NMI, but on x86 machines
437 +# all vCPUs receive it). The command fails when the guest doesn't
438 +# support injecting.
439 #
440 # Since: 0.14
441 #
qapi/run-state.json
+4 -2
@@ -317,8 +317,10 @@
317 #
318 # @none: nothing is done
319 #
320 -# @inject-nmi: a non-maskable interrupt is injected into the first
321 -# VCPU (all VCPUS on x86) (since 2.4)
320 +# @inject-nmi: a non-maskable interrupt is injected (machine
321 +# specific: for example on s390x CCW only the first vCPU
322 +# receives the NMI, but on x86 machines all vCPUs receive
323 +# it). (since 2.4)
324 #
325 # Since: 2.1
326 ##