From patchwork Thu Jan 20 12:36:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 533563 Delivered-To: patch@linaro.org Received: by 2002:adf:f849:0:0:0:0:0 with SMTP id d9csp15749wrq; Thu, 20 Jan 2022 09:15:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxofwh03nXnIevJWPywhIHpJolnhYGki3jlgDfxAZjHfwholtpadQGSHexduOVt0WzU/zFz X-Received: by 2002:a1f:1953:: with SMTP id 80mr15314419vkz.8.1642698926599; Thu, 20 Jan 2022 09:15:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642698926; cv=none; d=google.com; s=arc-20160816; b=ZDRrPEMZ0m9LXS7wdpSbA/IbR/j5HEa1ca0JY3Nl0d/8KLJhcK2UyugKM1g5eJLMLL vwo8RMDILu40g0VyH63tNfESatujTUEZLcg36TusIwN65B5dsERRAFNsMmlNE7KBe7Dc mzQPsc/ApiVeWOvqgE7Go/Ay8JyLOcA/uRmAETrijaozkTkln0KtcZpfNHLKB/8dmnO8 IqoX7jEmxzNLnLObR0qh99NH6yC1YVPjj6CmW46aNVYQPebwpjMsE06EIW/qBQN6MZPu o+WAbSZ+Afk6vs1AOuNPywVzXfPnHaotI3XNsCE/xDVJu+mfpAEIVQvzSN8o798LQZoC xfoA== 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:to:from :dkim-signature; bh=FZNzOyeGj4/sq8Srv8WNLvy4rb7thXkM78LTfwnMVmc=; b=M6UfNABPnTbwlAPqWsb0VfO7MciHqhB60wpak7xIbWcy3ICAhN0tNK6x+X/DZeqft9 jFkGLhal6SCWPIk1K4Ep21oFeqCI7uUdX6+kS7uUN0KuK3Aw/9TVvjxqWkeuNb3hKiuR Twofsau1MrLaq7y391rz6ciDJLxNXDmnf63eV/3qSgQ+14OFqmYkGmLd0cY7v24iM8rt Vps8dQE8lEiwovTvc5ZGLLv8zcuOGaKdB/6HeD2No0iDPV+7k1xxWdTFxuCqvsvnIlVG EgQWRN2qDoS4HqyquOo8TjQkEU+FcZp7MhpPyBi8qKc62t8vQiyVALRWOVgHYJ5lnonY DZaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tPiJtsp6; 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 q25si690189vsj.730.2022.01.20.09.15.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Jan 2022 09:15:26 -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=tPiJtsp6; 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]:42444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAb1x-0000Qg-5C for patch@linaro.org; Thu, 20 Jan 2022 12:15:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAWgN-0004Bc-FC for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:36:52 -0500 Received: from [2a00:1450:4864:20::32a] (port=43637 helo=mail-wm1-x32a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAWgJ-00039p-52 for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:36:50 -0500 Received: by mail-wm1-x32a.google.com with SMTP id e9-20020a05600c4e4900b0034d23cae3f0so13398904wmq.2 for ; Thu, 20 Jan 2022 04:36:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FZNzOyeGj4/sq8Srv8WNLvy4rb7thXkM78LTfwnMVmc=; b=tPiJtsp6J2VAAB1jEFZg62QZhuPg3UYg8bAcABT8OdUbwtsCaGCBGW/v/XvqS7Rclo iqhZiAj+h2dlDN2NCmqqKJl07yVH24a2baN7Ucu6kpEYsCugnr5rfZDbDgCp71NGNXDA 9TtjUTvH0Jd4XXfxBzIXYIkYSTehZTgT7pB2imC8jMQCoD3M2rn7PEKJBQhOosNNTfT/ ScvBSeOxkvEpT99XfNOKenvEiTRDGP/Ks3tWE+ujas2s240yUoKTD0dGRqRFCdKQNAEp Zx++ihOxqIn0Ouo3CNiJf33hM7LXyWdJIyfZIiRZQwIGmIuPl4fApeVseiFhJ93xYWJn dr8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FZNzOyeGj4/sq8Srv8WNLvy4rb7thXkM78LTfwnMVmc=; b=PMv57EUvLOdBzgCgOLXAijhu8IGnyZ+J1AS0r/iuxdbr1nRzCXiiMFV6WwLdGYQDov JBOUoXTZiq0ShCBG00mw0T7Xm+EjcGEtVlxVy623697z3umpZbswhZx2ittNA9mWkCN9 uyEtYL10x0i8bzQdBtSNF4bchI5u8/ud//5jKIniQx3SG/G5bXVLUOQ+Y+FHr3w8acNm B7zfx+L+Uu0iLz3CDvu4l+TZalBPKubbAfjHt1Ul2gGKxbmI/ooLTuznx/dmpWXmaXIN znM74jKTEInuAcJoyt0OR/f073T9dS+9j1Vnxrw7QcFmzdmnXVWv3wJAdu4mQuI6+467 pS9A== X-Gm-Message-State: AOAM5319Mi3uSchaLga7hzdYFPK1H8ZSGlvUWSe8+Xmoecd/fYDbsDTi 04+h4/PIG0LyXdtxc77bw5Q/cOCQv9NhLw== X-Received: by 2002:adf:fa91:: with SMTP id h17mr417582wrr.189.1642682204891; Thu, 20 Jan 2022 04:36:44 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t8sm7993324wmq.43.2022.01.20.04.36.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 04:36:44 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/38] hw/intc/arm_gic: Allow reset of the running priority Date: Thu, 20 Jan 2022 12:36:07 +0000 Message-Id: <20220120123630.267975-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220120123630.267975-1-peter.maydell@linaro.org> References: <20220120123630.267975-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32a (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" From: Petr Pavlu When running Linux on a machine with GICv2, the kernel can crash while processing an interrupt and can subsequently start a kdump kernel from the active interrupt handler. In such a case, the crashed kernel might not gracefully signal the end of interrupt to the GICv2 hardware. The kdump kernel will however try to reset the GIC state on startup to get the controller into a sane state, in particular the kernel writes ones to GICD_ICACTIVERn and wipes out GICC_APRn to make sure that no interrupt is active. The patch adds a logic to recalculate the running priority when GICC_APRn/GICC_NSAPRn is written which makes sure that the mentioned reset works with the GICv2 emulation in QEMU too and the kdump kernel starts receiving interrupts. The described scenario can be reproduced on an AArch64 QEMU virt machine with a kdump-enabled Linux system by using the softdog module. The kdump kernel will hang at some point because QEMU still thinks the running priority is that of the timer interrupt and asserts no new interrupts to the system: $ modprobe softdog soft_margin=10 soft_panic=1 $ cat > /dev/watchdog [Press Enter to start the watchdog, wait for its timeout and observe that the kdump kernel hangs on startup.] Signed-off-by: Petr Pavlu Message-id: 20220113151916.17978-3-ppavlu@suse.cz Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/arm_gic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 0cd9ceca8d1..492b2421ab4 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -1736,6 +1736,7 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset, } else { s->apr[regno][cpu] = value; } + s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu); break; } case 0xe0: case 0xe4: case 0xe8: case 0xec: @@ -1752,6 +1753,7 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset, return MEMTX_OK; } s->nsapr[regno][cpu] = value; + s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu); break; } case 0x1000: