qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	qemu-s390x@nongnu.org, qemu-ppc@nongnu.org,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Corey Minyard" <minyard@acm.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>
Subject: [PATCH 4/4] hw/nmi: Remove @cpu_index argument from nmi_trigger()
Date: Tue, 20 Feb 2024 16:08:33 +0100	[thread overview]
Message-ID: <20240220150833.13674-5-philmd@linaro.org> (raw)
In-Reply-To: <20240220150833.13674-1-philmd@linaro.org>

nmi_monitor_handle() is not related to the monitor,
rename it as nmi_trigger(). Return boolean value
indicating success / failure. The 'cpu_index' argument
is not used, remove it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/nmi.h       | 13 ++++++++++++-
 hw/core/nmi.c          |  9 ++++-----
 hw/ipmi/ipmi.c         |  3 +--
 hw/watchdog/watchdog.c |  2 +-
 system/cpus.c          |  2 +-
 5 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/include/hw/nmi.h b/include/hw/nmi.h
index c70db941c9..32b27067f2 100644
--- a/include/hw/nmi.h
+++ b/include/hw/nmi.h
@@ -49,6 +49,17 @@ struct NMIClass {
     bool (*nmi_handler)(NMIState *n, Error **errp);
 };
 
-void nmi_monitor_handle(int cpu_index, Error **errp);
+/**
+ * nmi_trigger: Trigger a NMI.
+ *
+ * @errp: pointer to error object
+ *
+ * Iterate over all objects implementing the TYPE_NMI interface
+ * and deliver NMI to them.
+ *
+ * On success, return %true.
+ * On failure, store an error through @errp and return %false.
+ */
+bool nmi_trigger(Error **errp);
 
 #endif /* NMI_H */
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index 409164d445..a740f39c98 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -22,11 +22,8 @@
 #include "qemu/osdep.h"
 #include "hw/nmi.h"
 #include "qapi/error.h"
-#include "qemu/module.h"
-#include "monitor/monitor.h"
 
 struct do_nmi_s {
-    int cpu_index;
     Error *err;
     bool handled;
 };
@@ -53,19 +50,21 @@ static int nmi_children(Object *o, struct do_nmi_s *ns)
     return object_child_foreach_recursive(o, do_nmi, ns);
 }
 
-void nmi_monitor_handle(int cpu_index, Error **errp)
+bool nmi_trigger(Error **errp)
 {
     struct do_nmi_s ns = {
-        .cpu_index = cpu_index,
         .err = NULL,
         .handled = false
     };
 
     if (nmi_children(object_get_root(), &ns)) {
         error_propagate(errp, ns.err);
+        return false;
     } else if (!ns.handled) {
         error_setg(errp, "machine does not provide NMIs");
+        return false;
     }
+    return true;
 }
 
 static const TypeInfo nmi_info = {
diff --git a/hw/ipmi/ipmi.c b/hw/ipmi/ipmi.c
index bbb07b151e..45e36a7492 100644
--- a/hw/ipmi/ipmi.c
+++ b/hw/ipmi/ipmi.c
@@ -59,8 +59,7 @@ static int ipmi_do_hw_op(IPMIInterface *s, enum ipmi_op op, int checkonly)
         if (checkonly) {
             return 0;
         }
-        /* We don't care what CPU we use. */
-        nmi_monitor_handle(0, NULL);
+        nmi_trigger(NULL);
         return 0;
 
     case IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP:
diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 955046161b..d324c761aa 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -81,7 +81,7 @@ void watchdog_perform_action(void)
 
     case WATCHDOG_ACTION_INJECT_NMI:
         qapi_event_send_watchdog(WATCHDOG_ACTION_INJECT_NMI);
-        nmi_monitor_handle(0, NULL);
+        nmi_trigger(NULL);
         break;
 
     default:
diff --git a/system/cpus.c b/system/cpus.c
index 68d161d96b..f11ee3d404 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -856,6 +856,6 @@ exit:
 
 void qmp_inject_nmi(Error **errp)
 {
-    nmi_monitor_handle(monitor_get_cpu_index(monitor_cur()), errp);
+    nmi_trigger(errp);
 }
 
-- 
2.41.0



  parent reply	other threads:[~2024-02-20 15:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 15:08 [PATCH 0/4] hw/nmi: Remove @cpu_index argument Philippe Mathieu-Daudé
2024-02-20 15:08 ` [PATCH 1/4] hw/nmi: Use object_child_foreach_recursive() in nmi_children() Philippe Mathieu-Daudé
2024-03-20 13:09   ` Peter Maydell
2024-02-20 15:08 ` [PATCH 2/4] hw/s390x/virtio-ccw: Always deliver NMI to first CPU Philippe Mathieu-Daudé
2024-03-20 13:16   ` Peter Maydell
2024-03-20 14:12   ` David Hildenbrand
2024-02-20 15:08 ` [PATCH 3/4] hw/nmi: Remove @cpu_index argument from NMIClass::nmi_handler() Philippe Mathieu-Daudé
2024-03-20 13:23   ` Peter Maydell
2024-03-20 16:47     ` Philippe Mathieu-Daudé
2024-03-20 19:05       ` Markus Armbruster
2024-03-20 19:39         ` Peter Maydell
2024-02-20 15:08 ` Philippe Mathieu-Daudé [this message]
2024-03-20 13:34   ` [PATCH 4/4] hw/nmi: Remove @cpu_index argument from nmi_trigger() Peter Maydell
2024-02-20 15:19 ` [PATCH 0/4] hw/nmi: Remove @cpu_index argument Thomas Huth
2024-02-20 20:05   ` Philippe Mathieu-Daudé
2024-03-20 11:19   ` Philippe Mathieu-Daudé
2024-03-20 11:44     ` Mark Burton
2024-03-20 12:00     ` Peter Maydell
2024-03-20 12:31       ` Mark Burton
2024-03-20 13:55         ` Peter Maydell
2024-03-20 14:09           ` Mark Burton
2024-03-20 15:00             ` Peter Maydell
2024-03-20 15:40               ` Mark Burton
2024-03-22 14:08               ` Cédric Le Goater
2024-03-22 14:55                 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240220150833.13674-5-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=armbru@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=minyard@acm.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).