From patchwork Tue Feb 20 15:08:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 774269 Delivered-To: patch@linaro.org Received: by 2002:a5d:4943:0:b0:33b:4db1:f5b3 with SMTP id r3csp1699901wrs; Tue, 20 Feb 2024 07:09:51 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUo2N48GWhpr2Y7S3dXNnLQQR7+Tu+cCn0vPzFxlOCVkxlVvOxiIAF23RMTFA571LKvR5Z6cmiLy5ZG7vEEI0LQ X-Google-Smtp-Source: AGHT+IGHU/K6+m6HUadEXkUgkhe3lbIP1W1wDy/zGwtFYD6KHXaX/U4Qg+JZ/xZouuXld65WKk8k X-Received: by 2002:a1f:6603:0:b0:4c9:98f8:83db with SMTP id a3-20020a1f6603000000b004c998f883dbmr5822331vkc.5.1708441790952; Tue, 20 Feb 2024 07:09:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708441790; cv=none; d=google.com; s=arc-20160816; b=yB9y5VcdCOTcWDSI4dX2sXET0oZ+HFT6GvUcPREdYidzoIvMgSD0IC8nb5zovb7oxt jq3zQ0yWF/XsGNTj5OZ1P+Cwm0QX1ONlm0M45ybZkzKzw0eu0MeEE2K3jRve76ONMmge u0hms5aVmbCc+/8fON9RkK6EjiV8DTV94w899z8NBff+DX28BfmIIcQS6WYlfqRO47il Gcc4ThQjozINVdimmsdosfbLZeNK9fpAhZhtlnYgQXicGYCMEAbleFKCVrQ0w5oDF2Wv LC/spxgSuxYwd6joeV+zfoiiJjaC5EpNE2G+OP8OgIBUWE9kLUMe65QI4n6H1Wh/gvHu 8JKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZKFNf1gtsBliHsHbsrrbkJOq0Jz4DmD1IjvRvgcWfg0=; fh=/Kun7NpHNyPa3Ld0Z3cO9MuBbBbPmXyiTFVDShVwRUg=; b=VS2KfiHwYT4Epku9ACbLVt3xKtcFZn44iZtcBD8Xmjsa7CiadXftqq6mVEGbX2xwvF UDwRvlyycjXJlEIkcqKWQdwUg3CZE4muyO3jDtg61/tC+g+c03lRBFpvD6AewHx0G9ad VWr2gTyN+rE373e5/E0EYwqv4wvjO25QNVao0vHLKbNNO68ACcgan4wh7612vImsTKIe MkxdR6lWATTQF/xkUIWjdE15cA5hWl9xdXY8z+dafQVQygNceyoK2By5MEn0UR31Rl97 rfzJrtUS9c73zUKFqEXpKbafH8D76LwwwB8RWpEoWvqSOVvLfcbzxmu/meoNZN5LAJQE mNaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fexEQGh9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y11-20020a05612211ab00b004ca7e35c25esi695614vkn.114.2024.02.20.07.09.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Feb 2024 07:09:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fexEQGh9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcRkJ-0005Fd-C3; Tue, 20 Feb 2024 10:09:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcRk3-00054h-83 for qemu-devel@nongnu.org; Tue, 20 Feb 2024 10:09:07 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcRk1-0003ox-4U for qemu-devel@nongnu.org; Tue, 20 Feb 2024 10:09:06 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40fd72f7125so45872665e9.1 for ; Tue, 20 Feb 2024 07:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708441742; x=1709046542; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZKFNf1gtsBliHsHbsrrbkJOq0Jz4DmD1IjvRvgcWfg0=; b=fexEQGh9XEL8qUstAtojl0IVHEEyKJbK0ajvhXPcORIQZGdbcZT4FKZ3suIauvIwBY K4NYx1FZkh7FDp16IgqWPGYN6idxtqOudJbhA+81O0W8vVAuDbaNKwrfOiTyLioGDtQD 0zOvHyEz6a09gDPeKH0WPMnzxdoBx1qfOw/hGiEZfpOiIM2pp0cJteyFmedWfYUX+B0O k9O6goS6wPzhtadfvgghHAYbP5C2u0XitAmUcobPG+YhVMeD8Wms8xLXSYj2weQomgoO G9Vxpjn7mBi4Rnj6V7j2yTRKOJqkzzl1DTiRdJeBhGoPwtWMHxpdp7ZWqK7J37MjXwKy wDJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708441742; x=1709046542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZKFNf1gtsBliHsHbsrrbkJOq0Jz4DmD1IjvRvgcWfg0=; b=BLZsGQTJ3ikpl4u6/4NNoMF0ZNQzJPltFaCqNHXSJZgOzm2d4PTCf2+T3ko/JkoCP1 h0SaBYSjQFn+B1U112dG7jbUD38IOpKU+zj74Qg6i9Moundwlt0g5wfj0ygXJOmOdIP9 Sp2cW9Fp5jz1TloHsJlX1zM3CXFoYfewMauXOwiEmBypTW83Yk6SnhGDCu+KlVMaTCsx OIm/mFkKOlsnJVUqtw/fM90VGW3z+p0Pj+E6vTTronNCXf6d4JfJHj2EaJ0rHMdNgQTW j3xYUC/HgfFog+RjReSSdT9UGuHH1nqKTA3QhJeDVncQBUxRssnVWfJYJGOG63ohIMGi 106A== X-Gm-Message-State: AOJu0Yxjf0rzb4JBvjtQlO3UWjuS1vKll3ZAxL14LsH9iu94/QZ8XXLF YPgF8v5686TUBppxS9R20M/UXj6MVUsFtqGnRMWlLsMuKBRcvL6ljuNWvjkM0HM+w0VWfycuQba t X-Received: by 2002:a05:600c:198a:b0:412:6d66:c88 with SMTP id t10-20020a05600c198a00b004126d660c88mr1686022wmq.23.1708441742437; Tue, 20 Feb 2024 07:09:02 -0800 (PST) Received: from m1x-phil.lan (mek33-h02-176-184-23-7.dsl.sta.abo.bbox.fr. [176.184.23.7]) by smtp.gmail.com with ESMTPSA id r13-20020a05600c35cd00b00410c7912c6esm15202117wmq.14.2024.02.20.07.09.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Feb 2024 07:09:01 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Markus Armbruster , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Christian Borntraeger , =?utf-8?q?Philippe_Mathi?= =?utf-8?q?eu-Daud=C3=A9?= , Corey Minyard , Paolo Bonzini , Richard Henderson Subject: [PATCH 4/4] hw/nmi: Remove @cpu_index argument from nmi_trigger() Date: Tue, 20 Feb 2024 16:08:33 +0100 Message-ID: <20240220150833.13674-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240220150833.13674-1-philmd@linaro.org> References: <20240220150833.13674-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.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é --- 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); }