From nobody Mon Nov 10 12:49:24 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1556630232; cv=none; d=zoho.com; s=zohoarc; b=eTO4cbyceD7cIVkML1wogftDhCNB9DXnwhYBF50MVnPZtPzMBKCdzAQVG0aK9nTFHc9U1DZcUXrKpOEQ8QqbR4VoqqZnf9RH6WHUisFhZy3G2IkWY/mdZN7/SPXHMo+z06Ol+Rvr5L/bqwUwr3+ebERnk8IPUSLc69Ijm8QTxt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556630232; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=U/R8O7Qr7W3Gev40Mu9XCs2DcqDhxle1cGlCTNhZ1V0=; b=Bl7orAWVNs4WBlWmFj0epTzKGr7LnCpSizqjklG32EZzfOQ4wOoHgsMrD3Dh3L+4zuEteUnumbTXPB3k35CB4J6SQksd3GaWYVOzl4J++/qCOr6S9AO9K+o6qjq/Tuj6Mi8iKTvw9kwmt6+jEeP1aNCwjOFa8EdCTPZ+fNTCZSk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556630232622657.4711614727948; Tue, 30 Apr 2019 06:17:12 -0700 (PDT) Received: from localhost ([127.0.0.1]:47147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLScz-0002So-3a for importer@patchew.org; Tue, 30 Apr 2019 09:16:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLSar-00010e-0H for qemu-devel@nongnu.org; Tue, 30 Apr 2019 09:14:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLSap-0002Aw-Vu for qemu-devel@nongnu.org; Tue, 30 Apr 2019 09:14:44 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:38205) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLSap-0002AJ-Pa for qemu-devel@nongnu.org; Tue, 30 Apr 2019 09:14:43 -0400 Received: by mail-wm1-x341.google.com with SMTP id w15so3791786wmc.3 for ; Tue, 30 Apr 2019 06:14:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a12sm16557460wrh.46.2019.04.30.06.14.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 06:14:42 -0700 (PDT) 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=U/R8O7Qr7W3Gev40Mu9XCs2DcqDhxle1cGlCTNhZ1V0=; b=Q1AiOBUhsGvl0IcKOiLai/mtenqy4Kr17qXwXw5RbT+iBk1OYQnlLt6o4LpTxPzjSd td87MSU842aTbeQWtWHjklKn2qP8eIJlXdswud2xVGarUy+9Jx9RtuZOcsSp1NuB3mBu Xf9rcgYwhP8dqWpJtLvI37VjX9iGENpCNK139NHnpcvrQ33h1tu0eJIFGmMVSyeYkTXn RA0nPQtup+N08tvyskTvCxzpDHGiqvUaIhTXOk67RGuNOLaLPP4pWyQpKtQnjfof3lkN w71P9TLydNHwbUIdZKgg6H4jvm3lmgReNUmuBa63j8NiqFJurb/Z9PFQ7UeB/w86ll0J ZeUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U/R8O7Qr7W3Gev40Mu9XCs2DcqDhxle1cGlCTNhZ1V0=; b=DhqKi1pSZEvY4cFXZ1L6nq7K6ZOk3h3oKoJbkGDt7Uk6mm5pOWUBXQRRQRKiZvWb/7 PSAUKJHB/eQmUL4NMUk0qWnFaTNcscXZk85a08XZqVq0UX9r631CTnMlxNXjvwhCXjJt veq2p4qlC5lJ7uvrBJ1ztfCeawlifY56m4j52NqWYzNMlpsAV3LcV3BLFKai0VgJjP3/ ApKu47HLqhVL9cx2aFmNgB/1uQzkH1nJBYrBvFSe9xMKdCgEsaRI7EIwdwyX3qPxfAw/ Dk9esSYpSFiCcTC5B8lLL+8ewQmUPTNxnnrHWQmJceP7MQi447uaOSDaNMlu7eUR1Z+G Czfg== X-Gm-Message-State: APjAAAWF5a65RzQHH0RbeC+LfwTBbiwsPLgCljpB2tEQ9UKZwhet++YH 8ZsK4B4UTEIZyKYHi3kt66AYmA== X-Google-Smtp-Source: APXvYqyW0sTuY6hcViJsEKypB8BM3Se7PQcuwyHwAntt6B5e2zeRE2VOzjATSx+EZivodfsBsMGsGg== X-Received: by 2002:a05:600c:2506:: with SMTP id d6mr450717wma.106.1556630082710; Tue, 30 Apr 2019 06:14:42 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 14:14:36 +0100 Message-Id: <20190430131439.25251-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190430131439.25251-1-peter.maydell@linaro.org> References: <20190430131439.25251-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH 1/4] hw/arm/armv7m_nvic: Check subpriority in nvic_recompute_state_secure() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Rule R_CQRV says that if two pending interrupts have the same group priority then ties are broken by looking at the subpriority. We had a comment describing this but had forgotten to actually implement the subpriority comparison. Correct the omission. (The further tie break rules of "lowest exception number" and "secure before non-secure" are handled implicitly by the order in which we iterate through the exceptions in the loops.) Signed-off-by: Peter Maydell --- hw/intc/armv7m_nvic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index fff6e694e60..131b5938b9a 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -213,6 +213,7 @@ static void nvic_recompute_state_secure(NVICState *s) int active_prio =3D NVIC_NOEXC_PRIO; int pend_irq =3D 0; bool pending_is_s_banked =3D false; + int pend_subprio =3D 0; =20 /* R_CQRV: precedence is by: * - lowest group priority; if both the same then @@ -226,7 +227,7 @@ static void nvic_recompute_state_secure(NVICState *s) for (i =3D 1; i < s->num_irq; i++) { for (bank =3D M_REG_S; bank >=3D M_REG_NS; bank--) { VecInfo *vec; - int prio; + int prio, subprio; bool targets_secure; =20 if (bank =3D=3D M_REG_S) { @@ -241,8 +242,12 @@ static void nvic_recompute_state_secure(NVICState *s) } =20 prio =3D exc_group_prio(s, vec->prio, targets_secure); - if (vec->enabled && vec->pending && prio < pend_prio) { + subprio =3D vec->prio & ~nvic_gprio_mask(s, targets_secure); + if (vec->enabled && vec->pending && + ((prio < pend_prio) || + (prio =3D=3D pend_prio && prio >=3D 0 && subprio < pend_s= ubprio))) { pend_prio =3D prio; + pend_subprio =3D subprio; pend_irq =3D i; pending_is_s_banked =3D (bank =3D=3D M_REG_S); } --=20 2.20.1