From nobody Mon Nov 23 04:52:38 2026 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=1791880796; cv=none; d=zohomail.com; s=zohoarc; b=iib0CQnRrKfcgwkzGVmYnBGsvKw7NrngRsWdMJuKedgomJPuLIIkXDshedSmngkc89Nu/nsUcsA9BRe2AQAiB2hnWx4mJAz3asvnJ97JfPZcY0aOL51dUgJpt9K1XeYF0nvNNaTsQi4NdN+6nh+VBaPIvrmNbFImqrkjgot/B0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880796; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=yMqLoW+XIVeQet+rIDECiVnH/oSDnZLxZQh8AFD0o2w=; b=S9wStolVNW0Ejdsafgvf3rLwtV7S4bJt+s0Qa533c7infj0gYllI0vjk6Sj5OZU/ZJaFG4ysRD9hB/Igv15gNq3udAcEoZ10Nq5UFBSHHRMA5u+imnKvJlikDrrD2zNVvRy7VomDMvMrBO6J+uMaE8n3KCfEhG2JqRscTUuU2+0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791880795885402.9306933291864; Tue, 13 Oct 2026 01:39:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY2x-0006lQ-8s; Tue, 13 Oct 2026 04:39:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY2v-0006ka-PU for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:41 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY2u-0007Y7-0U for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:41 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4a0213948d3so16335175e9.2 for ; Tue, 13 Oct 2026 01:39:39 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880778; x=1792485578; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yMqLoW+XIVeQet+rIDECiVnH/oSDnZLxZQh8AFD0o2w=; b=q48KTAVJRjjM7NPzja7OF5c9ebpWYLORzYv8op7q0XKMnqARCWNvhTzcmMORfHxD7+ HCgckV2xIyUsevQ7Uo7+6BAvItrmRVaj7qgGvdhcwKGtD0SYZA/POd6b5zEPowSFyAGb IYPpSX695b07gdCXCOr3WIdtyHh2DgKx8k4lVETE2uLX3DGT2U7anNCV0P9G7Y9/Gcqn UfUmBGRWrGLl/Bk8XglI3LF4T7ZbRwPWxPVRbTam/4Tt1GJl56WA4/nceLcUEXCUZsH2 rheKHrMXbc1JxnqvixdKOUgD2mV40ED35pzxibkbUN5mHILjLh+P0rEvW+LdKrEJb6v3 IT+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880778; x=1792485578; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yMqLoW+XIVeQet+rIDECiVnH/oSDnZLxZQh8AFD0o2w=; b=s8qkNPjsS7vmLgpGTEemnPWe8m2aNk1ym/mBNGhESTd0HkaiambQs3cFYT4glT48up PuhUVOIAkhM3TqT46RpdY+zx9+sIEGvOJ2X+HQggjxvBty6KLtJeK0x+W8dbSrEeomF2 4WBIkIPQgCTcFsurv6ThHmYX37kb40PQWT77VZ4Kvo3Zz7S009QkP1h33FBZHvpkRcj+ VZVFP3N1EG6o2GailntjUSzddeKsJx7AHMt0F1jeHTcahGHRvAczSWyP7WA8E+EcLS8+ AmvSzBNvAjZFJelwEcS7Yo+cc3OH42hRA3r70IIPUlsH7G1Sd6BLujw+3Eia6P++GZzs REXg== X-Forwarded-Encrypted: i=1; AKwUvBw66aIImc53T5rsxN+ok2RzPCjkncuafEM/hNiv9hIZJrEbs2HH0N/ctLfNj75cOdIBTLborOUrhuyx@nongnu.org X-Gm-Message-State: AFq9FYJtUJN832DbB4r6y31rEdhLksK4zEf6cwtSMwFHn78l0k0hhXFe A7kLb7AtHPjvhnADog8ZDFTiCNjkx5LFR87RGzyzL2yCy8o3gaZvlZ9EV+cWB1TPc6bASWRlBM0 4c48y2B0= X-Gm-Gg: AYBFou1r4/Z8oA2dGo58bDRZUbRW4oIJOULd2FxLJXngibB0RSxrqAOlN1qV9DSfZDY L4fXGwBtcTo2lbUQGVyn9xbQhkDoFcjrtdsgG79v2NG+OtB7QUk+563Fg2V/kHxJm3tkbALjsml GXK2wD3+coeOpxRZZL152N3pZASy0Ie0H1rRAma2aYyTZGwfUwO23r+uOse+pCnWKC3SZ1j7SYz AqsO/UCMKOih6CIxP5z+/sOSpqeS1BBhWf0SHBUj/o6YyZsKW0OnMw3aU+mmxTCvvY3jR0+OD0J 89dgz0R0ZRD2F96rZz1nAqy38i27n8cwP07LJ5hefQeS5QfG2I13YmBBppyuTkzDvS977I3Kdai f+zq3soGI0ad14ZPv1LKv4d4NwjLvUbCvl3iZJ2ihc4+L7TpYB29TE/W1XDANJ14zxwmMCjNJPF KJ4i97CWC2gIaHgumaAlRvCWetr+QTxSD3xvw7E6OcySOML7AbBbKljgiOtHqPo4SxL52JUUt/0 WzWrTG+xiSlJADCrQ3lcs3V+nrLqWnQgIBd3wGSSzHDrv1pK/v9fZsepap/FHe+5lNxZRH5h7yp BaE= X-Received: by 2002:a05:600c:154b:b0:4a1:6af4:c6be with SMTP id 5b1f17b1804b1-4a18e4d1c0amr215390865e9.34.1791880778509; Tue, 13 Oct 2026 01:39:38 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 01/86] hw/intc/arm_gicv5: Make IRS_IDR0 reads return actual value, not 0 Date: Tue, 13 Oct 2026 09:38:08 +0100 Message-ID: <20261013083933.1024405-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880797862158500 IN the code for handling reads of IRS_IDR0, we carefully construct the correct value starting with cs->irs_idr0 and adjusting it. However, we never actually write the final value into *data, so the guest will always see zero. We didn't notice this before, because Linux happens to not care about this register value except to check for the presence of virtualization. Cc: qemu-stable@nongnu.org Fixes: 405ad2e76f13254 ("hw/intc/arm_gicv5: Implement IRS ID regs") Reviewed-by: Jim MacArthur Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 08878193dfc..ebfb0878af3 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1433,6 +1433,7 @@ static bool config_readl(GICv5 *s, GICv5Domain domain= , hwaddr offset, /* ...which means VIRT_ONE_N is also RES0 */ v &=3D ~R_IRS_IDR0_VIRT_ONE_N_MASK; } + *data =3D v; return true; =20 case A_IRS_IDR1: --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791881184; cv=none; d=zohomail.com; s=zohoarc; b=CABXdaWMHpuy1PIUre2ITJWr5NnHxgy4EGi+wdGAzBaodc+c6AyMKOkpIQwE6GWVBE91dfavjQlv2+Z7QX+5eRQE65dL3fzSIu3b8a5r/WxrtzSizFhQbJ8Ji5HiNpW/TYXrMLkn3jkiUBzfstYiI58/QIKsBJWQhiYzZkrgQtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881184; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=iOOUVgrNaS2uLQpuE+4HLt5jLUXlLvr0Bv+5ciAHV1g=; b=UiYoTfuVwYYp+kDKzhlSc9z0U/UmtmPMXgatJ+Ap5Q0dFSGCxZOMsS1HuDra7zGhDRiWGn6I6Aj1jaGaE3enA98p9poLKSgGbBKlL57tejn4r/05JnkvL2WV3wXpw4ViSDCixjWPnjgdvHivAWWrSkF2ImewRuEh0oFcDMpBaxM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881184018474.7464423859225; Tue, 13 Oct 2026 01:46:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY31-0006nZ-2L; Tue, 13 Oct 2026 04:39:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY2y-0006m8-S3 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:44 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY2x-0007Yi-5d for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:44 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4a018792ab3so22413755e9.0 for ; Tue, 13 Oct 2026 01:39:42 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880782; x=1792485582; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=iOOUVgrNaS2uLQpuE+4HLt5jLUXlLvr0Bv+5ciAHV1g=; b=YxMuGkqyBnkJBZFsltu5ar0lQ3MzgoQn0/YNBWeW5E5fLbh+WaxsTfGilqOxXjannm 1e34Q0YgYQXSGN3bBWKv+aDLMzGvuP1+eNPSSo6QPMIbXnVziESc7QlId7u3f2fOcBKv BnRRn0ki21JHQH3JqV+NTakh8vGPXcCjTvD9WjRg8McNTtXKf8/5fvVQN18YJAvDCZ2b LroMbqZ96KEJ46tVQQOQPJvVsAzqywXfKhw1b/ek/D0HpW3xmTwmWOEP16YYAQW90x8X wupodgnnN8Dnnat/9sbNMrSEYmmSHch7W1uREr0e4V76OApIW5gRxyY4nSBD05ObaZsS oTKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880782; x=1792485582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=iOOUVgrNaS2uLQpuE+4HLt5jLUXlLvr0Bv+5ciAHV1g=; b=O9fGejUxwPWkmDzi4k4IhWMbwQa1AqBp7aB1jALFG2Ow9XizXGTi18nMgDkti4L9yz io3YGl/YI2JSqgwcUUQNGoyXgJ07Jw6RTTX+q3dFvbGGw/5ghElncgFy2sqiMflagz21 Zm5I0M1OMRr81qN3ATivfTo1AlKY7ACI+zj56mczyWG/sSUhGVfmvJroNWWw1YSHwsfS TOxTw81M2qjuO/y0XeX+TZZyXWdOdNwIlxQ9XLFXgdAgzqGIPfKUSweBQoiAfHVaGZbg 8ZmJ6z1uQSzsjlKnzwQoZGXTCLajlYpxyqgRnY3umcQzIliiVidLTbnHqrtzIUnMOvAU FrAQ== X-Forwarded-Encrypted: i=1; AKwUvBxI44Xj65sh6MLa46U/DIXNbro5A4eeAmUUIGWRz/KJFCS0d9Bh1/k2KjQ0adoANP/9yLTd79eSo4PG@nongnu.org X-Gm-Message-State: AFq9FYI3RxVCeRK1B0cZo2r2n6Uzk4il644V6Qk3hTD+LknmAQJW7B8l JBQ2aeePDxFTKYnKzRd8gDG7s7fd5u3bd7XBnbdc9eLNdeeWblJfpc+hhb3OTZSb9DIJS2/77EZ xfoUeo1E= X-Gm-Gg: AYBFou3psiS1nfcs9/cgzF2BAuVAWoPDDbzpCgrQkelqMZ0nTASn4xtEDvRTvYMGsMp MOecvUuHWnp20x8yvMz8xCeRD6Vvdaxqc05+tWqQmeREk68YXa0/AcQPRqIu5acAaaEp/JEeaH9 mTJKAkPgtyhH0n5nwcjNjvytkR6FzV7dbyIyZ/ArEeytV4Mn2oN3iXpKYf7eZ4W19P97WdNXjoL ODMXHfAyNvi1U503KN/5iaHoxnb/+xBj14V6sLiJ5IM+xqZMoNP/FMwNLbMKAVIs0JL0ij2ALvQ Xmg0YhXyYJkIkRwbgOOCb98/nOqM8b2UhN2x50pxeg6m87c6MQGVv5oQis2QozyGKniCpPFrvrm ZCVjdsz2GrqEEDUtQ5AxxFShmeDXolanzB/2wtRxNVpalt8C9OnK1cnbW1I7dR4tE4+pjqYYav1 ZeQdMGnKxJfLZOPMjYPTYf0aLewgHkJDl2OkJ5MCrc7VyxAzbOf4st4GmilPRLKanLm8WTdax/P SXrp996ZHfXbDTVaSGQjKDFgiRPuyEE/Fa4pgF6gA/COTMJyz+l8WIDFf3oBdNYcZTa6zzifD02 zFwtx7mc0bncUA== X-Received: by 2002:a05:600c:8218:b0:49f:ffdc:939d with SMTP id 5b1f17b1804b1-4a18e49d9f5mr224228765e9.9.1791880780214; Tue, 13 Oct 2026 01:39:40 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 02/86] hw/intc/arm_gicv5: Ignore low bits in IRS_IST_BASER.ADDR Date: Tue, 13 Oct 2026 09:38:09 +0100 Message-ID: <20261013083933.1024405-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881185085158500 Content-Type: text/plain; charset="utf-8" The IRS_IST_BASER.ADDR documentation says: For IRS_IST_CFGR.STRUCTURE =3D 0: Bits[N:0] of the resulting address are 0 where N depends on the ISTSZ and LPI_ID_BITS fields in IRS_IST_CFGR as follows: N =3D Max(5, (ISTSZ + 1) + LPI_ID_BITS) For IRS_IST_CFGR.STRUCTURE =3D 1: Bits[N:0] of the resulting address are 0 where N depends on L2SZ, ISTSZ, and LPI_ID_BITS in IRS_IST_CFGR as follows: N =3D Max(5, LPI_ID_BITS - ((10 - ISTSZ) + (2 * L2SZ)) + 2) This enforces that the IST is aligned to the size of the IST table, or to a 64-byte boundary if the table is smaller than 64 bytes, even if the guest programs the low bits in the ADDR field to specify an insufficiently aligned address. We were missing this check, and instead trusted the guest-provided address to be sufficiently aligned already; add the alignment enforcement. The GICv5 spec defines the masking to be used with the expressions quoted above, which work with the raw field values from the IRS_IST_CFGR register; these simplify down to some straightforward expressions based on the sanitized values we've already extracted form those fields. You can get to the expressions we use here either by working through the simplification of the GIC spec expressions, or from first principles (the number of bits needed for the size of the table in bytes is the number of bits that index it plus the number of bits specifying the size of an individual table entry). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index ebfb0878af3..3c50238634e 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1313,6 +1313,7 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain= domain, uint64_t value) */ GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; uint8_t istbits, l2bits, l2_idx_bits; + int tableszbits; uint8_t id_bits =3D FIELD_EX64(cs->irs_ist_cfgr[domain], IRS_IST_CFGR, LPI_ID_BITS); id_bits =3D MIN(MAX(id_bits, QEMU_GICV5_MIN_LPI_ID_BITS), QEMU_GIC= V5_ID_BITS); @@ -1359,6 +1360,33 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domai= n domain, uint64_t value) cfg->l2_idx_bits =3D l2_idx_bits; cfg->structure =3D FIELD_EX64(cs->irs_ist_cfgr[domain], IRS_IST_CFGR, STRUCTURE); + + /* + * Bits [N:0] of the base addr are ignored, to enforce that in a + * 1-level IST it is aligned to the size of the ISTE array, + * and in a 2-level IST it is aligned to the size of the L1 table. + * The spec defines N in terms of the raw L2SZ, ISTSZ and LPI_ID_B= ITS + * fields, but we have already sanitized these to + * istbits =3D ISTSZ + 2 + * l2bits =3D (L2SZ * 2) + 12 + * id_bits =3D LPI_ID_BITS + * We have also already enforced the "bottom 6 bits are 0" via + * R_IRS_IST_BASER_ADDR_MASK, so can skip the Max() operation. + * We want tableszbits =3D=3D the number of bits to zero, which is= N + 1. + */ + if (cfg->structure) { + /* + * L1 table is indexed by the (id_bits - l2_idx_bits) bits in + * the ID, so has 2^(id_bits - l2_idx_bits) entries, and each + * entry is 8 bytes =3D=3D 2^3. + */ + tableszbits =3D id_bits - l2_idx_bits + 3; + } else { + /* table has 2^id_bits entries of 2^istbits size each */ + tableszbits =3D id_bits + istbits; + } + cfg->base &=3D ~MAKE_64BIT_MASK(0, tableszbits); + if (!cfg->lpi_cache) { /* * Keys are GINT_TO_POINTER(intid), so we want the g_direct_ha= sh --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791881645; cv=none; d=zohomail.com; s=zohoarc; b=KccXrrBpshHKL4qeYySb3ho+p0+G9Px89I51uY3USXMZwq1LP1G2PzQGO56Kr8OT6+bSoHWVaoo6R8Jz5D94Be6mbMl0tiVGR8s7Pycht5FzcyivOsfeiu/VSCtwgV5kwlnPrXAQOhwuqkxCQ2wwgO8vowco89FncTroqzXuqik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881645; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=9Vj/WyrTKsX+7lendkR52TtR2J1V9h9JXeBCl8flLS8=; b=I194kVrOpcEkEJVrzcCsTiuy3faeZwxzcOmyHqsW+L0P71StfXqnJTG/eB9eKaGuNLndS8GtuxpTZD762lfehRLsduZRy8b6DtG87Lm3Lzh8PDAnDYSGpL/nrO7i1WSSTN70+2WnOZnERvQRKdhyWo0k5de6RyICMxKIp7LTxOk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881645116804.3575370523234; Tue, 13 Oct 2026 01:54:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY32-0006o0-0E; Tue, 13 Oct 2026 04:39:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY30-0006n5-7o for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:46 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY2y-0007Yv-4O for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:45 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a1698ea378so21867465e9.2 for ; Tue, 13 Oct 2026 01:39:43 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880782; x=1792485582; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=9Vj/WyrTKsX+7lendkR52TtR2J1V9h9JXeBCl8flLS8=; b=Tqww0j8K7ajZ62Kslu0le83xYKHxhRvWBXq7un8iZYTQ3dJYE3M7QpsIqa/QoN0Xuz SRGbDZtq/coImPR/sUtouEURFFntZeDWohdS2gulzki2WdcskdULYiHTxYxZ3ueany+A fKNVj/LkcWiuPptYzyQT5FykqAOa+sJdCft4edkLZ3E9hldngUiimSYPnVPmX7KrbIHO wPZuBMsY1xylAu1cZOo0CZ1sHDkvKdNf1yRu7vy29g8SGzDM8USpsm0AtBTkW5Oticu9 /VhkjUTpbzd7E3clgMts3gagz8HQaYuzrWc3/ODhDvAgMbjdDmGqi3ccOVMnBwjIAM9U pqng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880782; x=1792485582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=9Vj/WyrTKsX+7lendkR52TtR2J1V9h9JXeBCl8flLS8=; b=0JLX67fKuqYlBxI6HLYFv4KaBxdhFgAwz/ZDv+YtUuFIy9wSzCCk4exOhRmQbMaTEh yYKhRElsTft2rSKHSsUJqy/kwUlHQ8s1V1O91Z+cG3Chw/iPQgz3z66FcH3NQ/TsFw1C 8vmrkuLfsb8AXgSS9CCUzOhN9nQObLrijFGXkBwfS4qd62E/RnBbBA7DtLYA5FspWkB1 gtldxu5efpb5L35xdrOxqda+p8y1Sg1GM6nUJ+nNmpyCgXFqJNdCKhuX2fP+eogkNWWI viaqODZlr6elsfykpHtN1PWS6cDHGQh5Hrsg/Z5hbVx1zvgBbKPmhTuU8bXWXQvg4X3z TNpA== X-Forwarded-Encrypted: i=1; AKwUvBxokcRrDng5zF0g7MwkjF7urSYJlV1dXTvxCHqAOah5so2Y9UgqYpA3CVnPYpPSCJp1ifr6XWg9sVX8@nongnu.org X-Gm-Message-State: AFq9FYLRkK0slS8RGF1XU08mvLqz6wFhaIL47hY+Hy8wtXPdRwXn0FXd SE7pdUkbK9OzDtWEqVdYnesVG+/RZcuhmLIyGFD8VAxMf2Gwl29hrCdFR4snJaB49nUFzCJyG9h 2ng80mxc= X-Gm-Gg: AYBFou3TF9fVILWZGvI0M71fhbUc+ygngR0CnajGQjLl0SMte+4D6OxDNj1TW5rshV7 iDi+3959scsuFG4u1/q8omFFNZS/DMztKEyf6BTYXk0ALEO7qqeQemnlQz1fTfYfbnd+czp3auy 8VUDTnQsCj9F+TUzY+BFaoAt25wUG9JfGr5ry6CSF7uxXPL4kDlm5Hqbpm5wWwQnfUGZGPQMARX FSV9t/dw34tRfOSNYehPVh5NP3WR2xRPqBPtSbfYMUubaFpNPSvvJtomKLhx2Y6xMJlQc6WyIq4 fcZP1c4V9eXDdabd0LF9vK/H3rhaxdB4YySZTGaYqscxpS1lhv7B9EFHzHQj3GyvvfGEz7bgyE5 WG5RiK6gs5b6Osz/vV30PJKuQLmhDQ8uARSX/WIC+sidcJdrJPDUMAyInJLUrZj98TASX/hP7KQ S5WIl8lW28ExcLKx/Sij+B9qCXDQNuENbuMHZCtDzBPafhAInYTdHRtKUAa7xUjX/3lWNSaQqvH aKAawSyKcPTtn8lRwALL58s5jTGeJdeL4PorTv0FqF+yldrqDqEk+wYMmdRjbaCd96sySrbaR5U NvE= X-Received: by 2002:a05:600c:3b87:b0:4a0:1b15:8852 with SMTP id 5b1f17b1804b1-4a18e4a977fmr291437115e9.16.1791880782604; Tue, 13 Oct 2026 01:39:42 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 03/86] hw/intc/arm_gicv5: Ignore low bits in L1_ISTE.L2_ADDR Date: Tue, 13 Oct 2026 09:38:10 +0100 Message-ID: <20261013083933.1024405-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881645858158500 Content-Type: text/plain; charset="utf-8" The GICv5 spec defines that an L2 IST is always aligned to its size, by stating that bits [N:0] of the address are 0 where N =3D 11 + (2 * L2SZ) We were missing this check, and only aligning by applying R_L1_ISTE_L2_ADDR_MASK, so we would only enforce 4K alignment even if the L2 IST was 16K or 64K. Add the missing masking of low bits. We already needed to calculate the number of bits needed to index each byte in the L2 table, so add it to the GICv5ISTConfig to save having to re-calculate it later. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 6 ++++++ include/hw/intc/arm_gicv5.h | 1 + 2 files changed, 7 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 3c50238634e..2b08f8feec2 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -595,6 +595,11 @@ static bool get_l2_iste_addr(GICv5Common *cs, const GI= Cv5ISTConfig *cfg, return false; } l2_base =3D l1_iste & R_L1_ISTE_L2_ADDR_MASK; + /* + * The effective base address of the L2 table is always + * aligned to the size of the L2 table. + */ + l2_base &=3D ~MAKE_64BIT_MASK(0, cfg->l2bits); id =3D extract32(id, 0, cfg->l2_idx_bits); } else { /* 1-level table */ @@ -1358,6 +1363,7 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain= domain, uint64_t value) cfg->id_bits =3D id_bits; cfg->istsz =3D 1 << istbits; cfg->l2_idx_bits =3D l2_idx_bits; + cfg->l2bits =3D l2bits; cfg->structure =3D FIELD_EX64(cs->irs_ist_cfgr[domain], IRS_IST_CFGR, STRUCTURE); =20 diff --git a/include/hw/intc/arm_gicv5.h b/include/hw/intc/arm_gicv5.h index b8baf003ad6..d763a7939c7 100644 --- a/include/hw/intc/arm_gicv5.h +++ b/include/hw/intc/arm_gicv5.h @@ -23,6 +23,7 @@ typedef struct GICv5ISTConfig { uint8_t id_bits; /* number of bits in an ID for this table */ uint8_t l2_idx_bits; /* number of ID bits that index into L2 table */ uint8_t istsz; /* L2 ISTE size in bytes */ + uint8_t l2bits; /* bits needed to index L2 table in bytes */ bool structure; /* true if using 2-level table */ bool valid; /* true if this table is valid and usable */ /* This caches IST information about pending LPIs */ --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791880862; cv=none; d=zohomail.com; s=zohoarc; b=h5WcIm2n6FX7izKT/SKaxa26NjTBGogk2C/w3mvHkLjl/UhnqECIcQ2xHFT3nkMEgj1jZJQkKBAjovTLAHF7GV2jaaV5rO9Xjwk80nL7iqu/rGohO8Ud6GjPZgA+i5lfpV7oKTTd0WXoS5f6HNEQ7PLbLmb2bc258o14QKCsG2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880862; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=dY5bJ6dJUERrSTEf33O+vZmh2Dy5obdCXPAP66j8BsQ=; b=iy7s/ZTylHlvRZfP01H6ie362I7IzezPJG92FtfgSRMMZ7eJF99nVMR09iJG7vmc+lDn26SM+cFZ9hNTA8JtSCfVLNj0/hDiHBl3g/iHAisSBVUMInipkl889rJ6p8XyggaktuyxZhcfTm8IwGTM3ZQjlKxwdUsYDBlJpDmrsJw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791880862689730.0025283418281; Tue, 13 Oct 2026 01:41:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY34-0006po-2K; Tue, 13 Oct 2026 04:39:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY31-0006nk-Gn for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:47 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY2z-0007ZJ-OD for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:47 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a01933b584so23046635e9.0 for ; Tue, 13 Oct 2026 01:39:45 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880784; x=1792485584; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=dY5bJ6dJUERrSTEf33O+vZmh2Dy5obdCXPAP66j8BsQ=; b=N3GtelX+1jIP79XN9kYqU/WTQAESAPsHCaWTA0OcJKM0vTaiCYjQ116QbJ+U0GekQM zoTaA5LCKAEi9d25+ALAfZjd05FDHsIeWoLJb4XRHWol5iwpyXMHHjcq4IU/XwYILqAH vEjSJtaetWBDec64Ohzk4rdGNZotK+5bBxR8CdJxZUgj1eHUrA/Ro7QdhQBGVSlkBd24 c6E2jE/fvxC0vR+iKPFU/IOKfPgUGljhOXEfEXcaYV6LS5eOpyZVreVUTfsMZ6wwZrW7 ChXvAxx9NVe73XDSWpeGsckHLgDBwBhIbX/JcutjWsiRt3Q3b3gZT7FrTUgCWeuYPDlo nRKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880784; x=1792485584; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=dY5bJ6dJUERrSTEf33O+vZmh2Dy5obdCXPAP66j8BsQ=; b=KCIcAClBplqqJ5nq7DxMklZmaenHyw4I0xTPk5dHlYUX7ZEOydWcoD3qxgkx/1Lbeu QAX4t2H+O2dj2PoN3R6DmDf3xBQL0XWLWBNEBkmsj/9NOiZScwTl4H2P4n2VTHX1JI2b BScfeJNsjUSYgNcr5D0OTFuvLeBSxCM8V0ZiybMxKOuRIcqDx0S07FL3IqGyyVbwtK5i jYU9P8tHqKzttKOpFhnHMqVB5yd1BMQGVjjHDR/lJlBDAbS7lM4e9JPnJ3kQWE5NzTXw Q8e8J3m5fF0Vh+oq9MhvhzteNY7vERR9BmjezuVoEqj8g5CErnzk+BlCS+yI2rfrC3T7 S6+w== X-Forwarded-Encrypted: i=1; AKwUvBy9ZubrvWS487wOnK+ZfKBZxwIyYgG2o5XuaFaXaYyw6qKVg0PqEwWahsP14O4jFbZZm6spQ1DWvFO6@nongnu.org X-Gm-Message-State: AFq9FYLud/jbtgsMvidv6bvQzSv7zF7ejjMzbXfzIF6PoDdBbSnPPtA9 KIseWAFqt/ezakZkPDrPYXRxYnHmVFhLgRly+EPr1Aj+ZPQYwG4ZQbOxp12zzKgZ5oY= X-Gm-Gg: AYBFou2BqUCIudhEqSYkKAQa+BDs+EnvMSOdt3cMoxWugFWsqWsSSzlDBl0yCWZ/zat YVLgkxN4jhOhLA3Jkerg3/L0JiZ2QVIf+sQcSZlSxdCnwpRkK84kEkBlVJAscwp/fRGK3/LGeZW rLx+RfFAC1SBze85wjoj0doh/e/RO47RILTfRpY9zba1bc3oJwHkugF4Isq73ZYqOB7EQTcr28H 6q8Ev8F5SLpxz515qhzbEPs44NDtjPh7obtQHX6S1TzLo7jfFB9FPL7MSP539l50ZTgJZveB49t 1HOu1DHkotxVdZHyIL/T1FizljiXlSSNiqmP5h5rTFPz7oe4QyW65FgMSM60yiNIC7LjGA433B3 fsxmhQ97h5xHC0OB+39myThaT9R0Wo9s0QryCcAtQtQYX1T3cynyBSqxohtgSThHfOnAEjqmQMc SNuRYCYKCPRYm6kyJlRgHKt8pclI67EU5yZq3bvFBuRWmjkCEikzUWr/QG22XZ3j0XwzGNr1l+C 47C2Bo7pePAwORZbqo5kgDI9wYotBS+pcfmkgMN6/P6mc62i0rE0R4QUCN4GM/IXemYFkfOrzoi LkA= X-Received: by 2002:a05:600c:1c1f:b0:4a1:a484:2c37 with SMTP id 5b1f17b1804b1-4a1a4842caemr80018425e9.25.1791880783731; Tue, 13 Oct 2026 01:39:43 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 04/86] hw/intc/arm_gicv5: Regularize spacing in config_readl() switch Date: Tue, 13 Oct 2026 09:38:11 +0100 Message-ID: <20261013083933.1024405-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880865001158500 In this file we don't put blank lines between cases in switches, except that for the switch in config_readl() we've written it half with blank lines and half without. Delete the blank lines to make it consistent with itself and the rest of the file. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 2b08f8feec2..d354ac6b992 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1469,53 +1469,41 @@ static bool config_readl(GICv5 *s, GICv5Domain doma= in, hwaddr offset, } *data =3D v; return true; - case A_IRS_IDR1: *data =3D cs->irs_idr1; return true; - case A_IRS_IDR2: *data =3D cs->irs_idr2; return true; - case A_IRS_IDR3: /* In EL3 IDR0.VIRT is 0 so this is RES0 */ *data =3D domain =3D=3D GICV5_ID_EL3 ? 0 : cs->irs_idr3; return true; - case A_IRS_IDR4: /* In EL3 IDR0.VIRT is 0 so this is RES0 */ *data =3D domain =3D=3D GICV5_ID_EL3 ? 0 : cs->irs_idr4; return true; - case A_IRS_IDR5: *data =3D cs->irs_idr5; return true; - case A_IRS_IDR6: *data =3D cs->irs_idr6; return true; - case A_IRS_IDR7: *data =3D cs->irs_idr7; return true; - case A_IRS_IIDR: *data =3D cs->irs_iidr; return true; - case A_IRS_AIDR: *data =3D cs->irs_aidr; return true; - case A_IRS_IST_BASER: *data =3D extract64(cs->irs_ist_baser[domain], 0, 32); return true; - case A_IRS_IST_BASER + 4: *data =3D extract64(cs->irs_ist_baser[domain], 32, 32); return true; - case A_IRS_IST_STATUSR: /* * For QEMU writes to IRS_IST_BASER and IRS_MAP_L2_ISTR take effect @@ -1523,11 +1511,9 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, */ *data =3D R_IRS_IST_STATUSR_IDLE_MASK; return true; - case A_IRS_IST_CFGR: *data =3D cs->irs_ist_cfgr[domain]; return true; - case A_IRS_SPI_STATUSR: /* * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect @@ -1538,7 +1524,6 @@ static bool config_readl(GICv5 *s, GICv5Domain domain= , hwaddr offset, v =3D FIELD_DP32(v, IRS_SPI_STATUSR, IDLE, 1); *data =3D v; return true; - case A_IRS_SPI_CFGR: { GICv5SPIState *spi =3D spi_for_selr(cs, domain); --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791880826; cv=none; d=zohomail.com; s=zohoarc; b=VrTitMtAffE4Z/Kc2htsr+INRhA476Rhr5873gTuLv+unmvWh3S+q1wjcyiAVj+VO0kkLWIap1QfBdcc+JqXUYhQ/X/z6O/bHICJylq3YttV4YP0Qe8cM/5n/BzfPJWVYEwXlgg4kkHDbVk9Pn2UVNPJ+NHIDWaC1zPLkn+weC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880826; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=g6OTnu60gLipqvPEMbn84dPOVj5s3bqVLHK6HOE+ziE=; b=bIKPbtBHibgkiWwLjuJBPKNXqATwhZccXBLFDRcB2YhWUnV+34Mxh43eFctWTJJlY/dglDcmGRpwxRzTOCT2U9wO9WigAe8gdm6ZBVDgcrt/P44ivGcbuSK0j6j97ZUgx/TJ3fNtUelFn1dMyiTWykzNo9wv+rDgTwuwpC+wV5s= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791880826706460.53469326902666; Tue, 13 Oct 2026 01:40:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY34-0006q3-FK; Tue, 13 Oct 2026 04:39:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY32-0006oN-5k for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:48 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY30-0007ZT-IT for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:47 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-48b0584ad71so1495305f8f.0 for ; Tue, 13 Oct 2026 01:39:46 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880785; x=1792485585; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=g6OTnu60gLipqvPEMbn84dPOVj5s3bqVLHK6HOE+ziE=; b=w6bb7OkToceIyPRh62U9U4/+LkSX2oADBjxIsyx9r4SgZyXZv2xqSu3fIl6r8ikXMv ir1gfmzVF8oDqwIJ5xAqEpmuuB/Z7cfYfwkJobBsu0YZO/mFYDt7aRHp8O9McBeVRSxq zVMd8JcMl1g4TAByxBD35QW42gmpoJqDddLpvl0ZdKakxAd1Q30UOKVhJB6oPrXZSPKl qoB8qb4bBkIc2ukvbdfsY4yicFObJVovexLPmSvw8s+j4izy0cf4KIQQTQyoSNO7P4oq XT5CcwceOQ8D4DC8XOzlqXF9DrhTaK3qJRSPoAsbKCln9CEk85ieftjATrCNPjJmxB7x lc6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880785; x=1792485585; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=g6OTnu60gLipqvPEMbn84dPOVj5s3bqVLHK6HOE+ziE=; b=F7f0MVkEjqEcvy6giPQDkAYNZAhLP1yzVK9S6P5S70BcZZKeXKz6AsEZ7LR5oo/c5I HckCmjMtZQMjaZCp20hO3gERu42x2gP9HMNdmwvK1PgWSqGfB6WBs7dKFM/agzkmhw6z JZTQBMOc9vNjRZlPq92pAvaZT0rVKZ2VYHTx8wVN1aQYryq7v00OvJZD260YN4KcADYn gouTjCnUDbUgGxsqE1Md+TzVfpIh2OsO2CnZF3iXJi6equLEi5lWyAZ7/OCbijpW2wfU SxpmRZmzdDtHAIqNMoSOn7GsATQ2UbFxvn4K+8uS1JeYXE3wjAjhbs1CG9aX/BZHsYV/ 9Tqg== X-Forwarded-Encrypted: i=1; AKwUvBxBZsaLCUqIx5SdC6z5ZfqtD4GtanasSRZV+TDG9wSjiy1rdUL2o3nCIAizMuQDzTWMeTTKbfHvTja4@nongnu.org X-Gm-Message-State: AFq9FYKC4IgU4haLDs9k8hs7Ou02wpdEATaLOjwtpZgvUQkLFnZ9UV3q 2QuGEjFcCGbu/RLoB0BvPODz5zFmktpY5y9jTpB0HpwadBfmNnYjmDFTYs4gq0XyHz4= X-Gm-Gg: AYBFou2JAx+rnlf8RF1rnGgJ60qxG9Id4xY0A93keAyeO2ucCfni+MWhNpDIAJEKb9g IpttBvqY3Tkk3YfMNmuxQQFvL6KxYZZQx/QTMSvBALf3mBc3iRWngDT+eHpdQpcwzZxxM2giQ5T iLs68JOLbr08kuxcF3p7wDQPVQqzcl/85AGh30JidHzVd3YPQ2qb+iUQtpPBYYJi1SV55Wh1cS3 p4y4cmHVV5BZZNn4T6Z2ZT8roY3Qe080ahl/wdrn3YVSX9k7ads2VVq/z4Mjvl8ggGM513Xzdau c1tbX9l31kaMxntPxnhY20Bmi0t2oyWKxPpwV0x1FAqea0TZ/bCmZRURYhstAZ0mAqu40DYsG7g DBvdVAfzFqvvuUfqz6qwCdqfp/kw0/ijB4xIaRjyKLHbfiaeJ9avBtRYGZLxzP7b+jwarQbB8XV SwzJzl/0yRZ4tYJagUGOMDjKpVlUqKO9pYB8QGPlwOw54xTgKjPY7SpIcpIj3lrZ5nM12FePHBI E/jTx7ezkqiWvd+x24taOBdyc4IuPfKkXq9a9fVuHLP5JXEUpi6JIb/oixfrunAPSQzTyLHd0X/ qmA= X-Received: by 2002:a05:600c:609b:b0:49f:ce78:356d with SMTP id 5b1f17b1804b1-4a18e4c9944mr219993375e9.30.1791880784696; Tue, 13 Oct 2026 01:39:44 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 05/86] hw/intc/arm_gicv5: Use cached IRS_IST_BASER.VALID state Date: Tue, 13 Oct 2026 09:38:12 +0100 Message-ID: <20261013083933.1024405-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880828518158500 Content-Type: text/plain; charset="utf-8" When the guest writes to IRS_IST_BASER we effectively cache the value of the VALID bit in the GICv5ISTConfig valid field entry. In a few places we check whether the IST is valid by doing a bit extract on the register value; switch those to look at cfg->structure instead. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index d354ac6b992..ca5c3ca6e03 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1223,8 +1223,7 @@ static void irs_map_l2_istr_write(GICv5 *s, GICv5Doma= in domain, uint64_t value) uint64_t l1_iste; MemTxResult res; =20 - if (!FIELD_EX64(cs->irs_ist_baser[domain], IRS_IST_BASER, VALID) || - !cfg->structure) { + if (!cfg->valid || !cfg->structure) { /* WI if no IST set up or it is not 2-level */ return; } @@ -1294,7 +1293,7 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain= domain, uint64_t value) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); =20 - if (FIELD_EX64(cs->irs_ist_baser[domain], IRS_IST_BASER, VALID)) { + if (s->phys_lpi_config[domain].valid) { /* If VALID is set, ADDR is RO and we can only update VALID */ bool valid =3D FIELD_EX64(value, IRS_IST_BASER, VALID); if (valid) { @@ -1605,7 +1604,7 @@ static bool config_writel(GICv5 *s, GICv5Domain domai= n, hwaddr offset, deposit64(cs->irs_ist_baser[domain], 32, 32, d= ata)); return true; case A_IRS_IST_CFGR: - if (FIELD_EX64(cs->irs_ist_baser[domain], IRS_IST_BASER, VALID)) { + if (s->phys_lpi_config[domain].valid) { qemu_log_mask(LOG_GUEST_ERROR, "guest tried to write IRS_IST_CFGR for %s config= frame " "while IST_BASER.VALID set\n", domain_name[domai= n]); --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791880998; cv=none; d=zohomail.com; s=zohoarc; b=XQFhQRNC7Lq4/8UUEboLMvUaCuVezA9+vPM9BErR3VNLZ8jVKTkyJUPEApTsRNcolB1ILDe6Gmt+N4RXanKty9IyDQL/U8g3VLdSV7Kug7MR4bnEVIN2WAbDMsstApHva9eDqeGY2I1RFOJGlsr0Q425OV5Fyod1Axr1vFNKfz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880998; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=CdqM6HYBiDR7dqKjxvWd0m8Z09BAdsUWKaoEl5skuzI=; b=OOON60hrLHy4vp8i9SR0+I4ETIEDdavp1M7PXMOiPOB7x/plP1LIeJZHjz10eeSkzsScQVRGIl6ySzjPUqvnLFNUJk6BfGkUNTSf25NOSSlFlkqtnaXfaJKX6Pj/1BXUreBsy9dJHPBOXx0WIcfsFWadGKfzpUsEEdG4GoWxpIc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791880998807477.62373084433625; Tue, 13 Oct 2026 01:43:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY35-0006qb-81; Tue, 13 Oct 2026 04:39:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY32-0006oo-Qm for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:49 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY31-0007Zl-7M for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:48 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4a17baef589so22009505e9.0 for ; Tue, 13 Oct 2026 01:39:46 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880786; x=1792485586; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=CdqM6HYBiDR7dqKjxvWd0m8Z09BAdsUWKaoEl5skuzI=; b=kGH8ItLCqyxZgFSl6LC7SLiS0Dfr9SMYdt7TL3C2RNc1f9x7xJeD3pfNX454KSFa2t wsGtqW+Tzxd+ftFa3xN+0ZQuQEDix0hjk2eJiLIWSvLTXYnYf/1vJCIJLh293ush4k26 kzILFDgtrhEimzP6rz1c23CecpIJzdGKPnwL3oZHLFSYLknkG/cKsmMSsfwXzJxeGRa9 IwHFLwMvNMEbP+rwhy8X2vM9tDQPPC89oKztiFhCr6hWagLvKORErvNg0W53QNjJkxuJ iBhLJtnbV7MEsniehemJN1swRkvnfUu1u2C4GvuEyqAWUF51TOlJML058JFaiQd9NA5N WTkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880786; x=1792485586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=CdqM6HYBiDR7dqKjxvWd0m8Z09BAdsUWKaoEl5skuzI=; b=dLIgmNzHdjEam3LSlmlVUbhgGAMqK+mYmfCkqFbDa+KrirVblJhN2x1MA914Nm9ijL +Z1/YxiZQ7qhHiEl43qQsbG8zT+sGKCqbmawZDhEvTFJ2gERlfTQbeQHKGYrzVzkCJvr fbPo6VfuNPNw3VNFx69Owqc8BeJXPxWH6MocpvsqN7y/OmvjRePjLmxGMzd9+1B474Bb /oHv0kR4EjyzRKiLFgti9bwl6ZMn6ZvEzZ9w2PRImDuNTNASm0L0ryH6OmhTgdZeP8DT fBmHsz2osRV8YhC7YIzomUxqHGxQN0Wfgr2k1RXsB0cLLGI0Tg+IZqOyj4F8HuOn6AsY sFMw== X-Forwarded-Encrypted: i=1; AKwUvBw/QVvKvSykl6KVysTX0wnbZPSZ1Bi1xUK2mHSw5CFLH7dQsTJewQBdRWLwDHY+K3EKwx7ARI3Nhx3I@nongnu.org X-Gm-Message-State: AFq9FYIA/GjYmiqu1JiY/LMiblJ4BX0FNufU8zIBfm+xLlneEaWYWCcp kQkbh8ZTZvf6hHHe3oDpqyUEDVpeCbdmlzl6X0vfz+Ei544Yb5MoUaEqFyu93JF5X7s= X-Gm-Gg: AYBFou2Ii4u0PLGR79MJ38ZNYMzFWmZTnYp8Gh90RwDv455NvP6EnV8GXnjkdr3Sleo R1kXju6uW5wirKnbYW9Wd8WqmtDAv0or7F5HXluzF+56HMYQpDSY2hbjzwu4Kl/9lAYw/6tz/0A g+7opTy05lxhHTdKw0YVAovG70qkAqnqywoNW0W2G69B8k5GGR+tyr3lj1yCx1hmobjLgNc90bZ uQyogXVNuUlkn0zMCYDNU093yKUfpGTuTbyQtfsvNK+6NClLxg+19zKWqArnOmH60tWfbRrzkLH 0Zy+ilSGZaVvbDdsAVsxr0W6PoKLbs9e2W/8ENG7UvypZ/gdAR2L4/Vm6Lf2XWlqJQjSv/DEnLT DpIK1A6lLvS3AsKD80xaNyxWY6799btZhXyYZoJ7MmLZACvEMs0O/jpn6ASdjWD0JcebL6OIVpm H34WsbBdvnZ9TH0T73rjRDjMS27qjk4QO2K2EJYcQgvSsSbYM7ESOeTi3jxWhvAUpRMGSVLmF+b 2O8l4vC6CPlKWVwkXaGm18Jeh3+5fgFoF8o2G28anwV4ZXuCNg7Jrjzwl1NlKDIVCK50RwffgQL JbIS X-Received: by 2002:a05:600c:4e89:b0:4a0:12d7:4c88 with SMTP id 5b1f17b1804b1-4a18e4ac77amr257836635e9.30.1791880785675; Tue, 13 Oct 2026 01:39:45 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 06/86] hw/intc/arm_gicv5: Free memory in finalize Date: Tue, 13 Oct 2026 09:38:13 +0100 Message-ID: <20261013083933.1024405-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880999486158500 Content-Type: text/plain; charset="utf-8" The GICv5 allocates memory and creates hashtables during realize and as part of its operation. Free those resources in finalize. Since the GICv5 is created at QEMU startup and remains in existence for the lifetime of the process, this isn't an in-practice leak, only a theoretical one. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 11 +++++++++++ hw/intc/arm_gicv5_common.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index ca5c3ca6e03..ecafb4838ab 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1971,6 +1971,17 @@ static void gicv5_init(Object *obj) =20 static void gicv5_finalize(Object *obj) { + GICv5 *s =3D ARM_GICV5(obj); + + for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { + GHashTable *ht =3D s->phys_lpi_config[i].lpi_cache; + + if (ht) { + g_hash_table_destroy(ht); + } + + g_free(s->hppi[i]); + } } =20 static void gicv5_class_init(ObjectClass *oc, const void *data) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index b155486af65..cc67246686e 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -112,6 +112,9 @@ static void gicv5_common_init(Object *obj) =20 static void gicv5_common_finalize(Object *obj) { + GICv5Common *cs =3D ARM_GICV5_COMMON(obj); + + g_free(cs->spi); } =20 static void gicv5_common_realize(DeviceState *dev, Error **errp) --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791881187; cv=none; d=zohomail.com; s=zohoarc; b=LJfaZfoXJOVCuVV0bLBoOlzFXVCgpny5yM9jSZI05+A46njlgGv8rW+aqoE2648glRnhvIOHu9ENEc0+aM2NtyBKVJFdDGXSQBFninRguUhse38GNq83w1SLgIMmuWD+0JDywpH2apoiT9DtV1cv1fYOJNwZ6gfIkkYpTM5GM70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881187; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=OaiC0A3kyB7u1DNetaci/CV68nbx8shGZnFz0+Agagc=; b=DuaPFExWUrOAS8LyTK11Tm4f0Fz7v4/+i0QoHggDVgJNh15AJxhoj7AnUR2C2sBpq61r28qUFPpGqZSlYWQNEnnvw2EttHBiL4/sFX2F7WIJJHvc/GdOVVUO2Jl4Vy8FIeaAQuEKaAl8U9EOfS4VBiL6KFUUyKutTLmTyTwDTU4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881187770343.6387999744428; Tue, 13 Oct 2026 01:46:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3Z-0007RT-FS; Tue, 13 Oct 2026 04:40:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY33-0006pm-Ug for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:49 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY32-0007a4-3l for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:49 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-49ff680331aso21708255e9.3 for ; Tue, 13 Oct 2026 01:39:47 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880786; x=1792485586; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OaiC0A3kyB7u1DNetaci/CV68nbx8shGZnFz0+Agagc=; b=SM7FturrB2CnLG8ip++Ru1u8lJc/0KOc3eWiZF/m+rB+qhWsU4wYDpZdO6d3lKDEW2 I/W7xXz4ZgT9zDaVxNJXdaekyUbvNdxVCJpdSRoQrprrkOM+WpcDOD5rPmiM53V6gMS0 oshtz5XWuYMhWQ3quLtH54A/SHro4XTasDnx0Tw5tRNtYGYzyQCz22mqZJ5sLvDFtok4 QEwrOseuxWdFfDfE+aoxVf6SVQCxQfyxjSZzvzOaZYVFxitfsgHD400IiM/aBrVVN9LP 8g8hLN2ij9y77paGIIdrMMiMPPw0haBBWdwda6RB8AszYSPiCiQPzEkJGx71GVZicIFt TqDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880786; x=1792485586; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OaiC0A3kyB7u1DNetaci/CV68nbx8shGZnFz0+Agagc=; b=mb6IsnDsfai5Qd4w2+Ynr/364jiYutjZqgYgbBXZeoFrnhN+cKt8BGTj9R/jF2rqu0 dZan2Hqz44+gggpNfFUg/w069Gef7Uifi6PAYZ+5rMxjXLH2YODVwxyaHKhZ0aB/sLGg s9FoITd/JeU287ShPah3D9ouoam9y92OR8nWWZFs2qGq+0Ha8NHH4Noqtw766XQsd9PG AI5IKijersfsnljiUCYZX/zCAjNZHOpFgduXQ5Iscu6OpdyWO5+TZ09rrGQvWrH2NyQq 7m+oVlen7n8tqiAOTCNzsmvcsZFWDvJ+oRitxKXMMTKfjBUB/vWevCHXRrG+1iOrPFSU vG0A== X-Forwarded-Encrypted: i=1; AKwUvBzh0ZP4R7NyfZ8tte8CiC1WqGWP1ovTWabemgW+Ub/Al3HuVh6gRi8uJmpG3pp7mS6I0swHy+T/I/D/@nongnu.org X-Gm-Message-State: AFq9FYKM1i3pjfevtBgxB98IdfYDNdH8dkXDVKbmLiAUGR6HfGK8v1dD ZrR17o/5iRVvn2HqB4umUk26GW7svcqoa1ARJSXphUGHkwGt5gm48J2pe0v798Ep5TlxON58ESp DS4KDOgM= X-Gm-Gg: AYBFou31VT9nRvyvidastMomJQr2WOHm9USi+kWC+QoFiDeUYHAC1PQvuOCBDjG4oB+ mZm6LKQJBJIC9+xHON4mE+XIRoqpx27lWURsru+4GGQQM1iaCcosG1rlfqZZF5buxDL8hdSgR1a tbGgK2xO5GjD1V+KrKSmGvoyExwsnMZGHNZuglys/h/j0dVs0K37EmOzK3mLLkxbJMSJtagGgxs javp2EuV1icz4DT5nyi+qe2wQ1LRc15AzOKq1dQCX4I9vSZohw29hrMhG0JGC+Xy3LqBJLeNBZ1 2D+w+d9hHPhkfcNT4IXKz+F11+ytPbnPqcpWTE62eiR2eqNV8RpE6AOKXM8xZ/bz4g5KL99mjq8 LRC/rEzYcJfGpM1LD7VIZFUGxcps3eIw1y7bZ6a14qk6dgAvfkpLJB7LoVmloZCR7NHhP6XzTT6 2xlI/+smcOz3w2LEo9akq2yWUritB8j3v2DxAxBvaiK08t6d4jEZIYTVUgvrKzosz3YED0mgyUH td2rvOE4LcPPE4l92q9KlTtKht6KjKNDiOvDtNqROk9aLn2cxg+E9pCmrO4/HTDEnBkR0pIakz7 O84= X-Received: by 2002:a05:600c:c167:b0:4a1:a3cc:3c5c with SMTP id 5b1f17b1804b1-4a1a3cc3c71mr70054675e9.16.1791880786633; Tue, 13 Oct 2026 01:39:46 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 07/86] target/arm: GICv5 cpuif: Use arm_cpu_set_irq() to set IRQ/FIQ status Date: Tue, 13 Oct 2026 09:38:14 +0100 Message-ID: <20261013083933.1024405-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881189155158500 Currently the GICv5 cpu interface directly calls cpu_interrupt() and cpu_reset_interrupt() to raise and lower IRQ and FIQ. This is almost but not exactly what we do for GICv2/GICv3 external GPIO IRQ/FIQ line changes. Those are handled by arm_cpu_set_irq(), and as well as calling cpu_interrupt() or cpu_reset_interrupt() they also update env->irq_line_state. For IRQ and FIQ it doesn't matter whether we set and clear the bits in irq_line_state, because nothing looks at them. But for VIRQ and VFIQ it will matter, because VIRQ and VFIQ are the logical OR of the line state and some bits in HCR_EL2. We're going to need to call arm_cpu_set_irq() for VIRQ and VFIQ; for consistency, handle IRQ and FIQ that way too. Since arm_cpu_set_irq() is now a function called from other parts of the CPU code, we make its first argument a properly typed one, with a wrapper taking void* for when we need to use it as a qemu_irq_handler. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpu.c | 14 +++++++++++--- target/arm/internals.h | 14 ++++++++++++++ target/arm/tcg/gicv5-cpuif.c | 35 ++++------------------------------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 10ac6c98318..014ec6a945e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -808,9 +808,8 @@ void arm_emulate_firmware_reset(CPUState *cpustate, int= target_el) =20 =20 #ifndef CONFIG_USER_ONLY -static void arm_cpu_set_irq(void *opaque, int irq, int level) +void arm_cpu_set_irq(ARMCPU *cpu, int irq, int level) { - ARMCPU *cpu =3D opaque; CPUARMState *env =3D &cpu->env; CPUState *cs =3D CPU(cpu); static const int mask[] =3D { @@ -862,6 +861,15 @@ static void arm_cpu_set_irq(void *opaque, int irq, int= level) } } =20 +/* + * Wrapper of arm_cpu_set_irq with the right argument types to be a + * qemu_irq_handler function for our inbound GPIO lines. + */ +static void arm_cpu_gpio_set_irq(void *opaque, int irq, int level) +{ + arm_cpu_set_irq(opaque, irq, level); +} + static bool arm_cpu_internal_is_big_endian(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); @@ -1265,7 +1273,7 @@ static void arm_cpu_initfn(Object *obj) */ qdev_init_gpio_in(DEVICE(cpu), arm_cpu_kvm_set_irq, 6); } else { - qdev_init_gpio_in(DEVICE(cpu), arm_cpu_set_irq, 6); + qdev_init_gpio_in(DEVICE(cpu), arm_cpu_gpio_set_irq, 6); } =20 qdev_init_gpio_out(DEVICE(cpu), cpu->gt_timer_outputs, diff --git a/target/arm/internals.h b/target/arm/internals.h index c41fa5225c7..9d817961c67 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1886,6 +1886,20 @@ void define_gcs_cpregs(ARMCPU *cpu); /* Add the cpreg definitions for OMAP CP15 regs */ void define_omap_cp_regs(ARMCPU *cpu); =20 +#ifndef CONFIG_USER_ONLY +/** + * arm_cpu_set_irq: Assert or clear an IRQ/FIQ/etc interrupt line + * @cpu: CPU to set interrupt on + * @irq: one of the ARM_CPU_IRQ/ARM_CPU_FIQ/ARM_CPU_VIRQ/etc values + * @level: 0 to deassert, non-zero to assert + * + * This function is called by the qemu_irq_handler function + * when IRQ etc are real inbound GPIO lines; it is also called + * directly by the GICv5 CPU interface. + */ +void arm_cpu_set_irq(ARMCPU *cpu, int irq, int level); +#endif + /* Add the cpreg definitions for the GICv5 CPU interface */ void define_gicv5_cpuif_regs(ARMCPU *cpu); =20 diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index a6e6c440849..517c780d1f7 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -173,33 +173,6 @@ static GICv5PendingIrq gic_hppi(CPUARMState *env, GICv= 5Domain domain) return best; } =20 -static void cpu_interrupt_update(CPUARMState *env, int irqtype, bool new_s= tate) -{ - CPUState *cs =3D env_cpu(env); - - /* - * OPT: calling cpu_interrupt() and cpu_reset_interrupt() has the - * correct behaviour, but is not optimal for the case where we're - * setting the interrupt line to the same level it already has. - * - * Clearing an already clear interrupt is free (it's just doing an - * atomic AND operation). Signalling an already set interrupt is a - * bit less ideal (it might unnecessarily kick the CPU). - * - * We could potentially use cpu_test_interrupt(), like - * arm_cpu_update_{virq,vfiq,vinmi,vserr}, since we always hold - * the BQL here; or perhaps there is an abstraction we could - * provide in the core code that all these places could call. - * - * For now, this is simple and definitely correct. - */ - if (new_state) { - cpu_interrupt(cs, irqtype); - } else { - cpu_reset_interrupt(cs, irqtype); - } -} - static void gicv5_update_irq_fiq(CPUARMState *env) { /* @@ -243,12 +216,12 @@ static void gicv5_update_irq_fiq(CPUARMState *env) /* * Unlike a GICv3 or GICv2, there is no external IRQ or FIQ line * to the CPU. Instead we directly signal the interrupt via - * cpu_interrupt()/cpu_reset_interrupt(). + * arm_cpu_set_irq(). */ trace_gicv5_update_irq_fiq(irq, fiq, superpriority); - cpu_interrupt_update(env, CPU_INTERRUPT_HARD, irq); - cpu_interrupt_update(env, CPU_INTERRUPT_FIQ, fiq); - cpu_interrupt_update(env, CPU_INTERRUPT_NMI, superpriority); + arm_cpu_set_irq(env_archcpu(env), ARM_CPU_IRQ, irq); + arm_cpu_set_irq(env_archcpu(env), ARM_CPU_FIQ, fiq); + arm_cpu_set_irq(env_archcpu(env), ARM_CPU_NMI, superpriority); } =20 static void gic_recalc_ppi_hppi(CPUARMState *env) --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791880863; cv=none; d=zohomail.com; s=zohoarc; b=Ru5bUKeUrMVTpSf2eMUaX5oYaK8Ha14PVwEwzknt4/9S53OEzA/cUZD9TCidIyxiqCfbOnLHPrKLoPQDB/uuaBwm4iRqheEIJJ1lDzDZHUxC0Pl4KGRlaJF5zoyr0kBsVOOW4tqDPw41J80n/rOQqi+uK4aoXa9hjE7RmH/qaFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880863; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=e279h5aviwj2Oil4aweVMx7m2/REtZvKy9eOEgndrbI=; b=AD2TdCpVlxESbHH3NlUL62vaFm3pe7foKETmVSgeCBoUeE1FBxWaMgtUmIN9fO2TK3ztWekivS5YaZwab3PoF9KN24BKK8Afn4g4K+qLsNYjiCbLwGCXgCSBOl7Fr+Rk9aLIo1kaPQvXW7kZTe+J6MSypvHjV90yCT1jRhfTgNY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791880863213391.68185897141757; Tue, 13 Oct 2026 01:41:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3U-00078n-8E; Tue, 13 Oct 2026 04:40:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY35-0006qy-Ey for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:53 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY33-0007aj-LJ for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:51 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-48b0d19cf7eso3172940f8f.1 for ; Tue, 13 Oct 2026 01:39:49 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880788; x=1792485588; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=e279h5aviwj2Oil4aweVMx7m2/REtZvKy9eOEgndrbI=; b=wWfs3F1kJ27omE8c/NesPbup95SAdr76iQFQjmA+crCJt/C2lHNs5/eboYZWVT9wzt Ml1JsfvneNBSkmC8BX8uOJCEg2yz5l0PgHj1NrEjEuAcdvc++/AZZlwfDwO8WVOU4OoQ uQNQxaV563qutbFer+GQhWTHFC7/LSHe3eQSC6WUsMPw4SkHgpUCkKTgXFCw07LmVVu5 RAFb1KS4MG/5Fhv1DhTCH5h9VawdA8WO+HahUUbbX6uMCqlsSrusB7cbF4eo0kzDlFwm Y0A/Wz3t24g1hf1wMnebGGDzkOYIa2OntWIhFuJGCO7QadZeh2IdzC07BgNAiocERxAE PNkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880788; x=1792485588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=e279h5aviwj2Oil4aweVMx7m2/REtZvKy9eOEgndrbI=; b=U3Qf10eN6b+xxwELl7t+1fcXIuO9s7IBBrU8c7ay5dDdyy2N7gCdPHwGgVmePUSuzq ZGc0zrfsE3evPDaxVoPuBTNwpUL3ulV2n2K0X+3+v2KC+RHrVnSWmtmYs5nF8oA84OP+ DPYTx8RFJ3hmNncP+OB+a/0HyTDgt5xhcaZNbua+XxJTaZWB+JYHUDQBW7AHtcvPeCVz hEnHA99Hs7ASTZpLgEiwE1Wf8nx1B441PX+CnJNxeKzDLAQTXljykFa+W3D/imo6Mx3r 9ROAebxyhtL9RDLN/gdWhKwoohbqPLbKlEiOa7Yp06HnKkMVCuo7gzsO3W1lW2TDGmPC e/KQ== X-Forwarded-Encrypted: i=1; AKwUvBwB5U1D2/oItoVSFYoJGw225O+uFbBzUgi+ZzO2LKGBwElEN58WEAQ080B30t1MvcfYRSC/yvhmr7np@nongnu.org X-Gm-Message-State: AFq9FYLCjvkE7om2v0jbANhRn+1McSbUjDTn8HNo22tje0690s6pBoKn n/e4amroIEhjFbaI5KJJhJrfdZolqZgsqGKJVbl0XC8+5AfecOxg6oOzNRVss3sQnyw= X-Gm-Gg: AYBFou1htAOhDoguUYICqRItQSu+gRnRYHbkxyMvftEZ9kWio0E9SfJbjuKkQMcyEo4 fDqGFyFsWWDfzPo3WdtEcZB8WcxcCm9d8gHjW0YqPC0u0cfpxSWBUAumKRt/MBSFI9jepBtdJ7S l9Xn8VF1lNf3+Qehen7ToCQ9TlFx549QDSbkRWx9IFAv5pcAXnhzJ8vYiIpFu7IJf4Rr5O93n2z lGzVUobwMcEQVLJ79OiI0uaI66cNPQ4OT1i1pNBPfJ5YiWYKNN1QmCRzLT/ico4NNoRntJf7NoS 8pPdecemiBAhzHE/lBwbC7lAFYPqD/IJdPpQHZvijXkp1z4EmzDpBkJ+qmYAmxmPxE2WuxUZbPw +VdV/P+QZZd1yH0iW6z4JVPI2zV+WUOnug7bnfCo8TlEqsBQoxpF1al9MlcNpqDxfqtJvT1edLI cL052u/9h7ujXMEpGA4mrvnDh0rrTk3HWoljVB3XYFdU4RWUL6+1zngODddBfaWFy94/KTJYHs4 zMuHdRdYWWtwWWu9lqjHvtO1FIYkEIZZMA3FxVm0J8WCFc6dKLAHuBLfaY+W2pYUhp2wONvwfUx cWg= X-Received: by 2002:a05:600c:5254:b0:4a0:20b4:ba93 with SMTP id 5b1f17b1804b1-4a18e4aa11dmr239412455e9.16.1791880788130; Tue, 13 Oct 2026 01:39:48 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 08/86] target/arm: Only allow GICv5 on CPUs without AArch32 at EL1..3 Date: Tue, 13 Oct 2026 09:38:15 +0100 Message-ID: <20261013083933.1024405-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880865055158502 Content-Type: text/plain; charset="utf-8" We previously allowed the GICv5 on any 64-bit CPU, with a hack where enabling the GICv5 silently disabled AArch32 for EL1..3. Now that we have a separate 'max-v8' and 'max-v9' where max-v9 correctly doesn't implement AArch32 at EL1..3, we can fix the "when do we expose the has_gcie property" condition so that we only allow the GICv5 when AArch32 doesn't exist above EL0, and remove the hack disabling AArch32. We could instead have defined a new ARM_FEATURE_V9, but "allow the feature to be present on CPUs where it doesn't actively break anything" fits the way we've generally handled things in QEMU, and it avoids having a new V9 feature bit that we only use for this one thing and where it's not clear when we should be setting it for KVM, hvf, etc accelerators. In practice the only CPUs which will allow GICv5 now are max, max-v9 and a64fx. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpu-features.h | 8 ++++++++ target/arm/cpu.c | 37 +++++++------------------------------ 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index a9eebb45564..3322d65fc19 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -1130,6 +1130,14 @@ static inline bool isar_feature_aa64_aa32_el3(const = ARMISARegisters *id) return FIELD_EX64_IDREG(id, ID_AA64PFR0, EL3) >=3D 2; } =20 +static inline bool isar_feature_aa64_aa32_above_el0(const ARMISARegisters = *id) +{ + /* True if any EL above EL0 has AArch32 support */ + return isar_feature_aa64_aa32_el1(id) || + isar_feature_aa64_aa32_el2(id) || + isar_feature_aa64_aa32_el3(id); +} + static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64PFR0, RAS) !=3D 0; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 014ec6a945e..d9e6d1ad771 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1594,8 +1594,13 @@ static void arm_cpu_post_init(Object *obj) &cpu->rvbar_prop, OBJ_PROP_FLAG_READWRITE); =20 - /* We only allow GICv5 on a 64-bit v8 CPU */ - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + /* + * We only allow GICv5 on a CPU with no AArch32 support above EL0 + * (which is typically a v9 CPU), because GICv5 defines no AArch32 + * system registers to control it. + */ + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) && + !cpu_isar_feature(aa64_aa32_above_el0, cpu)) { qdev_property_add_static(DEVICE(obj), &arm_cpu_has_gcie_proper= ty); } } @@ -2249,34 +2254,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) =20 /* Report FEAT_GCIE in our ID registers if property was set */ FIELD_DP64_IDREG(isar, ID_AA64PFR2, GCIE, cpu->has_gcie); - if (cpu_isar_feature(aa64_gcie, cpu)) { - if (!arm_feature(env, ARM_FEATURE_AARCH64)) { - /* - * We only create the have_gcie property for AArch64 CPUs, - * but the user might have tried aarch64=3Doff with has_gcie= =3Don. - */ - error_setg(errp, "Cannot both enable has_gcie and disable aarc= h64"); - return; - } - - /* - * FEAT_GCIE implies Armv9, which implies no AArch32 above EL0. - * Usually we don't strictly insist on this kind of feature - * dependency, but in this case we enforce it, because the - * GICv5 CPU interface has no AArch32 versions of its system - * registers, so interrupts wouldn't work if we allowed AArch32 - * in EL1 or above. Downgrade "AArch32 and AArch64" to "AArch64". - */ - if (cpu_isar_feature(aa64_aa32_el3, cpu)) { - FIELD_DP64_IDREG(isar, ID_AA64PFR0, EL3, 1); - } - if (cpu_isar_feature(aa64_aa32_el2, cpu)) { - FIELD_DP64_IDREG(isar, ID_AA64PFR0, EL2, 1); - } - if (cpu_isar_feature(aa64_aa32_el1, cpu)) { - FIELD_DP64_IDREG(isar, ID_AA64PFR0, EL1, 1); - } - } =20 if (cpu_isar_feature(aa64_mte, cpu)) { /* --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791881218; cv=none; d=zohomail.com; s=zohoarc; b=epjLEYnOCczAxWAg3nG53o7fxhIbBwXjifbs7/QCdUMNR9lGJx1Q0iTUeGT12y3/FMqwYNAst2F3J+LnXtdx9diPrPaMxE7dcrCH6GcNRfYMhLEEbnxzNpxiYsz4/AqICfTVu8+lBQe9gmqEaC09aLKFu6oYtfg48QAzixK5ljI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881218; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Y5b5DfgJa/hfRu28byh9TDYXyYRAsZXk05ndwETZi9c=; b=NZrO+39fzCZNmO/truxR1z12Lhm9BaCX8qT2vvwxmo+6sFMcArZxaGnVo4BBDtOmqSn08Xj56/SQtBQGzEZvQsInkbDrJ9/we4DvQ45yLx2ZXncyTwyw+P+X9dgWXQ7uwI1HxsVKTUIgkrTH4Ipz0kfbnuEFCCW0ROExYeA+hXw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881218054194.49169734564828; Tue, 13 Oct 2026 01:46:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3T-0006yb-8R; Tue, 13 Oct 2026 04:40:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY37-0006r9-35 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:53 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY34-0007b7-Ok for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:52 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a0286c981dso22786535e9.2 for ; Tue, 13 Oct 2026 01:39:50 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880789; x=1792485589; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Y5b5DfgJa/hfRu28byh9TDYXyYRAsZXk05ndwETZi9c=; b=neSbMe0mtq/lYKcWqIMHAuFAm3krRGxJFFE8TNIw8TnvYPWRE+DKji7OOvS6of4dg/ yd/tpgb36QZdOwzUKVqqTlS85uV2Uc0iAPcmrFZIUA1iRDvgnO55oYdnUowjyQjAwKqi WGT0b5AzYW6DpiP1WjLXeOn0Rj9Nqdb+uBqSKeMY0VIZnUBw+vPqcyEwivqDOe/OTfvu bTqYANALz5DTN9yvHdpeJaVPQKNpOxg+cJ0X4sOeM2wrK3z/2X04snJR0MyMBmn/4EYW lm87Vwx/D36KxnWfdXAU48HJz0+a9/0YAdVxHGUIFB3jHiDHhzJ48bGOPCcg7SIgWeDM VXgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880789; x=1792485589; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Y5b5DfgJa/hfRu28byh9TDYXyYRAsZXk05ndwETZi9c=; b=EVjKK6jtJdYYYc4JVhlwVrlktomwrNQOwoqciVPOc53zLEYfuP9+vaqYsApqXF0ecw ipYFBAmeiMZ90o2UuozWRJTz4ItX8+BHmGhSgUW9iVKHSLVhhJ/srlvw0sCQ8fnuqvVY kNtri4nD4xyn5iHEpxZbpgI0ppFuNLgugXd/1s3BRXWOenllWbo+ToI5U2I8/2SJ6EAC 9q4BzWZBp8K+XpY1kpj5iiVqiLFGgLbxKFLyDNEEjrTKMJou2w3o132TecThQF/UsyFx nYouGp26+YsKc3OqpBBSUlN2T8WTPAg4/MZjJiIvxYJ8Xgk07p8/YC1khAidlnbZRff+ tbug== X-Forwarded-Encrypted: i=1; AKwUvBwSpgZCRL8zsFvMhVVqeeEHVwUdD6L55G4OPbvD6kOVMo2WQWEN85+pGeYvpOCEKMrwiUGpnvpxaEsY@nongnu.org X-Gm-Message-State: AFq9FYIcF8vi5YWNWDJoQvyQg0LMsnpHK2FqxUMZx1pzjlnONseR8i6H BWD8ETcHq8n9/8f7VnoPZ3bwX7X0bQjC+W0pd5Zy2XA4OArziHjQLcj8ViqxjV0lt/1Bf50GqZT yPve2Nnc= X-Gm-Gg: AYBFou3B9a2jI3RtHMBCD2qNoH9vr5fP6b7IXeTzGuLTocAd/w3n/P9e8HlFBBZUxtk elo/q/wGnKOrLObIA8dJ3/y8QmGHdX7IqbOODUaiN3DrZwQPpENM3pllIFhftt68YPXod82dW4c vAWV5dR8ZH6yof0RAHiLgweAUv4CVWC8VEOtknxn98qcJf4hFaOTOjgkLp3nBq1uwkvRwZW5Slr LV2+416ilQoT+dRs/9Lm9t3EV1ZY/BxMlgUZxpyT7BMAXkQcz4+YgIAzlNzNG0I+rkoopFdQoI0 sjoi9XG1VL0LeZFdK7xyxWnSxXOemDQJs3Bv3NgGwixKhBTq/kHQp3BMl9efwQyXNQ3VJbJA2Ez OAKoMOWWUCyDJiCGioCP6OiknWXrrs5RFfTg8OW1dMSLMFgvuNUSci+AsaXI7BDIGjJkctQCZHq K0YHUSw/swAYohzM15UVQFZej3+toUTy0xG+VYaON4m50gdaXcYERc2BbqfutjVO80SW1iZnNtU BfRPQXh3/1yK2JECqm03nZL0C9EawDF/98sxssRq2TtSySV7RzXTxg9hypRRwOTSR4ni602v0xj gGY= X-Received: by 2002:a05:600c:8b06:b0:4a1:7ce1:2eaf with SMTP id 5b1f17b1804b1-4a18e4e0963mr234306935e9.34.1791880789239; Tue, 13 Oct 2026 01:39:49 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 09/86] hw/intc/arm_gicv5: Pass CPU index to CPU interface Date: Tue, 13 Oct 2026 09:38:16 +0100 Message-ID: <20261013083933.1024405-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881219724158500 In a real hardware GICv5, the IRS knows which CPU is talking to it because each IRS<->cpuif link is a separate 1:1 connection. In QEMU's implementation, the cpuif code calls functions like gicv5_set_priority(), and currently we usually don't pass anything to tell the IRS which cpuif is making the call, because mostly the IRS doesn't need to care. There are a few places where it does need to know, notably in gicv5_get_hppi(). Here we have the cpuif pass its IAFFID; the IRS then looks that up by doing a linear search of the cpu_iaffids[] array to get the index of the CPU. For virtualization, many of the stream commands which don't currently need to say which cpuif is making the call will have to start doing so, because changing the state of a virtual interrupt requires the IRS to look up the VPE which is resident on the calling cpuif. This makes the IAFFID->cpuidx lookup seem increasingly awkward. Change gicv5_set_gicv5state() to pass the IRS's CPU index value for the cpuif as well as the guest-visible IAFFID, and make the stream functions identify the cpuif by CPU index rather than IAFFID, to avoid the unnecessary IAFFID->cpuidx lookup. As this is now three GICv5-related things that we are keeping in the CPU state struct, we push them into a sub-struct to keep them tidy. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Gustavo Romero --- hw/intc/arm_gicv5_common.c | 2 +- include/hw/intc/arm_gicv5_stream.h | 6 ++++-- target/arm/cpu.c | 10 ++++++---- target/arm/cpu.h | 10 ++++++---- target/arm/tcg/gicv5-cpuif.c | 6 +++--- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index cc67246686e..cfadfee4f05 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -176,7 +176,7 @@ static void gicv5_common_realize(DeviceState *dev, Erro= r **errp) } =20 for (int i =3D 0; i < cs->num_cpus; i++) { - if (!gicv5_set_gicv5state(cs->cpus[i], cs, cs->cpu_iaffids[i])) { + if (!gicv5_set_gicv5state(cs->cpus[i], cs, cs->cpu_iaffids[i], i))= { error_setg(errp, "CPU %d (IAFFID 0x%x) does not implement GICv5 CPU = interface", i, cs->cpu_iaffids[i]); diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index 3cc9f611557..f45072d8c57 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -20,7 +20,8 @@ typedef struct GICv5Common GICv5Common; * gicv5_set_gicv5state * @cpu: CPU object to tell about its IRS * @cs: the GIC IRS it is connected to - * @iaffid: the IAFFID of this CPU + * @iaffid: the IAFFID of this CPU (guest-visible) + * @cpuidx: the index of this CPU for this IRS (QEMU-internal) * * Set the CPU object's GICv5 pointer to point to this GIC IRS. The * IRS must call this when it is realized, for each CPU it is @@ -29,7 +30,8 @@ typedef struct GICv5Common GICv5Common; * Returns true on success, false if the CPU doesn't implement the * GICv5 CPU interface. */ -bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid); +bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid, + uint32_t cpuidx); =20 /* * The architected Stream Protocol is asynchronous; commands can be diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d9e6d1ad771..4731d1cc7c4 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1215,17 +1215,19 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *= f, int flags) } =20 #ifndef CONFIG_USER_ONLY -bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid) +bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid, + uint32_t cpuidx) { /* * Set this CPU's gicv5state pointer to point to the GIC that we are - * connected to, and record our IAFFID. + * connected to, and record our IAFFID and CPU index. */ if (!cpu_isar_feature(aa64_gcie, cpu)) { return false; } - cpu->env.gicv5state =3D cs; - cpu->env.gicv5_iaffid =3D iaffid; + cpu->env.gicv5.gicv5state =3D cs; + cpu->env.gicv5.iaffid =3D iaffid; + cpu->env.gicv5.cpuidx =3D cpuidx; return true; } #endif diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 06ebed4a8fd..82c13186b68 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -814,10 +814,12 @@ typedef struct CPUArchState { const struct arm_boot_info *boot_info; /* Store GICv3CPUState to access from this struct */ void *gicv3state; - /* Similarly, for a GICv5Common */ - void *gicv5state; - /* For GICv5, this CPU's IAFFID */ - uint64_t gicv5_iaffid; + /* Information the GICv5 IRS passes to us */ + struct { + void *gicv5state; /* GICv5Common struct */ + uint64_t iaffid; /* this CPU's IAFFID */ + uint32_t cpuidx; /* GIC IRS-internal index of this CPU */ + } gicv5; #else /* CONFIG_USER_ONLY */ /* For usermode syscall translation. */ bool eabi; diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 517c780d1f7..eea66a4140e 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -87,7 +87,7 @@ FIELD(ICC_HPPIR_EL1, HPPIV, 32, 1) =20 static GICv5Common *gicv5_get_gic(CPUARMState *env) { - return env->gicv5state; + return env->gicv5.gicv5state; } =20 static GICv5Domain gicv5_logical_domain(CPUARMState *env) @@ -147,7 +147,7 @@ static GICv5PendingIrq gic_hppi(CPUARMState *env, GICv5= Domain domain) return GICV5_PENDING_IRQ_NONE; } =20 - irs_hppi =3D gicv5_get_hppi(gic, domain, env->gicv5_iaffid); + irs_hppi =3D gicv5_get_hppi(gic, domain, env->gicv5.iaffid); =20 /* * If the best PPI and the best interrupt from the IRS have the @@ -788,7 +788,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 5, .access =3D PL1_R, .type =3D ARM_CP_NO_RAW, /* ICC_IAFFIDR_EL1 holds the IAFFID only, in its low bits */ - .fieldoffset =3D offsetof(CPUARMState, gicv5_iaffid), + .fieldoffset =3D offsetof(CPUARMState, gicv5.iaffid), /* * The field is a constant value set in gicv5_set_gicv5state(), * so don't allow it to be overwritten by reset. --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791880868; cv=none; d=zohomail.com; s=zohoarc; b=CdGavPjnSCRYRwXCjnOpzzeXRz0oIKApeEtb3rNTiNPdfl4nw3+peJ9DIW5bPkt7DW7vfWZuh5+kBIZyYqvMLaZMNZ38WcodeasGKWXUFh7bOpk8x/WNefltnroLSG6i7+QlyIRPoDxty+OvutvpdUwffr+iB0MryyAJWRO+Jtc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880868; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=dvGw7sYWTHKozFXf7ViNBZ3cO32w5AjyPGAyekjse54=; b=gTy1v9ck8pFuuwaVB+KLEBiER3FNJRIryDfh2NrhDo6dqYQcSoAYdt9yGE1HDG27DH1H7+pNg07EUAeHHQGeYg1UB+PK/T6T5bpXDHwMaKE0XIvCGI4ijD0pa4pp5XeKhDwSQTm71hVrGU6JNepBY+stASxijo6e9ZYBuLPh0Zc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188086836650.20536121951977; Tue, 13 Oct 2026 01:41:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3V-0007Hf-Oy; Tue, 13 Oct 2026 04:40:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY37-0006rG-9W for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:53 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY35-0007bI-Ly for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:52 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a1635f7c89so26930945e9.2 for ; Tue, 13 Oct 2026 01:39:51 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880790; x=1792485590; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=dvGw7sYWTHKozFXf7ViNBZ3cO32w5AjyPGAyekjse54=; b=TgIlRILGZsXyZ7ASYZ02bsBGpd13VFSYYoUw1LzDygCqy/IJMMLe3wGcw9a1WGsypP IBlqPh4ftbgK1E9M1bRsGcjJO2Fp8L+TOLrjFYJazuXDo/ul+fdloGcgoYvABKhRJISP 40BCzyt0rTMrhpKrAEKjuN2rDGXUjaaRIDjbEEG5oPixa6NGLOAooeM/il3stctv0xKE i7eqApWL+iendoeJnpf5Ew8cc0RDw6Wv0c5+8QhWjIFWfCFQqKhcF78i8Jis850JfJBL uHd3d6wNqrQG0/ZlG3VFwE2S2EgmoTWHbuJ8I7paAIyx6RR/ugjPU/4Lg2DsmMgdRFKB FNag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880790; x=1792485590; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=dvGw7sYWTHKozFXf7ViNBZ3cO32w5AjyPGAyekjse54=; b=o2fTGVqvNFVj+Rgp6m9IY9ElB4MZOx9q7O0V9vu3NcSHoqeHt2/SK/ciblcSeGzBeI ty/0PKsV6I2XvxZhBs3U3ZjI9EddanhgHfvpTCynFpPt9jrjLs987z6ETnayjK759lSK H8eGLVRyY9P9XzUC3ZD/OsUkmrJICaYa0TgUPXdMmx8m30qfdJ2dcU2keuXu/euzV+Qc Vv+t5DdFnIPNDhJrBJ+FOMABmX5mFaTVDwrzYtYWqeqCwV784A1aHwfq2LL0qmHBWu1K rW2aiHIa4G17PSBIYb3ehVfjcrtDI6oXGwUITouiSPtQ4NZ9Cp2VNUlrSPciIQVbocfN pa8A== X-Forwarded-Encrypted: i=1; AKwUvBxKa2QMmq7I7hhQO0YC2AwLGeQ6xicQRx31JMdIbwPYEgDbXRTmEwugI/p+SB2HHIzNcNelR30lz+h1@nongnu.org X-Gm-Message-State: AFq9FYJhCNQHxLVTrkJmRB7gGBGFi6cmBkU88na5Lcfnmc8JlKMgVmBn RdnXkPZpgW4m4uxpPWOeCJYcZIBrfvQH4izODFgC0nqZE1j1je3xcmHMUFhLYmpXd/hyNfaXiHL UB8j8lio= X-Gm-Gg: AYBFou1sAiPVejjKuf/+yJBA3EeCO+mk9lWZXALNu74edcSnheW6++p4jDKzcEiF0R7 5biyUH8Md2Kx10RvyU9/gE3C+MUvZEy0J7U7nnsL+yZL3PpAYR5R6wJdcJJLpRxqckwjSGsNS0l sJ4Nzwvn3/F3567g4ICKK3npXOTpDKFZZ0BGGylykn380uAL7Z8okLYFt2NtA8Dfk+wqjNg1NsS jX1TpHR4APblqI9udBllsG/av+SSDCXA+vqKwaBO1431LvLZDePgHYtXT6Tjulc2bhhA23e0I8y h1dmPC7K8XGOUoW4S5fjJVBkr561/P1Tx+KU9+IYxfE2xQTN7OUmFQWciCIcln2k7rm/b8opnph dm6uOSVsnh8LGV6IQLPx6lVxtff91wTyGyO8XWi1mkXKpHQcz3dDaQTTx4ZaDzjGJ16knNs4KVH wfx69ZWlUMxAaQJcUpyROeg08LwarI7Erw/e9oiEFIPVte6TYy6BCIabaEVjmBc/Ag/wJ4iCSQ1 q8K37i02IQIwFiBr9vp0AybcEtPnQGwufzSC7iKlHDtnp6YA0KHtu1ja07mW/TYutxfKZ9NXrEk 4Hc= X-Received: by 2002:a05:600c:8209:b0:4a0:2375:dc1a with SMTP id 5b1f17b1804b1-4a18e4cb771mr230905295e9.21.1791880790204; Tue, 13 Oct 2026 01:39:50 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 10/86] hw/intc/arm_gicv5: Pass cpuidx rather than iaffid in gicv5_get_hppi() Date: Tue, 13 Oct 2026 09:38:17 +0100 Message-ID: <20261013083933.1024405-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880869198158500 Now the CPU interface knows its own cpuidx, we can pass that to gicv5_get_hppi() and avoid the IAFFID->cpuidx lookup in the IRS. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 5 ++--- include/hw/intc/arm_gicv5_stream.h | 4 ++-- target/arm/tcg/gicv5-cpuif.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index ecafb4838ab..fd6456cd8aa 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -531,12 +531,11 @@ static void irs_recall_hppis(GICv5 *s, GICv5Domain do= main) } =20 GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5Domain domain, - uint32_t iaffid) + uint32_t cpuidx) { GICv5 *s =3D ARM_GICV5(cs); - int cpuidx =3D irs_cpuidx_from_iaffid(cs, iaffid); =20 - assert(cpuidx >=3D 0); + assert(cpuidx < cs->num_cpus); return s->hppi[domain][cpuidx]; } =20 diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index f45072d8c57..641f3d0f499 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -204,14 +204,14 @@ void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain= domain); * gicv5_get_hppi * @cs: GIC IRS to query * @domain: interrupt domain to act on - * @iaffid: IAFFID of this CPU interface + * @cpuidx: IRS CPU index of this CPU interface * * Ask the IRS for the highest priority pending interrupt that it has * for this CPU. This returns the equivalent of what in the stream * protocol is the outstanding interrupt sent with a Forward packet. */ GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5Domain domain, - uint32_t iaffid); + uint32_t cpuidx); =20 /** * gicv5_deactivate diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index eea66a4140e..0b1033c1ef0 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -147,7 +147,7 @@ static GICv5PendingIrq gic_hppi(CPUARMState *env, GICv5= Domain domain) return GICV5_PENDING_IRQ_NONE; } =20 - irs_hppi =3D gicv5_get_hppi(gic, domain, env->gicv5.iaffid); + irs_hppi =3D gicv5_get_hppi(gic, domain, env->gicv5.cpuidx); =20 /* * If the best PPI and the best interrupt from the IRS have the --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791881195; cv=none; d=zohomail.com; s=zohoarc; b=VCr4pu75fb/DT9REOi0JnF1f3qy7Lb6ZpMsGRt2q+QGtGNj/RutWZm7/CaFVncYWVrKUSfL6AyeZLuHrVlvGeH7kzt/WhebryRBocIxz+dS0gBMMijwoUiwL+pbKnBCYXf9DxBEsjMWJizAwf066DBzKutF/zXAaZGEmfWKgP1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881195; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=hqqeZR9hh82Ok/85fIviXaUdYKynKCQ8FaCgEa2tPAY=; b=H+Ihe0qfUvpD9nSTjVSxRt5CBSV0vAkTkh3P9g245/RUuBto1/xdiG4diQ9WgLl+8b7wKj2DUAo2e+ytdcf9/u+YC0r9sm8yaftXSfLC6ZwGUA47yuDembVZFyKDVA8MX7DZ6YS2lYz6CC6UbdK39G7kJey8W/FIL62/7UDonzA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188119542622.946640863046127; Tue, 13 Oct 2026 01:46:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3a-0007S7-8b; Tue, 13 Oct 2026 04:40:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3I-0006yF-Qx for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:09 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY36-0007bd-On for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:39:54 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a161d9b8c7so18410715e9.3 for ; Tue, 13 Oct 2026 01:39:52 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880791; x=1792485591; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=hqqeZR9hh82Ok/85fIviXaUdYKynKCQ8FaCgEa2tPAY=; b=hfEgI4i84v2Q8MTSOgTZOxJ1qYYyZyulrQ0fL/fdQFbo0U8aPMsvT4QE8mzZeHju48 sOJCKoQBqTWBKzX5JqTDzY4lfNIynUKcabN7NL0MoqCCWv4AWANdsfmSshQnzvpy+MiW r7lJE/L/XoabVobDI780VDsIdvWRNAfahfcA45wFJHz3lsIZPwaf7+LPFf2L+XCqefZE 5OyaLXDpa3IzWhU4/2DlEk04tSXrCvKNQ32CuBAQBEMxNDd5fEfBTkQo2akvYpdiNODo syBSTkSBTGaLMuqt35Xxd2gtrPiJvAQr4kyf3NIEI1fcSbaeEwtsjc+NMQ/9QXLYS/pk 2GCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880791; x=1792485591; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=hqqeZR9hh82Ok/85fIviXaUdYKynKCQ8FaCgEa2tPAY=; b=1NbPZuUylkKlwXn3xlEUX3F+jkEFa7OAw5QaHL3XK0y3F8+X215Cp4gZgW+TKpoZm8 IDKGmc+JcioKFb+OZsmaASucbbw3kSxnYh4Qa7PNcW3N36cTwuDXNMz7bXCyA1LKEvsf 0In43KycIyCu+U5/ILP83U0uhRx/m/1kRrL8a/ZOue6sGkITuevQnXNp+0EgRe+MDnMt iG101AIUtNqx82EAdB8IbTODY60dX0+kK6+sNGuRKBh6BqMgbX6AzrqCjv2rXImRiPSV +0nHY5LP0gZ/9RchbwAdd9CFLwIlN18Xf7ksrStTT1z0UhXj+79cXJzhX3rqDzR+lpYS 2MHw== X-Forwarded-Encrypted: i=1; AKwUvBzWuXljO+uPDHE/TN4uT+n+YJ5sEzX6u35Lo6suwBk9U6S/37cjCf/1aZolCb2hA45Fm70vZd54cFIC@nongnu.org X-Gm-Message-State: AFq9FYJB30dGMtLdh8vuEkaycQ+8IsoMZb4rFQqfINkjqCUqcO0Ml3nf x7Q6O2Fjfkqa9SZnf1CznlxNoXjKnh6kxe3nMU6nc7a4qWK6DyslSvPBYAgI7Uo+abE= X-Gm-Gg: AYBFou0anDV6hnjrDmPMATvqwQ47/S64dBZgmAY5zxvnxVYQmo4akg5r5V1tcT5ZTYX uLVnuKaRXz8h2ubk+vs9OdmsmABPAUzDmalI3cdF6JGdPn17l2ZjEdNjd/uhw8sVg6antLZz6Ld 8zB8UVZH3Ag295KqqqVHJKXDV7JILa8yZvnLefzy34b/JcbOzEHiwkvoGb4eYIk3paXt3zH+Fbx M4iiRn5ddZVNI/7iOSbm8Lsh+hbDeW3qkSUsnDhBP3odB3wc8fsfzZ8coPlmqhhU4bv4nAyqPqu CZXfKdZtRNolJXkBAW61BcVSP5ugZDk9KMSzigJgmVYeVGPoRv+TBcakrWSjwnea3614ZkCp6cK jA3PTfxyKxO6Bdo8HFfhbR3ek9Gx0vh7sdzct/lY93Gf8sZctzEPaMiYhxGL7uEXE6kpapVkSBa 5RnV3Gl/NBVBpXFlY42xUd934r4S/axp1xnuotMM/GxHItPfl7xzWS2cb91IhytoXLMjPihrdXi k+aaauZe6QQ/wC12p7xw1LE/vAb6x2aDq8rFXwlc5RTpzVI+cTPpRQtTEWAN9sKUxpbGIFXEoKh sjXT X-Received: by 2002:a05:600c:6388:b0:4a1:ac66:5ffe with SMTP id 5b1f17b1804b1-4a1ac666396mr23882515e9.15.1791880791184; Tue, 13 Oct 2026 01:39:51 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 11/86] hw/intc/arm_gicv5: Use correct type for value in lpi_cache_get_hppi() Date: Tue, 13 Oct 2026 09:38:18 +0100 Message-ID: <20261013083933.1024405-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881197247158500 Content-Type: text/plain; charset="utf-8" lpi_cache_get_hppi() is a function we pass to g_hash_table_foreach() to iterate over the LPI cache hashtable. This hash table has keys which are GINT_TO_POINTER(intid) and values which hold the L2 ISTE value, allocated as "hashvalue =3D g_new(uint32_t, 1)". The function is passed the key and value as type 'gpointer' and has to cast them to the real types itself, but it incorrectly casts the value pointer to a uint64_t*. This works on little-endian hosts (since we only read specific fields of the L2 ISTE using bitmasking), but won't work on big-endian, and trips the clang sanitizer. Fix the pointer type. Cc: qemu-stable@nongnu.org Fixes: a0562ada75e ("hw/intc/arm_gicv5: Calculate HPPI in the IRS") Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index fd6456cd8aa..a362349e5ed 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -390,7 +390,7 @@ typedef struct GetHPPIUserData { static void lpi_cache_get_hppi(gpointer key, gpointer value, gpointer user= _data) { uint64_t id =3D GPOINTER_TO_INT(key); - uint64_t l2_iste =3D *(uint64_t *)value; + uint64_t l2_iste =3D *(uint32_t *)value; uint32_t prio, iaffid; GetHPPIUserData *ud =3D user_data; =20 --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791881561; cv=none; d=zohomail.com; s=zohoarc; b=KdkSCqUj5WV3piSXqx/vhkOIUVechzAHL5LW7LLib1z4+ul1aqsQdBRMZTocTIDoERay1bgdnnK7DXVEXjzNYp02EzZe3NQpEhuDZIYsUIOAyFhCBB4N14TnsZhCRQR7MMWNsKHjFKMYcciFNw1WNtxEwUimkFD+wmELHHUSg54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881561; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=UViGHcknrDhUYElC9wgz9XVN/w6c0++pkoJaAEN1syM=; b=X4U96DKCezA14tvr85ZgASXWYGdHOc8pHI+SCOPLfZH9Jtsa+dp6fqkWCNIR15Kr6YXlX7hDoqmIBdNHUC65jGI4c8P4GVLaw52fSkhIE6yyFs3klYAnt9+IA91/HUOM8eKqZFiJpS30NbnGlIUHxvzxYeCaINZRULLVH9KcN9g= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881561759419.6597625728747; Tue, 13 Oct 2026 01:52:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3c-0007VS-Dp; Tue, 13 Oct 2026 04:40:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3K-0006yl-NY for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:12 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3D-0007bn-NM for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:05 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4a1880e1bf1so24723185e9.1 for ; Tue, 13 Oct 2026 01:39:53 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880792; x=1792485592; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=UViGHcknrDhUYElC9wgz9XVN/w6c0++pkoJaAEN1syM=; b=GlGX8WyUZLOKbjKxltbHUCmR1yyx2myOzaF/2wgOIZplRM7kcGv9gud1A+ZKKAgIJ3 zY6VvkdVG5DW0ETewJDu7FxLAdZpYUqsK8lHE/NAK7HplN4BvPMsKFgMF8kJkieQV9Bo ZpaNe0XQns9TYUcwRpx7zCnZj/ZA7HSeupth86XmcohhhUYV91sdgawQ/utW6TX/Dx3n uUAGufd5LZc1h1TiTO0z9svuw3AjzuACX6BYimYhA06jT1qTRDP0UK9c83BlY0u/13OT Hxf+miaZ+H6G2UR5QfghCzvVGlOqLzHH6jN1wRlROPtM0UQYCxDxxD+JCQjg0CTrwWkm khQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880792; x=1792485592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=UViGHcknrDhUYElC9wgz9XVN/w6c0++pkoJaAEN1syM=; b=X8j1RJWBKgEIyXwgXHf0Tc1oMvp2VW5sEZqw+XjyyvGL6FQKX1xG0Ze89iyfovhPDS 9cp/qEVRy+9J7rkxrV9DNMIFfEE/qy63KwnkzXP6b815V2TxFQJt3UpJwkBoqjB1Ob+W W8P4EEdH1mSX6AlMNByoiHxOmMHqN9nYDh+ynZw6DATrFcCzVHyvC1SdhllAsOjgxSNj +zjdi+d1eN2AnbwZ7eP9YdSP9a5XJDWrQpPkLv9UZRZ9rrrXO+NPLmBmg3ZfRs1+TnoS 71LBsLl1sIhBNCfOzwNBKjZNJz3bRrgc/SxbuWcpEEO5ui4nhZTfnCALSOuN+9eolwje ZaLw== X-Forwarded-Encrypted: i=1; AKwUvBzPWGYahGsLTKYP0nZCWTDRa2g7vThJa7JnZU056o2aoQK9s9zxjLa4pAW6Wth78wA2s79mVF78OZGg@nongnu.org X-Gm-Message-State: AFq9FYJRAucKQqSpJKJferb6mcW90fkDPr1grcMylxMkmHeUMjUqVOLd wyKJYvm9EwdgAsqAKQOU2pNeYQSm+J2dqvbRKJ4iTleWYjS5sT3/1bov7pCK/JVGmJGy4AaeOev 1Zvpm+3U= X-Gm-Gg: AYBFou2/5SrBfd+Izc0b26bLlrOk6C3u04k7F12WAlCSb/rwiABp3SA/mbS0rkZqWim axHi4M+bXl3335o3gcs/WBdUko0LOMgja5O0ZQqnu/ApozFWcUs8SBmgnWTxkpTnOFCmm7JSwKR ZeqWa90r4zalhH0b42sAKZWL7TJwAtHTX+IJZchfCensc4XKH7Fjz+LyKE6krXQbCTcDcxKhmFM CpsyN7/J0x49p+/OmOBhwEwV+HoDa2Qy4/l4D/Nk+2b012eDO0tagTNJaJBm0fgGHD0K4Z4G/MN p3HDGHXyH4jsW+89JRCjmYJk4/kz2OemYwr6CKYwWRkY7ImEqNJwX2E3JH2lHWP812lb2gmxPag QsSKf21xxGeIizQI3N4v2mZ7ZO0dqzgpOE7LYnyjQi4b+3hzKCBcbBTViPFMe+0VCwFxbbo1hBq r7muidB9Gdi4WVaZTmpnC3oaj2wuB9EBP1WsDo+TLPUeaMp9jcmrOuTo00CCge4cBV0HEFvidi+ gXnWJ1iB/UTo2BUbJyM2zI7aa3M7Gv+f8cGuT7BuujTkuHPETQrkoyja+ou7UB0N8rR35i6UL3j 6VE= X-Received: by 2002:a05:600c:e549:20b0:4a1:9438:719e with SMTP id 5b1f17b1804b1-4a1943872ecmr113069885e9.9.1791880792088; Tue, 13 Oct 2026 01:39:52 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 12/86] hw/intc/arm_gicv5: Relax QEMU_GICV5_MIN_LPI_ID_BITS to 0 Date: Tue, 13 Oct 2026 09:38:19 +0100 Message-ID: <20261013083933.1024405-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881564290158500 Content-Type: text/plain; charset="utf-8" The GICv5 specification allows implementations to declare a MIN_LPI_ID_BITS value in IST_IDR2, which specifies the minimum number of supported LPIs which can be configured (both for physical LPIs and for virtual LPIs in VMs). It also notes (I_ZKLJR) that it doesn't expect most hardware implementations to require a minimum numberof LPI ID bits, and that this is mostly useful for the virtual IRS that a hypervisor might expose to a guest. QEMU generally prefers to offer the guest the highest-flexibility setting when it comes to this kind of IMPDEF value, so for instance we set our supported ID and IAFFID bit size to the maximum the spec permits. Since this value is a minimum rather than a maximum, "highest-flexibility" means allowing the guest to configure a very small LPI range if it wants to. Our current setting of 14 for QEMU_GICV5_MIN_LPI_ID_BITS is the least-flexible the architecture permits and requires that guests always configure large LPI ranges. Set QEMU_GICV5_MIN_LPI_ID_BITS to 0, as the spec suggests real hardware would. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Gustavo Romero --- include/hw/intc/arm_gicv5_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 59ac1c3880c..a47f639e84c 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -146,7 +146,7 @@ struct GICv5CommonClass { /* Number of INTID.ID bits we support */ #define QEMU_GICV5_ID_BITS 24 /* Min LPI_ID_BITS supported */ -#define QEMU_GICV5_MIN_LPI_ID_BITS 14 +#define QEMU_GICV5_MIN_LPI_ID_BITS 0 /* IAFFID bits supported */ #define QEMU_GICV5_IAFFID_BITS 16 /* Number of priority bits supported in the IRS */ --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791881283; cv=none; d=zohomail.com; s=zohoarc; b=F1s10euwRca3PSnBqo2kECbboUsOB3nsZExsiWjNfJrgAdaqXSnG06PM2FraUW/dtJFl5UoAChDvkbiC37OYJxJKCi/2hsS6g5+Bh7Eswtxc5mznceLIe95nsuCXD4khMtc07hXmFJSlczLtWw95S2HXhGcFcm2zds5xc1FHImA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881283; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=qpgEaqwbI8cXhwzqqc5V6TxLN3Im1mcvPlwe4PGvMA8=; b=HcxZ0c6++TswYrsDan6AK81wxgkzct5IBs1m2ci02Bxm9KJcopRjTxPPnpjlFEfFfiqKZzTZTeovBUwllkL9PpuPyTiGFAqWtOxi4Xzw5Jr7FJPAwBz0NTK+VH4eUx4VG+O0C5oXCfHRWJbhe5J/Z41kLlRub9B2Mmf89fRbwYI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881283369874.0193649219757; Tue, 13 Oct 2026 01:48:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3e-0007aP-A6; Tue, 13 Oct 2026 04:40:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3P-00071j-VZ for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:14 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3K-0007cL-Fs for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:10 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4956869750eso20242305e9.2 for ; Tue, 13 Oct 2026 01:39:54 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880793; x=1792485593; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=qpgEaqwbI8cXhwzqqc5V6TxLN3Im1mcvPlwe4PGvMA8=; b=Mut4tNWg+ihZb04jsCn9gVV87CGjj81ZKQtFhZrBQcCPAVUOidAM3xfzySAB1nwHUC RBHO0daEUeB0aWlR2yxXv1I/Ra2R305/HY1njSTarJBG9s+9uCHtPttXKpeCrO9Wv9nQ dzmYRiRPmuvY16FQWv4bSc/CwUG19smi0JxkiXENFiyDEOtNIRpsW5w36djKRwlirW2b DHeLD5WrQaxhbleco/8boDazsv9zeXMy9+oTbpeuR1X96RVi+tjHyHV53HNyy8p8608D 49UZY+t+01y0nX2XQh4CamLznWGQtq1GUqa3OtORpIilIMvX57Vum8H97IVDEQbJOzCd JAMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880793; x=1792485593; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=qpgEaqwbI8cXhwzqqc5V6TxLN3Im1mcvPlwe4PGvMA8=; b=CRtKWbmDzObHny4mQkneENniwuwvs0eXvRppJY3lNQlQmIJXTJI56CL8u2skreiedP gOw1xx/VCdBxyyP/n5SapAWdvToRGLoPoGxUXGTkVZQ7UXCeGJep+VDZLX+XzISU9JRQ uGu+xgG6M6hS8Mipwt2j46dS0VkRk9epnPQsJbwos3VibXv0pL3a896ID0KNJVKTs6P+ 0qgfrhXKDbDNUHGiD2eGObjNxDFm5wPr93Xram9Qqa7ArJxC3ljR6pmZfFrMkh25gQF+ zK8MJmVMdb1/lr5YCwNcfesYKz1gSoNgr+cQ1Uv/ll0bL1etb5MxPMJEYBAtscN6wyVN +0CA== X-Forwarded-Encrypted: i=1; AKwUvBwgA82xbGUYUikoxyHk/6NrOFY3hlmjxY5LkXeCsVQHELa8YTPbqSgJm5P2t1bAGVuC8nGWS+6t5cH6@nongnu.org X-Gm-Message-State: AFq9FYIT24vvNPOg8wQqeZNV/Nckhjr+yhNq0smiKeEbyllf+W7yhRyT Npx3YQIDZO/LVwoO54EB5gJrXEjqMjm75appI501TZUn6AkYI6PptxcNxGWJDpb/YdppopRNdVl xrfnrHas= X-Gm-Gg: AYBFou0hrVZZjhstycDPK1doSvyFxiBHIbaCIb4DtCV4FQQbydA4CkCxgE7kzyX5bXk cd7FYuKPlgc6cwPZ8BFzOCwSnG9pwcB8y5/AORVqdhah4akqryocjxZZ8MjZNMji3p1iOUKYc5P pSG4Q0caZK+dyC9XCRp73BWWQHTT5p07X/cRkRAZ5zkPfP33ssrPm3t/mr7p4WrIDZl6RogZA6a WGwExrVEsWLf2cLq5BtiK3OBn5C6j3OvleYcFS70utLAPWiApSg54DhmzV/PDu7rXnOq5qc6THJ h9+rnISn9+Z90si5cBfkrJE8+AdUhLysPIAIrutvBULsWGpw+ebcKa+XjZ1AjGJ/vsnuWjdYJpr YBMVoEz7sebXxM3GktQDQO2WYWl7tBpHKc6b+hm0ZUMqjUVMzfCXuorTpx6XXzU8loGG8rQe3gI jyQXQqSzkp5in8CTubVizNR5/YZ7Ro0ZP2ETBEF3DQEpBhKUUmQX2BurpsYPQBBPeVKV5isv7+J KaTzgE0jyMbNkjFrYp1TEHLgYRv8nGAaus6PeL2dfqqTSbXhe53NqefMzwmXIECUwvKtFez5F6a HcXjCTJtC4PNCQ== X-Received: by 2002:a05:600c:3b1a:b0:49c:fa20:cbfd with SMTP id 5b1f17b1804b1-4a18e4b91f8mr200321455e9.20.1791880793162; Tue, 13 Oct 2026 01:39:53 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 13/86] target/arm: GICv5 cpuif: Implement ICH_APR_EL2 Date: Tue, 13 Oct 2026 09:38:20 +0100 Message-ID: <20261013083933.1024405-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881284938158500 Content-Type: text/plain; charset="utf-8" Implement the ICH_APR_EL2 register. This is part of the hypervisor control register interface, and is the hypervisor-facing access to the state which holds the guest's its active priority register. The only slightly non-straightforward part of this is that because the GICv5 allows a hypervisor to give its guest a GICv3-compatible virtual CPU interface, this register has to UNDEF to the inner guest when legacy-vcpu operation is enabled. We don't implement GCIE_LEGACY in QEMU yet, but since we expect to do so in future, the handling for this is implemented here. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpu.h | 2 ++ target/arm/tcg/gicv5-cpuif.c | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 82c13186b68..a93fd362417 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -594,6 +594,8 @@ typedef struct CPUArchState { =20 /* Cached highest-priority pending PPI for each domain */ GICv5PendingIrq ppi_hppi[NUM_GICV5_DOMAINS]; + + uint64_t ich_apr_el2; } gicv5_cpuif; =20 struct { diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 0b1033c1ef0..83c9be2b0e6 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -90,6 +90,15 @@ static GICv5Common *gicv5_get_gic(CPUARMState *env) return env->gicv5.gicv5state; } =20 +/* + * Return true if GIC virtual interface legacy operation is enabled. + * We don't currently implement FEAT_GCIE_LEGACY. + */ +static bool gicv5_legacy_enabled(CPUARMState *env) +{ + return false; +} + static GICv5Domain gicv5_logical_domain(CPUARMState *env) { /* @@ -696,6 +705,34 @@ static void gic_cddi_write(CPUARMState *env, const ARM= CPRegInfo *ri, } } =20 +static CPAccessResult access_gicv5_ich_reg(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + /* + * accessfn for GICv5 ICH regs. The NV behaviour here is a little + * different from usual because of the optional legacy GIC feature. + * + * At EL1, if GCIE_LEGACY is disabled or not implemented, these + * behave like normal EL2 registers, which is that they redirect + * to memory if NV2 is enabled and trap to EL2 if not. If legacy + * operation is enabled, these registers must UNDEF to EL1 + * (because from the inner guest's point of view it has a GICv3 + * and this sysreg doesn't exist). + * + * The UNDEF at EL1 when NV=3D=3D0 is handled already because of the + * .access =3D PL2_RW setting on the cpreg. + */ + if (arm_current_el(env) =3D=3D 1 && gicv5_legacy_enabled(env)) { + return CP_ACCESS_UNDEFINED; + } + /* + * continue to either redirect-to-memory, trap-to-EL2 or (if + * current EL is 2 or 3) access the register + */ + return CP_ACCESS_OK; +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -893,6 +930,13 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .writefn =3D gic_icc_pcr_el1_write, .resetfn =3D gic_icc_pcr_el1_reset, }, + { .name =3D "ICH_APR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 8, .opc2 =3D 4, + .access =3D PL2_RW, .type =3D ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb00, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_apr_el2), + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881116352649.5748335303609; Tue, 13 Oct 2026 01:45:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3h-0007gK-05; Tue, 13 Oct 2026 04:40:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3P-00071n-VI for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:14 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3L-0007cb-HS for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:11 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4a02718da81so20751455e9.1 for ; Tue, 13 Oct 2026 01:39:56 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880796; x=1792485596; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=3izCqRV5UcshDEmb0rQN8l/m/Afo4OAdHcc2f4wlql4=; b=qwcM9ef2YTUd8KrkTfwWErxRnWdnxTic+1Mi18/bOOE06GJH6R6l7z76IoozbRN0H7 qgNQrXJGHahrzRADEgzdeM5b9F8qTIbPx8+YrLNyi0aTcmvwgARAEO3AS/phESvJqsEc N7folfpUTLNSQ8kIkO5HVFjwacKrEVBH+Ansqz/xeGZOkiRcX7OVF0Yu2W+byiniTdYM F1H70Nz+MfF+I3Yo9XRfj2DL014xhzu41u+8/EqdVIu5lRD9Ex3AIVyiK21HYgxwuTC1 HaVvTs/uIl6tM1Z48UFgPzu9rjfclFvQv4HVbTDJRzDj10LpN2IWky8sZvjXFHwjmPNa fdhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880796; x=1792485596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=3izCqRV5UcshDEmb0rQN8l/m/Afo4OAdHcc2f4wlql4=; b=nJxNTwvDLuLELYPQF+o94Hmnndr00RZlHqLtDGmTANFUdtXqRfenT+Anl3Igvbm7Dg /29s5xrQ3YnBA9QZzzP1GV+PRsGWGH2OXVES9g3dsyvM/uqV373qYhCxPObKkVb3DV5V Q0AHhJjBXmcHS7xrCMBNRWD8bjn4HMOGji/fnqiVo6x4OIE2TDbM+rswaKkq+QfhoV8U U5xLcUffBH6t3u2+p0wC//sfwGgj1yLSEuoxkbI+TpQTYxGPq97DDyVmYZIPiN6JMbbF gbqEk/KKmb6AMgIB+cM27WGa0JMLDXBHiIxDs+DkpbjEL23b4tAJ6omFYtavPIf8gQDc IeaA== X-Forwarded-Encrypted: i=1; AKwUvBy77tqZDciEi3Y2gT7m6h0Gdg99Oew1KVKSKWk0PK3xFeBJytgW2R74w3My8HmbpTa0HPmmdmQjyJr7@nongnu.org X-Gm-Message-State: AFq9FYL+O40jG/DALoqAVr5NoinzutNmSvTQtlYWe9uSa/UtYwfcQnm+ PEK4tOBvmX/gHi5MnmLfhnon48Rptv+Pd0eUoILbc3paG4SwnlP0QEAkMjkjRAVz70DALlBQCrs QK7ZatQ0= X-Gm-Gg: AYBFou19XABfCqRVTSDXKmMUseNV0Sgy4RkSBAXtdrA0AsVoqYp5bUNkB6D4gV8bTra KNIIA3G2QV5kucVgVpgOFypXTzC3JifG7bcY9PizGttG9ngxW+5Vz9lSKmAoyCBG2ckpf1eqvCX +VSjNOmOrMHDVGJsR8YVrmEOjDEjJfL6JVI9Gsm+8t+2is2hdqFvKN7qLFZ1AQp6sN916vfSxWh njkxE3PJ5UV08XSYv3CNyjWp8q2/lWB2X0rRwBJlXihM4wS1PkRzxBiJ6tj6STP2hhFuSb4Lpj1 88lEtEfvsZQHIpRoiCk1oWuKDcdP2S1lvPKrfdt14DpEBGU2mZkp05N9acXJou8adpqVBIkHkQW saxerVcmOZdb6f+Ny/y0t9LaCiyT18H3uVLtBiKOD32rMorHdPW0EmHEOZLlLCSaGb2l/uWWjY2 Q66l3Dj24ZGwf6o6TbZKFJ06uvPPS093RiGr2KWhEUxrxLe0x//cHPNi/m+GMCkWBUXX/hcgJmb M3NpIUzw9kyYkQXy+lB9UfJE0SCHsgKVnfwb9I0Ta8sYCc1NcfZsLuNFf2i5dAmhBT+5o+5nyiE nzU= X-Received: by 2002:a05:600c:1909:b0:4a0:159b:d283 with SMTP id 5b1f17b1804b1-4a18e4d5412mr260780845e9.30.1791880794376; Tue, 13 Oct 2026 01:39:54 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 14/86] target/arm: GICv5 cpuif: Implement ICH_PPI_{ENABLE, PEND, ACTIVE} regs Date: Tue, 13 Oct 2026 09:38:21 +0100 Message-ID: <20261013083933.1024405-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1791881117848158500 Content-Type: text/plain; charset="utf-8" Implement the ICH_PPI_ENABLERn_EL2, ICH_PPI_PENDRn_EL2 and ICH_PPI_ACTIVERn_EL2 registers. These are the hypervisor interface to the underlying state of its guest's PPI interrupts. Unlike the ICC PPI registers, these don't have set and clear register pairs. We mark these as ARM_CP_IO and give them a writefn, even though right now the only thing the writefn does is a raw_write to the underlying CPU struct field, because eventually hypervisor writes to these registers will need to trigger recalculation of the highest priority pending PPI and possible signalling of VIRQ. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpu.h | 3 ++ target/arm/tcg/gicv5-cpuif.c | 64 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a93fd362417..62262c594d7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -596,6 +596,9 @@ typedef struct CPUArchState { GICv5PendingIrq ppi_hppi[NUM_GICV5_DOMAINS]; =20 uint64_t ich_apr_el2; + uint64_t ich_ppi_active[GICV5_NUM_PPIS / 64]; + uint64_t ich_ppi_pend[GICV5_NUM_PPIS / 64]; + uint64_t ich_ppi_enable[GICV5_NUM_PPIS / 64]; } gicv5_cpuif; =20 struct { diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 83c9be2b0e6..6dec0ec1ea6 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -463,6 +463,24 @@ static void gic_ppi_priority_write(CPUARMState *env, c= onst ARMCPRegInfo *ri, gic_recalc_ppi_hppi(env); } =20 +static void gic_ich_ppi_enable_write(CPUARMState *env, const ARMCPRegInfo = *ri, + uint64_t value) +{ + raw_write(env, ri, value); +} + +static void gic_ich_ppi_pend_write(CPUARMState *env, const ARMCPRegInfo *r= i, + uint64_t value) +{ + raw_write(env, ri, value); +} + +static void gic_ich_ppi_active_write(CPUARMState *env, const ARMCPRegInfo = *ri, + uint64_t value) +{ + raw_write(env, ri, value); +} + /* * ICC_APR_EL1 is banked and reads/writes as the version for the * current logical interrupt domain. @@ -937,6 +955,52 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .accessfn =3D access_gicv5_ich_reg, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_apr_el2), }, + { .name =3D "ICH_PPI_ENABLER0_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 10, .opc2 =3D 2, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb50, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_enable[= 0]), + .writefn =3D gic_ich_ppi_enable_write, + }, + { .name =3D "ICH_PPI_ENABLER1_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 10, .opc2 =3D 3, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb58, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_enable[= 1]), + .writefn =3D gic_ich_ppi_enable_write, + }, + { .name =3D "ICH_PPI_PENDR0_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 10, .opc2 =3D 4, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_pend[0]= ), + .writefn =3D gic_ich_ppi_pend_write, + }, + { .name =3D "ICH_PPI_PENDR1_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 10, .opc2 =3D 5, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_pend[1]= ), + .writefn =3D gic_ich_ppi_pend_write, + }, + { .name =3D "ICH_PPI_ACTIVER0_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 10, .opc2 =3D 6, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb30, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_active[= 0]), + .writefn =3D gic_ich_ppi_active_write, + }, + { .name =3D "ICH_PPI_ACTIVER1_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 10, .opc2 =3D 7, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb38, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_active[= 1]), + .writefn =3D gic_ich_ppi_active_write, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791881634; cv=none; d=zohomail.com; s=zohoarc; b=AR+0h4QE8AJvqqL/i8iNbXrmiHIQ9laJxGRaaa99eDteTafSU2TpTdPZ8G4uQHWjWxFUD5bUrhn5gasCV8uFADaadVBoYdcFLpRst9Oqu2iigX7rxi5LHs5jyCxXsGDORkoGRYFmMGA3TKHPD/0MpvgEquTSFwfpqrVM6NxEJ0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881634; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=egeU1Fljgl1j52jTMJ1XUl/uSLAULc4z+LFi4aErDLw=; b=RZ/uIhthPDB5dpeOJXUiVRHhjHQuZ1MBA1Aeiw/fRWFEX/ESOq5NUgMptfdiXfAxrjAHTG5akS22Ubqc7x9KVzJmsRNtDmxFavE8M/X7HAvGZyH7NlrghtMspotJ2aVYVPkbrOaqC8lgVcFnTf1eezDUTHFNGDA3Qce6Rhq7Z/8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881634336688.0325896017114; Tue, 13 Oct 2026 01:53:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3n-0007zF-1K; Tue, 13 Oct 2026 04:40:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3M-00070M-R3 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:13 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3I-0007cY-K7 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:07 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4998b5a63e2so26703345e9.1 for ; Tue, 13 Oct 2026 01:39:56 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880795; x=1792485595; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=egeU1Fljgl1j52jTMJ1XUl/uSLAULc4z+LFi4aErDLw=; b=iCkh7xPHpLVZrFw3JtHI8FU0aCNyMo6M/KjxmRX5TxS7HN7GcHiv9s/C+oq/fuoZqd ow1RI4/IyQZmd4w/cMTnG4wJt8txLE2W1uarayRF9nb0rVcWd/iGabdGbwnIgNV6b26V ATxo2Erx2m9L2F8Kdja4+a7a4XAyellSF3bxYHg1Pfk5B+gNuA7drMZIWTeY+Vo4Trk4 EhMkixa1Ig0lwCVoDNZoTjoe9czCgg8orCMwju7ZMbBvUxJnyzUnsb6OEQLn1O4XjuGU H94Pp6zf7Dsm/LMmuDHEJHSKkxbxA/f3tO7RZbq0hSA29qxJkn292KqEP9jhI/HvV/f4 7zaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880795; x=1792485595; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=egeU1Fljgl1j52jTMJ1XUl/uSLAULc4z+LFi4aErDLw=; b=nvGAMQZLN8SkPs0SdhxPMUdLUQZOdjoD//p5qr1IZnFLgFMTQsPyb27YOHMLVBYZ3k yqTwp4dGvQjUNxFsfURCPD15NV5bZ82o1BQTjnwAEO16SiNQckZfT0EzpmQ7c64HuNot SFA4EMwiGBWmky/Pdy8q0hXUJrg9suRqw+UKK9b/jEAyMqlosLPjfoa65bxJbOMsG8zm CFRKKEiF6fBfFwUh+g5ZEk0P7k4EhTPfacg4KpN9J2DGbahpkmyxqK2nQ96rS44aSuEm HFAs67tsTh8vXH3py3JGnmJIOgIJ+t3f0AX7j3lM4cP6Xbpmq4cL4A1DeqZ/NrYVl3Ef smcw== X-Forwarded-Encrypted: i=1; AKwUvBxLNZIH1S0Haeq5oROIc+Mf8FJlBblmKwPxEd9Ph05qO3r2uAyS2QzS9LS59Eyb5bswyXmf/7zpq7mM@nongnu.org X-Gm-Message-State: AFq9FYKXyYsVXcmzxKYZRmsM6BhldTNSX77BkQV8BOUcxGzxTdzIP22W 6zvonZYBUI31GkCzo/pKM8GXVUUgTLRs72rJu67tYrs02q+TdVbwzhV6Zt+9sf26L6Ax1mTpjh+ YxRv8gNc= X-Gm-Gg: AYBFou3UABUStFK2XhWMrypQMKvYguz/DKMfUdt35F4VgNC4JpoyC1rT8GgAEXJCDax si0sunPTMzYYmi3Dhyl3oFeXd232eWIGf92jGGLR++9e9G5pW5XvZm9k9g7X9sikb5MPpnHNWyG VwcSru0BbwIduTzEZKGyPT7cBPfQvJ+F/ow4yw/VhUeM8BHrwD9qLX83iUu4iR314dxZ7Ja2xEj WzDx5SaXvqtccXKWPDVuu21OGFVizDvdA0MiivMZXihpYl1fXSBok04HK85LyfOy123VqiZOUNV c0kgGN5PNYUFjXYqdLxPqePP1VLdfMknaqNCg36BrCEQWzwVmPZ47zEbTCuzkM+5T21fBp8spH7 xk5M3Aq4MAY6mG3pE51dCA/P2OKKbOaXqF92Yg7pZ5JWA2vEwEFgB/4wWgN/WG5rR2mdSTsKYYY SYUcLajhL7YPsq+vDiQ6V2t/KSc04u2Ja+6HSuyAq7X03o3m09KkMmvO/CblQIVyFZb4J2FXxfq uMZ0BGEbJfCAJpy2TMHshIQs3Cvu8Pf3esc0hbBuyBaGPwfGL4yQgOXKkwXRn8LlxdeYise9IVV Ev4= X-Received: by 2002:a05:600c:19cf:b0:4a0:168f:d962 with SMTP id 5b1f17b1804b1-4a18e44363dmr226192455e9.3.1791880795278; Tue, 13 Oct 2026 01:39:55 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 15/86] target/arm: GICv5 cpuif: Implement ICH_PPI_PRIORITYR_EL2 Date: Tue, 13 Oct 2026 09:38:22 +0100 Message-ID: <20261013083933.1024405-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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_FILL_THIS_FORM_SHORT=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881635647158500 Content-Type: text/plain; charset="utf-8" Implement the ICH_PPI_PRIORITYR_EL2 registers, which are the hypervisor's interface to its guest's PPI priority register state. As with ICC_PPI_PRIORITY_EL1, we define these programmatically to avoid listing out 16 near-identical cpreg definitions. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpu.h | 1 + target/arm/tcg/gicv5-cpuif.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 62262c594d7..287cfa87140 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -599,6 +599,7 @@ typedef struct CPUArchState { uint64_t ich_ppi_active[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_pend[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_enable[GICV5_NUM_PPIS / 64]; + uint64_t ich_ppi_priority[GICV5_NUM_PPIS / 8]; } gicv5_cpuif; =20 struct { diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 6dec0ec1ea6..b901e64ef0d 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -481,6 +481,12 @@ static void gic_ich_ppi_active_write(CPUARMState *env,= const ARMCPRegInfo *ri, raw_write(env, ri, value); } =20 +static void gic_ich_ppi_priority_write(CPUARMState *env, const ARMCPRegInf= o *ri, + uint64_t value) +{ + raw_write(env, ri, value); +} + /* * ICC_APR_EL1 is banked and reads/writes as the version for the * current logical interrupt domain. @@ -1024,5 +1030,20 @@ void define_gicv5_cpuif_regs(ARMCPU *cpu) }; define_one_arm_cp_reg(cpu, &ppi_prio); } + /* Similarly for ICH_PPI_PRIORITYR_EL2 */ + for (int i =3D 0; i < 16; i++) { + g_autofree char *name =3D g_strdup_printf("ICH_PPI_PRIORITYR%d= _EL2", i); + ARMCPRegInfo ppi_prio =3D { + .name =3D name, .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, + .crm =3D 14 + (i >> 3), .opc2 =3D i & 7, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb80 + (8 * i), + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi= _priority[i]), + .writefn =3D gic_ich_ppi_priority_write, + }; + define_one_arm_cp_reg(cpu, &ppi_prio); + } } } --=20 2.43.0 From nobody Mon Nov 23 04:52:38 2026 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=1791881222; cv=none; d=zohomail.com; s=zohoarc; b=Bzd013g9lxkQTqTrUgCAewI0e/whtlTYDcAfC+wA3AR4/fgVwpt+dkRcMg3bBc1IShD+5Np7WGgQV+GslcaapD/4g2VMu60VA9NejnLkEfCSO+GZU/TtzQ8EsycxuR4vjKIPBTnLHxeQKsZCgzZLue0RFBySPIkTs+rhvYeF+Mc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881222; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=FcrvcwO8TfKKXlj5jfLPNIJA9YWvLSs6kM7SKop1Kq4=; b=M7gwD29K4pZg6weIJdDJqgfhT7U0bWcKX4lO38T+G/9Tb5RV/tAMPtL+zFtYxjs8X0Jk/brqWvDMptyu30NxgJWHFwNCIYmWSdzWSefXLCgH9bCsboyXx6UoVL+KArMije4kJJ5uUA8fdUUPo55S/EzlPg2Dl8thpWkZ56Rm0RA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881222053724.6301219587945; Tue, 13 Oct 2026 01:47:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3g-0007ee-8d; Tue, 13 Oct 2026 04:40:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3R-00075x-7I for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:15 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3L-0007cj-IN for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:12 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a17baef589so22011165e9.0 for ; Tue, 13 Oct 2026 01:39:57 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880796; x=1792485596; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=FcrvcwO8TfKKXlj5jfLPNIJA9YWvLSs6kM7SKop1Kq4=; b=ujt5PVQkNfTI6SyhYanDDDkRFwjaQAI+vkpjUmqHqRT/0bCgUqWPKUhtGf+EXy+4mP t/2HZX8gQ/Srxuij++ZIaP0LEYb2u2uj6hgIpZDJTRGOSGL338LYKPW5zF97U2HMTLQV 2iggm1d3MfaMGFx5txbLK3XVqCU1s+nl8RukLrRr2yHfeUHIwiAHCmzFjW8ZulISCjnM kCjWfJkpbs6t2XGmyu7n1/Ogp+VoZyLI089dP7INBISG8ONU4cs5EYTMwB871uqApcB8 z52KjZVDRo/7SKIM6WeXtgp49zLCIv+VHpb/mGBiayq1j6nlfaX2PCB9B3T8Wx4+Prkc ZuVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880796; x=1792485596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=FcrvcwO8TfKKXlj5jfLPNIJA9YWvLSs6kM7SKop1Kq4=; b=Bq1g6N4EWEHneIMsk9zxRyGBnZKcJs8pDGqP8GEmlWjyt8SFu4bojzG35OT2nx9TSi cdct9gGR+akH7Lb91HShvlrVayGkAuYYIK9IxsLL4e+EsOAzwAuYXOSxZxKyzR6vGBMI IikJ7ewUV1liVbxUGmeMtacaLNHhg9/EuOPs4C1eVObyeu9xBBPmfb6nqb2keERlk8Bi q0giYCLkfFyGeT+R2feg8OsYWsBUg1s402dPjgX+uhUVIcJYDbQiPjZd9a2n2x4n0FUr 4HHUhzf2B+v4+4TCT3tSI4wbYEIWmxBeKZ3iArTMh/usUEogb/KX7E3+sqObTNUYhEYy 4cKA== X-Forwarded-Encrypted: i=1; AKwUvBwaSnc1u0e5818t1LXqv6zSSJGZh7ZGE8N8bXvFlTq3xnh/Bm8LyPJNUe4Fik+du3mIR8GpVuarXuJM@nongnu.org X-Gm-Message-State: AFq9FYLu1kQLZ6ODyV7u0blzBcOdQkn4x24WyBG2Ir7vJGERJnyiEMLE CsNydlaEz2WfNe7YqFygNEGmeej+qDbo/xBt41ReZiQtgvd8sak8F9fD6FrWodCJ8Sv8twNusjU K6mLX9Tc= X-Gm-Gg: AYBFou2DWJcC0DGkYk4Ogb9x9p0p1HJpCgRymxBqOuFgwqjmeO5DOk3XlhLoLrDnXZ2 4kGRFPUu5JygmpP+QXMMUMMxYRBIHnAL6DLiVWaCOKW4W98JRb4evfZPj6Xeky9AvYMzWvY5c8G M7Mf+vRjuTQIrBqyj8OezPLD5slhOUe9q2Z8zR625ItJpHB1vU3RKOsDxswBZOpkAxX12Ek9q1Y w8VZWmVnjjG++7DW6rfZ7xIuDJ5+aZQ+HW7u+FaSUQRY/OPl3GkUwZJPrGiRWlOyum1XwrP4r+B ajg1es9ZRq1XAAZRilAlaXzIQiC3IYwbAYBkK2USsT3e+J4I79zKMumcBG/v1RlRx1dxXSJkA+d tUWrCkuTqZmZqEITB8dKZP7vzitPE0ndJcmrDvGaMPmnEP9W9RtGa+m8A6sSvHUj7eIFEYAu62i 5fw3VdX6l8uDcoJXvodjXpet7Ts7dY2o95upm2NA95EFn2TJu8wlGehDWIgwmeGg3G5CFgT5kK8 a9KEutt1sHuEXkhS64Qc4jWuXh6K35RHv07EOwWgjaeffJCUdMFTFqj3wujHWPoKRLvBDKgYNrG 75s= X-Received: by 2002:a05:600c:3144:b0:4a0:2423:946 with SMTP id 5b1f17b1804b1-4a18e48d362mr224435315e9.15.1791880796256; Tue, 13 Oct 2026 01:39:56 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 16/86] target/arm: GICv5 cpuif: Implement ICH_PPI_DVIR_EL2 Date: Tue, 13 Oct 2026 09:38:23 +0100 Message-ID: <20261013083933.1024405-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881223779158500 Content-Type: text/plain; charset="utf-8" Implement ICH_PPI_DVIR_EL2, which is the register that controls whether pending physical PPIs are directly injected as virtual PPIs to the virtual interrupt domain. Bits in this register are RAZ/WI from EL1 and EL2 if the PPI is not assigned to the current interrupt domain, but since we don't yet implement EL3 GICv5 support yet all PPIs are always assigned to the current interrupt domain. In this commit we just implement the register access to the state; actual injection of PPIs will be dealt with later. We give the register a writefn because eventually writing to this will need to trigger a recalculation of VIRQ/VFIQ. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpu.h | 1 + target/arm/tcg/gicv5-cpuif.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 287cfa87140..5d3587739d7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -599,6 +599,7 @@ typedef struct CPUArchState { uint64_t ich_ppi_active[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_pend[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_enable[GICV5_NUM_PPIS / 64]; + uint64_t ich_ppi_dvi[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_priority[GICV5_NUM_PPIS / 8]; } gicv5_cpuif; =20 diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index b901e64ef0d..2141f1d8e2c 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -487,6 +487,12 @@ static void gic_ich_ppi_priority_write(CPUARMState *en= v, const ARMCPRegInfo *ri, raw_write(env, ri, value); } =20 +static void gic_ich_ppi_dvi_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + raw_write(env, ri, value); +} + /* * ICC_APR_EL1 is banked and reads/writes as the version for the * current logical interrupt domain. @@ -961,6 +967,27 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .accessfn =3D access_gicv5_ich_reg, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_apr_el2), }, + /* + * Note that DVIR bits RAZ/WI when the PPI isn't assigned to the + * current domain, so we will need to mask them when we implement + * EL3 support and ICC_PPI_DOMAINR_EL3 + */ + { .name =3D "ICH_PPI_DVIR0_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 10, .opc2 =3D 0, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb40, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_dvi[0]), + .writefn =3D gic_ich_ppi_dvi_write, + }, + { .name =3D "ICH_PPI_DVIR1_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 10, .opc2 =3D 1, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb48, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_dvi[1]), + .writefn =3D gic_ich_ppi_dvi_write, + }, { .name =3D "ICH_PPI_ENABLER0_EL2", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 10, .opc2 =3D 2, .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881385; cv=none; d=zohomail.com; s=zohoarc; b=CCskxPnYp3cVbm3acC8cOthPk5OB8Kl17CBGFVpaHtFlsG3XBVOHub+JyQcfcZxqdE0PQdYkfdF+mShE6Ys3GtIpS+zV15VBJWItH5nwHFMs5givHzfYrUVdnuLN+etuPQwtxUJz1IH4ZaEK6tgl2T1j52RDvIhgronZdNw5/tE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881385; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=K/fazeDrj1SJvW+QNVTTmk1BBmWOISZMReEdlQ3HE/s=; b=IoqsbRRiU61JhNDNR4rdBDbcvbRZ6yIQ62Y3e0JXTe/EwtKHtI5UNO9fGr5xXqG20+rXO/NZR67GMKo8fJIomGgKsX3EBLEduxK8wz1+BA1itaeCXs3YOkQ6cfJSjopDF4IfoIObP5RWxbZTsBkoRcplncLvHgpfQo8v+fh90LI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881384990441.53275187020154; Tue, 13 Oct 2026 01:49:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3f-0007bp-4q; Tue, 13 Oct 2026 04:40:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3Q-00075P-Ps for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:15 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3L-0007cs-IR for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:12 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4a1688d7769so22518215e9.0 for ; Tue, 13 Oct 2026 01:39:59 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880798; x=1792485598; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=K/fazeDrj1SJvW+QNVTTmk1BBmWOISZMReEdlQ3HE/s=; b=vCLsdyaBxcUANmL5UPuu+dTDqhaIs8BAQ8jTzu34/RhvRE7+rmBmnCxbRiHE5MrQZy eJ3DDrwPBJRFtKNNZWNgEvmgd9rrPhHggI3DzxbxglSieqNeaYcF01qArPP66H268j1e ORGWprrcuTwYT8iFEvoemnStbFE1+UeqUQH9VFTogGCbAFTLuE1+eu12a+5Qa8FGuKf8 O2OwJDbCiVmphVHlPmnsai0zE+TetXcXCUp8XxxQM2moxtuJoeASsXiM8C9Wpf/6l9Nm 89XBy3O76401L1oJPSgcRbyDCS/RwLwQ7iKTpcbItLoY4A3wmH+bALwJplvdScX+S5Mx eMtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880798; x=1792485598; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=K/fazeDrj1SJvW+QNVTTmk1BBmWOISZMReEdlQ3HE/s=; b=G7rt6C+QVdARP1GYyPRpiRl9BFXYi4QdwIQ+wLVut8mKXPpDOdemY1D86Xd8hHyzSu Bp0l5ZHQFBgs70vhk3KYPMweDKL2I8SiaSHWV2sqjT7KevipIVa14HfuUxpgC66+hWok M7AP4n3PA/V0a5WvJWe/hWx4LaIYEhS/aOwdE5BUygTp6ancsiXCKAoh1lx3WJOQupdY vpiXA7ZSDDdecmpFvUMrQzKDkeboQGLB5rbNiIxvAVDPS90L1ThXbGE4bXFUJR9r8RWn c1pLzgzXSEhy1SinhLVmelcLeUAh6Fao9GeNvl+T3HwZuaCiU0A52Vig4+MWX6eWpwCR xALA== X-Forwarded-Encrypted: i=1; AKwUvBxi+tSZcA9dNK6PL/F/wQ5O4ON2uMTovmbwN9+y3yFvngiwWyMjgrjv0KeZNRYIA4u2rzGWwiwxTIz0@nongnu.org X-Gm-Message-State: AFq9FYLBsvcJJGAISLq6rqj4dq0RNbtWDzuwgPPFm9Jov+RPV8n+vBZR pNxS9smrNANPkLk9Wcw/4j6nZqHDzNzYzGbRddAkubOBiqtnl5dOfkjRD/Hb+KyZslvlLqKtoGP Zcnz3LtQ= X-Gm-Gg: AYBFou2xm2+Tas78kUxLgKqs3dX3Gr2fNrgO9Am2Q95N0GN552q4DYT4Z/6Qn4OB1it KrH4L8U3djdBlv4DRVFR+4giBrP/ThpGyaSjkIPybfqjAgFwBYCiLSlvrGtMdpIOVYZFO+nsE50 i+gTsIvWihE82Z6XKGpLARVdGrJMalyPQ2SbYClLS/3rYxErcYEmgJ5QoCqdfMAWdnuEdm1rZ1j IUcu3Vc0ej5T5hFv2cmmuFywq4Ynay53TZYopO8rXALnAa/Ef6REoL5LCdEQPxM1fSwS/2QlRx1 LTs7uAE7nCM/bIXRsY/WpenV/MECWH9plBRiGhAS8aAJOqGMtZ9k0tiLK9aMfY5PG+v5yI+do/x dAh5lfTvwiw55lmAGLpExEFpxyak04wXCkoKFT9CABdInU4CRcvVk4Z3m2mM+0gRKw6k4u4OzwJ EM3p2QL4Jlmatx7ou1JGrA65yXnAvNtGEty1H/pOfbAssBBuoeVnmhbKmnj8xz2EF1SCPh7QIU8 I5fTwOLlM1K3llGJZBf/fhhadHGwDyALNUW2PtlJAnqgECOmKrEv8LeLUjpo4FN5TyDPYHqCUtC XCxNvrpsCOHZfw== X-Received: by 2002:a05:600c:1e0f:b0:4a1:7b87:8d34 with SMTP id 5b1f17b1804b1-4a18e4b46e1mr212143875e9.21.1791880797929; Tue, 13 Oct 2026 01:39:57 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 17/86] target/arm: GICv5 cpuif: Implement ICH_VCTLR_EL2 and ICH_VCMR_EL2 Date: Tue, 13 Oct 2026 09:38:24 +0100 Message-ID: <20261013083933.1024405-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; 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: -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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881386898158500 Content-Type: text/plain; charset="utf-8" Implement the ICH_VCTLR_EL2 and ICH_VMCR_EL2 registers, which hold hypervisor state for controlling its guest's GICv5 virtual cpu interface. We give these write functions and mark them as ARM_CP_IO even though they currently don't do anything special on write, because later on we will need changes to fields in these registers to trigger a recalculation of whether the VIRQ and VFIQ interrupts are signalled. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpu.h | 2 ++ target/arm/tcg/gicv5-cpuif.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 5d3587739d7..4e7076a5339 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -596,6 +596,8 @@ typedef struct CPUArchState { GICv5PendingIrq ppi_hppi[NUM_GICV5_DOMAINS]; =20 uint64_t ich_apr_el2; + uint64_t ich_vctlr_el2; + uint64_t ich_vmcr_el2; uint64_t ich_ppi_active[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_pend[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_enable[GICV5_NUM_PPIS / 64]; diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 2141f1d8e2c..ac667c84c2f 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -493,6 +493,18 @@ static void gic_ich_ppi_dvi_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, raw_write(env, ri, value); } =20 +static void gic_ich_vctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + raw_write(env, ri, value); +} + +static void gic_ich_vmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + raw_write(env, ri, value); +} + /* * ICC_APR_EL1 is banked and reads/writes as the version for the * current logical interrupt domain. @@ -1034,6 +1046,22 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_active[= 1]), .writefn =3D gic_ich_ppi_active_write, }, + { .name =3D "ICH_VCTLR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 11, .opc2 =3D 4, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb28, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_vctlr_el2), + .writefn =3D gic_ich_vctlr_write, + }, + { .name =3D "ICH_VMCR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 11, .opc2 =3D 7, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0x4c8, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_vmcr_el2), + .writefn =3D gic_ich_vmcr_write, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881186; cv=none; d=zohomail.com; s=zohoarc; b=FLthT45LHrI9wDE0UXbrZyqTrYjo6nmAYHwlgN1PTG8H0UW9aZV6fqcdwfLUSBO2eigAFJk1ePRK1R6JDysAb7jrPZSo7dBu4PeMqy+1S8lV35uJc3KiUlItoQZdzxLZsumKQbbnxMui2emHa851w+QlGyq+RHSO2MA181Xve8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881186; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=7xlfYHyIYxKoALR890FGz7sTstMZUZWDOD7rBywE0fs=; b=j9L4IfuhFHPi3/sNJe0I6NQxeJ5xEqqeaDWI/GhiPdinzMkfa0e8oyv918SlcBT9UPdlGACbjuKpHeaGlEJ77gmpd6IjzH5uWMptkORKv0memVJF0kYz+s64e1yd2tulhS5MFHUT916FBCE/kJ1Z1Vy9VAgWtdb6WZhTkD5bvHs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881186564354.6832979215483; Tue, 13 Oct 2026 01:46:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3a-0007Sw-SU; Tue, 13 Oct 2026 04:40:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3P-00071c-Sp for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:13 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3K-0007d1-Fz for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:09 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49ff680331aso21710605e9.3 for ; Tue, 13 Oct 2026 01:40:00 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880799; x=1792485599; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=7xlfYHyIYxKoALR890FGz7sTstMZUZWDOD7rBywE0fs=; b=vF8XZMNfRabwmEJeKKFs9YYjE+l+gRDlxofuaZJYBecBDRR9OiYros4kQZ9JnH8bos Ae6WiueLaGGMFdizoY+rYXQ1zRqisqnIGqVciA/WLA6bmTzPgDvUWE4jaoG/v4IJLqxK xKF1aXE1vpbptyl1DVEnnLQWrPTDREaSX5LDJtUSoQ+8ZbNAb0DPOUnoO6ffiE8t4aqV HbogZ6P67LRLQsh9CTdC58CtOqJcZvY8hDxWaN4z2G5QaZbgPUd5ERQYJ4pt+J/fZYtO 7Z2giW1uV4hG0o2oIC/9ExNxbMIedPnE8m0YKATXBsN6nORFXxry1L4gnLUQzafMYe1m lUow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880799; x=1792485599; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=7xlfYHyIYxKoALR890FGz7sTstMZUZWDOD7rBywE0fs=; b=CBK24vnIafoVf+zCEVmFIElkQq9qfTS1MwWZPdQtf6C5oB5fK+AqqAXmu6cuLLsFd+ CVeiCE5gAxaxiwYPoMCHluSIl+v/Nq7BFrldFu1hb8/ZoseFz+lErwPsPfN1Bqf/lpI4 YL2VQpesZlr8imjYF9l3WGulMcQZv4b2E5mRDGxA9vU630l/I98xQTlm0F1VB2z7Z/2e Y2iMcFNF6k1HDffc3tDO+vb8+21PvHlF8qwg6fUfVV0Td/X3KlEk62zNsXFd7CfxGGeW +8i1FwK7cCc4yLbGgrIBEEbZkPnDg2p7L/J2R4HNEV5bPn8iT+pViLfS9kQPBzB95WAF sTMQ== X-Forwarded-Encrypted: i=1; AKwUvByS4xyOjAtB8LLV+pdwKtAd+i6+aF3fGx4wkhEvrDYlo9g8US7vsqW+r7aKCQQnadjP+CGCdBDo9Fcj@nongnu.org X-Gm-Message-State: AFq9FYL6ZFc6Z/041ME8u+1IwmBmPnAw1VADzqy6F/l4RaavY5+ClHMq QLW/03IbQU7SGrzh2/kHPZ21k2hB7UIec+e8iE1kb78xerKh9qbbXJ6xUBmurKMOUyU51IGaL8E tDb9ubxk= X-Gm-Gg: AYBFou0DpUDHlP1hjFBldW2PrRjWbVm2ElBy4Bkg8l8Bbhe8reoD1tBWSQU+GRN/99e Rcmwf37v7kUdQbU2psZU7Qq3bS3t2X5FSySbCFpIiUGLiHHHF522JvTh06jAl/AFgV/M4eH+rH5 pvAj3cfIIGOImYnhJe0S4bpBzuQ6r+yXWK/XV1EiVRLyMVKojsfY1ZyO0bnRE491bngot1zoA/C cjGSMa6qYaRzF4txFldInZKftDKBPub0XGJMh0QkVvtXHhECO9lUqJjHtsTDzwRP7tXgaVFs9Cq oQVULRWbNQqvD3/4DDkrfTFypDsMm7RVGQYXVRqjISmEq0TjXNFSMuCgozrs2SXC967HhvT8XwV ydmlQ5ufvBY0LYJ68jJJTYhea/TLlTeaQXhdThO4SvKpn5h6ZUajlYZB3zXPC9lL6pdW69VDqra u8TLnrpxSrIG1aYMoiwSdNvw4uyo2FU2GMJZlaqZ3xQ3JqPmWg8KLFpXKhU1ykfmfbgNzLsdHCo rClszQIZ4QMwg/jTtsoVuePH63cwuaKfYz1R9ALKmWAUJM3b8Q5IMj+X1JDoQc3OrIpRzsf/T2/ tJCjXhHUn8IjVA== X-Received: by 2002:a05:600c:4593:b0:4a1:7ed5:99e8 with SMTP id 5b1f17b1804b1-4a18e49bffbmr230919965e9.22.1791880799246; Tue, 13 Oct 2026 01:39:59 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 18/86] target/arm: GICv5 cpuif: Implement GIC fine-grained trap registers Date: Tue, 13 Oct 2026 09:38:25 +0100 Message-ID: <20261013083933.1024405-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881187057158500 Content-Type: text/plain; charset="utf-8" The GICv5 cpu interface includes a set of fine-grained trap registers which allow a hypervisor to trap guest accesses to the various GIC cpu interface registers and instructions. We implement this using the existing fine-grained-trap mechanism. This commit provides the definitions of the FGT register bits and the registers themselves; we will mark up the cpreg definitions with the fgt trap information in the following commit. Note that because FGWTE3 has only write-traps and the indexes into fgt_read[] and fgt_write[] have to line up, we leave a gap in the fgt_read[] array for the unused slot. We could have moved FGTWE3 to the end of the array, since the array location isn't encoded in the migration stream, but that only saves us 8 bytes in the CPU struct size and leaves the possibility that we forget about the need to align the read/write indexes next time we add an FGT feature. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpregs.h | 85 +++++++++++++++++++++++++++++++++++- target/arm/cpu.h | 10 +++-- target/arm/tcg/gicv5-cpuif.c | 22 ++++++++++ 3 files changed, 111 insertions(+), 6 deletions(-) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index ce651a4faa6..e46c8c979e1 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -389,12 +389,16 @@ typedef enum CPAccessResult { /* Indexes into fgt_read[] */ #define FGTREG_HFGRTR 0 #define FGTREG_HDFGRTR 1 -/* Indexes into fgt_write[] */ +/* 2 unused: FGWTE3 doesn't have read-traps */ +#define FGTREG_ICH_HFGRTR 3 /* GICv5 */ +/* Indexes into fgt_write[]; these must align with the fgt_read[] ones */ #define FGTREG_HFGWTR 0 #define FGTREG_HDFGWTR 1 #define FGTREG_FGWTE3 2 -/* Indexes into fgt_exec[] */ +#define FGTREG_ICH_HFGWTR 3 /* GICv5 */ +/* Indexes into fgt_exec[] (these don't have to line up with read/write) */ #define FGTREG_HFGITR 0 +#define FGTREG_ICH_HFGITR 1 /* GICv5 */ =20 FIELD(HFGRTR_EL2, AFSR0_EL1, 0, 1) FIELD(HFGRTR_EL2, AFSR1_EL1, 1, 1) @@ -720,6 +724,45 @@ FIELD(FGWTE3_EL3, TTBR0_EL3, 20, 1) FIELD(FGWTE3_EL3, VBAR_EL3, 21, 1) FIELD(FGWTE3_EL3, GPCBW_EL3, 22, 1) =20 +/* These are the GICv5 fine-grained trap registers */ +FIELD(ICH_HFGRTR_EL2, ICC_APR_EL1, 0, 1) +FIELD(ICH_HFGRTR_EL2, ICC_IDRN_EL1, 1, 1) +FIELD(ICH_HFGRTR_EL2, ICC_CR0_EL1, 2, 1) +/* Bit 3 is RES1 */ +FIELD(ICH_HFGRTR_EL2, ICC_HPPIR_EL1, 4, 1) +FIELD(ICH_HFGRTR_EL2, ICC_PCR_EL1, 5, 1) +FIELD(ICH_HFGRTR_EL2, ICC_ICSR_EL1, 6, 1) +FIELD(ICH_HFGRTR_EL2, ICC_IAFFIDR_EL1, 7, 1) +FIELD(ICH_HFGRTR_EL2, ICC_PPI_HMRN_EL1, 16, 1) +FIELD(ICH_HFGRTR_EL2, ICC_PPI_ENABLERN_EL1, 17, 1) +FIELD(ICH_HFGRTR_EL2, ICC_PPI_PENDRN_EL1, 18, 1) +FIELD(ICH_HFGRTR_EL2, ICC_PPI_PRIORITYRN_EL1, 19, 1) +FIELD(ICH_HFGRTR_EL2, ICC_PPI_ACTIVERN_EL1, 20, 1) +/* All RES1 bits in this register */ +#define ICH_HFGRTR_EL2_RES1_MASK (1 << 3) + +/* Matches ICH_HFGRTR_EL2, but bits for RO regs are RES0 */ +FIELD(ICH_HFGWTR_EL2, ICC_APR_EL1, 0, 1) +FIELD(ICH_HFGWTR_EL2, ICC_CR0_EL1, 2, 1) +FIELD(ICH_HFGWTR_EL2, ICC_PCR_EL1, 5, 1) +FIELD(ICH_HFGWTR_EL2, ICC_ICSR_EL1, 6, 1) +FIELD(ICH_HFGWTR_EL2, ICC_PPI_ENABLERN_EL1, 17, 1) +FIELD(ICH_HFGWTR_EL2, ICC_PPI_PENDRN_EL1, 18, 1) +FIELD(ICH_HFGWTR_EL2, ICC_PPI_PRIORITYRN_EL1, 19, 1) +FIELD(ICH_HFGWTR_EL2, ICC_PPI_ACTIVERN_EL1, 20, 1) + +FIELD(ICH_HFGITR_EL2, GICCDEN, 0, 1); +FIELD(ICH_HFGITR_EL2, GICCDDIS, 1, 1); +FIELD(ICH_HFGITR_EL2, GICCDPRI, 2, 1); +FIELD(ICH_HFGITR_EL2, GICCDAFF, 3, 1); +FIELD(ICH_HFGITR_EL2, GICCDPEND, 4, 1); +FIELD(ICH_HFGITR_EL2, GICCDRCFG, 5, 1); +FIELD(ICH_HFGITR_EL2, GICCDHM, 6, 1); +FIELD(ICH_HFGITR_EL2, GICCDEOI, 7, 1); +FIELD(ICH_HFGITR_EL2, GICCDDI, 8, 1); +FIELD(ICH_HFGITR_EL2, GICRCDIA, 9, 1); +FIELD(ICH_HFGITR_EL2, GICRCDNMIA, 10, 1); + FIELD(FGT, NXS, 13, 1) /* Honour HCR_EL2.FGTnXS to suppress FGT */ /* Which fine-grained trap bit register to check, if any */ FIELD(FGT, TYPE, 10, 3) @@ -798,6 +841,9 @@ typedef enum FGTBit { FGT_HDFGWTR =3D FGT_W | (FGTREG_HDFGWTR << R_FGT_IDX_SHIFT), FGT_HFGITR =3D FGT_EXEC | (FGTREG_HFGITR << R_FGT_IDX_SHIFT), FGT_FGWTE3 =3D FGT_W | (FGTREG_FGWTE3 << R_FGT_IDX_SHIFT), + FGT_ICH_HFGRTR =3D FGT_RW | (FGTREG_ICH_HFGRTR << R_FGT_IDX_SHIFT), + FGT_ICH_HFGWTR =3D FGT_W | (FGTREG_ICH_HFGWTR << R_FGT_IDX_SHIFT), + FGT_ICH_HFGITR =3D FGT_EXEC | (FGTREG_ICH_HFGITR << R_FGT_IDX_SHIFT), =20 /* Trap bits in HFGRTR_EL2 / HFGWTR_EL2, starting from bit 0. */ DO_BIT(HFGRTR, AFSR0_EL1), @@ -955,6 +1001,41 @@ typedef enum FGTBit { DO_EL3_BIT(FGWTE3, TTBR0_EL3), DO_EL3_BIT(FGWTE3, VBAR_EL3), DO_EL3_BIT(FGWTE3, GPCBW_EL3), + + /* + * Trap bits in ICH_HFGRTR_EL2 / ICH_HFGWTR_EL2, starting from bit 0. + * These are all "trap on 0, don't trap on 1" and don't follow the + * "name starts with 'n' if sense is reversed" convention of the + * main FEAT_FGT registers. + */ + DO_REV_BIT(ICH_HFGRTR, ICC_APR_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_IDRN_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_CR0_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_HPPIR_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_PCR_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_ICSR_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_IAFFIDR_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_PPI_HMRN_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_PPI_ENABLERN_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_PPI_PENDRN_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_PPI_PRIORITYRN_EL1), + DO_REV_BIT(ICH_HFGRTR, ICC_PPI_ACTIVERN_EL1), + + /* + * Trap bits in ICH_HFGITR_EL2, starting from bit 0. These also + * are all "trap on 0". + */ + DO_REV_BIT(ICH_HFGITR, GICCDEN), + DO_REV_BIT(ICH_HFGITR, GICCDDIS), + DO_REV_BIT(ICH_HFGITR, GICCDPRI), + DO_REV_BIT(ICH_HFGITR, GICCDAFF), + DO_REV_BIT(ICH_HFGITR, GICCDPEND), + DO_REV_BIT(ICH_HFGITR, GICCDRCFG), + DO_REV_BIT(ICH_HFGITR, GICCDHM), + DO_REV_BIT(ICH_HFGITR, GICCDEOI), + DO_REV_BIT(ICH_HFGITR, GICCDDI), + DO_REV_BIT(ICH_HFGITR, GICRCDIA), + DO_REV_BIT(ICH_HFGITR, GICRCDNMIA), } FGTBit; =20 #undef DO_BIT diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4e7076a5339..276466d2b84 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -550,11 +550,13 @@ typedef struct CPUArchState { * Fine-Grained Trap registers. We store these as arrays so the * access checking code doesn't have to manually select * HFGRTR_EL2 vs HFDFGRTR_EL2 etc when looking up the bit to test. - * FEAT_FGT2 will add more elements to these arrays. + * These include the trap registers for all features which have + * FGT-style trapping: FEAT_FGT, FEAT_FGWTE3. GICv5, and (when we + * implement it) FEAT_FGT2. */ - uint64_t fgt_read[2]; /* HFGRTR, HDFGRTR */ - uint64_t fgt_write[3]; /* HFGWTR, HDFGWTR, FGWTE3 */ - uint64_t fgt_exec[1]; /* HFGITR */ + uint64_t fgt_read[4]; /* HFGRTR, HDFGRTR, unused, ICH_HFGRTR */ + uint64_t fgt_write[4]; /* HFGWTR, HDFGWTR, FGWTE3, ICH_HFGWTR */ + uint64_t fgt_exec[2]; /* HFGITR, ICH_HFGITR */ =20 /* RME registers */ uint64_t gpccr_el3; diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index ac667c84c2f..55dc2e3b3b2 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -979,6 +979,28 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .accessfn =3D access_gicv5_ich_reg, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_apr_el2), }, + { .name =3D "ICH_HFGRTR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 9, .opc2 =3D 4, + .access =3D PL2_RW, .type =3D ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb10, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, cp15.fgt_read[FGTREG_ICH_HF= GRTR]), + .resetvalue =3D ICH_HFGRTR_EL2_RES1_MASK, + }, + { .name =3D "ICH_HFGWTR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 9, .opc2 =3D 6, + .access =3D PL2_RW, .type =3D ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb10, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, cp15.fgt_write[FGTREG_ICH_H= FGWTR]), + }, + { .name =3D "ICH_HFGITR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 9, .opc2 =3D 7, + .access =3D PL2_RW, .type =3D ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb10, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, cp15.fgt_exec[FGTREG_ICH_HF= GITR]), + }, /* * Note that DVIR bits RAZ/WI when the PPI isn't assigned to the * current domain, so we will need to mask them when we implement --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881093; cv=none; d=zohomail.com; s=zohoarc; b=JDbNLpNH7ORlfD+ZORXmhzPtcfvbRTLITXvZUv7KNkyaY6+uLoXZIsM9lDLonrgMbz2qPUlNshMQriCRAWaa3PAQiVdfoaTtsx0Npu/EZeIzYoNa2UaDWwyB6o9BuAgTrdA/M4KieKcF8gyTZ6Tf6B4EB/IQnp8BvhQNeZEURIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881093; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=gVXcihlenbO4kdBms1ArgyANCPh5orEbYliejO8EpDg=; b=WVVt0Etp1ux3hXPqIQw68ugyuHbz6VWlaza/FUdNs9czrYSplKly+p+qweTMwYv/oUP7RA36W5uE5MsDuoZmddAm9wUYc7dGXchnezhXD3Yq7EpT68Qc71NxHFC4lQOQRt9KjFhgkO4EQ1I2fHH275IfccgYXNUFMhg1/9D/XAA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881092977256.47212047515563; Tue, 13 Oct 2026 01:44:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4G-0000Ke-Qm; Tue, 13 Oct 2026 04:41:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3P-00071e-S0 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:13 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3K-0007dx-Gm for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:09 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4a171b677d2so15777465e9.0 for ; Tue, 13 Oct 2026 01:40:02 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880802; x=1792485602; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=gVXcihlenbO4kdBms1ArgyANCPh5orEbYliejO8EpDg=; b=Gu977fvhfOmxoMP+2BTvjXJr0WPZjnJK2C7p5h3oVMAUS9/GOSSuu6cYHe/X2Xf7DM mMH0WPF8AKESqgrPRF2sHf8XQeRAXZydDxcp6Ah2t3fOPXxZhcdtMJ6b/A4WnZPKHZuq 3BDTVlMZxjmYz6vFZBl8PtJaQ7KdeXuHJj3M/o8tfhHHI/NXGOafExCNiAndGw7/Xxt4 IoYCzid4EHWLZoj0n/0Ng0HHWdaCq0x4PCksoyZ1ieoPKXttY3nsBpRFU3RNoDcy49Ap AugDAio077CwdN2oWqKChwRxRXXzvYDDHigxVkmNVWzSVL8IIQQr5KeC5rmWc4HoKRpz 8eJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880802; x=1792485602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=gVXcihlenbO4kdBms1ArgyANCPh5orEbYliejO8EpDg=; b=2C/S3TmsC9NmQKAE41bVvRPosQDodz1nkm1venwuwb9/ETda+wzmsmX3RgKyLqB04Y 0vMRtnRMUw/onxBE0X3nlKgo90xs9L+hHkPOcu0DpRrQfR+wTxJOaz+4V4Se64d9UEHo oG7rD45n+zOmOWDKbej0hO0ypZsXUxPVYE3GViyDNM1w55ouIjLekbp4NqOlVYukb4W0 lvwJyNWEB3BHq4cxYHcEFrxx/zxaGCAi/0M/O85ROyuouUVBjJXswMf4neVUF8Rm2/NK qFnA/3Bdq6UmmTYZiUW334xCfJMecds1N/9VVA7WP2Cw031IEs93s8zbLhuB5poDilve PLJg== X-Forwarded-Encrypted: i=1; AKwUvBxr4V3y/BDHUyh3+KdQOA5F547GanDRVHfA1Ty6/qnbZCGu02TsyXJLx7oEf8lhfqm0kjGB0XX12FZc@nongnu.org X-Gm-Message-State: AFq9FYIr1s/5nhLZts5dl/BDsD6oh0yhSOEzzpYoYFzhK2y/QB+O2O43 F5vd5M86lEMh7GmEuFa4ANoqZdmAlRDIkVcahHfZ06T2WleQoDOwmFqH+x1jSkHMuL4= X-Gm-Gg: AYBFou1KmBi5Yh7IuRxE03SN3k2wagrS0b0e+C++a0XOj8RuyDusH3aSYTqZ9DVD1SE fs84Kx/hQmFSwVaUpImJJ8OPz6TWG40vV5tN+0zfOFBBLTBzIodwQI8+O4cgaFUov1YH9V10PCs 9EgSEwtlf9h5cfiA3JuDBaBr1ZhFhpmETPASSR7v5iCFRwJlyjRDatYZbWNpSIbEONeS5XKqHZg GYtRVARWOntYFalaO27/PC5DmkLhRhNp8yoTIiZRhrVXhrl9Wh6UOtiRlIxHeVmtTUUHDw9Fb0p d9pY5h8YO81fkT06H1DLh9LZ4AtD/tAgQ0IXh02EzqKgTWGgTD7aWnWNcsfeddczND3b6SprC8z 79YRqpNWPTvLX8IFUWGNLmFWeCa7c65iQTrWO4+02CYwNL/Q+cF7V7aS5YffajrkGqzsr8OBymz VhqglQYCNG55S80QULf9OBBMChWi52HNZkCegJdDvICpm1wKlZ95gY787MHXa4ZVNy6SJdZjoYE NzbEegYzsYn1StQXiHB7HCXfRGg1vGJyfxebNZhfdMFz3wrFlYquxb6Qy3e1ucrbn6JmjOTO6/m x6w= X-Received: by 2002:a05:600c:348d:b0:4a1:813f:2a63 with SMTP id 5b1f17b1804b1-4a18e4aa26amr220016585e9.18.1791880801179; Tue, 13 Oct 2026 01:40:01 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 19/86] target/arm: GICv5 cpuif: Mark GIC registers for fine-grained traps Date: Tue, 13 Oct 2026 09:38:26 +0100 Message-ID: <20261013083933.1024405-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881095264158500 Content-Type: text/plain; charset="utf-8" Annotate the GICv5 cpuif register cpreg structs with the fine-grained trap information. This covers all the bits in ICH_HFGRTR_EL2 and ICH_HFGWTR_EL2. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 55dc2e3b3b2..a829b90f334 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -855,17 +855,20 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { { .name =3D "ICC_IDR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 2, .access =3D PL1_R, .type =3D ARM_CP_CONST | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_IDRN_EL1, .resetvalue =3D QEMU_ICC_IDR0, }, { .name =3D "ICC_ICSR_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 4, .access =3D PL1_RW, .type =3D ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_ICSR_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.icc_icsr_el1), .resetvalue =3D 0, }, { .name =3D "ICC_IAFFIDR_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 5, .access =3D PL1_R, .type =3D ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_IAFFIDR_EL1, /* ICC_IAFFIDR_EL1 holds the IAFFID only, in its low bits */ .fieldoffset =3D offsetof(CPUARMState, gicv5.iaffid), /* @@ -877,83 +880,97 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { { .name =3D "ICC_PPI_CACTIVER0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 13, .opc2 =3D 0, .access =3D PL1_RW, .type =3D ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO= _RAW, + .fgt =3D FGT_ICC_PPI_ACTIVERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_active[0]), .writefn =3D gic_ppi_cactive_write, }, { .name =3D "ICC_PPI_CACTIVER1_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 13, .opc2 =3D 1, .access =3D PL1_RW, .type =3D ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO= _RAW, + .fgt =3D FGT_ICC_PPI_ACTIVERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_active[1]), .writefn =3D gic_ppi_cactive_write, }, { .name =3D "ICC_PPI_SACTIVER0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 13, .opc2 =3D 2, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PPI_ACTIVERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_active[0]), .writefn =3D gic_ppi_sactive_write, }, { .name =3D "ICC_PPI_SACTIVER1_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 13, .opc2 =3D 3, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PPI_ACTIVERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_active[1]), .writefn =3D gic_ppi_sactive_write, }, { .name =3D "ICC_PPI_HMR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 0, .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PPI_HMRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_hm[0]), .resetvalue =3D PPI_HMR0_RESET, }, { .name =3D "ICC_PPI_HMR1_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 1, .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PPI_HMRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_hm[1]), .resetvalue =3D PPI_HMR1_RESET, }, { .name =3D "ICC_HPPIR_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 3, .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_HPPIR_EL1, .readfn =3D gic_icc_hppir_el1_read, }, { .name =3D "ICC_PPI_ENABLER0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 6, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PPI_ENABLERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_enable[0]), .writefn =3D gic_ppi_enable_write, }, { .name =3D "ICC_PPI_ENABLER1_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 7, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PPI_ENABLERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_enable[1]), .writefn =3D gic_ppi_enable_write, }, { .name =3D "ICC_PPI_CPENDR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 13, .opc2 =3D 4, .access =3D PL1_RW, .type =3D ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO= _RAW, + .fgt =3D FGT_ICC_PPI_PENDRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pend[0]), .writefn =3D gic_ppi_cpend_write, }, { .name =3D "ICC_PPI_CPENDR1_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 13, .opc2 =3D 5, .access =3D PL1_RW, .type =3D ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO= _RAW, + .fgt =3D FGT_ICC_PPI_PENDRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pend[1]), .writefn =3D gic_ppi_cpend_write, }, { .name =3D "ICC_PPI_SPENDR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 13, .opc2 =3D 6, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PPI_PENDRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pend[0]), .writefn =3D gic_ppi_spend_write, }, { .name =3D "ICC_PPI_SPENDR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 13, .opc2 =3D 7, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PPI_PENDRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pend[1]), .writefn =3D gic_ppi_spend_write, }, { .name =3D "ICC_APR_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 1, .crn =3D 12, .crm =3D 0, .opc2 =3D 0, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_APR_EL1, .readfn =3D gic_icc_apr_el1_read, .writefn =3D gic_icc_apr_el1_write, .resetfn =3D gic_icc_apr_el1_reset, @@ -961,6 +978,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { { .name =3D "ICC_CR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 1, .crn =3D 12, .crm =3D 0, .opc2 =3D 1, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_CR0_EL1, .readfn =3D gic_icc_cr0_el1_read, .writefn =3D gic_icc_cr0_el1_write, .resetfn =3D gic_icc_cr0_el1_reset, @@ -968,6 +986,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { { .name =3D "ICC_PCR_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 1, .crn =3D 12, .crm =3D 0, .opc2 =3D 2, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PCR_EL1, .readfn =3D gic_icc_pcr_el1_read, .writefn =3D gic_icc_pcr_el1_write, .resetfn =3D gic_icc_pcr_el1_reset, @@ -1102,6 +1121,7 @@ void define_gicv5_cpuif_regs(ARMCPU *cpu) .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 14 + (i >> 3), .opc2 =3D i & 7, .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_ICC_PPI_PRIORITYRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pri= ority[i]), .writefn =3D gic_ppi_priority_write, .raw_writefn =3D raw_= write, }; --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881454; cv=none; d=zohomail.com; s=zohoarc; b=ePzPBL4W/f1fU0yq2TBAM5J02zFuW2+EuO7YkVYPyd1IyKK0j2KX3sUlwrbThfGMKrHDEwYMkpR7IkcKOcdKUHED07mO1P+kL0YIBwOJpYIPw4qaMjCXDXAXNwtIMC9zGkIJX4V0QUZpjKI09EXDDiZbOqYlgLv2IJTG2zDcGjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881454; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=phhovw2oMK5AXV5XzQAgTt3Eg1fVusDb5Wdqr/0Mm3w=; b=NFajepkd8r6UqHjORodny76xxJKE5+fbVnHG+0JPQ0tGyvfCL7EOKGlZAQITsrehjBYx7ynHEeSUWtjNCu/i3XIMAPFBSSmALVaUfNXGJnsODWQ4V3KX0MxI54wZDY1mEFumx2WHTRPMXja1rCrD9crPMEeBibn1gGd6Fnif5To= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188145469521.837913674679953; Tue, 13 Oct 2026 01:50:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3n-00081H-FL; Tue, 13 Oct 2026 04:40:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3R-00076o-Th for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:15 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3L-0007gs-Hx for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:13 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a140e7405dso30872055e9.3 for ; Tue, 13 Oct 2026 01:40:03 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880802; x=1792485602; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=phhovw2oMK5AXV5XzQAgTt3Eg1fVusDb5Wdqr/0Mm3w=; b=aIp1DGjni4JYFhzF0GIsarj0LkQER+Wz+hU1SLFhhj5Le0IM66j60BJkrgob0oJSoq rd9GSX0+YHZbehkKzEDL8u4u4v3q8IQKMnICE9uDFXWdJgc5Nmid/JX+OC/47GzBNUSB QVTUIYCa6XGLY0PttcQpTKY1/bg606ZxKXMaE7xNrmPvO09skJVdSGBArSUq8YpkFxFz p+8mJE6dwge0tywvYTOa3SzNXYzFbNEjz0y/LeEJG9lHFAZTg7OdFLfZetWO9Mg0MjHL EWIoLtosXE69EKdQ2MYj8h8zbfs4ipDUVeiUpsP2uxhEJSaZQc2uFiuGq1GW1AZwBnNu KLzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880802; x=1792485602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=phhovw2oMK5AXV5XzQAgTt3Eg1fVusDb5Wdqr/0Mm3w=; b=UCrLPT2dJ0ZySie1TXGKOGlFJYaWMuUi9h2PhBU7Zvc2AwpcawTFKc7TjvNAnrTQkb N45pdFBKjb4R9UGpNyMSEpU3fiOfNMxkejtTyljWtvEY+ba7FT6SQQfYpKBm67RDnaFq l8j8mfgLzXxJ4pPWCHoM8p+MyPFGE8XmRyCYDGQzpBvaPrjaLcqknRsmbHPGVIGltsAi 0DA9y9wlLTw8/52BjXTA3X84ZMyjUSsaMsJeB+g31OUIDSDYN5wRpQJa0/XJAttcG3Ca DujncQeXO6XHNSko0NLHKjydkDwvcv/lG6poF2vq+kzZFgIvZSGY75QlXtoUWqLoR33X gfAg== X-Forwarded-Encrypted: i=1; AKwUvBxsxaGbSbRXvFFZNY81Mb4UfWzVgl8S1132OyV9KOVY35in2BMElgwZePMLWY15A1Qh4qZ/HsTslcDX@nongnu.org X-Gm-Message-State: AFq9FYIX09lgjlx05Qdd+xcS5Jypd6E99d9AOzBK/VX32zT9jGdLqrPr 3k88JBpxGidOxKE7f7iSuDXU7ntKYcB02UUbx6CDR3NcOhwF5m8PG9FiKYLU/3E7nTVLh52TkV7 cj7XmCyc= X-Gm-Gg: AYBFou2FO3/d8fg76+yhZQpdNDpWdKIIo/aISw5HFNuDMhDvAdpJ+reWt+qC0Rrxvn8 +jfeJpxMJP7d9g97UtrGDxrqOZ0wdTszViNBxTSIOZEa72JZ796l99yDClsONUEUE5ZhF/JeRfo tYTgk32nyXZFHnl4SYTLUOR98edv3+kJ9wD0ISAV1tqgfqF4tKofTexXYIA8UBqUZYSQvXdI7y0 6slp9qT03IuGsQjTuSWHMYcBLdCzux9B9MPUIHSN7jkVbG+px4MT+heDubU8s+sDdEY9TlX6/L+ 51+xuN1TzpdujmLxMd1nkfuDXacDaVrvDLyVhQFFsoNt2RLAv8WPhVORzDktkV976iiFIht6Ldz QjyHHxOsu3JXshjiPcbdqyyWBnlfL5sH3/Yz+JXlKBYM5nWJBzBWDqBi3YdpBGjbkLBiLmSTyBf fz1wKrLEvvqf2Okv29Dh79ji2iKOddGrU4KhgwiuIUA4slE6ULkltsveo/CNkJ5bPv4zAgwdvEF AeZIz0l2Nftp2umW/a5Yn9pIS+elmn9LResKxrBtr49dD9+cwD5kFqJLXqopkrngSZj+zHipyjk BSAX+JQ/KP/fEw== X-Received: by 2002:a05:600c:a4b:b0:4a0:23f:8b0d with SMTP id 5b1f17b1804b1-4a1af68d397mr8797305e9.2.1791880802413; Tue, 13 Oct 2026 01:40:02 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 20/86] target/arm: GICv5 cpuif: Mark GIC insns for fine-grained traps Date: Tue, 13 Oct 2026 09:38:27 +0100 Message-ID: <20261013083933.1024405-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881456203158500 Content-Type: text/plain; charset="utf-8" Annotate the GICv5 system insn cpreg structs with the fine-grained trap information. This covers all the bits in ICH_HFGITR_EL2. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index a829b90f334..be34312d242 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -800,56 +800,67 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { { .name =3D "GIC_CDDIS", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 1, .opc2 =3D 0, .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICCDDIS, .writefn =3D gic_cddis_write, }, { .name =3D "GIC_CDEN", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 1, .opc2 =3D 1, .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICCDEN, .writefn =3D gic_cden_write, }, { .name =3D "GIC_CDPRI", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 1, .opc2 =3D 2, .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICCDPRI, .writefn =3D gic_cdpri_write, }, { .name =3D "GIC_CDAFF", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 1, .opc2 =3D 3, .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICCDAFF, .writefn =3D gic_cdaff_write, }, { .name =3D "GIC_CDPEND", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 1, .opc2 =3D 4, .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICCDPEND, .writefn =3D gic_cdpend_write, }, { .name =3D "GIC_CDRCFG", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 1, .opc2 =3D 5, .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICCDRCFG, .writefn =3D gic_cdrcfg_write, }, { .name =3D "GIC_CDEOI", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 1, .opc2 =3D 7, .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICCDEOI, .writefn =3D gic_cdeoi_write, }, { .name =3D "GIC_CDDI", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 2, .opc2 =3D 0, .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICCDDI, .writefn =3D gic_cddi_write, }, { .name =3D "GIC_CDHM", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 2, .opc2 =3D 1, .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICCDHM, .writefn =3D gic_cdhm_write, }, { .name =3D "GICR_CDIA", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 3, .opc2 =3D 0, .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICRCDIA, .readfn =3D gicr_cdia_read, }, { .name =3D "GICR_CDNMIA", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 3, .opc2 =3D 1, .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .fgt =3D FGT_GICRCDNMIA, .readfn =3D gicr_cdia_read, }, { .name =3D "ICC_IDR0_EL1", .state =3D ARM_CP_STATE_AA64, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881672; cv=none; d=zohomail.com; s=zohoarc; b=Qx9UUSb27a0SNiMdlsVWpW59iA/NV5Kvx1hS99PJ68MkYo6Qmp5JvLxLr8Iuie3i57T00wWhbsOBge9ZuwFH7vxTBKTSzr0uQXO9B4D6x/2R73/RLqJlzWLtyHzhdBtOOvWz0/Ky2X/2Gv1meReflU+1uRK/Y3rsQWBrks3kqh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881672; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=8uQRGGo33+t5uuGFTo4Z4S7EgGCw82RRO0sVfMQiO1g=; b=dXDwG3MikTzZ+vv+ifrS5Qbm6gh41ylv0lCdElDP2vB7BrU4nHX49TGy7OVmKigIAqFgY2gu71dKeTI5L+X6CzCDcuGCn1y1wK8cwo2SsdFamo54vXa/GHWvrmRZI/RChIBGnszhN4UIG2v2OrBVyZiLZKKwZ1z4WqJZHqXEXb0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881672187574.2874249250833; Tue, 13 Oct 2026 01:54:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3s-0008DC-8S; Tue, 13 Oct 2026 04:40:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3S-000774-7M for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:15 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3L-0007p1-It for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:13 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-487049569b6so1851182f8f.1 for ; Tue, 13 Oct 2026 01:40:04 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880804; x=1792485604; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=8uQRGGo33+t5uuGFTo4Z4S7EgGCw82RRO0sVfMQiO1g=; b=pI23lG78nJg3xQ4N/7hdnQNGXYZwk/4oXoWd9bUNxrxBWTpOF4+1nlLyrhLoeiC8OE LbBR47IOIuDEQKOFrS3clwJKD7pxLzIaQI4NS3y66MI9Bn3qbAuvCN4yksZuPMV5utTu 3HYB6P89ZUsB2vmH433t2Xv1PbbRALYvGeVDuzAB+VyamSac9dVOvbvyH1HVQMq4Nl+E KjSOVOcY1IGxAIKuFGzyXbbJalwef77p6kSRO7lKt7bM+kD8Q9s1hjcexKEKeBE7y553 7jpuJqzEW+XVCR+8zEZaCCH0FngcQrFKeYD6RWXfJ30B5iCN3ql5fitgbfVc8Q5U62kt wtgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880804; x=1792485604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=8uQRGGo33+t5uuGFTo4Z4S7EgGCw82RRO0sVfMQiO1g=; b=rZqf/jprZGjW5fKSd47xGdG1IsnbNh6MH6bIOGm/D/LfdeH1cvsD40g8QQtZFnGKRT gQzfOJQqBNLJ5FjbeYk3y5Y9LfgojJUL96BVQKACSl1wyRrXAyDjNJvi0q/Oosrpl2rM Nggel6Qpno3a9qoIhn1qMbHLv9W9ZD/mJqbvv4A/RghFDOTaaP7MIiWA6p+f99ncBaxD rV6rsAOiusLWqQTLXJJ8UXYf4JIzNB8jp9MUVKrZ6+fFJ+jbY5kpGp6jJE/btAObcvlY wuWaLPo0lwDvMa3Zo3Y0vlFfOHVi+Nsz+uc+MEOKSDKkH/cu7vbMgY9DqmfjGQ+1Gdne Sa2Q== X-Forwarded-Encrypted: i=1; AKwUvBzb9tIrvqW49TAhUwbVN2zSXFpbdBt5/Rx9Ngr9DHG9FivhZpvC+j3UxIcbx87IxKXKTRqY1KfaKFsG@nongnu.org X-Gm-Message-State: AFq9FYIQH0dNv4kQAylrTyKokMLKyHsbse/6tEhzlndqUfQyQtXDPN2t 0JvgvhFa9bJhj9hGSop9yCxb6ag0JHCpcczIuAKilNrSLPgJg4+1zKBnzdbyMHTZKJ0= X-Gm-Gg: AYBFou11eUltcd50PbpmBszYHIWakUT9dlY4Ul9ZxRgVCS5EZQpWEvwbk2shYuCs1p7 JWnozfrnyu+bzXt3TpkcKl+N5so4tvi6VfP/Z6WOZ5RXO77Bv+a2CFgiiJIyPV0xBpoAcx2iEF9 I6YkViwJlsLGTs6geB3VAUX1wDw9XFS7gP8vcdKlLvyxa6RmCI39cYgbtK/rMLjoiHG+sG0unnc Fg+phuk8TMNVFqRw7Z9W9ycwkfHSwgpOKwmgvBbos9u/C9KaKmk1tGEFqJFoUACW1LllxByYLy3 P62uAGqScMAPBoIPu8+8EL2Ibp3L4C6m87DTV2LofWLt7yN9xPptGuT/Gdu0fKF0q5xaRMaN1n0 ykOVO5iw4d0HO0NSIExZSDUIEZKhwd3HGV20VpKDB6EeFv93XmMM4Ycn5lYmt+gm+04CIpRLqkj MOMyCYOoWaRvoRj4Bek9EsPm+9tPq/BJfP27Rbu7nYVzU8n15YBr4k7O1/0HGe9u3reMBNC0+Io EkRdtXSbgTnfqPrKmNiq+lhe+/A/ZKnj6lsGE0JB9WLOBH0ubc5GtkrTdV7dKfQvAEjogW/NPcA PTvrBF3sDzdszg== X-Received: by 2002:a05:600c:1d0e:b0:49f:ec98:f030 with SMTP id 5b1f17b1804b1-4a18e4e9db3mr236851375e9.33.1791880803659; Tue, 13 Oct 2026 01:40:03 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 21/86] target/arm: GICv5 cpuif: Implement ICC_SRE_ELx Date: Tue, 13 Oct 2026 09:38:28 +0100 Message-ID: <20261013083933.1024405-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881672348158500 Content-Type: text/plain; charset="utf-8" When FEAT_GCIE and FEAT_EL2 are implemented, the GICv5 specification requires that the old GICv3 ICC_SRE_EL1 and ICC_SRE_EL2 registers are present, with RAO/WI bits, even if FEAT_GCIE_LEGACY is not implemented or enabled. ICC_SRE_EL3 is not present, but the CPU behaves as if its Enable and SRE bits are always set. (See R_SLVXV, R_MCTMX, R_HQBBN.) Implement the ICC_SRE_EL1 and ICC_SRE_EL2 registers. For QEMU, this "all bits RAO" is identical to how we implemented it for GICv3, because we didn't implement the memory-map register interface, we didn't support IRQ or FIQ bypass and we took advantage of the IMPDEF option to make the ENABLE bit RAO so we didn't need to trap lower-EL accesses to ICC_SRE_ELx. The RAO behaviours correspond to "do nothing" -- don't trap system register accesses, no IRQ/FIQ bypass handling -- so we don't need any special handling in any part of the CPU implementation, just as we didn't for GICv3. Because ICC_SRE_EL1 is EL1-visible but only present when FEAT_EL2 is implemented, we need to put it in a cpreg array that we only register when ARM_FEATURE_EL2 is set, rather than being able to list it in the main gicv5_cpuif_reginfo array and relying on the access field as we do for other FEAT_EL2 GICv5 registers. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index be34312d242..8cb790204f1 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -1017,6 +1017,11 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, cp15.fgt_read[FGTREG_ICH_HF= GRTR]), .resetvalue =3D ICH_HFGRTR_EL2_RES1_MASK, }, + { .name =3D "ICC_SRE_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 9, .opc2 =3D 5, + .access =3D PL2_RW, .type =3D ARM_CP_NO_RAW | ARM_CP_CONST, + .resetvalue =3D 0xf, + }, { .name =3D "ICH_HFGWTR_EL2", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 9, .opc2 =3D 6, .access =3D PL2_RW, .type =3D ARM_CP_NO_RAW, @@ -1116,6 +1121,14 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { }, }; =20 +static const ARMCPRegInfo gicv5_cpuif_el2_reginfo[] =3D { + { .name =3D "ICC_SRE_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 12, .opc2 =3D 5, + .access =3D PL1_RW, .type =3D ARM_CP_NO_RAW | ARM_CP_CONST, + .resetvalue =3D 0x7, + }, +}; + void define_gicv5_cpuif_regs(ARMCPU *cpu) { if (cpu_isar_feature(aa64_gcie, cpu)) { @@ -1153,5 +1166,9 @@ void define_gicv5_cpuif_regs(ARMCPU *cpu) }; define_one_arm_cp_reg(cpu, &ppi_prio); } + + if (arm_feature(&cpu->env, ARM_FEATURE_EL2)) { + define_arm_cp_regs(cpu, gicv5_cpuif_el2_reginfo); + } } } --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881117; cv=none; d=zohomail.com; s=zohoarc; b=Dzcx0srlVN8aY7XFTzLuaOcoelGfKrY4/dTvCKAI1BaXCS6WINoKSSTzfP/sMAiXAWH0PCDRF3dEwywMal5bsrEs0v+XpJlI5ssh6jJhZ4X4AndMIayF2cGdIx43Lf3xq59LPLNnpptWHegOgfv01EseCIqKG4YjO4ewxv+mF5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881117; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=iEX+WzxiZFfdpDo3ifOhYecTGAzyVyR7DGadGLTp9Rg=; b=EtHk1kwp50wG8mVYPfU5xo/8jEtjhmc5k3ZNKl/BOoFgsJjSBoi6kgk3G2Kb7p2+/SwHoKakxvQxZ6etsHwW6wAn+y7YzGBaRBd/KIZ4WjbGBtjhiSls4nBmmzBnyk+voML41RnsAdpQiH1DSx61UlWXVJfwX2n3sH77uyiiefQ= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188111773153.92681231154677; Tue, 13 Oct 2026 01:45:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4M-0000oC-Ku; Tue, 13 Oct 2026 04:41:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3R-00076M-F9 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:15 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3L-0007pS-IA for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:13 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a061a13884so23058945e9.3 for ; Tue, 13 Oct 2026 01:40:06 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880805; x=1792485605; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=iEX+WzxiZFfdpDo3ifOhYecTGAzyVyR7DGadGLTp9Rg=; b=IkRMtWW3tafpC+OYylMBOA54VUYCzHt8Two70H4zkbTXUuVCXGElYbsKqVsLnZlSCV fA5KgbABfA6bbYkbOz0az2PKXKnn3mD0WpK7kE9AqinqjeWHIYt9kbMScrDk3waezSq7 MfWngMgo2Jm4wMI2Q3d1etpH10YYAdnzbcMHBISZUCwTBdDwvizvpZpVmZ0vxQeP4P36 SY+CODaGxHsLkQYJqBxVXoj3kz18TmVTagCVqfFot2cQmXRGgCkG7zlt9YGsHv3SXBGh Wb4uDhTV7j2JgbPdHzl46c2GfM0NfHogHFVqhzqF/2ZqZzGKL2QOvH6DD/evSQlt1WIj fGGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880805; x=1792485605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=iEX+WzxiZFfdpDo3ifOhYecTGAzyVyR7DGadGLTp9Rg=; b=uRoSYzRjLeJF4ACnWydSRuUiDQ1vOjEBq1CyJBr99GpILW6y3+6CX/KeRXWgdFcqA7 BKuXexLqGQ5EPQxJIeBxh4eEGNFyy4QJI94Eh/XXYkcY4s5g0hZbedcIbF/s1W5OTYCI wqdM4z358+o7XMWCPdsAwpe0xtlHUJoWRQNCOirzmV66ZqoOInwW0lQBzlh55Mb5Rx8T PKiJ1YhmAEnpz0RHA2yEDNocp/xDpiH+rinGTg3bqeOB4dcUk62bxUEBjne9Cb6UyzDf +K6rYQXhRWSRJImhVaxxngdNXKnmZ2Az3WdDLaCMdlP1W8eAS9Qf++AQbHIXw75bB8qb 5EKg== X-Forwarded-Encrypted: i=1; AKwUvBylQT3/ERY3Q3e1SvwLzwA6N5OVkQ8vilYpFCI4B9DphYD1ZNAmeG446VR8zM2vnOe+iJP6fzLDFu6m@nongnu.org X-Gm-Message-State: AFq9FYKbI2UE2vzKRlzjfojSa1Ye+ITDdWuaENSvdYIuyvtqoaBuVZB1 30Q9f5/J375h5JPEBDkP/bBJ6xgsSWThyzvT4VVeCNywUsgz9oN8jFcik0EZglo1sVw= X-Gm-Gg: AYBFou1nyrh3hfWxWELHMwPgRYZ6tds2YhgcgRYmTmcu/yNHc8hDzdXpv+rO5CYXUzs 8pKcOaKkPzrOILUvORzgD3N9kTSYb2gz8tiUGntnz/Pnmlcw54Xt38my14BN/QAZcJSiZYg7dQI Kw6k//OJ7ZI5baIDl9YiMrPCyvB8gp0QMI0SkLkI/Q6cWGJJxTEMpmRowjm+hhIlVFeWvSq2Ach G5CZW4CuFVergukagHBLGD0k3DAxHoNZzou1MBvYixtXN+XuYLxodZG5HEDwO27vcKzSWrTmeoS M9G3PVAYYQqzg36OKpKLvbzZDSjawZcN8jDX68dzHAkNnYZ+LRWJIYeU9Dw7p9pS19ljS9YbMk2 dkmEiWvVikKGp2zju7FZ8dsDyQFJ8c+sPEBqmXgqKLJ4RULl2Kg+ZY1xmeZg6/juSwaToVHxYVl N5P9i7MX2syH1PmG8LfLo4W3oM5dfaq0EcV8/gHo/RgP48MIrvdxjyEAtHBQ23HV2QQfThgNdaF Dn1p6dqjro06+T34h1YkNXG5x8IECbxzyke6etZ8EXJDOyyww5J46dBGNG49OWU0SmW1j9er/TZ Yh4= X-Received: by 2002:a05:600c:4ecb:b0:4a0:c01:1902 with SMTP id 5b1f17b1804b1-4a18e43a29fmr236742755e9.2.1791880805159; Tue, 13 Oct 2026 01:40:05 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 22/86] target/arm: GICv5 cpuif: Implement ICH_PPI_HVIR_EL2 Date: Tue, 13 Oct 2026 09:38:29 +0100 Message-ID: <20261013083933.1024405-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881119775158500 Content-Type: text/plain; charset="utf-8" The ICH_PPI_HVIR_EL2 registers allow a hypervisor to hide a PPI from the virtual interrupt domain. When the bit is set, direct reads and writes to ICV register fields for that PPI are RAZ/WI. As we haven't yet implemented the ICV accesses, all we need to implement here is the cpreg and its backing storage. We will then be able to test the DVI bits in the functions that add ICV read and write handling. We give the register a writefn because eventually it will need to trigger a recalculation of the virtual PPI HPPI. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpu.h | 1 + target/arm/tcg/gicv5-cpuif.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 276466d2b84..81fb68facb9 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -600,6 +600,7 @@ typedef struct CPUArchState { uint64_t ich_apr_el2; uint64_t ich_vctlr_el2; uint64_t ich_vmcr_el2; + uint64_t ich_ppi_hvi[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_active[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_pend[GICV5_NUM_PPIS / 64]; uint64_t ich_ppi_enable[GICV5_NUM_PPIS / 64]; diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 8cb790204f1..93141c751e4 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -493,6 +493,12 @@ static void gic_ich_ppi_dvi_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, raw_write(env, ri, value); } =20 +static void gic_ich_ppi_hvi_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + raw_write(env, ri, value); +} + static void gic_ich_vctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -1002,6 +1008,22 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .writefn =3D gic_icc_pcr_el1_write, .resetfn =3D gic_icc_pcr_el1_reset, }, + { .name =3D "ICH_PPI_HVIR0_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 7, .opc2 =3D 0, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xc00, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_hvi[0]), + .writefn =3D gic_ich_ppi_hvi_write, + }, + { .name =3D "ICH_PPI_HVIR1_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 7, .opc2 =3D 1, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xc00, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_ppi_hvi[1]), + .writefn =3D gic_ich_ppi_hvi_write, + }, { .name =3D "ICH_APR_EL2", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 8, .opc2 =3D 4, .access =3D PL2_RW, .type =3D ARM_CP_NO_RAW, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881126; cv=none; d=zohomail.com; s=zohoarc; b=j4q13q9yxVFlC03sK7AbXMtw934LEodl+23Luupx1tITweG00284R6Tiy/B2W2wWVBOI5SxT3+flbIJzOM3XRvyWy0x4gHbesKOz2DIm+NFwaSQskWp2CmoPZDjxzBDfqNUvA25L7BHNsip1rP4NLWPDnHT5gDR3vj40RYErNh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881126; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=B1w6uxY/LEmMclAoc4yxHiksAryvWTTi6k+Zr0LKKAc=; b=gA52gx1m3aF/rmsVKvMGxP1KD56yi/XKzdGkI7eKtYoypfsqxAj+sdCVxGiLSZf0ZLdrY2njhe6C0EeuEkVhVFazSUSw+5ofTA1dz2+vH+8eYioPDB3uJoYDaupdYJ+hQTDS9YUKO/wrIKcxPG+TTWTsclHedeFl4Ya3fTDVPB4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881126512726.5288731005585; Tue, 13 Oct 2026 01:45:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4J-0000fS-Tb; Tue, 13 Oct 2026 04:41:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3T-00077Z-3c for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:15 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3M-0007pw-Iw for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:14 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a0286c981dso22788855e9.2 for ; Tue, 13 Oct 2026 01:40:07 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880807; x=1792485607; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=B1w6uxY/LEmMclAoc4yxHiksAryvWTTi6k+Zr0LKKAc=; b=GCcG4gJz+49AB+wk5seIVt04U0JAupgbwBHNjGyeCRk1zxseTyWRH8028s+EGUdAnQ bTSrvzkhbWtipqJmbFPvnoVrEt0PQJ639zwVMQnriJW0ZpPGcB9H6Mlf1QtDNO52JXz8 paN3oBom5bfIHe9223drrp8HVlugXZ5IholX57BTepsOyLqLzfDMTlRjh/gb0CP7lPyk /ormPfB+EtLdPPzGAx6ptJ09oDeUsNueeadtIK90pWjaN2av8sPUHW2fmJ19U3XtPRB9 4CHDkZAN3YFs0oUY5SXC/0+hg/iPab9b5otuwRVuyf4xqbthmEgQFKo1WwyVWw9D+HDQ KXcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880807; x=1792485607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=B1w6uxY/LEmMclAoc4yxHiksAryvWTTi6k+Zr0LKKAc=; b=B7B66PsB39C57j+N92z9Ogz5FBSM78lUcvTY28FQL9IHWeO0rJRVemQLCgh08TF+pe +NL1JvCptaDxFORgCmO+guBQNgDm9JPy29b+YadqyNJXbuSgDYq2UuJeOJmleXv26Z99 5wRffENZrCpRnQd/2qqWr0d8yRgVcPNHYTkrlJRPWTdmomMO4V1QUSWvBj2MnyOXFAVf f1GTA43q13nLLgfGwI75ufzwtOVeVBdIzyd/PimfOyVLZlD/Z3GaANwCdKLKrojQuzto nj0gNzYPCFvaHBftXJyM2alo10PVabF2akKTey88yVHR7JdA81PEtxd+Ph6CdEYK5Lw7 yGlw== X-Forwarded-Encrypted: i=1; AKwUvBzYkkW1Dx9IL6HpGAUgDowQsV4x/pxyqSWJ42xX8CvbifFxpniwv8lxVy7dtE5z3OMtbj6u/JSsESIC@nongnu.org X-Gm-Message-State: AFq9FYLn5rKnyluL/ByBdJTnjzHVJ9osyHYHc6ugHPXsoWp/6veuureQ NOpZdeIAsFUiQdLva0HNf0BqBOr2ZpThhtcPV/JZfrEBgRSB+han3oqclX2Wb4HjuFJir5MwKrz u9IYnXPI= X-Gm-Gg: AYBFou0M5PmxUpW2YwW8xGZa1uXWobaPXAoOlWtGzNpLmZfzGMw+xu0vHtcwMY8keWb bUjLgagUgq4Bn1L70vlXVd2tBVHPQdihi9loFSXScrpf1W0Znso+Czq220ltDgEYg3ZXeJpeRUA FFofVAiOudRx41hG7m4Lh2aWYtq0fNvPLZx0hT00SD0ouP4xspsh9gCqHAOvY/SoTTYPAIhfRad 4e90VnWve/4le1P03Pkgj5nAzkGx8XmUqWuDH2zLhULZ8tJb6nj3qJdUxMQwJGI47cCcoF+FjYH a8QBcRaEsKpY6U6f511BHVSSG8BWIpq+pdYHduTLWNHhdssVTtboW/KwTBBY3VzoCJCk0HsSwwm B0PRzbPZl9PtN15qCUMcOL6dsy0L446oQJUN4+aJ1TNALzy1BIswvHDw1XSv6ztKuECtkgNJnxd 8M86DjS0gB+mldRJ7PMaQH59AGQoMYx6/g5fLIjeEJ9jz9dSDQ77Kavq4lmJSb8UGenSlEycn3m KKCg8sizTV/+6WSfY3RtpVReOvW6n+sAZ6uzB1RT1V3uG5BR6lv8wVY4yOGWpOFIKeP2ff/k0q8 zrg= X-Received: by 2002:a05:600c:8216:b0:49d:34:420d with SMTP id 5b1f17b1804b1-4a18e4b0465mr233700905e9.20.1791880806655; Tue, 13 Oct 2026 01:40:06 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 23/86] target/arm: GICv5 cpuif: Implement ICV_APR_EL1 Date: Tue, 13 Oct 2026 09:38:30 +0100 Message-ID: <20261013083933.1024405-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881128046158500 Content-Type: text/plain; charset="utf-8" Implement the redirection of the ICC_APR_EL1 encoding to the hypervisor guest's view ICV_APR_EL1; the data for this is stored in the ICH_APR_EL2 register. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 93141c751e4..b183c8a6e79 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -99,6 +99,17 @@ static bool gicv5_legacy_enabled(CPUARMState *env) return false; } =20 +static bool gicv5_icv_access(CPUARMState *env) +{ + /* + * Return true if ICC_*_EL1 accesses should redirect to ICV_*_EL1 + * (i.e. we are in a hypervisor guest). Note that unlike GICv3 we + * don't need to care about HCR_FMO. See I_XVDWC. + */ + return arm_current_el(env) =3D=3D 1 && (arm_hcr_el2_eff(env) & HCR_IMO= ) && + !gicv5_legacy_enabled(env); +} + static GICv5Domain gicv5_logical_domain(CPUARMState *env) { /* @@ -522,16 +533,25 @@ static void gic_icc_apr_el1_write(CPUARMState *env, c= onst ARMCPRegInfo *ri, * With an architectural 5 bits of priority, this register has 32 * non-RES0 bits */ - GICv5Domain domain =3D gicv5_logical_domain(env); value &=3D 0xffffffff; - env->gicv5_cpuif.icc_apr[domain] =3D value; - gicv5_update_irq_fiq(env); + + if (gicv5_icv_access(env)) { + env->gicv5_cpuif.ich_apr_el2 =3D value; + } else { + GICv5Domain domain =3D gicv5_logical_domain(env); + env->gicv5_cpuif.icc_apr[domain] =3D value; + gicv5_update_irq_fiq(env); + } } =20 static uint64_t gic_icc_apr_el1_read(CPUARMState *env, const ARMCPRegInfo = *ri) { - GICv5Domain domain =3D gicv5_logical_domain(env); - return env->gicv5_cpuif.icc_apr[domain]; + if (gicv5_icv_access(env)) { + return env->gicv5_cpuif.ich_apr_el2; + } else { + GICv5Domain domain =3D gicv5_logical_domain(env); + return env->gicv5_cpuif.icc_apr[domain]; + } } =20 static void gic_icc_apr_el1_reset(CPUARMState *env, const ARMCPRegInfo *ri) --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881504; cv=none; d=zohomail.com; s=zohoarc; b=WHfFllEQbi59TSudSJNsi0yqm1344qja/eoGG7X8gHt9T4YBghP7Y7q/PsBY9ouKHBhdod9oZNipUmTkuEhb0kXWV4LCv4RWJCemVI1ngjIZPqlUfWBGUxH5i4NzErp4ImOg+dvUuUK8S246vlGbIH+HvJZjLdkypJ1VumbG8pM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881504; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=FFC15qOUGo6FRd9B9ir9SIKtB3uGsFYdGz30HW4TUIA=; b=QEa9ly1KAyKZwMJ4iofC/sSQ17/j8OhWHEDeNkfUVkLWkoITJv9HybJlC6ZZ1FAehHP3jbBn96FKecrMGjeFIRFv9VC4Y9HKyA+wq4UKZBH7u31HNJIMvSwkWUP7MCSPC4D6ShhNO31ZIoQiffMhB1WeubZA4XmKGueb8tr3S1A= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188150484251.54704501174888; Tue, 13 Oct 2026 01:51:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3i-0007mb-Gv; Tue, 13 Oct 2026 04:40:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3U-0007Ct-An for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:16 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3P-0007qQ-M4 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:15 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4a17baef589so22013365e9.0 for ; Tue, 13 Oct 2026 01:40:10 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880810; x=1792485610; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=FFC15qOUGo6FRd9B9ir9SIKtB3uGsFYdGz30HW4TUIA=; b=XUNuV036M96mWPGF1NzPF0kUO2AI05+bNbKx5rf97nfyXxHXM8Hi2Usuk68H96RKQZ D4CBQjR+wRNhHiXfvg6hOTScpaH+bEv2h5RZwuU4kFeV/hFmW3uPX6ERn4MUuDkfZu11 e+XghbbdZLwE71SmRLgR29NYIbD2AF6Rvo4XRgcbdM2eVefrDHm7uNnWZsBsgpgKrybY B3nkxw1DskrbtzVDiKP5JAh5jEl82n3vvyuGPj+MMqSTzyKD8l1MP+Q5spnISNTLowOL W0ZD6wcv0q/17cTAmOseJrpUsQk5w1fs5FTs7TKFJ1Yow8qOPxUykTPkkOgex7alDFYC I5gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880810; x=1792485610; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=FFC15qOUGo6FRd9B9ir9SIKtB3uGsFYdGz30HW4TUIA=; b=IpNFSg5vLgCPOBJQOPtLCh2VE3Ylf4l2rRtEz9AHvAu0DumZ20/hKtKcTX//dEEuc2 e3HYZjnlFKatxuwRzO5tWB1WUVuL9FunxAjBdPD+PUpuCOXWk5+EElGNiziXMWp/cguc PJIkCc4lkwk80gL8JVqmDDXikYimdQ5FDo+L/t6iD65v/nNnOD8Y+XuBvzdddGbDhBqS FYU51eT3h1wuobXtwj0Cc+e7bvEIkWDXV0RRJsAnlgXNUTN7w6h18LWI6tjmn7Zi9K7V SXW6qd1Ml7EqZ1I/S1+wNMKHHmpDdytX7Z4X7Jyqk5GGcoQJrinZzBXdelomXAPNhPMq 6wiQ== X-Forwarded-Encrypted: i=1; AKwUvBwSttYNnftvm3KflW8RhzmbCrgj39DYXhTkOwiHMe6OzJj6eUX2V7RTkZAxKbLDBA4Gt/BbGz2KTKfL@nongnu.org X-Gm-Message-State: AFq9FYKBq6S56zyybsC+ee9Gq5YAyFlB5o0WKoVEEVpLvaCEjz3eNv+R KLwtPNeq541NHOBq88HDbdSk10gAdZ3oArYCu43KyCMM4lFBm1CxOLr9uAY2+mdYdTq6SJWlZVJ 9HZTZRY4= X-Gm-Gg: AYBFou0zRcq2jQqiaGjTsAdo7FhCDpFQH+33++dFUIzlF0eQ3b2+htMFHNvTdTRhzBk 7ZKrSEs9cAHIgyhrxzkYUWKLIwdJRVPzzZGWtlxTMJfxMTwNj0WnOq87/OQ+jL9oRghpf2YCzH2 +Gqv4yBLcl1Rl0oREBzP8hoSIJXvqmomS+sHRx65sKqv0bCg2sFpPKWmviOuICvNZYF2b1MjwSp r1fMF+lSbZWzxxFFUdLCtoTNdXbqZEQetHvFDrF8FSTUpXdUzVF/GZ3XrPnc+FFKam2GXjrO2pt bxhetIdzHZRGS86E8nqmu5ECWjXdiKJoXNhl8jXJM42Ej12Q3r1lkvLRNkGwAPiPXciEHu4AITA OfV11OgTDqELC3qrvGtw2477uG87Sz07+PvLZCwvDZKy01HCyB3Kdjbyuog0GNny/SGFKXvUjNJ ZdqOHbz3xqJ/scd0QbjDzgIw6cX58WkOv+lU8Sh8vHgS38LP7HL9bHbgotJfz6RGcCVn9w7fK6x awSsnixe4EzTAdXe112PNxT5HGqQW94D04r9qnSrJPxs6Ae6qi9gFD5md5/F4Kf7nz8Kn4zcVVQ i9g= X-Received: by 2002:a05:600c:4504:b0:49c:fc6e:a3da with SMTP id 5b1f17b1804b1-4a18e4a7839mr250549645e9.25.1791880807540; Tue, 13 Oct 2026 01:40:07 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 24/86] target/arm: GICv5 cpuif: Implement ICV_CR0_EL1 Date: Tue, 13 Oct 2026 09:38:31 +0100 Message-ID: <20261013083933.1024405-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881507192158500 Content-Type: text/plain; charset="utf-8" Implement the redirection of the ICC_CR0_EL1 encoding to the hypervisor guest's view ICV_CR0_EL1. This has only one bit in it, the enable (EN) bit, which is stored in ICH_VMCR_EL2.EN at the same bit location (0). Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 41 +++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index b183c8a6e79..247cefd9e68 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -67,6 +67,9 @@ FIELD(ICC_HPPIR_EL1, ID, 0, 24) FIELD(ICC_HPPIR_EL1, TYPE, 29, 3) FIELD(ICC_HPPIR_EL1, HPPIV, 32, 1) =20 +FIELD(ICH_VMCR_EL2, EN, 0, 1) +FIELD(ICH_VMCR_EL2, VMPR, 27, 5) + /* * We implement 24 bits of interrupt ID, the mandated 5 bits of priority, * and no legacy GICv3.3 vcpu interface (yet) @@ -564,24 +567,38 @@ static void gic_icc_apr_el1_reset(CPUARMState *env, c= onst ARMCPRegInfo *ri) /* ICC_CR0_EL1 is also banked */ static uint64_t gic_icc_cr0_el1_read(CPUARMState *env, const ARMCPRegInfo = *ri) { - GICv5Domain domain =3D gicv5_logical_domain(env); - return env->gicv5_cpuif.icc_cr0[domain]; + if (gicv5_icv_access(env)) { + /* ICV_CR0_EL1 has only an EN bit, stored in ICH_VMCR_EL2.EN */ + return FIELD_EX64(env->gicv5_cpuif.ich_vmcr_el2, ICH_VMCR_EL2, EN); + } else { + GICv5Domain domain =3D gicv5_logical_domain(env); + return env->gicv5_cpuif.icc_cr0[domain]; + } } =20 static void gic_icc_cr0_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - /* - * For our implementation the link to the IRI is always connected, - * so LINK and LINK_IDLE are always 1. Without EL3, PID and IPPT - * are RAZ/WI, so the only writeable bit is the main enable bit EN. - */ - GICv5Domain domain =3D gicv5_logical_domain(env); - value &=3D R_ICC_CR0_EN_MASK; - value |=3D R_ICC_CR0_LINK_MASK | R_ICC_CR0_LINK_IDLE_MASK; + if (gicv5_icv_access(env)) { + /* Only the EN bit is writeable, and it lives in ICH_VMCR_EL2 */ + uint64_t vmcr =3D env->gicv5_cpuif.ich_vmcr_el2; =20 - env->gicv5_cpuif.icc_cr0[domain] =3D value; - gicv5_update_irq_fiq(env); + vmcr =3D FIELD_DP64(vmcr, ICH_VMCR_EL2, EN, + FIELD_EX64(value, ICC_CR0, EN)); + env->gicv5_cpuif.ich_vmcr_el2 =3D vmcr; + } else { + /* + * For our implementation the link to the IRI is always connected, + * so LINK and LINK_IDLE are always 1. Without EL3, PID and IPPT + * are RAZ/WI, so the only writeable bit is the main enable bit EN. + */ + GICv5Domain domain =3D gicv5_logical_domain(env); + value &=3D R_ICC_CR0_EN_MASK; + value |=3D R_ICC_CR0_LINK_MASK | R_ICC_CR0_LINK_IDLE_MASK; + + env->gicv5_cpuif.icc_cr0[domain] =3D value; + gicv5_update_irq_fiq(env); + } } =20 static void gic_icc_cr0_el1_reset(CPUARMState *env, const ARMCPRegInfo *ri) --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881649; cv=none; d=zohomail.com; s=zohoarc; b=PDsXsJ9frbK09bc7d1iWhsFcx1Jyz+9B8w17eoHaKeCaSTfSi59GrBbOhbEOWH2kT0OANSnd7s4z7HZX3atVYXUVTvMXweI7HaKZtFjjwa5nfmOD67AkkI7fGP1skZ3T5sGauylXdAWRQm4cv1LXKjiLZ2giWs9Y+slsut06aKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881649; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=4fi3KaUQEy1+IJ+5cSEeFvIQP/QNmNxFWZjQRxfI9as=; b=Y/3USBvzq+POAO1PH1zg0yMu7RNMvBWTAbiHAjozmTysWk/1HJDlVKurLoaU891zt4KSHTDcs36eo1ndsekQItpZJfi1ksds0MTLn9zS95ZCcyxnFIVcKq49L+QhHEccP06lef601hRNxGCVBtlyR5gJuyI4KL+ZJb8HfKCOlKE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881649325325.52330641751803; Tue, 13 Oct 2026 01:54:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4Q-00018Q-VB; Tue, 13 Oct 2026 04:41:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3U-0007ES-F7 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:16 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3Q-0007qX-1Y for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:16 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4a171b677d2so15778405e9.0 for ; Tue, 13 Oct 2026 01:40:11 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880810; x=1792485610; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=4fi3KaUQEy1+IJ+5cSEeFvIQP/QNmNxFWZjQRxfI9as=; b=KfHpZzP1LooLBUS7nCCXO7jW4UfzjU7Wp7nVYRxhTqVcBAHens6oK70Jv73XlS/+BE BLXnMHNG6k27NmVBcXeZNyS2Jgq4UQhB6HPfgIeCUspu/KcyE9ub1v9Du6pkJSptOjfT ZWyZFGt9/2uiKX9Z705xHVFoQLwOAlNFGzQs39cpMPP120JEuIN3FgAPwkfcEs44qXT8 xm7VVNNX/RnYjPDWdEkiLwLybLTLanaY8q1b4jmeGLpNS0di1OoZDkSmXPey/wjBYcyS 7s0NdFq2B7Y9zIzk9IMCS+oWUxi9qTYs3bL7bjOBeZ5eN8/1PqcqhNqtK9QbKW1NNxwM h+SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880810; x=1792485610; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=4fi3KaUQEy1+IJ+5cSEeFvIQP/QNmNxFWZjQRxfI9as=; b=nHPktA786CIAAV83byeEHeWQ0/zz1UPdpWpDsgUtWi1fArhIaoRzyBRXz9Fog4yzwP kS/LPCUzGqeJnkp+mgmdHvLCNy9o47jtlWjIWRtmpHi6s1UwwN4rpPDwlQyUtTD/JwSJ CkDINPFnlC89FhNdh8n2+bNSFDz6hQNYgvHZeyZlewAfFr/GTX6+FR4lx24WgOc+1/Cp 18a0mmyHsZ3np0J538QkJP6JFQztiq0MSYzYIjvcYEOzHrLLZTaJLHvBnIxnN3G/9oid kJw96HnS4wU2ePpBhSL+wkV206Tv7DlHCqjzb7zHWhnyjG63e16AA/n10blyJaHkHXC+ Oyng== X-Forwarded-Encrypted: i=1; AKwUvBx+3hfErSa7Tb9hdnOlED2qm5/2bm1SVEtxY8kKUbBwrZOLAIS8HcMEyOSu4uzFR3/QWH5H5jAWUjxP@nongnu.org X-Gm-Message-State: AFq9FYK0oZ7lj7K+bqwaCnLLqGxjIFeXWu8V5Dug5xa32nv2wGRag2YT wSUawvg/W3WTS+YKrZdiUPUU1tjr5sgAmzrsVP55LrvHxBTekPHPdG1VzpdHvQKsrPPnIWH1O/N kGTwgkCU= X-Gm-Gg: AYBFou0useSjKrXF9UUvMY7qf3dDOFr3Zvk7vaQFwZWt3NadmLhFihlwQTg5yGZy0WK u7LTjxu3fN2mNB3zQlnxGe6JXG9dcEsH228sf8tqEyim8AgafOq6LiRJ5PCApOXKR0MsN5CMIsP Ywvn8mOR4ZEKth4hHxiCaMBjCx7w81HUSZ4eZCuoArzkrNkRiRUsKj8Ofofbnh5DXJRPdK8YypB uYoC3j0XHhHnq31P4BawJshmn2IfiRT5c/32t+gg5JlG5CIvvokA6+JFH1wvRkxBzKevYb4vwVv DkvmYnLg5+tqQNEci4KIXCFU9J7yEaRcYQTqE9yzYo9800NKnAeDG0Q71pjc8bGaHbLAQMFIOux XluKgO5LbFKtVGh1SrB/Xdvurcd0Rkvkr3mZ1RfAzhETBRnx7tHzFOnuYrvAqzJCIGZz0Egci5J 0l2k+Vdc80XzOwm8xUjeMuHQPvbIoUBine4NqUx4x2q6HJBUn7uIPbOBxpSlslzDXDlt6Ru0rvu zdRoSsWS3RKqlt0IrcxMzkciMSkaQ12v8xMRTs5278QCRyq4lomq6vi971H5mAMpBESLWNNKu7b v6gK0PycNaWy0Q== X-Received: by 2002:a05:600c:348d:b0:4a1:813f:2a63 with SMTP id 5b1f17b1804b1-4a18e4aa26amr220023575e9.18.1791880810486; Tue, 13 Oct 2026 01:40:10 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 25/86] target/arm: GICv5 cpuif: Implement ICV_PCR_EL1 Date: Tue, 13 Oct 2026 09:38:32 +0100 Message-ID: <20261013083933.1024405-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881649911158500 Content-Type: text/plain; charset="utf-8" Implement the redirection of the ICC_PCR_EL1 encoding to the hypervisor guest's view ICV_PCR_EL1. This contains only the PRIORITY field, which is stored in ICH_VMCR_EL2.VMPR. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 247cefd9e68..125dcd8cf4d 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -612,18 +612,32 @@ static void gic_icc_cr0_el1_reset(CPUARMState *env, c= onst ARMCPRegInfo *ri) =20 static uint64_t gic_icc_pcr_el1_read(CPUARMState *env, const ARMCPRegInfo = *ri) { - GICv5Domain domain =3D gicv5_logical_domain(env); - return env->gicv5_cpuif.icc_pcr[domain]; + if (gicv5_icv_access(env)) { + return FIELD_EX64(env->gicv5_cpuif.ich_vmcr_el2, + ICH_VMCR_EL2, VMPR); + } else { + GICv5Domain domain =3D gicv5_logical_domain(env); + return env->gicv5_cpuif.icc_pcr[domain]; + } } =20 static void gic_icc_pcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - GICv5Domain domain =3D gicv5_logical_domain(env); + if (gicv5_icv_access(env)) { + /* The PRIORITY field lives in ICH_VMCR_EL2.VMPR */ + uint64_t vmcr =3D env->gicv5_cpuif.ich_vmcr_el2; =20 - value &=3D R_ICC_PCR_PRIORITY_MASK; - env->gicv5_cpuif.icc_pcr[domain] =3D value; - gicv5_update_irq_fiq(env); + vmcr =3D FIELD_DP64(vmcr, ICH_VMCR_EL2, VMPR, + FIELD_EX64(value, ICC_PCR, PRIORITY)); + env->gicv5_cpuif.ich_vmcr_el2 =3D vmcr; + } else { + GICv5Domain domain =3D gicv5_logical_domain(env); + + value &=3D R_ICC_PCR_PRIORITY_MASK; + env->gicv5_cpuif.icc_pcr[domain] =3D value; + gicv5_update_irq_fiq(env); + } } =20 static void gic_icc_pcr_el1_reset(CPUARMState *env, const ARMCPRegInfo *ri) --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881647; cv=none; d=zohomail.com; s=zohoarc; b=Ve4KlOWzOh2+7B9zP8MUBVXpf5TcAxIjH6YLENpfh4x1dyWf5fxpUwvOrriEvfAsgnccl2/SHM2RhzADqisy4fGoNCcuMt1nTKT5p/TXIdu7aik2wjUI10XNag7CG2UMY5WLmEJKMcGyy56elhmw0x3NLWiYI41kYKf/01EnDGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881647; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=4zMTZd7IrsEt0EnquPhNbZyBoyakwm0X4gRcwyF+QHw=; b=G/kQx+WoFDrEkHfqKqpvy8KJTd9x+n+WEssuA6Iss3av+xfuJoy91YxDt7bd2v3mS0iWSZfXXc007mWqBUVpL9ItKma5TmssfepicPLmhtSIWRVXYpMEhr56CkBNicjKFPpDJPD4ZbeFZjPbqm8gt7ZaWCUHpN4TxcrWF03AcFU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881647399483.4047148683069; Tue, 13 Oct 2026 01:54:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3n-00080D-7f; Tue, 13 Oct 2026 04:40:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3V-0007LJ-V7 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:18 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3R-0007rd-JW for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:17 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-48af27fe287so2300225f8f.0 for ; Tue, 13 Oct 2026 01:40:13 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880812; x=1792485612; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=4zMTZd7IrsEt0EnquPhNbZyBoyakwm0X4gRcwyF+QHw=; b=rMyKJv6xU46W7RAKBEupIm3obwSCkOftKbBq2Dgg5enz8R8oyGz+NdTxJNFHeTicKE dPMIzb0HFD0f7O7TuQHBmfw2zqO0WTPS5YNtXxf35Y083igu7B4WYWB1PU/96clv3yoH aX8RHZeXT7TTD3uM/Q9FKBYeIXIuOodUh8dfVFsHjDiNAcaREnQwzmetJfwPQ2jaRSqM HOiOckDvHJSywrxZGQNWrzTWxUzaty5Ipybhev+6UpB7zXisAuT98wI6rt1oaiUnZGjS JWjZC/etRHiGPyssbpdOK8BLrZaNdbmhbC1eCWEKfIDOmuEyrqqXGnNpvFWDauALp/GJ BmaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880812; x=1792485612; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=4zMTZd7IrsEt0EnquPhNbZyBoyakwm0X4gRcwyF+QHw=; b=JR8eRytJNua/8ZM8CdQatobKP3det0LPTJg9Zvdc+pwjrNkhR0DWP3ZdKb6zKl9gIY OGbz3VL0lpfbXF1yWoUt4yugC5v0pz+YWuSCZwnHdnWrwQ1PopoMzgLfgLK2v3EUBG+E Q8gD8brnrGHwsFzYHXdShrXEYY4yHrnvGMEp7rmXfZjytqHP7dfruo7E80q4B+J+mmMo ADj6k7nFcxjDvff6okD7O/tS+kMPOe+3LnX2/9qHWCXaMika2qp7dFxyKB1alOSpAbZW 02hmWAnwY1M+3OQJQ+QzlNXHiwu4DKKtb22O71Wl3gnhSx7z1Tt+C2GA0va2n1zfPi8y AQXA== X-Forwarded-Encrypted: i=1; AKwUvBwcI/aKtynFJ4noHlbCwMu+a+P6uXPFBarN/fQTXR3R9Ts0xQPWQB5L7XDGj4LmgQfO+bDxLSKOSP2p@nongnu.org X-Gm-Message-State: AFq9FYK3HlnuSs5rokv/p2tWy5u3PTXPSuMkyOf5OIjlQsWdgQD+8a3L 5CGs0DP/XSUV1TiRiBoATphafNourZIJzbipbLwYXc72mmGAFJR+qM+f95isdA9oOO0= X-Gm-Gg: AYBFou1KplpQ8dpjVMNMBd8lckKIJugjui1wwzHNsCCW6rey9t8TngDc87uAo5I5Cat 1c+lbWcPxnI9/uCroTutuyteGIZUtIU9PU+4clnp2yE+lM8xOeMkxQb/SQsG9EDlk5StqwrC1A1 SPEHxBIZ+pq5BQ/pDtIhmxi7a5DLVY2YOaVxRiWlzktSp7nMNYZEkqXwuPaNtK2yAreuJpk5iG2 rVmKcSbhSmDBz0OPtEprR9LtfBqupcFEiQnaN2ijJB7M9DtlAaYIoRHmz8rHHvdRPF8gOOV+IDt 6wJi/JxwXr3eg7kBjHhZCrv1qHz26inbWoqW/owo7EoGVA5hNpb0YStGMjTzAah+0Mx0BuWnWhu BEC/ZEocKNgfHycWxVJVXEqliTtJOo3QjLHOaYBFUheKBieCbyBhAoq+Hn4k2xKtSHvyl1/yyba vHKySCcXR43OQlgak9lUjZB3ep5LHOYy53/1jhFF1sWCbAxLQ2vcis0cr27GhdPJhObva1LMHbf fGPQidYFSTbl01CwQUnUMtTRCd84ETOOR2tS2cLCW1OcHOVkify3v5ie0ACArvIrif+lCKiEcR5 8avmuav+nxIJPQ== X-Received: by 2002:a05:600c:608d:b0:49c:cee0:e7c1 with SMTP id 5b1f17b1804b1-4a18e48d45cmr248217005e9.16.1791880811970; Tue, 13 Oct 2026 01:40:11 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 26/86] target/arm: GICv5 cpuif: Implement ICV_PPI_ENABLER_EL1 Date: Tue, 13 Oct 2026 09:38:33 +0100 Message-ID: <20261013083933.1024405-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881647863158500 Content-Type: text/plain; charset="utf-8" Implement the redirection of ICC_PPI_ENABLER_EL1 to ICV_PPI_ENABLER_EL1; the data for this is stored in ICH_PPI_ENABLER_EL2. For the ICV access we need to honour the "make this RAZ/WI" config bits in ICH_PPI_HVIR_EL2. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 125dcd8cf4d..2c717b99a0b 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -463,11 +463,28 @@ static void gic_ppi_spend_write(CPUARMState *env, con= st ARMCPRegInfo *ri, gic_recalc_ppi_hppi(env); } =20 +static uint64_t gic_ppi_enable_read(CPUARMState *env, const ARMCPRegInfo *= ri) +{ + if (gicv5_icv_access(env)) { + uint64_t r =3D env->gicv5_cpuif.ich_ppi_enable[ri->opc2 & 1]; + + r &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; + return r; + } else { + return raw_read(env, ri); + } +} + static void gic_ppi_enable_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - raw_write(env, ri, value); - gic_recalc_ppi_hppi(env); + if (gicv5_icv_access(env)) { + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; + env->gicv5_cpuif.ich_ppi_enable[ri->opc2 & 1] =3D value; + } else { + raw_write(env, ri, value); + gic_recalc_ppi_hppi(env); + } } =20 static void gic_ppi_priority_write(CPUARMState *env, const ARMCPRegInfo *r= i, @@ -998,6 +1015,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .fgt =3D FGT_ICC_PPI_ENABLERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_enable[0]), + .readfn =3D gic_ppi_enable_read, .writefn =3D gic_ppi_enable_write, }, { .name =3D "ICC_PPI_ENABLER1_EL1", .state =3D ARM_CP_STATE_AA64, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791880854; cv=none; d=zohomail.com; s=zohoarc; b=LmuXCec7JSFPfMYhE5tiqBKgxApGe7dariH/qhrWNYDfA6BqHOVe5nCHi5B6T4+UcMeqAdtXsd92ENVB3S158sKNKK5DylHW90vH4KCuyM+tux84F8cmoUSYxf6DeD3mHOWnsJCQH/DSAUbu083v9BNHPvf8Dk4E6W60EeDC8tQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880854; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=rsG3TCscVd7PYoqyQA/dMMFq21JiQcdL/3Au5s6HFt4=; b=N/aa0l96DuQkMfzhS/MU5RzqpMf/i3WOE4Yo7p/KT6HsV5mzU8/fP6NGPncUsegFNDV927vOZl3S/I45uuAtu1MXel1YRIhwsObsZ0jJjapGtXhJ4xLwPwe/AvV+4Wjx02mpa8Y27yi83iLyS79NihBixXV0sn4YMgJ+isV1lw0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791880854745974.841858633359; Tue, 13 Oct 2026 01:40:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3k-0007rP-SB; Tue, 13 Oct 2026 04:40:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3V-0007LK-V4 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:18 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3T-0007sH-3z for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:17 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-48441a2ba1bso1543845f8f.1 for ; Tue, 13 Oct 2026 01:40:14 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880814; x=1792485614; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=rsG3TCscVd7PYoqyQA/dMMFq21JiQcdL/3Au5s6HFt4=; b=gkuYDE/x+uxQlelbg+HsK0UVNrhrhXPgGLajX387YT3QA2dagnAQSuqrH1AAuz3xEG jBx9JN0Pbonw9E+peFB1NVXFgTkVU5Z3iPp9Q7DPX5kTirVMpN9o1hMZ9eXUU9Re8vgs slSiL/1dAd9cFmv+mzlyYWtK59QZB77B8wLcCHj+HNq/NtKyihtcQElTac3DAWbUrBbc Jn+P4fUTWrK6wkQ4fMIQJsMrSDVJ34Q4wA/tPH9p4qN3uuYxVUZA43h7mAlEngf2GQ3T W34gUerG0ltlJZ6efARnS0cK3gM+6Y7qEKyZHoQ3linbpKVLqCqT592qq47da+p8YN1T ZugQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880814; x=1792485614; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=rsG3TCscVd7PYoqyQA/dMMFq21JiQcdL/3Au5s6HFt4=; b=nJZ3Z9ylEt16hxr7fuAPINH5UrDj0pzQ10xnXkKak8nh0ROB6rCcyypteh+McHI+i4 hyMTfrdqkwrCN9/tGtLQR48pRhSmkg3lHIOS5jbCF7OjLbcVdHhQZn8dapGqzXcZGw+K UnxPcCo59NCF6BgMuGtQMycn2jYCgDv+waSDmN9Mp1re4X66kJy/OQ+SAdmg8XfqUVPr LcGOXimYZZYuSRV1noWqCRVwhOF2Zx/LlnBQ9WE9pqf48Neu9Z8Qk3G3QWDq6UmUonTZ 2XDYklzt9RFBXqhzJVjHVO4W738CpUTn23s5043SSYehz/Oy8q4vOUgpsAxlpcv9UOvw 1Zqg== X-Forwarded-Encrypted: i=1; AKwUvByUEAz1dbBz2LpKmpPnG99BxJ8SU/Xe6H2Wf1cTJz27SnNIkp2NOAHLZGJ+K4VBA4SvXDF0OaRqHRYU@nongnu.org X-Gm-Message-State: AFq9FYI5bid4bdnxEEpJK0uFOQ0Kx48WsHzKttH5SNiqTnxdj8ZleWNl qW8dLjtVRMDsOiGd+lslLTSK9lByts4ej10sZvxn6nlgZpOp7DFUe0Uix5Ts6kxWqUxO9FT45wK 4kaOp7nE= X-Gm-Gg: AYBFou0eeKiDI5Q9VVVB2onWwxgy6EPXUoSFuyLd37ZwWtLBDyJF3tSWoGCggqfWc8w TiQG7AO/ZtMfPThMDxOgAUqEDgFFw0EKfkoa0Txz9cK9F7D5uw18tmX8pflI0Wb5aVx3UyNpXpI RIpiwIv8A9QHbIPuf8PWsAmopkwPQhh8jqKer+tEXcRGEUO9bHO9ws5U2ETfSZPGFbnFVO1Nip1 USXakNXNr0byatal10MG7m9YA03DlwQxfbEY9yk5txYrH5EdAEHUJX8Y8h6LfZaDRYM9w2MKqtL i300681ypuVZf7YcuXhGZHQXpBIvGGLqPwSufZZtOULy4WQtzfrW7I8Fz/IwoyPKAFdyFNKMdet GTCaFJoRGDBo0kS/u+M+9w/17Y+OEsHLVjiThJjM+JVfs42ju6gg3ErWX56Ebt0jsJUFaxiX18K abMY9rqTrPnyuXTdkjbY0rVCX8EbNiWheqseJtLSMYaXsVW/XoXd0MR1GikIoxhq1X9rqcNkcBy hzgu8CTr4qJBXoUG6mSk7Op51Pcgw/w722vKT+8kCMojsa+FFeQZ6/zaChMkmllCtKM7OgOWPuZ UO8= X-Received: by 2002:a05:600c:c167:b0:4a1:a3cc:3c5c with SMTP id 5b1f17b1804b1-4a1a3cc3c71mr70078265e9.16.1791880813676; Tue, 13 Oct 2026 01:40:13 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 27/86] target/arm: GICv5 cpuif: Implement ICV_PPI_PRIORITYR_EL1 Date: Tue, 13 Oct 2026 09:38:34 +0100 Message-ID: <20261013083933.1024405-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880856860158500 Content-Type: text/plain; charset="utf-8" Implement the redirection of ICC_PPI_PRIORITYR_EL1 to ICV_PPI_ENABLER_EL1; the data for this is stored in ICH_PPI_ENABLER_EL2. The algorithm in gic_ppi_prio_hvi_mask() for expanding 8 mask bits out into 8 mask bytes is suggested by an AI, but it is only 4 lines of code, and I wrote the comments. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 64 ++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 2c717b99a0b..e1d3ffb7b1e 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -487,11 +487,70 @@ static void gic_ppi_enable_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, } } =20 +static int icc_ppi_prio_reg_index(const ARMCPRegInfo *ri) +{ + /* + * Return the index of the ICC or ICV PPI_PRIORITYR register, + * which is CRm[0]:opc2[2:0]. + */ + return deposit32(ri->opc2, 3, 1, ri->crm); +} + +static uint64_t gic_ppi_prio_hvi_mask(CPUARMState *env, int idx) +{ + /* + * Return the mask of which fields in the given priority register + * the guest cannot see, which is controlled by the ICH_PPI_HVI + * registers. We need to expand the appropriate 8 bits from + * ICH_PPI_HVI out to a mask where each byte is either all-1s or + * all-0s. The return value here is 1s for "do not show the + * guest", the same sense as the ICH_PPI_HVI registers. + */ + int regno =3D idx >> 3; + int startbit =3D idx & 7; + /* Extract the relevant 8 HVI bits from the right register */ + uint64_t mask =3D extract64(env->gicv5_cpuif.ich_ppi_hvi[regno], start= bit, 8); + + /* + * Now we're going to distribute those 8 bits so they end up in + * bits 0, 8, 16, ... 56 of the mask (i.e. in the LSB of each byte). + */ + /* Split the 8 bits into two 4-bit chunks at bits 0 and 32 */ + mask =3D (mask | (mask << 28)) & 0x0000000f0000000fULL; + /* Split again into four 2-bit chunks at bits 0, 16, 32, 48 */ + mask =3D (mask | (mask << 14)) & 0x0003000300030003ULL; + /* Split again into eight 1-bit chunks, at the LSB of each byte */ + mask =3D (mask | (mask << 7)) & 0x0101010101010101ULL; + /* Finally, the multiply turns each 0x1 byte into 0xFF */ + mask *=3D 0xff; + return mask; +} + +static uint64_t gic_ppi_priority_read(CPUARMState *env, const ARMCPRegInfo= *ri) +{ + if (gicv5_icv_access(env)) { + int idx =3D icc_ppi_prio_reg_index(ri); + uint64_t r =3D env->gicv5_cpuif.ich_ppi_priority[idx]; + uint64_t hvi_mask =3D gic_ppi_prio_hvi_mask(env, idx); + + return r & ~hvi_mask; + } else { + return raw_read(env, ri); + } +} + static void gic_ppi_priority_write(CPUARMState *env, const ARMCPRegInfo *r= i, uint64_t value) { - raw_write(env, ri, value); - gic_recalc_ppi_hppi(env); + if (gicv5_icv_access(env)) { + int idx =3D icc_ppi_prio_reg_index(ri); + uint64_t hvi_mask =3D gic_ppi_prio_hvi_mask(env, idx); + + env->gicv5_cpuif.ich_ppi_priority[idx] =3D value & ~hvi_mask; + } else { + raw_write(env, ri, value); + gic_recalc_ppi_hppi(env); + } } =20 static void gic_ich_ppi_enable_write(CPUARMState *env, const ARMCPRegInfo = *ri, @@ -1239,6 +1298,7 @@ void define_gicv5_cpuif_regs(ARMCPU *cpu) .fgt =3D FGT_ICC_PPI_PRIORITYRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pri= ority[i]), .writefn =3D gic_ppi_priority_write, .raw_writefn =3D raw_= write, + .readfn =3D gic_ppi_priority_read, }; define_one_arm_cp_reg(cpu, &ppi_prio); } --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881216; cv=none; d=zohomail.com; s=zohoarc; b=crTC3FPfhGLx9eyml5tdX5GKlibEkYv5Co7/+i4H2rPnKkkFDcckjeHeNRaWmwum7iAPhO0yPUwUkfQETbpUkuZxCxMyNAXeMcAJnWONSAc0Mj47nLpgpyn6ZRtqhVOyIpVmbO3wedXsf0eSz5p1444t1/2hf+vAmkpaQpKZ5g4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881216; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Jn5hYBmxlFxPYaAOsEx1XVxpQ4Vhj6Xdy2HZCagZ5gA=; b=J58wtTl7sCRcit11BcuTOUVAc022+ID3Kgm3SM+vLtb5rRYPoHdhfsK6b9I1ZzsUBieg8ehasUod00FtP1zde99LqpvUpvu24Ef77NypturwSZk19oPeeL/3cVO8NNSKv1Iui/+/SoAyxJV4DOSrHz6bzu+5yDsjle+asay+vjw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881216583958.9280427172251; Tue, 13 Oct 2026 01:46:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3j-0007nu-5t; Tue, 13 Oct 2026 04:40:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3X-0007Pw-2N for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:20 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3U-0007sk-F4 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:18 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4a021c809e3so26433885e9.0 for ; Tue, 13 Oct 2026 01:40:15 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880815; x=1792485615; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Jn5hYBmxlFxPYaAOsEx1XVxpQ4Vhj6Xdy2HZCagZ5gA=; b=iS9nU8vY+5RuH+aofJGDpzFfTNVNkE4zPhv/Kkphhj0gnOgYzPi02qs/bPpnian/NO GHv05ySm59ShXmWHhVfFDDqdBMKg0o6LFlD/IW7pcNFoJBOLurCnYF+KWsrf/XO3mLZl Bi8/WBquZ/N6vjkxr0/gtUnimJ2NmIi/7HE4bQPPHJZhZnItc2ZR+d7y6JIPWC0XPCL/ W6StOoNL0sBw0tLszZuhkHVqpoHKjfHakGSNJPC26WNn1Uj6UqEFcL/u7Z09XocXQ+hZ g8m51O73JfZJYQEURgDb2wIJ4zl1wMU2fDJ8wJxcVd3Up3xayUpuTrs3eLNfjBVUXOqy IHHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880815; x=1792485615; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Jn5hYBmxlFxPYaAOsEx1XVxpQ4Vhj6Xdy2HZCagZ5gA=; b=M+pGh5aEo4BPZS3QFIHK4tR/HF4v8HLOZd2TJH3ez2IRdPMEJlVlKgEBr+weoJPTgU n+FMCiNe+15alnlhz2gXITYFEsEKjfPxbtac0dW8Qo0ADcoW/5yHZbCL28iSFFhWtPin 1XYIDvuzEvsWPkB+g7GB6rXKqZhJequVTSeC89xzvqiE/RuaTQNZq9x3veWsJQPIBAmt vt1pydW2BmC5Oa4kRVTvlrJUAiQ7MruRFLN2Cg6hAIu9ZQW3X4VAX8+Tp9WYrPCpTDCq FyxQ5q7BLFfTN4UEf9XBC9/KVHwmjb4pvZmPVriO5nPAqOgk2fXMfyR2fezGMOo9QPmR EdOQ== X-Forwarded-Encrypted: i=1; AKwUvByWw0DlEZQd23dDTtnEd2t8y+8huSfZaL+s3EJvLdSaPtf8n0AiA42MsY9ajKe1bqPXkmm+kHIa1SJE@nongnu.org X-Gm-Message-State: AFq9FYJG5NrF/fMP6+6gfG4nV00cMucHE9UOghEC3iEzHPlvOolqB7Dt wWP1E+KOnJrCflPs3JQvx04m1LylXwhUhBnJLDpoAlkJFTIjEshLuwgUDKX6HoJGRUo= X-Gm-Gg: AYBFou1r6Q1tR4GF2a7FYL6t0cS+eGVOkdSrRbjqshzkDZDqEx+ARKiw6t501znOolH LALKqF5I9woe7cDvs146Ow9ONmwP0t5kOkUK4gBNvIAT6N1EDN81vvPcTJp7DWlrHwyhRn6NzAa BTYsMNhhNB2LS09BcZPx0xWCNnb0mxUx0mfZBKJf6m95FQSexG/AHSz8ahtuB/l9KNMSRFQzRdu nWOXjM97FFspiWav0PXtfXV0jvqVv57MCpv4Gb80myNlcufnrsjoRZf2WqgLLryipdzxAuFmXiC LCPIBrMjXBJvhUJfOD5289V/n+Z0ppD1Rx7MLIa1zIo7FSrdhmeOcO/34rqnwzAWJQr4OLYdHyA vpQSF+/9L1YgUPmfYJBCM+04frTiezOZDvkmDiebOVReg1HaQlL37xFjBcg1qlXQXZ8sEyJ3/1F wbv3RnhPd+jUvKVHs9UTk4TI8aHQfJkqwucRNGNuW9dPYkuFOyXghDxZoPB1NkxQLbQ3a3DCTOq 2K6qPC+SLwR0BOVyh9Kry7Nal9fKyvhLAdXFFeltB9LD9un8C9t5XyfjFnb/8EEfY4szMMl/YPc aQ0= X-Received: by 2002:a05:600c:c3cb:20b0:4a1:a7f8:c12a with SMTP id 5b1f17b1804b1-4a1a7f8c1b4mr25662785e9.21.1791880814627; Tue, 13 Oct 2026 01:40:14 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 28/86] target/arm: GICv5 cpuif: Add comment about ICV_PPI_HMR_EL1 Date: Tue, 13 Oct 2026 09:38:35 +0100 Message-ID: <20261013083933.1024405-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881217637158500 Content-Type: text/plain; charset="utf-8" The ICC_PPI_HMR_EL1 and ICV_PPI_HMR_EL1 registers are both read-only and report whether PPIs have the edge or level handling mode. This doesn't change under virtualization and there is no mechanism for the hypervisor to report a different value to the guest. However, we do need to honour the ICH_PPI_HVI bits that make the PPI behave as if it was unimplemented (bit is RAZ/WI). Add a readfn for these registers so we can mask them when they are read by the hypervisor guest. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index e1d3ffb7b1e..b55fe4991ba 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -425,6 +425,23 @@ static void gic_cdhm_write(CPUARMState *env, const ARM= CPRegInfo *ri, gicv5_set_handling(gic, id, hm, domain, type, virtual); } =20 +static uint64_t gic_ppi_hmr_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + uint64_t value =3D raw_read(env, ri); + + if (gicv5_icv_access(env)) { + /* + * The spec defines ICV_PPI_HMR_EL1 virtual versions of these + * registers, but they are read-only and can only ever report the + * same value as the physical ICC_ versions. However we do need + * to make sure the bits RAZ/WI if the hypervisor has made the + * PPI appear disabled to the guest via ICH_PPI_HVIR_EL2. + */ + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; + } + return value; +} + static void gic_ppi_cactive_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -1054,6 +1071,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .fgt =3D FGT_ICC_PPI_HMRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_hm[0]), + .readfn =3D gic_ppi_hmr_read, .resetvalue =3D PPI_HMR0_RESET, }, { .name =3D "ICC_PPI_HMR1_EL1", .state =3D ARM_CP_STATE_AA64, @@ -1061,6 +1079,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .fgt =3D FGT_ICC_PPI_HMRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_hm[1]), + .readfn =3D gic_ppi_hmr_read, .resetvalue =3D PPI_HMR1_RESET, }, { .name =3D "ICC_HPPIR_EL1", .state =3D ARM_CP_STATE_AA64, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881619; cv=none; d=zohomail.com; s=zohoarc; b=m3SGUCy3jaYWag50V4X3AuVRAFfvasaq/kAIwwTGiqnehW2MWhSBCyrLhhSOapQtocF+H8OwgNryYdQawLKhDcWyJM53Z3fH3VN2e4OyH6T7bwbRy1j+rn61SS1HWxsWmkR3gfeoMM9SYqXG3Q424xDgbp+PsXh8InltRV1Mqmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881619; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Y8q71JbmtGZDvZaAdzWnKGUCtm5nx9NvXNrI90s4PFM=; b=H+45PwlFc4aCFSIg2WhRWyPMo7Z9p56YL297cpfRO/X4z7Ly06SdnG5UUpb+Ij4dae+NteBS2MB0rTHmo7clUkbu4Aiv6Cy0Zy96R5gEuCAMxbfFzcaKVx2SzKMA4BtsmRXXWcJwH14TmBVyqSECah39Qzyzy3WUD4/WXsWishM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881619941835.6455120509377; Tue, 13 Oct 2026 01:53:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4L-0000kE-NE; Tue, 13 Oct 2026 04:41:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3b-0007UP-9j for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:23 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3V-0007tf-E0 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:19 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-48b02b1b4cfso3001641f8f.0 for ; Tue, 13 Oct 2026 01:40:16 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880816; x=1792485616; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Y8q71JbmtGZDvZaAdzWnKGUCtm5nx9NvXNrI90s4PFM=; b=DvzvNN8jECCQDSRyUL5rjWrPIMoK2ILMonvragJQuVPJew20Ojo7eptN/DUd0q3s4z iQJFWyDbWfO+aoQwL2Bi599cX36Qenk42QZzhEyUPrD5utsVRUDEWXEKcMvD4kJTiYz+ mUcxVQ2rd2mWDDU+lwQqpX6XFLzgZNyF6phudzNGD9ByKWwtDUVq6L4WlemH5OW2zidj PtHFGDDtRSPt6emuz3BowIQKJJSPxPkWjEg35Lt59wa36aRlWrstcthaEndSlAJCl1Ib gkmz9KvIQ3AZC0f1K0mWEmth7SNfJ/MSciqZxlkl+VyOVYJsoQWXVeXRVb+gey7+I0i0 Zcpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880816; x=1792485616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Y8q71JbmtGZDvZaAdzWnKGUCtm5nx9NvXNrI90s4PFM=; b=GGZuufjB9Y2yys1X3pCUKRBNGYFxaiOpFYOtzbUIcrqoNF/qi0cRUi5E3MhDXItZKQ wt+6+gYOBFXQY9Q/e9ty+MSNhsyEHLNHpFmHyBWaS1wn8+cxc4gY0Gr+UYnaFW86A1Z7 lkvEDKI2qaaXL0+0SBW8VLOpaDIZvDlHEKdWMzfRhhnt8ySlMALbPBYXoYjxIwxkG6BA 37aDlTwNaQnL5301PJEsiBE2jN1M93OS1IBCyVLRzPUivJVl4v7AjzDQtbns9sJ2sD+3 0RXmMDVsxxdjEVBZkXWk6d/W9S/taWR3ZVn9D9+Z19YQ6wliPcLvzvCT1ztCNVfiUX7B yplg== X-Forwarded-Encrypted: i=1; AKwUvBztkZOM50xqtjEHK8rwiriCTgRNAl5d+iom01uN46J2GdNCmUx9xzU4wCgVGThN2UKfmi7lx+UQ5UeX@nongnu.org X-Gm-Message-State: AFq9FYInE+AOFhFcfoaxQQfJvhzQW+ro3SK9bInJs2+Lh66ypbaJh8a9 5ORaO0iAsrJG0TlvObcclTvYzX/4MCQ+8L85wwZhT8kUQoO3SiLjBMZ/ciEPSB0qDSM= X-Gm-Gg: AYBFou3eahwkjbjAuo+1IHn5TqCKI2LqMVmgW0UCYbvzH9xyWTc9n6nUf6a27I8VAEj Ar4D0lAWKLdDj0AVIyIsfQhkzDKcddoqvYXxwJVdj4iFDpoZxFwl7zQBbfD6Q3MWLhbFonDN7QA 7R8fJORZwV2Tp9nYFi+UYWPf5BrlEwZdiANiqvq3ZEAFSznqGqSjX6poaw97LQx3sPR0MexdnfL EUrWOwsjus2v/pOe7ICNqGSR6lreXfGuqV2+DDTrQg8AjluXxSFiqYcnj9Kk4/FowWpqjDfDjmi p1QNPqdeUqNTfNDSddfuGllM6/HPRgXbGnGZi6QjmmroHr2WzrEgy4z3mOpAzEPW3MuiskQZmKa HJSLLC29Fv0OThGsQA1gBqu6kSGT+RYY390Q7Bpgdv9sVrIpGrgahOhDcLAukx43ASDSUdtnM/s Fg5d1zOmXvtA5OP2oWf0b0xf7+NPxlm0BM6BNr5AFG3i8mYQBFemWcFcgWy/1mUSvPU5MWCpEFE t2Vd5ljNIQPHGilbinM6vnmVs7gQyZsQMdDMG+5Uaq78wjLJiM9THpS1KzQac2snJxn/U3CrZIs idc= X-Received: by 2002:a05:600c:3512:b0:49f:c5aa:9ef4 with SMTP id 5b1f17b1804b1-4a18e4913c3mr198777055e9.8.1791880815822; Tue, 13 Oct 2026 01:40:15 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 29/86] target/arm: GICv5 cpuif: Implement ICV_PPI_CACTIVER_EL1, ICV_PPI_SACTIVER_EL1 Date: Tue, 13 Oct 2026 09:38:36 +0100 Message-ID: <20261013083933.1024405-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881621444158500 Content-Type: text/plain; charset="utf-8" Implement the redirection of ICC_PPI_CACTIVER_EL1 and ICC_PPI_SACTIVER_EL1 to the virtual ICV_ versions of these registers. The underlying state here is held in ICH_PPI_ACTIVER_EL2, but the inner-guest facing view has set/clear semantics. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 38 ++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index b55fe4991ba..876f5813d5a 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -442,20 +442,42 @@ static uint64_t gic_ppi_hmr_read(CPUARMState *env, co= nst ARMCPRegInfo *ri) return value; } =20 +static uint64_t gic_ppi_active_read(CPUARMState *env, const ARMCPRegInfo *= ri) +{ + if (gicv5_icv_access(env)) { + uint64_t value =3D env->gicv5_cpuif.ich_ppi_active[ri->opc2 & 1]; + + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; + return value; + } else { + return raw_read(env, ri); + } +} + static void gic_ppi_cactive_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - uint64_t old =3D raw_read(env, ri); - raw_write(env, ri, old & ~value); - gic_recalc_ppi_hppi(env); + if (gicv5_icv_access(env)) { + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; + env->gicv5_cpuif.ich_ppi_active[ri->opc2 & 1] &=3D ~value; + } else { + uint64_t old =3D raw_read(env, ri); + raw_write(env, ri, old & ~value); + gic_recalc_ppi_hppi(env); + } } =20 static void gic_ppi_sactive_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - uint64_t old =3D raw_read(env, ri); - raw_write(env, ri, old | value); - gic_recalc_ppi_hppi(env); + if (gicv5_icv_access(env)) { + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; + env->gicv5_cpuif.ich_ppi_active[ri->opc2 & 1] |=3D value; + } else { + uint64_t old =3D raw_read(env, ri); + raw_write(env, ri, old | value); + gic_recalc_ppi_hppi(env); + } } =20 static void gic_ppi_cpend_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -1043,6 +1065,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO= _RAW, .fgt =3D FGT_ICC_PPI_ACTIVERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_active[0]), + .readfn =3D gic_ppi_active_read, .writefn =3D gic_ppi_cactive_write, }, { .name =3D "ICC_PPI_CACTIVER1_EL1", .state =3D ARM_CP_STATE_AA64, @@ -1050,6 +1073,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO= _RAW, .fgt =3D FGT_ICC_PPI_ACTIVERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_active[1]), + .readfn =3D gic_ppi_active_read, .writefn =3D gic_ppi_cactive_write, }, { .name =3D "ICC_PPI_SACTIVER0_EL1", .state =3D ARM_CP_STATE_AA64, @@ -1057,6 +1081,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .fgt =3D FGT_ICC_PPI_ACTIVERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_active[0]), + .readfn =3D gic_ppi_active_read, .writefn =3D gic_ppi_sactive_write, }, { .name =3D "ICC_PPI_SACTIVER1_EL1", .state =3D ARM_CP_STATE_AA64, @@ -1064,6 +1089,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .fgt =3D FGT_ICC_PPI_ACTIVERN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_active[1]), + .readfn =3D gic_ppi_active_read, .writefn =3D gic_ppi_sactive_write, }, { .name =3D "ICC_PPI_HMR0_EL1", .state =3D ARM_CP_STATE_AA64, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881563; cv=none; d=zohomail.com; s=zohoarc; b=LdYG251icInxEAIqMXxVzMHL+LrsAMFpk9t4HWH67ca3Ge+8McVclMMH32yRhjcAF5oW/WGgPu7EEdSfUrY/cwSKz1RGEKMMm1117l7yd8J4slXcz/UbgB6b5xwUhhskpgUOP5XHm/4SH8QxgNBkeS/bTMGIvL3FAjdGUQpvFiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881563; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Hrch6mWn18Vsni9ZYGMXpYD4co+MVRjdvkjQZHLk8Lc=; b=RpdEwIVk+l+CW1xq+2YClu4Vn+UL0w0VcCbaJNnvbMbOFqxLBsiLLL4yD4EJ13AKZgFqB1gvZyG+sHHFMooRXSTC5wbBFKJuhqqiG8+2YPkC9mILCqxZupKPjvHqOpIJ3iHqvBFEGSgZtU+tHTTH2C0Ao8w1VcpmDTnxr3ySG+s= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881562985393.5858625397941; Tue, 13 Oct 2026 01:52:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY42-00005F-6T; Tue, 13 Oct 2026 04:40:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3b-0007UY-B6 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:23 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3W-0007uD-ME for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:23 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4a020e65269so16617055e9.2 for ; Tue, 13 Oct 2026 01:40:18 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880817; x=1792485617; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Hrch6mWn18Vsni9ZYGMXpYD4co+MVRjdvkjQZHLk8Lc=; b=d2e+aPxgNxvYeNKooL417/DX2KuMKT2T7P3JQlVVciYfYTaxk4EncoJ+U4mr1qyHIo 0yGYkkCG6FLsiOdWTblj6bryp6lc4qCJJI7D21Z0AOp+jngDMaPqKo7FlFfiuhbb541f ymLPS41mwGHXsWXdtOfZ9qJsFYz782Dj9LtUaihWb9u7jdZZC4Xjukl9hrBOpjsqPtzC bosW3k7okVAIpYC8qP0pyuvs67ZqZuX2IjIR4rZ+qcUz9qr/lP9aUYpoxeTzgEoOarq2 JCZft58VeVCS6DsNvyk5//AImbfdLguvrm1whNeLmzI5UjraTJE41oedG7gETp36ucI7 Nxyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880817; x=1792485617; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Hrch6mWn18Vsni9ZYGMXpYD4co+MVRjdvkjQZHLk8Lc=; b=lGOMGUGZaE2lCNqEKtR4i4AH4+p1yiaCgvXvTRmLD/zJ9N2wlQHLdtWhjcANjfu1Bg dwuMPq/Gif7+mfXcL1gZESkmhwY9CKlKE7HzR2Y3pYugKCNxBarOW1KYcMkw41S2qFsy pfNzxLaoO6h3oLVTC7/in4PPcN3g3uzXB+wX9R+SqrWbyV4AMtFGlVnlsCqTpQZ4aKXZ gVVqCA8CPH/+WUpPYFxqzZroHQuFAJ7DyPNTnGM+0P5KI7LsyLDY0IPYC45HtdbX70oq zzFxBjr6PczxtFP2VvNgTrDfbiDte5XZCrmPiDLLn/bRVXaMA7G6xl4XpPtYZj6UBbCO QuIQ== X-Forwarded-Encrypted: i=1; AKwUvBykjedBehn/lRR5zJb7+tDnZbZO32QYikr9BJX2wGXSEuviRVglsR+yGwuLyFcaR7lJoefnlqiHpi61@nongnu.org X-Gm-Message-State: AFq9FYJpF/rp9+dNKJNitlgYDv8HHJPwYrhLiVRmHby4+9edOeEsAMch X4ms6NCCPgVyz+ncFpByAiawr5VidzTGfgcuFtI6MuHEz2wRrbvU2DhapKQe7tc4+l5u7VQQ+yS 330ilOv4= X-Gm-Gg: AYBFou1larMkWxhveS8yOBOr38xF+FNSzwpMbAj0SztyQnZ+GmXVzmvWROa6jw6C+s4 Xh6fhr0FZOfn4CwFbWuMbwm3hSXCPWi2YfkDf1YdyCfYHxhHdVZS10/Tvt3ezL5sfvPDVaqXqTG KAEC6m/ebXbbPNhKn9cNcTW9GDMyE2vbQnU7F5nhrJFhSNlC4UOTDOUbXuDWuOhTT2K5/TC7ERZ 3BPX6MFrFoAbpUdj+H+Kh4sUMoAcsoi/XLGO7ru3GzPEEUr3AWnb9Lb6MvOLAA0A9b+nCOhvXTi oKFDSb8yB384kBtOv3rkI3BinKIvUxhLMuVTNRAztqI3gh23Ew2j2xsQKkC1MI9+ZSXJeocoZql MOhVN09D+kgaYF7h/JvVuA4KZzXuLgs6Q3Vk8cXE0C1cxsaCbxEQXaXyyCBfTm1zEYVosJqqIff hYJ33oFAs9wiZrfvDV9WUohwUBNxZrLfgBbsSx/Qd5Wpk6kBRf0YPnYT1EnTR+3J/eGuOnCgH7i B7nLcSuLg9j0a36XH8FtQsu0T5DqoxX9mMi9orjixeH9tsoqp6TpNBQaP09Mqu5o4lONe6h3Pau BF8= X-Received: by 2002:a05:600c:6388:b0:4a1:ac66:5ffe with SMTP id 5b1f17b1804b1-4a1ac666396mr23901165e9.15.1791880816785; Tue, 13 Oct 2026 01:40:16 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 30/86] target/arm: GICv5 cpuif: Implement ICV_PPI_CPENDR_EL1, ICV_PPI_SPENDR_EL1 Date: Tue, 13 Oct 2026 09:38:37 +0100 Message-ID: <20261013083933.1024405-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881564217158500 Content-Type: text/plain; charset="utf-8" Implement the redirection of ICC_PPI_CPENDR_EL1 and ICC_PPI_SPENDoR_EL1 to the virtual ICV_ versions of these registers. The underlying state here is held in ICH_PPI_PENDR_EL2, but the inner-guest facing view has set/clear semantics. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 40 ++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 876f5813d5a..96384c58726 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -480,26 +480,50 @@ static void gic_ppi_sactive_write(CPUARMState *env, c= onst ARMCPRegInfo *ri, } } =20 +static uint64_t gic_ppi_pend_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + if (gicv5_icv_access(env)) { + uint64_t value =3D env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1]; + + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; + return value; + } else { + return raw_read(env, ri); + } +} + static void gic_ppi_cpend_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - uint64_t old =3D raw_read(env, ri); /* If ICC_PPI_HMR_EL1[n].HM is 1, PEND bits are RO */ uint64_t hm =3D env->gicv5_cpuif.ppi_hm[ri->opc2 & 1]; value &=3D ~hm; - raw_write(env, ri, old & ~value); - gic_recalc_ppi_hppi(env); + + if (gicv5_icv_access(env)) { + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; + env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1] &=3D ~value; + } else { + uint64_t old =3D raw_read(env, ri); + raw_write(env, ri, old & ~value); + gic_recalc_ppi_hppi(env); + } } =20 static void gic_ppi_spend_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - uint64_t old =3D raw_read(env, ri); /* If ICC_PPI_HMR_EL1[n].HM is 1, PEND bits are RO */ uint64_t hm =3D env->gicv5_cpuif.ppi_hm[ri->opc2 & 1]; value &=3D ~hm; - raw_write(env, ri, old | value); - gic_recalc_ppi_hppi(env); + + if (gicv5_icv_access(env)) { + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; + env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1] |=3D value; + } else { + uint64_t old =3D raw_read(env, ri); + raw_write(env, ri, old | value); + gic_recalc_ppi_hppi(env); + } } =20 static uint64_t gic_ppi_enable_read(CPUARMState *env, const ARMCPRegInfo *= ri) @@ -1134,6 +1158,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO= _RAW, .fgt =3D FGT_ICC_PPI_PENDRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pend[0]), + .readfn =3D gic_ppi_pend_read, .writefn =3D gic_ppi_cpend_write, }, { .name =3D "ICC_PPI_CPENDR1_EL1", .state =3D ARM_CP_STATE_AA64, @@ -1141,6 +1166,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO= _RAW, .fgt =3D FGT_ICC_PPI_PENDRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pend[1]), + .readfn =3D gic_ppi_pend_read, .writefn =3D gic_ppi_cpend_write, }, { .name =3D "ICC_PPI_SPENDR0_EL1", .state =3D ARM_CP_STATE_AA64, @@ -1148,6 +1174,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .fgt =3D FGT_ICC_PPI_PENDRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pend[0]), + .readfn =3D gic_ppi_pend_read, .writefn =3D gic_ppi_spend_write, }, { .name =3D "ICC_PPI_SPENDR0_EL1", .state =3D ARM_CP_STATE_AA64, @@ -1155,6 +1182,7 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .fgt =3D FGT_ICC_PPI_PENDRN_EL1, .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pend[1]), + .readfn =3D gic_ppi_pend_read, .writefn =3D gic_ppi_spend_write, }, { .name =3D "ICC_APR_EL1", .state =3D ARM_CP_STATE_AA64, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881666; cv=none; d=zohomail.com; s=zohoarc; b=ditCVK0sY36myv7KBnEUZux/Z9eXsZbaTsVH5kdIRaow4/YQCGGRpPJ98YH+0TGhWEmGs7b1UdL74UpRaftTkczW0IMldzdR+BGRrG40fvdd/griagniL5LQ61Cd2+X5J8ucNeEdzDSm6zd4aofeupKS64nB3ak2eaEv9u7SfCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881666; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=lh+2T2GNGXypbGBZ7mOAEqbcBqzSK4Ir0IjdWPDly0g=; b=UqLykTpe42SFNR+VATzWTmTYtebMNlwMA22gVQCyYaJjreQL/81BqJyi9wXgEzUodnW3988rLHYvJxzPPLX7E75lkQVwmavuRLitWA1kau8O258MwrtqA5TSE3qVO7LCbcB9LF24PXhe2DAR9zVErVzMnH2EqmhCIS3Ovc3BcpI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188166633024.99770004069694; Tue, 13 Oct 2026 01:54:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3s-0008Dy-Aj; Tue, 13 Oct 2026 04:40:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3d-0007Zr-VF for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:26 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3b-0007uf-0p for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:24 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4a16c399641so26911355e9.2 for ; Tue, 13 Oct 2026 01:40:19 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880818; x=1792485618; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=lh+2T2GNGXypbGBZ7mOAEqbcBqzSK4Ir0IjdWPDly0g=; b=bIqJF2MRLaT/C6yyIqlnFSgkfiyBeHP2oj04JosMeYMn6gIohD5Sdz8SyK4y7ICtcx p1KvsAioL505nOVndastoA8RaP5zd1hxxuuO+5RvoDWbYaPJlwa4F565C9Ol98tXNvoG Ijvj2bhImqhKKi7S0DCDX0753mOWRZtYlE8igwMEXDVCefVqYG9FL5nT00MulkKN/DQ5 BomdZvpO5oo8kHmNvmKlPpBW1qeDfJmunbxAd+LxqfKPeLcD6urE7Nlh+X+4CZPyTX1P KHVswpBWrs/XZF65lvceneSK+qryXqGub3dHrzjldM1X9VNiAqBQgYPpiSAOm2eZziwF LY1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880818; x=1792485618; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=lh+2T2GNGXypbGBZ7mOAEqbcBqzSK4Ir0IjdWPDly0g=; b=1U4O/49aY9HP4jBl45gbXrc+mOVpz8WXao5gSDoZEmg9q+BLyaeqFcFpH7y9u8fa1X 8bGnLMoF5k8s6sXUttAzM9nLvBXLlH2sECvytFtIqyRY67OwuwW1/JZbiliuNDhvueCz 6msaR6123BkjD8ZcFuQ0/t0NW1m2Q3KZ+GTz3fuj8hLohxUWJJVgmz92oHPPaYW6P4T8 XeA6PjhXPzSxKGxm36GYRHYTQPoInHVs2egcRzCJHC2PsVfkFhXo7jlN0WozQipBu9DC NTVJq33ikpnW7KeiTnkXT0C9j2XSZq68vYs3RIhPUO/H2kkTrd0IsV7S4GsqHMBZttJ0 8/rQ== X-Forwarded-Encrypted: i=1; AKwUvBwUwh2DfAZ/nwq3C7wdC+JhxbrYlNKzF4XhiNUUJV6Q+E/N2DgY0U50If2Ycd0n+nghDCN5FZ2v1nAG@nongnu.org X-Gm-Message-State: AFq9FYIhPfhWCo4nY61U5T6L62Q1eogltGgITVeyMpM2Grx9QqETOIlL tDSC0vMccKMSWtrcRAEPc0V8H/DDMwriheJXc+MmHdl1gYRTVEo2/bfWuIYpQjSrEQs= X-Gm-Gg: AYBFou2RN3ZzpvjMRZ2Tm2CcZ593b0tn4vnD0bfbyrJ9G2zdQ5/azlw1tTyf0DwskZx lfwMhxmArb2Ft0JbFxbidVmsCDv5w/ceAiAPmnEJKBBf9gEABGFHJ7fLj7WIlRAelFrRPedBGXG T3PVqYmL4jKZYQ8ZybsDeA2Y9z/V5NEUoLTX6vwEWuiFrjDdgwB6kMEAVYfKTylmmTY84MfrpD5 nL8s2pQpUneGkDXyy58rox2MCgGF67r1dWkxhEGpC5AI7vPtxB7CtVpaz2968Z8Hqu/33Mk/sjU QZYjLHnJf4bzOIomj+2a8K/+nfSmJm03zpev8ZcgJzDJmhCP4yUt3/Tj4shBVz8oxiokwz59EfW ERB1WKQgQEJKAoZMngg2FmzCgoJnLWA0x1CZJx4iV3GmlayFYW5KfepcIbrTXyj82rPlu/dO02Z EZmlmk9Zst6UZ2dNlr1+dlloXmxtgM2jQ3mI863vy3Etyiokk9kcBZ0P+Fq/SB0E05qua2fxVz7 6dqHICTMAcboJRXc80QRNslUfB63FMkLJYdUx2065hfOJ82JTjncC5qPLhMrQeigp051j5EFFk6 P4I= X-Received: by 2002:a05:600c:138a:b0:4a1:7bd4:d07d with SMTP id 5b1f17b1804b1-4a18e4c85fdmr249944985e9.34.1791880818246; Tue, 13 Oct 2026 01:40:18 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 31/86] target/arm: GICv5 cpuif: Calculate current virtual PPI HPPI Date: Tue, 13 Oct 2026 09:38:38 +0100 Message-ID: <20261013083933.1024405-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881668265158500 Content-Type: text/plain; charset="utf-8" Implement gic_recalc_virt_ppi_hppi(), which calculates the current HPPI PPI for the virtual interrupt domain, using similar logic to gic_recalc_ppi_hppi(). We call this from everywhere where we update the state of the virtual PPIs. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/cpu.h | 2 ++ target/arm/tcg/gicv5-cpuif.c | 51 ++++++++++++++++++++++++++++++++++++ target/arm/tcg/trace-events | 1 + 3 files changed, 54 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 81fb68facb9..abaee5fc3a0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -596,6 +596,8 @@ typedef struct CPUArchState { =20 /* Cached highest-priority pending PPI for each domain */ GICv5PendingIrq ppi_hppi[NUM_GICV5_DOMAINS]; + /* And for the virtual interrupt domain */ + GICv5PendingIrq virt_ppi_hppi; =20 uint64_t ich_apr_el2; uint64_t ich_vctlr_el2; diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 96384c58726..0d38ed7b15b 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -298,6 +298,45 @@ static void gic_recalc_ppi_hppi(CPUARMState *env) gicv5_update_irq_fiq(env); } =20 +static void gic_recalc_virt_ppi_hppi(CPUARMState *env) +{ + /* + * Recalculate the HPPI PPI for the virtual interrupt domain: this is + * the best PPI which is enabled, pending and not active. + */ + env->gicv5_cpuif.virt_ppi_hppi =3D GICV5_PENDING_IRQ_NONE; + + for (int i =3D 0; i < ARRAY_SIZE(env->gicv5_cpuif.ich_ppi_active); i++= ) { + uint64_t en_pend_nact =3D env->gicv5_cpuif.ich_ppi_enable[i] & + env->gicv5_cpuif.ich_ppi_pend[i] & + ~env->gicv5_cpuif.ich_ppi_active[i]; + + while (en_pend_nact) { + uint8_t prio; + int ppi; + int bit =3D ctz64(en_pend_nact); + + en_pend_nact &=3D ~(1ULL << bit); + + ppi =3D i * 64 + bit; + prio =3D extract64(env->gicv5_cpuif.ich_ppi_priority[ppi / 8], + (ppi & 7) * 8, 5); + + if (prio < env->gicv5_cpuif.virt_ppi_hppi.prio) { + uint32_t intid =3D 0; + + intid =3D FIELD_DP32(intid, INTID, ID, ppi); + intid =3D FIELD_DP32(intid, INTID, TYPE, GICV5_PPI); + env->gicv5_cpuif.virt_ppi_hppi.intid =3D intid; + env->gicv5_cpuif.virt_ppi_hppi.prio =3D prio; + } + } + } + + trace_gicv5_recalc_virt_ppi_hppi(env->gicv5_cpuif.virt_ppi_hppi.intid, + env->gicv5_cpuif.virt_ppi_hppi.prio); +} + void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain) { /* @@ -460,6 +499,7 @@ static void gic_ppi_cactive_write(CPUARMState *env, con= st ARMCPRegInfo *ri, if (gicv5_icv_access(env)) { value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; env->gicv5_cpuif.ich_ppi_active[ri->opc2 & 1] &=3D ~value; + gic_recalc_virt_ppi_hppi(env); } else { uint64_t old =3D raw_read(env, ri); raw_write(env, ri, old & ~value); @@ -473,6 +513,7 @@ static void gic_ppi_sactive_write(CPUARMState *env, con= st ARMCPRegInfo *ri, if (gicv5_icv_access(env)) { value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; env->gicv5_cpuif.ich_ppi_active[ri->opc2 & 1] |=3D value; + gic_recalc_virt_ppi_hppi(env); } else { uint64_t old =3D raw_read(env, ri); raw_write(env, ri, old | value); @@ -502,6 +543,7 @@ static void gic_ppi_cpend_write(CPUARMState *env, const= ARMCPRegInfo *ri, if (gicv5_icv_access(env)) { value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1] &=3D ~value; + gic_recalc_virt_ppi_hppi(env); } else { uint64_t old =3D raw_read(env, ri); raw_write(env, ri, old & ~value); @@ -519,6 +561,7 @@ static void gic_ppi_spend_write(CPUARMState *env, const= ARMCPRegInfo *ri, if (gicv5_icv_access(env)) { value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1] |=3D value; + gic_recalc_virt_ppi_hppi(env); } else { uint64_t old =3D raw_read(env, ri); raw_write(env, ri, old | value); @@ -544,6 +587,7 @@ static void gic_ppi_enable_write(CPUARMState *env, cons= t ARMCPRegInfo *ri, if (gicv5_icv_access(env)) { value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; env->gicv5_cpuif.ich_ppi_enable[ri->opc2 & 1] =3D value; + gic_recalc_virt_ppi_hppi(env); } else { raw_write(env, ri, value); gic_recalc_ppi_hppi(env); @@ -610,6 +654,7 @@ static void gic_ppi_priority_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, uint64_t hvi_mask =3D gic_ppi_prio_hvi_mask(env, idx); =20 env->gicv5_cpuif.ich_ppi_priority[idx] =3D value & ~hvi_mask; + gic_recalc_virt_ppi_hppi(env); } else { raw_write(env, ri, value); gic_recalc_ppi_hppi(env); @@ -620,36 +665,42 @@ static void gic_ich_ppi_enable_write(CPUARMState *env= , const ARMCPRegInfo *ri, uint64_t value) { raw_write(env, ri, value); + gic_recalc_virt_ppi_hppi(env); } =20 static void gic_ich_ppi_pend_write(CPUARMState *env, const ARMCPRegInfo *r= i, uint64_t value) { raw_write(env, ri, value); + gic_recalc_virt_ppi_hppi(env); } =20 static void gic_ich_ppi_active_write(CPUARMState *env, const ARMCPRegInfo = *ri, uint64_t value) { raw_write(env, ri, value); + gic_recalc_virt_ppi_hppi(env); } =20 static void gic_ich_ppi_priority_write(CPUARMState *env, const ARMCPRegInf= o *ri, uint64_t value) { raw_write(env, ri, value); + gic_recalc_virt_ppi_hppi(env); } =20 static void gic_ich_ppi_dvi_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { raw_write(env, ri, value); + gic_recalc_virt_ppi_hppi(env); } =20 static void gic_ich_ppi_hvi_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { raw_write(env, ri, value); + gic_recalc_virt_ppi_hppi(env); } =20 static void gic_ich_vctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index bf1803c8722..da25ec994cc 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -3,6 +3,7 @@ =20 # gicv5-cpuif.c gicv5_recalc_ppi_hppi(int domain, uint32_t id, uint8_t prio) "domain %d ne= w PPI HPPI id 0x%x prio %u" +gicv5_recalc_virt_ppi_hppi(uint32_t id, uint8_t prio) "virtual domain new = PPI HPPI id 0x%x prio %u" gicv5_gicr_cdia_fail(int domain, const char *reason) "domain %d CDIA attem= pt failed: %s" gicv5_gicr_cdia(int domain, uint32_t id) "domain %d CDIA acknowledge of in= terrupt 0x%x" gicv5_cdeoi(int domain) "domain %d CDEOI performing priority drop" --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881146; cv=none; d=zohomail.com; s=zohoarc; b=bVQ9Lgkokic/aPHwDUoc/aC/MDH5j5YiW410wMzaXmICbPz8g5LQNoXj7nH8RyF6YBSDH/aB3uXwDNAjLjFmKYlDiUDb+bFvC1xF+GkBcSZGV5CMWSdDgb2eosgCX8RpTXEQfq6tJiliJYO+8XokkrzWREGXn7okSOiPmfUHqe4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881146; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=TU9O2PphfR7CT0QZAlJlY1ptLb1SjIOU0zHbyiVZJU0=; b=CqIk4qnZeOD+x4Zd8Gka5KgeguAsp5ytearCfzET8Ahh1WEU/y1xnaBIJg/YfC1lAccVvZ3MO/3SlJxK2jgDT9f1OP9hEzc3n/sWQnh+1sIMZ3E/5rwcW4jChKQDZJsoOFR5T35cU2mkbmxupfo+GV6xnoeuiqDEO0PStkvDNXM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881146735292.79025869030204; Tue, 13 Oct 2026 01:45:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3u-0008IA-3R; Tue, 13 Oct 2026 04:40:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3e-0007bd-GA for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:27 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3b-0007vB-2T for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:26 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4a16bc2278aso18551505e9.1 for ; Tue, 13 Oct 2026 01:40:21 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880820; x=1792485620; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=TU9O2PphfR7CT0QZAlJlY1ptLb1SjIOU0zHbyiVZJU0=; b=L78qflrZjqV7s5qvewqxVLzsdAGRAi6P1Jomim0SDl9mUmVakCsblpYRiKkWrRzBFg JqmkT37J6n/weXfcNhS6cyxpyXTLS52DfperPm0WujA9rrOzCma3pRB2JPxscadD6/ii LHOcLASAcWzrvuOIIDyiCh6R+lnq5ydjegV2M5YXF1rZzLT4v0lXhtXTudMx2Xhro7v4 diAPZ+BuugW+Ov18mN+MM9hU/gqul1an8zZUhOBRjN4AQz98h/8wWWiAyw9cgn78nS5d N5VtP2cTEECmyykVCip+DA7pwvqGoy0UIvVcmViBVkD3UI5Gy5uNrCYP96cLouwM88ir I/CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880820; x=1792485620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=TU9O2PphfR7CT0QZAlJlY1ptLb1SjIOU0zHbyiVZJU0=; b=spZxtkmU/6BzORFNdYSWZACAod5kRq7n5Fa7tVC9FBvML0ap0cWJWdGE+n2JkCIUW6 O3nMTSOUrF6xmPJghIUkTeGRandYThSe2ybE0ostWaS4jrwIho5+bRkSSnGG7aH7fRIY V7C6PkHzfUIr4mLy7N15SWuKYBD7a8wJJG1UPc5zU0Ox4VSiGgN+xr411abRwFIEJlB2 oL45Q7o3GUIHHz9pdb2b4jizMoQmc+uwSoILJNXPzFGVyJ7/IC8lnnaTLl8WTnpUY1OU cosrzMBXxJQsWIR8tFEd8qluBgKPX56c2wDiIY68czYvmzIi0O62fhj2HvRoXF3GUNJ6 VJRA== X-Forwarded-Encrypted: i=1; AKwUvBzDp7xgBwhQtMu1EJndmsgLF+0yb9MXOWytjFmwNRpTNb1k5S4eiLQmCWXw3dz/dOCAPLFlQHxifpkY@nongnu.org X-Gm-Message-State: AFq9FYKhqVBZTWYxl2Ok87FEGzZc/g5DlSBEhl38inYVq/kspF9PzRib nu0zzWMpRf5Ss3kpFHQs/NRsqscnySmvHT9/cp1xgRGNqmCAYju1XR6yAZ3se+D9F8c= X-Gm-Gg: AYBFou0zBHI+hVl6pern5G4vTZNAM7n5Kxl4ufoJJ5LcGbBtIaoGymBA6onCWJZTOWT 48LpM1bLjlPsVrbI3+5hBK/xNmKWa8kJJGK/X89HI2RzR5Do4pL1tDhd4lX/HBSZDQTHCHMLO/T KtR9H9fIEGZaMbYx5MZIsy7yoqIUl7tEBfpsSrAiK6wXWaurfSK7NLT8IJ7fJiedzYI1uQc/YE/ 6+6tMqi4W7ASuc4IizGwjadGEeFRSFxys7BVXSO1RK0Zm4nSNFJtSajuoGP/YTdxYrURuZzV6ic DqI4kjUWLKxXoeba8slbwKWHzS2rkJ3aHCMIPN56SGAQ4o2H/4j+oEZzZY3YvnKI+LJ3wsi4i64 u5UQqIiF4/DoPQ430NU6HRSCNKU72St8nWsVC+VMf9YyjHqRL6WEjlTI7MCmabx2Zz8A9l8yT8l c+SVToOC0XVk3GoajvAI46qwa0k1VN9DOzjfWMFqd8812NVdoAgO9DN2sLYWi2SAhaBqHWDTEDs k+CDd6Mypbh0S7VKN+u/XS0KJFEgvfK68MvmU4wtlw2Fw93ylotEpmSJyWSikiVQPoKVWecSiK9 zC8= X-Received: by 2002:a05:600c:4fc1:b0:49d:2536:402e with SMTP id 5b1f17b1804b1-4a19a9cf1e6mr109315605e9.30.1791880819403; Tue, 13 Oct 2026 01:40:19 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 32/86] target/arm: GICv5 cpuif: Add virtual support to IRS/cpuif HPPI APIs Date: Tue, 13 Oct 2026 09:38:39 +0100 Message-ID: <20261013083933.1024405-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881148340158500 Content-Type: text/plain; charset="utf-8" The APIs between the IRS and the cpuif for the IRS to tell the CPU that it has a new HPPI candidate and for the CPU to ask the IRS what its current HPPI candidate is do not currently allow for virtualization. Extend them to allow the IRS to tell the CPU about the candidate virtual HPPI and for the CPU to ask about the candidate virtual HPPI, using an extra 'virtual' parameter. This commit implements the CPU side of this interface, where a new virtual HPPI candidate makes us reevaluate our VIRQ/VFIQ status. As the IRS does not yet implement virtualization, it will always respond "no interrupt" when asked about the current virtual HPPI candidate. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 14 +++++++++++--- include/hw/intc/arm_gicv5_stream.h | 6 ++++-- target/arm/tcg/gicv5-cpuif.c | 11 ++++++++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index a362349e5ed..f714add1406 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -495,7 +495,7 @@ static void irs_recalc_hppi(GICv5 *s, GICv5Domain domai= n, uint32_t iaffid) * the cpuif asks for the current HPPI when it needs it * - the cpuif does not cache the HPPI on its end */ - gicv5_forward_interrupt(cpu, domain); + gicv5_forward_interrupt(cpu, domain, false); } =20 static void irs_recalc_hppi_all_cpus(GICv5 *s, GICv5Domain domain) @@ -526,16 +526,24 @@ static void irs_recall_hppis(GICv5 *s, GICv5Domain do= main) =20 for (int i =3D 0; i < cs->num_cpus; i++) { s->hppi[domain][i] =3D GICV5_PENDING_IRQ_NONE; - gicv5_forward_interrupt(cs->cpus[i], domain); + gicv5_forward_interrupt(cs->cpus[i], domain, false); } } =20 GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5Domain domain, - uint32_t cpuidx) + bool virtual, uint32_t cpuidx) { GICv5 *s =3D ARM_GICV5(cs); =20 assert(cpuidx < cs->num_cpus); + + if (virtual) { + /* + * Until we implement virtualization there is never + * an available virtual HPPI candidate. + */ + return GICV5_PENDING_IRQ_NONE; + } return s->hppi[domain][cpuidx]; } =20 diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index 641f3d0f499..21be859a233 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -180,6 +180,7 @@ void gicv5_activate(GICv5Common *cs, uint32_t id, GICv5= Domain domain, * gicv5_forward_interrupt * @cpu: CPU interface to forward interrupt to * @domain: domain this interrupt is for + * @virtual: true if this is a virtual interrupt for the resident VPE * * Tell the CPU interface that the highest priority pending interrupt * that the IRS has available for it has changed. This is the @@ -198,12 +199,13 @@ void gicv5_activate(GICv5Common *cs, uint32_t id, GIC= v5Domain domain, * HPPI info via a function call, so we do not need to pass it across * here. */ -void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain); +void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain, bool virtual= ); =20 /** * gicv5_get_hppi * @cs: GIC IRS to query * @domain: interrupt domain to act on + * @virtual: true to ask for the virtual HPPI for the resident VPE * @cpuidx: IRS CPU index of this CPU interface * * Ask the IRS for the highest priority pending interrupt that it has @@ -211,7 +213,7 @@ void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain d= omain); * protocol is the outstanding interrupt sent with a Forward packet. */ GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5Domain domain, - uint32_t cpuidx); + bool virtual, uint32_t cpuidx); =20 /** * gicv5_deactivate diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 0d38ed7b15b..5d0d599ddd5 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -170,7 +170,7 @@ static GICv5PendingIrq gic_hppi(CPUARMState *env, GICv5= Domain domain) return GICV5_PENDING_IRQ_NONE; } =20 - irs_hppi =3D gicv5_get_hppi(gic, domain, env->gicv5.cpuidx); + irs_hppi =3D gicv5_get_hppi(gic, domain, false, env->gicv5.cpuidx); =20 /* * If the best PPI and the best interrupt from the IRS have the @@ -337,13 +337,18 @@ static void gic_recalc_virt_ppi_hppi(CPUARMState *env) env->gicv5_cpuif.virt_ppi_hppi.prio); } =20 -void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain) +void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain, bool virtual) { /* * IRS HPPI has changed: recalculate the IRQ/FIQ levels by * combining the IRS HPPI with the PPI HPPI. + * If this is a virtual interrupt, do similarly for VIRQ/VFIQ. */ - gicv5_update_irq_fiq(&cpu->env); + if (virtual) { + /* Here we will eventually update the VIRQ/VFIQ state */ + } else { + gicv5_update_irq_fiq(&cpu->env); + } } =20 void gicv5_update_ppi_state(CPUARMState *env, int ppi, bool level) --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881322; cv=none; d=zohomail.com; s=zohoarc; b=APf0PrlebJZdHNY2qyZ3G0HmVzwUHiGlFpYwLPEopIX/MAG1Mh8+96gXmsyXxcZdyda+GgA1ncuvwVdUEcvlYMt+06oPm6SdiD4fyoUvBuS68I/C7RaI0RyZAz1guRxDGA2sL/lZlIRRtDMBah2ciWTOFCcoAMZ6ZTKbfK8xKk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881322; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=qRt/rpYOT3lnzhVYlcKmgZdrFw/mrh/LFo/lM8UvZ8s=; b=BCWxtR22TmJsLTdjVF7iTrgWqKTafFXtZCv/6i4Qsb9PEpz6munWvnzceoe0JnEzipuaVvgdo029wh/IGSZekBrosvxjzOxUh5OCmmpuEuS73ekVJsw8xFEMOOzm8SNrFYx9S+NZXs7F517I/XrVdkp0mH7FfffyurZMnxeJEG8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881322435411.4862630032063; Tue, 13 Oct 2026 01:48:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4O-0000xZ-NN; Tue, 13 Oct 2026 04:41:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3e-0007c5-LK for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:27 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3b-0007vF-6N for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:26 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4956869750eso20245505e9.2 for ; Tue, 13 Oct 2026 01:40:22 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880822; x=1792485622; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=qRt/rpYOT3lnzhVYlcKmgZdrFw/mrh/LFo/lM8UvZ8s=; b=JhGvwP+KlygYRwzVUGiuIw3B33GmjyjXVOU68NQhdECV+j14vO+oTOr23NiUVGXBzW YjM/hDyktPb+717rSXqGEyYDg4MPpzqzXGrWNl/6N/RH0d0leO+I2Vhq+P0wth1GbAt+ gKwAZyggwIj9pYx+mRHfFgne2rM4TWRVdkNwNTfoWnkiNdKz4Sr3qRX6sPyj7NmD2Ilc 1zPNRVJog4HEE5BfmHcE25pyhgHCdMCqvhUeDEKx6gw6fc6j7xR/PpahwzheqywqQdqS hyLN2ia9YFKZbA+hBZoXg3mPtX3TQJTJkiUD4ECaNGmJbH+k8QOGqBCTECB4Ljj/Ogxe TeLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880822; x=1792485622; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=qRt/rpYOT3lnzhVYlcKmgZdrFw/mrh/LFo/lM8UvZ8s=; b=ytTLYVhJ7PVwX/lryzQmUsPMcZWWQqLSpqioIvYa/8EIG6Y1xc38xAgQtuJi+hxhjz MfEqOljvuqbw6ErvIAT4+7mh+A/Wf7/U9SODa1qcwhvYKRrSZ9IjJChVgfl1H342Vqmq Hm0ziiy3v0H8h38uwtxzyScTS2UisQk7jtaXCGS08sTtSe5BuxpMFgHIfEdzVMTPvhR8 dqXM6AqvIQJKvmBN9kRICygnUO+n6OiCkzp2Y+Y93///C69egLXia5n94bNezT7hhW+b 88qfvUy8eeu9pcrjfxmh5eskMtBbsgn4XzSs7acEbPDb2QTuO+aoZVidwxQHubXmWdTr uRXg== X-Forwarded-Encrypted: i=1; AKwUvBy0ze4AfSvIIyzqZeIdYdyONO0Rx1tGc/xX+B7GCGaKveyCXzEenbRYGoWJYTfUuruRYKEdAvC2e11j@nongnu.org X-Gm-Message-State: AFq9FYIwuM3g5t18DJe17n00TCKlcpvFRL+TRz6hJoSrVbBHINnOJm7K nuSzWcccX092XeLasXvLwMSDTqemMCLtLD8P+DkGiHeBBzvmyf4M6X7lEKKBn+7UIh4juoRHJhI WfWpF+zk= X-Gm-Gg: AYBFou1p+R2ZMEfChcNKdC6P83exYwdDy+9oUZ6FQtSGrHmuWyggphSgaZXM1bpNyFo zzSevIceKEnsoAdWjD/YbQh9VtsjEohaGREQeii5SUnD6TTIG7chQKu061L7EEun5MCaOhsG+Fp JoVUn6SCLf73dQYt9UVCKilh2gl5eDuJ/NyT5Epz+ICGwMC6OwjBHTxWPwUZ0nOpEnXpcHjbjxs 1xNxsPpdJdhy2TYMRGQ25eZupK/+c4zbtQ9cnLUUDbLP6JMpq2d5fqPqiQDPkY4ETIecwrUBvgm xHpyBvNBrbCQtNQSZrj7bN48VlUMCt6B0Hra31c6Q8CegCJoW4q3JXNo/tkiaY5kRt68GTxSi/S GeP8Cp1yqCuGW4gGUefMF/Bapk9CzHXol/Zv15hEZ2pN/LLgp72yvONxvR4u0KyTdVsOMDOlKqb /RIxgnQX+1dcDX8TrbKF5ksebnia+e/g2LTbtgl6zjm/ByCWsnPctQ7IlOjd8t8BX1FsUjISnhc mZ+vzDiQzd/8eSkDSjS+hmGeSiPSWtq0Wuuep9/KgxIxF039578knBAjokA0HKR6LJcKpzCafPf Apw= X-Received: by 2002:a05:600c:3e83:b0:4a1:6d35:779a with SMTP id 5b1f17b1804b1-4a18e446880mr201721765e9.3.1791880821725; Tue, 13 Oct 2026 01:40:21 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 33/86] target/arm: GICv5 cpuif: Implement ICV_HPPIR_EL1 Date: Tue, 13 Oct 2026 09:38:40 +0100 Message-ID: <20261013083933.1024405-34-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881323605158500 Content-Type: text/plain; charset="utf-8" Implement the redirection of ICC_HPPIR_EL1 to the virtual ICV_HPPIR_EL1 register. This requires us to calculate the highest priority pending interrupt for the virtual interrupt domain, using a gic_virt_hppi() function that works in a similar way to the existing gic_hppi() for the physical interrupt domains. As we have not yet implemented IRS_CONTEXTR_EL2, we leave a placeholder "IRS does not have a virtual HPPI candidate"; we will fill this in later by calling gicv5_get_hppi() when the IRICHPPIDS bit in that register tells us we should. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 73 +++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 5d0d599ddd5..d2454011b40 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -70,6 +70,9 @@ FIELD(ICC_HPPIR_EL1, HPPIV, 32, 1) FIELD(ICH_VMCR_EL2, EN, 0, 1) FIELD(ICH_VMCR_EL2, VMPR, 27, 5) =20 +FIELD(ICH_VCTLR_EL2, EN, 0, 1) +FIELD(ICH_VCTLR_EL2, V3, 1, 1) + /* * We implement 24 bits of interrupt ID, the mandated 5 bits of priority, * and no legacy GICv3.3 vcpu interface (yet) @@ -153,6 +156,13 @@ static uint64_t gic_running_prio(CPUARMState *env, GIC= v5Domain domain) return hap < 32 ? hap : PRIO_IDLE; } =20 +static uint64_t gic_virt_running_prio(CPUARMState *env) +{ + /* Return the current virtual running priority */ + uint64_t hap =3D ctz64(env->gicv5_cpuif.ich_apr_el2); + return hap < 32 ? hap : PRIO_IDLE; +} + static GICv5PendingIrq gic_hppi(CPUARMState *env, GICv5Domain domain) { /* @@ -196,6 +206,59 @@ static GICv5PendingIrq gic_hppi(CPUARMState *env, GICv= 5Domain domain) return best; } =20 +static GICv5PendingIrq gic_virt_hppi(CPUARMState *env) +{ + /* + * Return the current highest priority pending interrupt for the + * virtual interrupt domain, if it has sufficient priority to + * preempt. If there is no interrupt that can preempt we signal + * this by returning a struct with prio =3D=3D PRIO_IDLE. + */ + GICv5PendingIrq best, irs_hppi; + + /* + * R_ZKPVN: No virtual HPPI if EL2 is not implemented and enabled + * in the Security state identified by SCR_EL3.{NSE,NS}, or if the + * enable bits in ICV_CR0_EL1 (stored in VMCR_EL2) or + * ICH_VCTLR_EL2 are 0. + */ + if (!arm_is_el2_enabled(env) || + !(env->gicv5_cpuif.ich_vctlr_el2 & R_ICH_VCTLR_EL2_EN_MASK) || + !(env->gicv5_cpuif.ich_vmcr_el2 & R_ICH_VMCR_EL2_EN_MASK)) { + return GICV5_PENDING_IRQ_NONE; + } + + /* + * TODO: When we implement ICH_CONTEXTR_EL2, we need to check + * IRICHPPIDS and if it is 0 get the IRS candidate HPPI. For now, + * set irs_hppi to "no candidate". + */ + irs_hppi =3D GICV5_PENDING_IRQ_NONE; + + /* + * If the best PPI and the best interrupt from the IRS have the + * same priority, it's IMPDEF which we pick (R_VVBPS). We choose + * the PPI. + */ + if (env->gicv5_cpuif.virt_ppi_hppi.prio <=3D irs_hppi.prio) { + best =3D env->gicv5_cpuif.virt_ppi_hppi; + } else { + best =3D irs_hppi; + } + + /* + * D_MSQKF: an interrupt has sufficient priority if its priority + * is higher than the current running priority and equal to or + * higher than the priority mask. + */ + if (best.prio =3D=3D PRIO_IDLE || + best.prio > FIELD_EX64(env->gicv5_cpuif.ich_vmcr_el2, ICH_VMCR_EL2= , VMPR) || + best.prio >=3D gic_virt_running_prio(env)) { + return GICV5_PENDING_IRQ_NONE; + } + return best; +} + static void gicv5_update_irq_fiq(CPUARMState *env) { /* @@ -844,8 +907,14 @@ static void gic_icc_pcr_el1_reset(CPUARMState *env, co= nst ARMCPRegInfo *ri) =20 static uint64_t gic_icc_hppir_el1_read(CPUARMState *env, const ARMCPRegInf= o *ri) { - GICv5Domain domain =3D gicv5_logical_domain(env); - GICv5PendingIrq hppi =3D gic_hppi(env, domain); + GICv5PendingIrq hppi; + + if (gicv5_icv_access(env)) { + hppi =3D gic_virt_hppi(env); + } else { + GICv5Domain domain =3D gicv5_logical_domain(env); + hppi =3D gic_hppi(env, domain); + } =20 if (hppi.prio =3D=3D PRIO_IDLE) { /* No valid interrupt */ --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791880861; cv=none; d=zohomail.com; s=zohoarc; b=hU1da3roT1s7vdFEsVY1Ro7uka7RislF0qweoXXYJIdoZCj7ASZiUkjK+luMWUfqmLtzoT07YJpz2QVCmDj9kiLFYhwMfUlwxMUSlPJYWpTtIrO9BxKFOSLmxJDO+eN+QuM7rG4qylaqO/XgmFOFAUJt2tvCQuXHuDp9hBQFuNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880861; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=gzfEd+fMuzIkl5MPbXsWVV3S6TkI1FXs7WFleXHIxOA=; b=KzB0xc3ddQi4pY/KRuvMfNFePQr9+b/4q/z0x/fwUV3uGJ8Ylt6/kRBDv1b6AuQ6ZHBJXt8zrNEErGfEaJi+Vv6XR7c4/PI2cyy7BIEgwCv6Rjzw6TpoXf7z1GryFrvLbmSAfeHJ4mvGBTMHMUgikbpl8m09k8DrrTyc32MHZhw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791880861905120.39316865422143; Tue, 13 Oct 2026 01:41:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY3w-0008La-Fd; Tue, 13 Oct 2026 04:40:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3f-0007cw-EK for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:27 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3c-0007ve-FW for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:27 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4a021c809e3so26435245e9.0 for ; Tue, 13 Oct 2026 01:40:24 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880823; x=1792485623; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=gzfEd+fMuzIkl5MPbXsWVV3S6TkI1FXs7WFleXHIxOA=; b=lGCnE8plH62BTdjaKYZf+Uj2+2y9GUG25IoweJhfWi819KdsCxIpOk76/jgMV3DKLp MRoVrhxoKM4DKrI5Q9NhUxRyChiZphpx8Ux9OvFKm93kG6GBAcHdyP1NsBVn0UKbg9oW SDDhtHNpJvf31qJU5T1WuOHN1qD/XlWpwsq58kFzZe7Y8D+kpfCEyTMOLzibSWAeudKE n9paoYrdx0l2i5sZK88HoDcxHpHF+IElzAVtWb143G1w7A31/EXVB/Hl8uI4Ph+dfqcc S1EO00gSkKc21aIVujG3vP7j0oqaIEDZgrvPFjwrHK3YLxDGNw1x+EkZEk6jwdYJnynN pOng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880823; x=1792485623; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=gzfEd+fMuzIkl5MPbXsWVV3S6TkI1FXs7WFleXHIxOA=; b=HiTOjifn9SCEG27AjvcEzGhUSU5LtiI/IosAlntDmZ0cDOumWljImze/Fv51GHvhHR AassM8sYwFOVfixGXj1MeCBvB3E+grJLUNZbHydNFNMz/0hbK4wvQW2Pbs2F+ZkH0Fuh rBsq2awT/tkj3x69oeBOgSWa19yncrcafimab50jgUcaGFBnhOUo8KSk3ueB1CthgYpt GGbpQTI3z7BVPBFUxoqhCoWx0Thn87YlUFrJY/8V9ali8f6VSsAk7qbSYHTS80CnX1vx 0NBmfvl/QsEcCPSMNmYuJcOh59WDPM1/aR6i2PiuCMUvvApdljgoM+KQiJNmFhLAbm8r fCLQ== X-Forwarded-Encrypted: i=1; AKwUvBwSdhrdMorcax3/96AOJ2H0l1bJYgJvDy1P+zHFUTIhzCUpmSoRl1GvJAKPUVFlTVTinxG5/RqJirgw@nongnu.org X-Gm-Message-State: AFq9FYKh+LRfwOl+r7kLKqTmWZgJeWwKGKnFk8GqVSk6K+PRtoaQG4jT 1aBwi6nHBlRuGuax22vpMFMZ2baLJ0ryu4BUS/sVMogu3cvZRJf41PgPqAwnvG+UWZvX0mIJEAQ jkEUr1bU= X-Gm-Gg: AYBFou0VWsW2WSoLI3bOZl+tKncDYKfdYYF0hzwMWs5gG6E/mIyFWZ1iaAoe7cQT6AI TAbS18JP5QrYrjqzRzifj17p7KYraQqnDfAp2o+zt1X9zMDZ2x6a5OHdmw8cNk4C9S1zUP9FGxk QGTaZjYnE0Ov/SPHwFEVLRDaLxMXXZgGJoYveoDa04wkGsunKRajA16K35Kti7A7twuJIXYoCFy uNhcGRVHaGDc2R7cWqeGJCXITWnyic6Frw/YzKxaNwN9aOotq2uTdGMGOsQgqsPgZLmbWjG2RRf Y8MQ8LWsPmlFAbIrZruXOMcvCLJEQVIccUJUV9h5eHDGLEXQFaxpNMddic/qyEXsuJMYqsTv97e WKplTb8CRifGRK2jR/jQbYRzntC2dkIJPwLVWwtXVFgUbJqdYuf0pk5XCH7qhbnLwTdQrVSzAyD B25ilb1iJ0wNjG1A79jflJ8jAx6hJ2Nq6oyLOM84qaROn40Goqtn9WdtETl6ERv9Y5jQPXa+vee JjFfAGJx7nXJsCWJTT9F9KFziGwWaS9KAFx9EVEyUNFoplSxpTn6tRukvYQLO1z+fz1BE3SRC/B blYnPYUEm7o3QQ== X-Received: by 2002:a05:600c:674a:b0:4a1:7cf8:5433 with SMTP id 5b1f17b1804b1-4a18e443ee9mr218545885e9.3.1791880822894; Tue, 13 Oct 2026 01:40:22 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 34/86] target/arm: GICv5 cpuif: Implement gicv5_update_virq_vfiq() Date: Tue, 13 Oct 2026 09:38:41 +0100 Message-ID: <20261013083933.1024405-35-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880863054158500 Content-Type: text/plain; charset="utf-8" Implement gicv5_update_virq_vfiq(), the virtual interrupt domain equivalent of gicv5_update_irq_fiq(). Based on the current highest priority pending interrupt for the virtual interrupt domain, we signal either the VIRQ or VINMI lines. For VIRQ and VINMI it is important that we call arm_cpu_set_irq() rather than calling cpu_interrupt() and cpu_reset_interrupt() directly, because arm_cpu_set_irq() handles the logical OR of the state from the cpuif and the value of HCR_EL2.{VI,VINMI} to produce the VIRQ/VINMI signals seen by the rest of the CPU. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 43 +++++++++++++++++++++++++++++++++++- target/arm/tcg/trace-events | 1 + 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index d2454011b40..a938428b20a 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -310,6 +310,35 @@ static void gicv5_update_irq_fiq(CPUARMState *env) arm_cpu_set_irq(env_archcpu(env), ARM_CPU_NMI, superpriority); } =20 +static void gicv5_update_virq_vfiq(CPUARMState *env) +{ + /* + * Update whether we are signalling VIRQ or VFIQ based on the + * current state of the CPU interface. + */ + GICv5PendingIrq current_hppi; + bool virq, superpriority; + + /* + * Only the legacy vCPU interface signals VFIQ, and we don't + * implement that yet. So we leave ARM_CPU_VFIQ and ARM_CPU_VFNMI + * at their default unasserted levels. + */ + + /* + * We signal VIRQ if there is a HPPI of sufficient priority for + * the virtual interrupt domain. It has Superpriority if its + * priority is 0 (in which case it is CPU_INTERRUPT_VINMI). + */ + current_hppi =3D gic_virt_hppi(env); + superpriority =3D current_hppi.prio =3D=3D 0; + virq =3D current_hppi.prio !=3D PRIO_IDLE && !superpriority; + + trace_gicv5_update_virq_vfiq(virq, superpriority); + arm_cpu_set_irq(env_archcpu(env), ARM_CPU_VIRQ, virq); + arm_cpu_set_irq(env_archcpu(env), ARM_CPU_VINMI, superpriority); +} + static void gic_recalc_ppi_hppi(CPUARMState *env) { /* @@ -398,6 +427,8 @@ static void gic_recalc_virt_ppi_hppi(CPUARMState *env) =20 trace_gicv5_recalc_virt_ppi_hppi(env->gicv5_cpuif.virt_ppi_hppi.intid, env->gicv5_cpuif.virt_ppi_hppi.prio); + + gicv5_update_virq_vfiq(env); } =20 void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain, bool virtual) @@ -408,7 +439,12 @@ void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain = domain, bool virtual) * If this is a virtual interrupt, do similarly for VIRQ/VFIQ. */ if (virtual) { - /* Here we will eventually update the VIRQ/VFIQ state */ + /* + * We don't need to check here for a mismatch between domain + * and the domain of the resident VPE, because that will + * be checked when gic_virt_hppi() calls back into the IRS. + */ + gicv5_update_virq_vfiq(&cpu->env); } else { gicv5_update_irq_fiq(&cpu->env); } @@ -775,12 +811,14 @@ static void gic_ich_vctlr_write(CPUARMState *env, con= st ARMCPRegInfo *ri, uint64_t value) { raw_write(env, ri, value); + gicv5_update_virq_vfiq(env); } =20 static void gic_ich_vmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { raw_write(env, ri, value); + gicv5_update_virq_vfiq(env); } =20 /* @@ -798,6 +836,7 @@ static void gic_icc_apr_el1_write(CPUARMState *env, con= st ARMCPRegInfo *ri, =20 if (gicv5_icv_access(env)) { env->gicv5_cpuif.ich_apr_el2 =3D value; + gicv5_update_virq_vfiq(env); } else { GICv5Domain domain =3D gicv5_logical_domain(env); env->gicv5_cpuif.icc_apr[domain] =3D value; @@ -844,6 +883,7 @@ static void gic_icc_cr0_el1_write(CPUARMState *env, con= st ARMCPRegInfo *ri, vmcr =3D FIELD_DP64(vmcr, ICH_VMCR_EL2, EN, FIELD_EX64(value, ICC_CR0, EN)); env->gicv5_cpuif.ich_vmcr_el2 =3D vmcr; + gicv5_update_virq_vfiq(env); } else { /* * For our implementation the link to the IRI is always connected, @@ -889,6 +929,7 @@ static void gic_icc_pcr_el1_write(CPUARMState *env, con= st ARMCPRegInfo *ri, vmcr =3D FIELD_DP64(vmcr, ICH_VMCR_EL2, VMPR, FIELD_EX64(value, ICC_PCR, PRIORITY)); env->gicv5_cpuif.ich_vmcr_el2 =3D vmcr; + gicv5_update_virq_vfiq(env); } else { GICv5Domain domain =3D gicv5_logical_domain(env); =20 diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index da25ec994cc..71f1369fcda 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -9,4 +9,5 @@ gicv5_gicr_cdia(int domain, uint32_t id) "domain %d CDIA ac= knowledge of interrup gicv5_cdeoi(int domain) "domain %d CDEOI performing priority drop" gicv5_cddi(int domain, uint32_t id) "domain %d CDDI deactivating interrupt= ID 0x%x" gicv5_update_irq_fiq(bool irq, bool fiq, bool nmi) "now IRQ %d FIQ %d NMI = %d" +gicv5_update_virq_vfiq(bool virq, bool vinmi) "now VIRQ %d VINMI %d" gicv5_update_ppi_state(int ppi, bool level) "PPI %d source level now %d" --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881119; cv=none; d=zohomail.com; s=zohoarc; b=LK3F+/fN9GKJvh4wrFMAS28gO4t29NDFV9dd6sabXNbEABw9fyt/ZdfpXTF0Piu065Ohnc2Qx4BTBMcgYRX/XpN/6+FjGIS0DDI509uQ5h1J2egin7/x6UCLpJYDun96x+u3eppil71CzuJ4s8hPT2mQW9WJwUXfAcFkKP5Xs8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881119; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=vTvIfdyX/SM1rGf15Fby2Qgem7tDHZaoRHeVArtn0is=; b=h3NyYRxYQ9VRDs/Aa4bxGxLJ7GiRhTHfGEbaMLT4PMztSbk9wVMQpCEM03Sv6R8IPIfczBJ4aQ3CZ7P6EVailiLBhk98Ff5MCnTCApNriaFKnCfZcQrw3nOUgtPznP7r/uNJ0RFGHqPMOxmWlgwcPP2+cosFseuz43TR6vsKETo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881119099838.3366168497197; Tue, 13 Oct 2026 01:45:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4P-0000zY-Bn; Tue, 13 Oct 2026 04:41:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3g-0007g8-OG for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:28 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3d-0007vr-Lz for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:28 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a02667ccebso18658625e9.0 for ; Tue, 13 Oct 2026 01:40:24 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880824; x=1792485624; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=vTvIfdyX/SM1rGf15Fby2Qgem7tDHZaoRHeVArtn0is=; b=Uv9Md4Bo/wJV2y1IN3oxZBgkOeaAvsqusKB0zpUJ5e+zy/7VAmQSQMHNDCl1PkjfuA bNXaga12nbumwQgbMgaaRYZ0LMKcfy8owDE2bugv3LHjYM1c5e5dr3ZStKE56Ja9wMhl neMfNFVOb2c/FrUIqd8YzTsYKks6q7Kl1cVUVE8QVXtJibcAkUQVPNaApCaMjk5vKXgH NmdzuOnj39Ly83D/TKxGvC6t4KrycqZUdOnkA7W5XF8a9YSZan6kf9DscLUiLstwZhio d2mz0D8DdxBN0MUmrY776o1W9ILuBGsvuXAONpugbXzDkI2q9ixn0qxiGR9P0MHAzfzO 3ESg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880824; x=1792485624; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=vTvIfdyX/SM1rGf15Fby2Qgem7tDHZaoRHeVArtn0is=; b=qu+TQgmoir/A/xX9m+t2eeQggBkID9ed3LOQe4GXe1YaNt00VPFxBKiega1EfG9xAl xPGQdZogvzrs7w1dchEbl5yKere7EAuPcfEYPdD17KxdZmw2LDGaFCfmsRGMs7xi+uM8 8wE2p/ZzVohKjRFXg36tHDtytffUXaEJQ0iV8fzcroxEGS9+IpVg4EQrxYgsqqHO8Rqr b/rQyvyusdEv/izudf9sLmlSeac4Szi0/2Jlf9dtpOOdhJ411VUwy7aKRf+P3K+bVj8V 6xlNTSPoosjsgBww4wX+N9pMZqZGGVNNT741Na7gbvXPdhfRhKZEjylzQem2CoYIb+gO Q3qw== X-Forwarded-Encrypted: i=1; AKwUvBxkOat9uO7WVbVTkQb2TOpIVJcX/6lSNQPxeNlQbU/k+lhiT4QuGUeNkFUBmEua8Ha5kR65NzS2b/j/@nongnu.org X-Gm-Message-State: AFq9FYJDdLa9rsKxOEBkn+tZxilQGSsblH+IO94SBjt/yWIK8YL7IhaX DEXt16XaqiaM2F5pnq15N75ZTYn/FXLE09NeFefOm8kxmJuOR/Bsjy7N/5nWD0Q75UU= X-Gm-Gg: AYBFou0dnlkb8UUc/8UCnk4Rv42FSytZsId4nUmFn7nh+loSw2Le6LDxSleraOBkW8R UjPlIFP/sQMTow0wDnWc125tOvjoF6sC8zmu1nqdCxI6T2Vty6wHeBaYTAJT9FJHij7zDPiAGOg CUX5dSI0C3hEtpmqKTpnVZ8Cns2pa2wTI2b/Y/3lawURcMr399NJR5Tbd5lCB7+soK10xxefLcn +BGzjeMWjd6pNTH10xDqfQ3MG7xEIM7FXnff1iJu+lQPwW6wnXtNfk8LIeN93QPmLjH1ERG8Gud gWvxL7S17ZWHSpsPMT9iuqDwsSUvbGKwWFkfXmW0hE/VN279WxCS8uGhxVTBwP8aHD52qx+N7pP pHJefX/d4JuWAalre7hKulwrIs8guMImFvPSXRQa/mxykDvJk5oFUCtuEERwvq+VqoxQLAy9q4U DSoOJIHCLD0csqcSpnyN1ZGq7YOumwjJwNpABs2FQHUU2V+Upvm4W6QunLy6/i6J+QKp7ld1qFZ fdkS6mP9+HisGyXaxjd+W6iDToDVxJuDrmW/dKG3RBmULumHCzhKHlpzk3gMhNdfw7Z83NtdbfB T50= X-Received: by 2002:a05:600c:64c7:b0:4a1:8399:b74a with SMTP id 5b1f17b1804b1-4a18e4e5c7cmr216353315e9.31.1791880823818; Tue, 13 Oct 2026 01:40:23 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 35/86] target/arm: GICv5 cpuif: Implement ICH_CONTEXTR_EL2 Date: Tue, 13 Oct 2026 09:38:42 +0100 Message-ID: <20261013083933.1024405-36-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881119867158500 Content-Type: text/plain; charset="utf-8" The ICH_CONTEXTR_EL2 register is how the hypervisor tells the GICv5 to make a VCPU for a VM resident on a CPU, so that the IRS will forward virtual interrupts for that VCPU to this CPU. We implement this similarly to the GICv5 stream protocol, which uses a SetResident command to tell the IRS to make the VCPU resident. This will always fail until we have implemented the IRS's end of virtualization support. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 8 ++ include/hw/intc/arm_gicv5_stream.h | 30 +++++++ target/arm/cpu.h | 1 + target/arm/tcg/gicv5-cpuif.c | 121 +++++++++++++++++++++++++++++ target/arm/tcg/trace-events | 1 + 5 files changed, 161 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index f714add1406..5ac50acc786 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1263,6 +1263,14 @@ txfail: "physical address 0x" HWADDR_FMT_plx "\n", intid, l1_add= r); } =20 +bool gicv5_set_resident(GICv5Common *cs, GICv5Domain domain, bool valid, + uint32_t vpeid, bool db, uint8_t dbpm, uint32_t vm= id, + uint32_t cpuidx) +{ + /* Until we implement virtualization, SetResident always fails */ + return true; +} + /* Data we need to pass through to irs_clean_lpi_cache_entry() */ typedef struct CleanLPICacheUserData { GICv5Common *cs; diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index 21be859a233..162d55a8e6b 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -229,4 +229,34 @@ GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5D= omain domain, void gicv5_deactivate(GICv5Common *cs, uint32_t id, GICv5Domain domain, GICv5IntType type, bool virtual); =20 +/** + * gicv5_set_resident + * @cs: GIC IRS to send command to + * @domain: interrupt domain to act on + * @valid: true if setting resident VPE, false to clear it + * @vpeid: identifier of the VPE to make resident + * @db: true to request a doorbell + * @dbpm: doorbell priority mask + * @vmid: Virtual Machine identifier + * @cpuidx: IRS CPU index of this CPU interface + * + * Tell the IRS to make the specified VPE resident for this CPU. This + * corresponds approximately to the stream protocol SetResident command. + * + * Returns the Fault state: false if the SetResident operation + * succeeded, true if the VPE could not be made resident. Clearing the + * VPE always succeeds and returns false. + * + * For QEMU this is a synchronous operation: the function does not return + * until the IRS has either succeeded or failed in making the VPE resident + * (including identifying whether there is a pending virtual interrupt for + * the VPE and forwarding it by calling gicv5_forward_interrupt() if so). + * + * Unlike the stream protocol (where the IRS knows which CPU it is talking + * to), we have to pass the cpuidx to tell the IRS which CPU we are. + */ +bool gicv5_set_resident(GICv5Common *cs, GICv5Domain domain, bool valid, + uint32_t vpeid, bool db, uint8_t dbpm, uint32_t vm= id, + uint32_t cpuidx); + #endif diff --git a/target/arm/cpu.h b/target/arm/cpu.h index abaee5fc3a0..0d8c2176a43 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -599,6 +599,7 @@ typedef struct CPUArchState { /* And for the virtual interrupt domain */ GICv5PendingIrq virt_ppi_hppi; =20 + uint64_t ich_contextr_el2; uint64_t ich_apr_el2; uint64_t ich_vctlr_el2; uint64_t ich_vmcr_el2; diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index a938428b20a..2eb8184e329 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -73,6 +73,14 @@ FIELD(ICH_VMCR_EL2, VMPR, 27, 5) FIELD(ICH_VCTLR_EL2, EN, 0, 1) FIELD(ICH_VCTLR_EL2, V3, 1, 1) =20 +FIELD(ICH_CONTEXTR_EL2, VM, 0, 16) +FIELD(ICH_CONTEXTR_EL2, VPE, 32, 16) +FIELD(ICH_CONTEXTR_EL2, DBPM, 55, 5) +FIELD(ICH_CONTEXTR_EL2, DB, 60, 1) +FIELD(ICH_CONTEXTR_EL2, IRICHPPIDIS, 61, 1) +FIELD(ICH_CONTEXTR_EL2, F, 62, 1) +FIELD(ICH_CONTEXTR_EL2, V, 63, 1) + /* * We implement 24 bits of interrupt ID, the mandated 5 bits of priority, * and no legacy GICv3.3 vcpu interface (yet) @@ -821,6 +829,110 @@ static void gic_ich_vmcr_write(CPUARMState *env, cons= t ARMCPRegInfo *ri, gicv5_update_virq_vfiq(env); } =20 +static void gic_ich_contextr_write(CPUARMState *env, const ARMCPRegInfo *r= i, + uint64_t value) +{ + GICv5Common *gic =3D gicv5_get_gic(env); + GICv5Domain domain =3D gicv5_logical_domain(env); + bool valid =3D FIELD_EX64(value, ICH_CONTEXTR_EL2, V); + uint32_t vpe =3D FIELD_EX64(value, ICH_CONTEXTR_EL2, VPE); + bool db =3D FIELD_EX64(value, ICH_CONTEXTR_EL2, DB); + uint8_t dbpm =3D FIELD_EX64(value, ICH_CONTEXTR_EL2, DBPM); + uint32_t vm =3D FIELD_EX64(value, ICH_CONTEXTR_EL2, VM); + uint32_t cpuidx =3D env->gicv5.cpuidx; + bool fault; + uint64_t oldval =3D env->gicv5_cpuif.ich_contextr_el2; + bool vm_vpe_changed =3D (oldval ^ value) & (R_ICH_CONTEXTR_EL2_VM_MASK= | + R_ICH_CONTEXTR_EL2_VPE_MASK); + bool valid_changed =3D (oldval ^ value) & R_ICH_CONTEXTR_EL2_V_MASK; + + /* + * DB and DBPM are RAZ: they are write-only fields that have + * an effect when V is changed from 1 to 0. + */ + value &=3D ~(R_ICH_CONTEXTR_EL2_DB_MASK | R_ICH_CONTEXTR_EL2_DBPM_MASK= ); + + raw_write(env, ri, value); + + trace_gicv5_ich_contextr_write(cpuidx, value); + + /* + * Changing V definitely causes us to make a new VPE resident, or + * remove the old one. + * + * Changing VPE or VM while V=3D1 is CONSTRAINED UNPREDICTABLE + * (R_VFKHN): we choose to make the new VPE resident so that we + * can trust that the information we have in the register matches + * what the IRS thinks the resident VPE is. + * + * For writes that don't trigger a change of resident VPE, we only + * need to update our copy of the register, and recalculate + * interrupts if IIRICHPPIDIS changed. + * + * If we do change the resident VPE, the interrupt recalculation + * will happen when the IRS calls gicv5_forward_interrupt(). + */ + if (!(valid_changed || (valid && vm_vpe_changed))) { + if ((oldval & value) & R_ICH_CONTEXTR_EL2_IRICHPPIDIS_MASK) { + gicv5_update_virq_vfiq(env); + } + return; + } + + if (valid) { + /* Doorbell info is only relevant when clearing the VPE */ + dbpm =3D 0; + db =3D false; + } else { + /* The IRS knows what the VPE is so we don't need to tell it */ + vm =3D 0; + vpe =3D 0; + } + + fault =3D gicv5_set_resident(gic, domain, valid, vpe, db, dbpm, vm, cp= uidx); + + if (valid) { + /* + * We only update F for a VPE set, not a clear. + * + * On a failure, it is CONSTRAINED UNPREDICTABLE whether V + * reads as 0 or 1 (R_NHCGW); we choose to set it to 0 so we + * can reliably use it to track whether a VPE is resident. We + * use this for instance in GIC VDPEND: we trust the V and VM + * fields to be accurate. + */ + value =3D env->gicv5_cpuif.ich_contextr_el2; + value =3D FIELD_DP64(value, ICH_CONTEXTR_EL2, F, fault); + if (fault) { + value =3D FIELD_DP64(value, ICH_CONTEXTR_EL2, V, 0); + } + env->gicv5_cpuif.ich_contextr_el2 =3D value; + } +} + +static void gic_ich_contextr_reset(CPUARMState *env, const ARMCPRegInfo *r= i) +{ + /* + * This register resets to zero, which includes telling the IRS + * that there is no longer a resident VPE for it. + * + * It doesn't matter if the domain we pass here doesn't match the + * domain of the VM/VPE: as with the GIC stream interface (see + * rule R_PYWKM) our IRS ignores the mismatch for a SetResident + * request with valid =3D false. + * + * As this is a reset fn we may get here before the GIC pointer + * has been set up yet, so unusually we need to check for NULL> + */ + raw_write(env, ri, 0); + GICv5Common *gic =3D gicv5_get_gic(env); + + if (gic) { + gicv5_set_resident(gic, gicv5_logical_domain(env), + false, 0, false, 0, 0, env->gicv5.cpuidx); + } +} + /* * ICC_APR_EL1 is banked and reads/writes as the version for the * current logical interrupt domain. @@ -1500,6 +1612,15 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_vctlr_el2), .writefn =3D gic_ich_vctlr_write, }, + { .name =3D "ICH_CONTEXTR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 11, .opc2 =3D 6, + .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .nv2_redirect_offset =3D 0xb08, + .accessfn =3D access_gicv5_ich_reg, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ich_contextr_el= 2), + .writefn =3D gic_ich_contextr_write, + .resetfn =3D gic_ich_contextr_reset, + }, { .name =3D "ICH_VMCR_EL2", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 12, .crm =3D 11, .opc2 =3D 7, .access =3D PL2_RW, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index 71f1369fcda..75f40c44f26 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -11,3 +11,4 @@ gicv5_cddi(int domain, uint32_t id) "domain %d CDDI deact= ivating interrupt ID 0x gicv5_update_irq_fiq(bool irq, bool fiq, bool nmi) "now IRQ %d FIQ %d NMI = %d" gicv5_update_virq_vfiq(bool virq, bool vinmi) "now VIRQ %d VINMI %d" gicv5_update_ppi_state(int ppi, bool level) "PPI %d source level now %d" +gicv5_ich_contextr_write(uint32_t cpuidx, uint64_t value) "cpuidx %d ICH_C= ONTEXTR_WRITE 0x%" PRIx64 --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881334; cv=none; d=zohomail.com; s=zohoarc; b=D9sPZnWxnoSGlFdiMamdlLr4xXHudnToavSggHVoWX0guv9WwCfPOj6dElVevR4sJUFIo3SMsQlWdKUNDFvltQo6YEkJxOByxBp4jQw52nU5E7E6RKNeY376IX6n5KVDxobP4ob0s7haMJFss4B33kypgyeK49CSGisZ9TKTq3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881334; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=q/K/INR89Bv6VAIICicuXn9qF9wKrXQNAiWLKbQvRBc=; b=mFm289o5M5C+wiVZlWtpATLxLqFyeYymZSVMG14RH+LotCmks+I//uhVSya6hMnUbah29CHsAQhuH+E7BZQ6TZLTATlcWWpGZrPLPwIx0n7kLyIgDpa0Lwt7lcprr6CnfvlKZAQozBt0NP/h1B6hyCAZUddBPFuoVRLHvijVZcg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881334439567.7384011891467; Tue, 13 Oct 2026 01:48:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4R-000193-4D; Tue, 13 Oct 2026 04:41:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3h-0007m5-P6 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:29 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3f-0007wX-Sv for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:29 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4a018dc1f98so21195085e9.3 for ; Tue, 13 Oct 2026 01:40:27 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880826; x=1792485626; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=q/K/INR89Bv6VAIICicuXn9qF9wKrXQNAiWLKbQvRBc=; b=MDluzdadyBuLwKZdEPermr3tTnObLYdw+fw4SVDwqaRLg5GS27v9fRGgpdPuceGK/u ExfJLebZ/H6+R8tiDLNEcoueEnrqE/yMKaSd5dsG37La6BJzCqltw3JYmPhieW84499C bq8hDu6nXM2EaPZIIjWOz/01eqQ/YiPm6twggfXSes8egdHJ24lQ3dMLbVTd9/2nl/EU P4XaLYLjHlK+wL0dFR3ZH7GGlyHWWRsEzSUESN5BMgtzBduzBhUfwKHkU8gLkannLG59 5FQbwC/7OUrLVJ9pK2szKl3wk1fzSSE/ILZaJeax8BZyPErFBXbaDhHq/r4T7gYLRdqV TF5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880826; x=1792485626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=q/K/INR89Bv6VAIICicuXn9qF9wKrXQNAiWLKbQvRBc=; b=Be5q2RjoLBe+Gcw4Dz6hawWuJB0XDvWckbtK9gl6UbzOxg7yhKnVqSLEOjHiDSoieS HaDK37N/orFeZQQw/NsOzAweNvYYr2DRjDyAuL0Y9e/5TUUgot5a60w/r/AK5URQ8CLZ loRz3EILNe2QHpmOzwMEx4f9EvxRZ3tJD85PdN/boN8J5at3iik+3Wya0182kwArZJJ+ Y7efnA7wBp7mPjPzULt+XP3okl9Qz8wM0kZ5sa+EDsG7WMZlH0NDJMVcBTMgZAtyii/z DCKhpYoccFFHL0MZZiODQu3jRhUOFOA4lo9SCo0cRZRgSl8Y7MfslrfjHj7jrBI+hYY4 SxPA== X-Forwarded-Encrypted: i=1; AKwUvBzxYT0ckESWq4qFxoUpji/1yNy3TTrql6bxBwnt8+nXYUNpnq118QN4DqD5XqIu8/TeNz1EELbJI9rD@nongnu.org X-Gm-Message-State: AFq9FYJqatELKvNf4WJppfyJ9MB0cey5zYKULJiZHHtdBousBrk8p4NU vm8sz+wrGoIQ+f3FQ7kP0DHiULBtvDXZhteu+BbnmtoLtTM53yEWAusybHrbbFTc2Sd/sv5YXkn r2wVzQo8= X-Gm-Gg: AYBFou0Q1+HEHrvYmfg29H9f6S+ABfcDfZtcvHnEoBiH3cbNByXBa8BB68KfQB3pVZG 7OdGcSsry/vITgJWqhkq71hSCEcPREBLqo5f2RD0XXkrsUxRvH+uBv5alvkgyHrTsOfyi7AXFK3 ls050Izpg6QVwVq3qIvLEh3udlDbNObHWzdew2l9yJy0Xdy9LfqW8XX6B4te8dywEu2EYNyxIu+ X/Lht646if2o2TXVsYZGMpWdwCYgizE6Ig/SIBtz4BPb0UdfMvjimFeuwo3c8TLob0njuUebTqS P3Lh1RihAbXq8xEIjwBeuM4WHvhTmrLA365i3jiOyJqDEVDO6Hi9t1COSJ/UWMJfWgIKBvL6NtZ ak/wOBaFL//yeHqj/oJ/+uN1nBNrEYGWiWjAZWj4dDIuJHSOlBqEmxXC2Cd+vaR4H0RgIMM7ADy 8p5Qm3oNa6x1FT0tCdhirW8/oPUwbEJmN0/buFKHLKiEVAdjKm5NxBmO7cwsFHjjDU/l7rjkWH4 EXf9cjc9fAgGhttWVY3dP4Q5lr4rVoAteYQAMyQbcxmgfKf7j5foaMnTu1HkhRJyf1CUwvXWjmB Xs7Q X-Received: by 2002:a05:600c:19cd:b0:4a1:80d8:aedb with SMTP id 5b1f17b1804b1-4a18e49d9eamr229535035e9.11.1791880826322; Tue, 13 Oct 2026 01:40:26 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 36/86] target/arm: GICv5 cpuif: ask the GIC for the virtual HPPI Date: Tue, 13 Oct 2026 09:38:43 +0100 Message-ID: <20261013083933.1024405-37-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881335858158500 Content-Type: text/plain; charset="utf-8" Now that we have an implementation of ICH_CONTEXTR_EL2 and the API to the IRS provides a way to query the virtual HPPI candidate, we can fix the TODO remark in gic_virt_hppi() by making the cpuif ask the IRS for its virtual HPPI candidate. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 2eb8184e329..cbe233c61bf 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -214,6 +214,19 @@ static GICv5PendingIrq gic_hppi(CPUARMState *env, GICv= 5Domain domain) return best; } =20 +static bool gic_get_irs_virt_hppi(CPUARMState *env) +{ + /* + * Return true if we should ask the IRS for its candidate virtual + * HPPI. We do this only if we have a resident VPE and are not + * ignoring IRS candidate HPPIs because of IRICHPPIDIS. + */ + uint64_t ich_contextr_el2 =3D env->gicv5_cpuif.ich_contextr_el2; + + return (ich_contextr_el2 & R_ICH_CONTEXTR_EL2_V_MASK) && + !(ich_contextr_el2 & R_ICH_CONTEXTR_EL2_IRICHPPIDIS_MASK); +} + static GICv5PendingIrq gic_virt_hppi(CPUARMState *env) { /* @@ -236,12 +249,14 @@ static GICv5PendingIrq gic_virt_hppi(CPUARMState *env) return GICV5_PENDING_IRQ_NONE; } =20 - /* - * TODO: When we implement ICH_CONTEXTR_EL2, we need to check - * IRICHPPIDS and if it is 0 get the IRS candidate HPPI. For now, - * set irs_hppi to "no candidate". - */ - irs_hppi =3D GICV5_PENDING_IRQ_NONE; + if (gic_get_irs_virt_hppi(env)) { + GICv5Common *gic =3D gicv5_get_gic(env); + GICv5Domain domain =3D gicv5_logical_domain(env); + + irs_hppi =3D gicv5_get_hppi(gic, domain, true, env->gicv5.cpuidx); + } else { + irs_hppi =3D GICV5_PENDING_IRQ_NONE; + } =20 /* * If the best PPI and the best interrupt from the IRS have the --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881566; cv=none; d=zohomail.com; s=zohoarc; b=dym2syDDxHVZ4IcfYl18oJTp1Ey5/AigRtLpu2kfJIHb+zE9KUditpYvIZGmpyZ4TWjZzcU9UrmWfJvFE2T5rKVYar9conUUIA4leAa8P0CEguJ+IWK8DgMSQa+5W+AJk9zvEiPqMNsvJrvPvrWyJn7ki9uJesdAZmo9PrwCad4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881566; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=EEvv5QuQZixZDbJ9DHZNjQdel6lxSlPk/jCh6hqlfL8=; b=DqJeycT6VXu/TAenqlNze9/RvRXFMxMUt2tP0XoHlXGxHGCGRAjIcNG1XVcymo8t1OW/S2lgyMzGGwX8kuDshi3ndueo54ak20sTiB17mS5hP3Dbt1wtek/TTuvz7g65KfFU0ztW4Pnelb9uUYYDPZGkm3rXEeajUaCGG+A1cv8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881566855615.2321580419181; Tue, 13 Oct 2026 01:52:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4h-0001np-7o; Tue, 13 Oct 2026 04:41:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3j-0007oi-D9 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:31 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3h-0007ww-5C for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:31 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a171b677d2so15779785e9.0 for ; Tue, 13 Oct 2026 01:40:28 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880828; x=1792485628; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=EEvv5QuQZixZDbJ9DHZNjQdel6lxSlPk/jCh6hqlfL8=; b=oaqfxgiDpRXduVgGS0OpsqBac61LPo+Yt4DII59PB+PmUvazahzmbmgxfY4phDTH1V QCOJfXR4yNj9+3ZzDT/tZB/zlrX/p3EvfGZVGRhfk5u5mKMW2cXKC3PMqOxXzDnbwsjU y+cYYEIj4gYxd5xLaYtXFL//9TmFKyn8fakb47blF4l00qX3s8Pxpwxiut5GcumQw56/ nGz9aKr+vhgAakBAwcJp7dwkFAaZamVn8jnrkHRV45buSqutNn1Y9CYNEODiBhXfieu1 iXaMU/5raZFSB1C4+ramVFLiqBu5WnAPm7p7xFiUUK197zZ9lvcLSvDK+d4iRw0rcf1e bhZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880828; x=1792485628; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=EEvv5QuQZixZDbJ9DHZNjQdel6lxSlPk/jCh6hqlfL8=; b=t5rVaC2GFuQabLImLMogYvTWv+1IsdBUJGdRZeiTge6FYBNPR6ZqinHu+JJAxGdyQ8 A3q2eZAX+xdtBBjNVEfkoQ27Rk5ATChI2E+2F+ffqNqF/SrjhsLixGOYRK9WvwZzNZSN 3DTjZcvgYtYU6qfk22KwBvig3Azh56HEGcvT4kiVp6M7IHrgw83QXjRoJ9Jos2FEkmpc 8PpAGVPRCRlY9pjKV+aze/ZLe7Ft2APgwooJtsRjRxmh7FZJMbjB/EVWDkTeYcIacPoG tLHmbFNOtD+pJpiTl5YBZrKTvEbVSgQ78kuArE3uW8gWnPGjfPt7QEdJtMPyWIg78heE IPDQ== X-Forwarded-Encrypted: i=1; AKwUvBw/HdnAgNet82zDtpYhnMhnMvdxAD+uyLnNjUuAp6pJqjp2xD+WmY3hg9YPGUfgtYz1M+s1m8JNnJaM@nongnu.org X-Gm-Message-State: AFq9FYLEn2rKxYzBIEEM2XSmeJtJUmeHEZKlDLJwxeuPimx/F1skaAAq wbrKW5H5/Z+96RRjcOHGwGJtysx+4LbPzp0S0VHQSO+FICrII8+ml9M+DwfhQxNq4CjfCZWQSiR BTNX93qA= X-Gm-Gg: AYBFou2F6MX8dh/EafYiAfvtw3KaeLzxyH+hXynIqQHKxISEUC1kcMqmE7d/uL+cFe/ Aym3kBK4FH/Fcrs85Mhp7y+VT7a5eABls8OVF3l0p6tR+46Jai3Mx4k3q8FK2G5BMIvlAt8LhiE UCje7RBzGwra5X79SoLoDrbJhgqEw3rNgS0pTPGYUwReu6t9EVbzQoKiDlKkywcucqSDmbi2cGA jpunI6uWfDy0NYJTS9ETM/pu2hUSxK9knYNBK9J7esC+O/fxgfcpr7xynwWL9TUwMlyfjdGVYnH Hg6br/nXBLtKS0nDp1X7PZAN3US8008+xrFsMLHq2h6/voEBNitb95ql4xLAPNlw4qL1h1iAAv3 8395gmIndcVnn3aRlgYJhjg1Rq74Q52WOKm+7YBeegN+s6/nC5ZQi8TPRVTDU8E0TXZPcwq4Rtr dnooWHDOJA0LBHuE8wTyThr+3/BsrWo6hhT9RQfJql7N+K8V7DHXCcKKfGDbhR97mgs6w5VjXds BUCBG0j/YEGqtdr6Ohsar8wqm229afOXurP/uunnUMewjGmwkGYxDNOUCwTLzg+znIfNRK4LsUB U1Y= X-Received: by 2002:a05:600c:4ecc:b0:49c:fa21:e749 with SMTP id 5b1f17b1804b1-4a18e4d55f2mr264357825e9.31.1791880827229; Tue, 13 Oct 2026 01:40:27 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 37/86] target/arm: GICv5 cpuif: Handle LD/VD insns when setting domain/virtual args Date: Tue, 13 Oct 2026 09:38:44 +0100 Message-ID: <20261013083933.1024405-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881568427158500 Content-Type: text/plain; charset="utf-8" GIC system instructions come in several families where the prefix of the name indicates which interrupt domain they operate on: - LD* commands (opc1 =3D=3D 6) operate on the logical interrupt domain. - VD* commands (opc1 =3D=3D 4) operate on the virtual interrupt domain, which is the domain of the current resident VM, which is the same as the logical interrupt domain but with the virtual flag set. - CD* commands (opc1 =3D=3D 0) operate on the current domain, which is the virtual one if ICC accesses redirect to ICV, and the current physical interrupt domain otherwise. The actual operation of the command in each case is the same apart from the domain/virtual parameter selection. Currently we hardcode "virtual =3D false, domain =3D current physical interrupt domain" in our writefns for the system insns, which is only correct for the CD* commands when virtualization is not enabled. Generalize our code for implementing the various GIC system insns so they call a new function gicv5_domain_for_insn() which sets the domain and virtual parameters based on the insn family (which can be determined from the system insn's opc1 field) and whether the virtual CPU interface is enabled. This will make the CD commands work correctly in the virtual CPU interface, and will let us use the same writefns for the LD and VD insns as we do for the CD insns. This change is all we need for the CD* commands to handle the virtual interrupt domain correctly in most cases; the commands which don't simply pass the argument through to the IRS (CDEOI, CDDI, CDIA, CDNMIA) need further changes which we will handle in the following commits. VDPEND also needs adjustment as it has an extra argument from the guest to specify the VM (making it the only LD* or VD* command that has a different field layout from the CD* version). (The IRS will currently reject any commands with virtual=3Dtrue; we add virtualization support to the IRS later in the series.) Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 71 +++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index cbe233c61bf..f8d58b5a537 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -154,6 +154,39 @@ static GICv5Domain gicv5_current_phys_domain(CPUARMSta= te *env) return gicv5_logical_domain(env); } =20 +static GICv5Domain gicv5_domain_for_insn(CPUARMState *env, + const ARMCPRegInfo *ri, + bool *virtual) +{ + /* + * Return the domain and virtual flag to use when GIC system insns + * result in commands to the IRS. + * + * GIC system insns come in several families where the prefix of + * the name indicates which interrupt domain they operate on: + * + * LD* commands (opc1 =3D=3D 6) operate on the logical interrupt domai= n. + * VD* commands (opc1 =3D=3D 4) operate on the virtual interrupt domai= n, + * which is the domain of the current resident VM, which is the + * the logical interrupt domain but with the virtual flag set. + * CD* commands (opc1 =3D=3D 0) operate on the current domain, which is + * the virtual one if ICC accesses redirect to ICV, and the + * current physical interrupt domain otherwise. + * + * Returns the domain to use, and updates *virtual to return + * whether this is the virtual interrupt domain. The caller can + * then pass domain and virtual directly to the IRS functions. + */ + bool logical =3D ri->opc1 =3D=3D 6; + + *virtual =3D ri->opc1 =3D=3D 4 || gicv5_icv_access(env); + + if (logical || *virtual) { + return gicv5_logical_domain(env); + } + return gicv5_current_phys_domain(env); +} + static uint64_t gic_running_prio(CPUARMState *env, GICv5Domain domain) { /* @@ -507,8 +540,8 @@ static void gic_cddis_write(CPUARMState *env, const ARM= CPRegInfo *ri, GICv5Common *gic =3D gicv5_get_gic(env); GICv5IntType type =3D FIELD_EX64(value, GIC_CDDIS, TYPE); uint32_t id =3D FIELD_EX64(value, GIC_CDDIS, ID); - bool virtual =3D false; - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 gicv5_set_enabled(gic, id, false, domain, type, virtual); } @@ -519,8 +552,8 @@ static void gic_cden_write(CPUARMState *env, const ARMC= PRegInfo *ri, GICv5Common *gic =3D gicv5_get_gic(env); GICv5IntType type =3D FIELD_EX64(value, GIC_CDEN, TYPE); uint32_t id =3D FIELD_EX64(value, GIC_CDEN, ID); - bool virtual =3D false; - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 gicv5_set_enabled(gic, id, true, domain, type, virtual); } @@ -532,8 +565,8 @@ static void gic_cdpri_write(CPUARMState *env, const ARM= CPRegInfo *ri, uint8_t priority =3D FIELD_EX64(value, GIC_CDPRI, PRIORITY); GICv5IntType type =3D FIELD_EX64(value, GIC_CDPRI, TYPE); uint32_t id =3D FIELD_EX64(value, GIC_CDPRI, ID); - bool virtual =3D false; - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 gicv5_set_priority(gic, id, priority, domain, type, virtual); } @@ -546,8 +579,8 @@ static void gic_cdaff_write(CPUARMState *env, const ARM= CPRegInfo *ri, GICv5RoutingMode irm =3D FIELD_EX64(value, GIC_CDAFF, IRM); GICv5IntType type =3D FIELD_EX64(value, GIC_CDAFF, TYPE); uint32_t id =3D FIELD_EX64(value, GIC_CDAFF, ID); - bool virtual =3D false; - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 gicv5_set_target(gic, id, iaffid, irm, domain, type, virtual); } @@ -559,8 +592,8 @@ static void gic_cdpend_write(CPUARMState *env, const AR= MCPRegInfo *ri, bool pending =3D FIELD_EX64(value, GIC_CDPEND, PENDING); GICv5IntType type =3D FIELD_EX64(value, GIC_CDPEND, TYPE); uint32_t id =3D FIELD_EX64(value, GIC_CDPEND, ID); - bool virtual =3D false; - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 gicv5_set_pending(gic, id, pending, domain, type, virtual); } @@ -571,8 +604,8 @@ static void gic_cdrcfg_write(CPUARMState *env, const AR= MCPRegInfo *ri, GICv5Common *gic =3D gicv5_get_gic(env); GICv5IntType type =3D FIELD_EX64(value, GIC_CDRCFG, TYPE); uint32_t id =3D FIELD_EX64(value, GIC_CDRCFG, ID); - bool virtual =3D false; - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 env->gicv5_cpuif.icc_icsr_el1 =3D gicv5_request_config(gic, id, domain, type, virtual); @@ -585,8 +618,8 @@ static void gic_cdhm_write(CPUARMState *env, const ARMC= PRegInfo *ri, GICv5HandlingMode hm =3D FIELD_EX64(value, GIC_CDHM, HM); GICv5IntType type =3D FIELD_EX64(value, GIC_CDAFF, TYPE); uint32_t id =3D FIELD_EX64(value, GIC_CDAFF, ID); - bool virtual =3D false; - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 gicv5_set_handling(gic, id, hm, domain, type, virtual); } @@ -1108,7 +1141,8 @@ static uint64_t gicr_cdia_read(CPUARMState *env, cons= t ARMCPRegInfo *ri) { /* Acknowledge HPPI in the current interrupt domain */ GICv5Common *gic =3D gicv5_get_gic(env); - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); GICv5PendingIrq hppi =3D gic_hppi(env, domain); GICv5IntType type =3D FIELD_EX64(hppi.intid, INTID, TYPE); uint32_t id =3D FIELD_EX64(hppi.intid, INTID, ID); @@ -1185,7 +1219,8 @@ static void gic_cdeoi_write(CPUARMState *env, const A= RMCPRegInfo *ri, * Perform Priority Drop in the current interrupt domain. * This is just clearing the lowest set bit in the APR. */ - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); uint64_t *apr =3D &env->gicv5_cpuif.icc_apr[domain]; =20 trace_gicv5_cdeoi(domain); @@ -1203,10 +1238,10 @@ static void gic_cddi_write(CPUARMState *env, const = ARMCPRegInfo *ri, * current interrupt domain. */ GICv5Common *gic =3D gicv5_get_gic(env); - GICv5Domain domain =3D gicv5_current_phys_domain(env); + bool virtual; + GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); GICv5IntType type =3D FIELD_EX64(value, GIC_CDDI, TYPE); uint32_t id =3D FIELD_EX64(value, GIC_CDDI, ID); - bool virtual =3D false; =20 trace_gicv5_cddi(domain, value); =20 --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791880992; cv=none; d=zohomail.com; s=zohoarc; b=l3s9xThOskPVrjqzTlNug+n4HtxQM1JtAg6+eyOneUq/l9jqIHoZwEAcTE1viaizOeWHn7LfDKWzJSm+YNK/ClD/HQdj1/6LFe9gi87B7CdU7h9LBjPc6a3zja/in45hq3a8d/G+gej5nicc02+Gs7ZoNVCOlG0sWfNDsIeRxI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880992; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=RJzfMhjKu4TNbAp9oHPUvWIkRSlmWLw3udGjNBH4jJg=; b=BUsIqRDSkrE6a/TRuvNFQDNX3fxGkrWDsnqqOPR/0kfu8lOj6y0ddnk+IEqx3QsPTS4s7M+urLD7pErLEs7paRK7OJsjKLTGhtwy569YdwDG8tEOzsqwiaG+v7Fb20XrX5S9qSigvMXj72m36+hCkhE2YVx1x+VRcxHyomb3usA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791880992177793.1457802678922; Tue, 13 Oct 2026 01:43:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4U-0001No-Im; Tue, 13 Oct 2026 04:41:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3k-0007pp-4w for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:32 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3i-0007xH-FA for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:31 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4a16c1608faso34528885e9.0 for ; Tue, 13 Oct 2026 01:40:30 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880828; x=1792485628; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=RJzfMhjKu4TNbAp9oHPUvWIkRSlmWLw3udGjNBH4jJg=; b=S8LcU0/gBM0S6n+1I96LlQe9V5VzypPCosZIaLhK+ecFWP3GUEczP44w/g7dvpdSqK mDd3U8x8cy9SIhFA3o8bIPRvUMWg0l46moohU1PkHG9iz77fCx78GtTVh8LL3v6vS7hU 0AO1f9yzxMbMCkEMN9a8aPG/kul/wlhzWgjGMdDMZLmNBx2iltqEtIw2eCboVX4dJd5u oVFOF+T6EpPMc1H+LvaJBgvXrKcF3E4sVlYN7jYy4q6iNTLGVMMXy8OWfLOpbyPyKXIT OgIiAKPcrk6K5bu1MKXLTDnvVVNuaXaEh9r8O+Mzs2CLZ1ohFLTA7Py76BDPzo/CDLlm Bj1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880828; x=1792485628; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=RJzfMhjKu4TNbAp9oHPUvWIkRSlmWLw3udGjNBH4jJg=; b=RirmXFmNoL3I/R4ahUvmK8rgRcq573zMNNhAMA5SCFg4id44vLMHyi9vj9OXXSOcr7 8s32jNRdmT2hEcSydi75liOJObNQIulAg4z6rdLuRI9+NxI7+AFIBkW6/2Q7Hx+ZuhR6 xlpquwd0pBUOw7l4VNPEm1dzd8ArsXZWpgQyAjIj/Yd51OdWx799I4Ggr7HhQVCS6uzY Qjg0oliFTZIHHrbvTCMzRIRRuA3ifPRqaOTdeaV8g/ysVGDiWMgXmh+AV0UV1FpWIxmA a+5eSmLtm/5XNU5GTg5cVA2VI9tllB4frhctADF7ncqbQLrLXn10uT+8CGkie+3CdK1F 1B0w== X-Forwarded-Encrypted: i=1; AKwUvBwUUh8ASeZMF0k8CMLBZlh1mj+IHTX+9ALjdXVHmfvDreY2NrA0T6zuPoc4oS28SrMRG21sHqM3KGdo@nongnu.org X-Gm-Message-State: AFq9FYLxS5KscLL8EJnPzyOv3tJxV9v4Ko9gePloxYIZ/cs8iV8PlWeG 7V6se8mmJ6zTjeJvJkTg8wmrzvEq5gtL3I6iNiVN3qSXNaUBpk5DvYZc5se87/5CzzM= X-Gm-Gg: AYBFou2JebANK0orP809iWEAvLORKVlYXPl9uBmBe5wIrG+Ra+ZWRiNETjmkd1Q9oX8 vSSUMU5AdpA2tczESDV8SwkOmnh+h0YxU0xiNEIbNGwYs1l2L0b6V37j+XdWuSRz5tNjCOhBziu G7fRtsBFabldMhXp+D7FerjdEkiE0TNiew0PwUMUhZt/cEzoJdvewqRFTmtfTF/bz9iaRjwWg0c Kre9xcpP7AVTyZpS4DL5Nx8iC7809k+jSq5XbDMNtKpDT8BjeElUHRbM3We5BEd3YC4svnF5eOa h+rb3ewegNL9PY8EIB4QC7STVtL/pc8RbpCCHaO4deTyOvwPsbsVm2/DbG38FOzaY8m3u1vDXVb fBtaaLeOzszFLMgjduL4joMN2Ag5HLdT2bxFyMCo8ROGcpJdyV8/vDORR8SMhfmBUfUzA7LyU/Z mIuyo/LQU9SH89Wf8v88zfJyXx7Lsyw2Vh1VwiaIJF5gCwnX1ZXPrW1CbpT3xIY4soVdSsEFSJv sqsvWenaK19+tROew7MQxEiEPvBKJw78DI7tbGI2RI6J5GPFS3V/CPz17zwSZbJuxSCIBY9n7lR 3QE= X-Received: by 2002:a05:600c:154e:b0:49f:ffa2:1c72 with SMTP id 5b1f17b1804b1-4a18e49ad83mr230799995e9.11.1791880828182; Tue, 13 Oct 2026 01:40:28 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 38/86] target/arm: GICv5 cpuif: Handle virtual interrupts for GIC CDEOI Date: Tue, 13 Oct 2026 09:38:45 +0100 Message-ID: <20261013083933.1024405-39-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880993469158500 Content-Type: text/plain; charset="utf-8" GIC CDEOI does a priority-drop for the current interrupt domain; when this is the virtual interrupt domain we must update the virtual APR register rather than a physical one. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 21 ++++++++++++++++----- target/arm/tcg/trace-events | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index f8d58b5a537..aeacc812fe0 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -1221,13 +1221,24 @@ static void gic_cdeoi_write(CPUARMState *env, const= ARMCPRegInfo *ri, */ bool virtual; GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); - uint64_t *apr =3D &env->gicv5_cpuif.icc_apr[domain]; =20 - trace_gicv5_cdeoi(domain); + if (virtual) { + uint64_t *apr =3D &env->gicv5_cpuif.ich_apr_el2; =20 - /* clear lowest bit, doing nothing if already zero */ - *apr &=3D *apr - 1; - gicv5_update_irq_fiq(env); + trace_gicv5_vcdeoi(); + + /* clear lowest bit, doing nothing if already zero */ + *apr &=3D *apr - 1; + gicv5_update_virq_vfiq(env); + } else { + uint64_t *apr =3D &env->gicv5_cpuif.icc_apr[domain]; + + trace_gicv5_cdeoi(domain); + + /* clear lowest bit, doing nothing if already zero */ + *apr &=3D *apr - 1; + gicv5_update_irq_fiq(env); + } } =20 static void gic_cddi_write(CPUARMState *env, const ARMCPRegInfo *ri, diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index 75f40c44f26..8e7e4c119db 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -7,6 +7,7 @@ gicv5_recalc_virt_ppi_hppi(uint32_t id, uint8_t prio) "virt= ual domain new PPI HP gicv5_gicr_cdia_fail(int domain, const char *reason) "domain %d CDIA attem= pt failed: %s" gicv5_gicr_cdia(int domain, uint32_t id) "domain %d CDIA acknowledge of in= terrupt 0x%x" gicv5_cdeoi(int domain) "domain %d CDEOI performing priority drop" +gicv5_vcdeoi(void) "virtual interrupt domain CDEOI performing priority dro= p" gicv5_cddi(int domain, uint32_t id) "domain %d CDDI deactivating interrupt= ID 0x%x" gicv5_update_irq_fiq(bool irq, bool fiq, bool nmi) "now IRQ %d FIQ %d NMI = %d" gicv5_update_virq_vfiq(bool virq, bool vinmi) "now VIRQ %d VINMI %d" --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881189; cv=none; d=zohomail.com; s=zohoarc; b=N7fZg+kqQpjTLuJVV4kbe6PY1ypyk0NzeQKBlL5d3Zd3sliJVGiotZh/uO6R20sglE4jIfyTcTkFFrG8B86lAPO/XQjy91mzQKMXrmrWEUmeIuDRS6P11qZ4ANImezJY2qcsuOIV7dEGt0VC8GZZ5eS/ZLY97WB+yjbbmz3ISLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881189; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=EDSv94O3ngBElAdZ3d0QnS2OnkdxbvDnsDEH1rGBv50=; b=Z+lRriyaL4fzTRpcgQZkU8MVD5htV7UP2LSmJlkIGRmHOpJXK010tHHSokpTH9O496vCZVyUlGp4jl8ej0/tuixbbONrJ7vsjycWWYq2cdjjfUcVl4Kq2x0BnDc9BKDSw0dhROoRM3wigMtrNbyhV4lqHXZfuWi2pOqCTU0tFGU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881189137627.723789732193; Tue, 13 Oct 2026 01:46:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4X-0001YD-6f; Tue, 13 Oct 2026 04:41:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3l-0007xt-QG for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:34 -0400 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 1xGY3j-0007xY-SP for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:33 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-48c4649b35bso2482897f8f.3 for ; Tue, 13 Oct 2026 01:40:31 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880830; x=1792485630; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=EDSv94O3ngBElAdZ3d0QnS2OnkdxbvDnsDEH1rGBv50=; b=FuOvJdGW3PQc4jbQPheRxAPZZ5ucWIKDtBqUwf3GhlPULbtu+MxSJci/YuQur545nz OMG3WX8Pg72/LvjQrmyvlNnXjbG+GxbauWjuWg0s6JbiM5M4/D6trYsxuckWobnMsH04 RlqN+q5XW6j89IhpzYw2fE3hbRLy4iq+LeoP5l9iPcISgGqM3ovVenRjrF7/BEkCBvJ5 fOM7gjCTsTWeDzw7m9FAjRlvHaPcJpP880uGEVpSLusTRNWcJ4r1UhPcqjJjg0IFiVJr t6vfwijYbnceYNIpVJVnLzhR2FKO4XDoClQDE1Ni0TPwQe7+QleuPHzLE+aI0HUbyg7/ 3tBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880830; x=1792485630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=EDSv94O3ngBElAdZ3d0QnS2OnkdxbvDnsDEH1rGBv50=; b=i5pOJoZjAZ1JGpmY3cPjH0UYvDg+r4XBdG+F9eXvRGeGwlDN+rDqjRv5VTurOXVGn4 TF0aijgNHLmeoZQll2y4QDOFwZJsBl1xz98ZWVIBONCRzOk4wtWOycahXYK6SKu6dJ5d 57NFeF5yJxWzag1nXDwhEMtyKWpwqTBRx7M3alcKwkCKQ6lNV2IkKV6w7mcGTwUOrbeY 6SwXQn5CP2z4LEmE50sY6FX1n06K0QE7pUJqSxX1HdmaaEJKKpx5gWY5z+9Pz1wi/WmC gsG4FqPU4KydTX83tFai5o5JCTr9fYZE1e+Kl/1Dkh1PY5eiOO9vgLZ9AY3BYSpqAONm tqHQ== X-Forwarded-Encrypted: i=1; AKwUvBwpmcE6p3FhpIqoDUy5ZjfHwo5QlnZB/NJGUG9BbiiH15niMyzENOgiv+Cf2UL53avB6bM1tixqsJ1H@nongnu.org X-Gm-Message-State: AFq9FYLqwgpG50Q/j+Hz8H1JqcNIrS9Mc1+fnseoiQ1I4zSmflP4GMaL WfReuFXB3Xi2P+7OgSUYduHS7fvvwxGoG7+QQ+6VLi5LefPdn4A6dVRxq8uqbOvrDjQ= X-Gm-Gg: AYBFou3YKKFVYM63nY9KGff4LFTy+BmcAGpaFGHNeFjouvHky7P68wMJD6kqp0lABIT fpUVidlBgGhp4eZf0ZKXB12nnDxXSguxPaazrZm6e+0KOPVqOhf/aErbovBvHbFlHteCE5L4Tvo wwkDcdLM/LzhDPr+txsVR67xU6t2wyvkFvsPDuGxGtW9NHsc3phWwtUW0McxYcH7+PmsSGxFloN lInsuKMY9VAZwuyLJFxg9/Y89mPVLfyBd5yE6kODCPKI+0XqwP5uDnkErrdI0skWbO9A9/8YqRq roHTg0I9F6I4hZjJrG+bfvZE1wp52Bj8hmC2QVToMr2i9TCqkHdH2Viz+N+NZFbOmfXOGp0+q2J 6Gqlu1tYtEXCxMJgZZXRRj7UlXN7w+8eFwbJZFSaYzOVhv6jPA5FxiGGPpGTFLBMCRFJ6BH/6ho ONpOVJLlu4sE5PdCYnrFaYnzRQ81nXddBIhUtqLU1nyiw7PWMU6dnl40fECdhhL0GyjM3nqwrcn 0scB44ECv/a3yIkU1MZ3S9jilyvqmZ/vH0ZZOCMJBe2JYRJGmPVKMK09QImMAgAarwM6kx+5OO5 ASret35glYsWmw== X-Received: by 2002:a05:600c:1e0f:b0:4a1:7b87:8d34 with SMTP id 5b1f17b1804b1-4a18e4b46e1mr212171255e9.21.1791880830101; Tue, 13 Oct 2026 01:40:30 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 39/86] target/arm: GICv5 cpuif: Handle virtual interrupts for GIC CDDI Date: Tue, 13 Oct 2026 09:38:46 +0100 Message-ID: <20261013083933.1024405-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881191213158500 Content-Type: text/plain; charset="utf-8" Handle the virtual interrupt domain in our GIC CDDI implementation: for LPIs and SPIs we just pass through the "virtual" parameter, but for PPIs we must look at the virtual PPI state rather than the physical PPI state. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 11 ++++++++--- target/arm/tcg/trace-events | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index aeacc812fe0..c85d72b05d0 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -1254,7 +1254,7 @@ static void gic_cddi_write(CPUARMState *env, const AR= MCPRegInfo *ri, GICv5IntType type =3D FIELD_EX64(value, GIC_CDDI, TYPE); uint32_t id =3D FIELD_EX64(value, GIC_CDDI, ID); =20 - trace_gicv5_cddi(domain, value); + trace_gicv5_cddi(domain, virtual, value); =20 switch (type) { case GICV5_PPI: @@ -1268,8 +1268,13 @@ static void gic_cddi_write(CPUARMState *env, const A= RMCPRegInfo *ri, ppireg =3D id / 64; ppibit =3D 1ULL << (id % 64); =20 - env->gicv5_cpuif.ppi_active[ppireg] &=3D ~ppibit; - gic_recalc_ppi_hppi(env); + if (virtual) { + env->gicv5_cpuif.ich_ppi_active[ppireg] &=3D ~ppibit; + gic_recalc_virt_ppi_hppi(env); + } else { + env->gicv5_cpuif.ppi_active[ppireg] &=3D ~ppibit; + gic_recalc_ppi_hppi(env); + } break; } case GICV5_LPI: diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index 8e7e4c119db..31c6eafd8ed 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -8,7 +8,7 @@ gicv5_gicr_cdia_fail(int domain, const char *reason) "domai= n %d CDIA attempt fai gicv5_gicr_cdia(int domain, uint32_t id) "domain %d CDIA acknowledge of in= terrupt 0x%x" gicv5_cdeoi(int domain) "domain %d CDEOI performing priority drop" gicv5_vcdeoi(void) "virtual interrupt domain CDEOI performing priority dro= p" -gicv5_cddi(int domain, uint32_t id) "domain %d CDDI deactivating interrupt= ID 0x%x" +gicv5_cddi(int domain, bool virtual, uint32_t id) "domain %d virtual %d CD= DI deactivating interrupt ID 0x%x" gicv5_update_irq_fiq(bool irq, bool fiq, bool nmi) "now IRQ %d FIQ %d NMI = %d" gicv5_update_virq_vfiq(bool virq, bool vinmi) "now VIRQ %d VINMI %d" gicv5_update_ppi_state(int ppi, bool level) "PPI %d source level now %d" --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881206; cv=none; d=zohomail.com; s=zohoarc; b=gce8Te4LcqbkzdWHj7R/MJTLpxkxScPzYrsBqtTnvhy7ckzyMpiO+xPVnT0Qp2HcqorNvxOOJVYFrJydBbz8upE7TogpeVCyh0IBPkov1CltQA1zxdMlwG0NmKSsjYOSyiy6VgZ3FiNQF4hBPP+aJK8Udlk/UBJMUS867CBxRg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881206; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=w1oglA4FavRm3WES/I25RSgG1C/w7HeWJ7z5SibC1Xk=; b=S5ddK+phxaBRYOlV6nj2jJV1FXkZ8WvaEStytxttBplx2zPFFhmGiVOPpyQJYjNAzuij8pmtXQQMXTEfgToigrOR8Qf5tERAa2+1St6+b3oXMPEdrzPDojhEtA7WxyVlcCmdbVm46Ktuvr9kXeEByXPE/ejMCxvKZLxf09am6tE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881206237769.6002499766969; Tue, 13 Oct 2026 01:46:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY5q-0002yU-R4; Tue, 13 Oct 2026 04:42:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3n-00081m-Dn for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:35 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3k-0007xp-If for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:35 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-48b060ec084so1658175f8f.0 for ; Tue, 13 Oct 2026 01:40:32 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880831; x=1792485631; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=w1oglA4FavRm3WES/I25RSgG1C/w7HeWJ7z5SibC1Xk=; b=ckrUDqj2Fujj7WsSKiNg5ErtgctIfwQtZ8b2fiByIQ88naZ7PvsC7B2uELsdol20mQ Ym/swyHXS1Rp+ypkTZA/8EOLC+c6xLBygZnlhfoaDYP2oTl9IW8UCKhD1pZ/hhE5u1lX 7Yaduvg11xafvOSgvvn6lJMQ7TN23J4NANsSjrcXFTSbBpegKi8x0ZWrqVAuaCRd6Typ xTyowTA4hkNHty9XbReHbzufad5tVOEGOgBX9wVFbeKtN18SutjSnyelbsFQ+gREK1rt K1SMe6WkYrwzyITIoMNNA5rDaNnrTCXSYzXl2rFBLl/kAFe64Z3i5cQw6hjo28lKCvOe NENg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880831; x=1792485631; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=w1oglA4FavRm3WES/I25RSgG1C/w7HeWJ7z5SibC1Xk=; b=IUX+nbgpwLRFGByc779k7FuhRZNRa1/iZsCANmdkO1EgqlM7YxkjNXr2UAxKFtxP/4 41QEKkXJzS3Ilsj4e7eAdnQxZS+1KtMEpKPw1zp3CFfnzW0D+78z6UHbhfTmlvE3XuIC p3zvMHtZbOYNEhoA4V6lqfyaRfFVN57iQkePgiku81LCyK0dXd+QkHCJ2Jg4Sqfvf3KP kQKfRx5S0vBlK76fUS0D+VFFBsmChX19q5QJ5FVBv1AZTz91xAf1IaTWOvVDaOPEdkRr Bqpe0EE7k+ckhA+AVQacK1zR9XOo8hPd4RPpmjN6cstqmGPYZPxNlOmaossjl/5sTJGb nD6w== X-Forwarded-Encrypted: i=1; AKwUvBxhPCpmocMGj/io8jnIwTap/DI85ZE/5fS2XvSJrdmwsxef5+nh3yCrZmLxBR7Ynvefs7n0bP6Hgouq@nongnu.org X-Gm-Message-State: AFq9FYK9JHlLaSV/EpJbl3dMyQWre3X41rBwb1gkDpMUUjz/navreqMr doqXBA9wqwcPT85Urn8pT6XE13sYz7a6C3DH1Q2R2dKSa7/L6cBmmrA03wR4DmNV5EgcbI4HlO7 0gYSn8pg= X-Gm-Gg: AYBFou0JHZ9z1NAHiNgr+qNAkgS3a3Te9LOXagfTVDpnwWIzRv6tH6qvnujKsTzh3w/ 8uXfejlRaPIcvQ9fzdT4f3GRPrnr4xaaCl5pzwKNthpsFCx658l0a4FNElkjcu6hBfOh4jamHXV ZQxRKgvvg5E8OacGnnVFfcSqRTcdLkGXzMek7TkZBekuHumpg19uiggCFzZicX5I21tkUeiYhs4 pM0FIM22Xnn6WGIjxvX/xjo3VNf0NCHauzDxRa31YQzkhSTk4R7i6ORj+VXz8WF61vMiHKfeKVj Ll0lInb8ePmaTule7nGAB/KhLjst7vY7WKCi9OhdkrFYpc6uH6GHAdH0Glc4aabvr0Q5aMrmDZ0 fnzx+88ghHEhNPz/A3na8L6i5SetvZlxtA4mZfTW5ILf+I1EUIIhtmpwi09743nyb4Ei0sfer5o i74dBk+FBy2liexjNpDVvRiztZ0zx8N25hFdBcWHF0iEmR7FJVtUv/s2eHEWRgEmVh6AUgbEm17 Mg+dnNUGF2A+9mgJFxDhwofwdTLQwrjqojvBRfo1HtpNuDjAgO5lhJx9I6eOPId25c+ZYPGSS18 UNc= X-Received: by 2002:a05:600c:c176:b0:4a0:c2a:485e with SMTP id 5b1f17b1804b1-4a18e4dce0cmr225633745e9.33.1791880831049; Tue, 13 Oct 2026 01:40:31 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 40/86] target/arm: GICv5 cpuif: Handle virtual interrupts for GICR CDIA, CDNMIA Date: Tue, 13 Oct 2026 09:38:47 +0100 Message-ID: <20261013083933.1024405-41-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881207477158500 Content-Type: text/plain; charset="utf-8" Handle the virtual interrupt domain in our GICR CDIA and GICR CDNMIA implementation. LPIs and SPIs are handled by passing through the 'virtual' parameter; PPIs look at the virtual PPI state. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 40 ++++++++++++++++++++++++++---------- target/arm/tcg/trace-events | 4 ++-- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index c85d72b05d0..4ee548a768b 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -1143,7 +1143,7 @@ static uint64_t gicr_cdia_read(CPUARMState *env, cons= t ARMCPRegInfo *ri) GICv5Common *gic =3D gicv5_get_gic(env); bool virtual; GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); - GICv5PendingIrq hppi =3D gic_hppi(env, domain); + GICv5PendingIrq hppi =3D virtual ? gic_virt_hppi(env) : gic_hppi(env, = domain); GICv5IntType type =3D FIELD_EX64(hppi.intid, INTID, TYPE); uint32_t id =3D FIELD_EX64(hppi.intid, INTID, ID); =20 @@ -1151,20 +1151,20 @@ static uint64_t gicr_cdia_read(CPUARMState *env, co= nst ARMCPRegInfo *ri) =20 if (hppi.prio =3D=3D PRIO_IDLE) { /* No interrupt available to acknowledge */ - trace_gicv5_gicr_cdia_fail(domain, + trace_gicv5_gicr_cdia_fail(domain, virtual, "no available interrupt to acknowledge"= ); return 0; } =20 if (gic_hppi_is_nmi(env, hppi, domain) !=3D cdnmia) { /* GICR CDIA only acknowledges non-NMI; GICR CDNMIA only NMI */ - trace_gicv5_gicr_cdia_fail(domain, + trace_gicv5_gicr_cdia_fail(domain, virtual, cdnmia ? "CDNMIA but HPPI is not NMI" : "CDIA but HPPI is NMI"); return 0; } =20 - trace_gicv5_gicr_cdia(domain, hppi.intid); + trace_gicv5_gicr_cdia(domain, virtual, hppi.intid); =20 /* * The interrupt becomes Active. If the handling mode of the @@ -1177,23 +1177,41 @@ static uint64_t gicr_cdia_read(CPUARMState *env, co= nst ARMCPRegInfo *ri) * gicv5_activate() cause a re-evaluation of HPPIs they use the * right (new) running priority. */ - env->gicv5_cpuif.icc_apr[domain] |=3D (1ULL << hppi.prio); + if (virtual) { + env->gicv5_cpuif.ich_apr_el2 |=3D (1ULL << hppi.prio); + } else { + env->gicv5_cpuif.icc_apr[domain] |=3D (1ULL << hppi.prio); + } + switch (type) { case GICV5_PPI: { uint32_t ppireg; uint64_t ppibit; + bool hm_edge; =20 assert(id < GICV5_NUM_PPIS); ppireg =3D id / 64; ppibit =3D 1ULL << (id % 64); =20 - env->gicv5_cpuif.ppi_active[ppireg] |=3D ppibit; - if (!(env->gicv5_cpuif.ppi_hm[ppireg] & ppibit)) { - /* handling mode is Edge: clear pending */ - env->gicv5_cpuif.ppi_pend[ppireg] &=3D ~ppibit; + /* handling mode is constant and doesn't differ for virt vs phys */ + hm_edge =3D !(env->gicv5_cpuif.ppi_hm[ppireg] & ppibit); + + if (virtual) { + env->gicv5_cpuif.ich_ppi_active[ppireg] |=3D ppibit; + if (hm_edge) { + /* handling mode is Edge: clear pending */ + env->gicv5_cpuif.ich_ppi_pend[ppireg] &=3D ~ppibit; + } + gic_recalc_virt_ppi_hppi(env); + } else { + env->gicv5_cpuif.ppi_active[ppireg] |=3D ppibit; + if (hm_edge) { + /* handling mode is Edge: clear pending */ + env->gicv5_cpuif.ppi_pend[ppireg] &=3D ~ppibit; + } + gic_recalc_ppi_hppi(env); } - gic_recalc_ppi_hppi(env); break; } case GICV5_LPI: @@ -1203,7 +1221,7 @@ static uint64_t gicr_cdia_read(CPUARMState *env, cons= t ARMCPRegInfo *ri) * name of the stream command, does both "set Active" and * "maybe set not Pending" as a single atomic action. */ - gicv5_activate(gic, id, domain, type, false); + gicv5_activate(gic, id, domain, type, virtual); break; default: g_assert_not_reached(); diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index 31c6eafd8ed..856a11b7d1b 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -4,8 +4,8 @@ # gicv5-cpuif.c gicv5_recalc_ppi_hppi(int domain, uint32_t id, uint8_t prio) "domain %d ne= w PPI HPPI id 0x%x prio %u" gicv5_recalc_virt_ppi_hppi(uint32_t id, uint8_t prio) "virtual domain new = PPI HPPI id 0x%x prio %u" -gicv5_gicr_cdia_fail(int domain, const char *reason) "domain %d CDIA attem= pt failed: %s" -gicv5_gicr_cdia(int domain, uint32_t id) "domain %d CDIA acknowledge of in= terrupt 0x%x" +gicv5_gicr_cdia_fail(int domain, bool virtual, const char *reason) "domain= %d virtual %d CDIA attempt failed: %s" +gicv5_gicr_cdia(int domain, bool virtual, uint32_t id) "domain %d virtual = %d CDIA acknowledge of interrupt 0x%x" gicv5_cdeoi(int domain) "domain %d CDEOI performing priority drop" gicv5_vcdeoi(void) "virtual interrupt domain CDEOI performing priority dro= p" gicv5_cddi(int domain, bool virtual, uint32_t id) "domain %d virtual %d CD= DI deactivating interrupt ID 0x%x" --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881207; cv=none; d=zohomail.com; s=zohoarc; b=KIArDEVtav8AoobR4ScDq23QeNXcx7os3uBMkZW7JLFLRJPDZj/CfRsN0TrGHMroKa+2Vd7R3Vw+7ISMdfdKHluzCcVUf4T16cmr+Y6/K9fQ/s+/ZUY44jmVhc8mdCw5N8o0TcYbtJyuaS9yWQzHigVEYzFPO3Ezpcl0aUNnTfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881207; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=4lbX4jqxG9XcAqUvTf01b6jgpr+mQAhWItQ+vjCx7vI=; b=ZNlcWTvd3B1l/cGGxFChnEgLZc+VwYr8MM/oMbBe586SmYxF5OKNsqtKJJk2o3x2Zc8CliiA6omOEkujfLFKhKWhNlAfZh84matoBXcWWTb31aAPP7MW0q1zkDkhoLa7N/nN1/1UNDiL+iEHP+oeQXHunwdBC94ndTGF2rJU5Vs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881206993809.1463711683449; Tue, 13 Oct 2026 01:46:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY44-00006A-9z; Tue, 13 Oct 2026 04:40:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3n-00083g-UB for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:36 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3l-0007yH-QK for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:35 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-49d05d51553so17365625e9.2 for ; Tue, 13 Oct 2026 01:40:33 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880832; x=1792485632; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=4lbX4jqxG9XcAqUvTf01b6jgpr+mQAhWItQ+vjCx7vI=; b=yPYOxiZVvqbwFp/8yTSJ6DJisXAN5KXbh66oGoTlIsXruGg/rAtMPCa0MO+pp8W12i hbCw0yY97Q3KIb4pbbh7EDTwW+v9+dN76viabfQq/ediv7od9IAK1yeVTvU9xz/jPQMf 1ajC+l/XheW8FixJJRKSfqy8lNzckKMwOKj9lwjC33BZ5CuMin8EppJiGaWCA6bNrf85 1Za+eNFtQOkqJ8u/Bj/7YRmVIhN96f47S8EAfpWsEs8/fuX+q3OQ3U3iS4dqEF1OWhSM FcEbeDwJfAPIeSHzwF8ANqlInWH/XtZ5ckoq9mM3VFDpgWtDeHi7saospJwA8dS25xKm 54Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880832; x=1792485632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=4lbX4jqxG9XcAqUvTf01b6jgpr+mQAhWItQ+vjCx7vI=; b=vIYOy0M3UYCiMtpMamShGJ9ZLIhhDR4+F5ovIlQtSwhLLbftV1TEgVDPtuL+75egY9 FwczjDHb2Yd//eW8Mg9hGrKQhQh5JFN67B0Uc1kFZarJfRuioDpliGzraPRSwkdbU4jj ygIeRKsTBhs7LukaoAxbSw8tqkAidtPpgBiNpfn0/BCc5f8P+tcX+JJMiTkhUrFF8QCP O1FVKhCJbMmXOPD7+gvqOq0yCo7M21Z8mde+RHzKTVX9A8GeyG5uoKx8SUaDQ43fUXax DfA8MwXpN3i+I4dOAY0dN/taV4RxEJF5NxRvVDVKbQEjmzMEAJMOX9nRYWMhBsAhwc/R MzXw== X-Forwarded-Encrypted: i=1; AKwUvBxR7ZjY7x4HmdLjVO/x84vZ76lrjeUYA1ncW3zr0xJSLucNI14zOFEgzanhzPJnrsI5GBfuW9+9lpvm@nongnu.org X-Gm-Message-State: AFq9FYJnGOm36L7rJeUtFvpPun991MW/VAdqLROOWYXYdrGadv02+nTr YuOTC5bOP0Y+Tm/bXT9Crsb4I7RLjiCIsXuDvfwZMkVA4NtfQYYTtVmaWQMnDcfLitlfaMUs57Y o3fjKtYE= X-Gm-Gg: AYBFou08gflXWfDTp2ot7JCl3gA4EXOFSzceMyLO5bFEF+FsBVcHwdD4sWUNV5br8IR iztcjdl6dygLCrnHM/FrBTEjNgvrJDaKH06InabqjS0xY8vmS18pQKWuxlyuCU1cEofpdMlP62M xNmTDRiVR1y7+0x7JpC7zEfcTxLk7jtwm3QwqfVyKoYxedUt+pqoV08ocPexOZ9ZxX+zxU7xExZ h8lzJrUowzlTM58z0RLK4+GqqIB4atklO7SRLfVIo2jf7LlhUUcqU6nO5T48Lod8pHGZJlwykuL MzFGpKa1ca1x77iBeS6i8z4I1QMpb7mHxZidFxI5ZaQPPiY8SG9dajI1mto8O/+gWFN7YMMH2nM V+mCC8ararpkjZwlAYhvL6fZq+PhpLbh3qgMczBMjKhJ3pW8Qacru8KbOtXaeu+tEQvBSDOUCc4 pMwWZ+64orlMrD6EzkMZFf5KLrRh6vXCnfmTqCclc4UXNLJgAJgJVYNbeY0RJ/8p0Apq3l7tRaF tncm/PxlTGbg3GwqTWQ8T0VWgwXoxIcR0okLqyybTRxftqWeNQgul7gnN0H4+jC8mHiNL0UK5eh I6kE4hKexsXs2A== X-Received: by 2002:a05:600c:4e89:b0:4a0:12d7:4c88 with SMTP id 5b1f17b1804b1-4a18e4ac77amr257883605e9.30.1791880832003; Tue, 13 Oct 2026 01:40:32 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 41/86] target/arm: GICv5 cpuif: Handle GIC VDPEND VM argument Date: Tue, 13 Oct 2026 09:38:48 +0100 Message-ID: <20261013083933.1024405-42-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881207494158500 Content-Type: text/plain; charset="utf-8" In the GIC system instructions, VDPEND is special: the other "act on virtual interrupt domain" operations act on the resident VPE/VM, but this one allows the guest to pass in the VM ID, so that a hypervisor can pend an interrupt for a VM even if there isn't currently a VPE for that VM resident on the CPU. Add the VM argument to gicv5_set_pending(), and fill it in with the VM argument from the guest for VDPEND, or the current VM (as set in ICH_CONTEXTR_EL2) for CDPEND and LDPEND. (The IRS will fail all virtual interrupt operations until we implement its virtualization support.) The placing of the VM field moves the PENDING bit from bit 32 to 63, so we need also to special case the reading of that bit. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 5 +++-- hw/intc/trace-events | 2 +- include/hw/intc/arm_gicv5_stream.h | 3 ++- target/arm/tcg/gicv5-cpuif.c | 34 +++++++++++++++++++++++++++++- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 5ac50acc786..d503d8db426 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -855,13 +855,14 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, = bool enabled, } =20 void gicv5_set_pending(GICv5Common *cs, uint32_t id, bool pending, - GICv5Domain domain, GICv5IntType type, bool virtual) + GICv5Domain domain, GICv5IntType type, bool virtual, + uint32_t vm) { GICv5 *s =3D ARM_GICV5(cs); uint32_t iaffid; =20 trace_gicv5_set_pending(domain_name[domain], inttype_name(type), virtu= al, - id, pending); + vm, id, pending); if (virtual) { qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to set " "pending state of a virtual interrupt\n"); diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 7512c6e6004..6681e32d1b7 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -237,7 +237,7 @@ gicv5_ist_valid(const char *domain, uint64_t base, uint= 8_t id_bits, uint8_t l2_i gicv5_ist_invalid(const char *domain) "GICv5 IRS %s IST no longer valid" gicv5_set_priority(const char *domain, const char *type, bool virtual, uin= t32_t id, uint8_t priority) "GICv5 IRS SetPriority %s %s virtual:%d ID %u p= rio %u" gicv5_set_enabled(const char *domain, const char *type, bool virtual, uint= 32_t id, bool enabled) "GICv5 IRS SetEnabled %s %s virtual:%d ID %u enabled= %d" -gicv5_set_pending(const char *domain, const char *type, bool virtual, uint= 32_t id, bool pending) "GICv5 IRS SetPending %s %s virtual:%d ID %u pending= %d" +gicv5_set_pending(const char *domain, const char *type, bool virtual, uint= 32_t vm, uint32_t id, bool pending) "GICv5 IRS SetPending %s %s virtual:%d = VM %u ID %u pending %d" gicv5_set_handling(const char *domain, const char *type, bool virtual, uin= t32_t id, int handling) "GICv5 IRS SetHandling %s %s virtual:%d ID %u handl= ing %d" gicv5_set_target(const char *domain, const char *type, bool virtual, uint3= 2_t id, uint32_t iaffid, int irm) "GICv5 IRS SetTarget %s %s virtual:%d ID = %u IAFFID %u routingmode %d" gicv5_request_config(const char *domain, const char *type, bool virtual, u= int32_t id, uint64_t icsr) "GICv5 IRS RequestConfig %s %s virtual:%d ID %u = ICSR 0x%" PRIx64 diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index 162d55a8e6b..f6d32c6beca 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -86,6 +86,7 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, * @domain: interrupt Domain to act on * @type: interrupt type (LPI or SPI) * @virtual: true if this is a virtual interrupt + * @vm: VM ID (for virtual interrupts) * * Set pending state of an interrupt; matches stream interface * SetPending command from CPUIF to IRS. There is no report back of @@ -93,7 +94,7 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, */ void gicv5_set_pending(GICv5Common *cs, uint32_t id, bool pending, GICv5Domain domain, - GICv5IntType type, bool virtual); + GICv5IntType type, bool virtual, uint32_t vm); =20 /** * gicv5_set_handling diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 4ee548a768b..7f0109e9b12 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -40,6 +40,11 @@ FIELD(GIC_CDPEND, ID, 0, 24) FIELD(GIC_CDPEND, TYPE, 29, 3) FIELD(GIC_CDPEND, PENDING, 32, 1) =20 +FIELD(GIC_VDPEND, ID, 0, 24) +FIELD(GIC_VDPEND, TYPE, 29, 3) +FIELD(GIC_VDPEND, VM, 32, 16) +FIELD(GIC_VDPEND, PENDING, 63, 1) + FIELD(GIC_CDHM, ID, 0, 24) FIELD(GIC_CDHM, TYPE, 29, 3) FIELD(GIC_CDHM, HM, 32, 1) @@ -594,8 +599,35 @@ static void gic_cdpend_write(CPUARMState *env, const A= RMCPRegInfo *ri, uint32_t id =3D FIELD_EX64(value, GIC_CDPEND, ID); bool virtual; GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); + uint32_t vm =3D 0; =20 - gicv5_set_pending(gic, id, pending, domain, type, virtual); + if (virtual) { + if (ri->opc1 =3D=3D 4) { + /* + * GIC VDPEND has a VM argument field, and PENDING + * is in a different bit location to normal + */ + vm =3D FIELD_EX64(value, GIC_VDPEND, VM); + pending =3D FIELD_EX64(value, GIC_VDPEND, PENDING); + } else { + /* + * GIC CDPEND for the virtual interrupt domain operates on + * the VM for the resident VPE. Our implementation of + * ICH_CONTEXTR_EL2 means we can trust that if the V bit + * is set the VM field is the right one. + */ + if (FIELD_EX64(env->gicv5_cpuif.ich_contextr_el2, + ICH_CONTEXTR_EL2, V)) { + vm =3D FIELD_EX64(env->gicv5_cpuif.ich_contextr_el2, + ICH_CONTEXTR_EL2, VM); + } else { + /* no resident VPE: instruction is a NOP */ + return; + } + } + } + + gicv5_set_pending(gic, id, pending, domain, type, virtual, vm); } =20 static void gic_cdrcfg_write(CPUARMState *env, const ARMCPRegInfo *ri, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881279; cv=none; d=zohomail.com; s=zohoarc; b=Jm7615jXGiqCfyos2ZOCtD+BFQlRLwtbIN9nQ+qEvx0V1gmNC9rxPVNN4tGJ8idXjO8Ae7f0cACkqX5bjsZwbTa+bsEBYJW+ZT7qgVQdrOFmBncUZ4ERiC5rwvQKT5nN4HkcM75bNOXRnQm7a29JRWZdLe8sfBeUhmW+pdD/Oig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881279; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=HAJqqQ3Uo3xCW2Bb5E3vPPfl8N3rhsh3k10EI5/4JrQ=; b=JXJN1Vl1wDVJ7/oU906mlZ12nvhSExgMwdZEVWqJqPl2lRZLWQ7D7NeylJPKzO0HhvQVklB84KgqHmT6GEmuSHRM2rGpl9kXOE6L5Ok/wr7ry5SO9hbSvRqk78IEx/2RleEK3CYdGFNL72QRC3vFlFPJg0mIYzs8qyvy6tBkNF8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881279340801.1258867830347; Tue, 13 Oct 2026 01:47:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY5C-0002QE-6C; Tue, 13 Oct 2026 04:42:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3r-0008Dp-Jw for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:39 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3o-0007yw-Rt for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:39 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4a1ad2e2391so2926155e9.0 for ; Tue, 13 Oct 2026 01:40:36 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880835; x=1792485635; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=HAJqqQ3Uo3xCW2Bb5E3vPPfl8N3rhsh3k10EI5/4JrQ=; b=wn3btXGiH9Lk2P98J5DPXkOiSEvw5OJ51U+FWUvbINUQ2jsDso4DBfSYty9eDGS4qA AfT/QhqwQ/Uo+AwcF5dDXxEQx5GykvpMnxTAqi5LYT0WZtxaTzprcVJGcX9Hj0t8cLQy 9ZlPmR1SSGeOPPIBq+20g8YhBEjNPrhsaok0z5Cj+8cfl74hJoybs5wOycAEJOIW4cSK KCD3y4CMbauutW5xKQ68spuDi9DPGxpTcGLXYWiA31ku1mO3uODtHgyRZmX25CVMyOUQ j06n5knUagr6lSr19C6nbblwtV++rZ2duxBpGcUaiRvWpZlL7MQEUFWCUzoh2ajOv8+I exkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880835; x=1792485635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=HAJqqQ3Uo3xCW2Bb5E3vPPfl8N3rhsh3k10EI5/4JrQ=; b=ywmejztLn369Inazu5kna3RzfJXM8u6PycQyMRjro6S75nFuL12HRkpov5CHXqvjoa bory9qA6SjXvVKAQ1UIZ9T7gAQWcUvIuxSJVk20pDfROzh8hQHaRYDA+RfjJPrH9JllX zAkugWl342dahdOQ0YTHfvXjfgOuBTmg3P35O+ZAk3Kp1BFvZYkrLL4fr9NbjX3/GfIp MJTt9a0UX9R8jQYJecuOmLm6ua1N6ISM8M03NCPtmRmIFVFHzjGkhoBXMlSRkS60+aPW 5jwvO3924QKp4buTaI+zy4xH3W899lk3ybWKzUv2XrqM9fcxAgtT4q+CU9nm1dZ055jE 2CEA== X-Forwarded-Encrypted: i=1; AKwUvBw4BamfRk4vOmbuqcbBQnGSfes6SptDCnzpEoY4L9a2ZDPtUzBePEsi7Re1jFY4X89oisSS4LnEa2qq@nongnu.org X-Gm-Message-State: AFq9FYJ4srv+CCjym0+b0qse8ioQsBjDINRmgwMu52XF4Nd3OUeBAEQ0 HC2UamEOCEJak8YVh0S2xU4OhdKzbfZJ8aLEnA/OYcRL9zpgy7bD7qXJyynJeCb4Ito7UtmG5+l paZxgZtk= X-Gm-Gg: AYBFou3BoMkWjVj4GMhLyAmEM63bGZCb/Mq6hHVqq+pMkej+r+xHqhhIXC//+Vg0ww8 AN/IYz7HmszeTnvRM9OgZcjmUBVc6pmzsdgm673JDVoUqtRAIhAclf5cE2HlSMaNbsowVAuOkQY /G3ZV/3/NVX4mXt23+NlLZVxW3j/NrKXRgQYqLkaDTAqqXpODqm+1YpQALOqMvwzfa0/Yydp07W zUlfhBDJ3xLD2+yG8GINmF+H7f11hiPF7OB7UBLvphgV/7F41CrOTgOK99IIGFlDcPn3vzof/mW gPHoT3NQxe6VEyIetlaAosKh5AMrq83TrZIyZH/JX+zJwTyO/nv+YbR3N9bVzOX1S88yOzTCw+5 7Gvc4hydNX9/Mm1uf3f+fOh7YP22V6YU7jYKSI2q37qniCsv2gyF5QaVHyHjiCiyoCZm+4XHO5B nA8TLBprtkYGT2g+ki+qUEfyZ5GYCEJe7RYBMxOczfhGb8tCgiVyhevIGInHmPHOroyczHWM9t/ 8SjtUbSv8LeAZ50r67dCz4t1GFH2GV7A1c7Lzq4yV0acFya0AMDUwm48zzB0TobxPXge+zjatCs OnE= X-Received: by 2002:a05:600c:350b:b0:4a1:ad01:f8dc with SMTP id 5b1f17b1804b1-4a1ad01f924mr23660115e9.21.1791880834828; Tue, 13 Oct 2026 01:40:34 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 42/86] target/arm: GICv5 cpuif: Implement GIC VDnnn insns Date: Tue, 13 Oct 2026 09:38:49 +0100 Message-ID: <20261013083933.1024405-43-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881280846158500 Content-Type: text/plain; charset="utf-8" The GIC cpu interface has a set of GIC VDnnn insns which behave exactly like the GIC CDnnn ones except that they always operate on the virtual interrupt domain. (EL2 can use these to examine and update the state of the interrupts of its guest.) Now we've updated the writefns to handle the virtual interrupt domain by looking at the opc1 field, we can implement these using the existing writefns. Note that there is no VD insn for CDIA, CDNMIA or CDEOI. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 7f0109e9b12..64e59589cc7 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -1453,6 +1453,54 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .fgt =3D FGT_GICRCDNMIA, .readfn =3D gicr_cdia_read, }, + { .name =3D "GIC_VDDIS", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 4, .crn =3D 12, .crm =3D 1, .opc2 =3D 0, + .access =3D PL2_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .writefn =3D gic_cddis_write, + }, + { .name =3D "GIC_VDEN", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 4, .crn =3D 12, .crm =3D 1, .opc2 =3D 1, + .access =3D PL2_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .writefn =3D gic_cden_write, + }, + { .name =3D "GIC_VDPRI", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 4, .crn =3D 12, .crm =3D 1, .opc2 =3D 2, + .access =3D PL2_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .writefn =3D gic_cdpri_write, + }, + { .name =3D "GIC_VDAFF", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 4, .crn =3D 12, .crm =3D 1, .opc2 =3D 3, + .access =3D PL2_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .writefn =3D gic_cdaff_write, + }, + { .name =3D "GIC_VDPEND", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 4, .crn =3D 12, .crm =3D 1, .opc2 =3D 4, + .access =3D PL2_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .writefn =3D gic_cdpend_write, + }, + { .name =3D "GIC_VDRCFG", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 4, .crn =3D 12, .crm =3D 1, .opc2 =3D 5, + .access =3D PL2_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .writefn =3D gic_cdrcfg_write, + }, + { .name =3D "GIC_VDDI", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 4, .crn =3D 12, .crm =3D 2, .opc2 =3D 0, + .access =3D PL2_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .writefn =3D gic_cddi_write, + }, + { .name =3D "GIC_VDHM", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 4, .crn =3D 12, .crm =3D 2, .opc2 =3D 1, + .access =3D PL2_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .accessfn =3D access_gicv5_ich_reg, + .writefn =3D gic_cdhm_write, + }, { .name =3D "ICC_IDR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 2, .access =3D PL1_R, .type =3D ARM_CP_CONST | ARM_CP_NO_RAW, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881355; cv=none; d=zohomail.com; s=zohoarc; b=g9pL76Vin6yDvs4T7YrRevUymyIfNKjbI6kU21re3Ja4Fxe6K/mXe7Tr9+3ieeNXFiJBECy634wD0/RkDSxGwvx3TMjQQ4/dbLVQmxR02mhC3GV8dLE+/K5OqxbOC9Wpq704zka3+XyqEsEU4U1N5YpvzbOSmvvcBmHL6y1ALi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881355; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=xzgSRPibV+W+TuXoD9LFFebcGlaP5K/iGBnAO14/huw=; b=BBT+nLUYtA/LFiOLNQKmq5OkOnNNwrJJygVc7kfqVvwuu9OEEw3kD/c7m2QXuLfz8pxpd4KcyZ4FXTAmCL8aHwA2d+fMCuDTGfPo2su2dNQ+dnp3+BMg7TOkzuF5NtOnBW1lfQH/D5awHZVQT6yBQF7ZtOyc2EGL9jl3Wyq950c= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881355299389.27145150520505; Tue, 13 Oct 2026 01:49:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY5v-000314-2d; Tue, 13 Oct 2026 04:42:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3r-0008Ds-OM for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:40 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3p-0007zP-DQ for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:39 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4a16aaf2067so32210825e9.0 for ; Tue, 13 Oct 2026 01:40:37 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880836; x=1792485636; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=xzgSRPibV+W+TuXoD9LFFebcGlaP5K/iGBnAO14/huw=; b=YoRRJsqEJnzWcEg2WqDBQrzvSQsyjmJTmriLnw65nQo24cHuKTYcIAwo4ODIeDTMoo 0GjRGi/+bOugV0YQsu1AALL7l22frSSdZlWmkJqnB/lG9hfnnlwKdNkUgCYWlKscIAZZ ogNp0gGxpzbrpAjmHsT7WFA2BAhNWsOxb4uhGxLDY3SqkI78Y8Of1bgeuod/eyOzpjVX 9Tly1DfWSaEDxULtTUHGj2qimsssz4xUYzJzD3I+ClEFyZsZHe4IJHEo/++JcOclnrx3 grdkNh7SHhyLNVtwm+i6qCfwDa0UlzbipNHFqIKUgAo/3tfhXXhhbfGFN5p8nCT2FFGQ 62yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880836; x=1792485636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=xzgSRPibV+W+TuXoD9LFFebcGlaP5K/iGBnAO14/huw=; b=Madx2WTkhb9FIGq8TZGOHeztH6C/TvV4AqpUClnS55Ton49e+iq/2uWdeX3axPp5zT UkU5vMhcRgVAUXxBfzzUsxkmovRGOUWVMuZiuLVbkICvd2NLYpMgGJsH1ULlvgk7YkAd KJOiWTcRoZkN4TmIGsVg7rmIdQLjFx3XU2UPabZRBbehFbV0FWVh48Wp8645frwuRc5g O7ckmLysUkLsTCIJIGiF4vmdSL2oCr5WbNR9T6RCYMOaJgEYeKVe4FCe3d5ORFdNQnXU ffajJWiRvYjnHtXL8w1cs1kI2YQfWf0EfSKFaRG3H8+ryRIBfZQwRykA+oghodJDeVh6 H12Q== X-Forwarded-Encrypted: i=1; AKwUvBxaoC4D9rxy5jPK75lr4hvEOMMnywHtpa/+BV1x7x0KQBIbaGVFvAc9Hzjptbh3lph9gd5366qEzaaC@nongnu.org X-Gm-Message-State: AFq9FYKEC4yE/psiF31CyuuOHuARpdqiLnqEl2bqWXN/gVkXLKG/s09g zSd4dVq8D1T/CeuUYNCHW/YZ3dPdf7rWg/KlIEB5o/qX8ET/lLzcJkRVNqa3EFsc9wM= X-Gm-Gg: AYBFou3UJaXC8KwpRTEViqQOVmFwlsgzIXq3xxo+BN3lsWepf1cgPdGd4dYRLoIgcbp ZTeSStwyzGThnBc+eUhOKajIWFwr7gKvKgn7K2E2FaFAMbTNCoQKydlZR7ka0lhZWKw1uyPs5eJ eqKkckHyDvnNu6DYIBSMnSM1C+9l2dWJm9CFBTPHSiaN+QGxVUsdMWneYfpDHA00ka8qoabcThX qGzcPcI6c/4IvoELOCir3vuwrDaoCeQEL5a565zQSgVndYje3rv+HanFlavmaG+17UcMKXMBeCF aDnww1G5vfwRjPIvhQrQFunqep0lLYFUPcJ1Mt18CjUzZUVKbXjH9D2K0McV3euBAa7MMgWCcri Kq+OZ7UqZyemxI7G5gh9sCOUHA0XHNean5eiuAIFuoBeIoZ9/S2ag3wsl+mn+5hAUZ++qn1r4Jj nwDtP9DZKu53F7hN/5aI3Hm4oeJLwoCibqbXSxYbJ6BkJyuK+ttzSCEySjKHsR1X/qddNOfQ2qx g33Dbm5gPmQluAqYnXRfTSVEDt4Xw1rY+5H97LiJcJiQNki0uor3v/HNnMvlXzDdTl3G2ecT0sw lXU= X-Received: by 2002:a05:600c:8716:b0:4a1:62b8:9aa1 with SMTP id 5b1f17b1804b1-4a18e44885dmr236696575e9.2.1791880835847; Tue, 13 Oct 2026 01:40:35 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 43/86] target/arm: GICv5 cpuif: Implement GIC LDnnn insns Date: Tue, 13 Oct 2026 09:38:50 +0100 Message-ID: <20261013083933.1024405-44-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881356294158500 Content-Type: text/plain; charset="utf-8" The GIC cpu interface has a set of GIC LDnnn insns which behave exactly like the GIC CDnnn ones except that they always operate on the logical interrupt domain. (EL3 can use these to examine and update the state of the interrupts in the physical interrupt domain for lower exception levels.) We won't need these until we implement EL3 support, but since we've put in all the necessary groundwork for the reginfo structs to just work, we might as well add them now. The writefns will select the domain to use based on the opc1 field. As with VD, there is no LD insn for CDIA, CDNMIA or CDEOI. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 64e59589cc7..69e51359f22 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -1501,6 +1501,46 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .accessfn =3D access_gicv5_ich_reg, .writefn =3D gic_cdhm_write, }, + { .name =3D "GIC_LDDIS", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 6, .crn =3D 12, .crm =3D 1, .opc2 =3D 0, + .access =3D PL3_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .writefn =3D gic_cddis_write, + }, + { .name =3D "GIC_LDEN", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 6, .crn =3D 12, .crm =3D 1, .opc2 =3D 1, + .access =3D PL3_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .writefn =3D gic_cden_write, + }, + { .name =3D "GIC_LDPRI", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 6, .crn =3D 12, .crm =3D 1, .opc2 =3D 2, + .access =3D PL3_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .writefn =3D gic_cdpri_write, + }, + { .name =3D "GIC_LDAFF", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 6, .crn =3D 12, .crm =3D 1, .opc2 =3D 3, + .access =3D PL3_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .writefn =3D gic_cdaff_write, + }, + { .name =3D "GIC_LDPEND", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 6, .crn =3D 12, .crm =3D 1, .opc2 =3D 4, + .access =3D PL3_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .writefn =3D gic_cdpend_write, + }, + { .name =3D "GIC_LDRCFG", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 6, .crn =3D 12, .crm =3D 1, .opc2 =3D 5, + .access =3D PL3_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .writefn =3D gic_cdrcfg_write, + }, + { .name =3D "GIC_LDDI", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 6, .crn =3D 12, .crm =3D 2, .opc2 =3D 0, + .access =3D PL3_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .writefn =3D gic_cddi_write, + }, + { .name =3D "GIC_LDHM", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 6, .crn =3D 12, .crm =3D 2, .opc2 =3D 1, + .access =3D PL3_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .writefn =3D gic_cdhm_write, + }, { .name =3D "ICC_IDR0_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 10, .opc2 =3D 2, .access =3D PL1_R, .type =3D ARM_CP_CONST | ARM_CP_NO_RAW, --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791880939; cv=none; d=zohomail.com; s=zohoarc; b=nMaBFebiieDAGBCVB/sYEE0PUCclaxCQ29VdslYLoBuagKIbdnurzzvn5OtH/FI4UMMsH72qq9s9I8KsqXycNe6FNLyr+zoe/kfXScPtbjjClh5Jab6zPGWNkrcPndHXVndIGIAaOTtosaK5dyfQy7WR+gFKGUwBlHzggIfwtgA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791880939; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=xP0RYGEb3pcQLvMwonSHUuJ7p4HuwBLMvh/lW59w/gs=; b=WQ5cI1LUsNDLStstwJuGZ//ZUvF9QQUg8keCNhIlTuImXdesYdxWeEzbhSaWFAjgq7BOn6LXRTjSz/JPXsPYbnza7grLCEZoVnPcLv8v8kL9JyFNYGa7bi1+rD+OvDjJOXq9h1LyhBXC6vfr14V2qGTfrBMwZogDh3Fbmkkdu0Y= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188093962340.77706007167001; Tue, 13 Oct 2026 01:42:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4T-0001I5-LR; Tue, 13 Oct 2026 04:41:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3s-0008Eq-EA for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:40 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3q-0007za-Db for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:40 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4a018792ab3so22421395e9.0 for ; Tue, 13 Oct 2026 01:40:37 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880837; x=1792485637; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=xP0RYGEb3pcQLvMwonSHUuJ7p4HuwBLMvh/lW59w/gs=; b=AgKXZRvnP1r/fA36jcYCm3Zn7F0aqIA2L6bXQqhM7nwyPns0jbGp4RZ6xeC3ROv2R1 2kJQYlyrq403GKKymZ1KdESqtWLLTcI01F7UhXIdNr9XolrGY5djULOZdq40d7XhnNW2 Q4bOVQglIJ45/oNj/v7/e4TUkq1MAPS1mPfTVszKNRE1GyekPoEHk98GN5CI1+FF01RO lSNiyldCCRWOSrFqzYvgGxCLtojnTBh4Ew22PGvPhzxZYn//8iq5dCptTLO4cTixBxml QYIwlVuw+J0HxSrjWs19pBkTk9rMDfwsqxEt50ZLWNdA/bLrH1pD44zC2/s77TrcqRql 7RDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880837; x=1792485637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=xP0RYGEb3pcQLvMwonSHUuJ7p4HuwBLMvh/lW59w/gs=; b=J8kGXZxd861z9p1vBCSi60h/yDT3nYGSAxIBtOTTtBkaie/ovvJ/qQzYHtKlIFYnjK gYdMBm5MePKKYnyzQxDRokhKUOaXXH21gg5/jywM94ktlS848nNrMihKhMpaQovE7HUs LEpQfqXoLa7G6MVCSgAjMTLXFoDg9G6koVt30s3rznaWKBinlWXtdw3IRab1KUE26Wna vPgcaq5UFxzQURkM8spt0xrdUPC3pjc0n3q7QsyODiwkmXRVcIpgj5zJKaESpfyPkdqB OODw+u50Us7/4clRUMBm74FXfma3eWGdTrEVPiMvJ5AFp5BQ/S+xiZJ1mGZM1I8rgQ2f rnzA== X-Forwarded-Encrypted: i=1; AKwUvBxVkG/zYNEmtLGBaUK30SPpOP2SZwwzY5wxQ88HlbwHygLXWYisaYBxnkOoKJ7hpa7sQkS+QgdcLmoO@nongnu.org X-Gm-Message-State: AFq9FYLMHj7/8UCCkrfnbquWjBjmZWDd+nkOsdw83+dA/TkSGAaaAyah AjNsVdBqZ9GBhdtCj1uv1Rn188FRe7WwbUrVyNSxT3kgNRchiXXBxBgUunLo+LQSRCo= X-Gm-Gg: AYBFou1WuUzy6WHtQTxj3OEnhvSvMsvXVD5d4ihUlFePbONUeX5euDKJKgWSPMOt/Wg i3ESczjaexjzfj8NmXCYXlqGMzG8qN1gnU0J2dzNzOUTKNQTMS6TNYGq7UYe7kVF+G3R+LpJF2i Cl0buKhOPiRI5Y4J4lLbVV9ldEP+oaDm3bVKtnOwYGc/DTZRsjmBSnsTMXxnLe6lsLywuCVgYBa YzHODVGUE2PMPfDVhAEHrUqPpVXo92ZK6eHMGoBhaw62Q5YseIjVSnW5ISq6dev88a+wQF87w08 x/WTZp1DUmvozyWBdffqbP1cnI6+mAHCSgCZElGzzKiR0rkL4P+THPzU4bz8JTMVvJZn3wIadKH bR28/UMNAWdhIBs0P5weqCE7kH8dQJ1vgVnP0TqcYb3JCtvR6zzKxYU1M4aPdqT5F6OS8d3ASF9 a1HckIQjjEcIRg2gkNt0x5wWdsugGjCLnybhjYGKr8JvOUMs6qmWVH0UPhON/0YWZrHh7xtRIGi c8xnsV+wvECCBBXUHrgfpziArzVz24dOoK6c7bfHCd5TxMCF6k61N8JYkXSU6tlBS4Wl2epcgpH SSk= X-Received: by 2002:a05:600c:8218:b0:49f:ffdc:939d with SMTP id 5b1f17b1804b1-4a18e49d9f5mr224274865e9.9.1791880836850; Tue, 13 Oct 2026 01:40:36 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 44/86] target/arm: GICv5 cpuif: Handle PPI injection in vPPI pending reads Date: Tue, 13 Oct 2026 09:38:51 +0100 Message-ID: <20261013083933.1024405-45-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791880940479158500 Content-Type: text/plain; charset="utf-8" The GICv5 cpuif allows the hypervisor to configure PPIs to be directly injected into a VM. Setting the appropriate bit in ICH_PPI_DVIR_EL2 causes that physical PPI to appear as a virtual PPI in the virtual interupt domain. Directly injected PPIs mostly behave like true virtual PPIs; the exception is that their pending state tracks the pending state of the underlying physical PPI, and guest operations that read or update the pending state work on the physical PPI's pending state. (Hypervisor operations via ICH_PPI_PENDR_EL2 are not changed, and don't work with the physical PPI pending state.) The complication here is that when nested virtualization is active the EL1 timer PPIs must be redirected so that they appear with different virtual PPI IDs from their physical PPI IDs. All other injection is a simple 1:1 mapping with a physical PPI always injecting to the virtual PPI with the same ID. In this commit we update the places which read the pending state of virtual PPIs to honour the DVI bits and report the pending state of the underlying direct-injected PPI. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 95 +++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 2 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 69e51359f22..cdde759bf41 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -192,6 +192,97 @@ static GICv5Domain gicv5_domain_for_insn(CPUARMState *= env, return gicv5_current_phys_domain(env); } =20 +static uint64_t gic_virt_dvi_mask(CPUARMState *env, int reg) +{ + /* + * Return the mask of bits of virtual PPIs which are being direct + * injected. 'reg' is which of the two ICH_PPI_DVIR_EL2 regs we + * are dealing with. + * + * The complexity here comes from the requirement when doing + * nested virtualization to redirect injected EL1 timer PPIs so + * that they appear with the PPI numbers that the inner hypervisor + * expects (see R_GYGNW). + * + * Note that the ICH_PPI_DVIRn bits correspond to physical PPIs; + * the ICH_PPI_HVIRn bits correspond to virtual PPIs. + */ + uint64_t dvi_mask =3D env->gicv5_cpuif.ich_ppi_dvi[reg]; + + if (reg =3D=3D 0 && + (arm_hcr_el2_eff(env) & (HCR_NV | HCR_NV1)) =3D=3D HCR_NV) { + if (arm_is_secure_below_el3(env)) { + /* + * If we are injecting phys PPI 30, it appears as virtual + * PPI 20; phys PPI 27 appears as virtual PPI 19. Note + * that if we are not injecting the phys PPI 30/27 then + * the guest is allowed to configure phys PPI 20 to + * direct-inject to virt PPI 20 if it likes. + */ + if (extract64(dvi_mask, 30, 1)) { + dvi_mask |=3D 1 << 20; + } + if (extract64(dvi_mask, 27, 1)) { + dvi_mask |=3D 1 << 19; + } + } else { + /* phys PPI 30 -> vPPI 26; phys PPI 27 -> vPPI 28 */ + if (extract64(dvi_mask, 30, 1)) { + dvi_mask |=3D 1 << 26; + } + if (extract64(dvi_mask, 27, 1)) { + dvi_mask |=3D 1 << 28; + } + } + /* We aren't direct injecting to virtual PPIs 30 or 27 */ + dvi_mask &=3D ~((1 << 30) | (1 << 27)); + } + + /* + * Now we've converted dvi_mask to virtual PPIs, fold in + * ICH_PPI_HVIR_EL2: if the vPPI is hidden it can't be + * direct-injected to. + */ + dvi_mask &=3D ~env->gicv5_cpuif.ich_ppi_hvi[reg]; + return dvi_mask; +} + +static uint64_t gic_virt_ppi_pending(CPUARMState *env, int reg) +{ + /* + * Return the pending state of the virtual PPIs; this is the + * combination of the ICH_PPI_PENDR_EL2 state and the pending + * state of the physical PPIs which are being direct-injected. + */ + uint64_t dvi_pend =3D env->gicv5_cpuif.ppi_pend[reg]; + uint64_t ppi_dvi =3D env->gicv5_cpuif.ich_ppi_dvi[reg]; + uint64_t dvi_mask =3D gic_virt_dvi_mask(env, reg); + + if (reg =3D=3D 0 && + (arm_hcr_el2_eff(env) & (HCR_NV | HCR_NV1)) =3D=3D HCR_NV) { + if (arm_is_secure_below_el3(env)) { + /* 30 -> 20 and 27 -> 19 */ + if (extract64(ppi_dvi, 30, 1)) { + dvi_pend =3D deposit64(dvi_pend, extract64(dvi_pend, 30, 1= ), 20, 1); + } + if (extract64(ppi_dvi, 27, 1)) { + dvi_pend =3D deposit64(dvi_pend, extract64(dvi_pend, 27, 1= ), 19, 1); + } + } else { + /* 30 -> 26 and 27 -> 28 */ + if (extract64(ppi_dvi, 30, 1)) { + dvi_pend =3D deposit64(dvi_pend, extract64(dvi_pend, 30, 1= ), 26, 1); + } + if (extract64(ppi_dvi, 27, 1)) { + dvi_pend =3D deposit64(dvi_pend, extract64(dvi_pend, 27, 1= ), 28, 1); + } + } + dvi_pend &=3D ~((1 << 30) | (1 << 27)); + } + dvi_pend &=3D dvi_mask; + return (env->gicv5_cpuif.ich_ppi_pend[reg] & ~dvi_mask) | dvi_pend; +} + static uint64_t gic_running_prio(CPUARMState *env, GICv5Domain domain) { /* @@ -461,7 +552,7 @@ static void gic_recalc_virt_ppi_hppi(CPUARMState *env) =20 for (int i =3D 0; i < ARRAY_SIZE(env->gicv5_cpuif.ich_ppi_active); i++= ) { uint64_t en_pend_nact =3D env->gicv5_cpuif.ich_ppi_enable[i] & - env->gicv5_cpuif.ich_ppi_pend[i] & + gic_virt_ppi_pending(env, i) & ~env->gicv5_cpuif.ich_ppi_active[i]; =20 while (en_pend_nact) { @@ -716,7 +807,7 @@ static void gic_ppi_sactive_write(CPUARMState *env, con= st ARMCPRegInfo *ri, static uint64_t gic_ppi_pend_read(CPUARMState *env, const ARMCPRegInfo *ri) { if (gicv5_icv_access(env)) { - uint64_t value =3D env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1]; + uint64_t value =3D gic_virt_ppi_pending(env, ri->opc2 & 1); =20 value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; return value; --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881645; cv=none; d=zohomail.com; s=zohoarc; b=EybbcKm8HEeVCGAeAAFOl8fbktXbmX1YB7FgPW+XQPctQ6iiE/PZDK3NkAO6D2DHegkcT/SGnoTJ3MATNXLxX+bp24CqF4fZxiTBpgVjIMYzS2nqWDB2s0ZaycNXiXnHtQX9teTs8ztz1oejZyB9iVMGixzYo0ufam1vCD8UAfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881645; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=VUDSzD4TunPAZw2/yTniSFjF4XVXwom+SGsmSd03A3E=; b=Or0I9lKPy39xA+RJD5P7NCbj06WnfUD42o4wZK+Ve6JzI0dxnupVEg+n7tdgEUCTnOuNDhPYw+K/CeZT6/nFT+FHDyC2Zy8PTAN7IASUuDBryz9jqEdfajhJdB5Cmkz7bbHFDoPJSGn6J4XQZrvPgmeRqUi6JBgtNFNxaFHpob0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188164528771.78674302369996; Tue, 13 Oct 2026 01:54:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4h-0001nq-7b; Tue, 13 Oct 2026 04:41:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3t-0008He-EH for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:41 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3r-0007zq-I0 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:41 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4a061a13884so23063635e9.3 for ; Tue, 13 Oct 2026 01:40:39 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880838; x=1792485638; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=VUDSzD4TunPAZw2/yTniSFjF4XVXwom+SGsmSd03A3E=; b=cjWB82rnhYfjA3kx8mGwPZFRywO7wNLCQTnPsfnjS76fH5WmN4xLq/LHP0anx1e5/H 1h+svO9uwKW8WPY9sg11rFEYFn94/ysURI1iAmmkKOFdHxhanRjbllzXo9XI8VLEJ0XJ FsYIUicSm8Co2Hqr2yFrhy8qlsSJSAzcmEf2Uxmarv+zYMO+aX1r+hDEQ0Wu97ooPnNe q4L7JsoAeuehTcv6ayi45UzouLHKCmDDHP6JrjGKZlFi15lM4eLTU44n1bauyTFtnRUE StsCVfDjv0pSHFv6OJvuv0z9yCquvaYwZnX1VKwHTruVFw8dAmT83cwZunmB3Ie2NVRU ZTbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880838; x=1792485638; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=VUDSzD4TunPAZw2/yTniSFjF4XVXwom+SGsmSd03A3E=; b=K58TLYSu/fsjMI8TCEtE2SpMEty2LgLEZyWIFh/dThg0aArBNU6zLNPTbYuPd03lZJ 4X3rswqnclyAfdAAdhADTDFtGTxn3VpJB0v6Y0UnldA81OVN133J/fCyMRdjxqy8R3Vi gimnCfhbQ9eyUadvd4/2GJoVgadS+sTUkqOQKJbBY7lZiYEjEtHvxwGXWzuXSqedFPpm Dqo27qiWoxOOGkODyRuqzd1jGlZBCGkPCteR6tE2le5P6yLODdMDrslKSfBNeGmDcnn2 0y80fYEokHQALRxg00VgHZ4z1gAdJUOVsZqsgQKqAnD2KJAF18uWww8dB6qUMGRAVSiC gV+Q== X-Forwarded-Encrypted: i=1; AKwUvByjFAF22PktsIr5SQWR/VQ8ASgJ24MiMuv7KMK5v5liPnmYdQo2RexkqSViri0sAqzv4VeuFwPkHJDd@nongnu.org X-Gm-Message-State: AFq9FYLVkgI3K0/plVM1ylvmszd+gqD5uEk3SNk7RFPnGoLUpXyb33nm /39tMLO/duta9wqUgO9sYlR8yIpyEsCA3WawBh4En82QhGzjNn1hnDbFcZIiHpKq9TaTaOvtHnP B/Fhn20E= X-Gm-Gg: AYBFou2AbYihr26QrUak0/2IPX77+Hs3vtfRxNqqpFdGb2+9Jq+cmrbJHHUORzg4DDW /qcncmB+0ueo0n1rnTlWUTlD6IGDnxeCaZE3p+v5RZcVXtFWl0jaajGZmv9RtY6FRxT2laM1Kvc NZL6ASfYAPcyLE648Ig1PGFamf9Cu5ZlaYHG0PltVBoNuuV5VAMdy+caNzcA6D267VP2QeClwY0 xe/N44n8IymPeIa+GQCqYQMi95UlqYXH4Vs+kRtDrVpag0+a1sjTtv+98AMp7uJjpkWEOopZn4G VhDuUZjeM3EGi+JP+y82MRWp7XR02COL5gfbNCUnTiGDSuenkI2oRXyz33itKSZ/wzUdSNDwhDR 3PVrCpvHbFB8yoozQf6LxVb3qLklgYq2NMMSLljbL/EwDR1UcoEfpFGvufJDam1jLSTcFEmmF59 FdOgiMHI/4IcYUzruy1daAxPqE02x1yt1In8mJBvg8ixcQwj9XIY8fmPNVcn04YKBzm51jZpR2c SJdjFXcLF5V+ljjvQsSnsUDGNpTvbuBx7TcAErtSom/IFT/oOQaxYrobzkddLbVgZhGE/I3G9yO STU= X-Received: by 2002:a05:600c:83c6:b0:4a1:7093:40c7 with SMTP id 5b1f17b1804b1-4a18e493048mr213062555e9.8.1791880837968; Tue, 13 Oct 2026 01:40:37 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 45/86] target/arm: GICv5 cpuif: Handle PPI injection in vPPI pending writes Date: Tue, 13 Oct 2026 09:38:52 +0100 Message-ID: <20261013083933.1024405-46-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881645868158500 Content-Type: text/plain; charset="utf-8" In this commit we update the logic for writes to the virtual PPI pending state by the guest using the PPI_CPEND or PPI_SPEND registers to honour the DVI registers, so that the pending state of the underlying physical PPI is updated. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 69 ++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index cdde759bf41..5a2927faf75 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -816,16 +816,61 @@ static uint64_t gic_ppi_pend_read(CPUARMState *env, c= onst ARMCPRegInfo *ri) } } =20 +static uint64_t gic_ppi_vpend_to_ppend(CPUARMState *env, + uint64_t value, int reg) +{ + /* + * Given a mask of bits which are virtual PPI pending bits being + * changed, output the mask of bits which are to be changed in the + * physical PPI pending state, by adjusting them for the the timer + * PPI redirection. We require that the input value has already + * had the bits masked out for vPPIs that are not direct-injected. + */ + if (reg =3D=3D 0 && (arm_hcr_el2_eff(env) & (HCR_NV | HCR_NV1)) =3D=3D= HCR_NV) { + if (arm_is_secure_below_el3(env)) { + /* vPPI 20 is pPPI 30; vPPI 19 is pPPI 27 */ + if (value & (1 << 20)) { + value |=3D 1 << 30; + } + if (value & (1 << 19)) { + value |=3D 1 << 27; + } + } else { + /* vPPI 26 is pPPI 30; vPPI 28 is pPPI 27 */ + if (value & (1 << 26)) { + value |=3D 1 << 30; + } + if (value & (1 << 28)) { + value |=3D 1 << 27; + } + } + value &=3D ~((1 << 26) | (1 << 28)); + } + return value; +} + static void gic_ppi_cpend_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { + int reg =3D ri->opc2 & 1; /* If ICC_PPI_HMR_EL1[n].HM is 1, PEND bits are RO */ - uint64_t hm =3D env->gicv5_cpuif.ppi_hm[ri->opc2 & 1]; + uint64_t hm =3D env->gicv5_cpuif.ppi_hm[reg]; value &=3D ~hm; =20 if (gicv5_icv_access(env)) { - value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; - env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1] &=3D ~value; + uint64_t dvi_mask =3D gic_virt_dvi_mask(env, reg); + + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[reg]; + + /* Update state for non-injected virtual PPIs */ + env->gicv5_cpuif.ich_ppi_pend[reg] &=3D ~(value & ~dvi_mask); + /* Update state for injected PPIs */ + value &=3D dvi_mask; + value =3D gic_ppi_vpend_to_ppend(env, value, reg); + if (value) { + env->gicv5_cpuif.ppi_pend[reg] &=3D ~value; + gic_recalc_ppi_hppi(env); + } gic_recalc_virt_ppi_hppi(env); } else { uint64_t old =3D raw_read(env, ri); @@ -837,13 +882,25 @@ static void gic_ppi_cpend_write(CPUARMState *env, con= st ARMCPRegInfo *ri, static void gic_ppi_spend_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { + int reg =3D ri->opc2 & 1; /* If ICC_PPI_HMR_EL1[n].HM is 1, PEND bits are RO */ - uint64_t hm =3D env->gicv5_cpuif.ppi_hm[ri->opc2 & 1]; + uint64_t hm =3D env->gicv5_cpuif.ppi_hm[reg]; value &=3D ~hm; =20 if (gicv5_icv_access(env)) { - value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; - env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1] |=3D value; + uint64_t dvi_mask =3D gic_virt_dvi_mask(env, reg); + + value &=3D ~env->gicv5_cpuif.ich_ppi_hvi[reg]; + + /* Update state for non-injected virtual PPIs */ + env->gicv5_cpuif.ich_ppi_pend[reg] |=3D (value & ~dvi_mask); + /* Update state for injected PPIs */ + value &=3D dvi_mask; + value =3D gic_ppi_vpend_to_ppend(env, value, reg); + if (value) { + env->gicv5_cpuif.ppi_pend[reg] |=3D value; + gic_recalc_ppi_hppi(env); + } gic_recalc_virt_ppi_hppi(env); } else { uint64_t old =3D raw_read(env, ri); --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881144; cv=none; d=zohomail.com; s=zohoarc; b=Euog9txBG8jPUdg0YgQnb7PlpsmzNYzZ1C3+jlElUxZBiMnH+Q/yNxs5gW00c9yYzUvmwg1recjcJIy+VP+VAcdqGRgsUNnHDY/PH/6aE6VuZW3xSyNcL7fJWPaNTJqxEdtSfEMrWmJnorq5BFnKqrBlulvv2Ult4v2TlfwJqTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881144; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=oIQa2uLYcdnzWkI38CuG/P8pp77y4VLZYUd1uI22D4g=; b=kxYKnc01qAGCNG2PYm/REQLO4AymXiIv41Z5OQyssyhymSTBWyOYT9vDmKj1nJu9EA2h8mQotlaW3ZQlJYdo27tQ85Q46xDocHrUgvW5+dFvtsBUSzaEsr8YVxcO6Qf/i0+tE6PKowzxtMpxi1g10jKkSxYUcVwTf7doPUpUbW4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17918811444511020.7845997286468; Tue, 13 Oct 2026 01:45:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4U-0001O4-Rt; Tue, 13 Oct 2026 04:41:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3u-0008LQ-SI for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:44 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3s-00080G-OO for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:42 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4a171b677d2so15780985e9.0 for ; Tue, 13 Oct 2026 01:40:40 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880839; x=1792485639; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=oIQa2uLYcdnzWkI38CuG/P8pp77y4VLZYUd1uI22D4g=; b=CAkd9DslOShn5Nl2X2Sq7YUCXcbFEluLc7D7MsW6zD1Fmu/rED7cIkHn5bUVSKaPuk 9us+mHhT+IwpCqae7X+bSgaSdYeceC7dFrUTY1nZ+YYo/I2Oy1JpIV52OS+DL6IXPBaG av/FbeDOIUh2XvxKWg77WUPwtypxBEYAwXL72l+UlVZnI1mJOwNewlfngQKtyOgFCGPB B45rpj3sE2Kdphrk+mq+/bJ4wtIg0bLibKUux307RBlFOerqu5AgrMjsNcn3EyUwgRDE sHUqcJWMu2CMGGLkmaN1EnEMNSuhoMD6ZOiYS+P+H4ob1PpCJTygZbA3vwCo4Xv1zQ3p iivA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880839; x=1792485639; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=oIQa2uLYcdnzWkI38CuG/P8pp77y4VLZYUd1uI22D4g=; b=K+9HmC1QLH+2nNvIHpejdVCmdesOCOu7DLCOEaeiS7MW1JdWAxV1K+PXsb9hRxhZcJ rdCpTfHriF9JOD1kEY8qkZFCarF+eNnaSZt3OTYoSrfs4NUMkihgGx3fdnkWKNCf1KiR 65X7/J+e9tvubAP6wEf5p2zOp5GV1lTKgFYD3b5fPZ+8xnABlRYS6V1pw0Rc6oWxN61G ZpObiZAgqo8ElM65eHco7+EVNTWAZKxs0AYjaBnWtvW+GceuHXzI949jI/PmQsUbaEhC i+f30NMRSJQ/XzWcJEHJnrnbe/RgVsamyHUJ3CCApwIJQeXPOPVXujWvEbvRSSb67v+d pRPw== X-Forwarded-Encrypted: i=1; AKwUvBwJg5IfYOf+I1v7Nce3Mg0ApKKoiFXxJrZQyYpm2dMEMw84ckS8ODbMnNqwA+zkdZrqgdYYoEal/nCI@nongnu.org X-Gm-Message-State: AFq9FYIijR9Px0Klq4AuQd91TEXfDBKdg3L//Iz+b4UYrMDIvJ3Lp6RO oAWg7rbQPZLRgQIolLpPhBqVyITfUprOGg5XMsc506ZfUxyRpcmTmoAaFzjCthvTGyw= X-Gm-Gg: AYBFou1wleg8bNT82qSzRdmQQcalC0IXoreoH1zcH3AjHnQHlkyBJHLTlK2K9+3Vrrb 1TAYCJMODNHotgejMQhkSkB1TCsF7isKN+Lg/jm1201GfvZSIfMZ0VHCMVn8HkFzxhcU6dJJqMW V3gAx+LcC0lO/7ReftetR+l4Hws+FC977MSCZnvqumWkwy/GqmpRhj5BAe/viG8+ulDHDiT4YlG WnjfbNiV0AtE41zyRtupxbC3tnfNHVnK4Q+LX8WkWhl0r4WG1myQbEQyMpe6MUqfUOgWLBo+52p ugvujiC7VqImyDxGtIMCQnQSM4VRi0De3Gl8qWyFajjRNgPWaLNY0xo4KUQARFkixZMdI6fmSZz I/9Cr558T8YiFaK/GB9T65Q8jBWu9o1kjlSXSl+AYrCkRDzbKE6MIn/Y2U2c24h68ctW9cxGfri cXunsAf9re9k7V1OvuHDOKuPdKEfM9Uznca8I+gSDc8vQRlaXJvjSAzAOa+B2v1HEa3n287qKac zgmzpAqTqGIF5leIE0YuEEwnNNPaE8gAaNBZg6Tos71wjJ2n1j/26QPlEQFwae8mypW+oRheMJh TkRxXX1WTbvVuw== X-Received: by 2002:a05:600c:3b87:b0:4a0:1b15:8852 with SMTP id 5b1f17b1804b1-4a18e4a977fmr291496295e9.16.1791880839142; Tue, 13 Oct 2026 01:40:39 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 46/86] target/arm: GICv5 cpuif: Handle injected PPIs in GICR CDIA Date: Tue, 13 Oct 2026 09:38:53 +0100 Message-ID: <20261013083933.1024405-47-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881146307158500 Content-Type: text/plain; charset="utf-8" When GICR CDIA for the virtual interrupt domain acknowledges an edge handling-mode interrupt, it causes it to no longer be pending. If this is a PPI which is being direct-injected, we need to update the physical PPI pending state, not the virtual state. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 5a2927faf75..1f032e39bf6 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -1317,6 +1317,27 @@ static bool gic_hppi_is_nmi(CPUARMState *env, GICv5P= endingIrq hppi, return hppi.prio =3D=3D 0 && arm_sctlr(env, arm_current_el(env)) & SCT= LR_NMI; } =20 +static void gic_clear_vppi_pending(CPUARMState *env, uint32_t ppireg, + uint64_t ppibit) +{ + /* + * Mark the specified virtual PPI as no longer pending. ppireg is + * the PPI register index (0 or 1) and ppibit is a mask with + * exactly 1 bit set in it. + */ + uint64_t dvi_mask =3D gic_virt_dvi_mask(env, ppireg); + + if (!(dvi_mask & ppibit)) { + /* Easy case: vPPI not direct injected */ + env->gicv5_cpuif.ich_ppi_pend[ppireg] &=3D ~ppibit; + return; + } + /* vPPI is direct-injected: unpend the physical PPI */ + ppibit =3D gic_ppi_vpend_to_ppend(env, ppibit, ppireg); + env->gicv5_cpuif.ppi_pend[ppireg] &=3D ~ppibit; + gic_recalc_ppi_hppi(env); +} + static uint64_t gicr_cdia_read(CPUARMState *env, const ARMCPRegInfo *ri) { /* Acknowledge HPPI in the current interrupt domain */ @@ -1381,7 +1402,7 @@ static uint64_t gicr_cdia_read(CPUARMState *env, cons= t ARMCPRegInfo *ri) env->gicv5_cpuif.ich_ppi_active[ppireg] |=3D ppibit; if (hm_edge) { /* handling mode is Edge: clear pending */ - env->gicv5_cpuif.ich_ppi_pend[ppireg] &=3D ~ppibit; + gic_clear_vppi_pending(env, ppireg, ppibit); } gic_recalc_virt_ppi_hppi(env); } else { --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188120574850.91954533573926; Tue, 13 Oct 2026 01:46:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4K-0000hG-8W; Tue, 13 Oct 2026 04:41:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3v-0008O3-Sx for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:44 -0400 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 1xGY3t-00080o-QV for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:43 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-487049569b6so1851749f8f.1 for ; Tue, 13 Oct 2026 01:40:41 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880840; x=1792485640; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=46TFe67yKvbFfVh4QDME6NqlGkn+SwL4WUrd3hyiWf0=; b=T1cX1RqBhFwyU9CbIkfY4Yc6EYKZfoA5rsLDWZzq2i4akah+hLPs95yhtDlb25OUm+ FptEnZKtPrnCYMXdepZGCUXWae6Wvdsh7mM+dl3pDFyOkeH6AfUsUj7lqLUPyKCk/c0k ixKIfW7PUZsCiNrWRLlXgfsEaf3yTnWTj0eT2i6zlU6dk/eHvZiAldsWpDSgYytWG3rx ySJD8Q4VIgaPjkNYuNFSEcPL6jR6HBftV4K1arO/VM7C0awuZfKRKqy4r8Ap5EFccMNQ V1IPbpmjlEqSYV2XVTUgZfljEWaTzrp+8OHAIY8+ZHW0oKGxYzdoumn2fXicDzwxZm2Q 8Xsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880840; x=1792485640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=46TFe67yKvbFfVh4QDME6NqlGkn+SwL4WUrd3hyiWf0=; b=BhAS2fs8HU4d4x3khJczntZ8l7PaB+PUGQtGymONntue6OgbOnkANhh6+LNNTC3MKH m0ZB6kI4Yx81C0kOMIPWiR9+EvgvTQgQsCrq4Q35mGNBnEBOXwRVpJ3DFOU1EyhAEwFF S+kAoAHl8WZFHzEtlAFUozhu4HHlLv3oA11HEfwszklSHzTZ1hXUijJ27WlrZ87D/5jN JS9NBy+BQjTVF79wa0KP7Bdt+8vO/Ws3E2SjcoC8QZFJ8UVnqUEcAVpbfEk2whfqPOcP eF9WNu5hCvoCiWuu7MnF4y9Wgl7ERXmDIjLL+Ch5iiUdkr9zj1Qccco01Y7yQy8l9pqb cRtQ== X-Forwarded-Encrypted: i=1; AKwUvBz1Uy8yDFGSZfncQmg6ng5hfEmbUgj66kIwN0FeUjr2O04vKIbv0/wkA8lWSH0u1m7txa4VK0Ylpxru@nongnu.org X-Gm-Message-State: AFq9FYI0g5dNGVEAju4eg3rrxujXron6rhQISJ5o6txs+uHasewToXjq XPWdYKLgFCtV6f+yGHcE0DHlMb/JM6JvqWwwkyk7EsHCz7WXpq3mTVOm8fBuuzRQGcvrZBPE2GV rnyrmm/w= X-Gm-Gg: AYBFou2OTJ9WLXo+DFoFBNRJdDjO2lwgxPFmeDgmqyjCrrC6rZRvsz7LuhEn2lVLk+O 8T5VCAfR0hoIdDSvha6rqawMkePlcqARHKZoMzNaJ/we5ozE+6UMG+E2RsVdMEFoaN10ucPPY0L gRAhuZnSRpeHlUfB+l/A75vMwka+QO3znRc0+3/0F5FSRbtYozqR1kxIEY7ZfWssxwxGOhio/2p rj8mbiP9HcVabbhhWxm3Jxb5verF7pjjjUvymsg6vhsJzR+YtsKhqrQu+FXHtc/ylMY6UXUl4n+ jtijT286hX4R+JAgGB6Wlwyb4/fGrb007bUZmubzhxPXDHWkKvpr2fFsPeMMgOlBvZluQylU0mw qX1UmPVyFcQ8gtC7oxoni3S6hY9TacqYClUGbBRts1U+UtfvFuHniSm/TFhK+HcA05uEkLd8n0E rsqmd2c8yKXf4FipMLQ7jSz6w0Gdq5WBc8CJlBjP6GWaHe/ywLmzfpjLC39N8MihXNjnY1+1tjA nYOzEcvDf5iiXDalRh2WS/UTfM/7YHMJJfloJjOk7yWMs4Mh88f9egGlADaEQHHDRZ5a7tlgVYt JDAJeCF3j2yP+Q== X-Received: by 2002:a05:600c:64c7:b0:4a1:8399:b74a with SMTP id 5b1f17b1804b1-4a18e4e5c7cmr216368425e9.31.1791880840264; Tue, 13 Oct 2026 01:40:40 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 47/86] target/arm: GICv5 cpuif: Update on HCR_EL2.{NV, NV1} and SCR_EL3.NS changes Date: Tue, 13 Oct 2026 09:38:54 +0100 Message-ID: <20261013083933.1024405-48-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1791881207485158500 Content-Type: text/plain; charset="utf-8" When HCR_EL2.{NV,NV1} or SCR_EL3.NS change, this can affect how direct injection of timer PPIs is handled, which in turn can potentially affect what the highest priority virtual pending PPI is. Since the virtual HPPI can be read from EL2 or EL3, we need to arrange that changes to these bits trigger a GICv5 recalculation. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/gicv5-stubs.c | 8 ++++++++ target/arm/helper.c | 23 ++++++++++++++++++----- target/arm/internals.h | 9 +++++++++ target/arm/tcg/gicv5-cpuif.c | 18 ++++++++++++++++++ 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/target/arm/gicv5-stubs.c b/target/arm/gicv5-stubs.c index 845626d7c6b..b8c926744cb 100644 --- a/target/arm/gicv5-stubs.c +++ b/target/arm/gicv5-stubs.c @@ -15,3 +15,11 @@ void define_gicv5_cpuif_regs(ARMCPU *cpu) void gicv5_update_ppi_state(CPUARMState *env, int ppi, bool level) { } + +void gicv5_update_on_hcr_nv_change(CPUARMState *env) +{ +} + +void gicv5_update_on_scr_ns_change(CPUARMState *env) +{ +} diff --git a/target/arm/helper.c b/target/arm/helper.c index ff0b766b73d..959f1d83a70 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1012,6 +1012,12 @@ static void scr_write(CPUARMState *env, const ARMCPR= egInfo *ri, uint64_t value) ARMMMUIdxBit_E2 | ARMMMUIdxBit_E2_GCS)); } + /* The GICv5 cpuif needs to know if SCR_EL3.NS changes */ +#ifndef CONFIG_USER_ONLY + if (changed & SCR_NS) { + gicv5_update_on_scr_ns_change(env); + } +#endif } =20 static void scr_reset(CPUARMState *env, const ARMCPRegInfo *ri) @@ -3881,7 +3887,7 @@ static const ARMCPRegInfo v8_aa32_el1_reginfo[] =3D { static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_= mask) { ARMCPU *cpu =3D env_archcpu(env); - bool hcr_change_timer; + uint64_t changed; =20 if (arm_feature(env, ARM_FEATURE_V8)) { valid_mask |=3D MAKE_64BIT_MASK(0, 34); /* ARMv8.0 */ @@ -3960,6 +3966,8 @@ static void do_hcr_write(CPUARMState *env, uint64_t v= alue, uint64_t valid_mask) } } =20 + changed =3D env->cp15.hcr_el2 ^ value; + /* * These bits change the MMU setup: * HCR_VM enables stage 2 translation @@ -3969,16 +3977,21 @@ static void do_hcr_write(CPUARMState *env, uint64_t= value, uint64_t valid_mask) * HCR_FWB changes the interpretation of stage2 descriptor bits * HCR_NV and HCR_NV1 affect interpretation of descriptor bits */ - if ((env->cp15.hcr_el2 ^ value) & + if (changed & (HCR_VM | HCR_PTW | HCR_DC | HCR_DCT | HCR_FWB | HCR_NV | HCR_NV1)= ) { tlb_flush(CPU(cpu)); } - hcr_change_timer =3D (env->cp15.hcr_el2 ^ value) & - (HCR_E2H | HCR_TGE); =20 /* update */ env->cp15.hcr_el2 =3D value; =20 + /* If HCR_EL2.{NV,NV1} change we must inform the GICv5 cpuif */ +#ifndef CONFIG_USER_ONLY + if (changed & (HCR_NV | HCR_NV1)) { + gicv5_update_on_hcr_nv_change(env); + } +#endif + /* * Updates to VI and VF require us to update the status of * virtual interrupts, which are the logical OR of these bits @@ -3998,7 +4011,7 @@ static void do_hcr_write(CPUARMState *env, uint64_t v= alue, uint64_t valid_mask) arm_cpu_update_vinmi(cpu); arm_cpu_update_vfnmi(cpu); } - if (hcr_change_timer) { + if (changed & (HCR_E2H | HCR_TGE)) { #ifndef CONFIG_USER_ONLY gt_recalc_timer(cpu, GTIMER_PHYS); #endif diff --git a/target/arm/internals.h b/target/arm/internals.h index 9d817961c67..f291aee0bd8 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1909,6 +1909,15 @@ void define_gicv5_cpuif_regs(ARMCPU *cpu); */ void gicv5_update_ppi_state(CPUARMState *env, int ppi, bool level); =20 +/* + * Tell the GICv5 when HCR_EL2.{NV,NV1} change. Does nothing if GICv5 not + * present. + */ +void gicv5_update_on_hcr_nv_change(CPUARMState *env); + +/* Tell the GICv5 when SCR_EL3.NS changes. Does nothing if GICv5 not prese= nt */ +void gicv5_update_on_scr_ns_change(CPUARMState *env); + /* Effective value of MDCR_EL2 */ static inline uint64_t arm_mdcr_el2_eff(CPUARMState *env) { diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 1f032e39bf6..e7e3dc214d6 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -630,6 +630,24 @@ void gicv5_update_ppi_state(CPUARMState *env, int ppi,= bool level) } } =20 +void gicv5_update_on_hcr_nv_change(CPUARMState *env) +{ + /* HCR_EL2.{NV,NV1} changed, which affects DVI timer PPI remapping */ + if (!cpu_isar_feature(aa64_gcie, env_archcpu(env))) { + return; + } + gic_recalc_virt_ppi_hppi(env); +} + +void gicv5_update_on_scr_ns_change(CPUARMState *env) +{ + /* SCR_EL3.NS changed, which affects DVI timer PPI remapping */ + if (!cpu_isar_feature(aa64_gcie, env_archcpu(env))) { + return; + } + gic_recalc_virt_ppi_hppi(env); +} + static void gic_cddis_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881341; cv=none; d=zohomail.com; s=zohoarc; b=nT2Tpa1fbCIyUY+zf5Vq8VoTDpDps5FYwmqjmwhxgKKHbnVp6aqJZAjuXbwEZ8YB4v5cpKnozV9nYrAXp9GWyuamlqEWoaOvUdTNM26nFcTZdhgVqv1ttM4JtGomeS6o7/OYkpA38G0Kw8LNBbAqc65kNraSHKC46C2rJXoxz2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881341; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=/Sig7FVvdhb0+exNtEt5dl5MsuYM+MG8UgxMJ4WaGc0=; b=F8Hqwa03VVnfRRTKHCfyg8wcp5JIpA5RWKWrnPpHdZNUUyBM4SWQWbfIvQ5NdffKKOH8PAA+6XvJ4e3enF0na+NVvuXpOgSXdNg/RUwadRXbFYJP7ngkeYLXGi9MV7LXbn0yKFqHpVD2HwSQNg0ckxkwG+H1CHiqypU2WccAW8E= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881341062403.5429280588339; Tue, 13 Oct 2026 01:49:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY6K-000445-0o; Tue, 13 Oct 2026 04:43:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3x-0008RV-1l for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:45 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3u-000818-Vz for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:44 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4a1ad2e2391so2927155e9.0 for ; Tue, 13 Oct 2026 01:40:42 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880841; x=1792485641; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=/Sig7FVvdhb0+exNtEt5dl5MsuYM+MG8UgxMJ4WaGc0=; b=WZakO9FSXbZ7GJhLZFFphQyksUyduQemaTIU2ABp1QInl0ka/Nv50vbbufTK8d0WLU 3yFD2wig1fMtyKC5HIDGNP8Jf2agR+U20/St7bD+6BFHjHapSTX0MKyf3pGTe/rh9MjI YkO24KI7f+qmzkJ/EIm/ukv664w2f9Kf+AeLPdYMscuueMdd+4ouCtfPt9mOONtVKX2I SPWV8XAKC64SPdl9x48HjKIlB/84F56mvUCnHu9c/RSV8opmqOwDuLLaU+SLB75bKBhw 2+6+9KJLXEtGiC/9RxeRKuzOS/06jUF6KGF8zuPpKOJbVHitUBBz1KA7iJv5OfeOf/16 icoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880841; x=1792485641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=/Sig7FVvdhb0+exNtEt5dl5MsuYM+MG8UgxMJ4WaGc0=; b=w0h/R4T7vVjhVIroQ66Hk5Vj+oVq0NgX9QYp5o1dnXEw3GUy6V98IIzpsUyO8aRokM Rv00xbmjGvmRA+5bqFDwX46t4mwazZec1/KFrVjJcob1U8kAVurc7MqIeZxDe4wQHwu/ VJetYCJoMkGMa1gPbUq06HNjX4wQBfV7utGplv4Ztd+R+0vO8kwXAkOTjLSRT00F+8dq pfcjcCE4Kp0oVU7VIC55wxfZNccbFz6QbW/p4mIx/hC/ayT4maSAiPRksSG84q5KcZ/D AzHn1de/1RxzkRgvkNpJon5mepnTnVYZMOm1psxV62M0SAxEIW6F9NmgvjQj3YRx/Tun LMEA== X-Forwarded-Encrypted: i=1; AKwUvByhqtDxuBP3iQ6Lny4CXZIvHH048+fbc6ZvnlZiJsEg/sroLmGghB0kKAfxVyp0VMxk8s++CuGuGRIl@nongnu.org X-Gm-Message-State: AFq9FYKKpNK1ejKAUZ2UboBRc/59mmOCTywe8Qk+Gs91RxMVfh2UmF7o OQCRJOCGSuRMFBetyZ8uDa12QnVl/UsakQNQCyK3enTuMNbBXibWq84naCSr0NCXceQuvuFDyYU z5TKoL50= X-Gm-Gg: AYBFou2rS/AWtn2trH7gKeKGwFp2fFhqx2A27mZRddEasjWIvc6UlcgXq76qxLZOT+B M9pLw//r6d9xR86TJsAcrUhP159XjfpnrmrbF26zwqtZwqsD7i2oE/bf7gnQtMbL1x4Fk7Wo6JN YUSgIWLfqCOKmyYw5GuHavz+gXG6ghjy4wk8mhovWuOsD1oCRSTTnmjmbfrCyK6N4v198oaolSX E80hNWWG5EJJS4f2/kTfcgazUrwaCld5J6Gk3pmc/pZkgOaP5q1KWO0/wdTKQV75XncYQn3ooJq dd1UfsP+KsUPpo7zWEgCGTG9CF8+OK9S8DztZ/cae6L/O6pwdLRJu0IkXGdm2L3ocnY669EXCdy G/QMzyA62kSO0ByaA6Qykg6FhD1mESwTmuCov9sx3KeL31lYdUEQXbzrA4xE5Wmd2drbpq4/VuW /ibH2Ye8IUS91MsErF0ckVVBMR0KOu4TSMqljiZmjO975CvV1IhqScLHDNmUGSlTfPkAF+tW8x9 /7V29MMCYA6bCSxOwyDtSJUQ2LlcHNN9Wp7P9br/kVR5JaHqkaTfwf11fIKwULPsLcckW1JnthQ M5E= X-Received: by 2002:a05:600c:350b:b0:4a1:ad01:f8dc with SMTP id 5b1f17b1804b1-4a1ad01f924mr23664985e9.21.1791880841177; Tue, 13 Oct 2026 01:40:41 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 48/86] target/arm: GICv5 cpuif: Update VFIQ/VIRQ when direct-injected PPIs change Date: Tue, 13 Oct 2026 09:38:55 +0100 Message-ID: <20261013083933.1024405-49-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881342008158500 Content-Type: text/plain; charset="utf-8" When a physical PPI changes its pending state we usually don't need to update the virtual PPI state. However, if the PPI is direct-injected to the VM then we do need to do that update. Make this check and call gic_recalc_virt_ppi_hppi() where we update physical PPI pending state. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- target/arm/tcg/gicv5-cpuif.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index e7e3dc214d6..406c980af5e 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -602,6 +602,28 @@ void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain = domain, bool virtual) } } =20 +static void gic_recalc_virt_ppi_hppi_for_dvi(CPUARMState *env, int reg, + uint64_t mask) +{ + /* + * Called after the physical PPI pending state has changed for the + * PPIs indicated by the mask and reg arguments. If any of these + * PPIs are direct-injected, we need to recalculate the virtual + * HPPI. + * + * It is possible that even if the DVI bit is set we might not + * actually be direct-injecting the PPI (e.g. if HVI is set, or if + * timer-PPI redirection means we're ignoring this DVI bit), but + * if so the recalculation will just do nothing. These cases are + * "the guest did something valid but odd" in that it set a DVI + * bit it knew wasn't going to have any effect, so not worth + * trying to catch early. + */ + if (env->gicv5_cpuif.ich_ppi_dvi[reg] & mask) { + gic_recalc_virt_ppi_hppi(env); + } +} + void gicv5_update_ppi_state(CPUARMState *env, int ppi, bool level) { /* @@ -627,6 +649,7 @@ void gicv5_update_ppi_state(CPUARMState *env, int ppi, = bool level) env->gicv5_cpuif.ppi_pend[0] =3D deposit64(env->gicv5_cpuif.ppi_pend[0], ppi, 1, level); gic_recalc_ppi_hppi(env); + gic_recalc_virt_ppi_hppi_for_dvi(env, 0, 1ULL << ppi); } } =20 @@ -894,6 +917,7 @@ static void gic_ppi_cpend_write(CPUARMState *env, const= ARMCPRegInfo *ri, uint64_t old =3D raw_read(env, ri); raw_write(env, ri, old & ~value); gic_recalc_ppi_hppi(env); + gic_recalc_virt_ppi_hppi_for_dvi(env, reg, value); } } =20 @@ -924,6 +948,7 @@ static void gic_ppi_spend_write(CPUARMState *env, const= ARMCPRegInfo *ri, uint64_t old =3D raw_read(env, ri); raw_write(env, ri, old | value); gic_recalc_ppi_hppi(env); + gic_recalc_virt_ppi_hppi_for_dvi(env, reg, value); } } =20 @@ -1428,6 +1453,7 @@ static uint64_t gicr_cdia_read(CPUARMState *env, cons= t ARMCPRegInfo *ri) if (hm_edge) { /* handling mode is Edge: clear pending */ env->gicv5_cpuif.ppi_pend[ppireg] &=3D ~ppibit; + gic_recalc_virt_ppi_hppi_for_dvi(env, ppireg, ppibit); } gic_recalc_ppi_hppi(env); } --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881488; cv=none; d=zohomail.com; s=zohoarc; b=C47FAM2Rn4XLXUyDf8HqwBq9SCqXG1m6U5nBr35Hy9Swqp5wsCw9L5K7PYgx5RktmiKX38XQ0qzjKG0xmUEFK/xW/zz/4OgHBYsKwGZjzpbhedw3lTKPErKencPafVks2KjV+Dze27FrdT1ILvpXTyP6g6D6YcoTpoxlBEmbiG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881488; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=smZTZM7oZW8bOZkpZTb5qADBZ0m6LNtjYEMi2pmMLN4=; b=RUHT+4AnUX4fSW8VHkfbSCI1+KYVNaUb2GqrskCen5QUdjgBKKlDQCMK1lu25lqlzT2GYfcYogzg5pmMOUktiqPXzjni2KpiMWPQDBElpuUz0SDZ7Kk7CJNMEZNUXAVWoOfGE+4uy8S4mv6UwtIY6lCf8aH7byg/Uy0mixQl/Nc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881488660169.5127162436155; Tue, 13 Oct 2026 01:51:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY6A-0003TK-A1; Tue, 13 Oct 2026 04:43:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3z-0008UT-7d for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:47 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3v-00081e-PU for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:46 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4a021c809e3so26438185e9.0 for ; Tue, 13 Oct 2026 01:40:43 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880842; x=1792485642; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=smZTZM7oZW8bOZkpZTb5qADBZ0m6LNtjYEMi2pmMLN4=; b=ZZHUJqgcWHO/TfiVA+aekEDb0AZ17g9wY31hC4vfIzr73PEFogN66asFaZzMpertps Nw4qbhfDevQTLJq6W6f4v6v52sC0I7da8mR24427jsyY0TsijLSC1kLqekrMenRCKz6S YYTiGN7l21y8gdjie6zcJLCBnuD2plt34WUGD9xwdE0rkHtshHd+R9vuHhOxH5qBGYF8 5GfEu8sbWhZVm+4v9jhUVNQJPGkpG3yIJNtdewAODE32h2qHpo+6pOYhgkif0FAy8YdU dv1y+6/Tu7yonITQD4g/oyIYMHZdpRynsa/pIKfqB64jejWNHuEYQu+tjAKYmd2qtpKm 3heA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880842; x=1792485642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=smZTZM7oZW8bOZkpZTb5qADBZ0m6LNtjYEMi2pmMLN4=; b=S62uOF8sASJsnDmvx8fSYd9T0HOuwh009Uj961c/yDhE+U13q9uVi/PEp9vRAhRkWa QNtXOZT7MyZlmnZHUuyWp+ercIkfgZ52FftvUZtPU96jriT8kuG9jgToEhkq0dRrer53 KX31btRHSYgabuoXynwJiYyrNN/SQDopYtl1H35RWJNNk883aaKC3TNcRHBsfjAX5JHy s9U2YtTdcWplYVWvYhhemW0VXu/1rYBYeA1dWNJFxOudzFh//p/iSjrTZHQhpuoZm3DD AoOgSyHLH8ptEFbuvPnBiTwdU6nirHnekX+n9H4ABNZ+10kwkD2GRzZhj5IhNTBnOOU2 Hbpg== X-Forwarded-Encrypted: i=1; AKwUvBwhKRBjT+QhnC7+QFvPPG/UqGL+UCkhVO5NxGJIOZrjc1c8ysIxPP8n4L+YjrcRfTbW0t5OiAxNtjog@nongnu.org X-Gm-Message-State: AFq9FYKffwDzT1cL4T+OhRTTuyqBvcK6xMaedqJxCJH1iusu+m7eL5ta kAJJIXkJS0e0UzJVgxJYyIHjUIo3zbxdWDDix5dA/Glji0kXBxuOCbA/ZAQPJgElX7267e3MAKx Z6R0JkaY= X-Gm-Gg: AYBFou3GgpOmq1R+z4CBUNLMKNGWz1xi9m7hGQ3o2TXYUFFAJgXfzwVWThUyO9XTlMb 5ZU+K8Qrsfvw9daoUevTfm8P37Lp194MCnxd3DcVlfV1L7Kqo+Qco/TSIBQxwE57AGiClb21Uxa 0dfMMYYBw33fw7ngfQOeQ9dm3dPwU+n4yZZ6C5P+Ajl0fi2MyZTVHYGpCTI6lcKsZHtB7HGgmjc JPDn62RF/o+RMJqQ1Kh3rKxHvf2oou6F/NWICm59cn3z+1hBfbAHB/AlPI13hzvbvzhzXiywvkd W65V8ntdHXe3cBoLFkn4rR8/kJDS8uWXASkwLNyggzdHF0rF9OnOif95OVVAwbJ/Q5AOuY1VFIl h/P6j1YCAwOzepYXFTIeiYM+Mm/IyQ7SKscX2Ag1UwEmlKMqh9Sje/SxygkLbuVnKRL9iJyaRPV 1aESFZGaxuVr6lhVrcO+53hFQvASnfXgZ2bMPEjjOs1vmLiCwTnCW68BKrhq4JJodoqslrsJp2g 9d0173BWJnsGKuMk5NGfSQBrs/rKtkcZtF8TX95cB3Wjin9estVpFZaAc2mQEumIDVzk2EhzLpw 1LO2duqYYFGQCw== X-Received: by 2002:a05:600c:6097:b0:49f:bd3c:bc24 with SMTP id 5b1f17b1804b1-4a18e4b8885mr219382515e9.31.1791880842127; Tue, 13 Oct 2026 01:40:42 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 49/86] hw/intc: Move GICv5 register and data definitions into a header Date: Tue, 13 Oct 2026 09:38:56 +0100 Message-ID: <20261013083933.1024405-50-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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, UPPERCASE_50_75=0.008 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881490986158500 Content-Type: text/plain; charset="utf-8" We put the definitions of GICv5 IRS registers and guest-memory data structures directly into arm_gicv5.c. It turns out that there are a few cases where we would like them outside that file (for instance register reset is handled in arm_gicv5_common.c). Move the definitions to their own header file. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 270 +---------------------------- include/hw/intc/arm_gicv5_regs.h | 286 +++++++++++++++++++++++++++++++ 2 files changed, 287 insertions(+), 269 deletions(-) create mode 100644 include/hw/intc/arm_gicv5_regs.h diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index d503d8db426..289a3afaeae 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -15,6 +15,7 @@ #include "hw/core/registerfields.h" #include "hw/intc/arm_gicv5.h" #include "hw/intc/arm_gicv5_stream.h" +#include "hw/intc/arm_gicv5_regs.h" #include "qapi/error.h" #include "qemu/log.h" #include "trace.h" @@ -48,275 +49,6 @@ static const char *inttype_name(GICv5IntType t) return names[t]; } =20 -REG32(IRS_IDR0, 0x0) - FIELD(IRS_IDR0, INT_DOM, 0, 2) - FIELD(IRS_IDR0, PA_RANGE, 2, 4) - FIELD(IRS_IDR0, VIRT, 6, 1) - FIELD(IRS_IDR0, ONE_N, 7, 1) - FIELD(IRS_IDR0, VIRT_ONE_N, 8, 1) - FIELD(IRS_IDR0, SETLPI, 9, 1) - FIELD(IRS_IDR0, MEC, 10, 1) - FIELD(IRS_IDR0, MPAM, 11, 1) - FIELD(IRS_IDR0, SWE, 12, 1) - FIELD(IRS_IDR0, IRSID, 16, 16) - -REG32(IRS_IDR1, 0x4) - FIELD(IRS_IDR1, PE_CNT, 0, 16) - FIELD(IRS_IDR1, IAFFID_BITS, 16, 4) - FIELD(IRS_IDR1, PRI_BITS, 20, 3) - -REG32(IRS_IDR2, 0x8) - FIELD(IRS_IDR2, ID_BITS, 0, 5) - FIELD(IRS_IDR2, LPI, 5, 1) - FIELD(IRS_IDR2, MIN_LPI_ID_BITS, 6, 4) - FIELD(IRS_IDR2, IST_LEVELS, 10, 1) - FIELD(IRS_IDR2, IST_L2SZ, 11, 3) - FIELD(IRS_IDR2, IST_MD, 14, 1) - FIELD(IRS_IDR2, ISTMD_SZ, 15, 5) - -REG32(IRS_IDR3, 0xc) - FIELD(IRS_IDR3, VMD, 0, 1) - FIELD(IRS_IDR3, VMD_SZ, 1, 4) - FIELD(IRS_IDR3, VM_ID_BITS, 5, 5) - FIELD(IRS_IDR3, VMT_LEVELS, 10, 1) - -REG32(IRS_IDR4, 0x10) - FIELD(IRS_IDR4, VPED_SZ, 0, 6) - FIELD(IRS_IDR4, VPE_ID_BITS, 6, 4) - -REG32(IRS_IDR5, 0x14) - FIELD(IRS_IDR5, SPI_RANGE, 0, 25) - -REG32(IRS_IDR6, 0x18) - FIELD(IRS_IDR6, SPI_IRS_RANGE, 0, 25) - -REG32(IRS_IDR7, 0x1c) - FIELD(IRS_IDR7, SPI_BASE, 0, 24) - -REG32(IRS_IIDR, 0x40) - FIELD(IRS_IIDR, IMPLEMENTER, 0, 12) - FIELD(IRS_IIDR, REVISION, 12, 4) - FIELD(IRS_IIDR, VARIANT, 16, 4) - FIELD(IRS_IIDR, PRODUCTID, 20, 12) - -REG32(IRS_AIDR, 0x44) - FIELD(IRS_AIDR, ARCHMINORREV, 0, 4) - FIELD(IRS_AIDR, ARCHMAJORREV, 4, 4) - FIELD(IRS_AIDR, COMPONENT, 8, 4) - -REG32(IRS_CR0, 0x80) - FIELD(IRS_CR0, IRSEN, 0, 1) - FIELD(IRS_CR0, IDLE, 1, 1) - -REG32(IRS_CR1, 0x84) - FIELD(IRS_CR1, SH, 0, 2) - FIELD(IRS_CR1, OC, 2, 2) - FIELD(IRS_CR1, IC, 4, 2) - FIELD(IRS_CR1, IST_RA, 6, 1) - FIELD(IRS_CR1, IST_WA, 7, 1) - FIELD(IRS_CR1, VMT_RA, 8, 1) - FIELD(IRS_CR1, VMT_WA, 9, 1) - FIELD(IRS_CR1, VPET_RA, 10, 1) - FIELD(IRS_CR1, VPET_WA, 11, 1) - FIELD(IRS_CR1, VMD_RA, 12, 1) - FIELD(IRS_CR1, VMD_WA, 13, 1) - FIELD(IRS_CR1, VPED_RA, 14, 1) - FIELD(IRS_CR1, VPED_WA, 15, 1) - -REG32(IRS_SYNCR, 0xc0) - FIELD(IRS_SYNCR, SYNC, 31, 1) - -REG32(IRS_SYNC_STATUSR, 0xc4) - FIELD(IRS_SYNC_STATUSR, IDLE, 0, 1) - -REG64(IRS_SPI_VMR, 0x100) - FIELD(IRS_SPI_VMR, VM_ID, 0, 16) - FIELD(IRS_SPI_VMR, VIRT, 63, 1) - -REG32(IRS_SPI_SELR, 0x108) - FIELD(IRS_SPI_SELR, ID, 0, 24) - -REG32(IRS_SPI_DOMAINR, 0x10c) - FIELD(IRS_SPI_DOMAINR, DOMAIN, 0, 2) - -REG32(IRS_SPI_RESAMPLER, 0x110) - FIELD(IRS_SPI_RESAMPLER, SPI_ID, 0, 24) - -REG32(IRS_SPI_CFGR, 0x114) - FIELD(IRS_SPI_CFGR, TM, 0, 1) - -REG32(IRS_SPI_STATUSR, 0x118) - FIELD(IRS_SPI_STATUSR, IDLE, 0, 1) - FIELD(IRS_SPI_STATUSR, V, 1, 1) - -REG32(IRS_PE_SELR, 0x140) - FIELD(IRS_PE_SELR, IAFFID, 0, 16) - -REG32(IRS_PE_STATUSR, 0x144) - FIELD(IRS_PE_STATUSR, IDLE, 0, 1) - FIELD(IRS_PE_STATUSR, V, 1, 1) - FIELD(IRS_PE_STATUSR, ONLINE, 2, 1) - -REG32(IRS_PE_CR0, 0x148) - FIELD(IRS_PE_CR0, DPS, 0, 1) - -REG64(IRS_IST_BASER, 0x180) - FIELD(IRS_IST_BASER, VALID, 0, 1) - FIELD(IRS_IST_BASER, ADDR, 6, 50) - -REG32(IRS_IST_CFGR, 0x190) - FIELD(IRS_IST_CFGR, LPI_ID_BITS, 0, 5) - FIELD(IRS_IST_CFGR, L2SZ, 5, 2) - FIELD(IRS_IST_CFGR, ISTSZ, 7, 2) - FIELD(IRS_IST_CFGR, STRUCTURE, 16, 1) - -REG32(IRS_IST_STATUSR, 0x194) - FIELD(IRS_IST_STATUSR, IDLE, 0, 1) - -REG32(IRS_MAP_L2_ISTR, 0x1c0) - FIELD(IRS_MAP_L2_ISTR, ID, 0, 24) - -REG64(IRS_VMT_BASER, 0x200) - FIELD(IRS_VMT_BASER, VALID, 0, 1) - FIELD(IRS_VMT_BASER, ADDR, 3, 53) - -REG32(IRS_VMT_CFGR, 0x210) - FIELD(IRS_VMT_CFGR, VM_ID_BITS, 0, 5) - FIELD(IRS_VMT_CFGR, STRUCTURE, 16, 1) - -REG32(IRS_VMT_STATUSR, 0x124) - FIELD(IRS_VMT_STATUSR, IDLE, 0, 1) - -REG64(IRS_VPE_SELR, 0x240) - FIELD(IRS_VPE_SELR, VM_ID, 0, 16) - FIELD(IRS_VPE_SELR, VPE_ID, 32, 16) - FIELD(IRS_VPE_SELR, S, 63, 1) - -REG64(IRS_VPE_DBR, 0x248) - FIELD(IRS_VPE_DBR, INTID, 0, 24) - FIELD(IRS_VPE_DBR, DBPM, 32, 5) - FIELD(IRS_VPE_DBR, REQ_DB, 62, 1) - FIELD(IRS_VPE_DBR, DBV, 63, 1) - -REG32(IRS_VPE_HPPIR, 0x250) - FIELD(IRS_VPE_HPPIR, ID, 0, 24) - FIELD(IRS_VPE_HPPIR, TYPE, 29, 3) - FIELD(IRS_VPE_HPPIR, HPPIV, 32, 1) - -REG32(IRS_VPE_CR0, 0x258) - FIELD(IRS_VPE_CR0, DPS, 0, 1) - -REG32(IRS_VPE_STATUSR, 0x25c) - FIELD(IRS_VPE_STATUSR, IDLE, 0, 1) - FIELD(IRS_VPE_STATUSR, V, 1, 1) - -REG64(IRS_VM_DBR, 0x280) - FIELD(IRS_VM_DBR, VPE_ID, 0, 16) - FIELD(IRS_VM_DBR, EN, 63, 1) - -REG32(IRS_VM_SELR, 0x288) - FIELD(IRS_VM_SELR, VM_ID, 0, 16) - -REG32(IRS_VM_STATUSR, 0x28c) - FIELD(IRS_VM_STATUSR, IDLE, 0, 1) - FIELD(IRS_VM_STATUSR, V, 1, 1) - -REG64(IRS_VMAP_L2_VMTR, 0x2c0) - FIELD(IRS_VMAP_L2_VMTR, VM_ID, 0, 16) - FIELD(IRS_VMAP_L2_VMTR, M, 63, 1) - -REG64(IRS_VMAP_VMR, 0x2c8) - FIELD(IRS_VMAP_VMR, VM_ID, 0, 16) - FIELD(IRS_VMAP_VMR, U, 62, 1) - FIELD(IRS_VMAP_VMR, M, 63, 1) - -REG64(IRS_VMAP_VISTR, 0x2d0) - FIELD(IRS_VMAP_VISTR, TYPE, 29, 3) - FIELD(IRS_VMAP_VISTR, VM_ID, 32, 16) - FIELD(IRS_VMAP_VISTR, U, 62, 1) - FIELD(IRS_VMAP_VISTR, M, 63, 1) - -REG64(IRS_VMAP_L2_VISTR, 0x2d8) - FIELD(IRS_VMAP_L2_VISTR, ID, 0, 24) - FIELD(IRS_VMAP_L2_VISTR, TYPE, 29, 3) - FIELD(IRS_VMAP_L2_VISTR, VM_ID, 32, 16) - FIELD(IRS_VMAP_L2_VISTR, M, 63, 1) - -REG64(IRS_VMAP_VPER, 0x2e0) - FIELD(IRS_VMAP_VPER, VPE_ID, 0, 16) - FIELD(IRS_VMAP_VPER, VM_ID, 32, 16) - FIELD(IRS_VMAP_VPER, M, 63, 1) - -REG64(IRS_SAVE_VMR, 0x300) - FIELD(IRS_SAVE_VMR, VM_ID, 0, 16) - FIELD(IRS_SAVE_VMR, Q, 62, 1) - FIELD(IRS_SAVE_VMR, S, 63, 1) - -REG32(IRS_SAVE_VM_STATUSR, 0x308) - FIELD(IRS_SAVE_VM_STATUSR, IDLE, 0, 1) - FIELD(IRS_SAVE_VM_STATUSR, Q, 1, 1) - -REG32(IRS_MEC_IDR, 0x340) - FIELD(IRS_MEC_IDR, MECIDSIZE, 0, 4) - -REG32(IRS_MEC_MECID_R, 0x344) - FIELD(IRS_MEC_MICID_R, MECID, 0, 16) - -REG32(IRS_MPAM_IDR, 0x380) - FIELD(IRS_MPAM_IDR, PARTID_MAX, 0, 16) - FIELD(IRS_MPAM_IDR, PMG_MAX, 16, 8) - FIELD(IRS_MPAM_IDR, HAS_MPAM_SP, 24, 1) - -REG32(IRS_MPAM_PARTID_R, 0x384) - FIELD(IRS_MPAM_IDR, PARTID, 0, 16) - FIELD(IRS_MPAM_IDR, PMG, 16, 8) - FIELD(IRS_MPAM_IDR, MPAM_SP, 24, 2) - FIELD(IRS_MPAM_IDR, IDLE, 31, 1) - -REG64(IRS_SWERR_STATUSR, 0x3c0) - FIELD(IRS_SWERR_STATUSR, V, 0, 1) - FIELD(IRS_SWERR_STATUSR, S0V, 1, 1) - FIELD(IRS_SWERR_STATUSR, S1V, 2, 1) - FIELD(IRS_SWERR_STATUSR, OF, 3, 1) - FIELD(IRS_SWERR_STATUSR, EC, 16, 8) - FIELD(IRS_SWERR_STATUSR, IMP_EC, 24, 8) - -REG64(IRS_SWERR_SYNDROMER0, 0x3c8) - FIELD(IRS_SWERR_SYNDROMER0, VM_ID, 0, 16) - FIELD(IRS_SWERR_SYNDROMER0, ID, 32, 24) - FIELD(IRS_SWERR_SYNDROMER0, TYPE, 60, 3) - FIELD(IRS_SWERR_SYNDROMER0, VIRTUAL, 63, 1) - -REG64(IRS_SWERR_SYNDROMER1, 0x3d0) - FIELD(IRS_SWERR_SYNDROMER2, ADDR, 3, 53) - -REG32(IRS_IDREGS, 0xffd0) -REG32(IRS_DEVARCH, 0xffbc) - -FIELD(L1_ISTE, VALID, 0, 1) -FIELD(L1_ISTE, L2_ADDR, 12, 44) - -FIELD(L2_ISTE, PENDING, 0, 1) -FIELD(L2_ISTE, ACTIVE, 1, 1) -FIELD(L2_ISTE, HM, 2, 1) -FIELD(L2_ISTE, ENABLE, 3, 1) -FIELD(L2_ISTE, IRM, 4, 1) -FIELD(L2_ISTE, HWU, 9, 2) -FIELD(L2_ISTE, PRIORITY, 11, 5) -FIELD(L2_ISTE, IAFFID, 16, 16) - -/* - * Format used for gicv5_request_config() return value, which matches - * the ICC_ICSR_EL1 bit layout. - */ -FIELD(ICSR, F, 0, 1) -FIELD(ICSR, ENABLED, 1, 1) -FIELD(ICSR, PENDING, 2, 1) -FIELD(ICSR, IRM, 3, 1) -FIELD(ICSR, ACTIVE, 4, 1) -FIELD(ICSR, HM, 5, 1) -FIELD(ICSR, PRIORITY, 11, 5) -FIELD(ICSR, IAFFID, 32, 16) =20 #define IRS_DEVARCH_VALUE ((0x23b << 31) | (0x1 << 20) | 0x5a19) =20 diff --git a/include/hw/intc/arm_gicv5_regs.h b/include/hw/intc/arm_gicv5_r= egs.h new file mode 100644 index 00000000000..275fee315b5 --- /dev/null +++ b/include/hw/intc/arm_gicv5_regs.h @@ -0,0 +1,286 @@ +/* + * ARM GICv5 emulation: Interrupt Routing Service (IRS) registers + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This file has definitions of IRS register layouts and + * in-guest-memory data structures, that shouldn't be needed + * outside the IRS implementation. + */ + +#ifndef HW_INTC_ARM_GICV5_REGS_H +#define HW_INTC_ARM_GICV5_REGS_H + +REG32(IRS_IDR0, 0x0) + FIELD(IRS_IDR0, INT_DOM, 0, 2) + FIELD(IRS_IDR0, PA_RANGE, 2, 4) + FIELD(IRS_IDR0, VIRT, 6, 1) + FIELD(IRS_IDR0, ONE_N, 7, 1) + FIELD(IRS_IDR0, VIRT_ONE_N, 8, 1) + FIELD(IRS_IDR0, SETLPI, 9, 1) + FIELD(IRS_IDR0, MEC, 10, 1) + FIELD(IRS_IDR0, MPAM, 11, 1) + FIELD(IRS_IDR0, SWE, 12, 1) + FIELD(IRS_IDR0, IRSID, 16, 16) + +REG32(IRS_IDR1, 0x4) + FIELD(IRS_IDR1, PE_CNT, 0, 16) + FIELD(IRS_IDR1, IAFFID_BITS, 16, 4) + FIELD(IRS_IDR1, PRI_BITS, 20, 3) + +REG32(IRS_IDR2, 0x8) + FIELD(IRS_IDR2, ID_BITS, 0, 5) + FIELD(IRS_IDR2, LPI, 5, 1) + FIELD(IRS_IDR2, MIN_LPI_ID_BITS, 6, 4) + FIELD(IRS_IDR2, IST_LEVELS, 10, 1) + FIELD(IRS_IDR2, IST_L2SZ, 11, 3) + FIELD(IRS_IDR2, IST_MD, 14, 1) + FIELD(IRS_IDR2, ISTMD_SZ, 15, 5) + +REG32(IRS_IDR3, 0xc) + FIELD(IRS_IDR3, VMD, 0, 1) + FIELD(IRS_IDR3, VMD_SZ, 1, 4) + FIELD(IRS_IDR3, VM_ID_BITS, 5, 5) + FIELD(IRS_IDR3, VMT_LEVELS, 10, 1) + +REG32(IRS_IDR4, 0x10) + FIELD(IRS_IDR4, VPED_SZ, 0, 6) + FIELD(IRS_IDR4, VPE_ID_BITS, 6, 4) + +REG32(IRS_IDR5, 0x14) + FIELD(IRS_IDR5, SPI_RANGE, 0, 25) + +REG32(IRS_IDR6, 0x18) + FIELD(IRS_IDR6, SPI_IRS_RANGE, 0, 25) + +REG32(IRS_IDR7, 0x1c) + FIELD(IRS_IDR7, SPI_BASE, 0, 24) + +REG32(IRS_IIDR, 0x40) + FIELD(IRS_IIDR, IMPLEMENTER, 0, 12) + FIELD(IRS_IIDR, REVISION, 12, 4) + FIELD(IRS_IIDR, VARIANT, 16, 4) + FIELD(IRS_IIDR, PRODUCTID, 20, 12) + +REG32(IRS_AIDR, 0x44) + FIELD(IRS_AIDR, ARCHMINORREV, 0, 4) + FIELD(IRS_AIDR, ARCHMAJORREV, 4, 4) + FIELD(IRS_AIDR, COMPONENT, 8, 4) + +REG32(IRS_CR0, 0x80) + FIELD(IRS_CR0, IRSEN, 0, 1) + FIELD(IRS_CR0, IDLE, 1, 1) + +REG32(IRS_CR1, 0x84) + FIELD(IRS_CR1, SH, 0, 2) + FIELD(IRS_CR1, OC, 2, 2) + FIELD(IRS_CR1, IC, 4, 2) + FIELD(IRS_CR1, IST_RA, 6, 1) + FIELD(IRS_CR1, IST_WA, 7, 1) + FIELD(IRS_CR1, VMT_RA, 8, 1) + FIELD(IRS_CR1, VMT_WA, 9, 1) + FIELD(IRS_CR1, VPET_RA, 10, 1) + FIELD(IRS_CR1, VPET_WA, 11, 1) + FIELD(IRS_CR1, VMD_RA, 12, 1) + FIELD(IRS_CR1, VMD_WA, 13, 1) + FIELD(IRS_CR1, VPED_RA, 14, 1) + FIELD(IRS_CR1, VPED_WA, 15, 1) + +REG32(IRS_SYNCR, 0xc0) + FIELD(IRS_SYNCR, SYNC, 31, 1) + +REG32(IRS_SYNC_STATUSR, 0xc4) + FIELD(IRS_SYNC_STATUSR, IDLE, 0, 1) + +REG64(IRS_SPI_VMR, 0x100) + FIELD(IRS_SPI_VMR, VM_ID, 0, 16) + FIELD(IRS_SPI_VMR, VIRT, 63, 1) + +REG32(IRS_SPI_SELR, 0x108) + FIELD(IRS_SPI_SELR, ID, 0, 24) + +REG32(IRS_SPI_DOMAINR, 0x10c) + FIELD(IRS_SPI_DOMAINR, DOMAIN, 0, 2) + +REG32(IRS_SPI_RESAMPLER, 0x110) + FIELD(IRS_SPI_RESAMPLER, SPI_ID, 0, 24) + +REG32(IRS_SPI_CFGR, 0x114) + FIELD(IRS_SPI_CFGR, TM, 0, 1) + +REG32(IRS_SPI_STATUSR, 0x118) + FIELD(IRS_SPI_STATUSR, IDLE, 0, 1) + FIELD(IRS_SPI_STATUSR, V, 1, 1) + +REG32(IRS_PE_SELR, 0x140) + FIELD(IRS_PE_SELR, IAFFID, 0, 16) + +REG32(IRS_PE_STATUSR, 0x144) + FIELD(IRS_PE_STATUSR, IDLE, 0, 1) + FIELD(IRS_PE_STATUSR, V, 1, 1) + FIELD(IRS_PE_STATUSR, ONLINE, 2, 1) + +REG32(IRS_PE_CR0, 0x148) + FIELD(IRS_PE_CR0, DPS, 0, 1) + +REG64(IRS_IST_BASER, 0x180) + FIELD(IRS_IST_BASER, VALID, 0, 1) + FIELD(IRS_IST_BASER, ADDR, 6, 50) + +REG32(IRS_IST_CFGR, 0x190) + FIELD(IRS_IST_CFGR, LPI_ID_BITS, 0, 5) + FIELD(IRS_IST_CFGR, L2SZ, 5, 2) + FIELD(IRS_IST_CFGR, ISTSZ, 7, 2) + FIELD(IRS_IST_CFGR, STRUCTURE, 16, 1) + +REG32(IRS_IST_STATUSR, 0x194) + FIELD(IRS_IST_STATUSR, IDLE, 0, 1) + +REG32(IRS_MAP_L2_ISTR, 0x1c0) + FIELD(IRS_MAP_L2_ISTR, ID, 0, 24) + +REG64(IRS_VMT_BASER, 0x200) + FIELD(IRS_VMT_BASER, VALID, 0, 1) + FIELD(IRS_VMT_BASER, ADDR, 3, 53) + +REG32(IRS_VMT_CFGR, 0x210) + FIELD(IRS_VMT_CFGR, VM_ID_BITS, 0, 5) + FIELD(IRS_VMT_CFGR, STRUCTURE, 16, 1) + +REG32(IRS_VMT_STATUSR, 0x124) + FIELD(IRS_VMT_STATUSR, IDLE, 0, 1) + +REG64(IRS_VPE_SELR, 0x240) + FIELD(IRS_VPE_SELR, VM_ID, 0, 16) + FIELD(IRS_VPE_SELR, VPE_ID, 32, 16) + FIELD(IRS_VPE_SELR, S, 63, 1) + +REG64(IRS_VPE_DBR, 0x248) + FIELD(IRS_VPE_DBR, INTID, 0, 24) + FIELD(IRS_VPE_DBR, DBPM, 32, 5) + FIELD(IRS_VPE_DBR, REQ_DB, 62, 1) + FIELD(IRS_VPE_DBR, DBV, 63, 1) + +REG32(IRS_VPE_HPPIR, 0x250) + FIELD(IRS_VPE_HPPIR, ID, 0, 24) + FIELD(IRS_VPE_HPPIR, TYPE, 29, 3) + FIELD(IRS_VPE_HPPIR, HPPIV, 32, 1) + +REG32(IRS_VPE_CR0, 0x258) + FIELD(IRS_VPE_CR0, DPS, 0, 1) + +REG32(IRS_VPE_STATUSR, 0x25c) + FIELD(IRS_VPE_STATUSR, IDLE, 0, 1) + FIELD(IRS_VPE_STATUSR, V, 1, 1) + +REG64(IRS_VM_DBR, 0x280) + FIELD(IRS_VM_DBR, VPE_ID, 0, 16) + FIELD(IRS_VM_DBR, EN, 63, 1) + +REG32(IRS_VM_SELR, 0x288) + FIELD(IRS_VM_SELR, VM_ID, 0, 16) + +REG32(IRS_VM_STATUSR, 0x28c) + FIELD(IRS_VM_STATUSR, IDLE, 0, 1) + FIELD(IRS_VM_STATUSR, V, 1, 1) + +REG64(IRS_VMAP_L2_VMTR, 0x2c0) + FIELD(IRS_VMAP_L2_VMTR, VM_ID, 0, 16) + FIELD(IRS_VMAP_L2_VMTR, M, 63, 1) + +REG64(IRS_VMAP_VMR, 0x2c8) + FIELD(IRS_VMAP_VMR, VM_ID, 0, 16) + FIELD(IRS_VMAP_VMR, U, 62, 1) + FIELD(IRS_VMAP_VMR, M, 63, 1) + +REG64(IRS_VMAP_VISTR, 0x2d0) + FIELD(IRS_VMAP_VISTR, TYPE, 29, 3) + FIELD(IRS_VMAP_VISTR, VM_ID, 32, 16) + FIELD(IRS_VMAP_VISTR, U, 62, 1) + FIELD(IRS_VMAP_VISTR, M, 63, 1) + +REG64(IRS_VMAP_L2_VISTR, 0x2d8) + FIELD(IRS_VMAP_L2_VISTR, ID, 0, 24) + FIELD(IRS_VMAP_L2_VISTR, TYPE, 29, 3) + FIELD(IRS_VMAP_L2_VISTR, VM_ID, 32, 16) + FIELD(IRS_VMAP_L2_VISTR, M, 63, 1) + +REG64(IRS_VMAP_VPER, 0x2e0) + FIELD(IRS_VMAP_VPER, VPE_ID, 0, 16) + FIELD(IRS_VMAP_VPER, VM_ID, 32, 16) + FIELD(IRS_VMAP_VPER, M, 63, 1) + +REG64(IRS_SAVE_VMR, 0x300) + FIELD(IRS_SAVE_VMR, VM_ID, 0, 16) + FIELD(IRS_SAVE_VMR, Q, 62, 1) + FIELD(IRS_SAVE_VMR, S, 63, 1) + +REG32(IRS_SAVE_VM_STATUSR, 0x308) + FIELD(IRS_SAVE_VM_STATUSR, IDLE, 0, 1) + FIELD(IRS_SAVE_VM_STATUSR, Q, 1, 1) + +REG32(IRS_MEC_IDR, 0x340) + FIELD(IRS_MEC_IDR, MECIDSIZE, 0, 4) + +REG32(IRS_MEC_MECID_R, 0x344) + FIELD(IRS_MEC_MICID_R, MECID, 0, 16) + +REG32(IRS_MPAM_IDR, 0x380) + FIELD(IRS_MPAM_IDR, PARTID_MAX, 0, 16) + FIELD(IRS_MPAM_IDR, PMG_MAX, 16, 8) + FIELD(IRS_MPAM_IDR, HAS_MPAM_SP, 24, 1) + +REG32(IRS_MPAM_PARTID_R, 0x384) + FIELD(IRS_MPAM_IDR, PARTID, 0, 16) + FIELD(IRS_MPAM_IDR, PMG, 16, 8) + FIELD(IRS_MPAM_IDR, MPAM_SP, 24, 2) + FIELD(IRS_MPAM_IDR, IDLE, 31, 1) + +REG64(IRS_SWERR_STATUSR, 0x3c0) + FIELD(IRS_SWERR_STATUSR, V, 0, 1) + FIELD(IRS_SWERR_STATUSR, S0V, 1, 1) + FIELD(IRS_SWERR_STATUSR, S1V, 2, 1) + FIELD(IRS_SWERR_STATUSR, OF, 3, 1) + FIELD(IRS_SWERR_STATUSR, EC, 16, 8) + FIELD(IRS_SWERR_STATUSR, IMP_EC, 24, 8) + +REG64(IRS_SWERR_SYNDROMER0, 0x3c8) + FIELD(IRS_SWERR_SYNDROMER0, VM_ID, 0, 16) + FIELD(IRS_SWERR_SYNDROMER0, ID, 32, 24) + FIELD(IRS_SWERR_SYNDROMER0, TYPE, 60, 3) + FIELD(IRS_SWERR_SYNDROMER0, VIRTUAL, 63, 1) + +REG64(IRS_SWERR_SYNDROMER1, 0x3d0) + FIELD(IRS_SWERR_SYNDROMER2, ADDR, 3, 53) + +REG32(IRS_IDREGS, 0xffd0) +REG32(IRS_DEVARCH, 0xffbc) + +FIELD(L1_ISTE, VALID, 0, 1) +FIELD(L1_ISTE, L2_ADDR, 12, 44) + +FIELD(L2_ISTE, PENDING, 0, 1) +FIELD(L2_ISTE, ACTIVE, 1, 1) +FIELD(L2_ISTE, HM, 2, 1) +FIELD(L2_ISTE, ENABLE, 3, 1) +FIELD(L2_ISTE, IRM, 4, 1) +FIELD(L2_ISTE, HWU, 9, 2) +FIELD(L2_ISTE, PRIORITY, 11, 5) +FIELD(L2_ISTE, IAFFID, 16, 16) + +/* + * Format used for gicv5_request_config() return value, which matches + * the ICC_ICSR_EL1 bit layout. + */ +FIELD(ICSR, F, 0, 1) +FIELD(ICSR, ENABLED, 1, 1) +FIELD(ICSR, PENDING, 2, 1) +FIELD(ICSR, IRM, 3, 1) +FIELD(ICSR, ACTIVE, 4, 1) +FIELD(ICSR, HM, 5, 1) +FIELD(ICSR, PRIORITY, 11, 5) +FIELD(ICSR, IAFFID, 32, 16) + +#endif --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881201; cv=none; d=zohomail.com; s=zohoarc; b=S44woPfjGzbofAxrfXb1eux4eskuW+xen2jppaybFL+75uUWGbqUbP8IXgpg59d0yF7zCOm+k1QkXhkU3Vs4L2E7NpHUHzOlJ2HRC/KNTAa9FOzSiq4bPdz+rRKnAnTIU5KErHxtaD6pUzo6dHRIgZhH6Osh0zaaf7xAbdX7aFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881201; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=LyvNqr8B9XOZSvfVbX8GBWpCDEyy4RrMQ2ufgi9wdS0=; b=jbnS5IuiyDgMn16O8so7FcnlYUuTKZls5sQOGbQ/QXjgfKJ+y7QBaJHMjyVkiWVnmO4NUq01ZE2UIKArsKjX2XTJ3KgeJextORRiowlCEqw9D6BPpm00nhl4k0m2w8AynT1kAPLzMBhfOnhlSeZrDPbgA9xI7EwzV6JrQ+Rd7F8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881201234970.0265428097067; Tue, 13 Oct 2026 01:46:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY4m-00021e-4o; Tue, 13 Oct 2026 04:41:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY3z-0008UZ-AU for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:47 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3w-00081p-MD for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:46 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4a1688d7769so22524905e9.0 for ; Tue, 13 Oct 2026 01:40:44 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880843; x=1792485643; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=LyvNqr8B9XOZSvfVbX8GBWpCDEyy4RrMQ2ufgi9wdS0=; b=mV+uUH8LcNXhOtYSCvzkYoE4rtPIr3rW3cNlWbMl5slFDIdkUL5JoQ5rKE+IfhjVqQ 1jSeRdb1fEf6u6lJFfFj0L7A9Nv5xuAZGnQ7vTV8zUVK7wDgZCoo+c84By3dO2tyz+ei i4bNONY+ptd+o1cjGESQDf8mW+dBee2BMI0+socf/guRYusprbsaIkcENWorK89Ougqb Mj3fSGv2l5iD7YjBBZ0cZ5ri5r908sZ87TnKZeGUrwaWh/Sr6uXHe1oaXsel+n0fPby3 MrTs3ACt7WGzX1Cd5bFTo45MmOTFYDo4mP/NJxPrSKlOExHaDX55cycsc24NIgJO/k51 2qlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880843; x=1792485643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=LyvNqr8B9XOZSvfVbX8GBWpCDEyy4RrMQ2ufgi9wdS0=; b=qlS3IpyP3FkN8fzemg69r4REwmkRixSO1iLqQzsPt2+y9gztoTSZR98jf5wk+f95dm dWTtxUbzwkwQUN8Uqbz/v3xn6j9A2kIm4O6s7ilf5O6IAUsdhbF8hfOQHSZrCiVAuzaz +uPz72Yk3U5qEvnW5xQNkxkntKnWvDRfIc6hFZgIj5MrvqqODKE0IZWCf87B3GcKQ3d1 b2U1OrwSsaPInvx2oFsk/pZcs7WiL6JPbyjA1Z5emgGjip4zUWqAaTRgOErZuv19aS8v Xx5BIJFKyx/9W1b47SJbWnLH0sq3TlFSfyEpek8wtlKYa97RoByUpoIqadShi3HqqjJG 7dwA== X-Forwarded-Encrypted: i=1; AKwUvBwPRaU6Q77jBouLAtf2doNff2GbghrVchWCoJjlmBNaX9cRtQ5LPFL97IxmLaKvU9RXN6BgmSZIBM5x@nongnu.org X-Gm-Message-State: AFq9FYLxT1GI+Lmdkl8m54fcUAX6geskUhJz2+8CRCKhP6dvMHqFTHyr uNmsM/NSsnT6S2W3Nu1X8nOmuLMGCEQ2MfHCI8beLfWDhmPet4yIHcWnKxWlrJ4WG/s= X-Gm-Gg: AYBFou1H4/Ml4HgFafsokkbQtGFY6/kfGcdqRs0wgLfFURB7hIxOvplFck+mCdO1rmD 9ybC/xljfoqzVQEIzbUcSbLGOL8cLl0OnEc9wqibx/WRL24USJ9+2jcQH/vJ99HlV17o5rSsleN 9L5eArlPT7Fh6osSRXQOaVp+kIKG+RbYfAngf3w7L9hb7j8LHHc+IzG+qNRSMth9kcLQJVTjD35 kom6qI9hO02ETzTGTJjVVVOFChKwrvdbVo+8U4TFfGKsy6RgVmTKNBOuJZt+ehSpxvlqGnK61uK TVusqoOkydmc8SGDHThlEx6gu4U6qJ0DrLz5fobUSZ/swPTGYL7Gev7AzfRWGe6b5PiYfZnmgjR 5PzLdirQ0DpcRTeqHys9MLRRfXVkuihFhAX4z1JzdrsGFz8M8kol5xl+0o2DskK++5rmfkzS5KQ lHtdNZVyciSRXOMuZ6uNSg4XHh/30QIyHAcIPAUqWyuvyJTsrAueCmAOF8B0wvYfsqoI+Sj9N0G orPAex+dJEYp/6uk8gXJNly41REYiLuKOSki9rpapmk/kt5RG1UnTS/SshAMAHrFuB2IiTXpA0x 5hOD X-Received: by 2002:a05:600c:4e41:b0:49f:c1a1:5222 with SMTP id 5b1f17b1804b1-4a18e4d80bdmr223995565e9.33.1791880843064; Tue, 13 Oct 2026 01:40:43 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 50/86] hw/intc/arm_gicv5: Correct offset for IRS_VMT_STATUSR Date: Tue, 13 Oct 2026 09:38:57 +0100 Message-ID: <20261013083933.1024405-51-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881203338158500 Content-Type: text/plain; charset="utf-8" A typo in the definition of IRS_VMT_STATUSR made its offset 0x124 instead of the correct 0x214. This was harmless for our initial EL1-only GICv5, where the register doesn't exist, but needs to be fixed for virtualization support. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- include/hw/intc/arm_gicv5_regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/intc/arm_gicv5_regs.h b/include/hw/intc/arm_gicv5_r= egs.h index 275fee315b5..1d0fb8b147e 100644 --- a/include/hw/intc/arm_gicv5_regs.h +++ b/include/hw/intc/arm_gicv5_regs.h @@ -149,7 +149,7 @@ REG32(IRS_VMT_CFGR, 0x210) FIELD(IRS_VMT_CFGR, VM_ID_BITS, 0, 5) FIELD(IRS_VMT_CFGR, STRUCTURE, 16, 1) =20 -REG32(IRS_VMT_STATUSR, 0x124) +REG32(IRS_VMT_STATUSR, 0x214) FIELD(IRS_VMT_STATUSR, IDLE, 0, 1) =20 REG64(IRS_VPE_SELR, 0x240) --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881258; cv=none; d=zohomail.com; s=zohoarc; b=iCMjsLRCyVg6vnXyO14geqTdIssTEhe1wNRQ+mX4FKYmqtDiMnBsB7dDgRufPQoLbBF0N46iAnMqtV6ASb7/6yWcVjHQRDFDpLX17umbL87tQy0pd7Yl1lc5S3rfAmbMZbfldlw6LC2PKUJX53cA1N1IZsv9gdEIFqsiTDsmjxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881258; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=fxZZyr5tqmX4RAAPXJIUMSNXuOO4bc4vIMg/smsoxD4=; b=JaMNMz5QUhTQNaI8pGdJ8zutzoGVBQk67FTXmUCRhyJEOentlTM+wIqtX5MQmwOgn+0Xnh5Y33M/9T8ycnpx+zgQIbRq+VuFqFB/EGBI7Nakm+hfHjg2Fog1KJ1+ekts1SlZ5iabAWPg3vw+BApGSePWtaV0S5QbshN7AuLVj0Q= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881258751762.2581635402153; Tue, 13 Oct 2026 01:47:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY6O-0004Ld-O8; Tue, 13 Oct 2026 04:43:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY42-00007K-JJ for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:52 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3x-00082G-PO for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:48 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4a1688d7769so22524985e9.0 for ; Tue, 13 Oct 2026 01:40:45 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880844; x=1792485644; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=fxZZyr5tqmX4RAAPXJIUMSNXuOO4bc4vIMg/smsoxD4=; b=TdxZ0gDjRFf0lUI9QzAAm6nmCCZdjR+L9T1QqPNDOh6M+Izlkx92H8w361Q6KmvG51 fx0dnYG9bzDO/SiByauG9MbT8ArMW8BdmlSkRbq97fZVrUoltKdggwe+I8WupBI8VeNC L1iLqLFSX+qJ6YyM6sHz7O5PZfPYv/D/f0G7+ccTHDW+2Z4wCCxP/wQNYpKiq+j9LGwe fo9r3WgW05IhRxQi0g0/EI32jPoTGURLl8LRqJpQ3x7powNYTpK4PY7xyj87xqbSmIcK RtEBF86TD7Q8n2IbHSB00wqDZyX+B579mt5BWgnhMOwbxR1YOfLxHZEM0fw9ujdq2gwR X+ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880844; x=1792485644; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=fxZZyr5tqmX4RAAPXJIUMSNXuOO4bc4vIMg/smsoxD4=; b=qpXqMD/7TyDOkbgz/feotZ3Ik7wqPCTDu5Fp/BfxCKTBUwUcu1mTTc7Pe2xSLNKoEV YEUJt06e6avhbS5snfh4W9Qnz/7MG5+wo6rKZlkbPrbIyaA4ejhJcgTygnh5Tde6jLuc uku8Imu35EXeX81BFuuY+j9mrkb0pI/5POO273HXosiUeVTDYAjjZape61zMSoIK5JgH N2psocKtICVO9FnDkaUF3qQ9YIG1YyJFiLmuKDOloPuNwUo6DI89YXM9hLZEBE+wiQI6 AxoMECgymjD7GIU6gSeL1ZFQSGcbRNrI1wH5/yGFD6rdNcv82O6vkRr3eOdZUypt6FDT nU2Q== X-Forwarded-Encrypted: i=1; AKwUvBxc9078Ij0+0E0m4oejsNbS25Wv/Gb3Y4iJvS126eYvGdPetvfrbV7zCTtDjHBdsAGukhWZ1GO2j6Lq@nongnu.org X-Gm-Message-State: AFq9FYLEyeW/B5TpBTciJl8VvT18w/HhgJ2x+spoM+QQXEn2D8Z2uSQ4 SU7SFaN1MbYuEE7fSeUJfCVtqrIoASy3/fTBY9Tqk1Pz/GwbF/8293gceg4TdCErCaw= X-Gm-Gg: AYBFou0tvesLppovS0jHTKLK/eFAkBv1SyILshEu10RB+PbJLHpGMLhZlPR1/XyvlL2 Lo1O9OYF+X+ebHYErYJZQrG/gPD872cAF8uNrxJKY4WIFjhWlBIEeeAn+PXalj1fVjvrfmRt98O VE2DaaosSjVPrfQtrxDNvlKwY52i4eXtIggPxqO58Yye3Fu0xUhBzJhIrsVu2snjKc56ajoNWxG TqN7kGjaoJSGSioyrxzAW74nO2nyykuI1Ai0AKtSGDgsbzgUz1CxQVD+q/f12Pn6Dz01kTsPrYN eIJBmL8wbhM807kqup3X7sIlbHpFay85OpsAcFGrCeae8CKigWuqaLKf9ITfqTNLLMaX5/6gzKw usWGmslCOiP3EzdiYXgAcPpH6zvZvxiON61JUfSQxmZf3oGCK6TXS1T/NN9+6+Wy9ob8+QoNOGe AAi1IyTuql9yBrMRmsu3sZPWtF78sHUl+3TbiLEXhPtLiFKX7kNMSKrKolqUn2CGwnk5N+A7ze5 e5qNhcq6NsJhmfyl7vr2ktSS+C6XJuuxt4DhZWnwCTdAcM2BtYqpCkXlwgRYV6t1Zml1JnLpdVh 4/pOLOwJk0w90g== X-Received: by 2002:a05:600c:190a:b0:4a1:746e:589a with SMTP id 5b1f17b1804b1-4a18e4aea54mr253139185e9.18.1791880843998; Tue, 13 Oct 2026 01:40:43 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 51/86] hw/intc/arm_gicv5: Ask CPUs whether IRS needs virtualization support Date: Tue, 13 Oct 2026 09:38:58 +0100 Message-ID: <20261013083933.1024405-52-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881260426158500 Content-Type: text/plain; charset="utf-8" The GICv5 IRS must support virtualization if any CPU in the system has EL2 (by spec rule R_KDSPG). Add a has_virt field to the GICv5Common struct to track this, and automatically set it if any connected CPU has EL2. We get the CPU to tell us whether it needs virtualization in the return value of gicv5_set_gicv5state(); this allows us to maintain the arm's-length relationship between the IRS and the CPU (and in particular we don't need to include cpu.h in arm_gicv5_common.c, as we would if we directly called arm_feature() there). We could alternatively have provided a has-virtualization QOM property, but then the board code would need to take care to explicitly configure the IRS to match the CPUs. (The GICv3 doesn't have an equivalent to this, because in the GICv3 design virtualization is handled entirely by the CPU interface and software; in GICv5 the IRS has hardware support, to reduce the work software needs to do.) None of the code we are about to add in future commits that tests the has_virt flag will be accessible until we remove the check in virt.c that prevents creation of a machine with the GICv5 and an EL2 CPU, so no behaviour will change until we have completed the entire virtualization support feature and allow the user to select it. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5_common.c | 9 ++++++++- include/hw/intc/arm_gicv5_common.h | 2 ++ include/hw/intc/arm_gicv5_stream.h | 15 +++++++++++---- target/arm/cpu.c | 17 +++++++++++------ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index cfadfee4f05..17fd67b5ccd 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -176,11 +176,18 @@ static void gicv5_common_realize(DeviceState *dev, Er= ror **errp) } =20 for (int i =3D 0; i < cs->num_cpus; i++) { - if (!gicv5_set_gicv5state(cs->cpus[i], cs, cs->cpu_iaffids[i], i))= { + switch (gicv5_set_gicv5state(cs->cpus[i], cs, cs->cpu_iaffids[i], = i)) { + case GICV5_CPUIF_MISSING: error_setg(errp, "CPU %d (IAFFID 0x%x) does not implement GICv5 CPU = interface", i, cs->cpu_iaffids[i]); return; + case GICV5_CPUIF_PRESENT: + break; + case GICV5_CPUIF_NEEDS_VIRT: + /* R_KDSPG: IRS must implement virtualization if any CPU has E= L2 */ + cs->has_virt =3D true; + break; } } =20 diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index a47f639e84c..d8f6f5d5db9 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -127,6 +127,8 @@ struct GICv5Common { uint32_t spi_base; uint32_t spi_irs_range; uint32_t spi_range; + + bool has_virt; }; =20 struct GICv5CommonClass { diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index f6d32c6beca..ea27d6aec0f 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -16,6 +16,12 @@ =20 typedef struct GICv5Common GICv5Common; =20 +typedef enum GICv5CPUIFStatus { + GICV5_CPUIF_MISSING, /* CPU does not have GICv5 cpuif support */ + GICV5_CPUIF_PRESENT, /* CPU has GICv5 cpuif */ + GICV5_CPUIF_NEEDS_VIRT, /* CPU has GICv5, and needs virt support in IR= S */ +} GICv5CPUIFStatus; + /** * gicv5_set_gicv5state * @cpu: CPU object to tell about its IRS @@ -27,11 +33,12 @@ typedef struct GICv5Common GICv5Common; * IRS must call this when it is realized, for each CPU it is * connected to. * - * Returns true on success, false if the CPU doesn't implement the - * GICv5 CPU interface. + * The return value indicates whether the CPU has a GICv5 CPU + * interface, and if it does whether it needs virtualization support + * from the IRS. */ -bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid, - uint32_t cpuidx); +GICv5CPUIFStatus gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, + uint32_t iaffid, uint32_t cpuidx); =20 /* * The architected Stream Protocol is asynchronous; commands can be diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 4731d1cc7c4..62262d742a2 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1215,20 +1215,25 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *= f, int flags) } =20 #ifndef CONFIG_USER_ONLY -bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid, - uint32_t cpuidx) +GICv5CPUIFStatus gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, + uint32_t iaffid, uint32_t cpuidx) { /* - * Set this CPU's gicv5state pointer to point to the GIC that we are - * connected to, and record our IAFFID and CPU index. + * Set this CPU's gicv5state pointer to point to the GIC that we + * are connected to, record our IAFFID and cpuidx, and let the IRS + * know if it needs to implement virtualization support. */ if (!cpu_isar_feature(aa64_gcie, cpu)) { - return false; + return GICV5_CPUIF_MISSING; } cpu->env.gicv5.gicv5state =3D cs; cpu->env.gicv5.iaffid =3D iaffid; cpu->env.gicv5.cpuidx =3D cpuidx; - return true; + if (arm_feature(&cpu->env, ARM_FEATURE_EL2)) { + return GICV5_CPUIF_NEEDS_VIRT; + } else { + return GICV5_CPUIF_PRESENT; + } } #endif =20 --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881135; cv=none; d=zohomail.com; s=zohoarc; b=TPTniNe6xCBkNLAvYgwESMKQaiU24Wl55xlpDhEECWr3ERsQbr+BDnMu2ozQiR5/ZyqyHkrge5q8BSNQULVt3ih1gZe74z6pZG1l/2DOfKjtpMGDKRtcmMY7EptqluNmf102yWmcu27A2FOWHjqMaeZOmg6Ftr6C/F+CHNi3Oss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881135; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=xKfVzycXN3xlTRcOP3v+QXWexvZM2B043jlT18XjlT4=; b=Czz6IGeiEhWmkX70lhLvhvF43JzJig40SbExfODGofXt5zf4cnhcRuP2Y2dT9veENK0rf6qFqG/bRfri/HlTeQjyU/RWgkAfkhvzoHHefJJsv8R0rGHnbs26c2s944sw1bXeU0kFqsWz4HKWjg3RDI0HmXS4zMHJH5DiYf0e2X4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881135171731.1828060336799; Tue, 13 Oct 2026 01:45:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY6a-0004vX-Fa; Tue, 13 Oct 2026 04:43:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY42-00007I-JQ for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:52 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3y-00082f-PY for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:48 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a17baef589so22018805e9.0 for ; Tue, 13 Oct 2026 01:40:46 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880845; x=1792485645; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=xKfVzycXN3xlTRcOP3v+QXWexvZM2B043jlT18XjlT4=; b=A8eKHNlBeSKcKJt44bta4eckTmUG4HgoJJzFo5NQg37Ck/+GcEbNssxFoNPPUaeJX7 b6XaF2zReHCIb+/gdtDIN4ZyQ57pwspvgB+oDJ2Ml98BaxOdcV20JH82B1p0rgF4rzoI yn6uDYjgQ3ipqBiQQqa7+xtz8vQctDCw8dUxC8mrnfIt/lwo65szewQYbM9SypuGM23A 66Ef2VK1VaC2Jbci33kWnLGvieTA5mm1wZyhM6TeOugFsoi76NPoxb7J1Uh+riwqZMBW isvkMaVvJ5i4JmQyGn+REWePC1MEu9LCP+ikM8wKOVbEsfi3GtdEbj7xhw66gCmwCLEN tuNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880845; x=1792485645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=xKfVzycXN3xlTRcOP3v+QXWexvZM2B043jlT18XjlT4=; b=wYB/mz2HjPqgoTEgZlfsnfZ8bwahyrRyehpzd7vVsiCy3IQD0A6FnhEe3m0TRKZymR pbu8dPpQ/qJcAYZtVfcaYEYpxbByYefvgvXZusDVYp0j//SCmtpyPFEGWRSA32fJDPDP Jdy+VxcNLkfQiUX/K5XdGLn9gdamfa3gCB3XLmFO0xVjOkyX90u7NLoL0Wl3wPKa61Py VUA0AQqWxVQ9tpQdZwyjVPZ4lpprxUOUYDxU0tHJ0vkHOMUkBWl18PS+G55cOsmo5yv4 o+IP9Ht0S70Hn8xehXMHdnExDeaoRhziM7EY8U2w492rvfSVQ3G1HD80RASNc4PnDlK8 HoeA== X-Forwarded-Encrypted: i=1; AKwUvBxWFuOrh6ayWvzr4RTlys66OCPCS94B4hatBosGaLYnc8AlPtqBUUHiCEv8B26kSzGsdH99OpyebEbI@nongnu.org X-Gm-Message-State: AFq9FYJUjRzLA9psmWHUn1NNraEvoK1DLGm8mSx2Hbuk2gYA1QMnOyF8 MDeGtqspk9SZdByQM+MEOQ+Grv17peGB504MOMQt9v9CmHxu7YrkjWY/bztqP2M/6TqIGt0X6Bk kUSZ8tMI= X-Gm-Gg: AYBFou2DLlzcLdrbygU9rAMnI7HgUARgwJ60T6CzJamDgWYpJ7Ci9/p+k3h7dnJVW2O 5w/2AalvzwPAqPDJIDMVNEVNWvQWvhbWfpZ4yBGsxlHx0IOJn8ne67TXKdHQcOW539M4rqokF77 /W5WFmcBN/ZBBe5hm/VGd7Ei89r7rSBzyaSRk9tzTqRvqxskZygSMyg+zPEqUEKGm0LCXIavkhd a7I3IHy3PcpVLwOUAuk9qsioQPDrgSIjYnVZXwCHNKhI7fNR73a5GqGh63/8HthVMLFTZn8XoEQ Po17uS+6YJh2XWZK96Io7zZI3sQ21L7yXeJj244ZPL9Kl6TYBM1gcpG6vSPSX5MVN+rOpqEaMl4 Cmr1CQVTyhOp5znTB4uT8HfC7a27vhh4XEGzBQy2G/wwn3T5sjqoiRUED3z2WWsWQqsUoPuC74H RBi+9LZBAwb1X9D5iqbU6/8yr9NB4nvJh96lon6uoB7IgxKmlmhGCNYIEErcf2iEZx8X860jFKh +Yz6/NeYQR6ZIn/V9o3L4SOejgqkKyNe9kOdH9TkPrH5EgOIhoRqzaJ0q6ZvnwaIi/peABN4hKZ Pws= X-Received: by 2002:a05:600c:4fd5:b0:4a0:5b:7bc0 with SMTP id 5b1f17b1804b1-4a18e49a7e3mr237514455e9.21.1791880845027; Tue, 13 Oct 2026 01:40:45 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 52/86] hw/intc/arm_gicv5: Indicate virtualization in ID registers Date: Tue, 13 Oct 2026 09:38:59 +0100 Message-ID: <20261013083933.1024405-53-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881136184158500 Content-Type: text/plain; charset="utf-8" When has_virt is true, report virtualization support in the IRS ID registers. This includes reporting various specifics of our implementation. We choose to implement the maximum possible sizes for VM and VPE IDs. We don't need to store any implementation state in the IMPDEF guest memory VM descriptor and VPE descriptor structures, so we indicate that we have no VM descriptors and that the VPE descriptor is the smallest size the spec allows. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 40 +++++++++++++++++++++++------- include/hw/intc/arm_gicv5_common.h | 25 +++++++++++++++++++ 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 289a3afaeae..63e4a165eea 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -75,6 +75,16 @@ static uint32_t gicv5_idreg(int regoffset) return gic_ids[regoffset]; } =20 +static bool gicv5_domain_has_virt(GICv5Common *cs, GICv5Domain domain) +{ + /* + * Return true if this domain implements virtualization. + * EL3 never does; if any CPU connected to the IRS has EL2 + * then all other domains must implement virtualization (R_KDSPG) + */ + return cs->has_virt && domain !=3D GICV5_ID_EL3; +} + static GICv5SPIState *spi_for_selr(GICv5Common *cs, GICv5Domain domain) { /* @@ -1208,8 +1218,8 @@ static bool config_readl(GICv5 *s, GICv5Domain domain= , hwaddr offset, /* MEC field RES0 except for the Realm domain */ v &=3D ~R_IRS_IDR0_MEC_MASK; } - if (domain =3D=3D GICV5_ID_EL3) { - /* VIRT is RES0 for EL3 domain */ + if (!gicv5_domain_has_virt(cs, domain)) { + /* VIRT is RES0 for this domain */ v &=3D ~R_IRS_IDR0_VIRT_MASK; /* ...which means VIRT_ONE_N is also RES0 */ v &=3D ~R_IRS_IDR0_VIRT_ONE_N_MASK; @@ -1223,12 +1233,12 @@ static bool config_readl(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D cs->irs_idr2; return true; case A_IRS_IDR3: - /* In EL3 IDR0.VIRT is 0 so this is RES0 */ - *data =3D domain =3D=3D GICV5_ID_EL3 ? 0 : cs->irs_idr3; + /* All fields are RES0 if domain doesn't have virt */ + *data =3D gicv5_domain_has_virt(cs, domain) ? cs->irs_idr3 : 0; return true; case A_IRS_IDR4: - /* In EL3 IDR0.VIRT is 0 so this is RES0 */ - *data =3D domain =3D=3D GICV5_ID_EL3 ? 0 : cs->irs_idr4; + /* All fields are RES0 if domain doesn't have virt */ + *data =3D gicv5_domain_has_virt(cs, domain) ? cs->irs_idr4 : 0; return true; case A_IRS_IDR5: *data =3D cs->irs_idr5; @@ -1636,6 +1646,7 @@ static void gicv5_set_idregs(GICv5Common *cs) * for 56 bits of physical address space. */ v =3D FIELD_DP32(v, IRS_IDR0, PA_RANGE, 7); + v =3D FIELD_DP32(v, IRS_IDR0, VIRT, cs->has_virt); v =3D FIELD_DP32(v, IRS_IDR0, IRSID, cs->irsid); cs->irs_idr0 =3D v; =20 @@ -1655,9 +1666,20 @@ static void gicv5_set_idregs(GICv5Common *cs) /* Our impl does not need IST metadata, so ISTMD and ISTMD_SZ are 0 */ cs->irs_idr2 =3D v; =20 - /* We don't implement virtualization yet, so these are zero */ - cs->irs_idr3 =3D 0; - cs->irs_idr4 =3D 0; + v =3D 0; + if (cs->has_virt) { + /* Our impl doesn't need a VM descriptor, so VMD and VMD_SZ are ze= ro. */ + v =3D FIELD_DP32(v, IRS_IDR3, VM_ID_BITS, QEMU_GICV5_VM_ID_BITS); + v =3D FIELD_DP32(v, IRS_IDR3, VMT_LEVELS, 1); + } + cs->irs_idr3 =3D v; + + v =3D 0; + if (cs->has_virt) { + v =3D FIELD_DP32(v, IRS_IDR4, VPED_SZ, QEMU_GICV5_VPED_SZ); + v =3D FIELD_DP32(v, IRS_IDR4, VPE_ID_BITS, QEMU_GICV5_VPE_ID_BITS = - 1); + } + cs->irs_idr4 =3D v; =20 /* These three have just one field each */ cs->irs_idr5 =3D FIELD_DP32(0, IRS_IDR5, SPI_RANGE, cs->spi_range); diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index d8f6f5d5db9..7b24cad211b 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -153,6 +153,31 @@ struct GICv5CommonClass { #define QEMU_GICV5_IAFFID_BITS 16 /* Number of priority bits supported in the IRS */ #define QEMU_GICV5_PRI_BITS 5 +/* Number of VM ID bits */ +#define QEMU_GICV5_VM_ID_BITS 16 +/* Number of VPE ID bits */ +#define QEMU_GICV5_VPE_ID_BITS 16 + +/* + * The VPE descriptor is IMPDEF in size and contents; it stores + * - the VPE's residency status and location + * - VPE doorbell settings + * - metadata tracking pending interrupts for the VPE + * In a real hardware implementation, the IRS will keep its per-VPE data + * in guest memory with a cache so it isn't actually doing full memory + * accesses all the time. For QEMU we will keep the per-VPE data in + * host-side data structures, which don't have any size limitations. + * The specification doesn't define any situations where the IRS + * must write its state back out to guest memory, except for the + * entirely IMPDEF and optional power-management suspend/resume. + * QEMU's IRS doesn't implement power-management, so we will never + * write out anything to the VPE descriptors in guest memory. + * We therefore define them to the smallest size the spec permits, + * which is 8 bytes. + * (We similarly do not use VM descriptors, but for those the spec + * permits an implementation to tell software it does not use them.) + */ +#define QEMU_GICV5_VPED_SZ 3 =20 /* * There are no TRMs currently published for hardware implementations --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881134; cv=none; d=zohomail.com; s=zohoarc; b=RB8rHmg6zhpU7uqoNqctLF8cScxmWegRNxreW2WYEOgbX0WPdVImliQhFCjExtkqAmXgvaQgVGl85fNNFldIqmeasCAyRZf8vHOGXaOInU/b80EDs/VZlINyyuDEy1T2rXUFMDJnueJ6+PTOhXZc/RBImj6lkMWZ7sD41vDDj0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881134; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=RpxSc5E6JZ85OCnxoQbmovvqMsjQZ6XLtXXpnhtsTUk=; b=iSZYnLPUdZG1dqiwED8sdOgbY1Zyyi43b7HP9jicps3JVPvw09V96yfDsmw7orIOq2PfabpsvfJW47P/SbzEByqjVC3mRS2pZiZ/PryStK//jH4OB8GR6fh1FFe222y9saQPH+5n/gqDUzAvC3GGDb0/4W1jN76XGTTbKAdx+50= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881134301485.81763477735205; Tue, 13 Oct 2026 01:45:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY6G-0003yp-6F; Tue, 13 Oct 2026 04:43:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY42-00007M-KV for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:52 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY3z-000834-Lx for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:50 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-49fbb2acc90so22382585e9.2 for ; Tue, 13 Oct 2026 01:40:47 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880846; x=1792485646; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=RpxSc5E6JZ85OCnxoQbmovvqMsjQZ6XLtXXpnhtsTUk=; b=XDOLGvT1ait4uHOStt0udr0pzwZGGkH5QCs4eIqjvm7Y+XUYNG5Pkhb8AnvoVAKak4 EjkWRFf9qLiPbcXVXC4GaTql+39aKVfhnDaKHRV0I6726YNEaGVDrviqk2bbwl0g1/AF gPgaiVhOUZRLGbyQTOEMdkdj0ZApam8CAxBh8LQeyvrKZzKaKGsvwrAF8piXzy1hPhXa n37BggokmgyGNTRgWy8ZONR9vY3M2dit4QQamkMrSp4zzSGxHC1UZK7ifV9OrkFZoSev XhlMi3CjTttOb/fYYzTikJVQmXZK7nk5h2pY7u/wlw/NHv1tOxNw+pAW01VNeO4IBgu3 jgeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880846; x=1792485646; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=RpxSc5E6JZ85OCnxoQbmovvqMsjQZ6XLtXXpnhtsTUk=; b=xa/j5udoDJdF7OR6L1rO/MpgqFV+Eq1AfPyK/x8gmhbB49xDAp/jlFfP2ZtAS3i3g9 aJOv3qrjMJbBwxQaUIDZyq2jVMV3dj/XSMMbBk9t2MdXezDx5iURL3maOTLQZQe006En Ctx+b+wtFZT5Iy5t5hd1wCqFFzYto3b02SkILNLA3xk006BvvR0gf1JD+pD+bxPQTBsk KENGOurF1SygdhlQCch9ckGEfj6WxaZfzrUg5LMqLSPQlkVeXtXmIrJ8eOILVsx15j/p PZIQpOc2Cw1g6wqALuBKFBPZhIlEj4/3Hqp0o0KR5wiuDoEsFE8pmA6Dfotfe1JfF/S0 pm3w== X-Forwarded-Encrypted: i=1; AKwUvBxBaMnWS642sgysXxZbSlzJQ4h7f3QWqKsuu+SvCKWgvsTjVIldIDr1kyM6ZiIQE0qU3lfikLHOB5bd@nongnu.org X-Gm-Message-State: AFq9FYJ+A//5XSXA83/7tCSL/KtNHRx4ORoq1eVPyH5hIhlug1BV6XPA KYoidHbVV1CoKnalQbKIFBgaXGCvRGqTb9od4qLa4O+sxNDfrMrMW156drW98Ym7rwQ= X-Gm-Gg: AYBFou1ugQu7CqcIrX0xvDMlyFHpnKXJOF1M8+B4NyZ8xFE7W+QfV25jjY+ROG+s+7h hkbwi1uAw2vtkN6gZmWleTJ4wWjKDWaTEJwdCFfY/m7hPJ9/Lqu37el6144Rwh/ahk114cVbLWK raOIS4hRs867w1Q+DDJqdmxZtsVWlmwQgm8nfKIo5BVPl+Ijo0tmrUX726mo/CgpMTdGl7GhBZG YA/m+6wxfO12SbwARaKonoW/0u12O35PhUTxOZi6bPMStWDEYFtSPtJbwiCiSYHsvSOsk6qBuNq q1n/HzoW1SWptcRaLblx+y1nyiD6WvZVUsp4Qmxh3NZqxpcP1TKgADJnylPWRIaLZJXA/reCej3 kNDQJHqRmqiiup06Y9i+qSJSU9isRxIKshB0v9Ft1Ic7ptd6pH8NOChM/P7jEMxxEVoM5IPmtRM V43EGBqIqxMsgxfPX2LOwdUx+Fp+//+ByBoWZnNJZtn0Q4oFkjgEE/2NBxOWZJIY1CjZmZUnyWm D8xCPSMEExV5TYzfgIIP9yTWhir3Lt/ZWLXbLCFry5XwIXOE8OaQKBU+nt2rx3iHSDESFXEYvub Wx4= X-Received: by 2002:a05:600c:3e8d:b0:4a1:7701:f863 with SMTP id 5b1f17b1804b1-4a18e4aeae4mr216049495e9.15.1791880846024; Tue, 13 Oct 2026 01:40:46 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 53/86] hw/intc/arm_gicv5: Implement IRS_VMT_BASER and IRS_VMT_STATUSR Date: Tue, 13 Oct 2026 09:39:00 +0100 Message-ID: <20261013083933.1024405-54-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881136192158500 Content-Type: text/plain; charset="utf-8" Implement the GICv5 IRS_VMT_BASER register, which holds the base address of the VM table. This is very similar to the IRS_IST_BASER register: it is 64 bits wide but can be accessed as two 32 bit pieces, it has a valid bit which the guest sets to make the table valid, and there is an associated IRS_VMT_STATUSR register which has an IDLE bit which the guest can read to find out when the write to VALID has completed. Implement IRS_VMT_BASER and IRS_VMT_STATUSR, using the same pattern we have for IRS_IST_BASER and IRS_IST_STATUSR. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 73 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 4 ++ hw/intc/trace-events | 2 + include/hw/intc/arm_gicv5_common.h | 1 + 4 files changed, 80 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 63e4a165eea..05c6b9c57fc 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1166,6 +1166,36 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domai= n domain, uint64_t value) } } =20 +static void irs_vmt_baser_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + + if (!gicv5_domain_has_virt(cs, domain)) { + return; + } + + if (FIELD_EX64(cs->irs_vmt_baser[domain], IRS_VMT_BASER, VALID)) { + /* If VALID is set, ADDR is RO and we can only update VALID */ + bool valid =3D FIELD_EX64(value, IRS_VMT_BASER, VALID); + + if (valid) { + /* Ignore 1->1 transition */ + return; + } + cs->irs_vmt_baser[domain] =3D FIELD_DP64(cs->irs_vmt_baser[domain], + IRS_VMT_BASER, VALID, valid= ); + trace_gicv5_vmt_invalid(domain_name[domain]); + return; + } + + cs->irs_vmt_baser[domain] =3D value; + + if (FIELD_EX64(cs->irs_vmt_baser[domain], IRS_VMT_BASER, VALID)) { + trace_gicv5_vmt_valid(domain_name[domain], + cs->irs_vmt_baser[domain] & R_IRS_VMT_BASER_= ADDR_MASK); + } +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -1271,6 +1301,31 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, case A_IRS_IST_CFGR: *data =3D cs->irs_ist_cfgr[domain]; return true; + case A_IRS_VMT_BASER: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(cs->irs_vmt_baser[domain], 0, 32); + } else { + *data =3D 0; + } + return true; + case A_IRS_VMT_BASER + 4: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(cs->irs_vmt_baser[domain], 32, 32); + } else { + *data =3D 0; + } + return true; + case A_IRS_VMT_STATUSR: + /* + * QEMU writes to IRS_VMT_BASER and IRS_VMAP_* take effect + * instantaneously, so the guest can never see the IDLE bit as 0. + */ + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D R_IRS_VMT_STATUSR_IDLE_MASK; + } else { + *data =3D 0; + } + return true; case A_IRS_SPI_STATUSR: /* * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect @@ -1373,6 +1428,14 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_MAP_L2_ISTR: irs_map_l2_istr_write(s, domain, data); return true; + case A_IRS_VMT_BASER: + irs_vmt_baser_write(s, domain, + deposit64(cs->irs_vmt_baser[domain], 0, 32, da= ta)); + return true; + case A_IRS_VMT_BASER + 4: + irs_vmt_baser_write(s, domain, + deposit64(cs->irs_vmt_baser[domain], 32, 32, d= ata)); + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; @@ -1457,6 +1520,13 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_IST_BASER: *data =3D cs->irs_ist_baser[domain]; return true; + case A_IRS_VMT_BASER: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D cs->irs_vmt_baser[domain]; + } else { + *data =3D 0; + } + return true; } =20 return false; @@ -1469,6 +1539,9 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_IST_BASER: irs_ist_baser_write(s, domain, data); return true; + case A_IRS_VMT_BASER: + irs_vmt_baser_write(s, domain, data); + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 17fd67b5ccd..89669493b83 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -104,6 +104,10 @@ static void gicv5_common_reset_hold(Object *obj, Reset= Type type) */ cs->irs_spi_selr[i] =3D cs->spi_base + cs->spi_irs_range; } + + if (cs->has_virt) { + memset(cs->irs_vmt_baser, 0, sizeof(cs->irs_vmt_baser)); + } } =20 static void gicv5_common_init(Object *obj) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 6681e32d1b7..3c7619cf3cd 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -246,6 +246,8 @@ gicv5_deactivate(const char *domain, const char *type, = bool virtual, uint32_t id gicv5_spi_state(uint32_t spi_id, bool level, bool pending, bool active) "G= ICv5 IRS SPI ID %u now level %d pending %d active %d" gicv5_irs_recalc_hppi_fail(const char *domain, uint32_t iaffid, const char= *reason) "GICv5 IRS %s IAFFID %u: no HPPI: %s" gicv5_irs_recalc_hppi(const char *domain, uint32_t iaffid, uint32_t id, ui= nt8_t prio) "GICv5 IRS %s IAFFID %u: new HPPI ID 0x%x prio %u" +gicv5_vmt_valid(const char *domain, uint64_t base) "GICv5 IRS %s VM table = now valid: base 0x%" PRIx64 +gicv5_vmt_invalid(const char *domain) "GICv5 IRS %s VM table no longer val= id" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 7b24cad211b..f134602d66e 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -89,6 +89,7 @@ struct GICv5Common { uint32_t irs_cr0[NUM_GICV5_DOMAINS]; uint32_t irs_cr1[NUM_GICV5_DOMAINS]; uint32_t irs_pe_selr[NUM_GICV5_DOMAINS]; + uint64_t irs_vmt_baser[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881189; cv=none; d=zohomail.com; s=zohoarc; b=Nab0hKwvBXqWBtEs5c6+cVxWpXdIBHzJ8pl2En5+WojHUguDy6S8+YIQpn0KsaUoDSjSE6uC0m6ul4GZps0+16X9AS1zPW83P3af1br7qv3KAJH7JsWQLn4jOqnwrFZBU0TjLUZ5+LOfulqSroEQOjFd+3Gp8fj+8pt8bf4U4D8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881189; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Vd0C4AnNkGrpnHjUGTSfRZsJ+SQNaIbir0ZKTaPfGI0=; b=g5q6xPKb+HMDRDN69NPu2oSrLMV5H6PY9MuMfLdRXheZwnrRpzpEkf4SMXWA9OVj544J1I+Mf6bTazFcqLcaHv5NUcF+VNw/U6HqtWMvBV1MjH2eGfSkcXzDTVZxhZroeFIAxmpsor5nnB3NQsGm6D7HEK9kSMtfmFf1MX72qFk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881189419515.1177857558193; Tue, 13 Oct 2026 01:46:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY6P-0004NO-9H; Tue, 13 Oct 2026 04:43:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY44-0000EV-Rg for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:53 -0400 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 1xGY42-00083x-Bi for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:52 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-487049569b6so1851836f8f.1 for ; Tue, 13 Oct 2026 01:40:48 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880847; x=1792485647; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Vd0C4AnNkGrpnHjUGTSfRZsJ+SQNaIbir0ZKTaPfGI0=; b=w9JQ3lW/uF27R9wlEng8OoK9RODkxHUOIs5blINqINCNTc1x6n38AxEb0ep6koEXyH kle8S3O3zVqgbBzjRvVs1zK59lg8R8UtcQi3ibF1hMTfiZM6W4lA6w8/OzihgFKmvDlk m41CS9dDtNd8yuyDo/WfbFGBTAyZBfdBS4+fua5zTnH0tD3A16858MV3cWmgllu5dBBh v5qTKawRdols2xsEr1C1oW021/V9kRBr4QUc46PMyAX3Qz0JFuWe+nyefwNHyYdBD0yY mbsrgZc4Xw5kB0ObJegVlvxC0yB5+2P72YinD2HK7C9x4XUrfGZazGUrFIcNzj8T2UWY MnuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880847; x=1792485647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Vd0C4AnNkGrpnHjUGTSfRZsJ+SQNaIbir0ZKTaPfGI0=; b=zZTeEMgrjwr4JTYlxATwk5mlHfzD1R7InB94RUQDlqEUPJVQrRRrWTo6uXrSionqoT PNu7br1lfrVcQ824QNwzZ7pRWWZKLoIeH8ikYll5bWKZOHhIxMloItNU9ubEFR7av4B4 S6UKeTiXyf0cRE3tu/DUh7b7Ua1zN7Jb1eFFM1UPP9LNrlYLvC8hz6Iqi0KBw98ziT+c pmtPW2uN548xsak/ZAbGJeoYXjDGjuLfTFbiidNWADjIXcsjBnj3JBI6Eu2cadbTyAF5 8Nl8m1PkOvrIyH3lNzOPZwAh63DuzafdoDGjh4YUkaP8CEAZLYzmoLQ3ss2BSW7eUs1E S6cw== X-Forwarded-Encrypted: i=1; AKwUvBzEDXmqzuYIxXA63PSMmSatSjFbDJesGiCo5kWaLCm/yaAWoLn8JJ82sKb8oA8qwS6c8hA4PYSuX7FC@nongnu.org X-Gm-Message-State: AFq9FYIIQGlng5mxnA4qzumJL19XlDgjVCdCXHOp60ML38sXbf5tnXYf LcO2QOpILaP02SWRYoUdP/OzyKJKh+cwDDJMmCyMn9GTVnYGJwEn2eWhpr2XTKTD9wsAYr0gKCL eSLDBu+0= X-Gm-Gg: AYBFou2FaeE0fWxtHE9lm014ZnYeXgb9s5HgH7nTC9sdgFOpRudyE2V4gWgK0cFCxA7 YIstLZzumHrTfVv04taWSPogFmB15iNBtcZpbbHC/1fwTAC/3+Y3TAwaVLS1oseKGVpehkK79RF Zu/Gth7s6bg/jFKtixOr7mPVNNiMspcYBttsXiQC/Pc/vRF5ymc3CrgJ61Y8/SQ8QgGmz4F+ey4 fM3k9Z+cDM/UnO/6FJcLyJFquPmnjkASYx7TDEsbDb3LG/8OCFNwhqjp7Dfhkf6Jn9HW1LwEbjy 37ZcYP5d54/cO17DDlE8oNu8PjyCVFV4v4rGHb4d6tV3lmTmSn3sJEWJ1NzykwbJY8/RE8MO4NR MNoqjpeKHcsNLtOn+c79+izAEVUGf9ymv7dVPozZBS7mxiKVqzirFTJb9eVJUhi78EiCRS8QZeW /Ht/zgg37zU5JAh1QJkIaseH/vJ6krPThrwi7E6YP4PVYNtIk+ELjHA3vQlNV1bqDXx7j22rC06 YWiduOVA9KTNplQXEBtrFqYelJ8BFP652l1eS5UEAYorfk1toKavSu3VpeRVn78qKwUHfDgycSB 4LM= X-Received: by 2002:a05:600c:3e16:b0:4a1:992f:d0e7 with SMTP id 5b1f17b1804b1-4a1992fd259mr147432325e9.16.1791880847301; Tue, 13 Oct 2026 01:40:47 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 54/86] hw/intc/arm_gicv5: IMplement IRS_VMT_CFGR Date: Tue, 13 Oct 2026 09:39:01 +0100 Message-ID: <20261013083933.1024405-55-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881191288158500 Content-Type: text/plain; charset="utf-8" The ISR_VMT_CFGR register is similar to the IRS_IST_CFGR register: the guest writes to it to specify some details of the VM table before writing to ISR_VMT_BASER. Implement this register, including capturing the config info in it and the ISR_VMT_BASER register into a GICv5VMTConfig struct when the VM table becomes valid (following the same pattern we have for IRS_IST_BASER and IRS_IST_CFGR). Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 83 ++++++++++++++++++++++++++++-- hw/intc/arm_gicv5_common.c | 1 + hw/intc/trace-events | 2 +- include/hw/intc/arm_gicv5.h | 10 ++++ include/hw/intc/arm_gicv5_common.h | 1 + 5 files changed, 93 insertions(+), 4 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 05c6b9c57fc..e12b73dcefe 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1174,7 +1174,7 @@ static void irs_vmt_baser_write(GICv5 *s, GICv5Domain= domain, uint64_t value) return; } =20 - if (FIELD_EX64(cs->irs_vmt_baser[domain], IRS_VMT_BASER, VALID)) { + if (s->vmt_config[domain].valid) { /* If VALID is set, ADDR is RO and we can only update VALID */ bool valid =3D FIELD_EX64(value, IRS_VMT_BASER, VALID); =20 @@ -1184,6 +1184,7 @@ static void irs_vmt_baser_write(GICv5 *s, GICv5Domain= domain, uint64_t value) } cs->irs_vmt_baser[domain] =3D FIELD_DP64(cs->irs_vmt_baser[domain], IRS_VMT_BASER, VALID, valid= ); + s->vmt_config[domain].valid =3D false; trace_gicv5_vmt_invalid(domain_name[domain]); return; } @@ -1191,8 +1192,60 @@ static void irs_vmt_baser_write(GICv5 *s, GICv5Domai= n domain, uint64_t value) cs->irs_vmt_baser[domain] =3D value; =20 if (FIELD_EX64(cs->irs_vmt_baser[domain], IRS_VMT_BASER, VALID)) { - trace_gicv5_vmt_valid(domain_name[domain], - cs->irs_vmt_baser[domain] & R_IRS_VMT_BASER_= ADDR_MASK); + /* + * If the guest just set VALID then capture data into config + * struct and sanitize. + */ + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + uint8_t vm_id_bits =3D FIELD_EX64(cs->irs_vmt_cfgr[domain], + IRS_VMT_CFGR, VM_ID_BITS); + int tableszbits; + + vm_id_bits =3D MIN(vm_id_bits, QEMU_GICV5_VM_ID_BITS); + + cfg->structure =3D FIELD_EX64(cs->irs_vmt_cfgr[domain], + IRS_VMT_CFGR, STRUCTURE); + cfg->vm_id_bits =3D vm_id_bits; + /* + * L2 VMTEs are always 32 bytes, and the L2 VM table is always 4KB, + * so 7 bits in a VM ID index the L2 table. As the L2 VMTE size + * and l2 index bits are constant, we don't need to precalculate + * them the way we do for GICv5ISTConfig. + */ + cfg->base =3D cs->irs_vmt_baser[domain] & R_IRS_VMT_BASER_ADDR_MAS= K; + cfg->txattrs =3D irs_txattrs(cs, domain); + + /* + * Enforce aligment of VM table, ignoring bits [N:0] of the addres= s. + * When STRUCTURE =3D 0, N =3D VM_ID_BITS + 4 + * When STRUCTURE =3D 1, N =3D VM_ID_BITS - 5 + * For us, tableszbits =3D N + 1. + */ + if (cfg->structure) { + /* + * L1 table indexed by (vm_id_bits - 7) bits, and each entry + * is 2^3 =3D=3D 8 bytes. + */ + tableszbits =3D vm_id_bits - 4; + } else { + /* table has 2^vm_id_bits entries of 2^5 =3D=3D 32 bytes each = */ + tableszbits =3D vm_id_bits + 5; + } + /* + * tableszbits is <=3D 0 for the silly but valid config where + * STRUCTURE =3D 1 but VM_ID_BITS is so small that there is only + * one L1 table entry pointing to a single L2 table with all + * the VMTEs in it. In this case the R_IRS_VMT_BASER_ADDR_MASK + * already aligned cfg->base sufficiently. + */ + if (tableszbits > 0) { + cfg->base &=3D ~MAKE_64BIT_MASK(0, tableszbits); + } + + cfg->valid =3D true; + + trace_gicv5_vmt_valid(domain_name[domain], cfg->base, + cfg->vm_id_bits, cfg->structure); } } =20 @@ -1326,6 +1379,13 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMT_CFGR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D cs->irs_vmt_cfgr[domain]; + } else { + *data =3D 0; + } + return true; case A_IRS_SPI_STATUSR: /* * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect @@ -1436,6 +1496,18 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, irs_vmt_baser_write(s, domain, deposit64(cs->irs_vmt_baser[domain], 32, 32, d= ata)); return true; + case A_IRS_VMT_CFGR: + if (gicv5_domain_has_virt(cs, domain)) { + if (s->vmt_config[domain].valid) { + qemu_log_mask(LOG_GUEST_ERROR, + "guest tried to write IRS_VMT_CFGR for %s " + "config frame while IRS_VMT_BASER.VALID set\= n", + domain_name[domain]); + } else { + cs->irs_vmt_cfgr[domain] =3D data; + } + } + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; @@ -1702,6 +1774,11 @@ static void gicv5_reset_hold(Object *obj, ResetType = type) g_hash_table_remove_all(s->phys_lpi_config[i].lpi_cache); } } + + /* IRS_VMT_BASER and IRS_VMT_CFGR reset to 0, clear cached info */ + for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { + s->vmt_config[i].valid =3D false; + } } =20 static void gicv5_set_idregs(GICv5Common *cs) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 89669493b83..6a9d727bb65 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -107,6 +107,7 @@ static void gicv5_common_reset_hold(Object *obj, ResetT= ype type) =20 if (cs->has_virt) { memset(cs->irs_vmt_baser, 0, sizeof(cs->irs_vmt_baser)); + memset(cs->irs_vmt_cfgr, 0, sizeof(cs->irs_vmt_cfgr)); } } =20 diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 3c7619cf3cd..30e2fc42471 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -246,7 +246,7 @@ gicv5_deactivate(const char *domain, const char *type, = bool virtual, uint32_t id gicv5_spi_state(uint32_t spi_id, bool level, bool pending, bool active) "G= ICv5 IRS SPI ID %u now level %d pending %d active %d" gicv5_irs_recalc_hppi_fail(const char *domain, uint32_t iaffid, const char= *reason) "GICv5 IRS %s IAFFID %u: no HPPI: %s" gicv5_irs_recalc_hppi(const char *domain, uint32_t iaffid, uint32_t id, ui= nt8_t prio) "GICv5 IRS %s IAFFID %u: new HPPI ID 0x%x prio %u" -gicv5_vmt_valid(const char *domain, uint64_t base) "GICv5 IRS %s VM table = now valid: base 0x%" PRIx64 +gicv5_vmt_valid(const char *domain, uint64_t base, uint8_t vm_id_bits, boo= l structure) "GICv5 IRS %s VM table now valid: base 0x%" PRIx64 " vm_id_bit= s %u 2-level %d" gicv5_vmt_invalid(const char *domain) "GICv5 IRS %s VM table no longer val= id" =20 # arm_gicv5_common.c diff --git a/include/hw/intc/arm_gicv5.h b/include/hw/intc/arm_gicv5.h index d763a7939c7..785c7112fd9 100644 --- a/include/hw/intc/arm_gicv5.h +++ b/include/hw/intc/arm_gicv5.h @@ -30,6 +30,14 @@ typedef struct GICv5ISTConfig { GHashTable *lpi_cache; } GICv5ISTConfig; =20 +typedef struct GICv5VMTConfig { + hwaddr base; /* Base address */ + MemTxAttrs txattrs; /* TX attrs to use for this table */ + uint8_t vm_id_bits; /* number of VM ID bits for the domain */ + bool structure; /* true if using 2-level table */ + bool valid; /* true if this table is valid and usable */ +} GICv5VMTConfig; + /* * This class is for TCG-specific state for the GICv5. */ @@ -38,6 +46,8 @@ struct GICv5 { =20 /* This is the info from IRS_IST_BASER and IRS_IST_CFGR */ GICv5ISTConfig phys_lpi_config[NUM_GICV5_DOMAINS]; + /* This is the info from IRS_VMT_BASER and IRS_VMT_CFGR */ + GICv5VMTConfig vmt_config[NUM_GICV5_DOMAINS]; =20 /* We cache the HPPI for each CPU for each domain here */ GICv5PendingIrq *hppi[NUM_GICV5_DOMAINS]; diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index f134602d66e..fb88c39e8b4 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -90,6 +90,7 @@ struct GICv5Common { uint32_t irs_cr1[NUM_GICV5_DOMAINS]; uint32_t irs_pe_selr[NUM_GICV5_DOMAINS]; uint64_t irs_vmt_baser[NUM_GICV5_DOMAINS]; + uint32_t irs_vmt_cfgr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881012; cv=none; d=zohomail.com; s=zohoarc; b=SPozK8Nh4q/hVzMj6TRHhpq1lDAQorqMSs0MZHsHsNAzVFTznv9DFgSYMP8+ygrDozoCaaoZcTi6RDrv1CAgGCk7u/7TZ+eQ2v49yyTcyPE87VfPwnMqnIaeXESUlb92oL2gN7UuWooaZBGzHLUkAb3IcDcgRCnYHner6Od6G4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881012; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=NCZsMS7sqb9Y3VaE0qbPpa4SMwY97DnFRVA8VMcGapM=; b=fa3ltSuBxUDgyqidm1j01CaEiliUIFeOChqxgrgx5kAdZLSS3qi15nH+UYBjzIzkQHeUV/1sdP/9w0EQ3JZ14+c5y7w0MI+RiLVSyZgm341SC3RfmvYTTvUUXswBNMu5VoG93G7lHZb8bIF4Lc6HTYVPeBVV8s558f5WSurUay4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881012705980.6186055268502; Tue, 13 Oct 2026 01:43:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY65-0003GO-Nc; Tue, 13 Oct 2026 04:42:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY46-0000Hc-HT for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:57 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY42-00084P-Cq for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:54 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-48c411d6615so1898024f8f.3 for ; Tue, 13 Oct 2026 01:40:49 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880849; x=1792485649; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=NCZsMS7sqb9Y3VaE0qbPpa4SMwY97DnFRVA8VMcGapM=; b=SCdh7EQLbpai6/47uTSd+7jtTc1DsCEOpnfNBBn88v47SNHF72N+XFjzICv96vBm4n 3s6qDQNNTH3UFepPuLN4ThRC+MDnxf9D+zbNRVTGyhQdoVla3sJg42uaCJukH3Mn+4Sg xOkZARmegfrD8eFVyKW14SfZceW5EcNlBM83IeX4F01zTnxsd3Ty0zk73SLfEbXdcpUh 9ViXkH1Isvpt1ADzsqE/oQSJDhzamvXuwr2kagcwmZwIMRomzw6dzVjhGpslaqwrrrrm x0S61nQAptxC5OTXH73MZ6ZIafc4F8Plnqk6DHAWnFkSens+XKh3Sssvu/CuRdS6ccUh xqTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880849; x=1792485649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=NCZsMS7sqb9Y3VaE0qbPpa4SMwY97DnFRVA8VMcGapM=; b=CTtm4ohXM6DVsCTgzO4LEg5sEE7jMlpOS8kxtBk9l/dY/M7MoUlfq2rSBTHDjaxUfL ijf0AEuZZZbtmcbSQCZtsAHHwEV6Fd7k4EqFkCPPtr4Lz1pVenfTP4qJM/ASuVuxSUAg 8GxizV+oBkxqk00czug0FadfvAsow62dWcxTrSGJyKN/P/F1obdPgZO+i/JbpMwD5ga1 NtPlumpqmHSR6WQpBdCmYByvSC8S6+BP7kwJ0GroBJGcY2D4v8M0Xd/XvMnvS0H4uamt tKNjQhF+gs6UWPqbooC9XiBmrUa9iJXGnJfExdtlyg80Dj8X2316sNlQCEHixQvcxAOB vg5Q== X-Forwarded-Encrypted: i=1; AKwUvBy0p2DDDMCb3r5cQHUKQQ5knJd2tS5G625XlbtdZXDjan0/fbs+0V47mCUxfuvCOt6CQzSkIvwwQZK0@nongnu.org X-Gm-Message-State: AFq9FYJmN4xVpCpHuK+rTJ5nNqwfiPYVhjF73/RtReSpVHpVVjdkfXNy 6S9qolIoGcep9A3X0VNiz4dW1lbszxXGcejJ0GPfhTcuAqICP5v+8GtouIXotp70g29ApcGnIhP YWxoen8o= X-Gm-Gg: AYBFou3LgGDPus2/cjjYIwiLTMlPzLXX8lGRRhmL9idHfs058SINjMAbpL8E4vxq6tX hJx9ZgOtltRBOJxST9teUNt/yzrPz+HqN4kkDUw25+3A/EImzXZB9Qy5a9YrAXYrhN+Tjkwbrx5 rUPbYtQLbbK3wwmZxbpV2uS6z9gWrn4vIBOmn+t8nxpkq/3xyYbf+kejCGNxDais5oAx/dFZXkV qpTfdbYoa1jPOToPigd96G80trzvFNMEL/S/BENPi8X8sw+mgnd8UFdz2O+LpANij1XLMe/shNE /sG3NnYP143YUq9LUK8MQ1HWecKoDttQA8Ug3ofTVS5yXs18afnAlobVnV3doLIaKQENSI/1tn7 SAKOP1l72eUtyOjTrIslgGPgWZFBJ8k/yDaP4oCjB4+6OVPf5B/ChDI67XF046ybSPUWJ6/I2sO AbDv1KYWBgWKxSvVwYWk0zTxlHEvhdGZdnUWB1AvhtqIYHcrwwsB1jVHApmLbHEdpEstDNBblHw AQrqbzsWT37fkR11ns03T67UTpb43MXlv0PEgbp3noLbE5ZKaDPpICDqILERaMzsfroj6A8T8wK Jas= X-Received: by 2002:a05:600c:e557:20b0:49f:dd9f:6038 with SMTP id 5b1f17b1804b1-4a18e4bff94mr148687545e9.25.1791880848728; Tue, 13 Oct 2026 01:40:48 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 55/86] hw/intc/arm_gicv5: Implement IRS_VMAP_L2_VMTR Date: Tue, 13 Oct 2026 09:39:02 +0100 Message-ID: <20261013083933.1024405-56-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881013876158500 Content-Type: text/plain; charset="utf-8" The IRS_VMAP_L2_VMTR register allows the guest to make a level 2 VM table valid. It's similar to what the IRS_MAP_L2_ISTR register does for the IST, but it's 64 bits, and so it is R/W and has an M bit for "actually do the operation" so that the guest can write it as two 32 bit halves. Since we don't cache anything yet, all the "make valid" operation needs to do is write to the VALID bit in the L1 table entry in guest memory. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 110 ++++++++++++++++++++++++++++- hw/intc/arm_gicv5_common.c | 1 + include/hw/intc/arm_gicv5_common.h | 1 + include/hw/intc/arm_gicv5_regs.h | 9 +++ 4 files changed, 120 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index e12b73dcefe..a81f7803ca5 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -49,7 +49,6 @@ static const char *inttype_name(GICv5IntType t) return names[t]; } =20 - #define IRS_DEVARCH_VALUE ((0x23b << 31) | (0x1 << 20) | 0x5a19) =20 static uint32_t gicv5_idreg(int regoffset) @@ -489,6 +488,19 @@ static void put_l2_iste(GICv5Common *cs, const GICv5IS= TConfig *cfg, write_l2_iste_mem(cs, cfg, h->l2_iste_addr, h->l2_iste); } =20 +static hwaddr l1_vmte_addr(GICv5Common *cs, const GICv5VMTConfig *cfg, + uint32_t vmid) +{ + /* + * In a 2-level VMT configuration, return the address of the L1 + * VMT entry for this VM ID. The bottom VMT_L2_IDX_BITS of the + * ID value are the index into the L2 table, and the higher bits + * of the ID index the L1 table. The L1 table entries are 8 bytes. + */ + uint32_t l1_index =3D vmid >> VMT_L2_IDX_BITS; + return cfg->base + (l1_index * 8); +} + void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, GICv5Domain domain, GICv5IntType type, bool virtua= l) { @@ -1249,6 +1261,62 @@ static void irs_vmt_baser_write(GICv5 *s, GICv5Domai= n domain, uint64_t value) } } =20 +static void irs_vmap_l2_vmtr_write(GICv5 *s, GICv5Domain domain, uint64_t = value) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + uint32_t vmid =3D FIELD_EX64(value, IRS_VMAP_L2_VMTR, VM_ID); + bool m =3D FIELD_EX64(value, IRS_VMAP_L2_VMTR, M); + hwaddr l1_addr; + uint64_t l1_vmte; + MemTxResult res; + + if (!gicv5_domain_has_virt(cs, domain) || !cfg->valid || !cfg->structu= re) { + /* + * The whole register is RAZ/WI if no virt, or if the VM + * table is invalid or not 2 level. + */ + return; + } + + /* + * Otherwise, write to the register. The M bit is WO/UNKNOWN, + * and we make sure it is 0, so that a 32-bit write to the low + * half of the register never appears to have the M bit set. + */ + cs->irs_vmap_l2_vmtr[domain] =3D value & ~R_IRS_VMAP_L2_VMTR_M_MASK; + + if (!m || vmid >=3D (1 << cfg->vm_id_bits)) { + /* + * If guest didn't actually ask to make the L2 table valid, or + * the ID is out of range, do nothing except the register update. + */ + return; + } + + /* Find the relevant L1 VMTE and set its VALID bit */ + l1_addr =3D l1_vmte_addr(cs, cfg, vmid); + + l1_vmte =3D address_space_ldq_le(&cs->dma_as, l1_addr, cfg->txattrs, &= res); + if (res !=3D MEMTX_OK) { + goto txfail; + } + + l1_vmte =3D FIELD_DP64(l1_vmte, L1_VMTE, VALID, 1); + + address_space_stq_le(&cs->dma_as, l1_addr, l1_vmte, cfg->txattrs, &res= ); + if (res !=3D MEMTX_OK) { + goto txfail; + } + + return; + +txfail: + /* Reportable with EC=3D0x0 if sw error reporting implemented */ + qemu_log_mask(LOG_GUEST_ERROR, "L1 VMTE update failed for VMID 0x%x at= " + "physical address 0x" HWADDR_FMT_plx "\n", vmid, l1_addr= ); +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -1386,6 +1454,24 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_L2_VMTR: + if (gicv5_domain_has_virt(cs, domain) && + s->vmt_config[domain].valid && s->vmt_config[domain].structure= ) { + *data =3D extract64(cs->irs_vmap_l2_vmtr[domain], 0, 32); + } else { + /* RAZ/WI if no virt or no VM table or VM table not 2 level */ + *data =3D 0; + } + return true; + case A_IRS_VMAP_L2_VMTR + 4: + if (gicv5_domain_has_virt(cs, domain) && + s->vmt_config[domain].valid && s->vmt_config[domain].structure= ) { + *data =3D extract64(cs->irs_vmap_l2_vmtr[domain], 32, 32); + } else { + /* RAZ/WI if no virt or no VM table or VM table not 2 level */ + *data =3D 0; + } + return true; case A_IRS_SPI_STATUSR: /* * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect @@ -1508,6 +1594,16 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, } } return true; + case A_IRS_VMAP_L2_VMTR: + irs_vmap_l2_vmtr_write(s, domain, + deposit64(cs->irs_vmap_l2_vmtr[domain], + 0, 32, data)); + return true; + case A_IRS_VMAP_L2_VMTR + 4: + irs_vmap_l2_vmtr_write(s, domain, + deposit64(cs->irs_vmap_l2_vmtr[domain], + 32, 32, data)); + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; @@ -1599,6 +1695,15 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_L2_VMTR: + if (gicv5_domain_has_virt(cs, domain) && + s->vmt_config[domain].valid && s->vmt_config[domain].structure= ) { + *data =3D cs->irs_vmap_l2_vmtr[domain]; + } else { + /* RAZ/WI if no virt or no VM table or not 2-level */ + *data =3D 0; + } + return true; } =20 return false; @@ -1614,6 +1719,9 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_VMT_BASER: irs_vmt_baser_write(s, domain, data); return true; + case A_IRS_VMAP_L2_VMTR: + irs_vmap_l2_vmtr_write(s, domain, data); + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 6a9d727bb65..945257fef2c 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -108,6 +108,7 @@ static void gicv5_common_reset_hold(Object *obj, ResetT= ype type) if (cs->has_virt) { memset(cs->irs_vmt_baser, 0, sizeof(cs->irs_vmt_baser)); memset(cs->irs_vmt_cfgr, 0, sizeof(cs->irs_vmt_cfgr)); + memset(cs->irs_vmap_l2_vmtr, 0, sizeof(cs->irs_vmap_l2_vmtr)); } } =20 diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index fb88c39e8b4..19700c7d5e3 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -91,6 +91,7 @@ struct GICv5Common { uint32_t irs_pe_selr[NUM_GICV5_DOMAINS]; uint64_t irs_vmt_baser[NUM_GICV5_DOMAINS]; uint32_t irs_vmt_cfgr[NUM_GICV5_DOMAINS]; + uint64_t irs_vmap_l2_vmtr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array diff --git a/include/hw/intc/arm_gicv5_regs.h b/include/hw/intc/arm_gicv5_r= egs.h index 1d0fb8b147e..d675a10c37f 100644 --- a/include/hw/intc/arm_gicv5_regs.h +++ b/include/hw/intc/arm_gicv5_regs.h @@ -270,6 +270,15 @@ FIELD(L2_ISTE, HWU, 9, 2) FIELD(L2_ISTE, PRIORITY, 11, 5) FIELD(L2_ISTE, IAFFID, 16, 16) =20 +FIELD(L1_VMTE, VALID, 0, 1) +FIELD(L1_VMTE, L2_ADDR, 12, 44) + +/* + * L2 VMTEs are always 32 bytes, and the L2 table is always 4KB, + * so the lower 7 bits in a VM ID index the L2 table. + */ +#define VMT_L2_IDX_BITS 7 + /* * Format used for gicv5_request_config() return value, which matches * the ICC_ICSR_EL1 bit layout. --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881427; cv=none; d=zohomail.com; s=zohoarc; b=E/SneFPLjre9zjwYkbbkw6DbyU1z95ZJlnX0//1S888xZtoRZV4yxJE79dGXmqAXgog1n6fr7f6cAfH9H/qCu9DsuoX+owGAMDBhUWrXWKZ/DHdsqO18HUfupz+0PlrJ7CZ+rGSc3W6HvUBQvp3klGDcUfNpDsR7CKJZT4JgoFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881427; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Sw6qKX4jnZDlIg+Q6bC4x/Bq9Cid04bGlCnmLqCpsaM=; b=m3G16Ow55Gcll8sNC0mCrtAVu42PO5ycy28X6VgT/hPzg/C6xomFYUg5ipeh8lpAIIuav6+N1Y734utMIzJW11lTLPiiAw0Aef6sSqIh0gGnWHkNL3tn/yrKT3zceTQG5CNA//s6RCKhZDY9DTyNigYl11Q68MFxUUIvZ+fv/bc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881426734738.2845165351357; Tue, 13 Oct 2026 01:50:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY5j-0002w6-At; Tue, 13 Oct 2026 04:42:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY46-0000In-S3 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:57 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY44-00084r-0N for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:54 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-486e70f2457so1159814f8f.2 for ; Tue, 13 Oct 2026 01:40:51 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880850; x=1792485650; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Sw6qKX4jnZDlIg+Q6bC4x/Bq9Cid04bGlCnmLqCpsaM=; b=WDfkel6Oj462W8rk/BzrAK5FKtOxOLWYIP1JfZkiWzCFCDH6iQauxHPa0iKnOeFp5D U88x8ZMVLjMlzGW8xPnUUP377i2v7gdX3QV1abRZiPEBE90wVSV8Smt3CahFiWXo2cXW eUk3qtzVIRz2BiQiBeyCujlGko49xgvOgPHrI0aLrRt1JsjGVNoJMmhEx815LIbamtsZ R3VWDFA02RjeEm8yoF6Y0ZrviZcWNV/HSgX81UCmofoTkqJagKH43JEWubeSXzq37MQv eVAoTshljLmp67J7FsY6+eHgS5K9joMrW5IEGr1uXSHtFnDAMr6cS4Ma8V79c1LccrH/ Q8Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880850; x=1792485650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Sw6qKX4jnZDlIg+Q6bC4x/Bq9Cid04bGlCnmLqCpsaM=; b=NPyNp5BavPuwFjeQYo0rDUKi12+8wRY/LVXE1KPLCXureSszJHBCCDCrS1tXV04FTw 2OgsQG7urELWlZITgA/cx622UOCOXikNvD6PGbK56yP4z/Swm3+dPKM6gV8b/ei1pFIB rp5ucrvYtYzvkKQTMhMxH/5OJyeCVdrnUtDbqKUSTTwyRMuRyMGPF4hGpH19f/7ysUNE KrPimG+rnbKHdGuy9faU+6xdc3gZ5NkCyxhwXzLKescAS7tx1pSvkVAAiYfffgC9hNqR lTxrpCC546+qyHYJNusIK7aryQpRiV8wCX9ItRErcBDN4F0vNJiEsXUzgGOhuPrkeI2u Jjcg== X-Forwarded-Encrypted: i=1; AKwUvBxyOBDlYUGEerQijzBg6g1QO3oyZocDZM3vlYUY0oNUlV2AfaxCiYiYI3IdjeJs9MkM9ENhb5ORSM5c@nongnu.org X-Gm-Message-State: AFq9FYK80Fpn5OcDU9vAsDuenykYLAeEn+IwO4ETgg0dqVyAFrlDFjK+ 6tq1QmuhXCn0DGErreRoDEZsph24J+VcE4cLw6uUNQSrP2lCpBE5FMzh+8CyHjLlHvA= X-Gm-Gg: AYBFou3wmP4rei/oJVUiBio6X3QpYzJkzVVFnVIfrTmIT3+y25RaKONuReJu2JfpPDe 7/8Wy5RQPdnY8XOV1uDy1Owg0/FwT2LnC3B7XWhsJzLpQ2GYAW1o7O0lHE5yOfC9k8E/6/p/eHd KdJZ91x1rY/oHBRTZKllA4Yj1HhvYyGQWx3kcqwoG1SG6jIOgbVGgQ0YHm+wEC1yQS3p5bveAoo mvso1S7KjEaaepiGg+HRHkbUKgpvthj2yn3n6GVAIQ2O2AokwtwXnvLepewgRoTZHv06mcgihn8 X/XtWAAQv4C+9+a59N95Y3z4kPhvf6jOgnNiXiJbwnKHmojGSRGnOXMKpgswNxz58hJAz2n5IHU M2pmcgKg87haLeBod5py2NX5TfFWzB8CcFRFS9P10VmrEtG9IPHKm3BVCUvLKAxZcT4MQ9wOOk4 etPGSf6GOSqiFYKhJ3bUdrWJ3hOEx/x44tgX3k8OfDd8ETjzJpFviXVEM+dadNRGCNVCZH+4lFr ze2x0Xn5QB/k4nIz8kJrmglttU167MQjlCdMWjVVA3aetV5lzedTdnwwcZjj4Vokx2ZShJQgAQC WI0= X-Received: by 2002:a05:600c:871b:b0:4a1:a2f3:e6f7 with SMTP id 5b1f17b1804b1-4a1a2f3e8a9mr85732845e9.29.1791880849735; Tue, 13 Oct 2026 01:40:49 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 56/86] hw/intc/arm_gicv5: Implement IRS_VMAP_VMR Date: Tue, 13 Oct 2026 09:39:03 +0100 Message-ID: <20261013083933.1024405-57-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881427702158500 Content-Type: text/plain; charset="utf-8" The IRS_VMAP_VMR register lets the guest mark a VM as valid. This is a 64-bit register similar in operation to IRS_VMAP_L2_VMTR. We are eventually going to want to cache the information in a VM table entry, but for the moment implement the "make valid" operation as simply writing 1 to the VALID bit in the L2 VMTE. Note that unlike many of the other address fields in GICv5 data structures, we don't need to clear any of the low bits in L1_VMTE.L2_ADDR beyond masking with R_L1_VMTE_L2_ADDR_MASK. This is because a level 2 VMT is always 4KB and so the alignment is fixed; the mask clears the low 12 bits, enforcing 4KB alignment. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 94 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 1 + hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_common.h | 1 + include/hw/intc/arm_gicv5_regs.h | 21 +++++++ 5 files changed, 118 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index a81f7803ca5..f03b790cf41 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1309,6 +1309,65 @@ static void irs_vmap_l2_vmtr_write(GICv5 *s, GICv5Do= main domain, uint64_t value) goto txfail; } =20 + trace_gicv5_vmap_l2_vmtr(domain_name[domain], vmid); + + return; + +txfail: + /* Reportable with EC=3D0x0 if sw error reporting implemented */ + qemu_log_mask(LOG_GUEST_ERROR, "L1 VMTE update failed for VMID 0x%x at= " + "physical address 0x" HWADDR_FMT_plx "\n", vmid, l1_addr= ); +} + +static void irs_vmap_vmr_write(GICv5 *s, GICv5Domain domain, uint64_t valu= e) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + uint32_t vmid =3D FIELD_EX64(value, IRS_VMAP_VMR, VM_ID); + bool m =3D FIELD_EX64(value, IRS_VMAP_VMR, M); + bool u =3D FIELD_EX64(value, IRS_VMAP_VMR, U); + hwaddr l1_addr, l2_addr; + uint64_t l1_vmte, l2_vmte_0; + MemTxResult res; + + if (!gicv5_domain_has_virt(cs, domain) || !cfg->valid) { + /* Whole register RAZ/WI if no virt or no VM table */ + return; + } + + /* M bit is WO/UNKNOWN; write the other fields */ + cs->irs_vmap_vmr[domain] =3D value & ~R_IRS_VMAP_VMR_M_MASK; + + if (!m || vmid >=3D (1 << cfg->vm_id_bits)) { + return; + } + + /* Find the L1 VMTE */ + l1_addr =3D l1_vmte_addr(cs, cfg, vmid); + l1_vmte =3D address_space_ldq_le(&cs->dma_as, l1_addr, cfg->txattrs, &= res); + if (res !=3D MEMTX_OK) { + goto txfail; + } + + if (FIELD_EX64(l1_vmte, L1_VMTE, VALID) =3D=3D 0) { + /* No effect if L2 VM table is not valid */ + return; + } + + l2_addr =3D l1_vmte & R_L1_VMTE_L2_ADDR_MASK; + + l2_vmte_0 =3D address_space_ldq_le(&cs->dma_as, l2_addr, cfg->txattrs,= &res); + if (res !=3D MEMTX_OK) { + goto txfail; + } + + l2_vmte_0 =3D FIELD_DP64(l2_vmte_0, L2_VMTE_0, VALID, !u); + + address_space_stq_le(&cs->dma_as, l2_addr, l2_vmte_0, cfg->txattrs, &r= es); + if (res !=3D MEMTX_OK) { + goto txfail; + } + return; =20 txfail: @@ -1472,6 +1531,22 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_VMR: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D extract64(cs->irs_vmap_vmr[domain], 0, 32); + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; + case A_IRS_VMAP_VMR + 4: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D extract64(cs->irs_vmap_vmr[domain], 32, 32); + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; case A_IRS_SPI_STATUSR: /* * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect @@ -1604,6 +1679,14 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, deposit64(cs->irs_vmap_l2_vmtr[domain], 32, 32, data)); return true; + case A_IRS_VMAP_VMR: + irs_vmap_vmr_write(s, domain, + deposit64(cs->irs_vmap_vmr[domain], 0, 32, data= )); + return true; + case A_IRS_VMAP_VMR + 4: + irs_vmap_vmr_write(s, domain, + deposit64(cs->irs_vmap_vmr[domain], 32, 32, dat= a)); + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; @@ -1704,6 +1787,14 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_VMR: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D cs->irs_vmap_l2_vmtr[domain]; + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; } =20 return false; @@ -1722,6 +1813,9 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_VMAP_L2_VMTR: irs_vmap_l2_vmtr_write(s, domain, data); return true; + case A_IRS_VMAP_VMR: + irs_vmap_vmr_write(s, domain, data); + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 945257fef2c..19338ad5b9c 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -109,6 +109,7 @@ static void gicv5_common_reset_hold(Object *obj, ResetT= ype type) memset(cs->irs_vmt_baser, 0, sizeof(cs->irs_vmt_baser)); memset(cs->irs_vmt_cfgr, 0, sizeof(cs->irs_vmt_cfgr)); memset(cs->irs_vmap_l2_vmtr, 0, sizeof(cs->irs_vmap_l2_vmtr)); + memset(cs->irs_vmap_vmr, 0, sizeof(cs->irs_vmap_vmr)); } } =20 diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 30e2fc42471..4b47b98e66c 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -248,6 +248,7 @@ gicv5_irs_recalc_hppi_fail(const char *domain, uint32_t= iaffid, const char *reas gicv5_irs_recalc_hppi(const char *domain, uint32_t iaffid, uint32_t id, ui= nt8_t prio) "GICv5 IRS %s IAFFID %u: new HPPI ID 0x%x prio %u" gicv5_vmt_valid(const char *domain, uint64_t base, uint8_t vm_id_bits, boo= l structure) "GICv5 IRS %s VM table now valid: base 0x%" PRIx64 " vm_id_bit= s %u 2-level %d" gicv5_vmt_invalid(const char *domain) "GICv5 IRS %s VM table no longer val= id" +gicv5_vmap_l2_vmtr(const char *domain, uint32_t vmid) "GICv5 IRS %s VM ID = %u now valid" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 19700c7d5e3..5707111b98a 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -92,6 +92,7 @@ struct GICv5Common { uint64_t irs_vmt_baser[NUM_GICV5_DOMAINS]; uint32_t irs_vmt_cfgr[NUM_GICV5_DOMAINS]; uint64_t irs_vmap_l2_vmtr[NUM_GICV5_DOMAINS]; + uint64_t irs_vmap_vmr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array diff --git a/include/hw/intc/arm_gicv5_regs.h b/include/hw/intc/arm_gicv5_r= egs.h index d675a10c37f..edc66887ac4 100644 --- a/include/hw/intc/arm_gicv5_regs.h +++ b/include/hw/intc/arm_gicv5_regs.h @@ -273,6 +273,27 @@ FIELD(L2_ISTE, IAFFID, 16, 16) FIELD(L1_VMTE, VALID, 0, 1) FIELD(L1_VMTE, L2_ADDR, 12, 44) =20 +/* The L2 VMTE is 32 bytes, four 64-bit words */ +FIELD(L2_VMTE_0, VALID, 0, 1) +FIELD(L2_VMTE_0, VMD_ADDR, 3, 53) + +FIELD(L2_VMTE_1, VPET_ADDR, 3, 53) +FIELD(L2_VMTE_1, VPE_ID_BITS, 59, 5) + +FIELD(L2_VMTE_2, LPI_IST_VALID, 0, 1) +FIELD(L2_VMTE_2, LPI_IST_L2SZ, 1, 2) +FIELD(L2_VMTE_2, LPI_IST_ADDR, 6, 50) +FIELD(L2_VMTE_2, LPI_ISTSZ, 56, 2) +FIELD(L2_VMTE_2, LPI_IST_STRUCTURE, 58, 1) +FIELD(L2_VMTE_2, LPI_ID_BITS, 59, 5) + +FIELD(L2_VMTE_3, SPI_IST_VALID, 0, 1) +FIELD(L2_VMTE_3, SPI_IST_L2SZ, 1, 2) +FIELD(L2_VMTE_3, SPI_IST_ADDR, 6, 50) +FIELD(L2_VMTE_3, SPI_ISTSZ, 56, 2) +FIELD(L2_VMTE_3, SPI_IST_STRUCTURE, 58, 1) +FIELD(L2_VMTE_3, SPI_ID_BITS, 59, 5) + /* * L2 VMTEs are always 32 bytes, and the L2 table is always 4KB, * so the lower 7 bits in a VM ID index the L2 table. --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881251; cv=none; d=zohomail.com; s=zohoarc; b=UDNdSVC0mNuNTzdV7FNYA9XJNNEImrcDEbNQE/wul5TNPiZ/G3XbMIMvAKokXKwn4kl7egYCPvG2+d2jM/Cjbigo8PLa8y5kKqDwZNRoaSujHL/fCdp+DkvnEo7NFuwCpc3gGDs7psmQFtEj+cNRDjETvlhNfCkCJiWHzhCpGIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881251; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Q24yZtF6JH+M8UUja9cJN6DozeEXycsaupE/igqjcjo=; b=Z30yG9EW71TUMW3aX1l7dYoDyR5ndIH62Jruj5vNLoO5uxSpUEO2mMgJDSgqnjOIVAcL+e1IsU98Tl+zg3YTS2jMvAGUrKEpe6MtuXMhTJwedLt9LiBbQxAe9ixfuqGK53Wtwfcv/pXXMXcW08zFgE6YnqfTRi3Uy098IMNdRXY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881251734616.3256602177472; Tue, 13 Oct 2026 01:47:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY6t-0005PT-Pg; Tue, 13 Oct 2026 04:43:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY46-0000Io-UU for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:57 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY44-00085J-MU for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:54 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a17baef589so22020075e9.0 for ; Tue, 13 Oct 2026 01:40:52 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880851; x=1792485651; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Q24yZtF6JH+M8UUja9cJN6DozeEXycsaupE/igqjcjo=; b=JisIGbKBSqpFdIKAURsQBtwt5M+GJfzxnMX+/SUsJzbUSF2QVGpTz40yDWetAr/v9i w4lIQJbdVQkyuAD8as+As9dU93XUdqS6e+qFRh0+ysAqQW3Y2H7dPUZ407OgVTom49Kk ws4mCyumt6hxHAPSDDhkO3kdx24AdL8uP2FllMgn7ilEF2yu3dEpb8Ke9BBLgt/28i/e upJdjN2PCXbVS8sq4IaKtWdwW7OJNJb/boujccz440m88kDI1Qb+UTCwY9jKVTficiPR v5hDCCCp+KnI1wT9Hcw6gf5ibY3VMXHmRLJo55cP46Wdcm/k71pdmuaZkJnkM9ax65yH v9zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880851; x=1792485651; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Q24yZtF6JH+M8UUja9cJN6DozeEXycsaupE/igqjcjo=; b=kNn0sKPEqopiSaYp50mSqPv4sKwAFu6YqC04YkMZGEWay06gbn0Fyj8074I6XNUrQs tppNvaNzxLtF1Og6/FbO4NM2b/sfAA2cIQ7tNqtjNJNuiCG2gHQugilEGFyHFOV+QbfF KZJsP04qWdeVN58gP8975vDAuvV0Hntl0KTqEBEj3MpjpmvVlhg5UxxmXmhrKBHbsEdv M2F7pAZB+NnJ7Zot21RbMAmMJLWeUeO1MUrRIujuO3N+8od7+iiQaehChl7mXVB79QNu aNw9JjTGEZhTiabBKd3BOWpPexxMl02Ek5vPGHqRQOoWe5bK1Ov6Qr91W5kVD+C4AF/i fhZA== X-Forwarded-Encrypted: i=1; AKwUvBzN5edH9u85FZ+whNNvB9nzJZAKiVYLoPDtuvD5LOVQTY40p96usCkBlvO+i1JdSncSHkKU25/3cNXS@nongnu.org X-Gm-Message-State: AFq9FYJsfnKln3Azno5dGI/5DpvaAtNAETVTji/yvWl0mR52EpFZ9TSd HUyNZLrF+VpoWNwTM+9jqc36HE16B9/Vx0ggs4+3VQiWr8VLclLcjcPervw1s7AGj2c= X-Gm-Gg: AYBFou0hTjTXkJtdP6eQM+jdceQSssxE9kNW8bpDXefjqBn6n8hLxO74NybQrpzMJoB 37+tXhXssHNQI1ivPYUqD1SzVuwFJf06GZk3A/me4lMjpFM6LBLDAAQRQWW8Jfl/kd+MloPjljr y26RHADgm+jt7+jzXeqNYi4W2ViTjBbVggyHLBP8giZComZkYkrtD1I9rcE1iZbFhRGga1acvvo gCXQU2pZ3UDl5uYy8rOz/Xi0BpXDGJ085YdFnPZcZB4pGaBrJUE5zoCUaywTd7ZxqzsjNII459J NzWBvOTesQ0Nw1geoQmhIkGoCkeEXss74ltu1PNsvipaxavA6AS/EalWKWHC6P15K6quiiZrk8/ f4EWg06/zcfWXV2+VgouLcgArtWXoCUTsksXsmoF5LWwZmdDfYJOA82AmIe8jfrcHuZt3g4C9hG ql4mfGlAG63NHhf5fQKx1olMuPfzePCb7a/wxfg0Yy+IKHjk24gt0Bs3kPxxTHTtRU+cB5M1upL aJh+YzZX2qPyhVz3hSvfCpcVp3EIzYuWfYp4fAtnh5Ruyyixr/Ksb2MxX+BKSoE464HUhsg4pT9 Zq8t X-Received: by 2002:a05:600c:c107:b0:4a1:875b:8be4 with SMTP id 5b1f17b1804b1-4a193f3b3a4mr144753915e9.8.1791880850917; Tue, 13 Oct 2026 01:40:50 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 57/86] hw/intc/arm_gicv5: Factor out code to fill in a GICv5ISTConfig Date: Tue, 13 Oct 2026 09:39:04 +0100 Message-ID: <20261013083933.1024405-58-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881252292158500 Content-Type: text/plain; charset="utf-8" irs_ist_baser_write() has code that fills in a GICv5ISTConfig based on various register fields, including sanitizing uses of reserved values, enforcing minimum and maximum values, and pre-calculating how many bits index the L2 table. We will want exactly the same logic for setting up GICv5ISTConfig structs for a VM's LPI and SPI IST structures based on the fields in the L2 VMTE. Factor out the "fill in the GICv5ISTConfig" code to a separate function that we can call. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 181 ++++++++++++++++++++++++-------------------- 1 file changed, 100 insertions(+), 81 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index f03b790cf41..8cf7e363f29 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -976,6 +976,96 @@ void gicv5_deactivate(GICv5Common *cs, uint32_t id, GI= Cv5Domain domain, irs_recalc_hppi(s, domain, iaffid); } =20 +static void initialize_ist_config(GICv5Common *cs, GICv5Domain domain, + GICv5ISTConfig *cfg, + hwaddr base, + uint8_t id_bits, uint8_t istsz, uint8_t = l2sz, + bool structure) +{ + uint8_t istbits, l2bits, l2_idx_bits; + int tableszbits; + + switch (istsz) { + case 0: + case 3: /* reserved: acts like the minimum required size */ + istbits =3D 2; + break; + case 1: + istbits =3D 3; + break; + case 2: + istbits =3D 4; + break; + default: + g_assert_not_reached(); + } + switch (l2sz) { + case 0: + case 3: /* reserved; CONSTRAINED UNPREDICTABLE */ + l2bits =3D 12; /* 4K: 12 bits */ + break; + case 1: + l2bits =3D 14; /* 16K: 14 bits */ + break; + case 2: + l2bits =3D 16; /* 64K: 16 bits */ + break; + default: + g_assert_not_reached(); + } + /* + * Calculate how many bits of an ID index the L2 table + * (e.g. if we need 14 bits to index each byte in a 16K L2 table, + * but each entry is 4 bytes wide then we need 14 - 2 =3D 12 bits + * to index an entry in the table). + */ + l2_idx_bits =3D l2bits - istbits; + cfg->base =3D base; + cfg->txattrs =3D irs_txattrs(cs, domain); + cfg->id_bits =3D id_bits; + cfg->istsz =3D 1 << istbits; + cfg->l2_idx_bits =3D l2_idx_bits; + cfg->l2bits =3D l2bits; + cfg->structure =3D structure; + + /* + * Bits [N:0] of the base addr are ignored, to enforce that in a + * 1-level IST it is aligned to the size of the ISTE array, + * and in a 2-level IST it is aligned to the size of the L1 table. + * The spec defines N in terms of the raw L2SZ, ISTSZ and LPI_ID_BITS + * fields, but we have already sanitized these to + * istbits =3D ISTSZ + 2 + * l2bits =3D (L2SZ * 2) + 12 + * id_bits =3D LPI_ID_BITS + * We have also already enforced the "bottom 6 bits are 0" via + * the fixed field mask, so can skip the Max() operation. + * We want tableszbits =3D=3D the number of bits to zero, which is N += 1. + */ + if (cfg->structure) { + /* + * L1 table is indexed by the (id_bits - l2_idx_bits) bits in + * the ID, so has 2^(id_bits - l2_idx_bits) entries, and each + * entry is 8 bytes =3D=3D 2^3. + */ + tableszbits =3D id_bits - l2_idx_bits + 3; + } else { + /* table has 2^id_bits entries of 2^istbits size each */ + tableszbits =3D id_bits + istbits; + } + cfg->base &=3D ~MAKE_64BIT_MASK(0, tableszbits); + + if (!cfg->lpi_cache) { + /* + * Keys are GINT_TO_POINTER(intid), so we want the g_direct_hash + * and g_direct_equal hash and equality functions. We don't + * want to free the keys, but we do want to free the values + * (which are pointer-to-uint32_t). + */ + cfg->lpi_cache =3D g_hash_table_new_full(NULL, NULL, NULL, g_free); + } + cfg->valid =3D true; +} + static void irs_map_l2_istr_write(GICv5 *s, GICv5Domain domain, uint64_t v= alue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); @@ -1086,92 +1176,21 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Doma= in domain, uint64_t value) * sanitize the reserved values, and expand fields out into byte c= ounts. */ GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; - uint8_t istbits, l2bits, l2_idx_bits; - int tableszbits; + hwaddr base =3D cs->irs_ist_baser[domain] & R_IRS_IST_BASER_ADDR_M= ASK; uint8_t id_bits =3D FIELD_EX64(cs->irs_ist_cfgr[domain], IRS_IST_CFGR, LPI_ID_BITS); - id_bits =3D MIN(MAX(id_bits, QEMU_GICV5_MIN_LPI_ID_BITS), QEMU_GIC= V5_ID_BITS); - - switch (FIELD_EX64(cs->irs_ist_cfgr[domain], IRS_IST_CFGR, ISTSZ))= { - case 0: - case 3: /* reserved: acts like the minimum required size */ - istbits =3D 2; - break; - case 1: - istbits =3D 3; - break; - case 2: - istbits =3D 4; - break; - default: - g_assert_not_reached(); - } - switch (FIELD_EX64(cs->irs_ist_cfgr[domain], IRS_IST_CFGR, L2SZ)) { - case 0: - case 3: /* reserved; CONSTRAINED UNPREDICTABLE */ - l2bits =3D 12; /* 4K: 12 bits */ - break; - case 1: - l2bits =3D 14; /* 16K: 14 bits */ - break; - case 2: - l2bits =3D 16; /* 64K: 16 bits */ - break; - default: - g_assert_not_reached(); - } - /* - * Calculate how many bits of an ID index the L2 table - * (e.g. if we need 14 bits to index each byte in a 16K L2 table, - * but each entry is 4 bytes wide then we need 14 - 2 =3D 12 bits - * to index an entry in the table). - */ - l2_idx_bits =3D l2bits - istbits; - cfg->base =3D cs->irs_ist_baser[domain] & R_IRS_IST_BASER_ADDR_MAS= K; - cfg->txattrs =3D irs_txattrs(cs, domain), - cfg->id_bits =3D id_bits; - cfg->istsz =3D 1 << istbits; - cfg->l2_idx_bits =3D l2_idx_bits; - cfg->l2bits =3D l2bits; - cfg->structure =3D FIELD_EX64(cs->irs_ist_cfgr[domain], + uint8_t istsz =3D FIELD_EX64(cs->irs_ist_cfgr[domain], + IRS_IST_CFGR, ISTSZ); + uint8_t l2sz =3D FIELD_EX64(cs->irs_ist_cfgr[domain], + IRS_IST_CFGR, L2SZ); + bool structure =3D FIELD_EX64(cs->irs_ist_cfgr[domain], IRS_IST_CFGR, STRUCTURE); =20 - /* - * Bits [N:0] of the base addr are ignored, to enforce that in a - * 1-level IST it is aligned to the size of the ISTE array, - * and in a 2-level IST it is aligned to the size of the L1 table. - * The spec defines N in terms of the raw L2SZ, ISTSZ and LPI_ID_B= ITS - * fields, but we have already sanitized these to - * istbits =3D ISTSZ + 2 - * l2bits =3D (L2SZ * 2) + 12 - * id_bits =3D LPI_ID_BITS - * We have also already enforced the "bottom 6 bits are 0" via - * R_IRS_IST_BASER_ADDR_MASK, so can skip the Max() operation. - * We want tableszbits =3D=3D the number of bits to zero, which is= N + 1. - */ - if (cfg->structure) { - /* - * L1 table is indexed by the (id_bits - l2_idx_bits) bits in - * the ID, so has 2^(id_bits - l2_idx_bits) entries, and each - * entry is 8 bytes =3D=3D 2^3. - */ - tableszbits =3D id_bits - l2_idx_bits + 3; - } else { - /* table has 2^id_bits entries of 2^istbits size each */ - tableszbits =3D id_bits + istbits; - } - cfg->base &=3D ~MAKE_64BIT_MASK(0, tableszbits); + id_bits =3D MIN(MAX(id_bits, QEMU_GICV5_MIN_LPI_ID_BITS), QEMU_GIC= V5_ID_BITS); + + initialize_ist_config(cs, domain, cfg, base, id_bits, + istsz, l2sz, structure); =20 - if (!cfg->lpi_cache) { - /* - * Keys are GINT_TO_POINTER(intid), so we want the g_direct_ha= sh - * and g_direct_equal hash and equality functions. We don't - * want to free the keys, but we do want to free the values - * (which are pointer-to-uint32_t). - */ - cfg->lpi_cache =3D g_hash_table_new_full(NULL, NULL, NULL, g_f= ree); - } - cfg->valid =3D true; trace_gicv5_ist_valid(domain_name[domain], cfg->base, cfg->id_bits, cfg->l2_idx_bits, cfg->istsz, cfg->structure= ); irs_recalc_hppi_all_cpus(s, domain); --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881661; cv=none; d=zohomail.com; s=zohoarc; b=EM/IXY2buAQHBxqZrAYNmd28aKdpfjyCNz0Nlk6VNtjhIpU21jv2FFz6Ik7FDSB25Nut1cqckfP+VcP7yhK0cdY9HOErfI3awP8h1+ADrv1g7K+QhoeYE0Mcf9oMecmZKMSP7HSsO2GNNmrNbxw3pmZBgH20Wz2i3I6zojEGP34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881661; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=fpHMIk8Nm/5w+iRREMxKf46LjEiZ4eICh82Sj9fIJiw=; b=EbZ4qNX0ujhO5J+KAG8sExNd/UL35e1BoCWog3N3hwcbkHuhYkGBQuI1yo52ejvrcW9SjkHEAO3ZQMFpoOfqLhM6Ovby9nn2AGfmG0kfy3CBjz1/0OAKTRPfF3U4L94kEJv+Lb4+ulBIHgbcb8mdEBcC5LQtxYsM8uIC//TNXkA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881661017826.4282165371999; Tue, 13 Oct 2026 01:54:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY7r-0005sc-AG; Tue, 13 Oct 2026 04:44:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY48-0000Je-Oi for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:57 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY45-00085k-PT for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:56 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4a16af2a232so21343305e9.1 for ; Tue, 13 Oct 2026 01:40:53 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880852; x=1792485652; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=fpHMIk8Nm/5w+iRREMxKf46LjEiZ4eICh82Sj9fIJiw=; b=rqS+dvBg02pTHkQwjRgqcevUQgq+SdAP/tahu+IAHQqlaWC4W0kHYTLzby1Cf9Pwew 285cnTZa4L7hWIAsauQAtwYHsH3+t2NgkVubftSGrJ+AMbd3YnOjFHb8ld/VHDI/Uway IbLNlHWyiYgclAuPl6dw5IN2inw2utFudhL+D7Zn8tflh2IK7GEKapIqRI0SB6T0ZOwI WS5zzkjlCvSEwaXIBzrC+pP0cZ6Qx/GhM0j3/l/vFAa8ObbJ2Ey0zjNjn7V+/AWeJsvE nbNuymcgFsHwhvrZzGzqNws1SEtimvCGjZ9ON1h2pJgrpgYAmIyFYUusN4t7q2pgRDvh XJ2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880852; x=1792485652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=fpHMIk8Nm/5w+iRREMxKf46LjEiZ4eICh82Sj9fIJiw=; b=lItPvafzk2FpUYXJ61fznj2Zcsi3o9dBRv3ZfN7wVqGsrSrA6F12Kyv0ycl8NazESt 12fKPyQNeKy3Tmiz5nkJgQORSb5iTiH01QZytIWHuZ/4uiIQMk7mYb4HXsuQTOwapfbx 01mV4KoOemWlp7d1qQ+Rgl+dlMIs5GWKzzuFw6+vCRcnIkh7o8Xs6Oj5bVlX0Qm00enA QpH+bANqNCB2E88FzODQCNJccAbl7mw1/P1vYKSpcHMUm798jK8dntbWRqBjcd2O0MJO mxE5j8RQnJwrnfP8WBgxvP8I2S5geS+my+9Lir52062kIB3e7U4wQc6kOB+P1G96oVr5 BXoA== X-Forwarded-Encrypted: i=1; AKwUvBxmQCkeu3ZJoqhl/f76oI8BISR4quQiqCC9/bJzcyYaISNZ7e4j/TgiTAO+lsa+yholsiTKMFrCHIxa@nongnu.org X-Gm-Message-State: AFq9FYJ6AGOrnuwiu9NervtwaY9VPFG1bzWlvkW27sX1KMMRroDTUBfi VSWeZf9Ze+w3QLsuTXkVwm1IFPu1UF91DP4A4fkM3AFCEYgNPNdEOli04Zba1p1Cc3yrk9GLrGV w3XVRzJE= X-Gm-Gg: AYBFou1C3g0N/HQicyLce4YJclmjq81AMoFHMuE0RewKnKvGglbQYN1PpK7o3qKbPv7 RviSpx4G/0g6Ouah7nO/LyStcXr5tCwA7VYUpyEDvg/4vgtONxIxG6Ker0fKq3y9yxwWIepsOUH 4AkUvGDao210kLwNRsxhGQiK2YCzC5q7bhYtz7ppDVrCJotqH1RpqneH8pFs3acxMncJE8zXvHa bYsZTvoBDIwLR6hoTd/ERG9MKSDnoI4t5AVyglxr6mpnALlfAsNgIWB9lTSuFqWGGrKlxkHw+pl Jc8mMqbZvrUgYAESYHhQdGXhUGzn6EGSV7ItI4PY7xwWiQCzBIGNO+Bh+V2aj412zS8tuXUgM7f yCPWsyxYAJBWzP5nQ8oqvGuThlY6Tg/dvi2CaoTKTFWe2BRdHnfCHFLlXIsmIjkgfXPDq+ZNPoU 7lA9PpZSekRfmj96QEV13CmqLMXxvFnXp4vy+kxbsSkcFQg1/sXztcr/FWzel1TMBwf+RQKDzTr N/nqPSHA++PjOIwPwlDnS9ydeGzPGL3xTD8EOKncBAvgQQhL1wKO5kCSOo2txT6iyvENk6Y2DLP Hf84 X-Received: by 2002:a05:600c:83c7:b0:4a1:698d:3044 with SMTP id 5b1f17b1804b1-4a18e493020mr228631015e9.11.1791880852212; Tue, 13 Oct 2026 01:40:52 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 58/86] hw/intc/arm_gicv5: Cache info about valid VMs in a hashtable Date: Tue, 13 Oct 2026 09:39:05 +0100 Message-ID: <20261013083933.1024405-59-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881662268158500 Content-Type: text/plain; charset="utf-8" The VM table in guest memory contains information about each VM the guest has set up. In particular, it has information about other data structures such as the VM's LPI and SPI tables and their configuration. We don't want to have to read this from guest memory and extract the fields every time we use it. Add a hash table to GICv5VMTConfig: the keys are VM IDs, and the values are structs with the extracted and sanitized information from the L2 VMTE. In this commit we populate the hash table entry when the guest makes a VM valid via a write ta IRS_VMAP_VMR. It is also permitted for the guest to pass us an L1 or L2 VM table where some entries are pre-marked as valid; we will handle creating the hash table entries for that case in the following commit. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 216 ++++++++++++++++++++++++++++++- hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5.h | 2 + include/hw/intc/arm_gicv5_regs.h | 3 + 4 files changed, 216 insertions(+), 6 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 8cf7e363f29..b66bc5b95df 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -23,6 +23,20 @@ =20 OBJECT_DEFINE_TYPE(GICv5, gicv5, ARM_GICV5, ARM_GICV5_COMMON) =20 +/* In the GICv5VMTConfig::vm_cache this is how we store VMTE info */ +typedef struct VMTE { + GICv5ISTConfig lpi_ist; + GICv5ISTConfig spi_ist; + /* Address of the in-memory L2_VMTE for this VMTE */ + hwaddr vmte_addr; + hwaddr vpet_addr; + uint32_t vmid; + uint8_t vpe_id_bits; + GICv5Domain domain; + /* We don't cache the VMD_ADDR as we don't use VMDs */ + /* We don't cache VALID: the existence of this struct implies VALID=3D= 1 */ +} VMTE; + static const char *domain_name[] =3D { [GICV5_ID_S] =3D "Secure", [GICV5_ID_NS] =3D "NonSecure", @@ -74,6 +88,22 @@ static uint32_t gicv5_idreg(int regoffset) return gic_ids[regoffset]; } =20 +/* GDestroyNotify function for VMTE struct */ +static void VMTE_free(void *data) +{ + VMTE *vmte =3D data; + + /* Destroy (without writing back to guest memory) the ISTConfigs */ + if (vmte->lpi_ist.lpi_cache) { + g_hash_table_destroy(vmte->lpi_ist.lpi_cache); + } + if (vmte->spi_ist.lpi_cache) { + g_hash_table_destroy(vmte->spi_ist.lpi_cache); + } + + g_free(vmte); +} + static bool gicv5_domain_has_virt(GICv5Common *cs, GICv5Domain domain) { /* @@ -1116,6 +1146,117 @@ bool gicv5_set_resident(GICv5Common *cs, GICv5Domai= n domain, bool valid, return true; } =20 +static bool read_first_vmte_word(GICv5Common *cs, GICv5VMTConfig *cfg, + hwaddr l2_addr, + uint64_t l2_vmte[L2_VMTE_WORDS]) +{ + /* Read the first word of the L2 VMTE, returning false on failure */ + MemTxResult res; + + l2_vmte[0] =3D address_space_ldq_le(&cs->dma_as, l2_addr, + cfg->txattrs, &res); + return res =3D=3D MEMTX_OK; +} + +static bool read_other_vmte_words(GICv5Common *cs, GICv5VMTConfig *cfg, + hwaddr l2_addr, + uint64_t l2_vmte[L2_VMTE_WORDS]) +{ + /* + * Read L2 VMTE words 1..3, returning false on failure. + * @l2_addr is the address of the start of the VMTE. + */ + for (int i =3D 1; i < L2_VMTE_WORDS; i++) { + MemTxResult res; + + l2_vmte[i] =3D address_space_ldq_le(&cs->dma_as, + l2_addr + i * sizeof(uint64_t), + cfg->txattrs, &res); + if (res !=3D MEMTX_OK) { + return false; + } + } + return true; +} + +static void initialize_vlpi_ist_config(GICv5Common *cs, GICv5Domain domain, + VMTE *vmte, uint64_t *l2_vmte) +{ + hwaddr base =3D l2_vmte[2] & R_L2_VMTE_2_LPI_IST_ADDR_MASK; + uint8_t l2sz =3D FIELD_EX64(l2_vmte[2], L2_VMTE_2, LPI_IST_L2SZ); + uint8_t istsz =3D FIELD_EX64(l2_vmte[2], L2_VMTE_2, LPI_ISTSZ); + uint8_t id_bits =3D FIELD_EX64(l2_vmte[2], L2_VMTE_2, LPI_ID_BITS); + bool structure =3D FIELD_EX64(l2_vmte[2], L2_VMTE_2, LPI_IST_STRUCTURE= ); + + id_bits =3D MIN(MAX(id_bits, QEMU_GICV5_MIN_LPI_ID_BITS), QEMU_GICV5_I= D_BITS); + + initialize_ist_config(cs, domain, &vmte->lpi_ist, base, + id_bits, istsz, l2sz, structure); +} + +static void initialize_vspi_ist_config(GICv5Common *cs, GICv5Domain domain, + VMTE *vmte, uint64_t *l2_vmte) +{ + hwaddr base =3D l2_vmte[3] & R_L2_VMTE_3_SPI_IST_ADDR_MASK; + uint8_t l2sz =3D FIELD_EX64(l2_vmte[3], L2_VMTE_3, SPI_IST_L2SZ); + uint8_t istsz =3D FIELD_EX64(l2_vmte[3], L2_VMTE_3, SPI_ISTSZ); + uint8_t id_bits =3D FIELD_EX64(l2_vmte[3], L2_VMTE_3, SPI_ID_BITS); + bool structure =3D FIELD_EX64(l2_vmte[3], L2_VMTE_3, SPI_IST_STRUCTURE= ); + + /* + * Note that QEMU_GICV5_MIN_LPI_ID_BITS applies to physical + * LPIs and virtual LPIs but not to vSPIs. + */ + id_bits =3D MIN(id_bits, QEMU_GICV5_ID_BITS); + + initialize_ist_config(cs, domain, &vmte->spi_ist, base, + id_bits, istsz, l2sz, structure); +} + +static void cache_vmte(GICv5Common *cs, GICv5Domain domain, + GICv5VMTConfig *cfg, + uint32_t vmid, uint64_t *l2_vmte, hwaddr l2_addr) +{ + /* + * Add a VMTE struct for an L2 VMTE to the VM cache for @cfg. + * @l2_addr should be the address of the L2 VMTE in guest memory. + * @l2_vmte is the contents of that VMTE. The caller guarantees + * that the VALID bit is set both in @l2_vmte and in memory. + */ + VMTE *vmte =3D g_new0(VMTE, 1); + + vmte->vmte_addr =3D l2_addr; + vmte->vmid =3D vmid; + vmte->domain =3D domain; + + vmte->vpet_addr =3D l2_vmte[1] & R_L2_VMTE_1_VPET_ADDR_MASK; + vmte->vpe_id_bits =3D MIN(FIELD_EX64(l2_vmte[1], L2_VMTE_1, VPE_ID_BIT= S), + QEMU_GICV5_VPE_ID_BITS); + /* + * Enforce alignment of the VPE table to its size: + * it has 2^vpe_id_bits entries of 2^3 =3D=3D 8 bytes each + */ + vmte->vpet_addr &=3D ~MAKE_64BIT_MASK(0, vmte->vpe_id_bits + 3); + + /* + * If the VALID bits are set for the LPI and SPI ISTs, we can read + * the address and config fields now to set up the GICv5ISTConfig. + * Otherwise, the guest can make them valid later via IRS_VMAP_VISTR, + * and we must not read the address/config fields yet. + */ + if (FIELD_EX64(l2_vmte[2], L2_VMTE_2, LPI_IST_VALID)) { + initialize_vlpi_ist_config(cs, domain, vmte, l2_vmte); + } + + if (FIELD_EX64(l2_vmte[3], L2_VMTE_3, SPI_IST_VALID)) { + initialize_vspi_ist_config(cs, domain, vmte, l2_vmte); + } + + g_hash_table_insert(cfg->vm_cache, GINT_TO_POINTER(vmid), vmte); + + trace_gicv5_cache_vmte(domain_name[domain], vmid); +} + /* Data we need to pass through to irs_clean_lpi_cache_entry() */ typedef struct CleanLPICacheUserData { GICv5Common *cs; @@ -1197,6 +1338,40 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domai= n domain, uint64_t value) } } =20 +typedef struct CleanVMCacheUserData { + GICv5Common *cs; + GICv5VMTConfig *cfg; +} CleanVMCacheUserData; + +static gboolean irs_clean_vm_cache_entry(gpointer key, gpointer value, + gpointer user_data) +{ + /* + * Drop this entry from the VM cache, including cleaning up its + * LPI and SPI caches. + */ + CleanVMCacheUserData *ud =3D user_data; + VMTE *vmte =3D (VMTE *)value; + + irs_clean_lpi_cache(ud->cs, &vmte->lpi_ist); + irs_clean_lpi_cache(ud->cs, &vmte->spi_ist); + return true; +} + +static void irs_clean_vm_cache(GICv5Common *cs, GICv5VMTConfig *cfg) +{ + /* + * Drop the VM table cache. We don't need to write anything back + * to guest memory for the VM table entries themselves, but we + * need to clean the LPI/SPI cache, which might do writeback. + */ + CleanVMCacheUserData ud; + + ud.cs =3D cs; + ud.cfg =3D cfg; + g_hash_table_foreach_remove(cfg->vm_cache, irs_clean_vm_cache_entry, &= ud); +} + static void irs_vmt_baser_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); @@ -1213,6 +1388,7 @@ static void irs_vmt_baser_write(GICv5 *s, GICv5Domain= domain, uint64_t value) /* Ignore 1->1 transition */ return; } + irs_clean_vm_cache(cs, &s->vmt_config[domain]); cs->irs_vmt_baser[domain] =3D FIELD_DP64(cs->irs_vmt_baser[domain], IRS_VMT_BASER, VALID, valid= ); s->vmt_config[domain].valid =3D false; @@ -1273,6 +1449,16 @@ static void irs_vmt_baser_write(GICv5 *s, GICv5Domai= n domain, uint64_t value) cfg->base &=3D ~MAKE_64BIT_MASK(0, tableszbits); } =20 + if (!cfg->vm_cache) { + /* + * Keys are GINT_TO_POINTER(intid), so we want the g_direct_ha= sh + * and g_direct_equal hash and equality functions. We don't + * want to free the keys, but we do want to free the values + * (which are VMTE*). + */ + cfg->vm_cache =3D g_hash_table_new_full(NULL, NULL, NULL, VMTE= _free); + } + cfg->valid =3D true; =20 trace_gicv5_vmt_valid(domain_name[domain], cfg->base, @@ -1346,7 +1532,7 @@ static void irs_vmap_vmr_write(GICv5 *s, GICv5Domain = domain, uint64_t value) bool m =3D FIELD_EX64(value, IRS_VMAP_VMR, M); bool u =3D FIELD_EX64(value, IRS_VMAP_VMR, U); hwaddr l1_addr, l2_addr; - uint64_t l1_vmte, l2_vmte_0; + uint64_t l1_vmte, l2_vmte[L2_VMTE_WORDS]; MemTxResult res; =20 if (!gicv5_domain_has_virt(cs, domain) || !cfg->valid) { @@ -1375,16 +1561,25 @@ static void irs_vmap_vmr_write(GICv5 *s, GICv5Domai= n domain, uint64_t value) =20 l2_addr =3D l1_vmte & R_L1_VMTE_L2_ADDR_MASK; =20 - l2_vmte_0 =3D address_space_ldq_le(&cs->dma_as, l2_addr, cfg->txattrs,= &res); + if (!read_first_vmte_word(cs, cfg, l2_addr, l2_vmte)) { + goto txfail; + } + + l2_vmte[0] =3D FIELD_DP64(l2_vmte[0], L2_VMTE_0, VALID, !u); + + address_space_stq_le(&cs->dma_as, l2_addr, l2_vmte[0], cfg->txattrs, &= res); if (res !=3D MEMTX_OK) { goto txfail; } =20 - l2_vmte_0 =3D FIELD_DP64(l2_vmte_0, L2_VMTE_0, VALID, !u); + if (u) { + g_hash_table_remove(cfg->vm_cache, GINT_TO_POINTER(vmid)); + } else { + if (!read_other_vmte_words(cs, cfg, l2_addr, l2_vmte)) { + goto txfail; + } =20 - address_space_stq_le(&cs->dma_as, l2_addr, l2_vmte_0, cfg->txattrs, &r= es); - if (res !=3D MEMTX_OK) { - goto txfail; + cache_vmte(cs, domain, cfg, vmid, l2_vmte, l2_addr); } =20 return; @@ -1999,6 +2194,10 @@ static void gicv5_reset_hold(Object *obj, ResetType = type) /* IRS_VMT_BASER and IRS_VMT_CFGR reset to 0, clear cached info */ for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { s->vmt_config[i].valid =3D false; + /* Drop the VM cache entries without writeback */ + if (s->vmt_config[i].vm_cache) { + g_hash_table_remove_all(s->vmt_config[i].vm_cache); + } } } =20 @@ -2121,6 +2320,11 @@ static void gicv5_finalize(Object *obj) g_hash_table_destroy(ht); } =20 + ht =3D s->vmt_config[i].vm_cache; + if (ht) { + g_hash_table_destroy(ht); + } + g_free(s->hppi[i]); } } diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 4b47b98e66c..cb3568fa80c 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -249,6 +249,7 @@ gicv5_irs_recalc_hppi(const char *domain, uint32_t iaff= id, uint32_t id, uint8_t gicv5_vmt_valid(const char *domain, uint64_t base, uint8_t vm_id_bits, boo= l structure) "GICv5 IRS %s VM table now valid: base 0x%" PRIx64 " vm_id_bit= s %u 2-level %d" gicv5_vmt_invalid(const char *domain) "GICv5 IRS %s VM table no longer val= id" gicv5_vmap_l2_vmtr(const char *domain, uint32_t vmid) "GICv5 IRS %s VM ID = %u now valid" +gicv5_cache_vmte(const char *domain, uint32_t vmid) "GICv5 IRS %s VM ID %u= valid and cached" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5.h b/include/hw/intc/arm_gicv5.h index 785c7112fd9..28417317376 100644 --- a/include/hw/intc/arm_gicv5.h +++ b/include/hw/intc/arm_gicv5.h @@ -36,6 +36,8 @@ typedef struct GICv5VMTConfig { uint8_t vm_id_bits; /* number of VM ID bits for the domain */ bool structure; /* true if using 2-level table */ bool valid; /* true if this table is valid and usable */ + /* This caches information about valid VMs */ + GHashTable *vm_cache; } GICv5VMTConfig; =20 /* diff --git a/include/hw/intc/arm_gicv5_regs.h b/include/hw/intc/arm_gicv5_r= egs.h index edc66887ac4..51ea451b6b6 100644 --- a/include/hw/intc/arm_gicv5_regs.h +++ b/include/hw/intc/arm_gicv5_regs.h @@ -294,6 +294,9 @@ FIELD(L2_VMTE_3, SPI_ISTSZ, 56, 2) FIELD(L2_VMTE_3, SPI_IST_STRUCTURE, 58, 1) FIELD(L2_VMTE_3, SPI_ID_BITS, 59, 5) =20 +/* Size of L2 VMTE in 64-bit words */ +#define L2_VMTE_WORDS 4 + /* * L2 VMTEs are always 32 bytes, and the L2 table is always 4KB, * so the lower 7 bits in a VM ID index the L2 table. --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881146; cv=none; d=zohomail.com; s=zohoarc; b=hLRpMF4B/mCdY7rAjQcFBuPlDB9bVI2tTWnBWwVEUYf7XSGslzURXvNXArke31mVrfoYpngph7VmaQbBuZFtvk3+V1quQTY+0sOLHYprQbzl00RtR4l1ld6ULDzwq6iebBADoB9wp1Ez2venc0DAVEjYizgbBpGAV63jECAi89s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881146; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=77m1KUCe87mNvexEH9gGkpi1V3Hg5U+1YnpivtmqzJw=; b=chaE0ckCR7YSahd8R6lcFwpL4pSpTDdXI16TGxsVuQSPN96uFVwZJ+6xaExRnNgpEq8kxryyzsR0b4hezDhCqF/uEdQkVmdi/lgzLxNbhH9oIUKOkdk2wmEvrzfKpd2i2MhNtzLNitI8YUwUWeK9vVswZ0jnrflcb2qiBPJJCog= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881146499432.27218124789215; Tue, 13 Oct 2026 01:45:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8F-0006Yq-5R; Tue, 13 Oct 2026 04:45:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY49-0000LC-Vr for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:59 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY47-000867-Ay for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:57 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4a022fee0caso24201825e9.1 for ; Tue, 13 Oct 2026 01:40:54 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880854; x=1792485654; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=77m1KUCe87mNvexEH9gGkpi1V3Hg5U+1YnpivtmqzJw=; b=XV40wo7hIv41XRB+1x4Bgm5NyAiTdnoaOYt0UjZHZbXY4MvbPGwKMCLN9zAjaR/mlr PsS0OUdhOMZCxs7HmPc74hl5vCJYIuZWMyZ4/7Q0ZzwS+C369ChuXi+UVT+lJ0GZwxsL KAQDOLYXjLRgfz86vXoiI1YLhihV7vvDLQfsPz1FGYFMo1lc/nxjHoxy0KLvqB6fP3qJ ZUGiJhXjYzdBYAAreVnMoRS7OljV5Hx/4FLw1Mlf2c74Tn1uLMQC9qIThBsPBfapkNZc 9ICdKM34jQ6hN+Ks9nxvGkYXA3F5qsqk2+7vyD1hoUlsg9y24jBGtRAU0VZFYP18t9Xu KYgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880854; x=1792485654; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=77m1KUCe87mNvexEH9gGkpi1V3Hg5U+1YnpivtmqzJw=; b=or1NX3uu9Xh1MjX7XKBhPDTGL3WjN53E3asTfSMOmyilkjIjdotwkt5IaI0Jks1V+J ZVOa9LxvM2Ku9ymrCWaYzht/TCugV/n7w8ZDH2JdqMak+Z01cXZULtkMBm6gxVVtiZug etv5SpxuJJN8N7mmixtQz/3PiBVaM6Rr8+kp8n9BTo9KJqolo7rIIieswrsmG35gZeqN WP42iAdYTUg6gu1h1rWi5CXPVNBbbQ71sqL9WF9OkDgXkmomN7EKh3raC2mNSGZjOCZJ g3yDq9cuBkFMbRxLaV//DUB0/TAt2D3Opv5lwUuWbjgai6ZLESyLVc9eaJKBsT4OuCfj dbZQ== X-Forwarded-Encrypted: i=1; AKwUvBzcmvBQ3wN3IgDcOPLIzu13yVDe/vlM0HleKb9RyRkl50Z5FGcQJmElLZny119oa5/YD1uqjhJS+KLL@nongnu.org X-Gm-Message-State: AFq9FYLDHkgaqM7Su0CAyEXJkuT5aQQHJJ/SC1L6Qyv5UGNwgtr38p6x gXLj55La9bSsHSDtSvczSt0vG9JTLKIAPXrkWT8K5fFlP75VMkucHOycc15yBeFyFPg= X-Gm-Gg: AYBFou2kTinbBdqOttvrh7uSasck+4rSO+gndv4uLRh8llxftMEoUwGHuRnIkNxObGC uJQvptnFMaa+n5SW5Staa/XZ7RHE8+qUErMJ9MogndaCISlyvwIue85RBdbXHsW0cLBmniWxZfY icCouD3TnBvbQ2xB625R6jip3iL5810VmijMG4WfAcEFbAQ4TaTtWyvOndnFv0pydtlfIEqgLBA ZrhSVBeL8QP1Uz9gCdZ4D1qCc38Dkkx/BzDqv3VUmGnYnuNk/uUjfneaH7H2wddYjDTsVtQlCXd jDFvNflUzEynZcpb8eqaDwQRlI0Is1ObH1AvJwhj4J8OLNVmQCP+EzEXSkbirIfSgp8LdPNGzOD ytoAJEv5deTEAVc0+FXcb3LokKAnn9o6VIi6swSmoHHoIJywCmZ7rr6D49eddOq//LZ+FqG0vo0 9JsyNMdzbArCIplh4OKJRShfE9rxJkAwIz0+8zVEigIZbA9HYludIroLv9wm/AvvPNGFGvcwFm/ Tu26+92zzBq2cgI/4F+QMDABNcm46Da63EDbU1TicXYqo4m9xhZaSaiF8M60zvTJa87lyVX0DNO ReykoBa+zuNwig== X-Received: by 2002:a05:600c:4e91:b0:4a1:7ec7:a479 with SMTP id 5b1f17b1804b1-4a18e4f56bcmr239711095e9.33.1791880853808; Tue, 13 Oct 2026 01:40:53 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 59/86] hw/intc/arm_gicv5: Populate VM cache when VM table becomes valid Date: Tue, 13 Oct 2026 09:39:06 +0100 Message-ID: <20261013083933.1024405-60-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881148347158500 Content-Type: text/plain; charset="utf-8" Unlike the IST data structure, the VM table entries are allowed to be set up in guest memory with the VALID bit set, so that the VM becomes valid when whe VM table is made valid (e.g. by setting up the L1 VM table in IRS_VMT_BASER, or by making an L2 VM table valid through IRS_VMAP_L2_VMTR). So we need to scan through the VM table in memory to populate the hash table when these things happen. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 80 +++++++++++++++++++++++++++++++- include/hw/intc/arm_gicv5_regs.h | 3 ++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index b66bc5b95df..3e8b20b6e9a 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1257,6 +1257,72 @@ static void cache_vmte(GICv5Common *cs, GICv5Domain = domain, trace_gicv5_cache_vmte(domain_name[domain], vmid); } =20 +static void fill_vmt_cache_from_l2_vmt(GICv5Common *cs, GICv5Domain domain, + GICv5VMTConfig *cfg, hwaddr l2_addr, + hwaddr l2_limit, uint32_t vmid) +{ + /* + * Scan an L2 VM table in guest memory, and populate our VMT + * cache for each entry that is marked as valid. + */ + for (; l2_addr < l2_limit; l2_addr +=3D 32, vmid +=3D 1) { + uint64_t l2_vmte[L2_VMTE_WORDS]; + + if (!read_first_vmte_word(cs, cfg, l2_addr, l2_vmte)) { + goto txfail; + } + if (FIELD_EX64(l2_vmte[0], L2_VMTE_0, VALID) =3D=3D 0) { + continue; + } + if (!read_other_vmte_words(cs, cfg, l2_addr, l2_vmte)) { + goto txfail; + } + cache_vmte(cs, domain, cfg, vmid, l2_vmte, l2_addr); + } + +txfail: + /* Reportable with EC=3D0x0 if sw error reporting implemented */ + qemu_log_mask(LOG_GUEST_ERROR, "L2 VMTE read failed for VMID 0x%x at " + "physical address 0x" HWADDR_FMT_plx "\n", vmid, l2_addr= ); +} + +static void fill_vmt_cache_from_l1_vmt(GICv5Common *cs, GICv5Domain domain, + GICv5VMTConfig *cfg) +{ + /* + * Scan the whole VM table in guest memory, and populate our VMT + * cache for each entry that is marked as valid. + */ + if (!cfg->structure) { + hwaddr l2_limit =3D cfg->base + (1ULL << cfg->vm_id_bits) * L2_VMT= E_BYTES; + + fill_vmt_cache_from_l2_vmt(cs, domain, cfg, cfg->base, l2_limit, 0= ); + } else { + uint32_t vmid =3D 0; + hwaddr l1_limit =3D l1_vmte_addr(cs, cfg, (1ULL << cfg->vm_id_bits= )); + + for (hwaddr l1_addr =3D cfg->base; + l1_addr < l1_limit; + l1_addr +=3D 8, vmid +=3D VMT_L2_TABLE_SIZE / L2_VMTE_BYTES) { + MemTxResult res; + uint64_t l1_vmte; + hwaddr l2_addr; + + l1_vmte =3D address_space_ldq_le(&cs->dma_as, l1_addr, + cfg->txattrs, &res); + if (res !=3D MEMTX_OK) { + continue; + } + if (FIELD_EX64(l1_vmte, L1_VMTE, VALID) =3D=3D 0) { + continue; + } + l2_addr =3D l1_vmte & R_L1_VMTE_L2_ADDR_MASK; + fill_vmt_cache_from_l2_vmt(cs, domain, cfg, l2_addr, + l2_addr + VMT_L2_TABLE_SIZE, vmid); + } + } +} + /* Data we need to pass through to irs_clean_lpi_cache_entry() */ typedef struct CleanLPICacheUserData { GICv5Common *cs; @@ -1461,6 +1527,9 @@ static void irs_vmt_baser_write(GICv5 *s, GICv5Domain= domain, uint64_t value) =20 cfg->valid =3D true; =20 + /* The VMT may already have some VMTEs with VALID=3D1 */ + fill_vmt_cache_from_l1_vmt(cs, domain, cfg); + trace_gicv5_vmt_valid(domain_name[domain], cfg->base, cfg->vm_id_bits, cfg->structure); } @@ -1472,7 +1541,7 @@ static void irs_vmap_l2_vmtr_write(GICv5 *s, GICv5Dom= ain domain, uint64_t value) GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; uint32_t vmid =3D FIELD_EX64(value, IRS_VMAP_L2_VMTR, VM_ID); bool m =3D FIELD_EX64(value, IRS_VMAP_L2_VMTR, M); - hwaddr l1_addr; + hwaddr l1_addr, l2_addr; uint64_t l1_vmte; MemTxResult res; =20 @@ -1514,6 +1583,15 @@ static void irs_vmap_l2_vmtr_write(GICv5 *s, GICv5Do= main domain, uint64_t value) goto txfail; } =20 + /* + * The L2 VM table we just made valid can have VMTEs which + * already have VALID=3D1 set: read them into the VM cache. + */ + l2_addr =3D l1_vmte & R_L1_VMTE_L2_ADDR_MASK; + fill_vmt_cache_from_l2_vmt(cs, domain, cfg, l2_addr, + l2_addr + VMT_L2_TABLE_SIZE, + vmid & ~MAKE_64BIT_MASK(0, VMT_L2_IDX_BITS)= ); + trace_gicv5_vmap_l2_vmtr(domain_name[domain], vmid); =20 return; diff --git a/include/hw/intc/arm_gicv5_regs.h b/include/hw/intc/arm_gicv5_r= egs.h index 51ea451b6b6..f1ebbb6aaf8 100644 --- a/include/hw/intc/arm_gicv5_regs.h +++ b/include/hw/intc/arm_gicv5_regs.h @@ -296,12 +296,15 @@ FIELD(L2_VMTE_3, SPI_ID_BITS, 59, 5) =20 /* Size of L2 VMTE in 64-bit words */ #define L2_VMTE_WORDS 4 +/* ...and in bytes */ +#define L2_VMTE_BYTES (L2_VMTE_WORDS * sizeof(uint64_t)) =20 /* * L2 VMTEs are always 32 bytes, and the L2 table is always 4KB, * so the lower 7 bits in a VM ID index the L2 table. */ #define VMT_L2_IDX_BITS 7 +#define VMT_L2_TABLE_SIZE 4096 =20 /* * Format used for gicv5_request_config() return value, which matches --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881664; cv=none; d=zohomail.com; s=zohoarc; b=OqeDNQkBC3+kZkxUsepHyxpT2x+SYKNMlCW54djlk66BQXRHpV/hu853Y/wlgu7XUjtAVuippQo/ZMfz3HoEdmwF8fXK3V6Ej7ZdmvgZlb1C09aYmQ1T+o1g1/iao0cG1h6XbDzlNt7CaeQFgs8hlaRwBzkl1Isl+kNET7Hqe8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881664; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=cp3KantnVGijsCKr6brtTMcQWEyeFUMvGoR0UlMwu5w=; b=HyuKlbyVQMqLAvC+TY2AxkO6hf4Bf9NIB5IUObpIybVdGZVf5kB8MXeuEZDaK8D04Kq4JEgFfjqK+JepOhs/tQ99g+8a3W9ENt+/hh8ykkXYLNMiBgoLm2bwvwtXDM16VctyBy19CZgxvaY9aYAM2KUDa15+iWpLfRsubzE2kLc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881664843842.3821306609118; Tue, 13 Oct 2026 01:54:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8H-0006q3-Ac; Tue, 13 Oct 2026 04:45:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4B-0000Lr-AR for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:59 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY48-00086S-Fz for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:58 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a172eb31f0so20441265e9.1 for ; Tue, 13 Oct 2026 01:40:55 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880855; x=1792485655; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=cp3KantnVGijsCKr6brtTMcQWEyeFUMvGoR0UlMwu5w=; b=vs7+73FQhqUYiA3CeY25xps7e1jQCmcXz/8L+rUpPsDC66wLde6Y3Ga+/OBOfGl9wp Hv4SnUSbTQzwgD6MwtsxmV6wkxS/AwXUbB6tdtZT3n8xFFkqJaJFQ4CNvnQshm1bvg7h kdk/IjCCBSR5xR/EooBJ/AIcB++slyDsZRTpFj0j3ZuyzSm5PisJKNHWYBFRwQKCNF3Z VVYdEm7asxruD7RZS+F+nThmvHHJYPkmO/TVDVynmMay8tz920RLmCEni6SbHZXGaxMD 8ft9jsngdxYRGphwR7VSrgGnKa5iHZUERppRLtEa5u276EdGt8WtiD795QqkwMpBnwwx 9wmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880855; x=1792485655; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=cp3KantnVGijsCKr6brtTMcQWEyeFUMvGoR0UlMwu5w=; b=XGsYIINVAJstWCXQFNqoTVV9FJ0Oh18GMPepbFPh9LEtO6R+emK46XwJi3tj2bv7hD CUqeWz/EhVf+ITEvr32jizFNU+MB0i+p9UqNKgHuRegCITbbyE3gCYw2nVnO5O8nTY4q Rwa/HFo7UP+ChpJ5srtFmVMDER1UI9SD2VQD3w1WqOmYmvxYtRLhaGWwIXeKaC8m3C+K FjWRjE9tA/0Ai2zBp9jXSmNiLo3iWWVKcpRfMAgbO6ONLENoonln4QuiLgGwtU5I+Yvo jJCGqO/shwoXmA6OzwS8d7WCWo7+/OgJRxolmjCUUm/KG+RR6dlq0w3j3v5Cqh0kUEio d+jA== X-Forwarded-Encrypted: i=1; AKwUvBz8GRpprVJMatQuUEb4cPHwfEkZ/tPEDOCZQWde98RFQ+BBIKPGUDiJFIvSICxxZNRMMUyZKHuOP5R7@nongnu.org X-Gm-Message-State: AFq9FYKTAO9sfIY7KeZjuZW7pmAjpuC/ULkgvHyDHtYf2AO1hv84W8oh Ys42eWfsuOewkDj845LPgM+Hy9yndhH1r3CAkP0Zrbh+yOdE3uJBK50+mBB5lDaibHVFQPqCLXe bDiLBkLQ= X-Gm-Gg: AYBFou0YrAHrOC/iSxOfgfi16JM+OJ53Rb0+CtWaPPpi+y6cyMhAPAGYUxGDmo07BwZ Hmja8YQ26gvbrp82fUa93lUfqOTPGDw8eWkwfPMs9L3sLi3gdw3LpPG2ONj0AhOclRshAtck5Rw vh+TCrRy9A9G5tD+6iqdUDRjCJeugUnevJtIyJcBUD8DXhY+m3BcpM0IOq3xzGJYOYSRsgcOdmv 8QZjE+KaxjkCL9cgm+Bc3xRInsdmfi0V3ljJ1TsXGqkD6VllGAnDekDV6p5zz7h8nLxL3If0l7m 9K5G11szwil+eiS41nJEOi6Gd/S7RMiqJ7dQKV3rZnQKPQTknCq6GDwmg/2VBytitP4+oxQRXp6 pHZwxp4CyLG9eHpifbl8O6m1Lv98dz+5EtYrSiYLDVsWAcv3I9bHrgLBLwp/VNGOzvN6sWfYqCP J0vwL70qFzamZW86BPSkkBfBai1csLE4mjxwu3cU6aee6jvlglIxSqVGvwEKJwP/5uM1pBkaoZN b1TbsqJFNQeHfaSYchuvmvJVV0PvsCf1zIeDjjX0xAfluBGyNDwltNuOmRCfjJZith7vIerDNn9 ERs= X-Received: by 2002:a05:600c:46cf:b0:4a1:7e1f:21bc with SMTP id 5b1f17b1804b1-4a18e4d6636mr236952995e9.29.1791880854830; Tue, 13 Oct 2026 01:40:54 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 60/86] hw/intc/arm_gicv5: Implement IRS_VMAP_VISTR Date: Tue, 13 Oct 2026 09:39:07 +0100 Message-ID: <20261013083933.1024405-61-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881666218158500 Content-Type: text/plain; charset="utf-8" A VM in the VM table does not have to specify the LPI and SPI ISTs up-front. Instead, it can leave the VMTE LPI_IST_VALID or SPI_IST_VALID bits 0, and set up the IST later using IRS_VMAP_VISTR. The sequence here is: * software writes to the L2 VM table entry to set the configuration fields associated with the IST * software writes to IRS_VMAP_VISTR * the IRS reads the info from the L2 VM table entry, sets up the IST, and writes to the VALID bit in the L2 VM table entry Software can also use IRS_VMAP_VISTR to change an IST from valid to invalid. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 154 +++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 1 + hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_common.h | 1 + 4 files changed, 157 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 3e8b20b6e9a..1d6f2767d02 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1438,6 +1438,29 @@ static void irs_clean_vm_cache(GICv5Common *cs, GICv= 5VMTConfig *cfg) g_hash_table_foreach_remove(cfg->vm_cache, irs_clean_vm_cache_entry, &= ud); } =20 +static void invalidate_vlpi_ist_config(GICv5Common *cs, GICv5Domain domain, + VMTE *vmte) +{ + /* + * Make the VLPI IST invalid. The caller must also update the + * VALID bit in the L2 VMTE in guest memory. + * We must write any cached VLPI IST info back to guest memory, + */ + irs_clean_lpi_cache(cs, &vmte->lpi_ist); + vmte->lpi_ist.valid =3D false; +} + +static void invalidate_vspi_ist_config(GICv5Common *cs, GICv5Domain domain, + VMTE *vmte) +{ + /* + * Make the VSPI IST invalid. The caller must also update the + * VALID bit in the L2 VMTE in guest memory. + */ + irs_clean_lpi_cache(cs, &vmte->spi_ist); + vmte->spi_ist.valid =3D false; +} + static void irs_vmt_baser_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); @@ -1668,6 +1691,101 @@ txfail: "physical address 0x" HWADDR_FMT_plx "\n", vmid, l1_addr= ); } =20 +static void irs_vmap_vistr_write(GICv5 *s, GICv5Domain domain, uint64_t va= lue) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + uint32_t vmid =3D FIELD_EX64(value, IRS_VMAP_VISTR, VM_ID); + bool m =3D FIELD_EX64(value, IRS_VMAP_VISTR, M); + /* U =3D 0 for "make invalid", 1 for "make valid" */ + bool valid =3D !FIELD_EX64(value, IRS_VMAP_VISTR, U); + GICv5IntType type =3D FIELD_EX64(value, IRS_VMAP_VISTR, TYPE); + uint64_t l2_vmte[L2_VMTE_WORDS]; + MemTxResult res; + VMTE *vmte; + bool was_valid; + + if (!gicv5_domain_has_virt(cs, domain) || !cfg->valid) { + /* Whole register RAZ/WI if no virt or no VM table */ + return; + } + + /* M bit is WO/UNKNOWN; write the other fields */ + cs->irs_vmap_vistr[domain] =3D value & ~R_IRS_VMAP_VISTR_M_MASK; + + /* + * M =3D 0 and bad VMID must be ignored; invalid TYPE is + * UNPREDICTABLE, and we choose to ignore + */ + if (!m || vmid >=3D (1 << cfg->vm_id_bits) || + (type !=3D GICV5_LPI && type !=3D GICV5_SPI)) { + return; + } + + trace_gicv5_irs_vmap_vistr_write(domain_name[domain], vmid, + inttype_name(type), + valid ? "valid" : "invalid"); + + vmte =3D g_hash_table_lookup(cfg->vm_cache, GINT_TO_POINTER(vmid)); + if (!vmte) { + /* VM is not valid */ + return; + } + + was_valid =3D type =3D=3D GICV5_LPI ? vmte->lpi_ist.valid : vmte->spi_= ist.valid; + /* Ignore request to make IST valid/invalid when it already is so */ + if (valid =3D=3D was_valid) { + return; + } + + if (!read_first_vmte_word(cs, cfg, vmte->vmte_addr, l2_vmte) || + !read_other_vmte_words(cs, cfg, vmte->vmte_addr, l2_vmte)) { + goto txfail; + } + + switch (type) { + case GICV5_LPI: + l2_vmte[2] =3D FIELD_DP64(l2_vmte[2], L2_VMTE_2, LPI_IST_VALID, va= lid); + address_space_stq_le(&cs->dma_as, + vmte->vmte_addr + sizeof(uint64_t) * 2, + l2_vmte[2], cfg->txattrs, &res); + if (res !=3D MEMTX_OK) { + goto txfail; + } + + if (valid) { + initialize_vlpi_ist_config(cs, domain, vmte, l2_vmte); + } else { + invalidate_vlpi_ist_config(cs, domain, vmte); + } + break; + case GICV5_SPI: + l2_vmte[3] =3D FIELD_DP64(l2_vmte[3], L2_VMTE_3, SPI_IST_VALID, va= lid); + address_space_stq_le(&cs->dma_as, + vmte->vmte_addr + sizeof(uint64_t) * 3, + l2_vmte[3], cfg->txattrs, &res); + if (res !=3D MEMTX_OK) { + goto txfail; + } + + if (valid) { + initialize_vspi_ist_config(cs, domain, vmte, l2_vmte); + } else { + invalidate_vspi_ist_config(cs, domain, vmte); + } + break; + default: + g_assert_not_reached(); + } + return; + +txfail: + /* Reportable with EC=3D0x0 if sw error reporting implemented */ + qemu_log_mask(LOG_GUEST_ERROR, "L2 VMTE update failed for VMID 0x%x at= " + "physical address 0x" HWADDR_FMT_plx "\n", + vmid, vmte->vmte_addr); +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -1839,6 +1957,22 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_VISTR: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D extract64(cs->irs_vmap_vistr[domain], 0, 32); + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; + case A_IRS_VMAP_VISTR + 4: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D extract64(cs->irs_vmap_vistr[domain], 32, 32); + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; case A_IRS_SPI_STATUSR: /* * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect @@ -1979,6 +2113,15 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, irs_vmap_vmr_write(s, domain, deposit64(cs->irs_vmap_vmr[domain], 32, 32, dat= a)); return true; + case A_IRS_VMAP_VISTR: + irs_vmap_vistr_write(s, domain, + deposit64(cs->irs_vmap_vistr[domain], 0, 32, = data)); + return true; + case A_IRS_VMAP_VISTR + 4: + irs_vmap_vistr_write(s, domain, + deposit64(cs->irs_vmap_vistr[domain], + 32, 32, data)); + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; @@ -2087,6 +2230,14 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_VISTR: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D cs->irs_vmap_vistr[domain]; + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; } =20 return false; @@ -2108,6 +2259,9 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_VMAP_VMR: irs_vmap_vmr_write(s, domain, data); return true; + case A_IRS_VMAP_VISTR: + irs_vmap_vistr_write(s, domain, data); + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 19338ad5b9c..181171e000b 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -110,6 +110,7 @@ static void gicv5_common_reset_hold(Object *obj, ResetT= ype type) memset(cs->irs_vmt_cfgr, 0, sizeof(cs->irs_vmt_cfgr)); memset(cs->irs_vmap_l2_vmtr, 0, sizeof(cs->irs_vmap_l2_vmtr)); memset(cs->irs_vmap_vmr, 0, sizeof(cs->irs_vmap_vmr)); + memset(cs->irs_vmap_vistr, 0, sizeof(cs->irs_vmap_vistr)); } } =20 diff --git a/hw/intc/trace-events b/hw/intc/trace-events index cb3568fa80c..a086b14c825 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -250,6 +250,7 @@ gicv5_vmt_valid(const char *domain, uint64_t base, uint= 8_t vm_id_bits, bool stru gicv5_vmt_invalid(const char *domain) "GICv5 IRS %s VM table no longer val= id" gicv5_vmap_l2_vmtr(const char *domain, uint32_t vmid) "GICv5 IRS %s VM ID = %u now valid" gicv5_cache_vmte(const char *domain, uint32_t vmid) "GICv5 IRS %s VM ID %u= valid and cached" +gicv5_irs_vmap_vistr_write(const char *domain, uint32_t vmid, const char *= type, const char *what) "GICv5 IRS %s VM ID %u %s IST now %s" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 5707111b98a..19e13693de9 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -93,6 +93,7 @@ struct GICv5Common { uint32_t irs_vmt_cfgr[NUM_GICV5_DOMAINS]; uint64_t irs_vmap_l2_vmtr[NUM_GICV5_DOMAINS]; uint64_t irs_vmap_vmr[NUM_GICV5_DOMAINS]; + uint64_t irs_vmap_vistr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881651; cv=none; d=zohomail.com; s=zohoarc; b=gDZ0uRHlw9bVuRs7bVbWkN0T9NQwU7XZ4xmTEtl4N13srJemgmyIey7HW5Qz7KIw6IfajC2027NaKJYDgs50pUWkSicW2xNvJ64KgFh+5b4hvPt4ILxmqY7NOHFDHkEw9u91vkWci3plP2ZsWFvqfrQ6BOCOoTCmUV2GcHUo174= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881651; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=ssQOKL4yIVf/4dvvQm7DObQY0a7iM7G4sOvZS6fl620=; b=NVadBxZb+b7QsCG+h59uoOrh5SLhJ9ybg7IrzGnefyWmZUc9FGz3xRPjwHhZ+FnNN+2FcP01eZrE84nFj70buN9DKKxbGeAm79ZPSpr8BwXMDojzFJHRofnUhmVTMwwML9nDZndoCXs5ioJgFJ/LMmDj4I5jHR54ZSZ93dv8T10= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881651125740.6218717696765; Tue, 13 Oct 2026 01:54:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY7r-0005sk-Al; Tue, 13 Oct 2026 04:44:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4B-0000Ls-Al for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:59 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY49-00086h-7p for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:40:58 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a172eb31f0so20441435e9.1 for ; Tue, 13 Oct 2026 01:40:56 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880856; x=1792485656; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ssQOKL4yIVf/4dvvQm7DObQY0a7iM7G4sOvZS6fl620=; b=IgQZtzhque9JHBcSC8AyxFUfkDXgrZyskzAFdOTkqLVvcmJbUPG12HCQcNtSVsuEhH tT53uPllwb7uhhTb/5vVmLmLXkv4sHevccBHHWXByVvCWabyQkHsEFVPoU52nsT1Sy4H UuVazVw4Qup2lv/LQXWAQ3fY5Crba5RX2KT+WJo2EyZgIHielt6FG5WOJ7MxGXNeKfZ3 xBa8HK8RK7G3aeMVzs4rEk/Y+T5p7aB25uMvWW5bAxUWdf0CL5fiFxlAyA/ikvui+X2B fkeSMMFPxo/+/K2D+1KWAcLXJcmzoJZsiVcN6+FBwfTz6P3rq/YwaPhxqoyOwxPaPREp gwYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880856; x=1792485656; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=ssQOKL4yIVf/4dvvQm7DObQY0a7iM7G4sOvZS6fl620=; b=a02ntYAll5jOemDaUDHSwKjNg4Fuoawmi2Dd0BAXX3wksWzTbmYY0z5Br6PLh3Twkl hdVNyj9gdjGJoerhHhJgCIzSuFnpMwqO8n8LAs2yfElq06qY8nUSYWb3PKGlfDdycCFS F1zYIZuxRjn6v2DS6F4zK1FhjkCbrhZLG7Q/VES1QOEBdj5CqoNLn8iMVkOT84GCb+os qzl4J8rrDS0uTDPtYBtFKrcr4zKHZjjSxJaIBxA2zM0s7QAqCn1/wSOAk8ejivNTkdDZ ext3NFv2Qe1+AE+IxMgkOE0m5xgIaA618GcIMuWc1XgPCO6wsAINilMg0Iv9FEr2fEL/ Itdg== X-Forwarded-Encrypted: i=1; AKwUvBz+fMIj4EDPAyen7DVOPrVPH+nfzzVHIbp9/GXhou09pumeUAY0ELnQSjpRpVKF8rQI3jrbcLvRawX5@nongnu.org X-Gm-Message-State: AFq9FYLMlDt/zcNdDV0cGXjCBYnLeKMzH64mxzaUhVio1QHlhll30tyP L/xxe1uwZVq+CGELsLrRN6r4sd6pJgicl3kMv8touqkFv5L5D7yxqihelGRXza9O5IxQR9lvCre GusG+Kqg= X-Gm-Gg: AYBFou3FwV9li3GCnaU1TSC1bdihkOLAeWmi8raLaUB8DUpaP6ASk+lD2njlcDO9y8d XkWPu+wkjWk/fJDGxlZtMBpzKStgVUAlaHqLEGzhQvC2svulATQyW7VyEu3/1xleV4g5hRiPuSQ nPIarVlr6CRX4xtR5KreLNIQxcX0PM/CCH/YniWVBrvPXCb0XZxgUhXGCso+DxHC4KHfWWBaQWi v/EYLuezGj1T4L+Yzqkg9jKA+PNls40Jey1SLkoe5YvvhiBPxmCTwWFPhfCKd3gNXhwRmCDDVOk xHv4QecFmwAO1qilI5AvNUrb0QKqMhiiqFOgP7MT4Hj2uRv20+C+gXvKyR0AwcdXd8wD2JLgflg 44h7Dj30U0sXc5AGKVM6gaeUq1irLHl37MZN8IEhB4zslmvG8xAdQHbClzSY/MZMJPAn7VLYkXn ew4JYLYEg3/AI9yr6zbKSBb2ohDtR8LCtNNWo2oRgSShEOifnUm//0AdSrEFY/LXQ0Vwp3+MR57 EOgP6HaYnX9rk3LOs3+6kDpAmWzHlPrHgC4YumDF8RIwUr+myRN8vHI6TzZuV656R58uz2fIIBy rAg= X-Received: by 2002:a05:600c:4e8a:b0:4a1:78dd:dd28 with SMTP id 5b1f17b1804b1-4a18e4d2b31mr235366395e9.27.1791880855762; Tue, 13 Oct 2026 01:40:55 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 61/86] hw/intc/arm_gicv5: Factor out "make an L2 IST valid" function Date: Tue, 13 Oct 2026 09:39:08 +0100 Message-ID: <20261013083933.1024405-62-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881651978158500 Content-Type: text/plain; charset="utf-8" irs_map_l2_istr_write() makes the L2 IST for a specified interrupt valid by finding the L1 ISTE and setting its valid bit. For virtualization, we want to do something similar for the ISTs used for virtual LPIs and SPIs. Factor out the "do the work" part of the function from the specifics of the IRS_MAP_L2_ISTR register. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 1d6f2767d02..3fac52012b1 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1096,11 +1096,8 @@ static void initialize_ist_config(GICv5Common *cs, G= ICv5Domain domain, cfg->valid =3D true; } =20 -static void irs_map_l2_istr_write(GICv5 *s, GICv5Domain domain, uint64_t v= alue) +static void map_l2_istr(GICv5Common *cs, GICv5ISTConfig *cfg, uint32_t int= id) { - GICv5Common *cs =3D ARM_GICV5_COMMON(s); - GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; - uint32_t intid =3D FIELD_EX32(value, IRS_MAP_L2_ISTR, ID); hwaddr l1_addr; uint64_t l1_iste; MemTxResult res; @@ -1138,6 +1135,15 @@ txfail: "physical address 0x" HWADDR_FMT_plx "\n", intid, l1_add= r); } =20 +static void irs_map_l2_istr_write(GICv5 *s, GICv5Domain domain, uint64_t v= alue) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; + uint32_t intid =3D FIELD_EX32(value, IRS_MAP_L2_ISTR, ID); + + map_l2_istr(cs, cfg, intid); +} + bool gicv5_set_resident(GICv5Common *cs, GICv5Domain domain, bool valid, uint32_t vpeid, bool db, uint8_t dbpm, uint32_t vm= id, uint32_t cpuidx) --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881657; cv=none; d=zohomail.com; s=zohoarc; b=a7LpmVmXZZ+aZy9t5OxU6pen41OMLOvj4/Bfn6l8xHrJmdf8u0zIRlaci3MD5U467poaLKpOzp5rf3XZ4lkh1sKPoQNvGo5TKbhfb6BVhCP1mM84UvMSrAczcVio6/wR/m8eviEICfNVxj77BkoCPhknEPRMiMD7gkJ81C91GeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881657; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=JeOIoH2LSOLlBPlR5f+UjDEd3AJlW/SfZVgno9HVm5A=; b=bD05qLqi2NS9GXD8HDZfNrFsV+4ykXH8prPSj3cEkZI5/5ko4Kwg/v95biIxoyur0PRcqkAN+7iah0xO49LIr5S9CfuRViY0GSrT7GrVerstzHNdu7r/gkdVi5J+W2Kqrl0TeiPTFlRry2YplTCWfdOgaJRzGBVlqkKv4CuV3UE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188165727835.00870440444214; Tue, 13 Oct 2026 01:54:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8H-0006pu-9r; Tue, 13 Oct 2026 04:45:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4F-0000WH-Kk for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:04 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4B-000872-24 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:03 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4a1ad2e2391so2929415e9.0 for ; Tue, 13 Oct 2026 01:40:57 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880857; x=1792485657; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=JeOIoH2LSOLlBPlR5f+UjDEd3AJlW/SfZVgno9HVm5A=; b=CwgpavYes32Q45/mmvtVjk/KPmuv5OdKePMV37DaFYNXY59/wAgMKgpHgiBRYTnowt g29liBmVASCri7IyQ0qgvjaQu0RisYSI/JV/Vc+uY4qmOunvj/NXuWUnvAZhnB4PJVkK TohtAupg3dK1Fv40/R0recOKgTSRtHjvjGw1rB2gSzYwy4mQz7yjzMJ72RFuDBjJnRv5 n+wRAg0HFg/905LrEC8G4tupVetPhC+rPdeuDDcs974n6f4Z1YJc/p4L3J8SXIXltjFn 6k2J3Y/eTiwhOavv6HFgg7/R4x9vTxAj3bcpKRwOD5U2gb2PcNGgPBPgQRm5TDoqdrCb +upw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880857; x=1792485657; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=JeOIoH2LSOLlBPlR5f+UjDEd3AJlW/SfZVgno9HVm5A=; b=2Nffn3qkUhzgtuntoH8CjQ21paznU8kacARZN+B3oGDWd7Olh3bR02HQOkBGGxsNVA gM6qPz8oOWH0xlq8HxywtMoPQ79Zc5pHeFH9lNIvqCyX60vabezWzbr6+fi3yaPhlc5H CzouBezPXDCwVrqPzun6fwyLNg8FI860kLxQLX+B7KSMnwDKQbXD207CqDafapBhE32B 0Pfdh8ytLrdKIUrbWroP7HQTzYxlD1XnPTQoHkuWniw3kDmK7EdqOOrN9fPv+vp3SdG7 CsxuyMSjoKJAXkaPuw7PCl6Ur9e1Jfc5MoFIuZ44CF2Rbogmeu+soxRAmjZ52PgH3May 81ew== X-Forwarded-Encrypted: i=1; AKwUvByclJorgpVm/t84hz4m8PC8Fq7fOEebjFf+49O5EI+BwuDqrBGH0Of5ZBKRWxh3hL3hISJaNK/FYWIX@nongnu.org X-Gm-Message-State: AFq9FYLyZUz6MmI81WjMK/GDiS959ELRNgYvd6EcA/O0OA+nXGVmZ8qh kJVDWO3JfS4LhzGgKUhQ3NpwpKTFba1HJb8kBFitK6nrWFvIIRp3ONIgxqkBzMKxai5PXmXj4Ha LU2f+ocs= X-Gm-Gg: AYBFou3Djm+ADr2Jc73wlyTYXxxOVKN6BOgySqv7lhD4JK2O0xyVktkmkUXe9qvPSyq VxBY4IZscvP37wZNKMza40WUHbKueYNbed91MbcBUUIPy17s3YgKgvmOGGFWgnVdg4H2+Z0tVJA I6U0mgsi5TQXTbWdrQ+WdXmbm/Cra0Yz6aBVcQSm+w7+CAHKUTBgyl2Wh2TRV1HvPepayczZ5th SHwe65+8aYAQQ9V4a3zmQITf97ipSPBoV9zkKnay5VDdKF3KhGh0sm6nYwldHxA0Lds6AeMwc4M Mc+I3gn1AHZRv093HmRNzSXyo6NUPsrxzEzbOa6PFpNim6V+haFkgOyJ8cNRyKdaZiUXhTbz5hm ZPDSU/KSTleZJ6Nup2ER2gnKaTA+Ith1LOvdGfiSNOI3fykNqYoMxXHh5wWWA9jPdJLEV02fzXT CUsuhkD9NUbg3V8phjjC5IUjbAO0ofkoa7mRQpcJQkkwKg+5nDudFjWLxMVmOnN7szFC4BcU28z n3q0io5+eltZOml/IjLBV4kA/4EDvHcX8BbNn8HNb4vOI4oJf26SN2vEKm9cc8Ow/h6ae/i2HWd 2B4= X-Received: by 2002:a05:600c:609b:b0:4a1:83f0:7c91 with SMTP id 5b1f17b1804b1-4a18e4ca1dcmr216950045e9.18.1791880856733; Tue, 13 Oct 2026 01:40:56 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 62/86] hw/intc/arm_gicv5: Implement IRS_VMAP_L2_VISTR Date: Tue, 13 Oct 2026 09:39:09 +0100 Message-ID: <20261013083933.1024405-63-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; 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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881658096158500 Content-Type: text/plain; charset="utf-8" The IRS_VMAP_L2_VISTR allows the guest to make an L2 entry in the VM's VLPI or VSPI IST valid; it is the equivalent of what IRS_MAP_L2_ISTR does for the physical LPI IST. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 76 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 1 + include/hw/intc/arm_gicv5_common.h | 1 + 3 files changed, 78 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 3fac52012b1..4f74236c62b 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1792,6 +1792,46 @@ txfail: vmid, vmte->vmte_addr); } =20 +static void irs_vmap_l2_vistr_write(GICv5 *s, GICv5Domain domain, + uint64_t value) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + uint32_t vmid =3D FIELD_EX64(value, IRS_VMAP_L2_VISTR, VM_ID); + bool m =3D FIELD_EX64(value, IRS_VMAP_L2_VISTR, M); + uint32_t intid =3D FIELD_EX64(value, IRS_VMAP_L2_VISTR, ID); + GICv5IntType type =3D FIELD_EX64(value, IRS_VMAP_VISTR, TYPE); + VMTE *vmte; + GICv5ISTConfig *vist; + + if (!gicv5_domain_has_virt(cs, domain) || !cfg->valid) { + /* Whole register RAZ/WI if no virt or no VM table */ + return; + } + + /* M bit is WO/UNKNOWN; write the other fields */ + cs->irs_vmap_l2_vistr[domain] =3D value & ~R_IRS_VMAP_L2_VISTR_M_MASK; + + /* + * M =3D 0 and bad VMID must be ignored; invalid TYPE is + * UNPREDICTABLE, and we choose to ignore + */ + if (!m || vmid >=3D (1 << cfg->vm_id_bits) || + (type !=3D GICV5_LPI && type !=3D GICV5_SPI)) { + return; + } + + vmte =3D g_hash_table_lookup(cfg->vm_cache, GINT_TO_POINTER(vmid)); + if (!vmte) { + /* VM is not valid */ + return; + } + + vist =3D type =3D=3D GICV5_LPI ? &vmte->lpi_ist : &vmte->spi_ist; + + map_l2_istr(cs, vist, intid); +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -1979,6 +2019,22 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_L2_VISTR: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D extract64(cs->irs_vmap_l2_vistr[domain], 0, 32); + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; + case A_IRS_VMAP_L2_VISTR + 4: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D extract64(cs->irs_vmap_l2_vistr[domain], 32, 32); + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; case A_IRS_SPI_STATUSR: /* * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect @@ -2128,6 +2184,15 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, deposit64(cs->irs_vmap_vistr[domain], 32, 32, data)); return true; + case A_IRS_VMAP_L2_VISTR: + irs_vmap_l2_vistr_write(s, domain, + deposit64(cs->irs_vmap_vistr[domain], 0, 3= 2, data)); + return true; + case A_IRS_VMAP_L2_VISTR + 4: + irs_vmap_l2_vistr_write(s, domain, + deposit64(cs->irs_vmap_vistr[domain], + 32, 32, data)); + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; @@ -2244,6 +2309,14 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_L2_VISTR: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D cs->irs_vmap_l2_vistr[domain]; + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; } =20 return false; @@ -2268,6 +2341,9 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_VMAP_VISTR: irs_vmap_vistr_write(s, domain, data); return true; + case A_IRS_VMAP_L2_VISTR: + irs_vmap_l2_vistr_write(s, domain, data); + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 181171e000b..b52dba3d3b4 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -111,6 +111,7 @@ static void gicv5_common_reset_hold(Object *obj, ResetT= ype type) memset(cs->irs_vmap_l2_vmtr, 0, sizeof(cs->irs_vmap_l2_vmtr)); memset(cs->irs_vmap_vmr, 0, sizeof(cs->irs_vmap_vmr)); memset(cs->irs_vmap_vistr, 0, sizeof(cs->irs_vmap_vistr)); + memset(cs->irs_vmap_l2_vistr, 0, sizeof(cs->irs_vmap_l2_vistr)); } } =20 diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 19e13693de9..8103f14ba44 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -94,6 +94,7 @@ struct GICv5Common { uint64_t irs_vmap_l2_vmtr[NUM_GICV5_DOMAINS]; uint64_t irs_vmap_vmr[NUM_GICV5_DOMAINS]; uint64_t irs_vmap_vistr[NUM_GICV5_DOMAINS]; + uint64_t irs_vmap_l2_vistr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881226; cv=none; d=zohomail.com; s=zohoarc; b=n+sMaWK5APn3aNH4xDpzTNCzciQP8W5s2STUKQqvKpGT64q0seRsUM+dlGJjpIsEdyyLTE3+n6kFe6XH6POfapaT+id9HHYnYLXwVGRcOfa87DNR88dpqrvQPC4X5T2giNEuzwcTFsgKjf6FXay/pwqhDVll0XLcsve+Vmxb1vg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881226; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=y2YLtKEIJReIXSWDT6avZPvz6gFeM5i0piN3T0fzPwU=; b=cdUnxHNSZ6soz9yp6lnhpuzVs7UjzJ4GMkj2ti55KUt6mgSMRt6Yuudy0hACEstmdSGcrcVjXOA+MgSl4/FQWYOqL9MmDIQ9ZyTq6URMiQ8d/xwzLKoDu4jlXHkVYhQqTr08lZtR2eQNdebNOdyuD9BuVyEAz3lHIEyPpdIO5oI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881226309591.0642866937983; Tue, 13 Oct 2026 01:47:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY84-0006La-Ql; Tue, 13 Oct 2026 04:45:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4D-0000SH-KA for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:03 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4B-00087R-3S for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:01 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a161d9b8c7so18417395e9.3 for ; Tue, 13 Oct 2026 01:40:58 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880858; x=1792485658; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=y2YLtKEIJReIXSWDT6avZPvz6gFeM5i0piN3T0fzPwU=; b=Xf1bgs0z52iOXZqY35y1Zdd+HK8LSR1X4i0if4NoLUtPnJUgv80xLz/PmQXUhG2VSw Q/c6/ZzNJuECep2mM0pUie27KdIOgqJ11ZY2N2cekcckftTzrVIHN8xmAWArHk3/oEJz 7yv7bik2K5TcephdVqo1ljgbpqWf5kCllqFEjvDYeYNw+4IYj2OhMuw0DDEkwA4JNyuy ihGJpSvJjNk2jQu3Lx3CVrGwjf1Qk0+tHSpJLOhDw0uZ5D4GaCRgsIES62zfXFbDZAb0 u298rALfvqDFKNLRGWgwOiSZ5+azI058NjFq1ctnU/T80Z4MEDGA8s1bx7LamM1Ejav8 1LqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880858; x=1792485658; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=y2YLtKEIJReIXSWDT6avZPvz6gFeM5i0piN3T0fzPwU=; b=dLYr3s/O16mcNnzltj+iuhqYZDYiXDzlFSerOd+ALl1TNeM6wq00AazilDdI84OfQu 4XXrtPPOXwibChQLtqHOf6El3H6e6s/76yiWE1ZqnZVrvIBVbcKzDhi2kxjojv6gw4iO Mka5RaC1s2NwymOfBdsf2VE/RQBxsacxpmlZau7tZ5iH5eH4pc3KEaIMRzg+lnQNhHDU 4G2FEZTii7qiqrZ+/t1uKKZvSymDF/r4KKB1zer4qsN1NxJ7R7Z5lDVlAk970k57PNlI BCJ0zQSCsTogSlbBKnZbfdK+fT0jHjwwbndrlS1IjNcMvat/xU+t6Ktq71tI935SelUt 2twQ== X-Forwarded-Encrypted: i=1; AKwUvByb5FqX7ICJMpX+qa62czRQLKYOAZ68s3uAzt1aENDFeh1sJxT5x+STu8mm36Vdo+tc4s3aCw8lVAOT@nongnu.org X-Gm-Message-State: AFq9FYKyTc0UotdyAtGsk9mCQNBKTp2luRZdTlSKvIvAs+9EEHp2AiIO oKVzTX1ILmZ09EMcWuQPeOgsRUkHb902SV+3d+oa+h6ZjE7qCns97a+2rym4UwmndmA= X-Gm-Gg: AYBFou2JzhXOMpaIPIIVkb2T6nuk3x3CmfiealTgxJ8jK1ezmXauB8rlaF2A3dXDmLL wclOOGQKnbif7EJmd0GxtQ5tKA2P8L411DxSxN6Mkv/7Ny3h5xTYr9anvG2RS40WNDsrmheNUk9 dxPZudqqiR3aDATh613krxNNlmbhofRiyMDQUXoRfhE90GUi7jbfJj7abW/lCflU7bld95m0qgT tWSzexVPn/WUiYSmv2ldkl3z1+7rN+5gctyBxFBmy0gdl9/wWAtXpSraHskPOYeJqzBx8jbQWdj lChQbPO+hv0wCcwtgUdKlW7PuTbTBG8cQNAnca+kdzlMEB77U/v0LZMaZ6GTkgK9pZvimPtEH3V pV7kq54fyS/h2sVRygElv1FLFGfVS6y6DDMG9/g+PqyEHXcsjd9uQitDCv+/1ghT1wPQsupSkjN sSYNROC+V9jH+6iujgAGX6ebjdILSgwa5cEgBaMjqEIFzzOtJXAGRYakEa308QCfQHW8XTn6Gzg eZ35LtLTTu4GQCMtQ8gPSO9r2hnu3c8gqW4XkOAUYnRsCIOz+nmGYvaRvTRpUqfygclAasqL6Xi NJQ= X-Received: by 2002:a05:600c:1d20:b0:49f:fd40:80fa with SMTP id 5b1f17b1804b1-4a18e4f50ecmr237606565e9.34.1791880857652; Tue, 13 Oct 2026 01:40:57 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 63/86] hw/intc/arm_gicv5: Cache VPE table information Date: Tue, 13 Oct 2026 09:39:10 +0100 Message-ID: <20261013083933.1024405-64-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881227882158500 Content-Type: text/plain; charset="utf-8" Each VM has a VPE table which is a single linear table with an entry for each possible vCPU in the VM. Each VPE has a 'valid' bit and a pointer to a VPE descriptor which has IMPDEF contents. When the VM is made valid, the table can contain a mix of already-valid and not-yet-valid VPEs. Cache this information. Since the GICv5 architecture requires a simple linear table here, we can assume that the guest is unlikely to populate it sparsely, so we use a simple array rather than a hashtable. We will gradually expand the information we put into our VPE struct, but for now we just have a boolean tracking whether the VPE is valid or not, the guest address of the VPED, and a back-pointer to the VMTE. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 62 ++++++++++++++++++++++++++++++-- hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_regs.h | 3 ++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 4f74236c62b..c3d824f045b 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -23,10 +23,20 @@ =20 OBJECT_DEFINE_TYPE(GICv5, gicv5, ARM_GICV5, ARM_GICV5_COMMON) =20 +typedef struct VMTE VMTE; + +/* Cached per-VPE information, from VPE and VPE descriptor */ +typedef struct VPE { + VMTE *vmte; + hwaddr vped_addr; + bool valid; +} VPE; + /* In the GICv5VMTConfig::vm_cache this is how we store VMTE info */ -typedef struct VMTE { +struct VMTE { GICv5ISTConfig lpi_ist; GICv5ISTConfig spi_ist; + VPE *vpet; /* Address of the in-memory L2_VMTE for this VMTE */ hwaddr vmte_addr; hwaddr vpet_addr; @@ -35,7 +45,7 @@ typedef struct VMTE { GICv5Domain domain; /* We don't cache the VMD_ADDR as we don't use VMDs */ /* We don't cache VALID: the existence of this struct implies VALID=3D= 1 */ -} VMTE; +}; =20 static const char *domain_name[] =3D { [GICV5_ID_S] =3D "Secure", @@ -101,6 +111,8 @@ static void VMTE_free(void *data) g_hash_table_destroy(vmte->spi_ist.lpi_cache); } =20 + g_free(vmte->vpet); + g_free(vmte); } =20 @@ -1219,6 +1231,51 @@ static void initialize_vspi_ist_config(GICv5Common *= cs, GICv5Domain domain, id_bits, istsz, l2sz, structure); } =20 +static void init_vpe_from_vpete(VPE *vpe, VMTE *vmte, uint64_t vpete) +{ + /* Given the value of the in-memory VPETE, set up one VPE struct */ + vpe->vmte =3D vmte; + vpe->valid =3D FIELD_EX64(vpete, VPETE, VALID); + if (vpe->valid) { + vpe->vped_addr =3D vpete & R_VPETE_VPED_ADDR_MASK; + vpe->vped_addr &=3D ~MAKE_64BIT_MASK(0, QEMU_GICV5_VPED_SZ); + } +} + +static void initialize_vpet(GICv5Common *cs, GICv5Domain domain, + GICv5VMTConfig *cfg, VMTE *vmte) +{ + /* + * Allocate our cached VPE table, and populate it from guest memory. + * Note that (per R_DLKTX) the VPE descriptor is supposed to be all + * zeroes at this point, and behaviour is UNPREDICTABLE if it is not, + * so we do not need to read the descriptor here. In any case QEMU + * doesn't use the VPE descriptors. + */ + int num_vpes =3D 1 << vmte->vpe_id_bits; + hwaddr vpete_addr =3D vmte->vpet_addr; + + vmte->vpet =3D g_new0(VPE, num_vpes); + + for (int i =3D 0; i < num_vpes; i++, vpete_addr +=3D 8) { + MemTxResult res; + uint64_t vpete; + + vpete =3D address_space_ldq_le(&cs->dma_as, vpete_addr, + cfg->txattrs, &res); + if (res !=3D MEMTX_OK) { + qemu_log_mask(LOG_GUEST_ERROR, "VPET lookup failed for VPE 0x%= x" + " at physical address 0x" HWADDR_FMT_plx "\n", + i, vpete_addr); + return; + } + + init_vpe_from_vpete(&vmte->vpet[i], vmte, vpete); + trace_gicv5_initialize_vpet(domain_name[vmte->domain], vmte->vmid, + i, vmte->vpet[i].valid); + } +} + static void cache_vmte(GICv5Common *cs, GICv5Domain domain, GICv5VMTConfig *cfg, uint32_t vmid, uint64_t *l2_vmte, hwaddr l2_addr) @@ -1243,6 +1300,7 @@ static void cache_vmte(GICv5Common *cs, GICv5Domain d= omain, * it has 2^vpe_id_bits entries of 2^3 =3D=3D 8 bytes each */ vmte->vpet_addr &=3D ~MAKE_64BIT_MASK(0, vmte->vpe_id_bits + 3); + initialize_vpet(cs, domain, cfg, vmte); =20 /* * If the VALID bits are set for the LPI and SPI ISTs, we can read diff --git a/hw/intc/trace-events b/hw/intc/trace-events index a086b14c825..9057f83af57 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -251,6 +251,7 @@ gicv5_vmt_invalid(const char *domain) "GICv5 IRS %s VM = table no longer valid" gicv5_vmap_l2_vmtr(const char *domain, uint32_t vmid) "GICv5 IRS %s VM ID = %u now valid" gicv5_cache_vmte(const char *domain, uint32_t vmid) "GICv5 IRS %s VM ID %u= valid and cached" gicv5_irs_vmap_vistr_write(const char *domain, uint32_t vmid, const char *= type, const char *what) "GICv5 IRS %s VM ID %u %s IST now %s" +gicv5_initialize_vpet(const char *domain, uint32_t vmid, uint32_t vpeid, b= ool valid) "GICv5 IRS %s VM ID %u VPE %u starts as valid %d" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5_regs.h b/include/hw/intc/arm_gicv5_r= egs.h index f1ebbb6aaf8..f4243abd182 100644 --- a/include/hw/intc/arm_gicv5_regs.h +++ b/include/hw/intc/arm_gicv5_regs.h @@ -306,6 +306,9 @@ FIELD(L2_VMTE_3, SPI_ID_BITS, 59, 5) #define VMT_L2_IDX_BITS 7 #define VMT_L2_TABLE_SIZE 4096 =20 +FIELD(VPETE, VALID, 0, 1) +FIELD(VPETE, VPED_ADDR, 3, 53) + /* * Format used for gicv5_request_config() return value, which matches * the ICC_ICSR_EL1 bit layout. --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881331; cv=none; d=zohomail.com; s=zohoarc; b=WbEgHu7mP8DOxNypfC7LB9VMeS/0MEWZbQOfV9Pu5pZt+BBAYxCFJ8s3z98Hf8w+2hSToWpldzaPdYubEx+pN2qFRxI10dEKdjKgZlZ+LeL1Bvl3Ef7W0za6mLwLQ6RFwz+tga9RTe8kH3TOJg3w0vqx+FEcw8V5C9gdxH40guY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881331; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Hv2b30aoeb/vVaLxh8kGllfwSe/dat19ne3H7Em9MoA=; b=VoXSTOtp+UBoKPJEwekLFdMn7oTJAVDH7BX4e1JcXSC5prtvso18ORuHyBafWeo0Ga6fstMq6F8D5i4ysESJ0gdz1McadgxIKqyLNCIuFhB5AyiOO2vQlRuMlq2xHlhed3gzQyPHeflJAIlocUPM6K8f9/OoElGo7PW+xMO/iTc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881331082541.7921904723931; Tue, 13 Oct 2026 01:48:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY9Z-0001se-6Y; Tue, 13 Oct 2026 04:46:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4F-0000WB-KR for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:04 -0400 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 1xGY4C-00088G-GF for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:03 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4a0e1b0681bso19395205e9.3 for ; Tue, 13 Oct 2026 01:41:00 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880859; x=1792485659; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Hv2b30aoeb/vVaLxh8kGllfwSe/dat19ne3H7Em9MoA=; b=W2hrRBsZpmAyZ2b1z+XPfOqQFt8HdWQt6tu357k6OdNFMXkBa/HFwxYbwVv1v5cu4a bdTZt6nH2/wa+o/SR0YhQ90QHSakyF11FTq2td21p9CatRNPfb29dEm1cFOKm5SuwxsD 30BW7GfEasA51i6B44MSyztwmClAdrL2hAVulqx3Rcc6Gj85uodvcO1Qb8Hh9rs4r84z 1JREZrRLPzjeDSSNE1ON3o2hDFyWTdx0jKq0/I9eQtaELDzWPHH2PpE4vVWLG4Rhu8Eo eD3xjcREnDO7Xj+TmTPvIsD+OZUqA9tuJTSxnNgzzXHpBiyVugLB5nfev4QXZAcnjTuP OYFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880859; x=1792485659; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Hv2b30aoeb/vVaLxh8kGllfwSe/dat19ne3H7Em9MoA=; b=0Ej72as9p9MyLf5qkYW0y26+gQjVkLyU31x00wUZZ33dbmnGkv2lItcb+onXoP+ZuF ph4LZsXwTr1hv+FYPy3phzMLYwq0fXc2qhMKn2jofjeUQiMTegBVvjie/aWavk55xjDN fqAEFH8Hvs50+TyJGbNwz/dDGkquPrZs2wFhEiQ3GpdRQaBH1lQs9FC4dRyGHLgixtlz hhrT1X32M1MeBcbI/sE/XFAQcWVQ2PP0wXMZJC/8SGpAgVV4ol864P9Vx0HB5geq0tTB S0S+CV/xcMZVTA/MbWP2nxY7LAeeqQQa9vXF/sdKVbcq551b8Bf6jHF/nCVPDBAEIF1s FYKw== X-Forwarded-Encrypted: i=1; AKwUvBxC1KJe22iV4IkKUR362uyqIcZS8apdN5TJMXDcqYT71vi7QuBElrSBpKxnfIN5+RwNrnMFaBVxYoBz@nongnu.org X-Gm-Message-State: AFq9FYLZMCHwmHs1BmYuXxteg0pU9xrg9NA9owDAjP8YtLaWhqQijxp8 qzO33p5pqwCv1ZOO/zTCIfQVOBkOZW4KwWDk3s2gk0yd+BQ+aQmobVBFQv7rOatLpet/uA3VYsH Ly4CF/3Q= X-Gm-Gg: AYBFou0YlO6hTo6y+JqVlxBiWbUxw83nuACuARpf7/x6albldyWtoE1BmUR0c/z8Ruw up+AhJb5hAIfPGGr/jD1YYOA9CuPRRSQqfJOa+rluD2LA/Vcj44WA0eMGE/ye3Sd8siYc7I1NN+ INVV0j31sHUn7NCfYq0zR6CmPdeBB9Mv2iClJBCk9O7wP6bDLZKPhrusKO0+kWnkKxx4efVo9it ijnhAcj4FaQhEfXcZrf55WqLabeu6A+cmwqwemGTxStY2McbLgyyeRIgzXaZaAKoK7vMfYyMOcI LDeqB6bNE+uATNu9Edb0TrFH2dJ5KnR3X68qJ4lP2TXZ32AtAzl5FKnYSBz98CxIm1WGkocJ50y OEgCQR9+ov7XguCV4aR2CD0u+yb4hy5OyZ9XEdghYNbgMACPvfZ+QGfRv7i9ZZPWfJc0qD9ac/j YiwxJrFhXVXXOsxD4h+F3hdO7pe7rY6CquZ3Yg5sjKn/IrzxMmPLlw9Jd7IygZttrQz7z6orOh5 bg9WrUXCVwMWSkC6tV9oBt5AUx138F8YNqMfX+670vAjXzwK7InP0pvcVtO0M2iRd9OH7skGvCJ 5kA= X-Received: by 2002:a05:600c:6097:b0:49f:bd3c:bc24 with SMTP id 5b1f17b1804b1-4a18e4b8885mr219396175e9.31.1791880858916; Tue, 13 Oct 2026 01:40:58 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 64/86] hw/intc/arm_gicv5: Implement IRS_VMAP_VPER Date: Tue, 13 Oct 2026 09:39:11 +0100 Message-ID: <20261013083933.1024405-65-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881331897158500 Content-Type: text/plain; charset="utf-8" The IRS_VMAP_VPER allows software to mark a VPE as valid if it was not originally valid when the VM was created. For us this means updating the valid bit in our cached VPE struct and in the VPE table in guest memory. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 94 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 1 + hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_common.h | 1 + 4 files changed, 97 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index c3d824f045b..e762c058a98 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1890,6 +1890,65 @@ static void irs_vmap_l2_vistr_write(GICv5 *s, GICv5D= omain domain, map_l2_istr(cs, vist, intid); } =20 +static void irs_vmap_vper_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + bool m =3D FIELD_EX64(value, IRS_VMAP_VPER, M); + uint32_t vmid =3D FIELD_EX64(value, IRS_VMAP_VPER, VM_ID); + uint32_t vpeid =3D FIELD_EX64(value, IRS_VMAP_VPER, VPE_ID); + VMTE *vmte; + hwaddr vpete_addr; + MemTxResult res; + uint64_t vpete; + + if (!gicv5_domain_has_virt(cs, domain) || !cfg->valid) { + /* Whole register RAZ/WI if no virt or no VM table */ + return; + } + + /* M bit is WO/UNKNOWN; write the other fields */ + cs->irs_vmap_vper[domain] =3D value & ~R_IRS_VMAP_VPER_M_MASK; + + /* M =3D 0 and bad VMID must be ignored */ + if (!m || vmid >=3D (1 << cfg->vm_id_bits)) { + return; + } + + vmte =3D g_hash_table_lookup(cfg->vm_cache, GINT_TO_POINTER(vmid)); + if (!vmte) { + /* VM is not valid */ + return; + } + + if (vpeid >=3D (1 << vmte->vpe_id_bits) || vmte->vpet[vpeid].valid) { + /* Invalid VPE ID, VPE already valid */ + return; + } + + vpete_addr =3D vmte->vpet_addr + vpeid * 8; + vpete =3D address_space_ldq_le(&cs->dma_as, vpete_addr, cfg->txattrs, = &res); + if (res !=3D MEMTX_OK) { + goto txfail; + } + vpete =3D FIELD_DP64(vpete, VPETE, VALID, 1); + address_space_stq_le(&cs->dma_as, vpete_addr, vpete, cfg->txattrs, &re= s); + if (res !=3D MEMTX_OK) { + goto txfail; + } + + init_vpe_from_vpete(&vmte->vpet[vpeid], vmte, vpete); + trace_gicv5_irs_vmap_vper_write(domain_name[domain], vmte->vmid, vpeid= ); + + return; + +txfail: + qemu_log_mask(LOG_GUEST_ERROR, + "VPETE update failed for VMID 0x%x VPEID 0x%x at " + "physical address 0x" HWADDR_FMT_plx "\n", + vmid, vpeid, vpete_addr); +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -2093,6 +2152,22 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_VPER: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D extract64(cs->irs_vmap_vper[domain], 0, 32); + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; + case A_IRS_VMAP_VPER + 4: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D extract64(cs->irs_vmap_vper[domain], 32, 32); + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; case A_IRS_SPI_STATUSR: /* * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect @@ -2251,6 +2326,14 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, deposit64(cs->irs_vmap_vistr[domain], 32, 32, data)); return true; + case A_IRS_VMAP_VPER: + irs_vmap_vper_write(s, domain, + deposit64(cs->irs_vmap_vper[domain], 0, 32, da= ta)); + return true; + case A_IRS_VMAP_VPER + 4: + irs_vmap_vper_write(s, domain, + deposit64(cs->irs_vmap_vper[domain], 32, 32, d= ata)); + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; @@ -2375,6 +2458,14 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VMAP_VPER: + if (gicv5_domain_has_virt(cs, domain) && s->vmt_config[domain].val= id) { + *data =3D cs->irs_vmap_vper[domain]; + } else { + /* RAZ/WI if no virt or no VM table */ + *data =3D 0; + } + return true; } =20 return false; @@ -2402,6 +2493,9 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_VMAP_L2_VISTR: irs_vmap_l2_vistr_write(s, domain, data); return true; + case A_IRS_VMAP_VPER: + irs_vmap_vper_write(s, domain, data); + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index b52dba3d3b4..6e0e2295fde 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -112,6 +112,7 @@ static void gicv5_common_reset_hold(Object *obj, ResetT= ype type) memset(cs->irs_vmap_vmr, 0, sizeof(cs->irs_vmap_vmr)); memset(cs->irs_vmap_vistr, 0, sizeof(cs->irs_vmap_vistr)); memset(cs->irs_vmap_l2_vistr, 0, sizeof(cs->irs_vmap_l2_vistr)); + memset(cs->irs_vmap_vper, 0, sizeof(cs->irs_vmap_vper)); } } =20 diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 9057f83af57..79381c109b7 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -252,6 +252,7 @@ gicv5_vmap_l2_vmtr(const char *domain, uint32_t vmid) "= GICv5 IRS %s VM ID %u now gicv5_cache_vmte(const char *domain, uint32_t vmid) "GICv5 IRS %s VM ID %u= valid and cached" gicv5_irs_vmap_vistr_write(const char *domain, uint32_t vmid, const char *= type, const char *what) "GICv5 IRS %s VM ID %u %s IST now %s" gicv5_initialize_vpet(const char *domain, uint32_t vmid, uint32_t vpeid, b= ool valid) "GICv5 IRS %s VM ID %u VPE %u starts as valid %d" +gicv5_irs_vmap_vper_write(const char *domain, uint32_t vmid, uint32_t vpei= d) "GICv5 IRS %s VM ID %u VPE %u now made valid" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 8103f14ba44..c8574f66a63 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -95,6 +95,7 @@ struct GICv5Common { uint64_t irs_vmap_vmr[NUM_GICV5_DOMAINS]; uint64_t irs_vmap_vistr[NUM_GICV5_DOMAINS]; uint64_t irs_vmap_l2_vistr[NUM_GICV5_DOMAINS]; + uint64_t irs_vmap_vper[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881423; cv=none; d=zohomail.com; s=zohoarc; b=ClsRr9Ricpt2ljU3dNGOzzMfqMjtUdzLq9XbRe/mWCLu7QutqS/Do6ETrGiaBzsiZrT0VlUsSuAU7piuvuvVFZOCbjB3TCFdiLSBhhlmtJUKTcrhVlNp2+OED3dPxF49+NTTNTWbNPNSzowZt6a6zqme7rHrugl6Ii76K3p8sAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881423; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=ygpZg/mvzQQKJ/1xoj7eG0F4DZfu+BwkAHYN9lMKm6g=; b=MDfa5fqUMB1UzZma1DNlKF3nEd0ZJlmnaSxJypxYi20Tu+bmkOqT2HmkJpChFRy+R38GVa3LWIsuDDf5KdMFBDXO2+mpLG0sq8agXutY5rWDd2WTgR0EDbQqYRET7FaPfcF4nUHTMfZXWpzClozdiAlLZa3tr7W9VWPy0ROGmZE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881423613806.6701905720414; Tue, 13 Oct 2026 01:50:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8Y-0007JO-QP; Tue, 13 Oct 2026 04:45:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4H-0000Y4-3h for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:05 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4D-000899-FZ for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:04 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49d0da752ffso24464925e9.3 for ; Tue, 13 Oct 2026 01:41:00 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880860; x=1792485660; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ygpZg/mvzQQKJ/1xoj7eG0F4DZfu+BwkAHYN9lMKm6g=; b=pJTnhtmvffTNznFDfwhVZl4V48KTSZhimQECNxhBJbCnVlP1WJkIPLHDbx3nbnIwsp nub3VIau2sNsZ0/2Tere0HFCQJTSY7VNl6654yqSaqq+4LkAxi0eS/1IWMCWR/srBNKU EN9R0iUXzoKDHAAw3y/Iog6RN9QaSgwiZ9Quzvr2WRGSRrPOolgwjrR7vlh4I5Zi3uwJ lfAOMrUEZ6/i+pLfJ/4kkmgEmQXRNlL9VETtbym5ayfvVaDK5mxRVotV0/ts3zmQVtt5 ZBLaXXk1Jo0ZMJLp7sXb58i/70EeO+ZnfXfF/mNQ6Bv5T48/Po9ZVGJTpJLD2TAIlD+n yT9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880860; x=1792485660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=ygpZg/mvzQQKJ/1xoj7eG0F4DZfu+BwkAHYN9lMKm6g=; b=r2yxTXcU32eQGpVLPkuqFlMt4tciG4oQ740/E3/uNw9zyvcfLzh/GPg8EW1h/fXywz s9FGizUmUCtu/S9j1Y3wWIG+sen3+fmAXFbLhEW9M7D5TLgcGFcAoiCaN+CWfJ8/vR7Q rHJlVWumgG0xoUhr05cEmLQQIu2x753XXw6KJp9wxppqKn9/wyltk0JaZlmtDhawEcmv 0Jpvhd42eBdpY9FyWstLsqLnftKFllne0GByUmQsX1oQD8zp1TIk9RxUVGyZPLLdSrXl L0WJL2HnZKZDkS+prFQrjWJlYpS+cE0LyNWiQ0kQv43f7I3WBhvzzAqyjxtx24zZRuY1 Kfdw== X-Forwarded-Encrypted: i=1; AKwUvBzHyqBdnXcw8QBXIlAxF6aP9cmb6442Wgg32XbDsvW6gZdn6p0+fPin0+Jfw8YzJXklTsXq9iLpk/ko@nongnu.org X-Gm-Message-State: AFq9FYKvfUWct8oe6jvOzHo4WwTTAKwTA4qdB4ZKYcIrV2sCY0ZXxl/B LgKii+LLdLKngtkXY0IhN3nm3bFQGfXQWTSg89WlcqPah1oK9mVXOiyophXromcJAHpaiQnkZDF mcmtZeXQ= X-Gm-Gg: AYBFou2J0EAa/krGyfW6H1UIgbvl9Q079ku4HLyRBuJIh+msVIkmhjYUeupDDT0XXdb gU3JZtvzi10LXvoUCUVBvpIwxRg2C5DQmTwQrTdHd+wMxOlheC1X+AYhJsWPE/891isM4ar/sKv qKUljpkbQ5sMcCgkDGKE/MHBcaB4ivY7YzvHlk1YQz2WbX7sU2IHOUbLe7VIEAGxvO1QewnEnhL mowE0nRqvi4qLc14Gt8nKqmrLmh+uZOyWdgeh1WlkS7gHSwKj0/OAqJNOMTELrhEXKsFowVbpNm WOKWja1dQ6j9XX2I3gdrOigNQE5eDhs1R8nFDLyqWFv1Keqn6a83KQ5e5HuxdvWNfQGL7yWl/QB xXdoAYHVUJljaeB5o7/Iyh20pjxqr33qV4Cwqi6BaOUcbb7Umjo5sjNlUuxlXfKVVyYpjwpoTgt YIWJD2doydz/t/8Z0f5r2kzlPNEsxeRcK/UOsx7peW0kdhQ3J4Z01ML71FomKRdv9rEWBVOkt4W pKUSTzBgR3aIlCrHmAR0DqsnyIIheLHJhaKuovrI2jvwaD3ZBhZUYkQY5OnZjgHbjFHTCyVU2xj Is0= X-Received: by 2002:a05:600c:8716:b0:4a1:62b8:9aa1 with SMTP id 5b1f17b1804b1-4a18e44885dmr236716145e9.2.1791880859842; Tue, 13 Oct 2026 01:40:59 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 65/86] hw/intc/arm_gicv5: Implement IRS_VPE_SELR and IRS_VPE_STATUSR Date: Tue, 13 Oct 2026 09:39:12 +0100 Message-ID: <20261013083933.1024405-66-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881425963158500 Content-Type: text/plain; charset="utf-8" The IRS provides a set of registers to allow software to read and write the configuration of a VPE. IRS_VPE_SELR selects the VPE to operate on, IRS_VPE_STATUSR indicates whether that selection was successful, and other registers like IRS_VPE_DBR will then provide access to the config for the selected VPE. Implement IRS_VPE_SELR and IRS_VPE_STATUSR, for the "select a VPE" part of this mechanism. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 111 +++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 6 ++ hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_common.h | 2 + 4 files changed, 120 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index e762c058a98..455242596bc 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -116,6 +116,24 @@ static void VMTE_free(void *data) g_free(vmte); } =20 +static VPE *vpe_for_vpeid(VMTE *vmte, uint32_t vpeid) +{ + /* + * Return the VPE struct for the specified VPEID for this VM, or + * NULL if there is no such valid VPE. + */ + VPE *vpe; + + if (!vmte || vpeid >=3D (1 << vmte->vpe_id_bits)) { + return NULL; + } + vpe =3D &vmte->vpet[vpeid]; + if (!vpe->valid) { + return NULL; + } + return vpe; +} + static bool gicv5_domain_has_virt(GICv5Common *cs, GICv5Domain domain) { /* @@ -1949,6 +1967,56 @@ txfail: vmid, vpeid, vpete_addr); } =20 +static VPE *vpe_from_selr(GICv5 *s, GICv5Domain domain) +{ + /* + * Return the VPE for the VM/VPE indicated by the current value of + * IRS_VPE_SELR, or NULL if none. + */ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + uint32_t vmid, vpeid; + VMTE *vmte; + + if (FIELD_EX64(cs->irs_vpe_selr[domain], IRS_VPE_SELR, S) =3D=3D 0) { + return NULL; + } + + vmid =3D FIELD_EX64(cs->irs_vpe_selr[domain], IRS_VPE_SELR, VM_ID); + vpeid =3D FIELD_EX64(cs->irs_vpe_selr[domain], IRS_VPE_SELR, VPE_ID); + + if (!cfg->valid || vmid >=3D (1 << cfg->vm_id_bits)) { + return NULL; + } + + vmte =3D g_hash_table_lookup(cfg->vm_cache, GINT_TO_POINTER(vmid)); + return vpe_for_vpeid(vmte, vpeid); +} + +static void irs_vpe_selr_write(GICv5 *s, GICv5Domain domain, uint64_t valu= e) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + uint32_t status =3D R_IRS_VPE_STATUSR_IDLE_MASK; + VPE *vpe; + + /* RES0 if we don't have virt */ + if (!gicv5_domain_has_virt(cs, domain)) { + return; + } + + cs->irs_vpe_selr[domain] =3D value; + + vpe =3D vpe_from_selr(s, domain); + if (vpe) { + /* We successfully selected a valid VPE */ + status |=3D R_IRS_VPE_STATUSR_V_MASK; + } + + trace_gicv5_irs_vpe_selr_write(domain_name[domain], value, status); + + cs->irs_vpe_statusr[domain] =3D status; +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -2168,6 +2236,30 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VPE_SELR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(cs->irs_vpe_selr[domain], 0, 32); + } else { + /* RAZ/WI if no virt */ + *data =3D 0; + } + return true; + case A_IRS_VPE_SELR + 4: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(cs->irs_vpe_selr[domain], 32, 32); + } else { + /* RAZ/WI if no virt */ + *data =3D 0; + } + return true; + case A_IRS_VPE_STATUSR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D cs->irs_vpe_statusr[domain]; + } else { + /* RAZ/WI if no virt */ + *data =3D 0; + } + return true; case A_IRS_SPI_STATUSR: /* * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect @@ -2334,6 +2426,14 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, irs_vmap_vper_write(s, domain, deposit64(cs->irs_vmap_vper[domain], 32, 32, d= ata)); return true; + case A_IRS_VPE_SELR: + irs_vpe_selr_write(s, domain, + deposit64(cs->irs_vpe_selr[domain], 0, 32, data= )); + return true; + case A_IRS_VPE_SELR + 4: + irs_vpe_selr_write(s, domain, + deposit64(cs->irs_vpe_selr[domain], 32, 32, dat= a)); + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; @@ -2466,6 +2566,14 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VPE_SELR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D cs->irs_vpe_selr[domain]; + } else { + /* RAZ/WI if no virt */ + *data =3D 0; + } + return true; } =20 return false; @@ -2496,6 +2604,9 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_VMAP_VPER: irs_vmap_vper_write(s, domain, data); return true; + case A_IRS_VPE_SELR: + irs_vpe_selr_write(s, domain, data); + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 6e0e2295fde..553598e3178 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "hw/intc/arm_gicv5_common.h" #include "hw/intc/arm_gicv5_stream.h" +#include "hw/intc/arm_gicv5_regs.h" #include "hw/core/qdev-properties.h" #include "qapi/error.h" #include "trace.h" @@ -113,6 +114,11 @@ static void gicv5_common_reset_hold(Object *obj, Reset= Type type) memset(cs->irs_vmap_vistr, 0, sizeof(cs->irs_vmap_vistr)); memset(cs->irs_vmap_l2_vistr, 0, sizeof(cs->irs_vmap_l2_vistr)); memset(cs->irs_vmap_vper, 0, sizeof(cs->irs_vmap_vper)); + memset(cs->irs_vpe_selr, 0, sizeof(cs->irs_vpe_selr)); + + for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { + cs->irs_vpe_statusr[i] =3D R_IRS_VPE_STATUSR_IDLE_MASK; + } } } =20 diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 79381c109b7..edfbf7d7157 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -253,6 +253,7 @@ gicv5_cache_vmte(const char *domain, uint32_t vmid) "GI= Cv5 IRS %s VM ID %u valid gicv5_irs_vmap_vistr_write(const char *domain, uint32_t vmid, const char *= type, const char *what) "GICv5 IRS %s VM ID %u %s IST now %s" gicv5_initialize_vpet(const char *domain, uint32_t vmid, uint32_t vpeid, b= ool valid) "GICv5 IRS %s VM ID %u VPE %u starts as valid %d" gicv5_irs_vmap_vper_write(const char *domain, uint32_t vmid, uint32_t vpei= d) "GICv5 IRS %s VM ID %u VPE %u now made valid" +gicv5_irs_vpe_selr_write(const char *domain, uint64_t selr, uint32_t statu= s) "GICv5 IRS %s IRS_VPE_SELR written 0x%" PRIx64 " IRS_VPE_STATUSR now 0x%= x" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index c8574f66a63..5823a7f78a0 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -96,6 +96,8 @@ struct GICv5Common { uint64_t irs_vmap_vistr[NUM_GICV5_DOMAINS]; uint64_t irs_vmap_l2_vistr[NUM_GICV5_DOMAINS]; uint64_t irs_vmap_vper[NUM_GICV5_DOMAINS]; + uint64_t irs_vpe_selr[NUM_GICV5_DOMAINS]; + uint32_t irs_vpe_statusr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881392; cv=none; d=zohomail.com; s=zohoarc; b=FDMDhXB//MUeFFbM+uZ//W0Src8UBTvcHQq+7UEsxMpPKfL9dDFmV8+nCyppiKdc2U9Ar6nXZJ/mjg/oTSFIzRlsn0g9nWugcAaHaP3W3KCuWCgIP6YMxUbFnBCBmKODmbwF5bUlBv695/KCMH8g0WV4DrQxLUygKgmdb/dvF7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881392; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=CSbF49+sZ3UGdDTJ3sEVMBom5AzlLVf7M9E9FjQ6vGs=; b=FDIuJGBoT20WG18gpo3riRMtZ+Tk7InKzSpnlRqNv1g0vKbUdePX7gpxDLRJ0J30IhTzdMvUjIvaAM3BgZL53m9jgxFhigv/d3xDrbKn0h/kRnhQhwQXLOROsV3M3S4V8UwRIPjTGgY10vdbJgrUy6fpFw0N+ajwR75BLcg4LAM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881392421914.0289306322356; Tue, 13 Oct 2026 01:49:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8Y-0007Jr-RW; Tue, 13 Oct 2026 04:45:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4H-0000Y8-D6 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:05 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4E-00089c-L4 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:05 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-48afbd2c386so1448659f8f.3 for ; Tue, 13 Oct 2026 01:41:02 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880861; x=1792485661; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=CSbF49+sZ3UGdDTJ3sEVMBom5AzlLVf7M9E9FjQ6vGs=; b=vj9j4b2JGzUE2OE8URce1vjnlxSz+NFvhj+KA/yj8qmFtqQRWuEFGr463TZ0PiYhlf KPnii6G51pYUYa3dKhLzCh3PNPQk5bC7EtPbll5B3xw3SvXsdCvjFeuYpPJP78Oc2IdA VRGdERBafIwV2dNinkD9uRgsFw3ydWx5abgHZnqXm2/3tp+XxXVFCgWaX4RgVWQi6z2q 1taoFea7SrHfuy+vdc2bpOkK7vuEO3Jb4cbCucE0B59NezuSMS6utLcHFS6hzCyF9L08 mcTN52i8qK1s9L5I8/gUCgpX2wKAKnuq/q5fPt2Usu3Jh6PqGx75ICOFB5JGAydwgtTU AYOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880861; x=1792485661; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=CSbF49+sZ3UGdDTJ3sEVMBom5AzlLVf7M9E9FjQ6vGs=; b=aR/Y4xMvJYmpkFEZ5t05D7pWwI5J2+Tiy22JDH1LBNwaUo2fCu9r7Q26+BmRkqURkf 5/3P6obzxoQM5aZBuUdw7uBeG+aYLlj4y75MLa+x0xZzq28d5ER3cwgg2W8PfF/TK78k njlUrYZ+zDVCeUB9wXgZWlFRldh/4tsd5PB/uz3bo8Q8Wt2ZDBW3uu3Erzj8MOnT8+0C rhpfDT5iiNqOAOGbi26q5IF8ZY8zyVYloe6k33LsfnusApLjYOKQn8GfL4B5Ljum9B/b Wptpi8XuhZtfD/kGCljDJ+yjcTRo6PLL2ahJ3TcmCEmqwy4co56rXsqdggTsFT5imY3k Wz6w== X-Forwarded-Encrypted: i=1; AKwUvBy9NabCq/+jclL51xPlmQ1mh6IiqfAXHlg1iNdIICqw/TS8hu8dAlhPl0jJ/qB9dZ1D0x+Y2Df1PARL@nongnu.org X-Gm-Message-State: AFq9FYJygYMLfghO3w3zpZvRAm3ekD2775kMcA/+B+vhAKT1khIjyF6J PTSz5FZe+qpbjGEB23Jg/ZxaB/hpehDomXT3cj++ams+L8mQozQDSqH0qUJIa3YkYtqkwYglA/w i8B3bDyo= X-Gm-Gg: AYBFou064Myzucpeq9ad3GPUKj7/eT+nuKJgyPdgBNH8yoTSAlrd1AjR33aIAvTQAtJ bNPmLUAbD3WLMW0QeF4dwBi+IOUh6QbluIn7I7Ny0z6zpIWwSKGuQkLP7gQEN5n+0VVSCVp4nEN LcvmDygVfrxgwknCOrIrl3+PlyqYjOUxOsLEZCZ4SNbDejGhF83vw71jrZ+c5tU4Zwu44iBdRdo VVi7s4clmTeLVc/TTsGzlwxdWeHrQw1p/GOw3KjWdtihhYICSc2rm0gLuoDFEfs49coUbTbxXOA nDVB2NsR17hIfSOhgKRCm106xGEIFYTmKt+AQJYRbeTI5scZGgGrV5IcGfHADdi7Ebrp5OlE2Ll Vez58yg6LFlBxqUX0HlArYZckSm70wjg2fO67KQv9NW3r6BFByp+nqVxZsV/pAXi9BQcoukwdh2 flkAuFFGkBPSQpurjXL9mpxei/vT8R0wXeZ2qZ8JCd4spn8DsDx4Fv6ObfMU9TCKFp5Q1QgAvRr qqotGDRymun3nKOlkmBI9uhSlAg0xTNCmxIM3xWl7vKi1eWQ21LJpYwS+77KUg9mK/g5gLkBkSx bo4= X-Received: by 2002:a05:600c:609b:b0:49f:ce78:356d with SMTP id 5b1f17b1804b1-4a18e4c9944mr220069735e9.30.1791880860784; Tue, 13 Oct 2026 01:41:00 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 66/86] hw/intc/arm_gicv5: Implement IRS_VPE_DBR Date: Tue, 13 Oct 2026 09:39:13 +0100 Message-ID: <20261013083933.1024405-67-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881393095158500 Content-Type: text/plain; charset="utf-8" The IRS_VPE_DBR register provides access to the doorbell config of the VPE selected with IRS_VPE_SELR. The config is sampled into the register when SELR is successfully written. Writes to IRS_VPE_DBR will update the config if the VPE selected by IRS_VPE_SELR is still valid; if the VPE became invalid between the SELR write and the CR0/DBR write then IRS_VPE_STATUSR.V is updated to report this. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 105 ++++++++++++++++++++++++++++- hw/intc/arm_gicv5_common.c | 1 + hw/intc/trace-events | 2 + include/hw/intc/arm_gicv5_common.h | 1 + 4 files changed, 107 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 455242596bc..f7d2d4a7143 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -29,7 +29,11 @@ typedef struct VMTE VMTE; typedef struct VPE { VMTE *vmte; hwaddr vped_addr; - bool valid; + uint32_t db_intid; /* doorbell interrupt ID */ + uint8_t dbpm; /* doorbell priority mask */ + bool valid; /* is the VPE valid? */ + bool db_valid; /* are doorbell settings valid? */ + bool db_req; /* is a doorbell requested? */ } VPE; =20 /* In the GICv5VMTConfig::vm_cache this is how we store VMTE info */ @@ -1257,6 +1261,8 @@ static void init_vpe_from_vpete(VPE *vpe, VMTE *vmte,= uint64_t vpete) if (vpe->valid) { vpe->vped_addr =3D vpete & R_VPETE_VPED_ADDR_MASK; vpe->vped_addr &=3D ~MAKE_64BIT_MASK(0, QEMU_GICV5_VPED_SZ); + /* Doorbell settings always start invalid */ + vpe->db_valid =3D false; } } =20 @@ -2008,7 +2014,20 @@ static void irs_vpe_selr_write(GICv5 *s, GICv5Domain= domain, uint64_t value) =20 vpe =3D vpe_from_selr(s, domain); if (vpe) { - /* We successfully selected a valid VPE */ + /* + * We successfully selected a valid VPE. Sample the config + * into IRS_VPE_DBR. + */ + uint64_t dbr =3D 0; + + if (vpe->db_valid) { + dbr =3D FIELD_DP64(dbr, IRS_VPE_DBR, DBV, vpe->db_valid); + dbr =3D FIELD_DP64(dbr, IRS_VPE_DBR, DBPM, vpe->dbpm); + dbr =3D FIELD_DP64(dbr, IRS_VPE_DBR, REQ_DB, vpe->db_req); + dbr =3D FIELD_DP64(dbr, IRS_VPE_DBR, INTID, vpe->db_intid); + } + cs->irs_vpe_dbr[domain] =3D dbr; + status |=3D R_IRS_VPE_STATUSR_V_MASK; } =20 @@ -2017,6 +2036,53 @@ static void irs_vpe_selr_write(GICv5 *s, GICv5Domain= domain, uint64_t value) cs->irs_vpe_statusr[domain] =3D status; } =20 +static void irs_vpe_dbr_write(GICv5 *s, GICv5Domain domain, uint64_t value) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + VPE *vpe; + + /* RES0 if we don't have virt */ + if (!gicv5_domain_has_virt(cs, domain)) { + return; + } + + cs->irs_vpe_dbr[domain] =3D value; + + if (!FIELD_EX64(cs->irs_vpe_statusr[domain], IRS_VPE_STATUSR, V)) { + /* No valid VPE selected via SELR */ + return; + } + + vpe =3D vpe_from_selr(s, domain); + if (!vpe) { + /* VPE became invalid since SELR was last written */ + cs->irs_vpe_statusr[domain] &=3D ~R_IRS_VPE_STATUSR_V_MASK; + return; + } + + vpe->db_valid =3D FIELD_EX64(value, IRS_VPE_DBR, DBV); + if (vpe->db_valid) { + vpe->dbpm =3D FIELD_EX64(value, IRS_VPE_DBR, DBPM); + vpe->db_intid =3D FIELD_EX64(value, IRS_VPE_DBR, INTID); + vpe->db_req =3D FIELD_EX64(value, IRS_VPE_DBR, REQ_DB); + + trace_gicv5_irs_vpe_dbr_write(domain_name[domain], vpe->vmte->vmid, + FIELD_EX64(cs->irs_vpe_selr[domain], + IRS_VPE_SELR, VPE_ID), + vpe->dbpm, vpe->db_intid, vpe->db_re= q); + + /* + * TODO: when we implement VPE doorbells, check here whether + * this config change means we should now generate a VPE + * doorbell event for this VPE. + */ + } else { + trace_gicv5_irs_vpe_dbr_write_nv(domain_name[domain], vpe->vmte->v= mid, + FIELD_EX64(cs->irs_vpe_selr[domai= n], + IRS_VPE_SELR, VPE_ID)); + } +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -2252,6 +2318,22 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VPE_DBR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(cs->irs_vpe_dbr[domain], 0, 32); + } else { + /* RAZ/WI if no virt */ + *data =3D 0; + } + return true; + case A_IRS_VPE_DBR + 4: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(cs->irs_vpe_dbr[domain], 32, 32); + } else { + /* RAZ/WI if no virt */ + *data =3D 0; + } + return true; case A_IRS_VPE_STATUSR: if (gicv5_domain_has_virt(cs, domain)) { *data =3D cs->irs_vpe_statusr[domain]; @@ -2434,6 +2516,14 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, irs_vpe_selr_write(s, domain, deposit64(cs->irs_vpe_selr[domain], 32, 32, dat= a)); return true; + case A_IRS_VPE_DBR: + irs_vpe_dbr_write(s, domain, + deposit64(cs->irs_vpe_dbr[domain], 0, 32, data)); + return true; + case A_IRS_VPE_DBR + 4: + irs_vpe_dbr_write(s, domain, + deposit64(cs->irs_vpe_dbr[domain], 32, 32, data)= ); + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; @@ -2574,6 +2664,14 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VPE_DBR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D cs->irs_vpe_dbr[domain]; + } else { + /* RAZ/WI if no virt */ + *data =3D 0; + } + return true; } =20 return false; @@ -2607,6 +2705,9 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_VPE_SELR: irs_vpe_selr_write(s, domain, data); return true; + case A_IRS_VPE_DBR: + irs_vpe_dbr_write(s, domain, data); + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 553598e3178..50365c4dfe6 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -115,6 +115,7 @@ static void gicv5_common_reset_hold(Object *obj, ResetT= ype type) memset(cs->irs_vmap_l2_vistr, 0, sizeof(cs->irs_vmap_l2_vistr)); memset(cs->irs_vmap_vper, 0, sizeof(cs->irs_vmap_vper)); memset(cs->irs_vpe_selr, 0, sizeof(cs->irs_vpe_selr)); + memset(cs->irs_vpe_dbr, 0, sizeof(cs->irs_vpe_dbr)); =20 for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { cs->irs_vpe_statusr[i] =3D R_IRS_VPE_STATUSR_IDLE_MASK; diff --git a/hw/intc/trace-events b/hw/intc/trace-events index edfbf7d7157..b187ceefe45 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -254,6 +254,8 @@ gicv5_irs_vmap_vistr_write(const char *domain, uint32_t= vmid, const char *type, gicv5_initialize_vpet(const char *domain, uint32_t vmid, uint32_t vpeid, b= ool valid) "GICv5 IRS %s VM ID %u VPE %u starts as valid %d" gicv5_irs_vmap_vper_write(const char *domain, uint32_t vmid, uint32_t vpei= d) "GICv5 IRS %s VM ID %u VPE %u now made valid" gicv5_irs_vpe_selr_write(const char *domain, uint64_t selr, uint32_t statu= s) "GICv5 IRS %s IRS_VPE_SELR written 0x%" PRIx64 " IRS_VPE_STATUSR now 0x%= x" +gicv5_irs_vpe_dbr_write(const char *domain, uint32_t vmid, uint32_t vpeid,= uint8_t dbpm, uint32_t db_intid, bool db_req) "GICv5 IRS %s VM ID %u VPE %= u IRS_VPE_DBR doorbell now valid: prio mask %u intid %u requested %d" +gicv5_irs_vpe_dbr_write_nv(const char *domain, uint32_t vmid, uint32_t vpe= id) "GICv5 IRS %s VM ID %u VPE %u IRS_VPE_DBR doorbell info no longer valid" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 5823a7f78a0..d82cc23d10c 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -98,6 +98,7 @@ struct GICv5Common { uint64_t irs_vmap_vper[NUM_GICV5_DOMAINS]; uint64_t irs_vpe_selr[NUM_GICV5_DOMAINS]; uint32_t irs_vpe_statusr[NUM_GICV5_DOMAINS]; + uint64_t irs_vpe_dbr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881583; cv=none; d=zohomail.com; s=zohoarc; b=g1ljSTdvz7X0fPismascSX3EXmPZ54z+jkeYhiS25C+PW+x78+fdMsCnt3BDOqkekAsWeeBBUPeqP21rT4LNZlmUZjcTbWMS0vkSpE2hy2JgRDrd/S7AFyHTXy4VpAn907BEQh5rBbStm2544ZpQCKXp9IcFRq9OrUPEhbLMb9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881583; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=wPv7Ak7ok91z1l/gQWZ23Vr8Ogtm8j6ZmfZUtTCQdFo=; b=mpPok1MNIVf0HRpqIVv9FJwk0JkbUH/885V0wmrNmGm6pVvt2UfMqJMn8NzdL7LXJlXCv6A5wiEkYOzDDHY1CNlhAwODJEvFfzXYkiseOn7+dNufzXjjQ1/KGaxtgcko+GZLpokf7KcXY3KXVImaO4j6UX+NYBNRyi3J03HPGSc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188158391314.442743987792483; Tue, 13 Oct 2026 01:53:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY6c-00055j-M4; Tue, 13 Oct 2026 04:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4I-0000cw-Jo for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:06 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4G-0008AL-R0 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:06 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4980fe6b3beso24566815e9.0 for ; Tue, 13 Oct 2026 01:41:02 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880862; x=1792485662; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=wPv7Ak7ok91z1l/gQWZ23Vr8Ogtm8j6ZmfZUtTCQdFo=; b=lU3Yxz1OHJLQD9YPuG9pRd4ykCAOgJPZ5OidntbYX0FKBWhDjTZBmVPgnw/5Nabdbp OWq9dKTCTZX38VDuaD3PrxGwqXYei3YyNiP7+bVctwGqhDMvr6gdLZpU3eHoXV4HXB7x TQkpEPr0+q1txBVdvOSNvLRlGqkTKP243iZ8VtukguhgE6lKHYjDNtddutzPVs8xnu8f ow5X3m4cx/mWZ/mKt87cY1l+NYAk9ezwm/P22XLvN9AMi0frdDK5UqUanBVQ4rCiS1lU dtwbuZfM5AYJYkqQ0b/WUA12SnkDtGOpk5clADCX+zUOy/iJ4ntPuw/JX0DJ9NkUyGJ3 LJZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880862; x=1792485662; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=wPv7Ak7ok91z1l/gQWZ23Vr8Ogtm8j6ZmfZUtTCQdFo=; b=vLVjfJLtC3nA9R1XP7nTli8S77+GeuR26vZBmJf+HNBATm5jNvTrWNB+aMKjglxlSv N+WXCJcF8gJWGuouBlH3PTlRbmXDbL71dxlUq11P4UZ0ksA54/jVUG+eXyqtiE2ni4QP l4SqNUKp89sM9JLNjfCT6r+NIGn0RSWvFkERKGE93/8j9kQI+1uGv4zGf5m1PLpyqBdq ohSoRrQn33FuCDmjZLwHs3XLcpDm9lEiqH/NQK6ekgRjRTtyK9NXce+nJHjueU16mu+Y ZRfx9Z+N0NhJgYM4F7BAIcHGw/DTzi0L+ZavDe57ay6pn2m6eHpUaMA8QXBRPWLoKiSW CP7g== X-Forwarded-Encrypted: i=1; AKwUvBxWCIX4ARPB0BGbpGxkHuesrhLdhDvgVXz3LRipZGwxpoXbOVD6YEUT1BSSLiDehsYacEoJgamOpBuE@nongnu.org X-Gm-Message-State: AFq9FYK4MFHwFmcpqQ3+0V+qq90Ma3zn3OJYbZdMwLVJCmvlqw+6Ux+b P+3EMRttQAn9AXFSrCuAovFR6mtY0vv9sSw+BQXj+HCyi3X6gdaSXnQ9bhmLz/6ROno= X-Gm-Gg: AYBFou2XSfI5MHiIBgGV1fnecYvyh3efa4Mnchr+ZuEvn5ykbPGP+HDg84k8f3SSYJC q2HTpLapVRyj9U1q3GT5+dF7g9ykm2AipRtfbCMBUmG9a7Gvu/QrlCKGepe9T0zDadzZzKwBJtb Z1TxXlud6JmwaSl8z/FZz5pOP3qHJz9Rd8QbgmNd3ndrlGDgLvZa5cwTiEuj3SA+SVY+sQ24goh X1YD8vct0RFhmbENFdVHr7jOx3r/u6jL9vXUEuVcKWiqtrzmrzxcuPd+xFJBWtv5XeQaZD52UdD TqVJZDvnmfL0Ze9ridCSXfIBe0Xd11J4RazRMlKHt1CpCGzRAdKHaavvcvLjB6aOe15Jn0g3mvM hYekUjLtRpTW37XBJ9sUciBhEOzSfzyZmdD40LjC8pO66riRv6Ul/9KN5Ivhg4kEPZiZ24hnEXg SsV7X4zG0TQzgX+LORqC34l5de1O2SKUxNWUrIT75xXCTfN/Jca7uhwi95TZquAQFasoL60JFhh xq5UNVmSlUeFfixI3WPMtdiGXOv4J3Gz7Et6Dm2+0nQJLSYdCzlbGf3cL7xpTNJu4d9JbSOoHE6 w/0= X-Received: by 2002:a05:600c:4e92:b0:49e:63cc:6324 with SMTP id 5b1f17b1804b1-4a18e4837e7mr230958985e9.6.1791880861802; Tue, 13 Oct 2026 01:41:01 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 67/86] hw/intc/arm_gicv5: Implement IRS_VPE_CR0 Date: Tue, 13 Oct 2026 09:39:14 +0100 Message-ID: <20261013083933.1024405-68-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881584611158501 Content-Type: text/plain; charset="utf-8" IRS_VPE_CR0 is a 32-bit VPE configuration register which has semantics similar to IRS_VPE_DBR. However, the only configuration field it has is for configuring 1-of-N VPE selection. Since QEMU does not implement the optional 1-of-N handling, for us the entire register is RES0. We don't need to implement the "writes to the register trigger a re-check of the validity of the VPE in IRS_VPE_SELR and update IRS_VPE_STATUSR.V" when the whole register is RES0, so our handling of the register can be simple. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index f7d2d4a7143..18ca7034011 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -2334,6 +2334,10 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VPE_CR0: + /* RES0 when VIRT_ONE_N is not implemented */ + *data =3D 0; + return true; case A_IRS_VPE_STATUSR: if (gicv5_domain_has_virt(cs, domain)) { *data =3D cs->irs_vpe_statusr[domain]; @@ -2524,6 +2528,9 @@ static bool config_writel(GICv5 *s, GICv5Domain domai= n, hwaddr offset, irs_vpe_dbr_write(s, domain, deposit64(cs->irs_vpe_dbr[domain], 32, 32, data)= ); return true; + case A_IRS_VPE_CR0: + /* RES0 when VIRT_ONE_N is not implemented */ + return true; case A_IRS_SPI_SELR: cs->irs_spi_selr[domain] =3D data; return true; --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881653; cv=none; d=zohomail.com; s=zohoarc; b=KdZXp1V8ILDq9Teb9binPqtp1zBvEHfoz9XNcRmP0SHOLQlyDthT+PtpH1Vk+RlK/BbRcmJ45XKkzs7tZH8tjAEuj23PTdOOjcoUwIo3G3nWWJWuBhL6IEaKehDR2cEgV7JducZdycQiJekH05F4mMy/Tuwsvmaz8pWB7aIoQ04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881653; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=eQNIdAvJC1ZfTaJFOVCOusHjVQCsOoyi8FgUc8+Bmwg=; b=BXeSH1+hilwm4GP0ODQKjswIeyOEauvywmtcgWKNJ8O9za/6AH/70SfPLMoQwZiwiuPVoDjohzJr2XJ5dPdgObLRbRmT0NSXBvV916+9m1QYoD2FWe/AotnPRkjC2v1SXqALBxASyThmLAuyMFH71++KY+ivx70Qp/y1G+4FKhY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881653600114.03399666816199; Tue, 13 Oct 2026 01:54:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8Z-0007TM-Pj; Tue, 13 Oct 2026 04:45:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4J-0000hj-UP for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:08 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4H-0008C1-H2 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:07 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4a1688d7769so22528035e9.0 for ; Tue, 13 Oct 2026 01:41:05 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880864; x=1792485664; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=eQNIdAvJC1ZfTaJFOVCOusHjVQCsOoyi8FgUc8+Bmwg=; b=Y/MOVzz55BlB3/QZht+ezX3th8qX83xVmnjQADy7ajPZQmxHspiyBEVZdhulGUlJUs w1m5SDlkd2q7MKyJDpIGRkl18ZM9Zg7fYQ/k6rRSonjMNX2fkAMgUpci++RASkMMcplQ Y7o34mcfzaDLVbMWGSKiVRNOocajvn5GG9YnLhGCGi5QTHxp54F8Ho3lJCECzCbbJnLe 25hZ/H0qeocvJLhq8MehSIrz9UpXHKOZJ5ZBOG87FhvbVI61J3xCXR7bprHpOi4U0rUx oXKhdKKInIb8tTQSQ1IlniAjb9bFAuR4WV0VR4dTc5ebesfzr530Dt3OTlfN81EM7RXM ojGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880864; x=1792485664; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=eQNIdAvJC1ZfTaJFOVCOusHjVQCsOoyi8FgUc8+Bmwg=; b=Fc7+bNoTHCkmdm0DrqVrg8x2zyjuhYICGaymonLbohej4cIA6IQp86KBjX7AmdFN5Y 0oSN3IRtbRtJEtYYlgMb9Sv5sa9/vQZSZpe7U0IONkuRvnSpMdt3pI0CT5J0iNRAd4U7 ceAW/lquz6NSyO3k8LQ2Pr0o+zKQLZgYz520DLQUCBFaY/DKUa0PO9V3fq9xjrYQeZT4 kuuD5EXblkqTpYx13FfzvnXUGcVkfXy5Xxil8P8cdieClNUBZXbIBlO+b9F14fpMv8rq 91MGusxSyQWfvuIGc6qIoUvrwQXGjX7XjVJeqwnpuySa4SwUh1kZLLseHU0qvzlLVIb8 YJrQ== X-Forwarded-Encrypted: i=1; AKwUvByqYgK+BxZwX5yn0aFePUmfmM7ePq/byCz3w5Xqx0ejxPDtMM8DSHxGjLTL9q3xZnSI7tdyS0gh5g4z@nongnu.org X-Gm-Message-State: AFq9FYK6ozuoO1ZNjcJdPu7cTcHVDhJ0bUlxTVhKC26TXJHFsZ3don+/ oFhvKcpfeU+L4rO3NVz12Wv03Gi4h8BAiSm8te8Vym2Z8upucSblWKjn93ZMgFOhUZJWuWndC3z lEDqkiBI= X-Gm-Gg: AYBFou2ZBLDvymigJImAO0NrZmp8zFoX9xv5/R8to68zSDS9eEWSjHemoQ01WMbnPSS eOPy6SK66NLXqA7gcb8e8KkKcui9vdRk7OVYzph/mAdD6G9Z9EvPVI9P6ZLD+oPehifmGaG4mIk HcIi5KYaNsM4De18FJ+dy8I69l0QbtQBZrwbDGlxpLs1Sx4mw6Pt+4/+FOVBbb8Yf6tEB8dN29k SGmlAsnBP4XSpAjUe8rW/bTG2xF4hK6qMrAnmC4z2szo/90l7jPdO0ih/Gd4jcoyNJ6X61A6LPv vPCmDJMbZ8c1CJlM+h7HpoNiVkZI0H7lDNrLos4miq1aLhcRSlhNwTLe4b6VS+QpbZ7eUexJWvX 7jN6x+81bIJOEVGwnf0+ZMj65JfQRYZGZqQo4S5Uqr8AwYNTw12PceRF22OZghodygmK4Ug49r1 zQEdUxawCDS2U+7xei8/7DwOjWsyzoD8tBOAXVos4vB7mby7FfAEvmuFLdrAoALo4XmZqkOZUkq 6GLGClmQ3ZkOWWt1fXT6njZL9p3NNpJJWFb7NPsvvjXGxPjrxz3ZWeFIKoK2pW3z06/vGwAKkRS r0w= X-Received: by 2002:a05:600c:19cf:b0:4a0:168f:d962 with SMTP id 5b1f17b1804b1-4a18e44363dmr226246925e9.3.1791880864055; Tue, 13 Oct 2026 01:41:04 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 68/86] hw/intc/arm_gicv5: Implement gicv5_set_resident() Date: Tue, 13 Oct 2026 09:39:15 +0100 Message-ID: <20261013083933.1024405-69-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881654082158500 Content-Type: text/plain; charset="utf-8" When the GICv5 CPU interface wants to make a VPE resident, it calls gicv5_set_resident(). Currently that is a do-nothing placeholder; implement the required behaviour of tracking on the IRS side that the VPE is resident on this CPU, and remembering the information about the doorbell interrupt. For each CPU, we keep a note of the current VPE that is resident (if any), so we have an easy way to get to that information given the CPU index in functions like gicv5_set_priority(). Since the only way to make a VPE invalid is to make the entire VM invalid, we only need to set this info in gicv5_set_resident() and then clear it when a VM becomes invalid or the whole VM table is made invalid. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 115 +++++++++++++++++++++++++++++++++++- hw/intc/trace-events | 2 + include/hw/intc/arm_gicv5.h | 5 ++ 3 files changed, 120 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 18ca7034011..01ee303d393 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -29,11 +29,13 @@ typedef struct VMTE VMTE; typedef struct VPE { VMTE *vmte; hwaddr vped_addr; + uint32_t cpuidx; /* CPU we're currently resident on */ uint32_t db_intid; /* doorbell interrupt ID */ uint8_t dbpm; /* doorbell priority mask */ bool valid; /* is the VPE valid? */ bool db_valid; /* are doorbell settings valid? */ bool db_req; /* is a doorbell requested? */ + bool resident; /* is VPE resident on some CPU? */ } VPE; =20 /* In the GICv5VMTConfig::vm_cache this is how we store VMTE info */ @@ -1182,8 +1184,89 @@ bool gicv5_set_resident(GICv5Common *cs, GICv5Domain= domain, bool valid, uint32_t vpeid, bool db, uint8_t dbpm, uint32_t vm= id, uint32_t cpuidx) { - /* Until we implement virtualization, SetResident always fails */ - return true; + VMTE *vmte; + VPE *vpe; + GICv5 *s =3D ARM_GICV5(cs); + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + + assert(cpuidx < cs->num_cpus); + + if (!gicv5_domain_has_virt(cs, domain) || !cfg->valid) { + return true; + } + + /* + * R_PYWKM: if resident VPE is for wrong domain, then ignore + * attempts to set a resident VPE. Allow an attempt to clear the + * resident VPE, but treat DB as zero. + */ + if (s->res_vpe[cpuidx] && + s->res_vpe[cpuidx]->vmte->domain !=3D domain) { + if (valid) { + return true; + } + db =3D 0; + } + + if (valid) { + /* Trying to make a VPE resident */ + + vmte =3D g_hash_table_lookup(cfg->vm_cache, GINT_TO_POINTER(vmid)); + vpe =3D vpe_for_vpeid(vmte, vpeid); + if (!vpe) { + return true; + } + + if (vpe->resident) { + /* + * Trying to make a VPE resident when it's already + * resident somewhere else is CONSTRAINED UNPREDICTABLE + * per R_JJKJV. We choose to fail the request. + */ + return true; + } + + vpe->resident =3D true; + vpe->cpuidx =3D cpuidx; + + s->res_vpe[cpuidx] =3D vpe; + trace_gicv5_set_resident(domain_name[domain], vmid, vpeid, cpuidx); + } else { + vpe =3D s->res_vpe[cpuidx]; + if (!vpe) { + /* Making non-resident when already no VPE resident */ + return true; + } + + vmte =3D vpe->vmte; + + vpe->resident =3D false; + vpe->cpuidx =3D UINT32_MAX; + vpe->db_req =3D db; + if (db) { + vpe->dbpm =3D dbpm; + } + s->res_vpe[cpuidx] =3D NULL; + + trace_gicv5_set_non_resident(domain_name[domain], cpuidx, db, dbpm= ); + + /* + * TODO: when we implement VPE doorbells, we should check whether + * we should immediately generate a doorbell for a VPE that has + * just been made non-resident. + */ + } + + /* + * Tell the cpuif that the vHPPI for its resident VPE has changed; + * it will then call gicv5_get_hppi() which will return either + * IRQ_NONE if this is make-non-resident or the vHPPI for the + * now-resident VPE if this is make-resident. + */ + gicv5_forward_interrupt(cs->cpus[cpuidx], vmte->domain, true); + + /* SetResident succeeded */ + return false; } =20 static bool read_first_vmte_word(GICv5Common *cs, GICv5VMTConfig *cfg, @@ -1566,6 +1649,8 @@ static void irs_vmt_baser_write(GICv5 *s, GICv5Domain= domain, uint64_t value) return; } irs_clean_vm_cache(cs, &s->vmt_config[domain]); + /* No VPE is now resident on any CPU */ + memset(s->res_vpe, 0, sizeof(VPE) * cs->num_cpus); cs->irs_vmt_baser[domain] =3D FIELD_DP64(cs->irs_vmt_baser[domain], IRS_VMT_BASER, VALID, valid= ); s->vmt_config[domain].valid =3D false; @@ -1713,6 +1798,20 @@ txfail: "physical address 0x" HWADDR_FMT_plx "\n", vmid, l1_addr= ); } =20 +static void remove_res_vpe_by_vmid(GICv5 *s, uint32_t vmid) +{ + /* Remove all res_vpe cached information for VPEs for this VMID */ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + + for (int i =3D 0; i < cs->num_cpus; i++) { + VPE *vpe =3D s->res_vpe[i]; + + if (vpe && vpe->vmte->vmid =3D=3D vmid) { + s->res_vpe[i] =3D NULL; + } + } +} + static void irs_vmap_vmr_write(GICv5 *s, GICv5Domain domain, uint64_t valu= e) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); @@ -1762,6 +1861,7 @@ static void irs_vmap_vmr_write(GICv5 *s, GICv5Domain = domain, uint64_t value) } =20 if (u) { + remove_res_vpe_by_vmid(s, vmid); g_hash_table_remove(cfg->vm_cache, GINT_TO_POINTER(vmid)); } else { if (!read_other_vmte_words(cs, cfg, l2_addr, l2_vmte)) { @@ -2858,6 +2958,7 @@ static void gicv5_set_spi(void *opaque, int irq, int = level) static void gicv5_reset_hold(Object *obj, ResetType type) { GICv5 *s =3D ARM_GICV5(obj); + GICv5Common *cs =3D ARM_GICV5_COMMON(obj); GICv5Class *c =3D ARM_GICV5_GET_CLASS(s); =20 if (c->parent_phases.hold) { @@ -2884,6 +2985,11 @@ static void gicv5_reset_hold(Object *obj, ResetType = type) g_hash_table_remove_all(s->vmt_config[i].vm_cache); } } + + if (s->res_vpe) { + /* No VPE is now resident on any CPU */ + memset(s->res_vpe, 0, sizeof(*s->res_vpe) * cs->num_cpus); + } } =20 static void gicv5_set_idregs(GICv5Common *cs) @@ -2988,6 +3094,10 @@ static void gicv5_realize(DeviceState *dev, Error **= errp) s->hppi[i] =3D g_new0(GICv5PendingIrq, cs->num_cpus); } } + + if (cs->has_virt) { + s->res_vpe =3D g_new0(VPE *, cs->num_cpus); + } } =20 static void gicv5_init(Object *obj) @@ -3012,6 +3122,7 @@ static void gicv5_finalize(Object *obj) =20 g_free(s->hppi[i]); } + g_free(s->res_vpe); } =20 static void gicv5_class_init(ObjectClass *oc, const void *data) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index b187ceefe45..6d646eacaeb 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -256,6 +256,8 @@ gicv5_irs_vmap_vper_write(const char *domain, uint32_t = vmid, uint32_t vpeid) "GI gicv5_irs_vpe_selr_write(const char *domain, uint64_t selr, uint32_t statu= s) "GICv5 IRS %s IRS_VPE_SELR written 0x%" PRIx64 " IRS_VPE_STATUSR now 0x%= x" gicv5_irs_vpe_dbr_write(const char *domain, uint32_t vmid, uint32_t vpeid,= uint8_t dbpm, uint32_t db_intid, bool db_req) "GICv5 IRS %s VM ID %u VPE %= u IRS_VPE_DBR doorbell now valid: prio mask %u intid %u requested %d" gicv5_irs_vpe_dbr_write_nv(const char *domain, uint32_t vmid, uint32_t vpe= id) "GICv5 IRS %s VM ID %u VPE %u IRS_VPE_DBR doorbell info no longer valid" +gicv5_set_resident(const char *domain, uint32_t vmid, uint32_t vpeid, uint= 32_t cpuidx) "GICv5 IRS %s VM ID %u VPE %u set_resident phys CPU idx %u: no= w resident" +gicv5_set_non_resident(const char *domain, uint32_t cpuidx, bool db, uint8= _t dbpm) "GICv5 IRS %s set_resident phys CPU idx %u: now no resident VPE; d= b_req %d dbpm %u" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5.h b/include/hw/intc/arm_gicv5.h index 28417317376..ac85cad3eb5 100644 --- a/include/hw/intc/arm_gicv5.h +++ b/include/hw/intc/arm_gicv5.h @@ -40,6 +40,8 @@ typedef struct GICv5VMTConfig { GHashTable *vm_cache; } GICv5VMTConfig; =20 +typedef struct VPE VPE; + /* * This class is for TCG-specific state for the GICv5. */ @@ -53,6 +55,9 @@ struct GICv5 { =20 /* We cache the HPPI for each CPU for each domain here */ GICv5PendingIrq *hppi[NUM_GICV5_DOMAINS]; + + /* Array: for each CPU, either NULL or ptr to the resident VPE */ + VPE **res_vpe; }; =20 struct GICv5Class { --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881218; cv=none; d=zohomail.com; s=zohoarc; b=P3IgD2O4nkBaGTVBIj2UUYuHYeGq26CzG7XtaDzzZOMw4oGsVlvG7JuJWYYJBTsubOuI5xsow9nvg3e4imwM02MeaCo9hZLCbhezhX8wjc/myA6Sma1TFdtD3zmZ7vSOg7jctpHxnEo9gDOVXIcgAm9QI35cNW45Okuhgntp6DE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881218; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=p5jmczQ7jRF4VI3U5WvjTrENUuNA4/rc3UHOagWDDVM=; b=kkkXugs5bdZm/YKwq3HcdUQazO6S/WrkiQS3HDKJhEPR88UPIlGcKLKGFkg2AK/6hlsh638tLRNOQ3o8hfvAeCBxqNwaPxCzJkDqQBIb0O6O7fszmZQaf5d1NLzPntsPl3r6Uw3gaTLcM5PJTfrvBTw2kzlXBb42FzugGHSGxeg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881218392807.9908995649785; Tue, 13 Oct 2026 01:46:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY77-0005XA-I8; Tue, 13 Oct 2026 04:44:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4L-0000lT-MZ for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:09 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4I-0008Ch-QL for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:09 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4a0286c981dso22797365e9.2 for ; Tue, 13 Oct 2026 01:41:06 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880865; x=1792485665; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=p5jmczQ7jRF4VI3U5WvjTrENUuNA4/rc3UHOagWDDVM=; b=Xnl8JXqTb1tRsFCkarcGm9O0QWSIqPFpZH5sj7sku/Wyp3MQ4lCRHlbSk3UQA7yNgH Z17JwIiEZXpY5kQh4mQtVlKfLyeYriAQ111TQ2VbdWIrLGijLwj9dvPbSGSqa/T1wDck xYNTcyeDFetGHYsP2FZ69dEHNBZ84Z9Vq88IyE3AnmX10KClVw5Jpi+gNxUma2HvhEYX m5RWhR4C+UbqAY+kNi5tHiXgzgT5PgVaH8nA5HOmXW0iylO/5+jR5SQ+0sgacKibF7b8 FjYCv78m4G/0x0JVlx4Jit71Lnt3ATC4EOqWn5fSrCWwRJYOs2AVtn1/oB090NOrI1z5 2pMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880865; x=1792485665; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=p5jmczQ7jRF4VI3U5WvjTrENUuNA4/rc3UHOagWDDVM=; b=MnJc/ssBB+ISmX9Oj6hZ6DAyzQrx2jIZIRV94uGrbybLKgtMyWYzCnUmDFDKjFoNFB rBc0kiG2m2KnwcLtERKW662ax0NehL9HL/FWUGsVq+vlclzLG2mXHJWJCUschDyR8ICd vOSWFdiez9H6mL4cPlUXjof63nLG5aUjlPPNWoF1upthiqMyTJu0xOwktK0r4ln3TfNP QUm5rm3gjDIIsHxwGAr905LUue29mIupWTBybHSYgZof9qxvcZEA5KMHPxcpcCLdo9n3 dZOCmTY+QtktRVOMU5tiZzoAr7ePAekMG/vXwSDz/kayFQlKOt/3ipQhwMQTeteH2lPB KPHw== X-Forwarded-Encrypted: i=1; AKwUvBx8hV7uOL5puTfAYRSPtVMyizEjymAP47/ddB6Y9Mv1HV73K8DpCcNopHYK3eRXlZU7hkHtsx9WGnlP@nongnu.org X-Gm-Message-State: AFq9FYIWGkvMsvrJVI6EyGxsMvrxA3tw1cnK9G6Ju2GQztD+6rVSLiLX iDQtBwnZiTgP1pAPQI/YKyTLhVuFdOZcyMzEU11UTXpll42f9vM4LD8dzyUFrTdSQlQ= X-Gm-Gg: AYBFou3kGVIxyYmstuOB7lQ7YVerxPoBJKUYbE1vCAoO0vpHjrTlSsPjtKMJHoVp97a H9v6mb//dyyNF0vSOF4YdL1KOwzhXKdr23oF/r7wjGlG8UGAG8Ijo1M6Iva8gVLUQgj+Ak/rWZc MrquhVeefxmw3vvfwNk589B+0yjGMfG78yTk77hJbSt4vXbVvJtNuKrWXWkihJ2Q0eLLTnCyupP wpm6KUBxnN+sZB5lISENefdZUP2qAFgGm9xPOQiiT71ex7N0ti/v+tbiVo4sr8QYzMfW1dZgo8z 08eO9aYYawolBPVv68RzfijLKd8j5HuVbQjXQSD9vxeKI6Z0OWx/9MNEY7fkp3QQxBOHCvv0ML4 vvCxKX4wgqTCxjh95ecqinOsAXwHPT7481tlFap+uSYaD0yg63dcyHFw7e/9FKbQYEZPe41ajW6 0z8DWaHHpTSrkJ7m7OjeLEdcD2iSQiAa8I6OtfSxxiDE/5JR61cTcEnXo8kETyNuoqgkqyvcwNQ TD/vgL1BCsFxEQtV9iQrpns/RWiWm97t/xtWVehRGFW8BRjVEmTmkfeZTt6ccauCvxkyJpsaO6a gqw= X-Received: by 2002:a05:600c:a016:b0:4a1:a44d:1d5 with SMTP id 5b1f17b1804b1-4a1a44d0221mr73304665e9.9.1791880865106; Tue, 13 Oct 2026 01:41:05 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 69/86] hw/intc/arm_gicv5: Take cpuidx for stream commands on virtual interrupts Date: Tue, 13 Oct 2026 09:39:16 +0100 Message-ID: <20261013083933.1024405-70-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881219747158500 Content-Type: text/plain; charset="utf-8" In hardware, the GICv5 stream protocol is a set of 1:1 links between the IRS and the attached CPU interfaces, which means the IRS always implicitly knows which CPU it has received a command from. For QEMU, these are all function calls, and so the IRS doesn't know unless we pass the cpuidx. For most of the stream protocol commands, the IRS so far hasn't needed to know, because operations on physical interrupts are the same whichever CPU requests them. But for virtual interrupts the operation will be on the interrupts of whichever VM owns the VPE currently resident on the requesting CPU, so we do need to know which one that is. Add a cpuidx argument to every function corresponding to a stream protocol command that can operate on a virtual interrupt. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 18 ++++++++++-------- include/hw/intc/arm_gicv5_stream.h | 25 +++++++++++++++++-------- target/arm/tcg/gicv5-cpuif.c | 21 ++++++++++++--------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 01ee303d393..fc1f09f51e8 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -568,7 +568,8 @@ static hwaddr l1_vmte_addr(GICv5Common *cs, const GICv5= VMTConfig *cfg, } =20 void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, - GICv5Domain domain, GICv5IntType type, bool virtua= l) + GICv5Domain domain, GICv5IntType type, bool virtua= l, + uint32_t cpuidx) { GICv5 *s =3D ARM_GICV5(cs); uint32_t iaffid; @@ -623,7 +624,8 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, u= int8_t priority, } =20 void gicv5_set_enabled(GICv5Common *cs, uint32_t id, bool enabled, - GICv5Domain domain, GICv5IntType type, bool virtual) + GICv5Domain domain, GICv5IntType type, bool virtual, + uint32_t cpuidx) { GICv5 *s =3D ARM_GICV5(cs); uint32_t iaffid; @@ -676,7 +678,7 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, bo= ol enabled, =20 void gicv5_set_pending(GICv5Common *cs, uint32_t id, bool pending, GICv5Domain domain, GICv5IntType type, bool virtual, - uint32_t vm) + uint32_t vm, uint32_t cpuidx) { GICv5 *s =3D ARM_GICV5(cs); uint32_t iaffid; @@ -729,7 +731,7 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, bo= ol pending, =20 void gicv5_set_handling(GICv5Common *cs, uint32_t id, GICv5HandlingMode handling, GICv5Domain domain, - GICv5IntType type, bool virtual) + GICv5IntType type, bool virtual, uint32_t cpuidx) { GICv5 *s =3D ARM_GICV5(cs); =20 @@ -777,7 +779,7 @@ void gicv5_set_handling(GICv5Common *cs, uint32_t id, =20 void gicv5_set_target(GICv5Common *cs, uint32_t id, uint32_t iaffid, GICv5RoutingMode irm, GICv5Domain domain, - GICv5IntType type, bool virtual) + GICv5IntType type, bool virtual, uint32_t cpuidx) { GICv5 *s =3D ARM_GICV5(cs); uint32_t old_iaffid; @@ -889,7 +891,7 @@ static uint64_t spi_state_to_icsr(GICv5SPIState *spi) } =20 uint64_t gicv5_request_config(GICv5Common *cs, uint32_t id, GICv5Domain do= main, - GICv5IntType type, bool virtual) + GICv5IntType type, bool virtual, uint32_t cp= uidx) { GICv5 *s =3D ARM_GICV5(cs); uint64_t icsr; @@ -933,7 +935,7 @@ uint64_t gicv5_request_config(GICv5Common *cs, uint32_t= id, GICv5Domain domain, } =20 void gicv5_activate(GICv5Common *cs, uint32_t id, GICv5Domain domain, - GICv5IntType type, bool virtual) + GICv5IntType type, bool virtual, uint32_t cpuidx) { GICv5 *s =3D ARM_GICV5(cs); uint32_t iaffid; @@ -991,7 +993,7 @@ void gicv5_activate(GICv5Common *cs, uint32_t id, GICv5= Domain domain, } =20 void gicv5_deactivate(GICv5Common *cs, uint32_t id, GICv5Domain domain, - GICv5IntType type, bool virtual) + GICv5IntType type, bool virtual, uint32_t cpuidx) { GICv5 *s =3D ARM_GICV5(cs); uint32_t iaffid; diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index ea27d6aec0f..0d62f86820d 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -59,6 +59,7 @@ GICv5CPUIFStatus gicv5_set_gicv5state(ARMCPU *cpu, GICv5C= ommon *cs, * @domain: interrupt Domain to act on * @type: interrupt type (LPI or SPI) * @virtual: true if this is a virtual interrupt + * @cpuidx: IRS CPU index of this CPU interface * * Set priority of an interrupt; matches stream interface SetPriority * command from CPUIF to IRS. There is no report back of @@ -66,7 +67,7 @@ GICv5CPUIFStatus gicv5_set_gicv5state(ARMCPU *cpu, GICv5C= ommon *cs, */ void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, GICv5Domain domain, - GICv5IntType type, bool virtual); + GICv5IntType type, bool virtual, uint32_t cpuidx); =20 /** * gicv5_set_enabled @@ -76,6 +77,7 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, * @domain: interrupt Domain to act on * @type: interrupt type (LPI or SPI) * @virtual: true if this is a virtual interrupt + * @cpuidx: IRS CPU index of this CPU interface * * Set enabled state of an interrupt; matches stream interface * SetEnabled command from CPUIF to IRS. There is no report back of @@ -83,7 +85,7 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, */ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, bool enabled, GICv5Domain domain, - GICv5IntType type, bool virtual); + GICv5IntType type, bool virtual, uint32_t cpuidx); =20 /** * gicv5_set_pending @@ -94,6 +96,7 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, * @type: interrupt type (LPI or SPI) * @virtual: true if this is a virtual interrupt * @vm: VM ID (for virtual interrupts) + * @cpuidx: IRS CPU index of this CPU interface * * Set pending state of an interrupt; matches stream interface * SetPending command from CPUIF to IRS. There is no report back of @@ -101,7 +104,8 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, */ void gicv5_set_pending(GICv5Common *cs, uint32_t id, bool pending, GICv5Domain domain, - GICv5IntType type, bool virtual, uint32_t vm); + GICv5IntType type, bool virtual, uint32_t vm, + uint32_t cpuidx); =20 /** * gicv5_set_handling @@ -111,6 +115,7 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, * @domain: interrupt Domain to act on * @type: interrupt type (LPI or SPI) * @virtual: true if this is a virtual interrupt + * @cpuidx: IRS CPU index of this CPU interface * * Set handling mode of an interrupt (edge/level); matches stream * interface SetHandling command from CPUIF to IRS. There is no report @@ -118,7 +123,7 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, */ void gicv5_set_handling(GICv5Common *cs, uint32_t id, GICv5HandlingMode handling, GICv5Domain domain, - GICv5IntType type, bool virtual); + GICv5IntType type, bool virtual, uint32_t cpuidx); =20 /** * gicv5_set_target @@ -129,6 +134,7 @@ void gicv5_set_handling(GICv5Common *cs, uint32_t id, * @domain: interrupt Domain to act on * @type: interrupt type (LPI or SPI) * @virtual: true if this is a virtual interrupt + * @cpuidx: IRS CPU index of this CPU interface * * Set handling mode of an interrupt (edge/level); matches stream * interface SetHandling command from CPUIF to IRS. There is no report @@ -136,7 +142,7 @@ void gicv5_set_handling(GICv5Common *cs, uint32_t id, */ void gicv5_set_target(GICv5Common *cs, uint32_t id, uint32_t iaffid, GICv5RoutingMode irm, GICv5Domain domain, - GICv5IntType type, bool virtual); + GICv5IntType type, bool virtual, uint32_t cpuidx); =20 /** * gicv5_request_config @@ -145,6 +151,7 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, uin= t32_t iaffid, * @domain: interrupt domain to act on * @type: interrupt type (LPI or SPI) * @virtual: true if this is a virtual interrupt + * @cpuidx: IRS CPU index of this CPU interface * * Query the current configuration of an interrupt; matches stream * interface RequestConfig command from CPUIF to IRS and the @@ -159,7 +166,7 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, uin= t32_t iaffid, * ICC_ICSR_EL1. */ uint64_t gicv5_request_config(GICv5Common *cs, uint32_t id, GICv5Domain do= main, - GICv5IntType type, bool virtual); + GICv5IntType type, bool virtual, uint32_t cp= uidx); =20 /** * gicv5_activate @@ -168,6 +175,7 @@ uint64_t gicv5_request_config(GICv5Common *cs, uint32_t= id, GICv5Domain domain, * @domain: interrupt domain to act on * @type: interrupt type (LPI or SPI) * @virtual: true if this is a virtual interrupt + * @cpuidx: IRS CPU index of this CPU interface * * Activate the IRS's highest priority pending interrupt; matches the * stream interface's Activate command. @@ -182,7 +190,7 @@ uint64_t gicv5_request_config(GICv5Common *cs, uint32_t= id, GICv5Domain domain, * its hppi[][] array. */ void gicv5_activate(GICv5Common *cs, uint32_t id, GICv5Domain domain, - GICv5IntType type, bool virtual); + GICv5IntType type, bool virtual, uint32_t cpuidx); =20 /** * gicv5_forward_interrupt @@ -230,12 +238,13 @@ GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5= Domain domain, * @domain: interrupt Domain to act on * @type: interrupt type (LPI or SPI) * @virtual: true if this is a virtual interrupt + * @cpuidx: IRS CPU index of this CPU interface * * Deactivate the specified interrupt. There is no report back of * success/failure to the CPUIF in the protocol. */ void gicv5_deactivate(GICv5Common *cs, uint32_t id, GICv5Domain domain, - GICv5IntType type, bool virtual); + GICv5IntType type, bool virtual, uint32_t cpuidx); =20 /** * gicv5_set_resident diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 406c980af5e..ed34196d7ce 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -680,7 +680,7 @@ static void gic_cddis_write(CPUARMState *env, const ARM= CPRegInfo *ri, bool virtual; GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 - gicv5_set_enabled(gic, id, false, domain, type, virtual); + gicv5_set_enabled(gic, id, false, domain, type, virtual, env->gicv5.cp= uidx); } =20 static void gic_cden_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -692,7 +692,7 @@ static void gic_cden_write(CPUARMState *env, const ARMC= PRegInfo *ri, bool virtual; GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 - gicv5_set_enabled(gic, id, true, domain, type, virtual); + gicv5_set_enabled(gic, id, true, domain, type, virtual, env->gicv5.cpu= idx); } =20 static void gic_cdpri_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -705,7 +705,8 @@ static void gic_cdpri_write(CPUARMState *env, const ARM= CPRegInfo *ri, bool virtual; GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 - gicv5_set_priority(gic, id, priority, domain, type, virtual); + gicv5_set_priority(gic, id, priority, domain, type, virtual, + env->gicv5.cpuidx); } =20 static void gic_cdaff_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -719,7 +720,8 @@ static void gic_cdaff_write(CPUARMState *env, const ARM= CPRegInfo *ri, bool virtual; GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 - gicv5_set_target(gic, id, iaffid, irm, domain, type, virtual); + gicv5_set_target(gic, id, iaffid, irm, domain, type, virtual, + env->gicv5.cpuidx); } =20 static void gic_cdpend_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -759,7 +761,8 @@ static void gic_cdpend_write(CPUARMState *env, const AR= MCPRegInfo *ri, } } =20 - gicv5_set_pending(gic, id, pending, domain, type, virtual, vm); + gicv5_set_pending(gic, id, pending, domain, type, virtual, vm, + env->gicv5.cpuidx); } =20 static void gic_cdrcfg_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -772,7 +775,7 @@ static void gic_cdrcfg_write(CPUARMState *env, const AR= MCPRegInfo *ri, GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 env->gicv5_cpuif.icc_icsr_el1 =3D - gicv5_request_config(gic, id, domain, type, virtual); + gicv5_request_config(gic, id, domain, type, virtual, env->gicv5.cp= uidx); } =20 static void gic_cdhm_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -785,7 +788,7 @@ static void gic_cdhm_write(CPUARMState *env, const ARMC= PRegInfo *ri, bool virtual; GICv5Domain domain =3D gicv5_domain_for_insn(env, ri, &virtual); =20 - gicv5_set_handling(gic, id, hm, domain, type, virtual); + gicv5_set_handling(gic, id, hm, domain, type, virtual, env->gicv5.cpui= dx); } =20 static uint64_t gic_ppi_hmr_read(CPUARMState *env, const ARMCPRegInfo *ri) @@ -1466,7 +1469,7 @@ static uint64_t gicr_cdia_read(CPUARMState *env, cons= t ARMCPRegInfo *ri) * name of the stream command, does both "set Active" and * "maybe set not Pending" as a single atomic action. */ - gicv5_activate(gic, id, domain, type, virtual); + gicv5_activate(gic, id, domain, type, virtual, env->gicv5.cpuidx); break; default: g_assert_not_reached(); @@ -1543,7 +1546,7 @@ static void gic_cddi_write(CPUARMState *env, const AR= MCPRegInfo *ri, case GICV5_LPI: case GICV5_SPI: /* Tell the IRS to deactivate this interrupt */ - gicv5_deactivate(gic, id, domain, type, virtual); + gicv5_deactivate(gic, id, domain, type, virtual, env->gicv5.cpuidx= ); break; default: break; --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881204; cv=none; d=zohomail.com; s=zohoarc; b=IVqhPL48NwLPQfwI58nUJbZfmDARjDg2t0seG5860ZSY0PbK0NkHJ8u5nIW7M16u9Z4F4s3/mHOfFlu8qfsFc2uCaRvJ87Q0e+pQjYaZAoT5mutgLlFkex2qtkcm1WSu7e0P3FXufI1fFyQt7A33StU6JVCe0tTjAX4jXvYmZzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881204; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=3fH1g5tdo8tCigjV124Cc0dlO1K5fRGTqJqA4DWBEjE=; b=SOap/dTGQEEiFOJIW0p9yuOVLONz0dlagcHSEJnPbiQ2J+ybmVRrLl0VQ5oqkOjTFVl+jKlgcl8InFV4xqOnVgu4vMqvywTccicIlfektYCQmAMpK3Rr+Kmwgm6xqETTHmrP3gHWSDUY5+gi4cUBKrU9y+3gNsD5K9ochhqndnY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881204393793.9634296062601; Tue, 13 Oct 2026 01:46:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY7u-00062N-Sf; Tue, 13 Oct 2026 04:44:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4L-0000nW-TI for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:10 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4J-0008DJ-My for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:09 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a180fbeef5so24336335e9.1 for ; Tue, 13 Oct 2026 01:41:07 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880866; x=1792485666; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=3fH1g5tdo8tCigjV124Cc0dlO1K5fRGTqJqA4DWBEjE=; b=QOEMMYGrww4cYMthgYTwYZAs2GlFGLCq1g8+WcdhAVsCNqSDLgdnbZKFFTC4a5SfEi 3ZrH7bUGPQsP4a8AVkyVJ81LpQFODQcUosW9ggMdxAkPaQBzomu9QLZ8TjxGdDw00A/e dTInQ3U7EZqV0mPu6S/V3REsN/6DFniHksY97RzccItGqBsV+/scDYs7Y7m51y1SYejr u9u/htwZtfhHTCVUMnjzkpUbrmOO0qlTiIXVSD1U2lccX3OHQx/GzlxDtgOFnwvc2VWv j3Sl5i25Zehx01CfvZQehOD7tQzquk1+UDAFwQOmz2ChWFOgZYe2UnsfjUWDXmFEFGVC OMBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880866; x=1792485666; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=3fH1g5tdo8tCigjV124Cc0dlO1K5fRGTqJqA4DWBEjE=; b=Acc+hXQZBV4Ls2DFstxH2l+czfc1WmAeMVzrvGwNfOaDzGdubkuTh1JKdj8ZKglxFO 5BI3OeRm4IS6qS8d9rf9FoSh8WxSyc0j4A8epexS+J05WKBcwIbjCesZ1vUOSLBwn/im Y477RSo9wRFM/gubKj7oq3Hoyah1HF+YIYuHaTNhpd5wrbdQCEQvFgB/rleXnfX9phqq 1a6eGw5tHvv3zQ7JsaNfCzdMKeGQLvW3tKAYjj1hQ9dI6Mj9Ge+G16+KkIXdmyxGU00G EtQG1rlHJBPWCIJdJgoAUZr7owzrtJEWXGr+8mmxxGw8qjHHNRhuRGlLi5tptL5/s3oA f+sw== X-Forwarded-Encrypted: i=1; AKwUvBx9C7esWyE/GQpTpoqTsJAtoeO/t7rgW3gMNHZomYIDu1pYONqgHqrFRJLnrGizmlCm/mxLyLzlGE3H@nongnu.org X-Gm-Message-State: AFq9FYKDVvC/JQbdmxENmdHMU69THz1Mg56sqUdcN+Yl2MrLq9R7t0+k A2rqLHdhzfBxz+yFZJkUGurUS6KqErxrtMr8sBd58g18B1vYQ/0I+9Sy6Kik56XOuxixiA5zncW UITRbalA= X-Gm-Gg: AYBFou332EVoS+8XZR8r5QH7I862TYvEjRdybfvAyGzCF/sLxLJSzm+WPf3W1rpP7iZ 823CrQdjySahRtHixV9w8cyRkxyP27cXtt0pmMzli5fS5gN0miSzTUIE50mvuZa3vQul8oRq5Xk +nD8z/6NWQiIXogfgfKV80p9odDVavYaznGEd67nnRsksmkMyuMJ8puDpnZodiPkrz2zUjRoPwV ojv2Dzvz7rWYGjIbrue7pbNFzEjO3D+qkMKpKgRjNUMYNLn9nN4X7DbeYNHGtrhb/MaA5OFZ1gH 0Mx/tjitAjIxS/4EU6nQAkUXqpY/oRcoueBW71dmI9nIt8vVgcbMDj+jGm74hVF7u0oEplkF6ao zBlA3aSGIrWRETN+tK1TUFzfHi9KDZ1hqEGJkBzH0JRwpS70VfE8n/FrG9h1Da06Gv/tnT5dg+r iDGl+X3wAUUrwXa+MWIK65UbFau6un2PT+fSYet7JAy7lD0ttKPDGSp95504BA0PxnaM74OCJzW IfARn+Kq/Ks8FqNZ5kjOvUOx+XqkQhblM6utgioriVeqI1AH2XC5L0X6LTbGtRDRWZmXM4UG/M4 ttc= X-Received: by 2002:a05:600d:644f:10b0:4a1:9661:14b5 with SMTP id 5b1f17b1804b1-4a196611aa3mr120014655e9.29.1791880866104; Tue, 13 Oct 2026 01:41:06 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 70/86] hw/intc/arm_gicv5: Handle virtual=true in gicv5_set_priority() Date: Tue, 13 Oct 2026 09:39:17 +0100 Message-ID: <20261013083933.1024405-71-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881205425158500 Content-Type: text/plain; charset="utf-8" The gicv5_set_priority() function has a 'bool virtual' argument so the CPU interface can tell us whether it is setting a virtual or physical interrupt's priority. Implement the handling for this. What we need to do is identical to what we do for physical LPIs, except that we need to do it on the IST for vLPIs or vSPIs for the resident vCPU. So we can factor out the "update the appropriate field in the L2 ISTE". We do this via a macro, because we're going to want identical behaviour for the other fields in an L2_ISTE that gicv5_set_enabled(), gicv5_set_pending(), etc update. Actually recalculating the vHPPI for the affected vCPU will be implemented in a later commit. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 90 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 8 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index fc1f09f51e8..e460d7957fb 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -567,6 +567,81 @@ static hwaddr l1_vmte_addr(GICv5Common *cs, const GICv= 5VMTConfig *cfg, return cfg->base + (l1_index * 8); } =20 +static void irs_recalc_vhppi(GICv5 *s, VMTE *vmte, uint32_t iaffid) +{ + /* + * Recalculate the highest priority pending virtual interrupt for + * the specified VM and vCPU. + * + * TODO: we will implement this in a future commit. + */ +} + +static const GICv5ISTConfig *ist_for_vint(GICv5 *s, + GICv5Common *cs, + GICv5Domain domain, + GICv5IntType type, + uint32_t cpuidx) +{ + /* + * Return the GICv5ISTConfig to use to look up the virtual interrupt. + * Return NULL for any case where the operation should be a NOP. + */ + VMTE *vmte; + VPE *vpe; + + if (!gicv5_domain_has_virt(cs, domain)) { + return NULL; + } + + vpe =3D s->res_vpe[cpuidx]; + if (!vpe) { + return NULL; + } + vmte =3D vpe->vmte; + if (vmte->domain !=3D domain) { + /* Ignore commands for the wrong domain (see R_PYWKM) */ + return NULL; + } + + return type =3D=3D GICV5_LPI ? &vmte->lpi_ist : &vmte->spi_ist; +} + +/* + * Define a function that, given a GICv5ISTConfig and an interrupt ID, + * will update the L2_ISTE entry for that interrupt in that IST to + * set the given field to a new value. The function returns true on + * success and if iaffid is non-NULL updates *iaffid with the IAFFID from + * the L2_ISTE (which is the IAFFID whose current HPPI will need to be + * recalculated). + */ +#define DEF_SET_FIELD_FOR_IST(NAME, TYPE, FIELDNAME) \ + static bool set_##NAME##_for_ist(GICv5Common *cs, \ + const GICv5ISTConfig *cfg, \ + uint32_t id, \ + TYPE NAME, \ + uint32_t *iaffid) \ + { \ + L2_ISTE_Handle h; \ + uint32_t *l2_iste_p; \ + if (!cfg) { \ + return false; \ + } \ + l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); \ + if (!l2_iste_p) { \ + return false; \ + } \ + /* read IAFFID first in case we are about to write to it */ \ + if (iaffid) { \ + *iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); \ + } \ + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, FIELDNAME, NAME); \ + put_l2_iste(cs, cfg, &h); \ + return true; \ + } + +DEF_SET_FIELD_FOR_IST(priority, uint8_t, PRIORITY) + void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, GICv5Domain domain, GICv5IntType type, bool virtua= l, uint32_t cpuidx) @@ -580,8 +655,12 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, = uint8_t priority, priority &=3D MAKE_64BIT_MASK(5 - QEMU_GICV5_PRI_BITS, QEMU_GICV5_PRI_= BITS); =20 if (virtual) { - qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_priority: tried to set " - "priority of a virtual interrupt\n"); + const GICv5ISTConfig *cfg =3D ist_for_vint(s, cs, domain, type, cp= uidx); + + if (!set_priority_for_ist(cs, cfg, id, priority, &iaffid)) { + return; + } + irs_recalc_vhppi(s, s->res_vpe[cpuidx]->vmte, iaffid); return; } =20 @@ -589,15 +668,10 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id,= uint8_t priority, case GICV5_LPI: { const GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; - L2_ISTE_Handle h; - uint32_t *l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); =20 - if (!l2_iste_p) { + if (!set_priority_for_ist(cs, cfg, id, priority, &iaffid)) { return; } - *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, PRIORITY, priority); - iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); - put_l2_iste(cs, cfg, &h); break; } case GICV5_SPI: --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881458; cv=none; d=zohomail.com; s=zohoarc; b=iFLG7PM1AAJhjF3V+kLyCGbPvlu5m59ajOQE4jiOE4oYBp9syBkRXWKo5y1/4u3KWltQ1swu7meLegNUWzhEdlaklTn6tgv4nu1szR+NLD17Hm4rNeKCamDUetu88IomIs2lJxMqCHAtKJM4rKcMOZzJsxTARIpdp+KyXqTihA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881458; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=X1axBU9YVOc4OpWrfbsWGttQLcfYQsseD9BVWGvayPE=; b=g8subNaOoU4z0+H5RommRvWJ65tsGb2/9YC8PTwFZItLtmMMEBoPSxcJrKfv46lA8FzVaRf890YACRfbAPQeUCKvK3L+G7xfaVU5y6iI97bGzeQBBfXTmbzgicv3qhA1icdaXR+2WKotsp91w6tILdU5DrF79b1mcWQrHDBDcIU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881458422461.24647567403997; Tue, 13 Oct 2026 01:50:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8f-0007yz-Mn; Tue, 13 Oct 2026 04:45:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4M-0000oY-7s for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:10 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4K-0008Dh-DT for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:09 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4a140e7405dso30884115e9.3 for ; Tue, 13 Oct 2026 01:41:07 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880867; x=1792485667; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=X1axBU9YVOc4OpWrfbsWGttQLcfYQsseD9BVWGvayPE=; b=JbCNEkoDsQmB3y8wkn6GUT2iaZVUDabKb1nrTeB+hm4jQzMFWN6sE9XLs/VKQMLDgx JhHu9KkqsSxW4xjPkBleCXE3yk3lC9impc50EARm6qhb4SG29bW3xkgp+1PDKQ6+npEm YiuEGfXu4P0jgPzsCAK1a1aKcU18CLkO9Ex/+JGBNQGS+booUr3mFDyQSsTJ11XhV0w+ ghaOwZVMNYoyyieXMxU0DJCUmMfcw79xuTz1W5bKmarMHECYLZvzPff/hjLQx1oPlolT SC36GhGIciyMbFMQ4cR4r7v6IDOAx16geAp9djkuzVewaC8PAHFcjDTrFWz/qLSbdeH1 lySg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880867; x=1792485667; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=X1axBU9YVOc4OpWrfbsWGttQLcfYQsseD9BVWGvayPE=; b=KdRZPWIBIJWoxOghSDubNxoez1p96OZYI6SkdsaYPJ9gFQJcRjNWTos005Mn2a54Le kJwPtz+C2hrUyjwygkI7dhMXcDn4d7A1zRaKkxEXxAd2aLqjxvxM64Jc/FBUUNYiJuKn a26ElWht/wBgYpSEqmjo9gqKL/Ssgo3XDh/gbfqOd28q1j0qF1IwRCX2Z6ZTIztOQdGJ DyhfUfGTx50QUAIrdYyO38EuraojzMk8YAP5K4T3mh+kSazbROxVNrhTgJMxh9/4StF8 T/1s4J8U3aVO9NiqF4h3UWmCgeJDFMiTbboLAD4UHSgHdvEkXSuAkfZmIX0Jw2alU9mh W8iA== X-Forwarded-Encrypted: i=1; AKwUvBwYHdpVEXi0v8zQcCsDDJy7KXOpzvziJ+JaoiqEU8jFl30cZE52Yp3dGEh8ZdTH9xdhRwoyhXJKOy4g@nongnu.org X-Gm-Message-State: AFq9FYKRTh4RtwbGpv1NPqJWbmDG4kJBSn1SPoqECbld20DFFxbdm+rT bV3wIxI6bVVvcmWoKgE+uEgu0gz23ODuU87qT7mHhb5EUXFtkfGST4oHn42p6NqPw9E= X-Gm-Gg: AYBFou0ZKlEaJabI7SEEYWreeJ1gAv9VjXSryzTknTbqWA/CCuoYcl7Rrf+hML/ZBal AUDKMn5CpdyF9T3zhpZsQDziINyIML5rr7jrNk1mbJe2RxDubOX0T5wbohJPiQQa1QvO+PilaR6 qimRC8wTPSEtzgncHDJ2lQdFjZT/5UwVJDHKNdL9w/YOwehuQv+7I85aCwx2O8aXlKyBjZ9u5rc e7E8fquAKCEq48xwYUDySZSan/jEZkhQBkjaLUg/obG7u8ttCUacPHFS6HNkHbY3f9zdTka7TuO PbP1I4UlJkcmOpd5gjoSjxX+W4MR9M/irVneVhjor95B2hRrz8TRxa4R3c03uKAPPH5igkt0sPG yXuPZA8IeGHHEcuHVLmIW1bPGrnUfUyaietw9l28o/Hle/EX7uHLZRJaFiGVIwr/1gBuRgAu6Xz nxvgICpB8XvnprIv54Y6hbvNAvR5RtnkhEfvGkIzHrIxXuHNyKqQ4vuZVrP23zT5DJ0KcQFt3Zu RtvtYLV8fMtSz0e7ZKyxLu2OliSqYYqN6QA4Cq0FofF9iPBoyNXWBxARwXZrAp311bhztMc1s+Q a1U= X-Received: by 2002:a05:600c:8708:b0:4a1:7b05:3a6d with SMTP id 5b1f17b1804b1-4a18e49881amr215760495e9.8.1791880866972; Tue, 13 Oct 2026 01:41:06 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 71/86] hw/intc/arm_gicv5: Handle virtual=true for setting enabled, pending, handling Date: Tue, 13 Oct 2026 09:39:18 +0100 Message-ID: <20261013083933.1024405-72-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; 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: -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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881460253158500 Content-Type: text/plain; charset="utf-8" Add virtual=3Dtrue support to gicv5_set_enabled() and gicv5_set_handling(), in the same way we already did for gicv5_set_priority(). Note that changing the handling mode doesn't affect interrupt prioritization, so we don't need to recalculate the vHPPI for that. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index e460d7957fb..1bb649cf4f1 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -641,6 +641,8 @@ static const GICv5ISTConfig *ist_for_vint(GICv5 *s, } =20 DEF_SET_FIELD_FOR_IST(priority, uint8_t, PRIORITY) +DEF_SET_FIELD_FOR_IST(enabled, bool, ENABLE) +DEF_SET_FIELD_FOR_IST(handling, bool, HM) =20 void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, GICv5Domain domain, GICv5IntType type, bool virtua= l, @@ -707,8 +709,12 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, b= ool enabled, trace_gicv5_set_enabled(domain_name[domain], inttype_name(type), virtu= al, id, enabled); if (virtual) { - qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_enabled: tried to set " - "enable state of a virtual interrupt\n"); + const GICv5ISTConfig *cfg =3D ist_for_vint(s, cs, domain, type, cp= uidx); + + if (!set_enabled_for_ist(cs, cfg, id, enabled, &iaffid)) { + return; + } + irs_recalc_vhppi(s, s->res_vpe[cpuidx]->vmte, iaffid); return; } =20 @@ -716,15 +722,10 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, = bool enabled, case GICV5_LPI: { const GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; - L2_ISTE_Handle h; - uint32_t *l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); =20 - if (!l2_iste_p) { + if (!set_enabled_for_ist(cs, cfg, id, enabled, &iaffid)) { return; } - *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, ENABLE, enabled); - iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); - put_l2_iste(cs, cfg, &h); break; } case GICV5_SPI: @@ -812,8 +813,11 @@ void gicv5_set_handling(GICv5Common *cs, uint32_t id, trace_gicv5_set_handling(domain_name[domain], inttype_name(type), virt= ual, id, handling); if (virtual) { - qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_handling: tried to set " - "handling mode of a virtual interrupt\n"); + const GICv5ISTConfig *cfg =3D ist_for_vint(s, cs, domain, type, cp= uidx); + + if (!set_handling_for_ist(cs, cfg, id, handling, NULL)) { + return; + } return; } =20 @@ -821,14 +825,10 @@ void gicv5_set_handling(GICv5Common *cs, uint32_t id, case GICV5_LPI: { const GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; - L2_ISTE_Handle h; - uint32_t *l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); =20 - if (!l2_iste_p) { + if (!set_handling_for_ist(cs, cfg, id, handling, NULL)) { return; } - *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, HM, handling); - put_l2_iste(cs, cfg, &h); break; } case GICV5_SPI: --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881620; cv=none; d=zohomail.com; s=zohoarc; b=BlXw35Kzx5+JNGAUfK/pbDZR1qyuLgCOpdOAtexZvYXTQ1xT8nzoxQjS3r28uJzsPrGSVKB45fg/Ljm+E+YBpvcfTINT/1CslFdsj6++daEktT+hVQ7fAa14buX+gzGzvCaDIXZ9MfmVJwO7sWpehEzxnYdoLAT+N7+vSG63ZZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881620; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=ajLhckcu3c2igWxUB3Vhg4b0TdY9O1nDNXhQTb9MzSE=; b=XMMAta9d+mhlfCN4sXeQHNR2eKf9pm5u9uM7TKXb4TB5pgaFGe6jH1xCLdRNGccm2oq+0UHwo0FIk7VRRBkBMeObu30VUupLKyTv7xhImPScf0ReIdkMV3H3fsVgsALDHrz/6/nrixz5ivY3dE2KqyC+C2yme51GDPW6oOQ5uvw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881620661420.38792699108535; Tue, 13 Oct 2026 01:53:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8i-0008DF-Cm; Tue, 13 Oct 2026 04:45:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4O-0000zX-In for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:12 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4M-0008EM-Hj for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:12 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4a0e1b0681bso19396465e9.3 for ; Tue, 13 Oct 2026 01:41:10 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880869; x=1792485669; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ajLhckcu3c2igWxUB3Vhg4b0TdY9O1nDNXhQTb9MzSE=; b=QQg/Iko93jcSaAKZhc72naJI+YAA3/Bc5/aG3fvSuFPHZPVPLaF0WzFAkPZq6d/sZK ibdBBB/lam2QaFLO+u0eRt2BHWeIrkeFnYtFW77YRU/I5rjd0hVCAKkUW8q/LcSSjKpG O79Kmm0U9QGt5W9suTc2qzzLjn08LCMermbR269mEABoM5VSt0jrSserMYj+KWHoSz/0 F587BQ69LWWgvD08AHDJTx5aMB/2kVLMf/jFJLixgnxd7T7L9z313JNyAVsGDi44feSi fVUNl3uGqAR1n21j+7d4QoKaV8YHjszGXsoKOY2qeAeeKaNcDFFluKcjbBbptmiLRZ2M 6ZFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880869; x=1792485669; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=ajLhckcu3c2igWxUB3Vhg4b0TdY9O1nDNXhQTb9MzSE=; b=PA/cj6I03Ak5SdP1F3tqm7eO0Ddeinn4bOmxOZXokMscWxCgsHZG6N823Qf5MtWbuG VrD8p+0F/VhOWIpAfLj50Ubk/u6FsBkMQ1A9bcU+w8Y+67QaGLx1EXJo474QoIEw14Rx GjeViaeBHy4cK0n38q+huWD12DZrL89+9qRJ/e+QQF0ozmVo+dhZQetBGvd31vKxwuMa /bLxw2zvKnK+ywNT7ZxeXHYGndSOKOBFHZId2+Ft8F/HuzBu749vF9u0uF3XBy+piMV+ RiWQrQUvp1ootkBSc5jAiCyb5OwyagfIdcLMpx4QzTZK+dRBzILr10tQ0ErzwfTJOwYR 2pxA== X-Forwarded-Encrypted: i=1; AKwUvBw/ws+y1XVYufSGvZlBDQ1Hn0vBFT2U+j9csnAFuwbxEhJTwX9KL5P7PJUSJwxlMA8gdxQfQKG7VdXe@nongnu.org X-Gm-Message-State: AFq9FYL8Kw1VqIxpbiTcL6rJvsQTuMybaGCUhPxH5gxVisZa02OA3zjo aA1OijERGAVxcRAW3P1knTaf4LiVtv/WkUZ09B0dixrO8Lkhro08azExTBOB6TsUvH8= X-Gm-Gg: AYBFou0acw1rQ6Pk3vRZvW3ZSEe7oVhxiBuWWkQCu2QykxP3fGccpoNkxlikUpbq2NA H16ia/CJYtgc3YvO7lEbvzqgh7Vy3nftsgdirlvS6flnqlRfmeXmUb5LlI+P22f3BQ5O2SRF2k5 48rJt6RZ9YLzpxbFQXOOfRweHchaKGE2xAhpeLc7OUXzB+/iA5Y+6tEet9U/kRijUSBDfhZXG+o BWDGS+OaJxO2+BpryM/nPA8NnWcR2YGS+OQtxIiQx22O3gQm1bwA8jUmaGJv4bvbi603znJlkhp uwJmBTk/gnD4+4PbgkGo2c/PaOGJPLLRqn7BGijyqFTiRrMX7+wl1H3NBqlIGW3ZP039zqWR+cp HpYPzYe1NoG25642Y+tUl+CKtqUkZRe1FyHO+V4KXiDsSGqrWNtTwenmoRygoL3PgqKR2J0TW1J 96lw+eLlgV7VVoIprx4WgAfPrYQBO5WXVU4Yy7j9/KaI3mdWGDUTsO5IuiCE/ZlquTu4u89s9Op Cv4xUyXxzX4RB23tR6JKWBrHPAHjluiKaPXGHTCws1cFsa5GhxAQWX+OEauXTDHfndR1uBnOGFT wLI= X-Received: by 2002:a05:600c:138a:b0:4a1:7bd4:d07d with SMTP id 5b1f17b1804b1-4a18e4c85fdmr249993545e9.34.1791880868893; Tue, 13 Oct 2026 01:41:08 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 72/86] hw/intc/arm_gicv5: Handle virtual=true for setting pending Date: Tue, 13 Oct 2026 09:39:19 +0100 Message-ID: <20261013083933.1024405-73-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881621480158500 Content-Type: text/plain; charset="utf-8" Add virtual=3Dtrue support to gicv5_set_pending(). This is similar to the handling for set_priority and friends, except that the Pending state is the one change a cpuif can make to an interrupt that doesn't require a VPE for the VM to be resident on it. Instead gicv5_set_pending() is passed the VM ID to operate on. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 1bb649cf4f1..c07122fe6e4 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -643,6 +643,7 @@ static const GICv5ISTConfig *ist_for_vint(GICv5 *s, DEF_SET_FIELD_FOR_IST(priority, uint8_t, PRIORITY) DEF_SET_FIELD_FOR_IST(enabled, bool, ENABLE) DEF_SET_FIELD_FOR_IST(handling, bool, HM) +DEF_SET_FIELD_FOR_IST(pending, bool, PENDING) =20 void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, GICv5Domain domain, GICv5IntType type, bool virtua= l, @@ -761,8 +762,30 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, b= ool pending, trace_gicv5_set_pending(domain_name[domain], inttype_name(type), virtu= al, vm, id, pending); if (virtual) { - qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to set " - "pending state of a virtual interrupt\n"); + /* + * SetPending is the one operation on an interrupt that a cpuif + * can do without having a VPE for the VM resident. Instead it + * passes us the VM ID to operate on, and we must look up the + * IST to use that way rather than with ist_for_vint(). + */ + GICv5VMTConfig *vmcfg =3D &s->vmt_config[domain]; + const GICv5ISTConfig *cfg; + VMTE *vmte; + + if (!gicv5_domain_has_virt(cs, domain) || !vmcfg->valid) { + return; + } + + vmte =3D g_hash_table_lookup(vmcfg->vm_cache, GINT_TO_POINTER(vm)); + if (!vmte) { + return; + } + + cfg =3D type =3D=3D GICV5_LPI ? &vmte->lpi_ist : &vmte->spi_ist; + if (!set_pending_for_ist(cs, cfg, id, pending, &iaffid)) { + return; + } + irs_recalc_vhppi(s, vmte, iaffid); return; } =20 @@ -770,15 +793,10 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, = bool pending, case GICV5_LPI: { const GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; - L2_ISTE_Handle h; - uint32_t *l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); =20 - if (!l2_iste_p) { + if (!set_pending_for_ist(cs, cfg, id, pending, &iaffid)) { return; } - *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, PENDING, pending); - iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); - put_l2_iste(cs, cfg, &h); break; } case GICV5_SPI: --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881619; cv=none; d=zohomail.com; s=zohoarc; b=JRPKOivpZSCVK66A/64h80oSouIgvmqW73JzgN11XubbtEUX7FTcoApE25i4Q6o4e+PZ9vNpWTpGG+oxuYEVofPJHZmWAjAKHBH2uNKNOUwqygqIfpqBaOXVpN9iFAx7Zz3mS+3Y3WP6sByagRaX47OX1WSWtQ3bm+rmVcir06Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881619; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=/MPD1vW8lp0kAxOSWh/UtStGkkrI/a03RZQPymBCy+4=; b=jvF+5GJhODJ4a7RRpgpEyPELdlhrcuhjML90BtbEyxPAcyoZCLZbOI2M+OQg2Q/Rj7aj7SGhF+3/PapsjEzrB7oQHuVQb8xiG4XpAX8lHAj5tl5CJQZ56w+3L0LVaqw4FiI4hVisE7rvjo9D152RAJM+1nU1FwkWOaxakQryBpo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881619741942.4344477097882; Tue, 13 Oct 2026 01:53:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8h-00085W-5c; Tue, 13 Oct 2026 04:45:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4P-00011k-B3 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:13 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4N-0008Et-Cx for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:13 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4a0286c981dso22798065e9.2 for ; Tue, 13 Oct 2026 01:41:10 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880870; x=1792485670; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=/MPD1vW8lp0kAxOSWh/UtStGkkrI/a03RZQPymBCy+4=; b=actH3kyTyQKYEJ+wsipulIB/diBA4edL2hJO9wsuwzOuSGMdCBzLEA9idHv8DKwWPE Mu4246fIxWSoqTUDYnHPfcJqNA7HNWFs6jXL8yYNKjNLjqfad8EI9G2CEibkkb7nlF9u pduXqVz6y1sX7e1U0CLM1wWcBVJeRCI/Xx86abhQenYRtdUXRS4j9jd+wLjc1lGoXqGX Pf4scRMnO2OcxlojIrQsqeuHyfKsueqmWJ4clflreXhPdAyZvWJAaEU3l6Tmd5RLvP47 0Phg2qWe56WhN9cV3QuliHKVdrnkkGDMzE7P+z5/l7dyXwEbBbeuQ4MFIc3Jt/UVCfq9 YqvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880870; x=1792485670; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=/MPD1vW8lp0kAxOSWh/UtStGkkrI/a03RZQPymBCy+4=; b=JdT68kjoaeCqz9Zf/YN79yGgU7eA6Cva7pSMA1Xf3bs158cToVKHoQfUUP3EMB9yi+ AQOUhMLbkFhvkCMMue3qzGJh+VEMfJxrkxNvn7Jp8vXLnBtAozltzJtfnZhGAq5Nr5B1 doHnMDFpqtTsG3qJFvu5gv/652N878gNLuhwFAFEX3Yb6kccysQQEbMWS+OJKqRpljva sffMrJWv/6LK0bexvC7gKnROGj9f0RIUXAxLLf07XPI0pIqC/Gc4athjFAE5+ALxDhwP 0TkD0qU8cVV1by92lUe+bds9Lf7p2RQlZE0OLrOtCD97g5J9cWhmv83/o7jkdBXj+tLw Y/7g== X-Forwarded-Encrypted: i=1; AKwUvBwMLvjQyIJ48O/NR0/spikgmAPFTk6tHwKXAcjw47yQ9S9iDgeWcWnWd96FowEoc0hxTUiELvegz08s@nongnu.org X-Gm-Message-State: AFq9FYKLQh3dn2lVehzjCx3Nxc651dwdMftRc1Rx5yz/xVLPBf1gQzur hGL3V9/VF0ehusqvZ/Uim+HX1GbXBL4+d1z7R390ncOev25gvxbeS4xd15VJvWGcgCL9c8LONHA b4VlEutg= X-Gm-Gg: AYBFou38T9zOPuiW69y9/EAD2/olKv51lMIZd29nDfARgolqooqxeSLvllfHpnLZF+U uJUgrTTR/AAKIcRyFiEPE7OsTsYG0KJ6hOFrWOf8Ur4iMeWOFZsX8zLO5J3Sh+0SqfXN2aeMlFN AN5ELYsOveNsfc9sHffYc4qwp3WyYuZFcApyK1WCgzlYV2RH5HfPVVyzEVMd44Baa+/Pc+N+mDB ehm/3KS++id34E8j9P72p1LrdenDIOxplBAMy7KD6SVm37iHlq4C0r8KTL7WUfZ6J5RW2xE9jkr g6Vht6KW575qUT0voGz+dqEleAvcKU42nHdt7UXKEoEhvmA4NzUJUznRDuUVwrD/g1YtZJ7R/EA k33WKH3Gae4ipE/lQm8YCUs3asK9fYcD9w+/w2r/yfsfCIDe1NW4c2QR5Mgpw+4thl71KNwIcL7 nfjEvbCkrUICiTl55e82Zn3o14WJY1BtUs/PzpCOdRYQgO4O8Cx8diINupD34jK2bV/RJX8bvuw Ku3fB1d1sYHfaChJEwYvjH3n5i7eJAnJiHSa/e72mHDvd0sg2t9Zu8JLjXpnH9r7/If3jTw7aLX OQ0= X-Received: by 2002:a05:600c:4e43:b0:4a0:1f90:594b with SMTP id 5b1f17b1804b1-4a18e4b67e1mr211450245e9.22.1791880869818; Tue, 13 Oct 2026 01:41:09 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 73/86] hw/intc/arm_gicv5: Handle virtual=true in gicv5_set_target() Date: Tue, 13 Oct 2026 09:39:20 +0100 Message-ID: <20261013083933.1024405-74-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881621486158500 Content-Type: text/plain; charset="utf-8" Support virtual=3Dtrue in gicv5_set_target(). This is basically the same approach as for the other gicv5_set_*() functions, with the slight wrinkle that we will need to update the vHPPI for both the old IAFFID and the new one, and that the comments and handling for (lack of) 1-of-N routing apply equally to virtual interrupts as to physical ones. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index c07122fe6e4..7c68fd6cc2e 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -644,6 +644,7 @@ DEF_SET_FIELD_FOR_IST(priority, uint8_t, PRIORITY) DEF_SET_FIELD_FOR_IST(enabled, bool, ENABLE) DEF_SET_FIELD_FOR_IST(handling, bool, HM) DEF_SET_FIELD_FOR_IST(pending, bool, PENDING) +DEF_SET_FIELD_FOR_IST(target, uint32_t, IAFFID) =20 void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, GICv5Domain domain, GICv5IntType type, bool virtua= l, @@ -878,11 +879,6 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, ui= nt32_t iaffid, =20 trace_gicv5_set_target(domain_name[domain], inttype_name(type), virtua= l, id, iaffid, irm); - if (virtual) { - qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_target: tried to set " - "target of a virtual interrupt\n"); - return; - } if (irm !=3D GICV5_TARGETED) { qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_target: tried to set " "1-of-N routing\n"); @@ -893,24 +889,32 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, u= int32_t iaffid, */ } =20 + /* + * For QEMU we do not implement 1-of-N routing, and so L2_ISTE.IRM + * is RES0. We never read it, and we can skip explicitly writing + * it to zero: it's sufficient to update L2_ISTE.IAFFID alone via + * set_target_for_ist(). + */ + + if (virtual) { + const GICv5ISTConfig *cfg =3D ist_for_vint(s, cs, domain, type, cp= uidx); + + if (!set_target_for_ist(cs, cfg, id, iaffid, &old_iaffid)) { + return; + } + irs_recalc_vhppi(s, s->res_vpe[cpuidx]->vmte, old_iaffid); + irs_recalc_vhppi(s, s->res_vpe[cpuidx]->vmte, iaffid); + return; + } + switch (type) { case GICV5_LPI: { const GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; - L2_ISTE_Handle h; - uint32_t *l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); =20 - if (!l2_iste_p) { + if (!set_target_for_ist(cs, cfg, id, iaffid, &old_iaffid)) { return; } - /* - * For QEMU we do not implement 1-of-N routing, and so - * L2_ISTE.IRM is RES0. We never read it, and we can skip - * explicitly writing it to zero here. - */ - old_iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); - *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, IAFFID, iaffid); - put_l2_iste(cs, cfg, &h); break; } case GICV5_SPI: --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881588; cv=none; d=zohomail.com; s=zohoarc; b=TWBa2XEn4gg8fCWCAP/oiFrzJgisXW47+2XEv/LxoEIj+4wCUyi8dLM6nId9VpzxN+IxQuB+TyqBEC7jddx/iz8RVh2/u17f08sTBkvf2CYyJE5sjg+Hnrlq/h4YiE5BAfMhpDrXpVjzM2n4b7ZcvcPhL2F7PqVosPLmUsbk/+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881588; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=fam63WVG4qIrwWX1AvZPXPDPo354Ibas6nosiQf5fbU=; b=kbiSlEkQQ5jOpKcHOHPq6tuBB/iL3Dxoq3ShgVOH++i/MPsFkxL+jz0o1BVqaIQMEQ8PNqzikZ4FsBolVOHxmA4TuPVdmcW3S91h+BM8xhogAVCfnp0dcDmj8tMldirx3MqprcCf8kinJlfIrmRdWYMx8J2Z69f3vltjmedTxrk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881588260945.7487745318753; Tue, 13 Oct 2026 01:53:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY9c-0002BF-57; Tue, 13 Oct 2026 04:46:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4Q-000171-63 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:14 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4O-0008FB-9b for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:13 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4a022fee0caso24204825e9.1 for ; Tue, 13 Oct 2026 01:41:11 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880871; x=1792485671; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=fam63WVG4qIrwWX1AvZPXPDPo354Ibas6nosiQf5fbU=; b=bHvsVRoa0mfQO47MydvMHD+1yMo3RptSvZc1mDbbuc36yDB6Sn9U5jqb7qhI+t3rBT kmg5KiGdv1HXUunmGLFtU5bmGwyYHJGvDBuM1TQZSQj7STvbx27Yn05oHptTAvEX5JtM VsMGP7EoFF6YN/i63ek8kgOj50QBq/TeWo7WBSoAT9Hn46GUWp70CWe5dKK+Qp0OxoBc Oq4HLtxcPF1Ait22SQaLKQJBQoacfeJic5mko0pykgd9Tf1Irp6nRWWYLBqiTehVJg76 l0EEU8u367mHajlSwrKmwa/wwajW7Uf0G+evOlkJuRxOghPZr90O5edW+TG7Vt1bWrr5 71og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880871; x=1792485671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=fam63WVG4qIrwWX1AvZPXPDPo354Ibas6nosiQf5fbU=; b=gQhi4razdJ/McJyxbDQmlhyTjg3l8NIAqmno+nQyAPf5vWDgfJO+euOeym9vv7V58Q rx4AvCbO3br9Wb3sQ1wUpToWL/oMND9zBv6fC9+48FqCbpObGtKNgSDMAWJOVRbfSqMp 1GdYftVh1+wsmZ8O+TGMttB1g96waeym5tGu+GKSuf7nTmJkh8GZ94SuPonNyX5f7xKG yGt65lv8zWcjH5V8yeSLbXBL5kZ/J9pYwN3DPP84N++t/NrKs0DH5rmKOai+BHqgkOTd m7ig3VbqqijgdhJ8M3T6maW6tXxLAOXL6wnehz49lev1/nJYowOT8GWdIayc4jJq+IiI LK3Q== X-Forwarded-Encrypted: i=1; AKwUvBwM13y3lbPNU4yz9QuHbcXQhlpox+CWkVDujk+HVqx95nr8MEi6fPUmMbVHhAsYDP4g1av8e5wsrJ2y@nongnu.org X-Gm-Message-State: AFq9FYLPQm9ZiREVF7ytPLFNAHnHX62jrkYwLomq+JjAwWPIRapz+l4z Lnz545Ty43eXrDP5iJ7npcOaaLwa72HiLakrBmc3dom1/3NuHtVdHe4cHMGV6EEMF8gyaiG8pUE ndQTuMbQ= X-Gm-Gg: AYBFou3YGxWEDSCG7lNRs8gnPvpxZLcNsKzvnxR8UDMyxMFJmahBPtjalNq7IIn/AGG yIFjpSkJSoYN5SBA3B+DvM7OKApBotfKUhbvMlX1Tx5nBSF0RtRVG6Qoa9eGwU/dIJ3VX7dDvvO oaLqw2W+3y8jbvv6PkZ/F8wt9R45CRRDGRrNG4wtqbgMlCn18pllcIIJM6PFeRwBXfa2i5J9wTt PcJzEABkRHSCUUUi/sdsBg12jZSCths3mJspNl4dH65sak3atpCZLY4lFXfDeZcVebWWhouedga F6VPTBJaQHKA5aGGXFzqUi9wuxpH/9CU2oTGeNXJLxSSPBFKQuG+iR6j/TaoybGNLlzbM1xYTc8 +FRtdmKCzSj18SMpwKqVenimaS5j4J5276b+tDV5p/DeFMpqvnUmuasKZBTd8pHI81OJE87PCEb 9Ka9w+iozz/3bZpRJkqRoMx9VlYHrCaeN9+USfEyh/BHi08cIohXT6q76ZEhGpvthcJZqdNoEh/ Jt7LXWzwgS2cjOVI2o7byj+ggDLeiXrnuutIVE3YHinaiZC2rjl/WPiqEuEJymsGNx7m33ccbMk KNQ= X-Received: by 2002:a05:600c:4f89:b0:4a1:acaa:9d4c with SMTP id 5b1f17b1804b1-4a1acaa9f79mr22107965e9.25.1791880870738; Tue, 13 Oct 2026 01:41:10 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 74/86] hw/intc/arm_gicv5: Handle virtual=true in gicv5_deactivate() Date: Tue, 13 Oct 2026 09:39:21 +0100 Message-ID: <20261013083933.1024405-75-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881588678158500 Content-Type: text/plain; charset="utf-8" Handle deactivation of a virtual interrupt, using a similar process to virtual interrupt config updates. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 7c68fd6cc2e..5a038fc14e9 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -645,6 +645,7 @@ DEF_SET_FIELD_FOR_IST(enabled, bool, ENABLE) DEF_SET_FIELD_FOR_IST(handling, bool, HM) DEF_SET_FIELD_FOR_IST(pending, bool, PENDING) DEF_SET_FIELD_FOR_IST(target, uint32_t, IAFFID) +DEF_SET_FIELD_FOR_IST(active, bool, ACTIVE) =20 void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, GICv5Domain domain, GICv5IntType type, bool virtua= l, @@ -1097,8 +1098,12 @@ void gicv5_deactivate(GICv5Common *cs, uint32_t id, = GICv5Domain domain, trace_gicv5_deactivate(domain_name[domain], inttype_name(type), virtua= l, id); =20 if (virtual) { - qemu_log_mask(LOG_GUEST_ERROR, "gicv5_deactivate: tried to " - "deactivate a virtual interrupt\n"); + const GICv5ISTConfig *cfg =3D ist_for_vint(s, cs, domain, type, cp= uidx); + + if (!set_active_for_ist(cs, cfg, id, false, &iaffid)) { + return; + } + irs_recalc_vhppi(s, s->res_vpe[cpuidx]->vmte, iaffid); return; } =20 @@ -1106,15 +1111,10 @@ void gicv5_deactivate(GICv5Common *cs, uint32_t id,= GICv5Domain domain, case GICV5_LPI: { const GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; - L2_ISTE_Handle h; - uint32_t *l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); =20 - if (!l2_iste_p) { + if (!set_active_for_ist(cs, cfg, id, false, &iaffid)) { return; } - *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, ACTIVE, false); - iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); - put_l2_iste(cs, cfg, &h); break; } case GICV5_SPI: --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881339; cv=none; d=zohomail.com; s=zohoarc; b=RMWbapfMScTFWoa/v6ADEJJRnO1ydQnDC2HpZp7OJ1GWt7iWJLtHmJ9tJ9S1rzQkTeUS7mao0cIeHQwF1pL/mooVLg7U3QMFcvXiFrcVylyyYQOR0EZvwdw1N9agIDI7xd+pEyY4DHzC4Mfsu7OkaGCKBKoQ2woXzU+nIlwGobY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881339; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=s/z9Yvn1Q+fwTQJfLeFnAK/nNkUh7Y2+PQGp/wBgZSw=; b=ewHUhHdf6Wq8yyLZEnnM+EPahdZKC+kOhKGb/yaTV/qDxSfaursEuBnwCPcAy7NDsayll1Av/VNh+MLBqCvvU8knGjYBYy5n+J/1lRajTrcj6EWYvuh8v80vGNiL+n+Oa+ToSZBep8Hy0M7IU2ABrww+c+lZbny5KrEqtZyBriA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188133924542.04705872743784; Tue, 13 Oct 2026 01:48:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8k-0008G1-4X; Tue, 13 Oct 2026 04:45:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4W-0001Xh-Gz for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:20 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4Q-0008Fc-BU for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:20 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4a022fee0caso24205205e9.1 for ; Tue, 13 Oct 2026 01:41:13 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880873; x=1792485673; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=s/z9Yvn1Q+fwTQJfLeFnAK/nNkUh7Y2+PQGp/wBgZSw=; b=Oc+eVk7oA9cBxCWBBtS2VklasV6wCwjU6u68RKw3hgneSKUJIVAIrQfq6/g7FBCUEU 0FKjdljNppz0eDNwQJqDbTp6FOTKnYtPCGhLFL+0S6PKJ8MSU24VTv+Tp5PN3erEpLWm nKr7jojj7A0SKqrqa4scjx7RhsRynPWT6rbhy4t3mxmLO8yC691TR7Y/WJ81p1zWBewR VRqujOMYk5PFElWvf4i1jvZrFiRVzRDHg40GLe/DZr2RJeh+euBCTw9Bv3x+xwkxNfX1 DWgZp0ESs8qsGCz8tbdKsO4UlJvD5VecNxvmW1DUVWyyiaxtLAk19eGU2JKjMTEtsNNx ZeZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880873; x=1792485673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=s/z9Yvn1Q+fwTQJfLeFnAK/nNkUh7Y2+PQGp/wBgZSw=; b=zvi24gVIKyPrAIC5uDp7nNIqpU++xowL0ubhNj33t3bg42/YaDACBPj1G6W5BFQrib w/1WfWqdplvUu0hCp0DZjgGlQ/4SGVW/eR/256opNhyNZylj2vx8RkG7gYIC6+zPqpHC 1JJXZAFkeK4DEUV2/xaXF0mFJZ3SCx1Jt7y6/qEUnx2DyiZbsqKAe4D13MLwfbpQXCR/ qeQ43CePiDFTRxFg8yDtCBzn+64n2TAr6gm/lVQfIE8oR0UD06kfvb+znwzGaAZJJuU5 aIA1OXOVLBho90iAMX1tyfav7XDkXt61OfyIXdkBvsFJ6p1y7JDv37pEIX1rdy3++dKi pL4Q== X-Forwarded-Encrypted: i=1; AKwUvBzKiKlwcXepK8zAAnsADPm09W9MDUVkZxHh+YBjXcbQIKm+uC2PqBa0WMwfYYhY+nihAl77hJsVP1BO@nongnu.org X-Gm-Message-State: AFq9FYIuxuJ44r540oS+6gaU3XpKL/dNabK5S2mifyifgfi2R6xtmoac BwqA+X9z7jFqHq0dNi2usoXkvXd3sWp/i8KBH9KxzpRAfEI2zSvt9xN6QFvNSGVfcLHX6tasPej 6oOzcmhY= X-Gm-Gg: AYBFou3p89gmi9MoP6IQVQqP1wSCN9TC9t53VSHohwVJHhXDJyWGc+SJja3jYMFgg8O bLAy/sEpG+geNdon7kM+Pbffr6LJsAByhaVAoI5Bj64AcLlJT8LCQQafLu43ZpnFRvm+1Sj7EGT YAxi2o5yMm99qjCbujD4O88s2SuEnw8pXQn72IZqmmiIUXYqBT7N3mzQBDUrMFujeOQk6Psn95X GHtaAaO6Jfu6cLeNNuy1vAsPiA7Wh4uKkMt2wajKvXz4U6QIsPvuK/ZIZYCg9QaUA7mKizMOXtL kMGAnqd5m1lc5abTipbYTY/dRrCeCvL9OjsrvOAE+IARAGmO92+VgvGCSPE+Wzg7A5U/1a5587b 6zBBTZfhW+HcCyVZaBJKY3yeDgVo5DdUwgo5djmt4xQDcS4Td14u0KMmHpBli7enDPgmNKqhJRP acA+GKYcKnN+EfxjFLFOPhitcg3A+x8JTGf6wouGk/HnzHC+EeGj9R8uGZYPWav3y/ZPA6WLkMG lqfw+W78/p13xMiVH8uRig8srlUvxK+0Dmi3yL8VvuoyM+17KDDpZqOokxD2em8gOgfDRg64yLf 5Bg= X-Received: by 2002:a05:600c:820c:b0:49c:fa21:1c81 with SMTP id 5b1f17b1804b1-4a18e4d5563mr210443465e9.22.1791880872770; Tue, 13 Oct 2026 01:41:12 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 75/86] hw/intc/arm_gicv5: Handle activation of a virtual interrupt Date: Tue, 13 Oct 2026 09:39:22 +0100 Message-ID: <20261013083933.1024405-76-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881339924158500 Content-Type: text/plain; charset="utf-8" Handle activation of a virtual interrupt. Because this is more complex than just updating a single field in the L2_ISTE, we can't use the DEF_SET_FIELD_FOR_IST() macro, but activate_for_ist() follows the same basic pattern. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 5a038fc14e9..39c96fe0526 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1031,6 +1031,29 @@ uint64_t gicv5_request_config(GICv5Common *cs, uint3= 2_t id, GICv5Domain domain, } } =20 +static bool activate_for_ist(GICv5Common *cs, + const GICv5ISTConfig *cfg, + uint32_t id, + uint32_t *iaffid) +{ + L2_ISTE_Handle h; + uint32_t *l2_iste_p; + if (!cfg) { + return false; + } + l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); + if (!l2_iste_p) { + return false; + } + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, ACTIVE, true); + if (FIELD_EX32(*l2_iste_p, L2_ISTE, HM) =3D=3D GICV5_EDGE) { + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, PENDING, false); + } + *iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); + put_l2_iste(cs, cfg, &h); + return true; +} + void gicv5_activate(GICv5Common *cs, uint32_t id, GICv5Domain domain, GICv5IntType type, bool virtual, uint32_t cpuidx) { @@ -1040,8 +1063,12 @@ void gicv5_activate(GICv5Common *cs, uint32_t id, GI= Cv5Domain domain, trace_gicv5_activate(domain_name[domain], inttype_name(type), virtual,= id); =20 if (virtual) { - qemu_log_mask(LOG_GUEST_ERROR, "gicv5_activate: tried to " - "activate a virtual interrupt\n"); + const GICv5ISTConfig *cfg =3D ist_for_vint(s, cs, domain, type, cp= uidx); + + if (!activate_for_ist(cs, cfg, id, &iaffid)) { + return; + } + irs_recalc_vhppi(s, s->res_vpe[cpuidx]->vmte, iaffid); return; } =20 @@ -1049,18 +1076,10 @@ void gicv5_activate(GICv5Common *cs, uint32_t id, G= ICv5Domain domain, case GICV5_LPI: { const GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; - L2_ISTE_Handle h; - uint32_t *l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); =20 - if (!l2_iste_p) { + if (!activate_for_ist(cs, cfg, id, &iaffid)) { return; } - *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, ACTIVE, true); - if (FIELD_EX32(*l2_iste_p, L2_ISTE, HM) =3D=3D GICV5_EDGE) { - *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, PENDING, false); - } - iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); - put_l2_iste(cs, cfg, &h); break; } case GICV5_SPI: --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881332; cv=none; d=zohomail.com; s=zohoarc; b=iboU/jPYjCGog8KqZnv7pS3qnW/GmDhoiEl/orqH9t2tMj4YpH3a8dLul9wiboiyYWtkb5++Wij3kdIhrMn4/57XZNksudLt3961+mtSgabVB+PltO2wqcScxk5W8flKW3/Ym0Vr5JtWsOlZDLG/TDYkXpmhN60HMBdLcfMcDPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881332; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=H+1SIPr+/cnH/YAjnVN8m/hIlWQogWqNOztypjX89Kg=; b=khxhFFUTXPmxppRACQx0B0JFGn8+5HXtdRrGJFjqhpEGzYKjLPL6v720HSfxFw/pMrf0vk3jlYICrtu1FiX4/D3WoQ4YpvzJpmumR/lEG8SsXpdN4kQtKgBIMnbqEB3+h9EyuvB0Uk4S6R15xo9zcX/TN3To16swxlifeNY+r1E= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188133235550.457668726635006; Tue, 13 Oct 2026 01:48:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY9f-0002Uz-MA; Tue, 13 Oct 2026 04:46:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4T-0001JS-Gw for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:17 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4R-0008G7-C0 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:17 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-48c45111bebso1512533f8f.0 for ; Tue, 13 Oct 2026 01:41:14 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880874; x=1792485674; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=H+1SIPr+/cnH/YAjnVN8m/hIlWQogWqNOztypjX89Kg=; b=SEsfp1/ptSNOo8rGY96Te1Ojp7XtidMQuDVXL5EHOYogacTNcCWcTg5P0pJdJ3mrfT 7h7BNjNmmvsNPLq0kS/PT7JFDpuasllQCCOfAonDgozN1XdIwvmKKZbLteSKEKU4Eyc3 sgFfuTcabWSSOm76ROVZclH709Cj4XQyOVMmDjJBtQib2Ek05YY7QT9sqlvJaA2oVXDF skWJfzq4cHrkBftODu39Uu/6EXVmNApZhLhcnbbfNDabk7O5cN1Ll9B896N+CR9umqzi c1eYRJBJ+S9q5sQvkq3/hb/5aSBMaxlszFgw8Iz8V9zVTUsrJsTUdxftR2qFmDt44Dwd W5YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880874; x=1792485674; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=H+1SIPr+/cnH/YAjnVN8m/hIlWQogWqNOztypjX89Kg=; b=d7HgzpeVkk6enw/ddh/C0tdS5AlKJ0O+wuNMXHpE/Cqn3UVVSfwuiU/QqZfqj1yM2b 37LLypetIrvcStGsyCxxoxa5QmOoe8HVnRRA2aRgyVpHIuwFho3cqC9zOKyfeeONYPVP bA8Vnx6UB3AemveT4mtkmHQ8THeshQo/i1NxkKezDo2KfaPkyrmlRB8JNp3JUzA0I/Cd ivRnkqMOjsV47dH8USFeqqR6/BYyHXRcGbp/L9krJvOHpFDgdST1433cBSD0QhTalnEv ndmOVndLK9koJiFJ9w5q1/nKiEXgxkvmawf8haa1EUFcLNi0Z2cwUoTO851S/Oo1KyUK xpeQ== X-Forwarded-Encrypted: i=1; AKwUvByp+UzHszR3khqX20q2PZe1s6Wzqc8te5NS/TEmmUCXC6XOq2DaSgjonZOw7mmhxvQVk8j2aFaEZgQj@nongnu.org X-Gm-Message-State: AFq9FYLMeNgNtPYt8wENKS7B7fkgkxLqM1W1dkS/4LIruXZM/8xiqimk SJqrjD8Fxd/uyRqQjDDbQFjfuU3ZVB0EWfytvxhcxd0wfbvlRKsH1rAzrTyqgMwTlJ5QXuDLBeq YUIqtWyk= X-Gm-Gg: AYBFou0QAa8whXJskX7whEDY1u0cipiOuCsdmJ/4XNF0eV2Zo2bjgll7m/64VvoTam/ 4jGOSHlOZU1jtZUTNhzPUuLfEUTTwu2cLk6l11CaNJcjXkTz1+YeetskY99A75QyKSvZQPk4phP VDAvQ18ZBX+r5NskKmvS5mpyNrnWqTlp49KgPk/HeI+8IbNK6pZdw6Cq5BTG514ihqvGIombTzo OrNdpLqvihXlS0nilrk95B9lgSfiAOFWhlVjBBS+T7w+JdIch7C49H/GJS6E3p+DGHWBpdp+5/O ZZBJZ4sNtGqdAp0V5iSrhrtw1De/rJ5mjYD4msK80eIDDyx+g6U+NQAReuQCai8CyAm7PCri+Zy 3eJUmJt/Wr5ZLKD/0BE9DeZaoOuYeKbZHXikqondreavCPZJK8Cz9GAWMacDLt7+VsQ/6Yg7JHk CmwuSDMznYU3jHy3hRdmuBYXs8NBSSJVnZarHqhzqmQdKFEU1D73hdjlBslRyYmbAst6roU2ugA s6RvXhvPYCmDWUezRssrtqnFctn+DebWeAoOS1tt+RD0gp5WREdjqSG/vdecZxkdq+l+j9kYL7G s7g= X-Received: by 2002:a05:600c:46c5:b0:4a1:78c5:79f5 with SMTP id 5b1f17b1804b1-4a18e4d6b28mr236081095e9.33.1791880873732; Tue, 13 Oct 2026 01:41:13 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 76/86] hw/intc/arm_gicv5: Handle virtual=true in gicv5_request_config() Date: Tue, 13 Oct 2026 09:39:23 +0100 Message-ID: <20261013083933.1024405-77-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881333810158500 Content-Type: text/plain; charset="utf-8" Support returning the config of a virtual interrupt; as with all the config-setting functions, virtual interrupts can be dealt with similarly to physical LPIs, just searching in a different IST. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 39c96fe0526..8f4d44b2b37 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -994,9 +994,19 @@ uint64_t gicv5_request_config(GICv5Common *cs, uint32_= t id, GICv5Domain domain, uint64_t icsr; =20 if (virtual) { - qemu_log_mask(LOG_GUEST_ERROR, "gicv5_request_config: tried to " - "read config of a virtual interrupt\n"); - return R_ICSR_F_MASK; + const GICv5ISTConfig *cfg =3D ist_for_vint(s, cs, domain, type, cp= uidx); + + if (!cfg) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_request_config: tried to= " + "read config of unreachable virtual %s %d\n", + inttype_name(type), id); + return R_ICSR_F_MASK; + } + + icsr =3D l2_iste_to_icsr(cs, cfg, id); + trace_gicv5_request_config(domain_name[domain], inttype_name(type), + virtual, id, icsr); + return icsr; } =20 switch (type) { --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881312; cv=none; d=zohomail.com; s=zohoarc; b=IG1myF+zLwvIROXAjwSRdsGKw9HrP0cjO+eV503nauCNhVSUBDIhQ2/ABShmk9DOfPamzJHCPNyGixTXHXHWMcX8jeAUIeGyxVA1fzAnRK1RFm6IIExx3a+h95dqYxkBU9XlJDqrVWvHyN+kU+q/O8hsNleoaElhKM7mTGl8PcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881312; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=sNKQ4kUhrMvPbIMfWxjETlhbpb5yOXnbWk+XZZ+a7WQ=; b=AE08MCTTuHNq87DU3bGcyLQww19+KHYqjUSyimnvUtKPOVNkTMRuN9Tqowz4hU58m3K3O5UfzyJmjCXgYV4gEpKPhmV1Txh4YXAbKEnfFoEI17t1ti2Ph4SsRCuw4gG8+6A/dz8XDdbGtfwqUXGZLxA9WrNsNaec2lGBMfF/td4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881312534179.10624600434016; Tue, 13 Oct 2026 01:48:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8g-00083q-NM; Tue, 13 Oct 2026 04:45:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4U-0001OA-Ff for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:18 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4S-0008GO-7P for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:18 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4a1ad2e2391so2932235e9.0 for ; Tue, 13 Oct 2026 01:41:15 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880875; x=1792485675; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=sNKQ4kUhrMvPbIMfWxjETlhbpb5yOXnbWk+XZZ+a7WQ=; b=CiUcMv5wDfv2dtmzHwXzH06IIxhSLZaIIF2YXhHS0AaqdWN+WfrhLDJIWvG8zb/I9o o3edqvxnlRKq4ASPApyFyBXp9hM2zobmaOUrZ+x43chDOrx6IR+DUTBEbzcmZPP75YfD 0+TgCWOSDgjLxZp3jO+GEahrpyrFWRRSMk67llOCXvgPjzkvYU+MjSu0E5rv5qGPY8Qd SHK5y/wyU7Zr6zq2dmNaf87NqtPCJSuldN5PeEmbbGYs9ShL6R9V0IWCuLa6in3TNP7a 4wJlQWGNz/AlEXNppuSQW5KheaGr1ml595cFDW1eoyIqRBIX5nqk75uvg109W3QIeTyM wyGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880875; x=1792485675; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=sNKQ4kUhrMvPbIMfWxjETlhbpb5yOXnbWk+XZZ+a7WQ=; b=odIOxzCBrT4m2l7asJZRa/Qxaa9muvZqbBvfwRPuGzr7guQjT9701Ef41k/TIhBdp1 kG5f54n+vVFqz+XJnzoqnGLLimJfX5Pd2IMqz4RgTx9WKi7omkjPqVILspDd3FTm4xG1 jNSWQvALlUl6jJNGK0RY7jKF075dDFEsioRhT9NWCJV7jw8e+xKxWF3akiAQoB6njXnV gPN7l3gr/rHYrtIVDQJqQz/AlI3wFeWhOE0i2GYkBUHrFtImW1z2hD97ZDtqBv6nNmJK YociK1imiEqlw91PMMu1+a3o8eaD0OmKWR4TbJWHqGzGN2Wk4MlxVfv1ZufJBDq2OO8N ofpw== X-Forwarded-Encrypted: i=1; AKwUvBx+ZOgQ1CRhSt2GmnpVVtCYEH7jfdJuL8hJoaaQEdtRKDK0qOEupdMohFUG7DdPrTVfCC2/QVXTg68c@nongnu.org X-Gm-Message-State: AFq9FYLd6twev18N/r9L9KYusalJ7l5KSsn5kQPkdHd5g2TQBUKpmSTg 072XZ3BVFJ02yQuPTkKj+SIOnH7L7LvXGj2jtOe/HKzKXf0QO8aGdAwGluMNx6HZxFlfhGJY901 yH4cV0qo= X-Gm-Gg: AYBFou2Ykj4lVvQce56TEglrq4nGc11vYZvMPGu0XGFYBP88KAOH7jKq+747FJ+ELbB Nzz286yyPRa8uh4JrBVJkTf3dcauUM/kM/EuhRXv+CpWuvTD3YqkUZySa4Su4b9CU/38sCrmwhA iBFcetSSgyiLt03Xn05Y8hwMX5mZHNRhBOMkW5ErZY9IrrqTVEmcdpE2L0T+Dn3BqtOaiGhQgb9 K4TteN0Ze1DR+BTO9SVsHBHgM84PenNDMWQjJwktYDS88rC4T8olDnBbd06KC4NFkwMGZLiRGdH 3ZH85+U2OyIYGV1tJRl9TgO490dzNcULDHHgZ08+wJaQvEm+ppMO6W9OyrAIhLakiQSyAVl8xgK I5/eC3ajwcfwcREeGBuoC3VbANr4CxTADmG2t8NNh2WvEZgnufy/+wIcVdqcXqllt4WrRnwbwxn wGvKxW4ZCLqJnxMNLo4GG/0/SGnnTNcImZX36kz6jTegKmJRUySMzqej41NFdFfN7Y+DYO+VA/q dcpoCvG1NLtb1vAB2A1uCnYvZ72vyLZ4FS6aW92wcuNo3Y2/myAGfwzIqwaC3Sjx7YwP/MF3zBC r9nHzUSLaQ76bQ== X-Received: by 2002:a05:600c:5493:b0:4a1:78da:d271 with SMTP id 5b1f17b1804b1-4a18e4ee976mr259096555e9.30.1791880874767; Tue, 13 Oct 2026 01:41:14 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 77/86] hw/intc/arm_gicv5: Implement irs_recalc_vhppi() Date: Tue, 13 Oct 2026 09:39:24 +0100 Message-ID: <20261013083933.1024405-78-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881313435158500 Content-Type: text/plain; charset="utf-8" Recalculate the highest priority pending virtual interrupt for a specified (VM, VPE) when we're called for interrupt state changes. Because vSPIs and vLPIs are both stored in ISTs, we can reuse our existing lpi_cache_get_hppi() function by making it take an extra type argument for which kind of interrupt it is working on. The logic for generating a doorbell interrupt if necessary for a non-resident VPE will be added in a later commit. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 43 ++++++++++++++++++++++++++++++++++++++++--- hw/intc/trace-events | 2 ++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 8f4d44b2b37..b4dbe7ce3e7 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -29,6 +29,7 @@ typedef struct VMTE VMTE; typedef struct VPE { VMTE *vmte; hwaddr vped_addr; + GICv5PendingIrq vhppi; /* vHPPI candidate, if any */ uint32_t cpuidx; /* CPU we're currently resident on */ uint32_t db_intid; /* doorbell interrupt ID */ uint8_t dbpm; /* doorbell priority mask */ @@ -192,6 +193,7 @@ static MemTxAttrs irs_txattrs(GICv5Common *cs, GICv5Dom= ain domain) typedef struct GetHPPIUserData { GICv5PendingIrq *best; uint32_t iaffid; + GICv5IntType type; } GetHPPIUserData; =20 static void lpi_cache_get_hppi(gpointer key, gpointer value, gpointer user= _data) @@ -208,7 +210,7 @@ static void lpi_cache_get_hppi(gpointer key, gpointer v= alue, gpointer user_data) prio =3D FIELD_EX32(l2_iste, L2_ISTE, PRIORITY); iaffid =3D FIELD_EX32(l2_iste, L2_ISTE, IAFFID); if (iaffid =3D=3D ud->iaffid && prio < ud->best->prio) { - id =3D FIELD_DP32(id, INTID, TYPE, GICV5_LPI); + id =3D FIELD_DP32(id, INTID, TYPE, ud->type); ud->best->intid =3D id; ud->best->prio =3D prio; } @@ -257,6 +259,7 @@ static void irs_recalc_hppi(GICv5 *s, GICv5Domain domai= n, uint32_t iaffid) =20 ud.best =3D &best; ud.iaffid =3D iaffid; + ud.type =3D GICV5_LPI; g_hash_table_foreach(s->phys_lpi_config[domain].lpi_cache, lpi_cache_get_hppi, &ud); } @@ -572,9 +575,42 @@ static void irs_recalc_vhppi(GICv5 *s, VMTE *vmte, uin= t32_t iaffid) /* * Recalculate the highest priority pending virtual interrupt for * the specified VM and vCPU. - * - * TODO: we will implement this in a future commit. */ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5PendingIrq best =3D GICV5_PENDING_IRQ_NONE; + GetHPPIUserData ud; + VPE *vpe =3D vpe_for_vpeid(vmte, iaffid); + + if (!vpe) { + trace_gicv5_irs_recalc_vhppi_fail(domain_name[vmte->domain], + vmte->vmid, iaffid, + "IAFFID doesn't match valid VPEI= D"); + return; + } + + ud.best =3D &best; + ud.iaffid =3D iaffid; + if (vmte->lpi_ist.valid) { + ud.type =3D GICV5_LPI; + g_hash_table_foreach(vmte->lpi_ist.lpi_cache, lpi_cache_get_hppi, = &ud); + } + if (vmte->spi_ist.valid) { + ud.type =3D GICV5_SPI; + g_hash_table_foreach(vmte->spi_ist.lpi_cache, lpi_cache_get_hppi, = &ud); + } + + trace_gicv5_irs_recalc_vhppi(domain_name[vmte->domain], vmte->vmid, + iaffid, best.intid, best.prio); + + vpe->vhppi =3D best; + + if (FIELD_EX32(cs->irs_cr0[vmte->domain], IRS_CR0, IRSEN) && + vpe->vhppi.prio !=3D PRIO_IDLE && vpe->resident) { + /* R_VBPZM: tell the PE about this vHPPI */ + gicv5_forward_interrupt(cs->cpus[vpe->cpuidx], vmte->domain, true); + } + + /* TODO: we may need to generate a doorbell interrupt. */ } =20 static const GICv5ISTConfig *ist_for_vint(GICv5 *s, @@ -1473,6 +1509,7 @@ static void init_vpe_from_vpete(VPE *vpe, VMTE *vmte,= uint64_t vpete) vpe->vped_addr &=3D ~MAKE_64BIT_MASK(0, QEMU_GICV5_VPED_SZ); /* Doorbell settings always start invalid */ vpe->db_valid =3D false; + vpe->vhppi =3D GICV5_PENDING_IRQ_NONE; } } =20 diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 6d646eacaeb..963fd75c13e 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -246,6 +246,8 @@ gicv5_deactivate(const char *domain, const char *type, = bool virtual, uint32_t id gicv5_spi_state(uint32_t spi_id, bool level, bool pending, bool active) "G= ICv5 IRS SPI ID %u now level %d pending %d active %d" gicv5_irs_recalc_hppi_fail(const char *domain, uint32_t iaffid, const char= *reason) "GICv5 IRS %s IAFFID %u: no HPPI: %s" gicv5_irs_recalc_hppi(const char *domain, uint32_t iaffid, uint32_t id, ui= nt8_t prio) "GICv5 IRS %s IAFFID %u: new HPPI ID 0x%x prio %u" +gicv5_irs_recalc_vhppi_fail(const char *domain, uint32_t vmid, uint32_t ia= ffid, const char *reason) "GICv5 IRS %s VMID %u IAFFID %u: no HPPI: %s" +gicv5_irs_recalc_vhppi(const char *domain, uint32_t vmid, uint32_t iaffid,= uint32_t id, uint8_t prio) "GICv5 IRS %s VMID %u IAFFID %u: new HPPI ID 0x= %x prio %u" gicv5_vmt_valid(const char *domain, uint64_t base, uint8_t vm_id_bits, boo= l structure) "GICv5 IRS %s VM table now valid: base 0x%" PRIx64 " vm_id_bit= s %u 2-level %d" gicv5_vmt_invalid(const char *domain) "GICv5 IRS %s VM table no longer val= id" gicv5_vmap_l2_vmtr(const char *domain, uint32_t vmid) "GICv5 IRS %s VM ID = %u now valid" --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881349; cv=none; d=zohomail.com; s=zohoarc; b=NAGv7n2sL1XnbPZgDQPZ5lEXha1rXqC2GUWK24sY4HGu6pfqtH4X+7MWoGF36GfeJW46MM3OQx5b6r0FHHKJ1TWyhzymUgXV6tbOuoWiVH9Up1XLDDNP+QjAzSmu0jKytwCSzywG7vmnZFmHlUjq5EbcK8lMZfE6oPCWm8gLjIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881349; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=paR4cyu9/UC5Kuni++Tg3b64V5PivixNJ34pK01k3sw=; b=WMAnrngxahRzLfWZdFZHG/+t++twpheC68VZXzIMjSwkvGhR7iGX3gTpRswIAPFM04JMY8Z2jJ40ueVHP8+x1jM7QreSTaEjRxjGd4OACgD3G/jDVFEHlL+RXAPihYA8rYmHBxWuOoT/iVBFi8LjWwIxfE1vGbfLObk20gbtX6M= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881349711397.3605047390911; Tue, 13 Oct 2026 01:49:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8n-0000Ck-LB; Tue, 13 Oct 2026 04:45:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4V-0001Tt-A5 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:20 -0400 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 1xGY4T-0008Ge-7s for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:18 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-49d0da752ffso24467425e9.3 for ; Tue, 13 Oct 2026 01:41:16 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880876; x=1792485676; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=paR4cyu9/UC5Kuni++Tg3b64V5PivixNJ34pK01k3sw=; b=Bm54QZGo6r0vNmS73OZXjMQF1PPmn6RIkfPjgm3Lwkg49SuWDdoksCKwNuK0MWIvZn r7RfFLxeG9j8fxO0lMZW4sHson2yk2xajwrNnX+a8LcDoUdIVuS6pNsz1haUJqLOVnd3 kPzmAtzWsGJM0PR0twrN19Ddp4hyaWF4nnVCl+DkwgkBr96J9QnZRKwEKbL4k8yWXwEO 7KWCueh9DOKol0JDNPyAAucFLzrs4wuJkrlMLf+h+FQX9EthL62EYBm5XStgJshjdvX4 FUziDM5JdWi6YUEgohasjndnTM8jJNpVIkuH6EjuQRFy/1mLRK9x6R/uSDWAe1kVSPt4 mk2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880876; x=1792485676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=paR4cyu9/UC5Kuni++Tg3b64V5PivixNJ34pK01k3sw=; b=fA6ifRqjaVUglHdaLXSaPux2oH11uqQo6IPn8kNO01mANrCBQN8xAl6rOrLGPBbxKb OQc9XxUYDPtewk26GSORxHBpEpiTYCGU6L0JLWhIOnRCGCQjP8/Q1kQ4xlMALe7Scov6 YKmBBvD+xqlL01d51SQVE9XH7jYP0MY6YdfxSuzY0SNQvlx75kPpZ5agJWttT9VwsXMj LhvZOFRNpUROblxpmpkTpa9mmjzdnGre/mNL1C1ybd7n718e+LXMacsy19RfRMugrSWw quOA+uqSeCklheFwkJd7ZeKKrHjUqUe123OuyCmVO98V+R4TTseie5Ylzr70UOGSVO0v 1wDg== X-Forwarded-Encrypted: i=1; AKwUvBxnBkOazTNAEMAYrGuiLvJ5YphoQ0l8Aw9dOs2nu5OoXlCQj3BPHlb5wShDl/foiTi9ZUjdjZz0JZMi@nongnu.org X-Gm-Message-State: AFq9FYIqWmDxvqTgRJNCC8FMmJ7DcggoAVyTQ9d6k7voQGGRN6/hIRzd tb0Kjhz8R/DDBdpScjFvdJABWqFF4SvTQe24Rq+rH7px6CVoplmZNhkcWMN0by8c89A= X-Gm-Gg: AYBFou3wLKIzcuAEQ9HfqDpECRajwutu6Rr3eyKoH8xPzQBOvtOuyrR4KXkHn+tLilz ZH8equVu5c29/GDRqRkXdqOb/AaSKYDsavPRpdGOyQZMWfZhDLCygK3cJlIey9OtRc8o8d7JX8Z eu0MT4Og9LT+epkRP3ecK9LFLFd4NmjZxWfaj244n5N3zUGZUZbF2z051xRPuA1gdJ9MSlMeuHy HZgazPGqvNGu3cjark2DpCp/qGAccemcGi1ZzjgiN84LJtsaKjJbVlTRXVvSX5xnyL5ZLrBiAWT A5SP1goQZihuEEBjPTIx06/gf8CNcWlNOgeKAl++EAKGOxUzE5PuuHKRLp8tuAXJ9IzBb8qC0b1 bSUL7TDm/bdh2NBlgiRTL1kxanFXJjJoUypfY0N1ltCY78NZ2GCQLe2uMTgVeLBMG1kWkuvBGQQ HiV0HsU0DRswdP80fd58Sv79fS4RG2OvErE85uL9+bR3uQwgf9+GwsDLhHKWs2pRfItKUVG68sg qARarciFgTeaHQfIJgS2SMuZgC4TCdHN5QRrzCe5E7nBJ1H20AAk6S9c4w3LFbhecB6ZtbqAEuM nrA= X-Received: by 2002:a05:600c:6099:b0:4a0:1feb:de6a with SMTP id 5b1f17b1804b1-4a18e4e7a85mr223917615e9.30.1791880875728; Tue, 13 Oct 2026 01:41:15 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 78/86] hw/intc/arm_gicv5: Recalculate vHPPIs on VIST and VPE mapping Date: Tue, 13 Oct 2026 09:39:25 +0100 Message-ID: <20261013083933.1024405-79-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881350139158500 Content-Type: text/plain; charset="utf-8" If the guest maps or unmaps the vLPI or vSPI for a VM via IRS_VMAP_VISTR, this affects the vHPPI for every VPE in that VM, so we need to recalculate it. Similarly, if the guest maps a VPE for a VM via IRS_VMAP_VPER_WRITE, we need to calculate the initial vHPPI for that VPE. Add the calls to recalculate the vHPPI for these register writes. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index b4dbe7ce3e7..199547abaed 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -613,6 +613,19 @@ static void irs_recalc_vhppi(GICv5 *s, VMTE *vmte, uin= t32_t iaffid) /* TODO: we may need to generate a doorbell interrupt. */ } =20 +static void irs_recalc_all_vhppi_for_vm(GICv5 *s, VMTE *vmte) +{ + /* Recalculate the vHPPI for all VPEs in this VM */ + + for (uint32_t i =3D 0; i < (1 << vmte->vpe_id_bits); i++) { + VPE *vpe =3D &vmte->vpet[i]; + + if (vpe->valid) { + irs_recalc_vhppi(s, vmte, i); + } + } +} + static const GICv5ISTConfig *ist_for_vint(GICv5 *s, GICv5Common *cs, GICv5Domain domain, @@ -2131,6 +2144,8 @@ static void irs_vmap_vistr_write(GICv5 *s, GICv5Domai= n domain, uint64_t value) } return; =20 + irs_recalc_all_vhppi_for_vm(s, vmte); + txfail: /* Reportable with EC=3D0x0 if sw error reporting implemented */ qemu_log_mask(LOG_GUEST_ERROR, "L2 VMTE update failed for VMID 0x%x at= " @@ -2228,6 +2243,8 @@ static void irs_vmap_vper_write(GICv5 *s, GICv5Domain= domain, uint64_t value) init_vpe_from_vpete(&vmte->vpet[vpeid], vmte, vpete); trace_gicv5_irs_vmap_vper_write(domain_name[domain], vmte->vmid, vpeid= ); =20 + irs_recalc_vhppi(s, vmte, vpeid); + return; =20 txfail: --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881351; cv=none; d=zohomail.com; s=zohoarc; b=kwIdedvlUhsc7JY6ADJWnfIN3KQr6NBjto4IhJ+EWlL+LTjIrJa2MVp3OkXXlhCLGufV/MkZE5cL5RWGnxWNxr4bZ1lL6CuWhsxCSV+DnrDPsAD7kpWty32WSE/IY+514doRsENrt1ZXDjXn5CoMlQPrJ8iz1t+fDJJiiMkesNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881351; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=HEpQd9AvFwO8uwPIw2G7NA2tUj48bKXTa16by3JaLzo=; b=HcmVTRNQUqi82KExxQQkncXtgX8P5T+OWIlYF3DE21J/3eUE8IISPuU2FGBsRxwZevmQ1A5JFvC1kQGafX8vPaMmx9UuOHq7L0KwWt1eoBF3Rt+IzycRqsGanieooSPBpkxD1Wlx2X8qjkC9Y8Or7C/7QE2/EnEPY4dCH4JoqeQ= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881351115891.1343873348521; Tue, 13 Oct 2026 01:49:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8l-0008Si-N6; Tue, 13 Oct 2026 04:45:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4V-0001XW-Vl for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:20 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4U-0008Gs-4m for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:19 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4a172eb31f0so20444575e9.1 for ; Tue, 13 Oct 2026 01:41:17 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880876; x=1792485676; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=HEpQd9AvFwO8uwPIw2G7NA2tUj48bKXTa16by3JaLzo=; b=HHQF9G9cUlVbED3dOFPvl5Jd0ZwOMhynCkqr57Phiwtf2WxyI3o3jC5TSCV/OksDVX G04w4XB+ZT6zHZx1KUxDBxVAFyPJ977OdtNx1xWRlRNWpQYWCRHckPY2n1UykUaMZzP0 6/GB7Kggcvj8Na/HAPQ6l4r2okQ1mCgOQMMS2iittZK6n4D/vPKKHM15m2FqMhKaM0oq 52WAuT3iHclpvdPFnyqJ7DRivFubjPOjGs9mPegP6oXkQsWqUEX/M2YkeagqZLBwqCLg J0cIpUFBlhhnM2KXVUgk/5ThS7qyUdGio0qnKxbr3vLPI4ofgDTO9CUIMZVyA5NhUnzT YdYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880876; x=1792485676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=HEpQd9AvFwO8uwPIw2G7NA2tUj48bKXTa16by3JaLzo=; b=KkVxJdngPEJGIN0onIO1kaWT90iTFY8jKbzwnVtvb8f4yikFAW1bXjCma+CqTeBXGG DuH8ksBing3NY4F+Hni9TYOi8LdB+Fy2IbSz+MHqLwQARgzTeim1+b2DNl87LisCFQtD pGc1broctP2NqQMCkxnBq8KaiVri8YeRUeSCJVJmQfAnci6fIyHB3SdHoO0dOBYWFtf7 wqTSIEDi4wGCYPoZf0oXJaZwgJOGP6sBydUgaFDxm2u1aVxw8ZZUAzWUSX70bLQV41T5 jT6CcszMS7G0hpE2wZQDco9zmw9IXBCSWax0RwwLsCFSrhXE8DSe/183IzgQNRBe8CVH WrCA== X-Forwarded-Encrypted: i=1; AKwUvBwF0TXStOd/5pIrzf3fMfWZkvgi7G74MEqhmzuSBF76zwLwfh7lIiBsm3iUO4gkkE1QKEVmlVz2I4Pg@nongnu.org X-Gm-Message-State: AFq9FYIsarWFAcch8jHPh/5IY20F7zhvnA4Ue+RzoAW7YTu5I+G32LJ2 ZiFmihXmQ2IfD50YSIYPnfD2oNpLtIA679pChsaRQt9sHEFZFCqXE0PkoERg5oH9Gkq9TnYYNVO Cb4NQpBQ= X-Gm-Gg: AYBFou0MNnN4y/MAXDjNhWXTnkjBLFtli/O7cks2gfOJdP+ZRWKnh9/2hVk3mt3vN00 Ia4x2MXa3W2QG6ubG0tbAFLBrucui3sFe9X2JA9OMKQBKVfdfrVs+9pvb1d5GHoq+wyOjAhkzTg OErwjqSYvFlfb/2z6Z6leWj4IBuYR+ZfohNF4+mlSSANK3/9xeiewn3Q7T1Mhh8vLWMN8bDvy9v yFWBcp57OVvtffevAa7dx4nlV9sYd7FDlLGBSzcVzjUgt2Rd+81KagJpHR2pqdRjNikx7dTjoRP q9No1Xo+KNW0EFCNvN5v2T1Gg5HlS97hG7i+2Hx3PnaafQdwI92xPMbG2rNk4WRwZ5ogL/1hbN2 0qbAA/H0rkXjSKfdQgOVBwiM2Um6FXr2PEkKUBFJ8WmkoZz48gRVA0gNfBvQ0yhssf9qXiLXAOZ zYUTsRWVOYSZTs57ul5sCCSY6EX5XM9Q2wAlIaAn7QduacIZ/NW7dZQYX2AlHSr5PyZ/sTbT7TO pM7aqfy4KHcxjQjrvA8zqA5rDDRDcHMby/lvdo/0OeMb60reYoECXqVLkvagb21fDHTfM86kq86 nhgMj9BSv+gvkA== X-Received: by 2002:a05:600c:4ecb:b0:49f:f099:6fb1 with SMTP id 5b1f17b1804b1-4a18e4adcd0mr233780555e9.15.1791880876648; Tue, 13 Oct 2026 01:41:16 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 79/86] hw/intc/arm_gicv5: Add virtual support to gicv5_get_hppi() Date: Tue, 13 Oct 2026 09:39:26 +0100 Message-ID: <20261013083933.1024405-80-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881352182158500 Content-Type: text/plain; charset="utf-8" If a CPU asks for the virtual HPPI for its resident VPE, return it. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 199547abaed..ab0cd1d80e5 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -348,11 +348,13 @@ GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5= Domain domain, assert(cpuidx < cs->num_cpus); =20 if (virtual) { - /* - * Until we implement virtualization there is never - * an available virtual HPPI candidate. - */ - return GICV5_PENDING_IRQ_NONE; + VPE *vpe =3D s->res_vpe[cpuidx]; + + if (!vpe || vpe->vmte->domain !=3D domain) { + return GICV5_PENDING_IRQ_NONE; + } + + return vpe->vhppi; } return s->hppi[domain][cpuidx]; } --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881585; cv=none; d=zohomail.com; s=zohoarc; b=DNB3GhBoWUAPFSPZZNwVH6Q/olF0OEHBBkABKWivxPkpRNIdhviiDyz1Cc/0v8eUBEQqxrWYIp7zGbu7/qn8GStm4fK5wiVy6M4yJWHZoAJnyyYw65JWN+/DUW4PhESCj5IHoOLDsG/nqahhIjFUV4MMkB+5EL5KGzZxqt09hos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881585; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=4um6vfgWs9h9kp00xbqJa6oHTA9SbTpa0Ruq+mXG+G0=; b=oCo39yOOuvpCq799SX2qZjyzvPIsyi8zWL8Yf7+IJBgAtJ/RhAPYk9qYePSL4hF3UWRf20KtjB44Qa21+rXAeNAlB6Ykkh3u88eCaIgPvyixzFDVbBC37jkQrvL81tMgbMrALmVeUSkAbr7OqGl6qx8tAXEeZuVpyFIeliddaAk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881585579573.561831032543; Tue, 13 Oct 2026 01:53:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY9f-0002TL-Ex; Tue, 13 Oct 2026 04:46:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4a-0001k6-N7 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:28 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4X-0008IC-NE for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:24 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49d0da752ffso24468155e9.3 for ; Tue, 13 Oct 2026 01:41:21 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880880; x=1792485680; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=4um6vfgWs9h9kp00xbqJa6oHTA9SbTpa0Ruq+mXG+G0=; b=fMhJP55lr+f1v0emdF0UCSQIH9vjE37/YGzLS0sxrkVLNmK2QgubE9C/142PiWvQP5 EE4piIec9usMdBEdfVn33mqYYMsqXhFSUGzltU7qQ8hxEH0YOsiLmcY1a2wSiUEbFHqc cVWWpIBD+7H5wA/HcS+dOLhIabF3z3h5b3BDn2+wvF71JoQdxDyqJWycVaarMXkzOmza 2SpzvI3FtMB+bM30bcMddjjU8nqPWqB3AyAichWse4fpafyt+/jDJ0N3mWTRORf7yiYt 6b4RDnQjs+cGz34biU8E5ENEyscWusZTEXwuofk4K2Yo1yl+IIuOkAJBOlh53LtA3Hl2 3xYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880880; x=1792485680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=4um6vfgWs9h9kp00xbqJa6oHTA9SbTpa0Ruq+mXG+G0=; b=vAYWm23iLgBjOfyiWJGuu7RQ1jL6Dn7b8qY0QSfyOI7Gjq+Nxc8JQI/QmbJ2iFwY/l BBfoVJt9ErgqNz+geag0ubxYOOpa2JoXVg9LFQHrcQW5tGrtNx5iW8H5LowgTKJn8otK z2ZIixQNFFg67yDuclQBz4yu1o9rbL9ch9nXXfXokfX7PqrYySO6UHlEsh8FNGw5M2Ie uc2eXQMwhds33rVhkbZ0Ql3VErDe6VOAdLoqJIrdqRQR4mh8mRi0k7vVA0AFZNUprTzI pKzfBHFJQzEAVknS4HT8nYeDu+XKfx/jIO/1qw8bh44DzQeHT5xhQRj4YShhPHfPX/Hy OyjA== X-Forwarded-Encrypted: i=1; AKwUvBzH8eJSzRqFoX2gDhoibJg+W5nYaMeFnR9KOvU4sNtP1B+UY7sGvwgOfyaP6K24X7Ay3bNAcmGaLCLE@nongnu.org X-Gm-Message-State: AFq9FYJb9HbDUbPaRihzETnKUvOtaK5mnyPazOYLctGIBIonFpX05/hH aflvD6kLuqh6BiiDib0A9MCqvdAsxDIaZ79iuZ1CaSYi15vZHDEkmIhjX+Is3X7T4txG7cqpKPC t9s4zEgw= X-Gm-Gg: AYBFou0V7SnWJt1F8n8DLa+pPiMravmktrP/CJelUulzUmMFjtKbUZFgJQOiD+84ULm lbXQRqM7+c8lLFXWVh2DHoj3eAoywIX17fYUAJpjQ7La8B7JzObpgbQ6B+yR3HMj2Z8WxvCfDo0 Hlbdux6ZtdGdIqTwQgrqoDifq1pwx3t8+9t99g71QzmHbR4TEiG5t1ICC06kN5NT/iXuGpoDI/o yE90OArC6m5jhSLhv+kNxo+PpoffGQEizYHUSzC5S0/jtmHQ19dRtWwZGzBMxAKBwpZYArcSOTQ 3AH59XVak8m6TxBiUtQYz3tOalQzroFd0tf34XD2CsH7Coo2bMj4BkJOm2hzv2gAlWWKZ3SkofZ smQzm7seynH7qX/Q2zzQHiDYcJrOjo75r0XYX8+gjsZOfI3uO34wq4olR/F2aLkAgE1WhS0L5Bt rS/DAKm7NfONKsT9qgyARS5x12MeQJK2sk5okjNHNPngJXrXL1mn2j/u/TzZWkSUQnpOinWj1nB ToXzotDf/ZLz9wAtzlveGQ3rxuD037VQDxjB13ynObOJXwlaV3rilb2nbPsOu6F5uqSgm32su5c fAs= X-Received: by 2002:a05:600c:6383:b0:4a1:a6e0:4ce4 with SMTP id 5b1f17b1804b1-4a1a6e04d7cmr36094065e9.33.1791880878575; Tue, 13 Oct 2026 01:41:18 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 80/86] hw/intc/arm_gicv5: Implement IRS_VPE_HPPIR Date: Tue, 13 Oct 2026 09:39:27 +0100 Message-ID: <20261013083933.1024405-81-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881586663158500 Content-Type: text/plain; charset="utf-8" Now we are calculating and storing the vHPPI for each VPE, we can implement IRS_VPE_HPPIR, which allows the guest to read the current vHPPI for the VPE it has selected using IRS_VPE_SELR. The specification allows the IRS to return the current vHPPI on reads, rather than having to sample and hold the vHPPI at the point when a VPE is selected by writing to IRS_VPE_SELR. We choose to do this. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index ab0cd1d80e5..b3ce8a87e81 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -2319,6 +2319,21 @@ static void irs_vpe_selr_write(GICv5 *s, GICv5Domain= domain, uint64_t value) cs->irs_vpe_statusr[domain] =3D status; } =20 +static uint64_t irs_vpe_hppir_read(GICv5 *s, GICv5Domain domain) +{ + /* + * The spec allows the IRS to update IRS_VPE_HPPIR as the VPE's + * vHPPI changes, rather than sampling it when IRS_VPE_SELR + * is written like e.g. IRS_VPE_DBR. That's what we choose to do. + */ + VPE *vpe =3D vpe_from_selr(s, domain); + + if (vpe && vpe->vhppi.prio !=3D PRIO_IDLE) { + return vpe->vhppi.intid | R_IRS_VPE_HPPIR_HPPIV_MASK; + } + return 0; +} + static void irs_vpe_dbr_write(GICv5 *s, GICv5Domain domain, uint64_t value) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); @@ -2617,6 +2632,22 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VPE_HPPIR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(irs_vpe_hppir_read(s, domain), 0, 32); + } else { + /* RAZ if no virt */ + *data =3D 0; + } + return true; + case A_IRS_VPE_HPPIR + 4: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(irs_vpe_hppir_read(s, domain), 32, 32); + } else { + /* RAZ if no virt */ + *data =3D 0; + } + return true; case A_IRS_VPE_CR0: /* RES0 when VIRT_ONE_N is not implemented */ *data =3D 0; @@ -2962,6 +2993,14 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_VPE_HPPIR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D irs_vpe_hppir_read(s, domain); + } else { + /* RAZ if no virt */ + *data =3D 0; + } + return true; } =20 return false; --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881271; cv=none; d=zohomail.com; s=zohoarc; b=JkQDYefAQXA+O4+tnQ2I45MScz5LmMJb+reU0mHHTDYbbfSlPJbavwzlGrV1cXqrO1yUiqpB0hD47aLhJ9G9bNedQYln3Bmk5/LlileMRyX67pS2MGQHx9bpdzqwjkLZaiCp+e7go+J9ZUjo5zxALgsMyev8VVkNryu2K4S+K6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881271; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Joy6MjKedRL92Qe+KSl4RhEqFwkrMXSKOsSYWcHJFiQ=; b=a5DfZXtWDi10agUHh2m13QOJBYAxKXg/ipMGJgmJJSxLYBlPJUM3ZDnUq5tNimYK0+IjOCrI8U7wQJAZ8MfznClh3WjSNCG5b2Mmdv8HjiiPATI7K+RDNd4tHOgLJX9G9tWe7GyiWqYf3wRzMjKjoDwbQnPWnOtRYQ+OyRdi600= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179188127141442.95391026012851; Tue, 13 Oct 2026 01:47:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY9N-0000eY-Ii; Tue, 13 Oct 2026 04:46:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4a-0001k7-Qu for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:28 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4X-0008Hu-8S for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:24 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4a172eb31f0so20444955e9.1 for ; Tue, 13 Oct 2026 01:41:20 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880879; x=1792485679; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Joy6MjKedRL92Qe+KSl4RhEqFwkrMXSKOsSYWcHJFiQ=; b=u3BrQTiiay7WvHPG/SLxxI/BuPqbFvuqxdJyLk4PtqCdJB+AHnefuX3Vc9zKsKKeRa cLvxOJ/VXNQ5/nIAgd8f01S04otMyBUogAneXE5r0YgLuYERhSFL6vx9f0vfYiBMhHdS xFerADDR3JEgB9QPMSPO3AdZDpt8vCY3GMAeaR+cwmVncd2EQc3egNlEDgHtzybesmN4 vck+eF7VOT8icKUpPlSUl/CfJ6bsxkq3Iv1L5vZePzzb2GtqxW03kXsISU4MAo1mJktS QKsHQk1OSj5Z8bUQf3b7trPHACw4XmDSaeYglUpbsrLkHQ3WmIeTvrqzWU9jG43ZmkM/ F0eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880879; x=1792485679; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Joy6MjKedRL92Qe+KSl4RhEqFwkrMXSKOsSYWcHJFiQ=; b=E0+FErTzKkklIb5QC+a+FjQqmvOqAotgecu6lrcIMve8AX79wY3guQHRWlMTGmOwgi qbrhuBgEe+cM6iHtqDJILmCObnTdZRq/QlEzCAERL3SNZ4Ag+CxRU0KAAetWjPFmlQ74 0ukcN+8YkuT2qXdCvomMnUqa02/SbQ9YnphLa577bzEB/6A2dAwGyXODlc3DGZzhiDzt lVNQKJ6RYHUqzizzK18kuOPC839zu1xupBfmI4PMqLmdLoHtW6YAOrwhJKOJOfQkRetL 21Yd0eyufaeTFXGorL+IE87hHq+Nr4yxtn+DVHcbFX+fgZbbE9kewHB7O5o99utmsJT7 7Upg== X-Forwarded-Encrypted: i=1; AKwUvBydbvHLWRkdGIocCzV6rPLDVKc+K2qv/IJt/pPLhC0Z5lNkqWqH4QCswfqjfZqkW2OrI0J06eITLbx+@nongnu.org X-Gm-Message-State: AFq9FYIc13rfpW15Zwwmt4NjRsaaUkiDY9QpBv/w4RxhAE/JKfEr15RX 7xLtkHzO2tw8SjbREwtbB+UbbT1qpq13W5hNAsQ/Cxan6EVjLjqzOC6vVWOT3svlBYhBhP5SqXL Z4To/eHw= X-Gm-Gg: AYBFou0mGN3HIfYzMAWWozOcau/PL0D7JojfH793qTxwolvKgPuQQUPk3di+kio1bSg c9miLWS7i2zA/AUMf6FnfC6JNAPfKpyHE51AErwyQQg+p2DZOPfKdlfOrThnss7HOdoL3Zn/wfV cNTviyNoQgeB06Y4oesFPPGBPPT6/lP5qieDM/6i0xiiATKaHooAU277GmhWo/VuCrqjvgU38z5 lNHtvJcoS0TMurK0fcwav1kJ7rOZ1o7AdE5sM2LSZE8T2uwz/e1OlEJF8dqhL+kTqBPDZoJNboH dymo3L6CvRPT+Rq7vbVAfar67prkj5SqAAoXZfM3SgCs5c8fLtsYj5MATDWx6IIxGiMmyWvnEbm 80cX0ud/HjNSjVUZo2tasd5YpLz30MeUNSFHNHZeyqntFyKVvR9kESdOFidWSOqvQPzXJUkO6DH zyfSplJMZ9JYEVy4PDfEKxp8c6IcPL7ghJJTNqZTzpcYXyggwdRtFuv62YTAiXSJuiv3U/UQbzN yahYzRicdCt+NaaaS67LqDtXs/pCgA5i4gIC9w/nHvzMXDEEh8hWWQH1MqvmunUzOXabr194UpH fKY= X-Received: by 2002:a05:600c:c176:b0:4a0:c2a:485e with SMTP id 5b1f17b1804b1-4a18e4dce0cmr225675005e9.33.1791880879547; Tue, 13 Oct 2026 01:41:19 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 81/86] hw/intc/arm_gicv5: Implement ringing doorbells for VPEs Date: Tue, 13 Oct 2026 09:39:28 +0100 Message-ID: <20261013083933.1024405-82-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881272733158500 Content-Type: text/plain; charset="utf-8" For the GICv5, if the IRS has a potential virtual interrupt for a VPE which is not currently resident on some CPU, then it might need to "ring the doorbell" by triggering a physical LPI to tell the hypervisor that it ought to schedule the VPE so it can handle the virtual interrupt. The conditions when we need to do this are defined in the spec by R_CWZMW: the VPE must be non-resident, have valid doorbell settings that request a doorbell, and the pending virtual interrupt must be high enough priority to satisfy the doorbell priority mask. We thus need to reconsider whether to ring the doorbell when the vHPPI for the VPE changes, when the VPE transitions between resident and non-resident, and when the doorbell settings are changed. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 62 ++++++++++++++++++++++++++++++++++++-------- hw/intc/trace-events | 1 + 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index b3ce8a87e81..a1fe6a8a822 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -572,6 +572,53 @@ static hwaddr l1_vmte_addr(GICv5Common *cs, const GICv= 5VMTConfig *cfg, return cfg->base + (l1_index * 8); } =20 +static void irs_maybe_ring_doorbell(GICv5 *s, VPE *vpe) +{ + /* + * Ring the doorbell for the VPE if required by the conditions + * defined in R_CWZMW: the VPE must be non-resident, and have + * valid doorbell settings that actually request a doorbell, and + * a doorbell priority mask that allows it. + */ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5ISTConfig *cfg; + L2_ISTE_Handle h; + uint32_t *l2_iste_p; + uint32_t iaffid; + + if (!vpe->valid || vpe->resident || !vpe->db_valid || !vpe->db_req) { + return; + } + if (vpe->vhppi.prio > vpe->dbpm) { + return; + } + trace_gicv5_irs_ring_doorbell(domain_name[vpe->vmte->domain], + vpe->vmte->vmid, vpe->db_intid); + /* + * Generate the doorbell event, and clear db_req so we only do it once. + * This is a SET_EDGE event for an LPI, so (R_HHKMN) it forces the + * LPI's handling mode to Edge ond its Pending state to Pending. + * If the LPI is unreachable (no LPI table, etc) then we would + * report it in IRS_SWERR_STATUSR if we implemented error reporting; + * the doorbell is marked as no-longer-requested regardless. + */ + vpe->db_req =3D false; + + cfg =3D &s->phys_lpi_config[vpe->vmte->domain]; + if (!cfg) { + return; + } + l2_iste_p =3D get_l2_iste(cs, cfg, vpe->db_intid, &h); + if (!l2_iste_p) { + return; + } + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, PENDING, true); + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, HM, GICV5_EDGE); + iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); + put_l2_iste(cs, cfg, &h); + irs_recalc_hppi(s, vpe->vmte->domain, iaffid); +} + static void irs_recalc_vhppi(GICv5 *s, VMTE *vmte, uint32_t iaffid) { /* @@ -612,7 +659,7 @@ static void irs_recalc_vhppi(GICv5 *s, VMTE *vmte, uint= 32_t iaffid) gicv5_forward_interrupt(cs->cpus[vpe->cpuidx], vmte->domain, true); } =20 - /* TODO: we may need to generate a doorbell interrupt. */ + irs_maybe_ring_doorbell(s, vpe); } =20 static void irs_recalc_all_vhppi_for_vm(GICv5 *s, VMTE *vmte) @@ -1428,11 +1475,7 @@ bool gicv5_set_resident(GICv5Common *cs, GICv5Domain= domain, bool valid, =20 trace_gicv5_set_non_resident(domain_name[domain], cpuidx, db, dbpm= ); =20 - /* - * TODO: when we implement VPE doorbells, we should check whether - * we should immediately generate a doorbell for a VPE that has - * just been made non-resident. - */ + irs_maybe_ring_doorbell(s, vpe); } =20 /* @@ -2369,11 +2412,8 @@ static void irs_vpe_dbr_write(GICv5 *s, GICv5Domain = domain, uint64_t value) IRS_VPE_SELR, VPE_ID), vpe->dbpm, vpe->db_intid, vpe->db_re= q); =20 - /* - * TODO: when we implement VPE doorbells, check here whether - * this config change means we should now generate a VPE - * doorbell event for this VPE. - */ + /* This config change might mean we now need to ring the doorbell = */ + irs_maybe_ring_doorbell(s, vpe); } else { trace_gicv5_irs_vpe_dbr_write_nv(domain_name[domain], vpe->vmte->v= mid, FIELD_EX64(cs->irs_vpe_selr[domai= n], diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 963fd75c13e..ddb7ab06207 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -260,6 +260,7 @@ gicv5_irs_vpe_dbr_write(const char *domain, uint32_t vm= id, uint32_t vpeid, uint8 gicv5_irs_vpe_dbr_write_nv(const char *domain, uint32_t vmid, uint32_t vpe= id) "GICv5 IRS %s VM ID %u VPE %u IRS_VPE_DBR doorbell info no longer valid" gicv5_set_resident(const char *domain, uint32_t vmid, uint32_t vpeid, uint= 32_t cpuidx) "GICv5 IRS %s VM ID %u VPE %u set_resident phys CPU idx %u: no= w resident" gicv5_set_non_resident(const char *domain, uint32_t cpuidx, bool db, uint8= _t dbpm) "GICv5 IRS %s set_resident phys CPU idx %u: now no resident VPE; d= b_req %d dbpm %u" +gicv5_irs_ring_doorbell(const char *domain, uint32_t vmid, uint32_t db_int= id) "GICv5 IRS %s VM ID %u: ringing doorbell LPI %u" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881206; cv=none; d=zohomail.com; s=zohoarc; b=ZIBaGmugg/i7+zN3X+EU+Or37GCnVa6xRS5kDtZ46iYYR1h7MSPyZKJ9YOUHzLq7b0S8Ebx+0UOTBEpPBOOf1gBtGMBMN08Rd5c1ylryR5BMuKY/hPltkcIbdzqDBtf1bMq5d7HKfIfmtapkFkh3EG/jm2RK1WttAMZfabyuGjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881206; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=/rH4fU/p7+EqPtCiTHc5w5GxOjkg2Vv400q3+sU1L1o=; b=GsCNbmLpaY1Wj1F/TtMLi7j4fwQFUwNn15AzlQKDhZ6Nw0WtHUrVqvJsaB1irlNFcWJYbO1Nfjkt06PzbDrZRTJXBW6QmNBOFQW8QQd4uJUSEk6ulz9mR1A8YWVhwO91kgxiFjKKpap5FDuWHlxWoGj/rTGOPU7ewffTaGqV2oE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881206654545.5914793036966; Tue, 13 Oct 2026 01:46:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8B-0006Tq-VY; Tue, 13 Oct 2026 04:45:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4c-0001n9-6D for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:28 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4Z-0008Id-BS for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:25 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a19cba5c14so20027295e9.3 for ; Tue, 13 Oct 2026 01:41:22 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880882; x=1792485682; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=/rH4fU/p7+EqPtCiTHc5w5GxOjkg2Vv400q3+sU1L1o=; b=l/eg47UIJScBomEF3y8j93j7ULzOCBsUfZJTjLhdiIIOfDNh2DgUiacZ98d7rERqbc LnF/6QLYSXTvSshgX9PzeBn+JmpAsGUk7z8V6vCerMSu7BUsiI67QP8xQ647bqY7H0hq 5oesSbiSkTX9YzCwmVHMXpZSxr73OSlmIVB64fuCNwf7ERo62BYqAYCEk+xPK5qYmTWl YbuhgazTWXR2P8pyST7aWj9QdBmu49v3mJExMvqPkqGdkegiKFW6BTQ3b8i80QP0I03y Yk6lGV+zB1LhLViBJdzxG7Hu4BTdOESAKNIU/zyM0g23iV7gCUrDDxJr56GCB9XtCH1B 5p6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880882; x=1792485682; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=/rH4fU/p7+EqPtCiTHc5w5GxOjkg2Vv400q3+sU1L1o=; b=JmF4kEEIOLuVB6V+vQvqJ8pAA3MzCN2BE7VoCc8SAjE+gJ2jkk61M0VkFPvFdG7bVc l7N9wwyCFtDYF9DGKs9CAB9oJKgu7rR52H15xbd0XfuWLzDpqYCjqlfR0ww4dDpIH9zM Vbf73/P9rGLQfSfhX8LYZbpzjLDyX9Vb/nv7aTqUbbp1r+leiHmdik6EFUZqNMbW0xMw p72B6Z5/zf5tbYVf+v33w/bNF34TKskazfvTKi7ZYGhEvNxgJ5ioVuiInugBPY9B/h4k mBWKOd5lg56An6suR02ix5lEa3sAVdluaigIjpVlzKG5T/8aS2ypfRYNdxTtFWEcMnBk 5Sbg== X-Forwarded-Encrypted: i=1; AKwUvBx+G8Ce9KXSwGbMXC/7DNum1I2mA+spx+QJmyBC6YrwUmFfYW6xbQVU26WW///akkDhnNEWyWlrOqyK@nongnu.org X-Gm-Message-State: AFq9FYK2qfsisPKaaU6fLQ5hUGXNo3DE1+hjNV5Wqp/qRxqZch1lPCwb OA7yRdRzbJ5RsB0jvZaWgkvZeZ/E8qtL4o6SEMFss5I7+pge77+wTKprumrAxXrqEcE= X-Gm-Gg: AYBFou3SU4HEXm4Kj5O1kMkTvaPOyTDwUibJ0S+8Zc3Wq3T8jxApAQ1u8Av1Fr8/PX3 f8qDvLC058eoD+OqiEOm5d1xJJvEKNWUgj9gKCTfrKyH2U9qLlXKcdpyx0b0VKZWP3lJ2fq4Px2 pTibfIrtribouk+4pDEMJHJ5CyM5t8TreImcnMRNFWiWcDoDtbYExNBVzcSW6zNnPx7ASfYeZsK h4HmuyqwIXYoSu4ze2x9sgvP6Oj1z4Py2Hzvilfdk6OwZX1y2QicBpk7JEU4CRKRMizC/UMYxcA aTMkmqLBXnpshQ/0jg4a0HVqoU/3K/UwaCPGILDkWi3SOFC9e1dBsEppxQIABXjF4va6XAjzpfC nuzx8eMAacNnxUsLGrfnC45oRuydN5JovFg1X7mdBp2SDCKbJ+CTzOTynR5EFE4bOeey3O71B4z EL/j9zpIRgPVsHtCMfVQAeVWiblzqoJMSEEtTEJIjU91XXbi5VHkrOVm+xf8jKTZWMRrTu7fDz/ Lopz8F+u7hgcaBoTDkCzh0IzEpcjbAgiMlmwxo2kUBH3LrZP499gHbe0BHahE2LrgU5wbwZaxSA h2OA X-Received: by 2002:a05:600c:3494:b0:4a0:bc9:28c6 with SMTP id 5b1f17b1804b1-4a18e4fb31emr225151755e9.34.1791880881754; Tue, 13 Oct 2026 01:41:21 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 82/86] hw/intc/arm_gicv5: Handle vHPPIs when IRS_CR0.IRSEN is toggled Date: Tue, 13 Oct 2026 09:39:29 +0100 Message-ID: <20261013083933.1024405-83-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.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: -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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881207460158500 Content-Type: text/plain; charset="utf-8" The IRS_CR0.IRSEN bit is somewhat misleadingly named: it is not so much an "enable the IRS" bit, but instead an "enable having the IRS forward HPPIs to the CPU" bit. If it's 0 then the IRS still does all its usual activities, apart from telling the CPUs about interrupt candidates. This applies also to virtual interrupts. For physical interrupts, we implemented this by not calculating the pending HPPI when IRSEN is zero, but for virtual interrupts we can't do it that way, for several reasons: * the vHPPI is visible to the guest via IRS_VPE_HPPIR * whether we should ring a doorbell interrupt depends on the vHPPI, and this still happens even when IRSEN is 0 So instead we need to check IRSEN in gicv5_get_hppi() and return "no interrupt available" if it is 0. We also need to re-prod the CPUs to ask the IRS about its HPPI candidates when IRSEN changes. We could check IRSEN only inside the "is (virtual)" block of gicv5_get_hppi(), but it's equivalent to do it unconditionally (s->hppi[domain][cpuidx] will bo IRQ_NONE in that case), and it's a bit clearer I think. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index a1fe6a8a822..4572e5a4017 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -340,6 +340,31 @@ static void irs_recall_hppis(GICv5 *s, GICv5Domain dom= ain) } } =20 +static void irs_resend_vhppis(GICv5 *s, GICv5Domain domain) +{ + /* + * The IRS was enabled or disabled for this domain. In hardware + * this makes the IRS either forward or recall any pending vHPPI + * it had for a VPE resident on the CPU. For QEMU, we tell the CPU + * interface that it needs to ask the IRS about the status of + * virtual interrupts for any VPE that is currently resident + * (which will return either "none" or "here's the new one"). + */ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + + if (!gicv5_domain_has_virt(cs, domain)) { + return; + } + + for (int i =3D 0; i < cs->num_cpus; i++) { + VPE *vpe =3D s->res_vpe[i]; + + if (vpe && vpe->vmte->domain =3D=3D domain) { + gicv5_forward_interrupt(cs->cpus[i], domain, true); + } + } +} + GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5Domain domain, bool virtual, uint32_t cpuidx) { @@ -347,6 +372,10 @@ GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5D= omain domain, =20 assert(cpuidx < cs->num_cpus); =20 + if (!FIELD_EX32(cs->irs_cr0[domain], IRS_CR0, IRSEN)) { + return GICV5_PENDING_IRQ_NONE; + } + if (virtual) { VPE *vpe =3D s->res_vpe[cpuidx]; =20 @@ -2738,6 +2767,8 @@ static bool config_readl(GICv5 *s, GICv5Domain domain= , hwaddr offset, } else { irs_recall_hppis(s, domain); } + /* IRSEN affects whether we should forward vHPPIs */ + irs_resend_vhppis(s, domain); return true; case A_IRS_CR1: *data =3D cs->irs_cr1[domain]; --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881628; cv=none; d=zohomail.com; s=zohoarc; b=NVUuu7w8L3LO4oXolUFTPxxnuhRFOOAZWZSSYnSQdFL6mWuCthRFRYMHalVYEvw2/pDHzTcErJSacqUUgF07Xqq/M8Z7/JtIabv/Slolrv0GTZ5m7tPU6R11B8aGrg3U3ZbLXOdPL0rmc3YThgdQrmTH1yz3ht89m7/hHe1+IIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881628; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=mT31UjfoQOsSWM6/4XaazdVD7Jw1EvSOBOVSSh0qErU=; b=VkxnCDEkyr1Icirxr0NbVBza80OhDn1ORo0YJTpIAjjDN7Iw/xpkp6Fj/O8/gCbCjido2WuFrCR/nEQZ+u1NdznX/6Z/sq8Ad/L1P6I5vg1EkZCprc5B8ek8SAyHe21BSkgKAZ/QaFKYNLib26G/GVp2jw9YPe0KfhiY1fPtGg4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17918816279171.7226661914332908; Tue, 13 Oct 2026 01:53:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY9Q-0000vV-Mq; Tue, 13 Oct 2026 04:46:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4d-0001nB-NS for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:28 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4b-0008J9-BH for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:27 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4a020e65269so16623885e9.2 for ; Tue, 13 Oct 2026 01:41:24 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880883; x=1792485683; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=mT31UjfoQOsSWM6/4XaazdVD7Jw1EvSOBOVSSh0qErU=; b=fpfQM/yXsYXMmNGsU0czs1VyIJ5ODb1DSF/Fr7LB7br2NlvAODOSGdBQELbaX2iXsj GLaoRQEROnRz6fdjNj+idtOi0LMdsISlAfna+w/QhFonx/aWdqq3H+1VL24/V04CWIrD oMO/EgJESM3fmDgw76QHkSTxNEBFlkNt74GDxjITEP5B7dKX3I/wApwsYfYYzEI7DADz 8edskGTiKwP/rHFoAF7ZbbtJTPZ8kH/hxLDwpGuLEObbDIuSiIbqLTJkruh3ak6bxCB6 XsC4y9/KT/KA9ed6LAh5UaXM54/ApNdABLQqUBNk1FtFAGa/YKVV6EW3JWQAJNyqJ5Yu xcGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880883; x=1792485683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=mT31UjfoQOsSWM6/4XaazdVD7Jw1EvSOBOVSSh0qErU=; b=TkDkHlzAU+cGoyEPjiPTXn6jpFZcE+jD6emqlOZeYbi3xNdu8o4PZjaMiUe6X8OQIK 0AEal6d+QGSPwvhVVtqPyJCcLZVu2tqcnBctehvTNUJ2qXbFNXnZM0EF9JJg1FVAx8dM DyE17RUvMof7GJYW+yQ4HQjo0jLdal4g+U0oppN0PhAyF4nv4Xp0rcvAJXpsqFzvIOY3 ad+GmKFWwodYI1N2qe38kCpVpomdGJCMh+T+SXxabQ3vWQzZXA44n455gEzFQ9Rt+lv2 mylrN1zLZSb6uITaNS01JyQwOhTsMgylFgm7tZ7UoXvHTOpTxAVahaG9q6zBaLt0K9jW az1A== X-Forwarded-Encrypted: i=1; AKwUvBysr32oC8+KYB+zf5Md73CgSaA7LQ9Fbd75A3cThj37PB/13PQT+8z4OQOc92XmzT7RgfzrNPEHX6zO@nongnu.org X-Gm-Message-State: AFq9FYK/sy2dbyl26xJrJGV2QU1TCcXZFIOXB8eA/4LdInNnzsHPXa4d zYR8PKOyPjg4vv49S2x8lF+gLDmfrIzY/lzaZ4GWWstg6yljdDllf8L2uw1JtkAbGwk= X-Gm-Gg: AYBFou0EO1VAIYPSertfQ6F+Ja4IUXFMxFsayqzkRMuEm3dEJUx9ATOcYCeq+2Q6isf gMqMzdOnusPiXCWl4npqNcMLEyZU+xft3Dq6nI6I3S17t3Jdc2cDjZ5l8ITUWFDg/SKdQ3G0iwX xWEligHM1o2H3DhfqKa0+VYxbL65OV+6BCm5OnzQwO0Pu3Tkbb9IAxSjlRmn4xoS6wp8vbuXbVE rOKh5SkqWAJ405cvcN6Rd5QSsYer3XiQIZWFbF82HX2/9OF7soC+MUI/HT4TN9wfZaR0q/+3FQV 5eUNInNlCsaVueeyT9lXFpidLHVaXwQf3uKL195xKC3M65ER04FLREeNaAc78jR6g3Z3FX2AHEx ufC7iBZzOUvzI/CSp6M/PFc+UHXeuWxYlCsUhpSPIMAzttV+PcUx5OT/EMWD+rMM7AY143CPUlK YK7cNS5hF8TfgbVQutLxnifG2+gfrd/bcR2B28mMAY4y8ScOR9Jy4SKBI6O+Yu1CaLs+O+/H1Bm U1S8H1XcSSeW8AMSmMCC3JPwe0mwNxBKBcuAwItu42uZdVLcLlBSYss8tVocniXpZ62t36+sko7 LlA= X-Received: by 2002:a05:600c:a010:b0:4a0:2500:2cd0 with SMTP id 5b1f17b1804b1-4a18e4b4646mr206929765e9.18.1791880882736; Tue, 13 Oct 2026 01:41:22 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 83/86] hw/intc/arm_gicv5: Implement saving virtual interrupt state to guest memory Date: Tue, 13 Oct 2026 09:39:30 +0100 Message-ID: <20261013083933.1024405-84-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881629685158500 Content-Type: text/plain; charset="utf-8" The IRS_SAVE_VMR register allows software to force the IRS to write out any cached virtual interrupt state and configuration to the guest memory data structures. (A hypervisor will use this as part of saving the configuration of a VM for migration.) When software writes the S bit to 1, we need to write out cached information in our hash tables for the vLPI and vSPI for the VM. As usual for QEMU, this operation is instantaneous from the guest's point of view. IRS_SAVE_VMR also has functionality for software to check that the state of the VM didn't change during the save procedure. Because we will have only one IRS, we take advantage of I_DSRQY's suggestion that we make writing {0,1} to {S,Q} be a no-op. This means handling of the reporting of the Quiesced state can be done entirely in the implementation of IRS_SAVE_VM_STATUSR, which will be done in the following commit. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 104 +++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 1 + hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_common.h | 1 + 4 files changed, 107 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 4572e5a4017..e1796ec17a6 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -2450,6 +2450,75 @@ static void irs_vpe_dbr_write(GICv5 *s, GICv5Domain = domain, uint64_t value) } } =20 +/* Data we need to pass to sync_l2_iste() */ +typedef struct SyncL2ISTEUserData { + GICv5Common *cs; + GICv5ISTConfig *cfg; +} SyncL2ISTEUserData; + +static void sync_l2_iste(gpointer key, gpointer value, gpointer user_data) +{ + uint64_t id =3D GPOINTER_TO_INT(key); + uint64_t l2_iste =3D *(uint32_t *)value; + SyncL2ISTEUserData *ud =3D user_data; + hwaddr l2_iste_addr; + + if (get_l2_iste_addr(ud->cs, ud->cfg, id, &l2_iste_addr)) { + write_l2_iste_mem(ud->cs, ud->cfg, l2_iste_addr, l2_iste); + } +} + +static void irs_sync_ist_to_memory(GICv5Common *cs, GICv5ISTConfig *cfg) +{ + /* + * Push any information in the IST hash table out to guest memory + * (but don't drop the hash table entries). Writeback errors are + * ignored. Compare put_l2_iste()'s code for writing out data whon + * it removes L2_ISTE entries from the hash table. + */ + SyncL2ISTEUserData ud; + + if (!cfg->valid) { + return; + } + + ud.cs =3D cs; + ud.cfg =3D cfg; + + g_hash_table_foreach(cfg->lpi_cache, sync_l2_iste, &ud); +} + +static void irs_save_vmr_write(GICv5 *s, GICv5Domain domain, uint64_t valu= e) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + uint32_t vmid; + VMTE *vmte; + + cs->irs_save_vmr[domain] =3D value; + + if (!FIELD_EX64(cs->irs_save_vmr[domain], IRS_SAVE_VMR, S)) { + return; + } + + /* Write out vLPI and vSPI config to guest memory */ + vmid =3D FIELD_EX64(cs->irs_save_vmr[domain], IRS_SAVE_VMR, VM_ID); + + if (!cfg->valid || vmid >=3D (1 << cfg->vm_id_bits)) { + return; + } + + vmte =3D g_hash_table_lookup(cfg->vm_cache, GINT_TO_POINTER(vmid)); + if (!vmte) { + return; + } + + trace_gicv5_irs_save_vmr_write(domain_name[domain], vmid); + + irs_sync_ist_to_memory(cs, &vmte->lpi_ist); + irs_sync_ist_to_memory(cs, &vmte->spi_ist); +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -2717,6 +2786,22 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_SAVE_VMR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(cs->irs_save_vmr[domain], 0, 32); + } else { + /* RAZ if no virt */ + *data =3D 0; + } + return true; + case A_IRS_SAVE_VMR + 4: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D extract64(cs->irs_save_vmr[domain], 32, 32); + } else { + /* RAZ if no virt */ + *data =3D 0; + } + return true; case A_IRS_VPE_CR0: /* RES0 when VIRT_ONE_N is not implemented */ *data =3D 0; @@ -2913,6 +2998,14 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, irs_vpe_dbr_write(s, domain, deposit64(cs->irs_vpe_dbr[domain], 32, 32, data)= ); return true; + case A_IRS_SAVE_VMR: + irs_save_vmr_write(s, domain, + deposit64(cs->irs_save_vmr[domain], 0, 32, data= )); + return true; + case A_IRS_SAVE_VMR + 4: + irs_save_vmr_write(s, domain, + deposit64(cs->irs_save_vmr[domain], 32, 32, dat= a)); + return true; case A_IRS_VPE_CR0: /* RES0 when VIRT_ONE_N is not implemented */ return true; @@ -3072,6 +3165,14 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_SAVE_VMR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D cs->irs_save_vmr[domain]; + } else { + /* RAZ/WI if no virt */ + *data =3D 0; + } + return true; } =20 return false; @@ -3108,6 +3209,9 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_VPE_DBR: irs_vpe_dbr_write(s, domain, data); return true; + case A_IRS_SAVE_VMR: + irs_save_vmr_write(s, domain, data); + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 50365c4dfe6..667f4501ef1 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -116,6 +116,7 @@ static void gicv5_common_reset_hold(Object *obj, ResetT= ype type) memset(cs->irs_vmap_vper, 0, sizeof(cs->irs_vmap_vper)); memset(cs->irs_vpe_selr, 0, sizeof(cs->irs_vpe_selr)); memset(cs->irs_vpe_dbr, 0, sizeof(cs->irs_vpe_dbr)); + memset(cs->irs_save_vmr, 0, sizeof(cs->irs_vpe_dbr)); =20 for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { cs->irs_vpe_statusr[i] =3D R_IRS_VPE_STATUSR_IDLE_MASK; diff --git a/hw/intc/trace-events b/hw/intc/trace-events index ddb7ab06207..9902cb97b8f 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -261,6 +261,7 @@ gicv5_irs_vpe_dbr_write_nv(const char *domain, uint32_t= vmid, uint32_t vpeid) "G gicv5_set_resident(const char *domain, uint32_t vmid, uint32_t vpeid, uint= 32_t cpuidx) "GICv5 IRS %s VM ID %u VPE %u set_resident phys CPU idx %u: no= w resident" gicv5_set_non_resident(const char *domain, uint32_t cpuidx, bool db, uint8= _t dbpm) "GICv5 IRS %s set_resident phys CPU idx %u: now no resident VPE; d= b_req %d dbpm %u" gicv5_irs_ring_doorbell(const char *domain, uint32_t vmid, uint32_t db_int= id) "GICv5 IRS %s VM ID %u: ringing doorbell LPI %u" +gicv5_irs_save_vmr_write(const char *domain, uint32_t vmid) "GICv5 IRS %s = VM ID %u saving IST data to memory" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index d82cc23d10c..7bd6f557058 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -99,6 +99,7 @@ struct GICv5Common { uint64_t irs_vpe_selr[NUM_GICV5_DOMAINS]; uint32_t irs_vpe_statusr[NUM_GICV5_DOMAINS]; uint64_t irs_vpe_dbr[NUM_GICV5_DOMAINS]; + uint64_t irs_save_vmr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881334; cv=none; d=zohomail.com; s=zohoarc; b=hcDINSOB/wcXGDDueitJH5Rh7CMhpDAqgEfYVNgkY2QFXW44Ha1mVV9wKkQTfxQSjcGhSFy80AHODAoLRPjIKH4kRNFXZ2P2gWhpUvJn7ylKGppo+B+1i7Y/mGFDSk57ZpFzErXE7VhGfV7fIlP7FCbHQ31hOBuw3eoIL8X5eNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881334; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=uCpgab38MLMVKSwDafn5dl4ylWQwh1yRX8QFoIz4DxM=; b=nh42JfAOHGUOewILAYHFyM1bAixnvoAEoy8n+kZbN3s696VByswZNX848GKwZfebKBrOECkTTqdfZBiqamh/Z0VtNS+Pp814ut9NWY5jofAo7Pr5OymDq5C8GRluFLe54HAnm8U0rpxm+vKtKDpCNWPdZpBlyPlba11hr+4zmBg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881334110400.81123043849936; Tue, 13 Oct 2026 01:48:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY9k-000347-VX; Tue, 13 Oct 2026 04:46:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4d-0001nC-QZ for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:28 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4b-0008JD-Lg for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:27 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4a01933b584so23060545e9.0 for ; Tue, 13 Oct 2026 01:41:25 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880884; x=1792485684; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=uCpgab38MLMVKSwDafn5dl4ylWQwh1yRX8QFoIz4DxM=; b=RBh3B2xWcN2bTkysZ5JAMPYDcCH7eprNE89ly59HcyrEjccuf/YwZz3Ruczhv1i+Cd pEqxI5mdFRVA5SHJJyiz/cqdlV2/vx0D0BWl3w3pED+NhOqLPun1qeqt3dzjyly2D5Ep jv/wNbgqDMK1Bwhi2uuScQqdojiActzXgPW9OO+554dnzOwOwSdcgxveTD/GiV9Gc3cB Oput4qcZfBGHz/2wN/xnlY+wLPgywEe6mh1qiI8a0e4mjdB6rS50hkx6JXYLMsk2rHQA p/XllIQJ8qSp01O0yChPkbYV8a3cSkPnFVczbgtjbFpiipA9lwJSSXI7VlFdqFJasNpe BVHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880884; x=1792485684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=uCpgab38MLMVKSwDafn5dl4ylWQwh1yRX8QFoIz4DxM=; b=d+fVfCqLAhjrz3wpdMeXZaRsMrO3ZfbSpLERtavM0QhM9GYgqYDkaif4HMrdp+A8gN 20I0hN4SBjzDuny61eZRMnzWX0QcjeTVwTRDmQ+E8XAFJYvXJNXknO/4uCvX8u/NIGBW sZwOptTcwO2kVeCGgOn3os8adjjOvaPujiqr4avTkb4KHjv1ZEAmhfOGVPajDeGMQoTD kF8TNYRIvrQq8ExCtH5R0Yz9Qf3OIEnGPm3uSqvJeDBpHPqZehX4OC324rbAwpPrJ1gg ZmMBciJ4ygODo5SGoXAbvtxU2LXAj7AXG2pGCKfw0tluxQeZ3mpvT93j9Re9D00d/kgc qjuw== X-Forwarded-Encrypted: i=1; AKwUvBz5M1OltjvYdkxt7FCVVT6UPpemxFJURCMbX9JuCBetw/w1JzNu86xzwjs23V+7Z9AXV4qOdLmS0/9Y@nongnu.org X-Gm-Message-State: AFq9FYKAUm3K7Ynfxj+rTOeApNsS42jpcdPOu2LzwQ0Ul4oI+1sL/vu1 RcimlUFN2YYozaZpxbhkX/93HqnldqUOFifIfdxlOVhndz/7gTmb9ZCzyXBwh5EroGM= X-Gm-Gg: AYBFou0l0iSHkh36JI38bfLd7+JCp8sW06Rn3q7pydoafImqFhLg8k1KnFp1ew7xVCn tIjKsntUlVd5RgbiAR4DvIguTmrE/5+jtnZj+zIvzrCNHDNM+SSlgtZDD6jIuSpOJF+P7rhXJyR VIjZ658m3VmLJoh8lv+mCNP+o6LANvJQLC59MDPpXg7/2FOdE2c5j4BkLV3A88Lp5N3cFIySaUT JQb6+L//3wWNFRX4mOlFppOeOn9UBaMsJdBadgP7cR3LcWI10qcGCfaMrInuJiYtpxjwxkQQVqD /YNq68e9ZRpX9Ui5A7Ngm6hIfvJgih5LiG5yvTKMY/LI9IkaF60Ne/AzcKen/Aq5y9098OBH/rf z1IQSGTGYvtJO1ts+1uhwhnmClN/FYv84XtkLnW8uDXDm/2T6lor+0Cgpx8plIvgUtMa9x36Ane Z7UXanosGH0vHA+Sdq+fCVKwGsTBvfRVbfuLo8oBUIlGbA72eSQtKyg07TvdEYZks1yVULWxywA ifw9CNWn+TOAGG4cLzoMw3zIM4u5m1B2qjgStk1wAjsjIi5+AN8cpJg+5bwtAFd1irAm7OKi+OA K+8= X-Received: by 2002:a05:600c:4e55:b0:49f:fe39:5bc8 with SMTP id 5b1f17b1804b1-4a18e49c008mr209129145e9.12.1791880883687; Tue, 13 Oct 2026 01:41:23 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 84/86] hw/intc/arm_gicv5: Implement reporting of Quiesced state Date: Tue, 13 Oct 2026 09:39:31 +0100 Message-ID: <20261013083933.1024405-85-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881335940158500 Content-Type: text/plain; charset="utf-8" Implement the IRS_SAVE_VM_STATUSR register and its reporting of Quiescent state. For QEMU, save-vm operations are instantaneous from the point of view of the guest, and so the IDLE bit is (as usual for these status registers) always 1. The other bit in the register is Q, which reports whether the VM is still in the Quiesced state following some previous write of 1 to IRS_SAVE_VMR.S. As I_DSRQY notes, the set of conditions when Q is UNKNOWN give us the latitude to implement it as "always returns the current state, and the guest doesn't need to trigger an update by writing IRS_SAVE_VMR.{S,Q} to {0,1}". A VM is Quiesced (D_MGVXX) if: * no VPEs in the VM are resident * there is no change in the Pending state of any virtual interrupt * there is no change to the number of valid VPEs in the VM * the VM does not become invalid We can therefore track Quiesced state via a flag in our VMTE struct, which is set to 'true' on an IRS_SAVE_VM_STATUSR S=3D1 write, and then flipped to false for changes in Pending state, number of VPEs, and so on. IRS_SAVE_VM_STATUSR.Q returns that flag value, or 0 if the VM selected by IRS_SAVE_VMR.VM_ID isn't valid. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 77 ++++++++++++++++++++++++++++++++++++++++++-- hw/intc/trace-events | 1 + 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index e1796ec17a6..de595d93506 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -50,6 +50,7 @@ struct VMTE { uint32_t vmid; uint8_t vpe_id_bits; GICv5Domain domain; + bool quiesced; /* We don't cache the VMD_ADDR as we don't use VMDs */ /* We don't cache VALID: the existence of this struct implies VALID=3D= 1 */ }; @@ -914,6 +915,8 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, bo= ol pending, if (!set_pending_for_ist(cs, cfg, id, pending, &iaffid)) { return; } + /* changing Pending state breaks Quiesced */ + vmte->quiesced =3D false; irs_recalc_vhppi(s, vmte, iaffid); return; } @@ -1171,7 +1174,8 @@ uint64_t gicv5_request_config(GICv5Common *cs, uint32= _t id, GICv5Domain domain, static bool activate_for_ist(GICv5Common *cs, const GICv5ISTConfig *cfg, uint32_t id, - uint32_t *iaffid) + uint32_t *iaffid, + bool *changed_pending) { L2_ISTE_Handle h; uint32_t *l2_iste_p; @@ -1185,6 +1189,9 @@ static bool activate_for_ist(GICv5Common *cs, *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, ACTIVE, true); if (FIELD_EX32(*l2_iste_p, L2_ISTE, HM) =3D=3D GICV5_EDGE) { *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, PENDING, false); + if (changed_pending) { + *changed_pending =3D true; + } } *iaffid =3D FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID); put_l2_iste(cs, cfg, &h); @@ -1201,10 +1208,15 @@ void gicv5_activate(GICv5Common *cs, uint32_t id, G= ICv5Domain domain, =20 if (virtual) { const GICv5ISTConfig *cfg =3D ist_for_vint(s, cs, domain, type, cp= uidx); + bool changed_pending =3D false; =20 - if (!activate_for_ist(cs, cfg, id, &iaffid)) { + if (!activate_for_ist(cs, cfg, id, &iaffid, &changed_pending)) { return; } + /* Changing Pending breaks Quiesced state */ + if (changed_pending) { + s->res_vpe[cpuidx]->vmte->quiesced =3D false; + } irs_recalc_vhppi(s, s->res_vpe[cpuidx]->vmte, iaffid); return; } @@ -1214,7 +1226,7 @@ void gicv5_activate(GICv5Common *cs, uint32_t id, GIC= v5Domain domain, { const GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; =20 - if (!activate_for_ist(cs, cfg, id, &iaffid)) { + if (!activate_for_ist(cs, cfg, id, &iaffid, NULL)) { return; } break; @@ -1484,6 +1496,10 @@ bool gicv5_set_resident(GICv5Common *cs, GICv5Domain= domain, bool valid, vpe->cpuidx =3D cpuidx; =20 s->res_vpe[cpuidx] =3D vpe; + + /* Making a VPE resident breaks Quiesced state */ + vmte->quiesced =3D false; + trace_gicv5_set_resident(domain_name[domain], vmid, vpeid, cpuidx); } else { vpe =3D s->res_vpe[cpuidx]; @@ -2317,6 +2333,9 @@ static void irs_vmap_vper_write(GICv5 *s, GICv5Domain= domain, uint64_t value) init_vpe_from_vpete(&vmte->vpet[vpeid], vmte, vpete); trace_gicv5_irs_vmap_vper_write(domain_name[domain], vmte->vmid, vpeid= ); =20 + /* Adding a VPE to the VM breaks it being Quiesced */ + vmte->quiesced =3D false; + irs_recalc_vhppi(s, vmte, vpeid); =20 return; @@ -2514,11 +2533,55 @@ static void irs_save_vmr_write(GICv5 *s, GICv5Domai= n domain, uint64_t value) } =20 trace_gicv5_irs_save_vmr_write(domain_name[domain], vmid); + /* + * Writing S =3D 1 is the start of a check for if the VM stays + * Quiesced. If some VPE is currently resident than the VM is not + * Quiesced. Other state changes later may also flip it to + * not-Quiesced. + */ + vmte->quiesced =3D true; + for (uint32_t i =3D 0; i < (1 << vmte->vpe_id_bits); i++) { + VPE *vpe =3D &vmte->vpet[i]; + + if (vpe->valid && vpe->resident) { + vmte->quiesced =3D false; + break; + } + } =20 irs_sync_ist_to_memory(cs, &vmte->lpi_ist); irs_sync_ist_to_memory(cs, &vmte->spi_ist); } =20 +static uint64_t irs_save_vm_statusr_read(GICv5 *s, GICv5Domain domain) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + GICv5VMTConfig *cfg =3D &s->vmt_config[domain]; + uint32_t vmid; + VMTE *vmte; + /* IDLE always set; Q set only if VM is Quiesced */ + uint64_t value =3D R_IRS_SAVE_VM_STATUSR_IDLE_MASK; + + vmid =3D FIELD_EX64(cs->irs_save_vmr[domain], IRS_SAVE_VMR, VM_ID); + + if (!cfg->valid || vmid >=3D (1 << cfg->vm_id_bits)) { + return value; + } + + vmte =3D g_hash_table_lookup(cfg->vm_cache, GINT_TO_POINTER(vmid)); + if (!vmte) { + return value; + } + + trace_gicv5_irs_save_vm_statusr_read(domain_name[domain], + vmid, vmte->quiesced); + + if (vmte->quiesced) { + value |=3D R_IRS_SAVE_VM_STATUSR_Q_MASK; + } + return value; +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -2802,6 +2865,14 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_SAVE_VM_STATUSR: + if (gicv5_domain_has_virt(cs, domain)) { + *data =3D irs_save_vm_statusr_read(s, domain); + } else { + /* RAZ if no virt */ + *data =3D 0; + } + return true; case A_IRS_VPE_CR0: /* RES0 when VIRT_ONE_N is not implemented */ *data =3D 0; diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 9902cb97b8f..017f0fc21dc 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -262,6 +262,7 @@ gicv5_set_resident(const char *domain, uint32_t vmid, u= int32_t vpeid, uint32_t c gicv5_set_non_resident(const char *domain, uint32_t cpuidx, bool db, uint8= _t dbpm) "GICv5 IRS %s set_resident phys CPU idx %u: now no resident VPE; d= b_req %d dbpm %u" gicv5_irs_ring_doorbell(const char *domain, uint32_t vmid, uint32_t db_int= id) "GICv5 IRS %s VM ID %u: ringing doorbell LPI %u" gicv5_irs_save_vmr_write(const char *domain, uint32_t vmid) "GICv5 IRS %s = VM ID %u saving IST data to memory" +gicv5_irs_save_vm_statusr_read(const char *domain, uint32_t vmid, bool qui= esced) "GICv5 IRS %s VM ID %u reporting quiesced %d" =20 # arm_gicv5_common.c gicv5_common_realize(uint32_t irsid, uint32_t num_cpus, uint32_t spi_base,= uint32_t spi_irs_range, uint32_t spi_range) "GICv5 IRS realized: IRS ID %u= , %u CPUs, SPI base %u, SPI IRS range %u, SPI range %u" --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881636; cv=none; d=zohomail.com; s=zohoarc; b=RDd8VojL6Oue9S4x8Am0MuQwapTTF67SygJDJZPQXC/BVlz2ZiR8CAYpZMbDC6I4JlLyPY61zNyUkjNmjOqKKQ5nzYesg6Tqc+VSBc3yekaCGRXX3x6nE2nqk4h6OVUTFNZFVSxD6xllXRggrw9eJnRjcZWPp3MEJVFO7RWSez4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881636; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=MeT+bQbA4mzMBemWeTOL9DdPMgcpzifck65oWgevcU0=; b=jHxCuylpm29Db338nPEeM67sU9CZqSY4+fmSFUyAlbZt/T6+yZqWb7fB9NQ1jP2l2yY3sT7nNIEhHRs3u9XEyumwmIp/Dz8FjzvgetsxJyYUhwCn0RGLaBoSj5jcU8ra7wW8SJz8XTbxikcafKncXfxZ46lnC2IxSz0npXBxr6I= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881636335849.2904740105117; Tue, 13 Oct 2026 01:53:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY9j-0002mh-5g; Tue, 13 Oct 2026 04:46:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4d-0001nF-RU for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:28 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4c-0008Jc-6o for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:27 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a1ad2e2391so2933775e9.0 for ; Tue, 13 Oct 2026 01:41:25 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880885; x=1792485685; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=MeT+bQbA4mzMBemWeTOL9DdPMgcpzifck65oWgevcU0=; b=yHGLZ/l/OWbP5NKMO+/e6qdeVQ6RCI8H3lDsoJyYV/HjY2xQPQ/haMIL+k4QFB0ZE9 jaD2ZsGIhh5SWr8nWbL09rPNaGajDxWRPEMCm8FWPwwzFbmwO0wyWIaEVmjgmQ5v6OHb 8uH9g+5zLQ6lS8upCIHRd/B/rzgr3ziBWIpww3hbMAHMVT6n7252Gr5j3ZTOVB2P/rMc uAN2L8lvZbtBtJuaEq9j44xjFqOIKkYlpJyvOYGdMOkvdw89V55MVUy5BygdrOnpueNg 9D1OhQOV2zPrpYVkR+IUB9TvR0DbFqyrgu9bKeG1TI6fzwCYQqwpY6LX3Jlt6n9Ycm6F qgRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880885; x=1792485685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=MeT+bQbA4mzMBemWeTOL9DdPMgcpzifck65oWgevcU0=; b=NsTADhJtsvzcFJxw5LYAXysgK9SLfvttir4VNZxca1wuo0EgD52q8tBbfp3rF2PCyi aIsS20dbW/fwedz3NIbs62m+yh9aIVEUlhOFi7O8PETxvBa2AW/f/qxbzA030cMgkKOO 8G2vSi3UPUG0Kk6SxHhFrDtu6RDiJK14FPXcGjvGqmxC7f46bJtBYC3K7TKoMMzN/6En XZGlrv5CdqhfwGtCVsY8fLmhYfVEjnUiCRpvkUvD4PR7SQA5Kyv2Q6RuSSYjFzRg0dQJ Q38v30H/tgse4OcKnsnHbmIsoS8TmZRXJibgSrhXRO8QE4mbESM4owjGYYPHrcZDheLC iZ+w== X-Forwarded-Encrypted: i=1; AKwUvBz/b02TQdXcKP0WcPYmZUoLRjsJthlJJR2IKc8mnXsPSWDiLk4SyqgTMiWh1GkfL/2AoSIUsSU8aKn/@nongnu.org X-Gm-Message-State: AFq9FYKoaLaTYsfF/shlnBWkqdRqxrTUbHR3qDIws79AVoNHDemkxEJr cHyhL/ptVzaNHqznYZLz+/RQB8W/rYW2NARjM5QSbFIisAo+eIR9dnaaujdCBxzW96c= X-Gm-Gg: AYBFou2V2fW9t0Z9LrWSWNEYdI+KIm459Shu5bYooTmJPgGnimndUKUlmcWvEjzLUdM g4KZOFgAMcEl4dZBNwazOMRBj1M19JmeetVjbvUzc7Ca5kNBJZwwIKBBDIXc8B9+7af3V5NMxzD mZo0KAyJtPJELpZbKdlEY4K2yuEjDVBQuuUT8Ed9wFQ0NZfAGeqGxYLBCiC/O/1OrbLlM9VwuNz NCq0gwYE7037Y8ww6kubwxmmaKTCT9PHzXzLQu5+NPxT3whu5C4ysmMzSFyVLN8I04XTNj9s+TJ QHCN9eDjhIJuu3VgKusteKHZOQqHjlnKouds4hDwbBof/7wVsSbp4F8tDhuGkqriPSgJXLHx7+6 XfzSgZuLHFScahFYwHASxexDGKbGj4TH90+WTfni/LLepRV3e+Arij2ED+/keL3fjRrO7WbS1q5 UCsOyn7pntj/vYGnSh4cMhfPbhPHEPZQJKv1yTtInkxKiFfvf0dh2wjfGsmxpoo3hsVm78c0pRf dQkkhydh3SOb6G93TfAS60vRus/BgA8kxu3WuckiYZKcRLGK19VFfKnzrpeb52saQZa7A2FiygF gL4= X-Received: by 2002:a05:600c:4689:b0:4a0:1cfd:321 with SMTP id 5b1f17b1804b1-4a18e4a9b31mr249422025e9.12.1791880884628; Tue, 13 Oct 2026 01:41:24 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 85/86] hw/intc/arm_gicv5: Implement no-passthrough IRS_SPI_VMR Date: Tue, 13 Oct 2026 09:39:32 +0100 Message-ID: <20261013083933.1024405-86-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881637709158500 Content-Type: text/plain; charset="utf-8" The GICv5 spec recommends, but does not require, that the IRS implements passthrough of SPIs to VMs. Linux does not currently use SPI passthrough. For our initial implementation, implement the IRS_SPI_VMR register as RAZ/WI, corresponding to "passthrough is not supported for any SPI", and with a LOG_UNIMP message if the guest attempts to configure passthrough for an SPI. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/intc/arm_gicv5.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index de595d93506..f380f144f6d 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -2582,6 +2582,24 @@ static uint64_t irs_save_vm_statusr_read(GICv5 *s, G= ICv5Domain domain) return value; } =20 +static void irs_spi_vmr_write(GICv5 *s, GICv5Domain domain) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + + /* RAZ/WI if no virt */ + if (!gicv5_domain_has_virt(cs, domain)) { + return; + } + + /* + * The spec merely recommends that passthrough of SPIs is supported. + * For an SPI where passthrough is not supported, IRS_SPI_VMR is + * RAZ/WI (indicating "not passed through" and not permitting it to + * be set to "passed through"). Log the missing functionality. + */ + qemu_log_mask(LOG_UNIMP, "QEMU GICv5 SPI passthrough not implemented\n= "); +} + static void spi_sample(GICv5SPIState *spi) { /* @@ -2873,6 +2891,11 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, *data =3D 0; } return true; + case A_IRS_SPI_VMR: + case A_IRS_SPI_VMR + 4: + /* Always RAZ/WI until we implement SPI passthrough */ + *data =3D 0; + return true; case A_IRS_VPE_CR0: /* RES0 when VIRT_ONE_N is not implemented */ *data =3D 0; @@ -3077,6 +3100,12 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, irs_save_vmr_write(s, domain, deposit64(cs->irs_save_vmr[domain], 32, 32, dat= a)); return true; + case A_IRS_SPI_VMR: + irs_spi_vmr_write(s, domain); + return true; + case A_IRS_SPI_VMR + 4: + irs_spi_vmr_write(s, domain); + return true; case A_IRS_VPE_CR0: /* RES0 when VIRT_ONE_N is not implemented */ return true; @@ -3244,6 +3273,10 @@ static bool config_readll(GICv5 *s, GICv5Domain doma= in, hwaddr offset, *data =3D 0; } return true; + case A_IRS_SPI_VMR: + /* Always RAZ/WI until we implement SPI passthrough */ + *data =3D 0; + return true; } =20 return false; @@ -3283,6 +3316,8 @@ static bool config_writell(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_SAVE_VMR: irs_save_vmr_write(s, domain, data); return true; + case A_IRS_SPI_VMR: + irs_spi_vmr_write(s, domain); } =20 return false; --=20 2.43.0 From nobody Mon Nov 23 04:52:39 2026 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=1791881229; cv=none; d=zohomail.com; s=zohoarc; b=jkKl2kvZP4gSlNyt8oiCokGYFvi76+KngfgXGYDUzlynN0+SYI9rAT60Vr8MkNwfr7aYJ+rpsmFXlkb7t9Um8Xt6JZW1701xhrW3Wz6D0GS30wbX8akgnbeqPOzBevDZpzV/QxZHVb2jwOInuJsMaLnXXcfsBiUUvmP6NKtDtiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791881229; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=FPolPi2JhiZ7Lq5RQip9zpX4wzM5RDqIgiaQzEcR81k=; b=d9OJ5Z8up5fbpDqcxRRjv4l59+AZuUcHO1NK7lMTUhYdmuK6KKhetgrJXmsErzmhDxAOif+R7qH9RITf1XC3Ho/C16PqGdzZTauw5u88tTOkdcRL+uwqjCT6qP7YaPuai9PpzB8PmCV2a6GmIN0kRefdh2wNmgbP5OyoXwVVIis= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791881229458755.3789871640439; Tue, 13 Oct 2026 01:47:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGY8o-0000I4-FK; Tue, 13 Oct 2026 04:45:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGY4f-0001o4-03 for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:30 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGY4d-0008K5-1k for qemu-devel@nongnu.org; Tue, 13 Oct 2026 04:41:28 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4a02667ccebso18666315e9.0 for ; Tue, 13 Oct 2026 01:41:26 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a18be96549sm495086735e9.6.2026.10.13.01.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 01:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1791880886; x=1792485686; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=FPolPi2JhiZ7Lq5RQip9zpX4wzM5RDqIgiaQzEcR81k=; b=ih8Szau5j9BzcU8de1V2Bj5v9QGrsgK3dUXtdAC5vg6aJqt9dN6et4hHZ9dXHoqpmp HI7HHFELYz7RexxIoEby3ROnhmW/eO66ylh8LPCuWu4bCTejYgmmXOlrCJKe+XnyN+jI 7AfYYi0v8Qi1vf3TwBNmoIoKJJzD1pvukCzRivUGLScehEwaCRq69R2cjIvsglg6qGu/ 9RFYm15w4yIDG7FtVpT3NlRROKVmkRFyDdQZ4K5fnTGzpMx8TcsYvZZPKO67ZpVJ1Z0i h9UlPo6jvy3fgvMurlSq+p5hPIQ8Sxtprs6YqxXyFJoOO8Z/oQ6quSXTxQrK7rkbw4D0 w9Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791880886; x=1792485686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=FPolPi2JhiZ7Lq5RQip9zpX4wzM5RDqIgiaQzEcR81k=; b=QF1i+b7bp4W+QkGe10nouWgRNyppzfb2Mi7uZkwq/EILZ5g/sZ3TpAQew4S5qMLu+s 8LKg4fvv2IMnAfUt5TGYkUaPMb1QWX0btgciKwoX6FOuvmVicGWenyzEJFuVPEHPn6mp grSDC7r5kdCCzFG0iv1VsveNGmmp2DXHfH8XKVNnKhgHaM8M88819rZTinmFfGACOXL3 HSDRBR5LkB32+wzHzMIYa10GJ/sZibGztjj0wnKWxBEL+7GCvZbEQuBkFZUw7vEXZTc/ rO8a++avJPG0eyL0mwBDYZ9F1epW0664FHrrIyhdAZK+ogLSwmj3jW/xaAUCquWhhEvx g4+Q== X-Forwarded-Encrypted: i=1; AKwUvBwkTffkiF5yKm97YA2un5I8/HFLIEdfbo1/2ECtdZvCVeKkKUr99SJf5qiGlviBJw7FTqWTLJDEM5AL@nongnu.org X-Gm-Message-State: AFq9FYIZZVHZwJhT157xmQaYKkuhsRXYO7Ep39Ky+ucoLUXg8+ZeF6Jk Jot7Y2y9OxXJvK5vXYKsOK0FEvs6f2hSWVts6jNj/yuHcVBC5f3QH0YdhQ4/4CI9m5edWbM+RBr uf7fv+tc= X-Gm-Gg: AYBFou10rjLKZndH5+dUTlJ9NesJelncLUnw8RBuVBT1nLq+9Oax7tJfi5eyGICSBJy BhGE4mCPKwiq5iEWBbT8RMR2aYR1Fbppvd/Q9qkRmgjrts86rd1nXkkxgLJRlDrWfjYSPmy5wJP bdvfinUTQEgrTUIMScYApTbIlToyuX/UO46h99GgFAzueg8v6MaS5F1pAwUSwe5ooxdxUvHSSsV 43nbYBbOlQ4hM8B5bkjOwLM+aIaL9h/qQPM/nm82XpxB77EW4ovZV1dc4vBZfpOctFC0KRpI1U5 NVyEaV/2RtitblKHuFPYzhtdrhdi+GIG5UBowRwB+Yp9ESFflTv9TUNVP3riXL0nWgj8gY4X1cz WUWALbc5ulIqzGOyPekF7VDZ7fJ74eg7+PtvKERHDAsSTBwnKH57q7PDCMbcdXeLHtXXypZJQH9 sxVZz7EmBvSjQT3ILo36Vo76p/5zdhjtnRNtYdylPobB8OCZ2ristYZS6rFjy7Lw6vQ6si2+Vlz Y5n1w2FM9qixWziNGy6A2U1Yie0UhxhRJIXKQZW9vNOlgjchXqvofrYx4kiZJS+xNCWvmAIFYee UHrnoum5Ws9Alw== X-Received: by 2002:a05:600c:6990:b0:4a0:1ea1:477a with SMTP id 5b1f17b1804b1-4a18e4d8bbamr204086655e9.27.1791880885616; Tue, 13 Oct 2026 01:41:25 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 86/86] hw/arm/virt: allow virtualization=on with gicv5 Date: Tue, 13 Oct 2026 09:39:33 +0100 Message-ID: <20261013083933.1024405-87-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261013083933.1024405-1-peter.maydell@linaro.org> References: <20261013083933.1024405-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1791881229859158500 Content-Type: text/plain; charset="utf-8" Now that the GICv5 implementation supports virtualization, we can remove the check in the virt board that prevented you from using 'virtualization=3Don' with 'gic-version=3Dx-5'. Signed-off-by: Peter Maydell Tested-by: Gustavo Romero --- hw/arm/virt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9d192515d85..51554619fd5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3015,9 +3015,8 @@ static void machvirt_init(MachineState *machine) exit(1); } =20 - if ((vms->virt || vms->secure) && - vms->gic_version =3D=3D VIRT_GIC_VERSION_5) { - error_report("mach-virt: GICv5 currently supports EL1 only"); + if (vms->secure && vms->gic_version =3D=3D VIRT_GIC_VERSION_5) { + error_report("mach-virt: GICv5 currently supports EL1 and EL2 only= "); exit(1); } =20 --=20 2.43.0