From nobody Fri May 10 16:58:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1638182484; cv=none; d=zohomail.com; s=zohoarc; b=X2zHn4mvwFjJeVsTNe865iz06KvGo6jiC6FYa8c93OZ3ds3AxFve9Kt5jBG0Bk9BeNLLVsgTZ2Maa8V8AGDQHAE482ZlJDdekNviccRR6SGEK0TzxeipELaVtycaYGHm6us213ukG4PFhVNCiDUyAep15FGDhUmBYucJYbusymI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638182484; 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; bh=l7d78ATa07OlF5TV8mrAqS1LhRjfotGyqwUydTrZV04=; b=fRkRoF4dXJY1hLQnkF0Fsgi/bYJXGwbwQYObMI1KVireExvzWOkxwidNp8OEUE6T8oteCRbqkdN+Np1/zRf/nPMS2KWuNsf8ckMh9SuV7rvPz0dZI/EoxyKs0zHIHV4QdrhKm2LxMX004OoCjR1azUX32PzhcsXufbQSCseEeks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638182484473873.3456246572678; Mon, 29 Nov 2021 02:41:24 -0800 (PST) Received: from localhost ([::1]:33180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mre67-0005CD-1v for importer@patchew.org; Mon, 29 Nov 2021 05:41:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mre49-0002Nu-Gr for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:21 -0500 Received: from [2a00:1450:4864:20::32f] (port=45844 helo=mail-wm1-x32f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mre48-0004mV-30 for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:21 -0500 Received: by mail-wm1-x32f.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so12042469wme.4 for ; Mon, 29 Nov 2021 02:39:19 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t17sm18810912wmq.15.2021.11.29.02.39.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 02:39:17 -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=l7d78ATa07OlF5TV8mrAqS1LhRjfotGyqwUydTrZV04=; b=MsgRM629o+ICVqkUNxnz7E8hIrTiWm8pIfPQNWvleXOP/bXtOYq25WjkNPlFKzMwFj qjZau19jE2qTbnCYMMJMO+ZK8ws7UWsX8SrTQevVp3S5JfTEjp0wg4L83lPNHwMHotc2 ES9ZSWo8gfQl17DIrNc45aIN4qWVwe/InNii6u3MurrhX/UONSpSKKTZMPcvOS6yT18z KVt3yg9VLCZfpv5wN0peUVIMu1E7zczn3+MSvWgSDQVZp7ZhRAu2zSUS/Z5yqKxNyv9l sUtlCJRsWeu9IJCs4KzQ7Az50UDXFUMnebANGEmivZPRn9/jNVx+I1CsW6ABwifkra+l apLg== 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=l7d78ATa07OlF5TV8mrAqS1LhRjfotGyqwUydTrZV04=; b=fIC/VeM4jyAOkjTELPTgWDsyCBD6sZWpLS130ItAwCJmv2R6M7MqQL9D4WTDbdzkuD WNtw66DpKLjv3Wn1cVQAj1gcNZ8hIoceXBEIQSwMe8WKu6QCJlsNyoiyDC0l3x7aRq8o anItqOd49vZI1sBJQgrcH/BBUiSgaLATMJt/foIJ5j3B2V6zUkunO+lrXmDqDu1da5RK wG7sATYuhlpqV6JQs2O5cpBcksuDoxsdJzggUzvEMWK7JmxKzqMtu0Y7Z01rkTcKiDh0 PopyF6qC7iK58OgC5ixC0DXW4zWTkgbNGNHpJkHs2AMVPfwX/H85bXhc0XaaAFlJ1P1d sqtQ== X-Gm-Message-State: AOAM5326SmvuGOCc+4v67DzxB1w93EmLHX7DfRwpXyW5Z2ueJS3lTLcx KxR8PND4pYLrmU9J6EI8xu+r08Vw0AEETg== X-Google-Smtp-Source: ABdhPJysgIPRKYhg9vadY0uNxvQ0Xl+D0152JWC5VH2DH7DIhESVium3x+Fg7rKHY9s8X31baicv5A== X-Received: by 2002:a05:600c:1d0e:: with SMTP id l14mr34841861wms.64.1638182358118; Mon, 29 Nov 2021 02:39:18 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/5] hw/arm/virt: Extend nested and mte checks to hvf Date: Mon, 29 Nov 2021 10:39:11 +0000 Message-Id: <20211129103915.1162989-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211129103915.1162989-1-peter.maydell@linaro.org> References: <20211129103915.1162989-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1638182485097100001 Content-Type: text/plain; charset="utf-8" From: Alexander Graf The virt machine has properties to enable MTE and Nested Virtualization support. However, its check to ensure the backing accel implementation supports it today only looks for KVM and bails out if it finds it. Extend the checks to HVF as well as it does not support either today. This will cause QEMU to print a useful error message rather than silently ignoring the attempt by the user to enable either MTE or the Virtualization extensions. Reported-by: saar amar Signed-off-by: Alexander Graf Message-id: 20211123122859.22452-1-agraf@csgraf.de Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/virt.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 369552ad45a..30da05dfe04 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -49,6 +49,7 @@ #include "sysemu/runstate.h" #include "sysemu/tpm.h" #include "sysemu/kvm.h" +#include "sysemu/hvf.h" #include "hw/loader.h" #include "qapi/error.h" #include "qemu/bitops.h" @@ -1969,15 +1970,17 @@ static void machvirt_init(MachineState *machine) exit(1); } =20 - if (vms->virt && kvm_enabled()) { - error_report("mach-virt: KVM does not support providing " - "Virtualization extensions to the guest CPU"); + if (vms->virt && (kvm_enabled() || hvf_enabled())) { + error_report("mach-virt: %s does not support providing " + "Virtualization extensions to the guest CPU", + kvm_enabled() ? "KVM" : "HVF"); exit(1); } =20 - if (vms->mte && kvm_enabled()) { - error_report("mach-virt: KVM does not support providing " - "MTE to the guest CPU"); + if (vms->mte && (kvm_enabled() || hvf_enabled())) { + error_report("mach-virt: %s does not support providing " + "MTE to the guest CPU", + kvm_enabled() ? "KVM" : "HVF"); exit(1); } =20 --=20 2.25.1 From nobody Fri May 10 16:58:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1638182557; cv=none; d=zohomail.com; s=zohoarc; b=FO27/J+kRGWrMkJvooLkF2zZ2OvZwEQOkcJdTHpuTm53ApTxJ3wiW/p6ZKYYn2AJ71kT4kLMtaGl//AEh1kzvTQBpn70OGZzRcAPkzjdrzVgAyvDU/zYOc8DpXbtZv9rhIe+EkcbaWfQsCWtOOggkqsZp0hMMmA1oHxR/87heec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638182557; h=Content-Type: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; bh=6uEVSjpgTVy8n9IaNTLJk5fiY17QBGe2oJgmoK4hlrk=; b=ks3TwUPnnLKDoRtWaiZlzOfCN97MfoH/SwfUdyiRCBXbuxGKuMd7pZC0RUMb5m+SMED5lYesWJABQlJjBUsK0JalNq9cpPOG6HT9hAt3S9S3tVzNRbwmBYKIezmDujGuPduR/EK/FxGGUz16up9j1upGhPf4b+LXOBXIpyMg+Bg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638182557476165.16306545179566; Mon, 29 Nov 2021 02:42:37 -0800 (PST) Received: from localhost ([::1]:35726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mre7I-0006tT-9X for importer@patchew.org; Mon, 29 Nov 2021 05:42:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mre4B-0002OC-39 for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:23 -0500 Received: from [2a00:1450:4864:20::434] (port=46975 helo=mail-wr1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mre48-0004mn-4A for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:22 -0500 Received: by mail-wr1-x434.google.com with SMTP id u1so35648414wru.13 for ; Mon, 29 Nov 2021 02:39:19 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t17sm18810912wmq.15.2021.11.29.02.39.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 02:39:18 -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=6uEVSjpgTVy8n9IaNTLJk5fiY17QBGe2oJgmoK4hlrk=; b=aqxe/SjhSgD2XUJjT0eboYXLxyuewhwxS1MgQqSmIpG97L/xlofnm1C3XA6VHKy+LD WUwl+nPdDJRiI28aRR/NKXkad/DgmOpld+cCW3ICDjgmgldr5pNPLOJVBhABP60Ej1YC Fqc5h4cPfYVmIJfX3fQsxvKTt+7nCx12LqDC0nH4gN8A2i+xoKToKoywpNT7AuxygKg2 cHA0hXqtwCtV8ffnHJL7Q+oNXhNnEvpFs/Wyl3mhSHaWFM6ZeKJgbo6SlB+wqVoQQwUV JJNCiE3NEvOXPSmayC4JF/VIuf7O/SuZ2j8NqAGcbkG3MtCxt/YVXzXjyuq5eZY4PNQt ChUw== 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=6uEVSjpgTVy8n9IaNTLJk5fiY17QBGe2oJgmoK4hlrk=; b=rjrYwBXXuZH0PoWUy2YVWso0QSJuneo+aipVkkm1FE2IpDHeM9pkNHn9mhmZToKO3j bwG9uwODM9tF90pjWTmmlOJdo7nSCq0akTWCoatQsbFGb3IgABgPSTzpLHQcqyKs8bVg lloWtslitfO9qYwt3sVcI7e/YhDvfMsqA7OSTWHVKL8UKZ64Nzoy1vSL1Ky4CG+r+3oe towekeB5/lqhdeKudvAULoX0cwbDzfgzvZ56FBhMWHtwJy/TETqFvggAEMi8KjW9KbOz jKU4kxnnleB3AKVElxS22vPtoA5t+dsho1eN9a2vuVJYIXwZ2Q+OR9CbCnwG1voz98QA jXvQ== X-Gm-Message-State: AOAM531vLAKZwj5+T7Fx6WunYd09D9UWC0XElzC3+2gGJJpwLvnhOQ+t 6MzFfyd8KSJKUHOKrZfh2ie0Qd7gfOydjQ== X-Google-Smtp-Source: ABdhPJxionqdFVhuvC4e1HpuSw4i220dUcOEH9dxo103XD52RKfj6YZEkT0kheBvnrVd0t76HYKaQQ== X-Received: by 2002:adf:e0c3:: with SMTP id m3mr32736618wri.546.1638182358558; Mon, 29 Nov 2021 02:39:18 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/5] hw/intc: cannot clear GICv3 ITS CTLR[Enabled] bit Date: Mon, 29 Nov 2021 10:39:12 +0000 Message-Id: <20211129103915.1162989-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211129103915.1162989-1-peter.maydell@linaro.org> References: <20211129103915.1162989-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::434 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1638182562237100001 From: Shashi Mallela When Enabled bit is cleared in GITS_CTLR,ITS feature continues to be enabled.This patch fixes the issue. Signed-off-by: Shashi Mallela Tested-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Message-id: 20211124182246.67691-1-shashi.mallela@linaro.org Signed-off-by: Peter Maydell --- hw/intc/arm_gicv3_its.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index 84bcbb5f56a..c929a9cb5c3 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -896,13 +896,14 @@ static bool its_writel(GICv3ITSState *s, hwaddr offse= t, =20 switch (offset) { case GITS_CTLR: - s->ctlr |=3D (value & ~(s->ctlr)); - - if (s->ctlr & ITS_CTLR_ENABLED) { + if (value & R_GITS_CTLR_ENABLED_MASK) { + s->ctlr |=3D ITS_CTLR_ENABLED; extract_table_params(s); extract_cmdq_params(s); s->creadr =3D 0; process_cmdq(s); + } else { + s->ctlr &=3D ~ITS_CTLR_ENABLED; } break; case GITS_CBASER: --=20 2.25.1 From nobody Fri May 10 16:58:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1638182638; cv=none; d=zohomail.com; s=zohoarc; b=ahM80sqSz7nXC3vDu3qCQStyjtpY56eKr10qNmWQUYlBxfk9GmQh+BwzaPVlM3mLIts99IhSd3XJ6zx7z9SQsDupG/Cpp2/1PVNvdQspy5dGbY3SCCU0IvgnhT7WOwquzbRKt3BIKZbApEV6y+jsw+Vu1MS2B4VJNkvcUJvqiC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638182638; h=Content-Type: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; bh=soOOpqio2WocZa+HeBfIL2JcxO9H3bplg2Ge+Gko5Ck=; b=WCO5H5yekBcCLE9h8/9B0f1PV42zix6IKYzS/fzkf9ibtYBMflRPWcVRaLVYtXjpN8O1YPejyqGiDel0/alMIzVVVPzN06dIyx72kwe/j72zh4ztKZF/axXjDfNdkolp+LHyGZwJJIP3pYesFf9C4qo+hsfJGDaQXrxidkJZuIU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638182638680560.9517276201084; Mon, 29 Nov 2021 02:43:58 -0800 (PST) Received: from localhost ([::1]:40436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mre8b-0001aC-Kl for importer@patchew.org; Mon, 29 Nov 2021 05:43:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mre4B-0002Og-Hz for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:23 -0500 Received: from [2a00:1450:4864:20::331] (port=43835 helo=mail-wm1-x331.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mre48-0004mt-FZ for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:23 -0500 Received: by mail-wm1-x331.google.com with SMTP id o19-20020a1c7513000000b0033a93202467so12065243wmc.2 for ; Mon, 29 Nov 2021 02:39:20 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t17sm18810912wmq.15.2021.11.29.02.39.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 02:39:18 -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=soOOpqio2WocZa+HeBfIL2JcxO9H3bplg2Ge+Gko5Ck=; b=H/duAQSfwOVerec0MVyCQe/CuuHTvJuDNXDf/YpIrRA7SfNojxC4WaiiqLlko4LUip iV4vyyehqiA7Ce7MrT0RfeYXhdLzCEx/INct5Hr+Gkv7pzxX4agPN1EJRryb8QUR9vTw uH4Rd4JutwDCrshtnRJm2Slp8JnERdQ7xkQ1JiGTWGzKt8Iu25+ziy1qehpjJmm7Z2z6 gMS10eQ90MDrfZq1jhYA51Ka/smumcY1KpAsepJvc5NaCMYTE6MX7D62R6Vo3qM35E3d WcZ4PD+z/EO2pYK0kQB+JBSfHneSaJfrTWxutVv9vWop+pTJs6iWDCXqoesWRri7EI87 HTfA== 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=soOOpqio2WocZa+HeBfIL2JcxO9H3bplg2Ge+Gko5Ck=; b=zciv7cjYTB9V8cHUXKcqaHqROhIBCARUiVGV8pZHfNmaBlPLzCLfmxO+QYa3qkk4r+ 4l4YWj/3vhQq9rx+MjJrXvMJ9D4oxQ1YvtmR7ZSu0f5eZc+HKmCohzNc2mUhpodJD2BV 3oHTQUd/sSZ2tbAxR5EdOV4pbvBiHtenr3YDydTcbDC1Kvqr8n1EnO/hEd1qeORrHTlz Y0NQPNnp58wAmGwQCCcHjbEWiOmvKLJiL1hPSTrz0TO2eyYtO6J2VHUshE9jjaFwbs7k Nz6pjP2oeS5QM7hTxIzPg/nyM4OGUAi99hazmQ1qNOqjbAL0vMBT/OD/rqQ5+Qu8MVtE ZTyA== X-Gm-Message-State: AOAM5334JMoHDoHjayDs/ForTQaQ6IiwukHuqZ/X9Ky0cYPzKA9+ip4L ay05+j08P9X1XhfGqsHtVckT+aRqPYMN9Q== X-Google-Smtp-Source: ABdhPJxDIdhm+iFIk3iwOBsGVAOSDjlieL/7r3xm23/Zs3k3wydIsf3N3ScuwkpyAJ1AfE9+8dZVcQ== X-Received: by 2002:a7b:c256:: with SMTP id b22mr9897827wmj.176.1638182359183; Mon, 29 Nov 2021 02:39:19 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/5] hw/intc/arm_gicv3: Update cached state after LPI state changes Date: Mon, 29 Nov 2021 10:39:13 +0000 Message-Id: <20211129103915.1162989-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211129103915.1162989-1-peter.maydell@linaro.org> References: <20211129103915.1162989-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::331 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1638182640343100001 The logic of gicv3_redist_update() is as follows: * it must be called in any code path that changes the state of (only) redistributor interrupts * if it finds a redistributor interrupt that is (now) higher priority than the previous highest-priority pending interrupt, then this must be the new highest-priority pending interrupt * if it does *not* find a better redistributor interrupt, then: - if the previous state was "no interrupts pending" then the new state is still "no interrupts pending" - if the previous best interrupt was not a redistributor interrupt then that remains the best interrupt - if the previous best interrupt *was* a redistributor interrupt, then the new best interrupt must be some non-redistributor interrupt, but we don't know which so must do a full scan In commit 17fb5e36aabd4b2c125 we effectively added the LPI interrupts as a kind of "redistributor interrupt" for this purpose, by adding cs->hpplpi to the set of things that gicv3_redist_update() considers before it gives up and decides to do a full scan of distributor interrupts. However we didn't quite get this right: * the condition check for "was the previous best interrupt a redistributor interrupt" must be updated to include LPIs in what it considers to be redistributor interrupts * every code path which updates the LPI state which gicv3_redist_update() checks must also call gicv3_redist_update(): this is cs->hpplpi and the GICR_CTLR ENABLE_LPIS bit This commit fixes this by: * correcting the test on cs->hppi.irq in gicv3_redist_update() * making gicv3_redist_update_lpi() always call gicv3_redist_update() * introducing a new gicv3_redist_update_lpi_only() for the one callsite (the post-load hook) which must not call gicv3_redist_update() * making gicv3_redist_lpi_pending() always call gicv3_redist_update(), either directly or via gicv3_redist_update_lpi() * removing a couple of now-unnecessary calls to gicv3_redist_update() from some callers of those two functions * calling gicv3_redist_update() when the GICR_CTLR ENABLE_LPIS bit is cleared (This means that the not-file-local gicv3_redist_* LPI related functions now all take care of the updates of internally cached GICv3 information, in the same way the older functions gicv3_redist_set_irq() and gicv3_redist_send_sgi() do.) The visible effect of this bug was that when the guest acknowledged an LPI by reading ICC_IAR1_EL1, we marked it as not pending in the LPI data structure but still left it in cs->hppi so we would offer it to the guest again. In particular for setups using an emulated GICv3 and ITS and using devices which use LPIs (ie PCI devices) a Linux guest would complain "irq 54: nobody cared" and then hang. (The hang was intermittent, presumably depending on the timing between different interrupts arriving and being completed.) Signed-off-by: Peter Maydell Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Message-id: 20211124202005.989935-1-peter.maydell@linaro.org --- hw/intc/gicv3_internal.h | 17 +++++++++++++++++ hw/intc/arm_gicv3.c | 6 ++++-- hw/intc/arm_gicv3_redist.c | 14 ++++++++++---- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h index a0369dace7b..70f34ee4955 100644 --- a/hw/intc/gicv3_internal.h +++ b/hw/intc/gicv3_internal.h @@ -463,7 +463,24 @@ void gicv3_dist_set_irq(GICv3State *s, int irq, int le= vel); void gicv3_redist_set_irq(GICv3CPUState *cs, int irq, int level); void gicv3_redist_process_lpi(GICv3CPUState *cs, int irq, int level); void gicv3_redist_lpi_pending(GICv3CPUState *cs, int irq, int level); +/** + * gicv3_redist_update_lpi: + * @cs: GICv3CPUState + * + * Scan the LPI pending table and recalculate the highest priority + * pending LPI and also the overall highest priority pending interrupt. + */ void gicv3_redist_update_lpi(GICv3CPUState *cs); +/** + * gicv3_redist_update_lpi_only: + * @cs: GICv3CPUState + * + * Scan the LPI pending table and recalculate cs->hpplpi only, + * without calling gicv3_redist_update() to recalculate the overall + * highest priority pending interrupt. This should be called after + * an incoming migration has loaded new state. + */ +void gicv3_redist_update_lpi_only(GICv3CPUState *cs); void gicv3_redist_send_sgi(GICv3CPUState *cs, int grp, int irq, bool ns); void gicv3_init_cpuif(GICv3State *s); =20 diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c index c6282984b1e..9f5f815db9b 100644 --- a/hw/intc/arm_gicv3.c +++ b/hw/intc/arm_gicv3.c @@ -186,7 +186,9 @@ static void gicv3_redist_update_noirqset(GICv3CPUState = *cs) * interrupt has reduced in priority and any other interrupt could * now be the new best one). */ - if (!seenbetter && cs->hppi.prio !=3D 0xff && cs->hppi.irq < GIC_INTER= NAL) { + if (!seenbetter && cs->hppi.prio !=3D 0xff && + (cs->hppi.irq < GIC_INTERNAL || + cs->hppi.irq >=3D GICV3_LPI_INTID_START)) { gicv3_full_update_noirqset(cs->gic); } } @@ -354,7 +356,7 @@ static void arm_gicv3_post_load(GICv3State *s) * pending interrupt, but don't set IRQ or FIQ lines. */ for (i =3D 0; i < s->num_cpu; i++) { - gicv3_redist_update_lpi(&s->cpu[i]); + gicv3_redist_update_lpi_only(&s->cpu[i]); } gicv3_full_update_noirqset(s); /* Repopulate the cache of GICv3CPUState pointers for target CPUs */ diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c index 424e7e28a86..c8ff3eca085 100644 --- a/hw/intc/arm_gicv3_redist.c +++ b/hw/intc/arm_gicv3_redist.c @@ -256,9 +256,10 @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwad= dr offset, cs->gicr_ctlr |=3D GICR_CTLR_ENABLE_LPIS; /* Check for any pending interr in pending table */ gicv3_redist_update_lpi(cs); - gicv3_redist_update(cs); } else { cs->gicr_ctlr &=3D ~GICR_CTLR_ENABLE_LPIS; + /* cs->hppi might have been an LPI; recalculate */ + gicv3_redist_update(cs); } } return MEMTX_OK; @@ -571,7 +572,7 @@ static void gicv3_redist_check_lpi_priority(GICv3CPUSta= te *cs, int irq) } } =20 -void gicv3_redist_update_lpi(GICv3CPUState *cs) +void gicv3_redist_update_lpi_only(GICv3CPUState *cs) { /* * This function scans the LPI pending table and for each pending @@ -614,6 +615,12 @@ void gicv3_redist_update_lpi(GICv3CPUState *cs) } } =20 +void gicv3_redist_update_lpi(GICv3CPUState *cs) +{ + gicv3_redist_update_lpi_only(cs); + gicv3_redist_update(cs); +} + void gicv3_redist_lpi_pending(GICv3CPUState *cs, int irq, int level) { /* @@ -651,6 +658,7 @@ void gicv3_redist_lpi_pending(GICv3CPUState *cs, int ir= q, int level) */ if (level) { gicv3_redist_check_lpi_priority(cs, irq); + gicv3_redist_update(cs); } else { if (irq =3D=3D cs->hpplpi.irq) { gicv3_redist_update_lpi(cs); @@ -673,8 +681,6 @@ void gicv3_redist_process_lpi(GICv3CPUState *cs, int ir= q, int level) =20 /* set/clear the pending bit for this irq */ gicv3_redist_lpi_pending(cs, irq, level); - - gicv3_redist_update(cs); } =20 void gicv3_redist_set_irq(GICv3CPUState *cs, int irq, int level) --=20 2.25.1 From nobody Fri May 10 16:58:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1638182486; cv=none; d=zohomail.com; s=zohoarc; b=IAAIRcKdlP9Qldjh4qtTTejzjQZvQZJmSgtNsrmZj4+ZJSC30qgA9CK76001t50wk066S6UCF4mi50XGta9vapVsG+QmtGZy7haXUbXZdKn0Ocn//7Uyd1wTwCX1Q9RuA+M8JwZk5h2sKF72OTK219VLnVLQCYROsQXFPA67iZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638182486; h=Content-Type: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; bh=9VVdwPMx3U1bUUTF2DIPsdquwWCg5tAFq2w0+RD0yNQ=; b=LaUJzcioMOL0nM8F5poZ6+5/DXqD/SeUMKPsrtztgvNo+3KWGUqREfPjB4o3G+voO4nW/ebXmrT4k1xgGZv+H4ZMjoZk1ZzZf+xUGXmgayIzVKebPc2/D2IOgLeFnX7vrZxHtG87mmkqrwAdGe8UsNWUihTUS3VhlOESdil5ojE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638182486674409.547328876131; Mon, 29 Nov 2021 02:41:26 -0800 (PST) Received: from localhost ([::1]:33284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mre69-0005GU-Dx for importer@patchew.org; Mon, 29 Nov 2021 05:41:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mre4B-0002OD-6Z for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:23 -0500 Received: from [2a00:1450:4864:20::431] (port=33690 helo=mail-wr1-x431.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mre48-0004n1-V4 for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:22 -0500 Received: by mail-wr1-x431.google.com with SMTP id d24so35765598wra.0 for ; Mon, 29 Nov 2021 02:39:20 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t17sm18810912wmq.15.2021.11.29.02.39.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 02:39:19 -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=9VVdwPMx3U1bUUTF2DIPsdquwWCg5tAFq2w0+RD0yNQ=; b=Q8C6YpWbnBnzVsHhlgmeK8/AI1M9QdoyNJL/ME+603di3XWA2sC1vTrs9whARvooJT UEEEppNLGrM9h6JxKxrKf1HNvE8TauycgY9cMfSA1Rkuw9sADa0RrYaxxQgJpwheQIM3 yAIihbu5rQ0ad6LJYoT/w9Y64StG/pLozI1QSGCxh7WM0WvTYU/WODNofVGwhg8SR621 t1bL6tTH5KLcu3VPcEj8dBbDRRcBbbmy02kyOfVSvtTTXDqfVGRir0oeHuKEn/bb3I4k unO//6ssKkfnpHudgXu/1HBLkqIA4vIbrdXf1iCUhVjKouQVeYqZQs5isyo6hiCthoym tipQ== 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=9VVdwPMx3U1bUUTF2DIPsdquwWCg5tAFq2w0+RD0yNQ=; b=vlh9FIzVkxfu8/Ix1kO76EEdZpt5iP7IGm+poHgA/EV1XDg1iz+t+dBz23Ko8XRopf 47CH6e0ecLeE2+5QgfIlAq10c+A9z9rsTocDqxDK8ICfsXQ0Rdg7YkeFJD0c1Q8hsvBW HQeE5y6sVn8H5mpK7a3CbquYcoGK1aNeQJlU59K86dTsJGPwc2+QHHpJ+01+2iiNYIJh XSighzTuEgsloRtBzlZ5U7khSSwQFNNyc1EiawD97jx2JKT54xdsKzpXKzgGZrnCsKqm Ci+jgXWF4O0yPj+GAWWbl3QcUcjb3jIWgZiZ3lDYOM3qNmY7l+ExBZu1BGeZdm7jxaDW TQAg== X-Gm-Message-State: AOAM531owky3jje3OqYIJAeEr3wgB951IMR2Du12OprFAscRPxHzR+3D kDiWO1s5Gj1sDvNQDidmzQxD3pDqnHSfyA== X-Google-Smtp-Source: ABdhPJyH/i6raiL+Cty4gu9QYtiQFm3jNZANoM4B2jxtFfGrztAvpoy7mEGMw4/yPhwCSr2BUL00vw== X-Received: by 2002:a5d:4843:: with SMTP id n3mr31867555wrs.335.1638182359696; Mon, 29 Nov 2021 02:39:19 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 4/5] hw/intc/arm_gicv3: Add new gicv3_intid_is_special() function Date: Mon, 29 Nov 2021 10:39:14 +0000 Message-Id: <20211129103915.1162989-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211129103915.1162989-1-peter.maydell@linaro.org> References: <20211129103915.1162989-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::431 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1638182487409100001 The GICv3/v4 pseudocode has a function IsSpecial() which returns true if passed a "special" interrupt ID number (anything between 1020 and 1023 inclusive). We open-code this condition in a couple of places, so abstract it out into a new function gicv3_intid_is_special(). Signed-off-by: Peter Maydell Reviewed-by: Marc Zyngier Reviewed-by: Alex Benn=C3=A9e --- hw/intc/gicv3_internal.h | 13 +++++++++++++ hw/intc/arm_gicv3_cpuif.c | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h index 70f34ee4955..b9c37453b04 100644 --- a/hw/intc/gicv3_internal.h +++ b/hw/intc/gicv3_internal.h @@ -411,6 +411,19 @@ FIELD(MAPC, RDBASE, 16, 32) =20 /* Functions internal to the emulated GICv3 */ =20 +/** + * gicv3_intid_is_special: + * @intid: interrupt ID + * + * Return true if @intid is a special interrupt ID (1020 to + * 1023 inclusive). This corresponds to the GIC spec pseudocode + * IsSpecial() function. + */ +static inline bool gicv3_intid_is_special(int intid) +{ + return intid >=3D INTID_SECURE && intid <=3D INTID_SPURIOUS; +} + /** * gicv3_redist_update: * @cs: GICv3CPUState for this redistributor diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index 3fe5de8ad7d..7fbc36ff41b 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -997,7 +997,7 @@ static uint64_t icc_iar0_read(CPUARMState *env, const A= RMCPRegInfo *ri) intid =3D icc_hppir0_value(cs, env); } =20 - if (!(intid >=3D INTID_SECURE && intid <=3D INTID_SPURIOUS)) { + if (!gicv3_intid_is_special(intid)) { icc_activate_irq(cs, intid); } =20 @@ -1020,7 +1020,7 @@ static uint64_t icc_iar1_read(CPUARMState *env, const= ARMCPRegInfo *ri) intid =3D icc_hppir1_value(cs, env); } =20 - if (!(intid >=3D INTID_SECURE && intid <=3D INTID_SPURIOUS)) { + if (!gicv3_intid_is_special(intid)) { icc_activate_irq(cs, intid); } =20 --=20 2.25.1 From nobody Fri May 10 16:58:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1638182640; cv=none; d=zohomail.com; s=zohoarc; b=TB3W/lxF8q3x9qxyo+fuQeWcMkqjvmGHxHjdHcedzYtYzPblKukneTgLJ6+lqSy9u7XRND+DeagatAbvPQWAePshbmoK9wIZIZa2cWNmssFZbo3cvZfrImJ0FH+KatEGszXIBJKpjETXWvMpyT+RDStAWnVKALqggMgyzuFx2ds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638182640; 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; bh=OjFLH2BFS+yCBbLcJauIqCZyc8Dqk6KrwSVe0yu3cfA=; b=TJGHb8VN1ziKapzafD8BXcIxp5ufUjZEEPPxJntHjv12JfxTmL/nowjV21MRTA+MJWusuF2bkRvG6Ld705TxKqWahoLyE9OL3BptW8DLB8cGU9ne2gi9LN5mUktd7jnVXvlDwM4QfSHUbHYNr1ZGA2wM2q5UdJWoc+qsCJ1cKGQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638182640323455.5261400625528; Mon, 29 Nov 2021 02:44:00 -0800 (PST) Received: from localhost ([::1]:40570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mre8d-0001fX-BZ for importer@patchew.org; Mon, 29 Nov 2021 05:43:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mre4B-0002OP-DS for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:23 -0500 Received: from [2a00:1450:4864:20::42b] (port=37472 helo=mail-wr1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mre49-0004n6-GO for qemu-devel@nongnu.org; Mon, 29 Nov 2021 05:39:23 -0500 Received: by mail-wr1-x42b.google.com with SMTP id d9so14818069wrw.4 for ; Mon, 29 Nov 2021 02:39:21 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t17sm18810912wmq.15.2021.11.29.02.39.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 02:39:20 -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=OjFLH2BFS+yCBbLcJauIqCZyc8Dqk6KrwSVe0yu3cfA=; b=NXANIftrw3uInIBAD1R0OaYw2tWvSd9V42K+gxpQw9e6lj0IG5FIEe7FVV6OQ+ZPqg lUehKs3kKrccq2S9ndKvJA/6eSt8ZNADAKczz6sIceBGvoHZlAl3YbuXCNpGcSVF2NbW RduR63oXxGWuw0iSLU6ynVZZEsbWFu18TOjNLuw4kngoT7g6SJRtsVKNKIN567iB4sWf 2/btmxchs4AM2eimh3aMyLPLVP8SvI6CMxx9bGdaoN3InB7/5kIOExS3z2SaT0ffkLvS 1wliglJycSuMrIJsd7L2+GqaXMQEZS+2vu1Mz5UebOwwaJ/b+ACdjSV0RfROEzHXUvOi ttFw== 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=OjFLH2BFS+yCBbLcJauIqCZyc8Dqk6KrwSVe0yu3cfA=; b=muksfQ9+08QoGeRjbjYwlCnPbSDTCEIAIBHt2PN2cENXtXjeySoriWg+WnYXXex34O H5R78RvZZ8dRuybzCE4RzvU73o260EXUkjRT5smCiQWvvXrA7FvHAEs3xnau8e7Lv+tb 8i9hawL2nNS59QPpxGwcoRunlJ2zMEAsXZt0E5Yf3cNQ35sBujmZnYTK+iUrAi+FiYhQ npmBZguejXTrIQDeYEKcJm0nKfG4Ng/7kdhlcRmbc88uYqMl3xy8Y7bZyFj0yA0C3nIL 4PD/qPHKIep1G1/YZhFUWDeN2Oy/cbv7v9htHdn+7TOvZUDimmNlqFSUZViu67S5RHP7 f/SQ== X-Gm-Message-State: AOAM53269jFrrZ4HUkIr+ku68wpdF+UXn6EkQTz3Kvjn5B0xr3nhjpPi fYR7DgcoGyWrCmlm/v3PU/jOtfIPIjUx+w== X-Google-Smtp-Source: ABdhPJzWfTdnqrCqhPY4sgpajujtncgsSYtvpSeX+gwBuQuZM3TSd+6TNwmcjtv4lMTDhoFX1dVJAg== X-Received: by 2002:a5d:4b45:: with SMTP id w5mr33316013wrs.272.1638182360215; Mon, 29 Nov 2021 02:39:20 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/5] hw/intc/arm_gicv3: fix handling of LPIs in list registers Date: Mon, 29 Nov 2021 10:39:15 +0000 Message-Id: <20211129103915.1162989-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211129103915.1162989-1-peter.maydell@linaro.org> References: <20211129103915.1162989-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42b (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1638182640722100003 Content-Type: text/plain; charset="utf-8" It is valid for an OS to put virtual interrupt ID values into the list registers ICH_LR which are greater than 1023. This corresponds to (for example) KVM using the in-kernel emulated ITS to give a (nested) guest an ITS. LPIs are delivered by the L1 kernel to the L2 guest via the list registers in the same way as non-LPI interrupts. QEMU's code for handling writes to ICV_IARn (which happen when the L2 guest acknowledges an interrupt) and to ICV_EOIRn (which happen at the end of the interrupt) did not consider LPIs, so it would incorrectly treat interrupt IDs above 1023 as invalid. Fix this by using the correct condition, which is gicv3_intid_is_special(). Note that the condition in icv_dir_write() is correct -- LPIs are not valid there and so we want to ignore both "special" ID values and LPIs. (In the pseudocode this logic is in: - VirtualReadIAR0(), VirtualReadIAR1(), which call IsSpecial() - VirtualWriteEOIR0(), VirtualWriteEOIR1(), which call VirtualIdentifierValid(data, TRUE) meaning "LPIs OK" - VirtualWriteDIR(), which calls VirtualIdentifierValid(data, FALSE) meaning "LPIs not OK") This bug doesn't seem to have any visible effect on Linux L2 guests most of the time, because the two bugs cancel each other out: we neither mark the interrupt active nor deactivate it. However it does mean that the L2 vCPU priority while the LPI handler is running will not be correct, so the interrupt handler could be unexpectedly interrupted by a different interrupt. (NB: this has nothing to do with using QEMU's emulated ITS.) Signed-off-by: Peter Maydell Reviewed-by: Marc Zyngier --- hw/intc/arm_gicv3_cpuif.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index 7fbc36ff41b..7fba9314508 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -653,7 +653,7 @@ static uint64_t icv_iar_read(CPUARMState *env, const AR= MCPRegInfo *ri) =20 if (thisgrp =3D=3D grp && icv_hppi_can_preempt(cs, lr)) { intid =3D ich_lr_vintid(lr); - if (intid < INTID_SECURE) { + if (!gicv3_intid_is_special(intid)) { icv_activate_irq(cs, idx, grp); } else { /* Interrupt goes from Pending to Invalid */ @@ -1265,8 +1265,7 @@ static void icv_eoir_write(CPUARMState *env, const AR= MCPRegInfo *ri, trace_gicv3_icv_eoir_write(ri->crm =3D=3D 8 ? 0 : 1, gicv3_redist_affid(cs), value); =20 - if (irq >=3D GICV3_MAXIRQ) { - /* Also catches special interrupt numbers and LPIs */ + if (gicv3_intid_is_special(irq)) { return; } =20 --=20 2.25.1