qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/4] hw/s390x/virtio-ccw: Always deliver NMI to first CPU


From: Peter Maydell
Subject: Re: [PATCH 2/4] hw/s390x/virtio-ccw: Always deliver NMI to first CPU
Date: Wed, 20 Mar 2024 13:16:06 +0000

On Tue, 20 Feb 2024 at 15:09, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> 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 maintainance, update s390_nmi()
> to deliver NMI to the first CPU.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  qapi/run-state.json        | 5 +++--
>  hw/s390x/s390-virtio-ccw.c | 4 +---
>  hmp-commands.hx            | 2 +-
>  3 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/qapi/run-state.json b/qapi/run-state.json
> index 08bc99cb85..a2542f1a50 100644
> --- a/qapi/run-state.json
> +++ b/qapi/run-state.json
> @@ -320,8 +320,9 @@
>  #
>  # @none: nothing is done
>  #
> -# @inject-nmi: a non-maskable interrupt is injected into the first
> -#     VCPU (all VCPUS on x86) (since 2.4)
> +# @inject-nmi: a non-maskable interrupt is injected (architecture
> +#     specific: on s390x only the first vCPU receive the NMI, on

"receives"


> +#     other architectures all vCPUs receive it). (since 2.4)

This part isn't really true, because it's machine-specific rather
than architecture-specific (and many architectures don't implement
it at all). But I don't think we want to introduce that doc cleanup into
this patch. Maybe we should leave it as only saying "all vCPUs on x86",
though.

>  #
>  # Since: 2.1
>  ##
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index 62804cc228..ba1fa6472f 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -605,9 +605,7 @@ static HotplugHandler 
> *s390_get_hotplug_handler(MachineState *machine,
>
>  static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
>  {
> -    CPUState *cs = qemu_get_cpu(cpu_index);
> -
> -    s390_cpu_restart(S390_CPU(cs));
> +    s390_cpu_restart(S390_CPU(first_cpu));
>  }
>
>  static ram_addr_t s390_fixup_ram_size(ram_addr_t sz)
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 17b5ea839d..2b01bb5926 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -851,7 +851,7 @@ ERST
>      },
>  SRST
>  ``nmi`` *cpu*
> -  Inject an NMI on the default CPU (x86/s390) or all CPUs (ppc64).
> +  Inject an NMI.
>  ERST
>
>      {

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]