From patchwork Tue Feb 20 15:08:31 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: 774267 Delivered-To: patch@linaro.org Received: by 2002:a5d:4943:0:b0:33b:4db1:f5b3 with SMTP id r3csp1699787wrs; Tue, 20 Feb 2024 07:09:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWJ7iziIMbx1qpBX5XqCbEKkPIwWYP5pgCd/5SoTA0nNn7n4oakKnqOnmzXBV3y3wl4O0PdeP5GRa81ZVlHohgU X-Google-Smtp-Source: AGHT+IH1SxT8QPjUy5XA4IGKlh0Q+LosNFktj0dvDctss0fwOzROlioPEQhY+j+HRB2gJxnqavoA X-Received: by 2002:a05:622a:1196:b0:42e:1f86:3910 with SMTP id m22-20020a05622a119600b0042e1f863910mr4618785qtk.62.1708441778824; Tue, 20 Feb 2024 07:09:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708441778; cv=none; d=google.com; s=arc-20160816; b=v+hpP8O1oJ/RczBMnP+243hhkZLdcl2hiRSuelA/ASP3a+RouzFm2YhAl/LW5xoBpO HchZamsTwO8PzEH1Ho05hp34I5cS6UkUnGWPj58gSW+YMU17h34i70VFpq9AlrkkJc7p BsOtr0ReUKT4ZSZX+6zbcUjDV5l8zXQQrISpeu7a+mTKx9xGsfe20C4JEs8Z1txxnrsW QX8WvCEEW3liglhORNog26oSYN6tsGZl+HqQarQwRBGXi0HnMTClr9KSRnN1Hr0ffV6Y ces5lvuOi2SoNhzaB3b5f2lNN67qUc55lKqDy/iYYZT5CTl0zXpCFuDLFpe8VjIqeGSv u1mQ== 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=9BjoHKgBAqJhVWzvihYewG3Mo1EyFTHucbJxjZyHAzY=; fh=mb86JNre3oQjGuH95DPd3qgDTY1GRs15m6ZKblGCJhs=; b=MmeVPaHnOkTdOA6T+RzB1dACU0zuQ1vjTMBoomkyrVDPNj7jg8ovvmk2L+kNyTbcdp W+buET5ET5rTXWl2B5IDGO2TIaD2HduAIowbkTY09xK26+NNgVyX10CHnHnscwYV6RC9 NKpND3pt21sHbdugMJ/5GYfM+QxEJS8tZBzZNU6ieitzTHKM2dvBJ29oB8NTpy8BHOfS ujDGD6GoqdTwaRfRHbRG2EwddB+MXCWcCc76NRbUN5BUrN3ivbmtnn76j0GTMAi4axKB Z55L8YscGT6CezpOwWyR1CVsP8Nx9mnVTnhdCwmwddNCCRezjA6TkLs5EGTNtV926DVu rHDA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AF+XmJU8; 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 f12-20020ac85d0c000000b0042df03d75a7si8904850qtx.116.2024.02.20.07.09.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Feb 2024 07:09:38 -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=AF+XmJU8; 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 1rcRjs-0004hq-GP; Tue, 20 Feb 2024 10:08:56 -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 1rcRjp-0004bp-Iu for qemu-devel@nongnu.org; Tue, 20 Feb 2024 10:08:53 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcRjn-0003n8-Kx for qemu-devel@nongnu.org; Tue, 20 Feb 2024 10:08:53 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33d375993f4so1577153f8f.1 for ; Tue, 20 Feb 2024 07:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708441729; x=1709046529; 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=9BjoHKgBAqJhVWzvihYewG3Mo1EyFTHucbJxjZyHAzY=; b=AF+XmJU8/fUgGnqSZvgXti+xcRjoOEmzKEXYzoEXX8ml2TopiLAI4hY9B+EUzWxZwC XX5qqKBICmOCl7znej2swDKPfbWhJbkBurQR39gScvF4F9hPnJbun7UMfkfI5w5Ir8s1 Jq7DBfbiLvZ9v2+/qjZa89cNYojP6IG0IWUlKgEONicpaIoEi/cirphZg0QURl7TZzFc 8iJCZPILL7iBjl4hHGeJzXTCSXKC6MkOjTe+EjrjWSlsP7EEMlsuy1x7zvmk6uaQiyGb 8ismPWGXnRCEdLNoLD43PlN7U3Wb4xCCVDQF9xWUeen0CPRx1C6USsDVHdugqS2bVmMB /FTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708441729; x=1709046529; 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=9BjoHKgBAqJhVWzvihYewG3Mo1EyFTHucbJxjZyHAzY=; b=o8nURtsClWlt6IgDEa3CZEXlpxzTDfUnV2R2PuL/goJIGUtbhzPQSW8KoN3XBoHtWH fWDAXFPxNda235+jrseUR3CpcTYPoqdT7/EmWKzuCiSBhRN+cwk5Cdu3chVbGHN3QDZ+ Zlvi+BlGKAUxN2B+23SmOwUu3sKKWcSSuuKwW4aukWlSmDEw5tZqbfpRvXiasdioUHO5 raDTP0V6hJK9hHKDxUo9fcbBuL8pb2ZVL2nmUVv0bP0o1v9dBNy9JEEPaqi3Hrwtb2lo jIQliuczg/DH3kCi9yyJBCwJsk9gasRVszT4UE0eZXlsUxDv1/ZClA7aZZOuRjSeqSAV Q0pQ== X-Gm-Message-State: AOJu0Yzn3oQqWbkRAEDiVJ48feVFl5yJqLhRuSEnwhr90HJSTl9ZvwwR +8qOAavr5Gcid6XGAj72PYGn58eTHEt2mEK27DgIZu9bu+mQtATi86iI/buvy1LfkIn+CPjPpXj y X-Received: by 2002:a05:6000:887:b0:33d:6bc6:26ef with SMTP id cs7-20020a056000088700b0033d6bc626efmr2045846wrb.14.1708441729095; Tue, 20 Feb 2024 07:08:49 -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 14-20020a056000154e00b0033d10bd6612sm14090980wry.81.2024.02.20.07.08.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 20 Feb 2024 07:08:48 -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?= , "Dr. David Alan Gilbert" , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Halil Pasic , Eric Farman , Eric Blake , Paolo Bonzini Subject: [PATCH 2/4] hw/s390x/virtio-ccw: Always deliver NMI to first CPU Date: Tue, 20 Feb 2024 16:08:31 +0100 Message-ID: <20240220150833.13674-3-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::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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 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é Reviewed-by: Peter Maydell Reviewed-by: David Hildenbrand --- 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 +# other architectures all vCPUs receive it). (since 2.4) # # 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 {