From nobody Sat May 30 18:35:06 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=1778169138; cv=none; d=zohomail.com; s=zohoarc; b=QTKZZKubQybGCZ4IWRXxT+KHAG5FBFrqIBiYBPNzufG6wW2nu2BmXFUF8MNAgYNnczppzoMk94bd8NU3XrpzSqR1cjzkRjZmfgPrfSGZGtuNTKnOy5kqZ3LHmLDFhIL699dkk+a0TT+6JmiDOqn0TaJYuytS48e/agbQQ8ljk1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169138; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=refkWTdHWDs8DEZOP5rbn+tFhpxCiAafNNrc4m7bQlE=; b=B9BufwbBAQUzypbeUol9bMHbiuHsxnrYFYOEPy9eDwzs4ve9g0EWzhuoH3IvRspaU7DB/m0SQxeNIx82oLbVqCwvnMjWDbZLnPOZ4wqqUpyKcgD3ZJndiHvlg3u7p8q7mxy3dCsHAu/gW6BYk9TrViTp3dZGad4egujrPNbBvgY= 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 1778169138365653.9670321056582; Thu, 7 May 2026 08:52:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11C-0003P6-Qo; Thu, 07 May 2026 11:52: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 1wL116-0003OO-OQ for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:00 -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 1wL114-0003jn-Q2 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:00 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4896c22fcbaso10530135e9.0 for ; Thu, 07 May 2026 08:51:58 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.51.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169117; x=1778773917; 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; bh=refkWTdHWDs8DEZOP5rbn+tFhpxCiAafNNrc4m7bQlE=; b=f8bDcUJZgHP99r9eK2UwJ5UmBTdoP/uWPEEH2xQR5crzg//KA7XaMZf1LJgukcX34J zkhj7xYxUGJhFkOOZDHfkSOWJpS9kFOEJqJn4Z+8D5YI/9I0/NnmkJuoeKvJ2L+BpGCk PNLpM3h5EF8rSfT7vacTjH9M+Rz7fi6KzoW5o0ZWaEQCrcEzXc/v9Av0auD2HO0xadI7 lnn01YseQ/I7XhgSVZalpgEjcg+lkg1pdMIBswXeM4qLAR3sW94igAcFoTmQJn/VdQap AuCxy4rxXJcZIstWIfDojJCoIWjg6dQN3DV4MriFEFXL8G9Lr0GG0h0LnFQTrkqp8+Yn SjFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169117; x=1778773917; 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; bh=refkWTdHWDs8DEZOP5rbn+tFhpxCiAafNNrc4m7bQlE=; b=mPqVb/KXCmaVKq/dG+4SxUoluGKEUAV9q2+PN3cMlav+1Mlh6GWBSGRF9W2n8TM1i+ SxBSW88oQ4Pg0CxzqG9rrEHq2vsTELAItWa3z9PzIntVO3j/2IyPBSTxLUh81YeK+L6s 9UFO4YF4veNWzC5en44TxRAG1wLMlew6hIDGbn5XYXG/7iJIkwiw536m25/UXCBYyXpk M1BNH9WH0750pI+ZmiQMNAW1x5pzzFyOV8A9VQEFVFSLp2YhmtrVhLU5a7BoAcp8G39l nl5QJHO+MHik17fXpCGvpQZNx3CQZPQR2avgcNuf75zvkzHgdzFYw6V5SRdnZsdKrVsA fOgw== X-Gm-Message-State: AOJu0YxI2Ebjh7kZIy8plQwyvurrEtCRvSwmpS+VfHsjnvnNsPm4hqh/ Dd8bItaxMCHaPcJhyO1aMWfVMWaaGAdb0rqW6LfLTh4h61DSj7tRupz8D7MwhQUoL7aPymxrB0n myzJA X-Gm-Gg: AeBDiesyfHoUL6Kek35wcBZnxIZ40zBlr1+tlaNWluDdEKJlkfpx4hqiGu6An9/ODpK 6FPiDVoS9V/1puSQxEC3rgZiBJud9Ch/mBnMU2ZD4C1m9EUI73b2hqu+OWeYS4gUC754f3f8NVe PbiEXH4OWerbIf8OTLwjLH+lQYUX5yYZHGjp/DSNqQQ2L91QwtKQ0LiXNyekkOKkHatGimLdB0v JnoHlyhzWkR8wCmGvxnWmklPJ2AZ72Gg7ab1XxPyM5BprJ8PdJ4TzVVaFxlkIzpJjdCLpCiHw1J QWT08ptCRFzSBRoOuvf1ywdECub6ZLqDp/VLDcSOyeKKGi+fH6U+OJpiXJB4h1+lRAP9TWuwNNJ YW25Zr+vXSLMbe9MM0c2D4U0w+n7eyohlMM1JMuuUP6EkOd+GNxrmk3lexMpXnDTS2jo/yIET5g 2KPkLEGM8Iqs9qr/c1rJ5481lPOjI6solNO3DSNtk0nj/5HkmvMoLBmPUCSWVFgkN4qqZu+vvDk xM6b8GS6RNdH5ky X-Received: by 2002:a05:600c:1f0d:b0:48a:93d2:60d2 with SMTP id 5b1f17b1804b1-48e51dd9772mr130038515e9.0.1778169116717; Thu, 07 May 2026 08:51:56 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/67] qom/object: Add object_resolve_and_typecheck() Date: Thu, 7 May 2026 16:50:48 +0100 Message-ID: <20260507155154.1886557-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169141311154100 Add a new function object_resolve_and_typecheck(), whose purpose is to look up the object at a given QOM path, confirm that it is the expected type, and return it. This is similar to the existing object_resolve_path_type(), but it insists on a non-ambiguous path. We were already using this functionality internally to object.c as part of the object_resolve_link() function, so this patch implements the new function by pulling the link-property specific parts out of the more generic resolve-and-typecheck part. The motivation for this function is that we want to allow devices to provide an array of link properties; for that we will need to be able to provide the expected type of the linked object in a different way to the single-item link properties. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Maydell Message-id: 20260327111700.795099-2-peter.maydell@linaro.org --- include/qom/object.h | 17 +++++++++++++++++ qom/object.c | 41 +++++++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 510885218b..f40d8ccd4a 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1742,6 +1742,23 @@ ObjectProperty *object_class_property_add_link(Objec= tClass *oc, Object *val, Error **errp), ObjectPropertyLinkFlags flags); =20 +/** + * object_resolve_and_typecheck: + * @path: path to look up + * @name: name of property we are resolving for (used only in error messag= es) + * @target_type: QOM type we expect @path to resolve to + * @errp: error + * + * Look up the object at @path and return it. If it does not have the + * correct type @target_type, return NULL and set @errp. + * + * This is similar to object_resolve_path_type(), but it insists on a + * non-ambiguous path and it produces error messages that are + * specialised to the use case of setting a link property on an object. + */ +Object *object_resolve_and_typecheck(const char *path, const char *name, + const char *target_type, Error **errp= ); + /** * object_property_add_str: * @obj: the object to add a property to diff --git a/qom/object.c b/qom/object.c index f981e27044..59fd79738d 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1835,26 +1835,12 @@ static void object_get_link_property(Object *obj, V= isitor *v, } } =20 -/* - * object_resolve_link: - * - * Lookup an object and ensure its type matches the link property type. T= his - * is similar to object_resolve_path() except type verification against the - * link property is performed. - * - * Returns: The matched object or NULL on path lookup failures. - */ -static Object *object_resolve_link(Object *obj, const char *name, - const char *path, Error **errp) +Object *object_resolve_and_typecheck(const char *path, const char *name, + const char *target_type, Error **errp) { - const char *type; - char *target_type; bool ambiguous =3D false; Object *target; =20 - /* Go from link to FOO. */ - type =3D object_property_get_type(obj, name, NULL); - target_type =3D g_strndup(&type[5], strlen(type) - 6); target =3D object_resolve_path_type(path, target_type, &ambiguous); =20 if (ambiguous) { @@ -1871,11 +1857,30 @@ static Object *object_resolve_link(Object *obj, con= st char *name, } target =3D NULL; } - g_free(target_type); - return target; } =20 +/* + * object_resolve_link: + * + * Lookup an object and ensure its type matches the link property type. T= his + * is similar to object_resolve_path() except type verification against the + * link property is performed. + * + * Returns: The matched object or NULL on path lookup failures. + */ +static Object *object_resolve_link(Object *obj, const char *name, + const char *path, Error **errp) +{ + const char *type; + g_autofree char *target_type =3D NULL; + + /* Go from link to FOO. */ + type =3D object_property_get_type(obj, name, NULL); + target_type =3D g_strndup(&type[5], strlen(type) - 6); + return object_resolve_and_typecheck(path, name, target_type, errp); +} + static void object_set_link_property(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169186; cv=none; d=zohomail.com; s=zohoarc; b=Jdu98nToirYfUMoihp1HXMSHzJzBZ4aZZG91lH7dkWUMzK2f48xG8L/Wy6Byw0MKyi9aHuYEw2QYEQE/VuDPrGVMmwwPWjo4LRADaYRzz0p/+0SiNEnk/5R4lEenDlZnOC4ivZyRNNnRAyMY+GDDp5LCPz2bj8la039gdHIuROQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169186; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=IcOf2tcUeiZi6Fy8YvI64XVHaYA65XN7OImXJDoNidg=; b=WhcQlLsets1IzEfrw4wcQAFnGZOo5nzU7ZoKJzkQL8TK0OhqXG0cAF1m2mOjgHnL95j5oMMVVugeNaUXKTVp3ew3TR/CnEl28fVkNZ2jvIqjt1xx/ICfwwC7zmHwTh+6UJ3Erwh470i83962Fz9L+UzRCcF5pUi52xUxa/3TK5o= 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 177816918632283.0971283451205; Thu, 7 May 2026 08:53:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11E-0003Pu-MB; Thu, 07 May 2026 11:52: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 1wL118-0003Oh-Vv for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:03 -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 1wL116-0003k2-D2 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:02 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-488b150559bso8027675e9.1 for ; Thu, 07 May 2026 08:51:59 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.51.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169118; x=1778773918; 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; bh=IcOf2tcUeiZi6Fy8YvI64XVHaYA65XN7OImXJDoNidg=; b=zE3UA9v+ZDJa6PJASNr5nMxbZJ43nnyiBoXNqTnh9XMOiEs5TKxkTO7Kqugesuot2t VAIlZM7Pv8Oy0j35ptLpoWHEGh2e6d0KMXnBlDVC2EorvyEnFqQe+lmo9g/I64MWaUY/ 7a8q+oaQtPbW9nMmxhKE3O1akb3CDQnSad+6/sIVw4WsiE0VzXK+ip4/9ZCC6caAc/S/ +lxDpNXkDfR0sB/ENlIr1+tbf2bZ4gIFXI2bqEHog71Y8owXO5W/w0Pt6DuXUWFvmyYL 89KLD2JVYfNKzXO8RdVyofsdIKTTm84WX1YqUzkYtzCSlQPOnzy2zJMkH8zHJw0SRYDS eP8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169118; x=1778773918; 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; bh=IcOf2tcUeiZi6Fy8YvI64XVHaYA65XN7OImXJDoNidg=; b=BXURm6/nDeoWQOVVKeaZ4No5Z+6ulY+CQCUUC7d3GWBqUtG7nxRV4gqi2gS7n0Urip UibUn+5Vysg00nugMMnl0BGZQHh5pMDaNbMLF1NlEqZ3jQ0wLJEevGIhbTrn3dsHb34M ndjKeTFDje0NAMmY0SBPTPAPFlCwUMMUoxLobCGL0/q7XoYbGb0cr3cNoaxhUwqX2NkN 0A/67O7Y5Yts4xRO7DArnb/hw7dWBgCYvX8Jymir9FoiojYnIBdobjFBiGcPUKR/rlGg OACcpNinfELsKdsbxu2ccM9yIZfgTtAsCroUZP0melG7F9J7lvAn3J7IgDXfTjxv81Nk N2VQ== X-Gm-Message-State: AOJu0YywqcGnAOikQWLA5FzadRj5ubjxx3nbxl9ipeqWXoAo9gJY2kGt G7cyRBSGOg7qNhJgdHzV/sDNw2dSXq9g2aUvSf7CbkgLNJeCD2kJTUzlzxEEw25WnyBVhErc7Md Wue7v X-Gm-Gg: AeBDievyCBUbT/FwlefXcNEE5R6VoFb6KyLfNdD5n7pVp832ucG5fMqG7xjavFEwK39 b9Wrk1iGJopMOzgxufxNCWIA6KcbziOLwT3nymVRD2KT1IQaY9FS5hp43xymMZ+GpzsjoXB1L8z iwQwZXNNbY1GLro26/zKUpgWUnRutYOXF8eH2WQvOhU7nt7p2SVG80DlpWwnMBKvK97c9G5H3hb X6snwc5KEKecqZ1DAnUuSf3nVv/mCL0RPbp2o4EX5kCjX6D5Rsg/iirgUIlpRw0PXc5d9Y2CjuA FBKVJ1md7ztwijoDrdWX+WwXhkmUsl8OLVI2GVXetBqCZphW3Z/mi3TSqHhpsDh43vilskrVA/M jSFWSNwG0peMsZbi1hAZbN526164eadHTQ+yur+YqH1V7qj8Qoh/MTrQdOoRtt/MzCNRzLzFPfv /ekNI6nwAyXHkzPi7TFsRJzXoQ1aqO5fv5UKf0goqVS6KLfgwQWisRetpIwPD+qL6ZH1TEBeOlA VLkDTDwAWBmJqxlYrdXjkvpGTk7U4g= X-Received: by 2002:a05:600c:3548:b0:489:1c1f:35f1 with SMTP id 5b1f17b1804b1-48e51e09706mr134387515e9.4.1778169117666; Thu, 07 May 2026 08:51:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/67] hw/core: Permit devices to define an array of link properties Date: Thu, 7 May 2026 16:50:49 +0100 Message-ID: <20260507155154.1886557-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169187783154100 Currently we allow devices to define "link properties" with DEFINE_PROP_LINK(): these are a way to give a device a pointer to another QOM object. (Under the hood this is done by handing it the canonical QOM path for the object.) We also allow devices to define "array properties" with DEFINE_PROP_ARRAY(): these are a way to give a device a variable-length array of properties. However, there is no way to define an array of link properties. If you try to do it by passing qdev_prop_link as the arrayprop argument to DEFINE_PROP_ARRAY() you will get a crash because qdev_prop_link does not provide the .set and .get methods in its PropertyInfo struct. This patch implements a new DEFINE_PROP_LINK_ARRAY(). In a device you can use it like this: struct MyDevice { ... uint32_t num_cpus; ARMCPU **cpus; } and in your Property array: DEFINE_PROP_LINK_ARRAY("cpus", MyDevice, num_cpus, cpus, TYPE_ARM_CPU, ARMCPU *), The array property code will fill in s->num_cpus, allocate memory in s->cpus, and populate it with pointers. On the device-creation side you set the property in the same way as the existing array properties, using the new qlist_append_link() function to append to the QList: QList *cpulist =3D qlist_new(); for (int i =3D 0; i < cpus; i++) { qlist_append_link(cpulist, OBJECT(cpu[i])); } qdev_prop_set_array(mydev, "cpus", cpulist); The implementation is mostly in the provision of the .set and .get methods to the qdev_prop_link PropertyInfo struct. The code of these methods parallels the code in object_set_link_property() and object_get_link_property(). We can't completely share the code with those functions because of differences in where we get the information like the target QOM type, but I have pulled out a new function object_resolve_and_typecheck() for the shared "given a QOM path and a type, give me the object or an error" code. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-3-peter.maydell@linaro.org --- hw/core/qdev-properties.c | 78 +++++++++++++++++++++++++++++++ include/hw/core/qdev-properties.h | 41 ++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 73539c727b..34d7b26a73 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -670,6 +670,7 @@ static Property array_elem_prop(Object *obj, const Prop= erty *parent_prop, * being inside the device struct. */ .offset =3D (uintptr_t)elem - (uintptr_t)obj, + .link_type =3D parent_prop->link_type, }; } =20 @@ -951,6 +952,12 @@ void qdev_prop_set_array(DeviceState *dev, const char = *name, QList *values) qobject_unref(values); } =20 +void qlist_append_link(QList *qlist, Object *obj) +{ + g_autofree char *path =3D object_get_canonical_path(obj); + qlist_append_str(qlist, path); +} + static GPtrArray *global_props(void) { static GPtrArray *gp; @@ -1060,9 +1067,80 @@ static ObjectProperty *create_link_property(ObjectCl= ass *oc, const char *name, OBJ_PROP_LINK_STRONG); } =20 +/* + * The logic in these get_link() and set_link() functions is similar + * to that used for single-element link properties in the + * object_get_link_property() and object_set_link_property() functions. + * The difference is largely in how we get the expected type of the + * link: for us it is in the Property struct, and for a single link + * property it is part of the property name on the object. + */ +static void get_link(Object *obj, Visitor *v, const char *name, void *opaq= ue, + Error **errp) +{ + const Property *prop =3D opaque; + Object **targetp =3D object_field_prop_ptr(obj, prop); + g_autofree char *path =3D NULL; + + if (*targetp) { + path =3D object_get_canonical_path(*targetp); + visit_type_str(v, name, &path, errp); + } else { + path =3D g_strdup(""); + visit_type_str(v, name, &path, errp); + } +} + +static void set_link(Object *obj, Visitor *v, const char *name, void *opaq= ue, + Error **errp) +{ + const Property *prop =3D opaque; + Object **targetp =3D object_field_prop_ptr(obj, prop); + g_autofree char *path =3D NULL; + Object *new_target, *old_target =3D *targetp; + + ERRP_GUARD(); + + /* Get the path to the object we want to set the link to */ + if (!visit_type_str(v, name, &path, errp)) { + return; + } + + /* Now get the pointer to the actual object */ + if (*path) { + new_target =3D object_resolve_and_typecheck(path, prop->name, + prop->link_type, errp); + if (!new_target) { + return; + } + } else { + new_target =3D NULL; + } + + /* + * Our link properties are always OBJ_PROP_LINK_STRONG and + * have the allow_set_link_before_realize check. + */ + qdev_prop_allow_set_link_before_realize(obj, prop->name, new_target, e= rrp); + if (*errp) { + return; + } + + *targetp =3D new_target; + object_ref(new_target); + object_unref(old_target); +} + const PropertyInfo qdev_prop_link =3D { .type =3D "link", .create =3D create_link_property, + /* + * Since we have a create method, the get and set are used + * only in get_prop_array() and set_prop_array() for the case + * where we have an array of link properties. + */ + .get =3D get_link, + .set =3D set_link, }; =20 void qdev_property_add_static(DeviceState *dev, const Property *prop) diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-prope= rties.h index 17543957a6..eba5436e53 100644 --- a/include/hw/core/qdev-properties.h +++ b/include/hw/core/qdev-properties.h @@ -169,6 +169,32 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP(_name, _state, _field, qdev_prop_link, _ptr_type, \ .link_type =3D _type) =20 +/** + * DEFINE_PROP_LINK_ARRAY: + * @_name: name of the array + * @_state: name of the device state structure type + * @_field: uint32_t field in @_state to hold the array length + * @_arrayfield: field in @_state (of type '@_arraytype *') which + * will point to the array + * @_linktype: QOM type name of the link type + * @_arraytype: C type of the array elements + * + * Define device properties for a variable-length array _name of links + * (i.e. this is the array version of DEFINE_PROP_LINK). + * + * The array is represented as a list of QStrings in the visitor interface, + * where each string is the QOM path of the object to be linked. + */ +#define DEFINE_PROP_LINK_ARRAY(_name, _state, _field, _arrayfield, \ + _linktype, _arraytype) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_array, uint32_t, \ + .set_default =3D true, \ + .defval.u =3D 0, \ + .arrayinfo =3D &qdev_prop_link, \ + .arrayfieldsize =3D sizeof(_arraytype), \ + .arrayoffset =3D offsetof(_state, _arrayfield), \ + .link_type =3D _linktype) + #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \ @@ -220,6 +246,21 @@ void qdev_prop_set_enum(DeviceState *dev, const char *= name, int value); /* Takes ownership of @values */ void qdev_prop_set_array(DeviceState *dev, const char *name, QList *values= ); =20 +/** + * qlist_append_link: Add a QOM object to a QList of link properties + * @qlist: list to append to + * @obj: object to append + * + * This is a helper function for constructing a QList to pass to + * qdev_prop_set_array() when the qdev property array is an array of + * link properties (i.e. one defined with DEFINE_PROP_LINK_ARRAY). + * + * The object is encoded into the list as a QString which is the + * canonical path of the object; this is the same encoding that + * object_set_link_property() and object_get_link_property() use. + */ +void qlist_append_link(QList *qlist, Object *obj); + void *object_field_prop_ptr(Object *obj, const Property *prop); =20 void qdev_prop_register_global(GlobalProperty *prop); --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169421; cv=none; d=zohomail.com; s=zohoarc; b=RnW9NO7ebzOtvmV9gx2Sp0aePJ+Z4HUPLN1fU70jT0OhHkEmEVkqwn1uaM2SPtWGiQo5CaJWDntaKh5lsl2zLH2cFxBvoFv+c8zseGZqCc/QP+dkbXh8WR/9Lwy0ceyvgxbKWPKdQPeA+AmzNCNfWDczuXHgOWs5M5K+Az4gJaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169421; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=NpvH/R2i57f6KnUbvaj8PUa3Nl1jmHGibvqUo7D9DqY=; b=TpUh7gNU508PvVzBg88njq6Yj814k1TZCyM0YuUQgCNCkFKgkc6m5FAjMQxBz7tm+LKUPPLNnmz9KjCGx9mR7nqte+FP+qtp6L9taiVDstzJYAZxzXQm4YM/NLljVbcwSF/f/gLJIbRg/FiPoHiEwkYd32wyQBzur5IbXm5jmW0= 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 17781694218187.731002764492473; Thu, 7 May 2026 08:57:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11G-0003Rd-Ck; Thu, 07 May 2026 11:52: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 1wL118-0003Ob-Oh for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:02 -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 1wL116-0003kF-I3 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:02 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4891e86fabeso12799555e9.1 for ; Thu, 07 May 2026 08:52:00 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.51.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169119; x=1778773919; 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; bh=NpvH/R2i57f6KnUbvaj8PUa3Nl1jmHGibvqUo7D9DqY=; b=AI+UHNQWq2EAI7n3oO/bDV8eupmYgeZ+LgKgfVLNatii7g8rluQ350fofMyuKhd2W6 aytDne/aFMmKgoJIB2LX92nedvHl3GQhpuvhvVLNBRfHabBqxLlLGR65dSxlhnyK5WAV AGGkXyIKtpfNfySRx6paZ5ABDqIyNx9FGjpqzQ/hrOHKnZ1TXfejVeAD9NEkp7do8jbd xsP+JMIIpE0qBzhDfOBErtDztgkp/HpXPhoHY6uPiU3Z3JV+12A1ABhU5CtYbHHN7y8o HzT+Q56bQ0AfBuxKPkkOZ9wqAhJvFpfXLOXZ3/OLydlt2FKkF7YGDAsL03tmbGQVU6IP TU7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169119; x=1778773919; 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; bh=NpvH/R2i57f6KnUbvaj8PUa3Nl1jmHGibvqUo7D9DqY=; b=AwbVFBhOBpFTs86SFQqmarM+wCz1xQQHq0e+n5xqzyEohSPnEC4Z+ySqZ8aJ2X1QVz mobCLYA1zJLuS6l++C+tzq/c4+ai8nKKdqPwBKxxcxrwgOBLj1162F9GxhWcPGX2PTsl tDw/jrnDQhM1IG1j0TU8JZLKnfc6u7OQQAGCAvmHmgx0JSM5FfsQeEXEh4mk/ne8UfZe fkN8bp2Tmb4+HBvu0cRoQZMTie83O8lhPpcFgFqkdS+tQHS08M2+DPj3yZ+Hm+2TPxx9 Fo6iiqPfnq0vgerDxkp4To/BSSb4lvsZ5fPlgySseQYya46Fm7lY2cKJP0Uyt/G2eDqC bBrA== X-Gm-Message-State: AOJu0YxMJBygvaNavpDzT8WC+jRWi+UVO5g88XrmKKR2Uy1AvCGTuCRk 7MqKtRL3MzblAnqOb/l3AKKTcyPa410x8HL0nV61XsOL6aWQEeDIrNOh526yNwV9cM8okhI+fYp uqUca X-Gm-Gg: AeBDieuA7wQEK59YwxP+MUJItBEmzocZ+k8sr6KWzS+AekAkCPaydCWN42d1pmU6mDv YyrZkp/Y01RCdeFL3Fy7Qdaoyrt16d528y7kzWqZ8uTuN9XtVdqArNhrL96tQV0T/xAO9kpU3na Mh+xvsFob4Ebt5iatMdROG2sVv+vRkBqlzjOXobnpnRLofcJ3m+fx9oV4m3xvhss1q5C9JG9/6X X1BeRPIy/37HUDO9CZsWSGP7XygMueM4csBkpgeks+oNS4xZNlNWIBBFvGtzettvQ+hGj1703cM 50tTpA0cc8nfkKfwVcIzY/9MWFlyR91EP5J0dwAbn8CZF+UnORSQ07GeOQYA5cYqxgfuSiKreWK QqL8tnCyyq7b99mBYln4ILX00zYZVNCJUh5o5ZmD2sQ5uYubp9JpxpFnyKuGJOxEnCjBhgYPH1u GsEf4AfajutDODmcj2UgIciKofCYlVn9jVtZPHWlmu0Cyr7qNW72Q117s6palNQNis5t2EQCiGQ 50b6YDMrczCSTgv X-Received: by 2002:a05:600c:1d18:b0:488:78f2:6b0 with SMTP id 5b1f17b1804b1-48e51f41b9cmr134944375e9.29.1778169118640; Thu, 07 May 2026 08:51:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/67] hw/intc: Skeleton of GICv5 IRS classes Date: Thu, 7 May 2026 16:50:50 +0100 Message-ID: <20260507155154.1886557-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169423554154100 This commit adds the skeleton of the classes for the GICv5 IRS (Interrupt Routing Service). Since the IRS is the main (and only non-optional) part of the GICv5 outside the CPU, we call it simply "GICv5", in line with how we've handled the GICv3. Since we're definitely going to need to have support for KVM VMs where we present the guest with a GICv5, we use the same split between an abstract "common" and a concrete specific-to-TCG child class that we have for the various GICv3 components. This avoids having to refactor out the base class later. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-4-peter.maydell@linaro.org --- hw/intc/Kconfig | 5 ++++ hw/intc/arm_gicv5.c | 39 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 31 ++++++++++++++++++++++++ hw/intc/meson.build | 4 +++ include/hw/intc/arm_gicv5.h | 32 ++++++++++++++++++++++++ include/hw/intc/arm_gicv5_common.h | 31 ++++++++++++++++++++++++ 6 files changed, 142 insertions(+) create mode 100644 hw/intc/arm_gicv5.c create mode 100644 hw/intc/arm_gicv5_common.c create mode 100644 include/hw/intc/arm_gicv5.h create mode 100644 include/hw/intc/arm_gicv5_common.h diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig index 9f456d7e43..636d00b7e8 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -35,6 +35,11 @@ config ARM_GIC_KVM bool depends on ARM_GIC && KVM =20 +config ARM_GICV5 + bool + depends on TCG + select MSI_NONBROKEN + config XICS bool =20 diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c new file mode 100644 index 0000000000..f9dab710d3 --- /dev/null +++ b/hw/intc/arm_gicv5.c @@ -0,0 +1,39 @@ +/* + * ARM GICv5 emulation: Interrupt Routing Service (IRS) + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/intc/arm_gicv5.h" + +OBJECT_DEFINE_TYPE(GICv5, gicv5, ARM_GICV5, ARM_GICV5_COMMON) + +static void gicv5_reset_hold(Object *obj, ResetType type) +{ + GICv5 *s =3D ARM_GICV5(obj); + GICv5Class *c =3D ARM_GICV5_GET_CLASS(s); + + if (c->parent_phases.hold) { + c->parent_phases.hold(obj, type); + } +} + +static void gicv5_init(Object *obj) +{ +} + +static void gicv5_finalize(Object *obj) +{ +} + +static void gicv5_class_init(ObjectClass *oc, const void *data) +{ + ResettableClass *rc =3D RESETTABLE_CLASS(oc); + GICv5Class *gc =3D ARM_GICV5_CLASS(oc); + + resettable_class_set_parent_phases(rc, NULL, gicv5_reset_hold, NULL, + &gc->parent_phases); +} diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c new file mode 100644 index 0000000000..b0194f7f26 --- /dev/null +++ b/hw/intc/arm_gicv5_common.c @@ -0,0 +1,31 @@ +/* + * Common base class for GICv5 IRS + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/intc/arm_gicv5_common.h" + +OBJECT_DEFINE_ABSTRACT_TYPE(GICv5Common, gicv5_common, ARM_GICV5_COMMON, S= YS_BUS_DEVICE) + +static void gicv5_common_reset_hold(Object *obj, ResetType type) +{ +} + +static void gicv5_common_init(Object *obj) +{ +} + +static void gicv5_common_finalize(Object *obj) +{ +} + +static void gicv5_common_class_init(ObjectClass *oc, const void *data) +{ + ResettableClass *rc =3D RESETTABLE_CLASS(oc); + + rc->phases.hold =3D gicv5_common_reset_hold; +} diff --git a/hw/intc/meson.build b/hw/intc/meson.build index c6de2d9d00..d7db99ce35 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -12,6 +12,10 @@ system_ss.add(when: 'CONFIG_ARM_GICV3', if_true: files( 'arm_gicv3_its.c', 'arm_gicv3_redist.c', )) +system_ss.add(when: 'CONFIG_ARM_GICV5', if_true: files( + 'arm_gicv5_common.c', + 'arm_gicv5.c', +)) system_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-= a10-pic.c')) system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_vic.c')) system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_intc.c')) diff --git a/include/hw/intc/arm_gicv5.h b/include/hw/intc/arm_gicv5.h new file mode 100644 index 0000000000..3cd9652f6f --- /dev/null +++ b/include/hw/intc/arm_gicv5.h @@ -0,0 +1,32 @@ +/* + * ARM GICv5 emulation: Interrupt Routing Service (IRS) + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_INTC_ARM_GICV5_H +#define HW_INTC_ARM_GICV5_H + +#include "qom/object.h" +#include "hw/core/sysbus.h" +#include "hw/intc/arm_gicv5_common.h" + +#define TYPE_ARM_GICV5 "arm-gicv5" + +OBJECT_DECLARE_TYPE(GICv5, GICv5Class, ARM_GICV5) + +/* + * This class is for TCG-specific state for the GICv5. + */ +struct GICv5 { + GICv5Common parent_obj; +}; + +struct GICv5Class { + GICv5CommonClass parent_class; + ResettablePhases parent_phases; +}; + +#endif diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h new file mode 100644 index 0000000000..d2243c7660 --- /dev/null +++ b/include/hw/intc/arm_gicv5_common.h @@ -0,0 +1,31 @@ +/* + * Common base class for GICv5 IRS + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_INTC_ARM_GICV5_COMMON_H +#define HW_INTC_ARM_GICV5_COMMON_H + +#include "qom/object.h" +#include "hw/core/sysbus.h" + +#define TYPE_ARM_GICV5_COMMON "arm-gicv5-common" + +OBJECT_DECLARE_TYPE(GICv5Common, GICv5CommonClass, ARM_GICV5_COMMON) + +/* + * This class is for common state that will eventually be shared + * between TCG and KVM implementations of the GICv5. + */ +struct GICv5Common { + SysBusDevice parent_obj; +}; + +struct GICv5CommonClass { + SysBusDeviceClass parent_class; +}; + +#endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169252; cv=none; d=zohomail.com; s=zohoarc; b=UEDDeuojhFUOW36ZCtDEgty/dteMG1oTE7AXGvwzPY1g1dtBji8Ef1Y7Kd7BdbayyF8Gd1QrARnCIicEapWA1YQVJECJ4n6AnME/sil17Tdy7Q9G832RmLsgxbJGwQljDwUqMJ9ZhzkXWQIEJXYRl/oD8TV9CACDcKf/FfqYukc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169252; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=V1C1Hqd/9X5wZGqORj/IsagCzcveEdkl7UsFoZal3QY=; b=hXyceq72ClxrRt8Tk2SfhYc5FhElmlSkS9BMnLa7GOHFOZhdjXRYnTOSc5A+HpThOvQ5mB4syzgvOTrd9mTN9qlGkjoFV9RQwV7nLl2S6Tcjm7i01F7JCdEkcqAGANkmgj7rgKrMRbTpbHYBa/9snXIBNiHIeXReAiNTNZmbRfs= 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 1778169252878824.2065627485772; Thu, 7 May 2026 08:54:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11F-0003RC-Dr; Thu, 07 May 2026 11:52: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 1wL11A-0003Os-8w for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:04 -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 1wL117-0003kR-AK for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:03 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-48d146705b4so12771975e9.3 for ; Thu, 07 May 2026 08:52:00 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.51.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169120; x=1778773920; 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; bh=V1C1Hqd/9X5wZGqORj/IsagCzcveEdkl7UsFoZal3QY=; b=yROlnLbbOnJyVyCJD+NLl5ZHG5Gf/3Omj31huV/2VeG94OiXiZPHW3iWaGBsYEXbN1 DGFb7ExTAwWxeylw6YgqS7jid5OUXy1uaeUlTYa6UistE0YuW2G01wZv7SSexo4NUD1B WAyADmc4O74EhXtr9XuUJSjGor7HzGpm617bKOn0Psxyca52uh+RpjLezKR4purV04Ac V+5YfAtGjON/F4rFTOMhNW+mwsr9N52MN26JQt/tr2SbyC/o5d+sjP1vlCz3AVcalpOP LEdSih4D1vBJ3kEP0nT0e3kg1JivusuhxhRJrLcLe8d/HVdhf7IRW+cxa1fb8b3OFbi+ RGnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169120; x=1778773920; 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; bh=V1C1Hqd/9X5wZGqORj/IsagCzcveEdkl7UsFoZal3QY=; b=mjSQckIfSiHP+nKZ/la4ER9vsufelSzqsPhjeATd9+T0VFja1qgxnl7p1wt748gCcO AI27G+X4mfvLxhEgBYWvky2WN7zj1ED+3a2rfS/8RuqDleVOhyGZwvHXOG3UM7HmsEO1 m21ihBXvbbtIprmvFaBsMqADhQSZkpb4/QOpNl3eHFobzX2wxe3ibR6x+0bn3XagoUiS ctVvk6KguEfOwwe5dmT4juppp+OJglJjQqSW7KghnPwzLpwZ77wAeZ+MzDlhcPc9e53/ 1oG0XnvAyAWhym/4agfnTby2+AO4qNbc/OcFxr2dyRvfjezYaWIIODzNhWTjuRCeHu3a UHUg== X-Gm-Message-State: AOJu0YwHmq0ZS9UzN6hbBG9Pwd31BnBT9OqTuMHwN3swXb4NtBo2Fgs7 lxQL9QkAbdYR32i6qFd8m1FeGgqdj12yZa9n7ZYs/+yrrABFcoEVi9fGvOdZaW7/DA8QZj7rK4P +upZ8 X-Gm-Gg: AeBDieuhbmbt4c1sNDySvDZ3+zjQx4eVNs0R4cPq8ep4K1XYxWQ8teW5+tRKWZbTvRu X/yJsCQZKIG/a97rqZOiVYnTxNR72wmUfwG4O8w507oHOVsSh3IzelkCH1AAd4L0haFXy+xCCHI i3yk+eAkZjoiKep0OfEg+A+Q+dZ45BDPST8WoNXXEWkbaA9CrVDOMVWKIIbrNYRBHXBrVtybvnq jRXpVJAwJKOom9GFH50iob93q+6BMM5YiUp/B49VfK2XVMsXNCwmj8bqYtosjW9wph9zShnSItd N9PQM0D9h8+OrXqEfF3QsYmV0IfBcjSDbnPgIe3HWnwDeZg0PsMsoYLTVL7dD0FzvC8pOLSPBd+ 8M/XEMWfZmmUz83VfMnP8789Lzfif03mmZW0mTsnZQJyLBDW3KD9V4rNtz9iQNWRnC1UXm80CSo gdqlZI+dyJ/9V91v5K9vN5pXf0or76I3vmwqC4aKq8E301ejS9asP9U/A3Y+3HElT5nDFSsXBX6 vmviboBdhvSNO7p2edqBi4WmjlFHfM= X-Received: by 2002:a05:600c:c096:b0:48a:f18:ece4 with SMTP id 5b1f17b1804b1-48e51f50982mr100817385e9.24.1778169119604; Thu, 07 May 2026 08:51:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/67] hw/arm/Kconfig: select ARM_GICV5 for ARM_VIRT board Date: Thu, 7 May 2026 16:50:51 +0100 Message-ID: <20260507155154.1886557-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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=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: 1778169254727154100 When building the Arm "virt" board, pull in the GICv5. We haven't added support for creating or wiring up the GICv5 in that board yet, but adding it to the Kconfig early means that the GICv5 code will be compiled and so we can have more confidence that the individual commits building it up are correct (or at least compile). Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-5-peter.maydell@linaro.org --- hw/arm/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index c31752e83a..5b198402d5 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -10,6 +10,7 @@ config ARM_VIRT imply NVDIMM imply IOMMUFD select ARM_GIC + select ARM_GICV5 if TCG select ACPI select ARM_SMMUV3 select GPIO_KEY --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169431; cv=none; d=zohomail.com; s=zohoarc; b=B0oFACwnZPSnsozmvC7A780pZlHj9UcnQ6Fl/TB3VRfzOoHQ6leibxObJJ3CIVxM25A+743IRJfhi9BW7/TPi4brdYa2iZ91j+LxgP8IDHaBzKCEoWn+H1s9LQeqSRjMES7mgE4YRi7KsKCSIEtG+TK/OorrZxeJR9kRYrcBVhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169431; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=aEuAsB43saFT3xD334pf1REQAACVFTsW2gDNGJZYJ1E=; b=K3ARnZ3B2sTxFB9/08ZUE40VRZcNLfn16W6oidczoMrmdq1RJbljg+aVpe8gwYAe4bbpkqgONusejMIQdgBdznx3kLx8yBP9sJ+mYhzSfbw5KAIfis+10AdIK/baRipewoWI98Xte9Wy2HsHoTxeIpdPrLftVxWuMuDvvvgOmTE= 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 1778169431690218.90129204952484; Thu, 7 May 2026 08:57:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11G-0003RV-15; Thu, 07 May 2026 11:52: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 1wL11B-0003P2-6r for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:06 -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 1wL118-0003l7-AO for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:04 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-488af96f6b2so12017265e9.0 for ; Thu, 07 May 2026 08:52:01 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.51.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169121; x=1778773921; 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; bh=aEuAsB43saFT3xD334pf1REQAACVFTsW2gDNGJZYJ1E=; b=zzkDQVj+raWg6FxZdy+00Kivrbrjv/AsmreudNnf0yTZ/AAKBnuE+8Db59lvKNCcq0 DXL71ZYP72sE3qSEBSu3elLJz9nxtcXvNRMzGDr4na5k00T5exgS3kBr59TTh1fDdBSP Klh6cjfN3kcqNK4+zl3nP0hU8yWJ+sKTd2h8jwleqfnZsEawOb1k+y2q1NXDbTqUuCO0 lE9NlP2IeXtE1QlRNxhj61fSQy82TwPuQIWIQdHSDQrA53iHvf7c4+tl3dYwwFoPYikR XxPPaOiKa8mDtxeTTxYPJ9fB+RyBGgnE4V1EpQqSDORHqxIJKuoUrp0FDDGwIg/cA2SU Rt2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169121; x=1778773921; 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; bh=aEuAsB43saFT3xD334pf1REQAACVFTsW2gDNGJZYJ1E=; b=DTJTc2E3h7rqW+8FKTA3ngo2ZZpRSPjRlffnj7b0ynMiWOzoj2naeYxGvQ35cDWzIP oi6hZLfj6QW/eVeojER0eqyk3xrymBr6aA6FCmGjwQcSSNhz2mbciJG2Pl6Cx0+tMUF9 0iR9PdI/rMtAcTqUFV82Sc73mDyvY6LRCbhk9xtJG1R7ojpjI7xhiWWQnjHTRjQv2Zuy wC9WVygkeqcb9AjKb1BsUITkVx9SWgXJhntDzf33vIKzuUrTIm7rYOvT8SURCiTXfb1b fq5VOTqCMQGpSA8koi1M+tYbPE0fkTraaW+szZJSLWtAwgaUf621j7tv9gtUFlUWGAo3 oX4A== X-Gm-Message-State: AOJu0Yygw5v7SKIJXRls6bwM+6JUxqW2NLzbbB+awDGgYyG2KqblZ4Th so8zo2CY+95n6RfLSmfipr02TMGD6h5OgXxFQBdlS/JCjeAIqX/4b61ATFn7IZMG2syuedT0Yob E2BxD X-Gm-Gg: AeBDieuqgrRgqkVTF01lTl96++6bW0tX33dA9jfWuFPDJ0aLvctWDxOz9l7OVJDyi7H juJcEndWcXntM1ZY9we0aLKK/uK1EtAYwtFf9Je50X182REyp93KqMST8epsYVLLBToezGYtPxx 3da6Bvqehdt41gV/6ERScrgxXrl0xvtBFwc9mi94C50BBIDgZ2+edYMpI6j/XprFMK5tr7IAklv m0MHvkjJbcpwFrTmAR9WYFIUkyN6zprPbJcHBJtlqEcNedIXrAT2ypasOszgWmjqU63ZKrlVaGh mRHJYyVCeGkCC65in3WUfsqsN/IwGsawFBgJL/08bPh7xt24pQHTgfv27Ru3GQaobmL8puvdMNk BE3O17YnxYtX11NigUhso38zFfHpqkIH0ry22IWY1YVag++N9T3rUqNWsisxJfwieps/9I6VJCH xW5gcxS+OqXJAfprd7AfdaVQN5stIkbALiGTybIGLVa2SCrkiYrCOyIe9z4jR5HFfcuX3d31Dxk D73vg694r5XG8cSSVcIsltt1gOi0XceSzshF8RwBw== X-Received: by 2002:a05:600c:c096:b0:485:40db:d40c with SMTP id 5b1f17b1804b1-48e51e08fedmr102092955e9.3.1778169120460; Thu, 07 May 2026 08:52:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/67] hw/intc/arm_gicv5: Implement skeleton code for IRS register frames Date: Thu, 7 May 2026 16:50:52 +0100 Message-ID: <20260507155154.1886557-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169433829154100 Content-Type: text/plain; charset="utf-8" The GICv5 IRS has one mandatory register frame (the config frame) for each of up to four supported physical interrupt domains. Implement the skeleton of the code needed to create these as sysbus MMIO regions. The config frame has a mix of 32-bit and 64-bit registers, and it is valid to access the 64-bit registers with 32-bit accesses. In a similar way to the various GICv3 devices, we turn the MemoryRegionOps read_with_attrs and write_with_attrs calls into calls on functions specifically to read 32 or 64 bit values. (We can't trivially implement one in terms of the other because various registers have side effects on write which must only trigger when the "correct" half of the 64-bit register is written to.) Unlike the GICv3, we choose to expose a sysbus MMIO region for each interrupt domain even if the config of the GICv5 means that it doesn't implement that domain. This avoids having the config frame for a domain ending up at a different MMIO region index depending on the config of the GICv5. (This matters more for GICv5 because it supports Realm, and so there are more possible valid configurations.) gicv5_common_init_irqs_and_mmio() does not yet create any IRQs, but we name it this way to parallel the equivalent GICv3 function and to avoid having to rename it when we add the IRQ line creation in a subsequent commit. The arm_gicv5_types.h header is a little undermotivated at this point, but the aim is to have somewhere to put definitions that we want in both the GIC proper and the CPU interface. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-6-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 172 +++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 35 ++++++ hw/intc/trace-events | 6 + include/hw/intc/arm_gicv5.h | 1 + include/hw/intc/arm_gicv5_common.h | 50 +++++++++ include/hw/intc/arm_gicv5_types.h | 28 +++++ 6 files changed, 292 insertions(+) create mode 100644 include/hw/intc/arm_gicv5_types.h diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index f9dab710d3..3a9d566924 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -8,9 +8,157 @@ =20 #include "qemu/osdep.h" #include "hw/intc/arm_gicv5.h" +#include "qapi/error.h" +#include "qemu/log.h" +#include "trace.h" =20 OBJECT_DEFINE_TYPE(GICv5, gicv5, ARM_GICV5, ARM_GICV5_COMMON) =20 +static const char *domain_name[] =3D { + [GICV5_ID_S] =3D "Secure", + [GICV5_ID_NS] =3D "NonSecure", + [GICV5_ID_EL3] =3D "EL3", + [GICV5_ID_REALM] =3D "Realm", +}; + +static bool config_readl(GICv5 *s, GICv5Domain domain, hwaddr offset, + uint64_t *data, MemTxAttrs attrs) +{ + return false; +} + +static bool config_writel(GICv5 *s, GICv5Domain domain, hwaddr offset, + uint64_t data, MemTxAttrs attrs) +{ + return false; +} + +static bool config_readll(GICv5 *s, GICv5Domain domain, hwaddr offset, + uint64_t *data, MemTxAttrs attrs) +{ + return false; +} + +static bool config_writell(GICv5 *s, GICv5Domain domain, hwaddr offset, + uint64_t data, MemTxAttrs attrs) +{ + return false; +} + +static MemTxResult config_read(void *opaque, GICv5Domain domain, hwaddr of= fset, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + GICv5 *s =3D ARM_GICV5(opaque); + bool result; + + switch (size) { + case 4: + result =3D config_readl(s, domain, offset, data, attrs); + break; + case 8: + result =3D config_readll(s, domain, offset, data, attrs); + break; + default: + result =3D false; + break; + } + + if (!result) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: invalid guest read for IRS %s config frame " + "at offset " HWADDR_FMT_plx + " size %u\n", __func__, domain_name[domain], + offset, size); + trace_gicv5_badread(domain_name[domain], offset, size); + /* + * The spec requires that reserved registers are RAZ/WI; so we + * log the error but return MEMTX_OK so we don't cause a + * spurious data abort. + */ + *data =3D 0; + } else { + trace_gicv5_read(domain_name[domain], offset, *data, size); + } + + return MEMTX_OK; +} + +static MemTxResult config_write(void *opaque, GICv5Domain domain, + hwaddr offset, uint64_t data, unsigned siz= e, + MemTxAttrs attrs) +{ + GICv5 *s =3D ARM_GICV5(opaque); + bool result; + + switch (size) { + case 4: + result =3D config_writel(s, domain, offset, data, attrs); + break; + case 8: + result =3D config_writell(s, domain, offset, data, attrs); + break; + default: + result =3D false; + break; + } + + if (!result) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: invalid guest write for IRS %s config frame " + "at offset " HWADDR_FMT_plx + " size %u\n", __func__, domain_name[domain], + offset, size); + trace_gicv5_badwrite(domain_name[domain], offset, data, size); + /* + * The spec requires that reserved registers are RAZ/WI; so we + * log the error but return MEMTX_OK so we don't cause a + * spurious data abort. + */ + } else { + trace_gicv5_write(domain_name[domain], offset, data, size); + } + + return MEMTX_OK; +} + +#define DEFINE_READ_WRITE_WRAPPERS(NAME, DOMAIN) = \ + static MemTxResult config_##NAME##_read(void *opaque, hwaddr offset, = \ + uint64_t *data, unsigned size,= \ + MemTxAttrs attrs) = \ + { = \ + return config_read(opaque, DOMAIN, offset, data, size, attrs); = \ + } = \ + static MemTxResult config_##NAME##_write(void *opaque, hwaddr offset, = \ + uint64_t data, unsigned size,= \ + MemTxAttrs attrs) = \ + { = \ + return config_write(opaque, DOMAIN, offset, data, size, attrs); = \ + } + +DEFINE_READ_WRITE_WRAPPERS(ns, GICV5_ID_NS) +DEFINE_READ_WRITE_WRAPPERS(realm, GICV5_ID_REALM) +DEFINE_READ_WRITE_WRAPPERS(secure, GICV5_ID_S) +DEFINE_READ_WRITE_WRAPPERS(el3, GICV5_ID_EL3) + +#define FRAME_OP_ENTRY(NAME, DOMAIN) \ + [DOMAIN] =3D { \ + .read_with_attrs =3D config_##NAME##_read, \ + .write_with_attrs =3D config_##NAME##_write, \ + .endianness =3D DEVICE_LITTLE_ENDIAN, \ + .valid.min_access_size =3D 4, \ + .valid.max_access_size =3D 8, \ + .impl.min_access_size =3D 4, \ + .impl.max_access_size =3D 8, \ + } + +static const MemoryRegionOps config_frame_ops[NUM_GICV5_DOMAINS] =3D { + FRAME_OP_ENTRY(ns, GICV5_ID_NS), + FRAME_OP_ENTRY(realm, GICV5_ID_REALM), + FRAME_OP_ENTRY(secure, GICV5_ID_S), + FRAME_OP_ENTRY(el3, GICV5_ID_EL3), +}; + static void gicv5_reset_hold(Object *obj, ResetType type) { GICv5 *s =3D ARM_GICV5(obj); @@ -21,6 +169,28 @@ static void gicv5_reset_hold(Object *obj, ResetType typ= e) } } =20 +static void gicv5_realize(DeviceState *dev, Error **errp) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(dev); + GICv5Class *gc =3D ARM_GICV5_GET_CLASS(dev); + + ERRP_GUARD(); + + gc->parent_realize(dev, errp); + if (*errp) { + return; + } + + /* + * When we implement support for more than one interrupt domain, + * we will provide some QOM properties so the board can configure + * which domains are implemented. For now, we only implement the + * NS domain. + */ + cs->implemented_domains =3D (1 << GICV5_ID_NS); + gicv5_common_init_irqs_and_mmio(cs, config_frame_ops); +} + static void gicv5_init(Object *obj) { } @@ -32,8 +202,10 @@ static void gicv5_finalize(Object *obj) static void gicv5_class_init(ObjectClass *oc, const void *data) { ResettableClass *rc =3D RESETTABLE_CLASS(oc); + DeviceClass *dc =3D DEVICE_CLASS(oc); GICv5Class *gc =3D ARM_GICV5_CLASS(oc); =20 + device_class_set_parent_realize(dc, gicv5_realize, &gc->parent_realize= ); resettable_class_set_parent_phases(rc, NULL, gicv5_reset_hold, NULL, &gc->parent_phases); } diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index b0194f7f26..bf990bfa54 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -11,6 +11,41 @@ =20 OBJECT_DEFINE_ABSTRACT_TYPE(GICv5Common, gicv5_common, ARM_GICV5_COMMON, S= YS_BUS_DEVICE) =20 +static bool bad_frame_accepts(void *opaque, hwaddr addr, unsigned size, + bool is_write, MemTxAttrs attrs) +{ + return false; +} + +/* + * Used for the sysbus MMIO regions corresponding to IRS frames where + * this IRS does not implement the interrupt domain. It's probably a + * board/SoC error to create an IRS and try to wire up this MMIO + * region, but if it does then the region will behave as unassigned + * memory (generating a decode error). These frames are just here so + * that changing which domains are implemented doesn't reorder which + * sysbus MMIO region is which. + */ +static const MemoryRegionOps bad_frame_ops =3D { + .valid.accepts =3D bad_frame_accepts, + .endianness =3D DEVICE_LITTLE_ENDIAN, +}; + +void gicv5_common_init_irqs_and_mmio(GICv5Common *cs, + const MemoryRegionOps config_ops[NUM_= GICV5_DOMAINS]) +{ + SysBusDevice *sbd =3D SYS_BUS_DEVICE(cs); + + for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { + g_autofree char *memname =3D g_strdup_printf("gicv5-irs-%d", i); + const MemoryRegionOps *ops =3D gicv5_domain_implemented(cs, i) ? + &config_ops[i] : &bad_frame_ops; + memory_region_init_io(&cs->iomem[i], OBJECT(cs), ops, cs, + memname, IRS_CONFIG_FRAME_SIZE); + sysbus_init_mmio(sbd, &cs->iomem[i]); + } +} + static void gicv5_common_reset_hold(Object *obj, ResetType type) { } diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 018c609ca5..edd3c49c5f 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -227,6 +227,12 @@ gicv3_its_vte_read(uint32_t vpeid, int valid, uint32_t= vptsize, uint64_t vptaddr gicv3_its_vte_read_fault(uint32_t vpeid) "GICv3 ITS: vPE Table read for vP= EID 0x%x: faulted" gicv3_its_vte_write(uint32_t vpeid, int valid, uint32_t vptsize, uint64_t = vptaddr, uint32_t rdbase) "GICv3 ITS: vPE Table write for vPEID 0x%x: valid= %d VPTsize 0x%x VPTaddr 0x%" PRIx64 " RDbase 0x%x" =20 +# arm_gicv5.c +gicv5_read(const char *domain, uint64_t offset, uint64_t data, unsigned si= ze) "GICv5 IRS %s config frame read: offset 0x%" PRIx64 " data 0x%" PRIx64 = " size %u" +gicv5_badread(const char *domain, uint64_t offset, unsigned size) "GICv5 I= RS %s config frame read: offset 0x%" PRIx64 " size %u: error" +gicv5_write(const char *domain, uint64_t offset, uint64_t data, unsigned s= ize) "GICv5 IRS %s config frame write: offset 0x%" PRIx64 " data 0x%" PRIx6= 4 " size %u" +gicv5_badwrite(const char *domain, uint64_t offset, uint64_t data, unsigne= d size) "GICv5 IRS %s config frame write: offset 0x%" PRIx64 " data 0x%" PR= Ix64 " size %u: error" + # armv7m_nvic.c nvic_recompute_state(int vectpending, int vectpending_prio, int exception_= prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_= prio %d" nvic_recompute_state_secure(int vectpending, bool vectpending_is_s_banked,= int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpend= ing %d is_s_banked %d vectpending_prio %d exception_prio %d" diff --git a/include/hw/intc/arm_gicv5.h b/include/hw/intc/arm_gicv5.h index 3cd9652f6f..42ccef8474 100644 --- a/include/hw/intc/arm_gicv5.h +++ b/include/hw/intc/arm_gicv5.h @@ -26,6 +26,7 @@ struct GICv5 { =20 struct GICv5Class { GICv5CommonClass parent_class; + DeviceRealize parent_realize; ResettablePhases parent_phases; }; =20 diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index d2243c7660..b7a17aac31 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -11,6 +11,26 @@ =20 #include "qom/object.h" #include "hw/core/sysbus.h" +#include "hw/intc/arm_gicv5_types.h" + +/* + * QEMU interface: + * + * sysbus MMIO regions (in order matching IRS_IDR0.INT_DOM encoding): + * - IRS config frame for the Secure Interrupt Domain + * - IRS config frame for the Non-secure Interrupt Domain + * - IRS config frame for the EL3 Interrupt Domain + * - IRS config frame for the Realm Interrupt Domain + * + * Note that even if this particular IRS does not implement all four + * interrupt domains it will still expose four sysbus MMIO regions. + * The regions corresponding to unimplemented domains will always fail + * accesses with a decode error. Generally the SoC/board should + * probably not map a region for a domain that it configured the IRS + * to not implement; the regions are only exposed so that changing + * which domains are implemented doesn't reorder which sysbus MMIO + * region is which (e.g. NS will always be 1 and EL3 will always be 2). + */ =20 #define TYPE_ARM_GICV5_COMMON "arm-gicv5-common" =20 @@ -22,10 +42,40 @@ OBJECT_DECLARE_TYPE(GICv5Common, GICv5CommonClass, ARM_= GICV5_COMMON) */ struct GICv5Common { SysBusDevice parent_obj; + + MemoryRegion iomem[NUM_GICV5_DOMAINS]; + + /* Bits here are set for each physical interrupt domain implemented */ + uint8_t implemented_domains; }; =20 struct GICv5CommonClass { SysBusDeviceClass parent_class; }; =20 + +#define IRS_CONFIG_FRAME_SIZE 0x10000 + +/** + * gicv5_common_init_irqs_and_mmio: Create IRQs and MMIO regions for the G= ICv5 + * @s: GIC object + * @ops: array of MemoryRegionOps that implement the config frames behavio= ur + * + * Subclasses of ARM_GICV5_COMMON should call this to create the sysbus + * MemoryRegions for the IRS config frames, passing in a four element array + * of MemoryRegionOps structs. + */ +void gicv5_common_init_irqs_and_mmio(GICv5Common *cs, + const MemoryRegionOps ops[NUM_GICV5_D= OMAINS]); + +/** + * gicv5_domain_implemented: Return true if this IRS implements this domain + * @s: GIC object + * @domain: domain to check + */ +static inline bool gicv5_domain_implemented(GICv5Common *cs, GICv5Domain d= omain) +{ + return cs->implemented_domains & (1 << domain); +} + #endif diff --git a/include/hw/intc/arm_gicv5_types.h b/include/hw/intc/arm_gicv5_= types.h new file mode 100644 index 0000000000..49dc1d6e95 --- /dev/null +++ b/include/hw/intc/arm_gicv5_types.h @@ -0,0 +1,28 @@ +/* + * Type definitions for GICv5 + * + * This file is for type definitions that we want to share between + * the GIC proper and the CPU interface. + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_INTC_ARM_GICv5_TYPES_H +#define HW_INTC_ARM_GICv5_TYPES_H + +/* + * The GICv5 has four physical Interrupt Domains. This numbering must + * match the encoding used in IRS_IDR0.INT_DOM. + */ +typedef enum GICv5Domain { + GICV5_ID_S =3D 0, + GICV5_ID_NS =3D 1, + GICV5_ID_EL3 =3D 2, + GICV5_ID_REALM =3D 3, +} GICv5Domain; + +#define NUM_GICV5_DOMAINS 4 + +#endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169518; cv=none; d=zohomail.com; s=zohoarc; b=cK0Slo0WzWzHr1cTOWFmh0vrVXY42mr/zDG3vU41UMw7+rwceUfXvk4JC4PS2x04M9Kq4dBWP8qdGUO569msiBWFryTjWScj1pRx+RaWZ4ymCucG5OcxdGP4OV3unjsCFHgYDtXxAGKgMYTBhgqxM6RM+NXlP7mtdxUExOq5G28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169518; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Wbux916U6XlS/bYu86AQohdEy9iAPtgneA9MemaZ2OA=; b=gczvVioyFAYlEXlS8Z5Cb4vK4SRb609/sImhxcN1b5t2HuZnaoQvtmbhGCCsBYFeOETkHqIZDcI2fi4FbfnP/D4LJHJg6qdDZvVI0GLo4oW/lv/z625ImVUGlDPL08p4D6wKgdos3bqmW/2aAfr/2R2U9M1yIpnT9XEdan5ygvE= 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 1778169518350487.0524557348714; Thu, 7 May 2026 08:58:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11K-0003UX-Ml; Thu, 07 May 2026 11:52:14 -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 1wL11B-0003PB-Vw for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:06 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wL11A-0003lv-2E for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:05 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-43d75312379so1493606f8f.1 for ; Thu, 07 May 2026 08:52:02 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169121; x=1778773921; 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; bh=Wbux916U6XlS/bYu86AQohdEy9iAPtgneA9MemaZ2OA=; b=SxgF5OUIo/4aLV2rPtBCAvXS/6WAKf2BU7fUX0IvX6TBRU96Rt65yfU44BUvQhaZOG OEeDa5c+L4R2HusHg+fd4MwPMZRAJnH0MuwSXWg7tO+WnrTGaLH0VVn1f0XpZDVX7Tm6 2OixwbyKoM6E1z1caZbXmcIMvfnkmhzpBoInLwieI3/vSfG9WBCIFG/JY2y1tHWkkd/H 70UtorovzlXaQnTs55qstEf8CUDlROFrI2auBxiEsryE4hJFKl50BYXGKGzLoBQosW82 MvuEHx5SLCaW6KV53mnX+9X8s0mAKqSzYhUAqkejka8Esa33kxvC3WcBM6mxXFj7aSSq azWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169121; x=1778773921; 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; bh=Wbux916U6XlS/bYu86AQohdEy9iAPtgneA9MemaZ2OA=; b=b/9ibFLjKeXFlnWB8HdBbtNQLWz4JaDVV8JdHC6T0sed+wolcEAqpLRWudaighcSlF AiMYZFD4jFojElCX4or3nH6Nnk+5fKmlUhgb8hmYri9VzrpKFGDheVDyXCnoYqC2w85l 1rOlHT6LqBVYdKK/6+O54NOV0pfJVs0APnLZjBNO4lkEdMq2LG+4ebRCs2pJuxm/MvB9 ly1MKGIILW/qO3qSTDowmZ+YWD3jU92QW+sRBxxTJTFsgIbljyJoWIWCAXfRC3SbJnZP Q0ifkWgaIMGzxBdjPQyPk0j9aK35zZVdOk25PsfrY+5bay70V71b2a5SV9qIWDu8o1lo D6rg== X-Gm-Message-State: AOJu0Yy2CqmlbYuN1kz84UG7vqch9CRn8rbP6sZDuu94m6v2YJ1R/bZM FAkBwhuFY3kq0S3mK56WEGTU3TLWMCq86eKFDBib9xyn8rilDe+GZiWozOP5Koe5Z8JAjc3mIq1 gb20R X-Gm-Gg: AeBDieur4m25R8Pk1pPRaO1EKGBOJ2WVfJL2j0+vGdj0yYs5NDVnZe1NMIWfq+qEfN0 BblfuQmdS1/pEQotxh5KiIjCKrjXrL0i070gxsu0pNagGMt9FuBqFdETYuaJpWndH8U/AOKY3Q+ ClWvjuXxgqNh6ooU5PXdtFuKraZOMTGz/t70zf9p74N7CuKxNgypf3bAYwRh/qF+yJNmOF0B+sJ Z23Y5rwbt3b8YQdUf+jrtHTQbp28/UreOY/vegnJbTIU2ATgNiMjb68CFo5jXH240jdK+qJLx4H IuqMmfjg8pucq0sDdMjlwfmcMfwRab2jr9XK+p2WmXttH3Es2i4r8yQUpB5FeL119RNHXjq0JY0 yzhNNPS1aa/gVM2J9V9KftcRNLKaxrrXYemOwh3GguYrITujLqfRpbhVHmGLQUOnceSW5hXhoqI eak0XxGd+wLMN8TIWaOIdKx3lfvQtt82Mg3UIcIiw46OQNUjz8jG60LBrLT8mvQKAJJ7mV2fUld dIsUA7efTJAvlzp4jJtiBQeQWje1Q7bre7phIPhpA== X-Received: by 2002:a05:600c:4f08:b0:48a:79d8:a8d6 with SMTP id 5b1f17b1804b1-48e6391c7e4mr5238075e9.7.1778169121313; Thu, 07 May 2026 08:52:01 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/67] hw/intc/arm_gicv5: Add migration blocker Date: Thu, 7 May 2026 16:50:53 +0100 Message-ID: <20260507155154.1886557-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.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: 1778169518955158500 Content-Type: text/plain; charset="utf-8" This initial version of the GICv5 will not support migration: * the spec is still only at EAC level, so the data to be migrated might in theory change before it is finalised * when we add support for missing features like EL2/EL3/Realm we might find we want to refactor the data structures we use * I still need to check against the proposed KVM GICv5 handling to see if there are any awkward mismatches that might affect how we want to store the data * it's experimental, so for pragmatic reasons I'm skipping it to get the initial version done faster Install a migration blocker to enforce this. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-7-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 3a9d566924..64bec16bdd 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -11,6 +11,7 @@ #include "qapi/error.h" #include "qemu/log.h" #include "trace.h" +#include "migration/blocker.h" =20 OBJECT_DEFINE_TYPE(GICv5, gicv5, ARM_GICV5, ARM_GICV5_COMMON) =20 @@ -173,6 +174,7 @@ static void gicv5_realize(DeviceState *dev, Error **err= p) { GICv5Common *cs =3D ARM_GICV5_COMMON(dev); GICv5Class *gc =3D ARM_GICV5_GET_CLASS(dev); + Error *migration_blocker =3D NULL; =20 ERRP_GUARD(); =20 @@ -181,6 +183,12 @@ static void gicv5_realize(DeviceState *dev, Error **er= rp) return; } =20 + error_setg(&migration_blocker, + "Live migration disabled: not yet supported by GICv5"); + if (migrate_add_blocker(&migration_blocker, errp)) { + return; + } + /* * When we implement support for more than one interrupt domain, * we will provide some QOM properties so the board can configure --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169506; cv=none; d=zohomail.com; s=zohoarc; b=VjYSnyC275BZwYF2Btd2atN5ybF+gK8u4VvhkAeEaUqciXx2kWIDCehbsNod5AOFbraD8M7ICBIeG1dOcnedervDcH6Stnbsw8kmKavelJ/+hY/fg0jWVBlbs6Zx2dAYgXoMYb6pIvxNaNyiAtu9KzKyLrLM8yQZWp+Pg1GK3yg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169506; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=HNhbXIYLPE3i7rsLfY3jqFMqXJBOaSPo/Us5CC4uauU=; b=N7bHiAdHTEP7JtmeH5EdN1SAIXqa1EOB0A9FcjsaX7g4nkLNCsmC+XB0vUvV6WSBjOUPnoEIzK1wLmZG0TsL85WCSoVfbl6uolO0OnD8SfEm/GSsn5i28MgX+oQApaGRQW93jdDoxBgkxBqeV2bj98y1/I6iE4UNqMv6XlOA3/c= 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 177816950697594.2018755941009; Thu, 7 May 2026 08:58:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11L-0003VA-Mx; Thu, 07 May 2026 11:52: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 1wL11C-0003PC-2t for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:06 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wL11A-0003ma-2Q for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:05 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-488b0046078so8991245e9.1 for ; Thu, 07 May 2026 08:52:03 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169122; x=1778773922; 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; bh=HNhbXIYLPE3i7rsLfY3jqFMqXJBOaSPo/Us5CC4uauU=; b=EE9m49gIXScxwPvuHE2kHbERoHl/+iExOc6MpXsxVyjE0LAHMHNrQNowAtnLwPdU7F U7Xm4DwbHQ92pRFTJQfcbAy2+WLVb1Paqx693A5+qibRUGvvotQmcUUV1ZBKGT2ggL9I TiobCW67g6rfEEwcdZj6811n+jJ5pyGUVH7hMND3aWHHiZBalKZ2EcmN6X4KioDogu9M tatTwSh6DcqEaTuzeBgOqCM0kcM+R86oF7k97T0HFWoEa2jVUOOihBWhjPfRyjgB9JIN Di87AsZ3NnZIVgXIwgIGZ43MLyJf6xF/j1LlnCK5V0m4GTy0eU2ojqen7GNGJF2g4lKW GHnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169122; x=1778773922; 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; bh=HNhbXIYLPE3i7rsLfY3jqFMqXJBOaSPo/Us5CC4uauU=; b=s3iVRhEvqzl6XoN6iu+YFsQD4QlbAWz2yadBijqlKIHc4iJL5A/eGsbqyRiEq0+BaJ Cgb0O1b6T4jRRTg+1tyvKYeFH32DkRc3F4Q3JTGaX4t+a6csc6sr6f313O2zR3WUzKYV KUYVsSpC8fn+51j0hwgNcv33R3fxdmEXiuIICW7tbH5sRGzZ4C4Q3/HDb7Kgxs0Rbebz KiX88c5xfwmuy61kwjB3k6Zm/kQP4jTNkZfPFRpPpuY/yMkGL4Q39ehibEfwjj3dVV6U KUQr4hMduMRgEV0tz0ZcsNOzAfSi6HI/XITTkxdpVqmWUzy0N41YeBy9zPhref6IBg1Y KB3Q== X-Gm-Message-State: AOJu0YwDzRip6peJSwkWxwVUCwRakdkkgHxjrg57Z9yRfhUUZ9/jvW03 hq2WW45rsECcznft+Gfc/QzOVbOt+eU5uGnOGmLO0bxN0C0wXga3GpxAX0aoUi/2ZHIPoxAdIDq nohbj X-Gm-Gg: AeBDievqQl+gfj6btj7bIk4tCQZ1OZWMztLLPz2k4nwGBZLReJtx9Rw2HvboW4GHc7z TGkNckLDXJ569mXuoiS5WbEo1galSzdSiX24w9TuUDGNwh+1181L+bdPGQtnFQOUf6aKBulHw4B 0I6iru5U+lFlc4w2qwGYHNmyVApUGg8RHP/M30Kv874hMr8lAzJUSq9fPDv33MFQs6H4mNFqqqd lqHfAqdfhuRIx1b9YG7+FdHEH5tvXjCvYWPF8Ju5V2W6Uv1ZbD4/XAkxda+BOzWMsws+vk9hweC xY5HoBWxptqCHuZTiBBCYb1io+4hbtyksJIKviNkbDEXiefIdYrMCN0lv+VyQ/iqdcChDtr5VdH CxeRDUYteLUKq70hb7UVSJhSAFdhTpsl3g47LLVdvm0+OsqlZisPS6hgtNZOb98CSaZtcm1xphM vAXdMqvhGnY8NVwHD8EiIBwDz5OnDEv3huE8jAEQLNmUApwpa04Z4YA1MGw62p2/RAZrY2rO8U4 yu8P0nyDmt1JCpYNAF2S0g8WD7fInefSx/+IagxEg== X-Received: by 2002:a05:600c:3f0b:b0:48a:6fd4:d3d3 with SMTP id 5b1f17b1804b1-48e51f37fb8mr173105635e9.20.1778169122200; Thu, 07 May 2026 08:52:02 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/67] hw/intc/arm_gicv5: Create and validate QOM properties Date: Thu, 7 May 2026 16:50:54 +0100 Message-ID: <20260507155154.1886557-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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: 1778169508993154100 Add code to the GICv5 skeleton which creates the QOM properties which the board or SoC can use to configure the GIC, and the validation code to check they are in range. Generally these correspond to fields in the IRS ID registers, and the properties are named correspondingly. Notable here is that unlike the GICv3 (which assumes its connected CPUs are the system's CPUs starting from 0), we define a QOM array property which is an array of pointers to the CPUs, and a QOM array property which is an array of integers telling the GIC what the IAFFID (interrupt affinity ID) for each CPU is; so a board or SoC which wants to connect multiple CPUs to this GICv5 would do something like: QList *cpulist =3D qlist_new(), *iaffidlist =3D qlist_new(); for (int i =3D 0; i < ms->smp.cpus; i++) { qlist_append_link(cpulist, OBJECT(qemu_get_cpu(i))); qlist_append_int(iaffidlist, i); } qdev_prop_set_array(vms->gic, "cpus", cpulist); qdev_prop_set_array(vms->gic, "cpu-iaffids", iaffidlist); Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-8-peter.maydell@linaro.org --- hw/intc/arm_gicv5_common.c | 80 ++++++++++++++++++++++++++++++ hw/intc/trace-events | 3 ++ include/hw/intc/arm_gicv5_common.h | 25 ++++++++++ 3 files changed, 108 insertions(+) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index bf990bfa54..3448734686 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -8,9 +8,15 @@ =20 #include "qemu/osdep.h" #include "hw/intc/arm_gicv5_common.h" +#include "hw/core/qdev-properties.h" +#include "qapi/error.h" +#include "trace.h" =20 OBJECT_DEFINE_ABSTRACT_TYPE(GICv5Common, gicv5_common, ARM_GICV5_COMMON, S= YS_BUS_DEVICE) =20 +/* Any value > 2^24 is out of the valid range for this property */ +#define GICV5_SPI_IRS_RANGE_NOT_SET 0xffffffff + static bool bad_frame_accepts(void *opaque, hwaddr addr, unsigned size, bool is_write, MemTxAttrs attrs) { @@ -58,9 +64,83 @@ static void gicv5_common_finalize(Object *obj) { } =20 +static void gicv5_common_realize(DeviceState *dev, Error **errp) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(dev); + + if (cs->num_cpus =3D=3D 0) { + error_setg(errp, "The cpus array property must have at least one C= PU"); + return; + } + if (cs->num_cpus >=3D (1 << 16)) { + /* We'll hit other QEMU limits long before this one :-) */ + error_setg(errp, "Number of CPUs exceeds GICv5 architectural maxim= um"); + return; + } + if (cs->num_cpus !=3D cs->num_cpu_iaffids) { + error_setg(errp, "The cpu-iaffids array property must be the same = size " + "as the cpus array property"); + return; + } + if (cs->irsid >=3D (1 << 16)) { + error_setg(errp, "irsid (%u) is more than 2^16-1", cs->irsid); + return; + } + if (cs->spi_range > (1 << 24)) { + /* + * Note that IRS_IDR5.SPI_RANGE is a 25 bit field but the largest + * architecturally permitted value is 2^24 (not 2^25-1), hence + * use of > in the range check. + */ + error_setg(errp, "spi-range (%u) is more than 2^24", cs->spi_range= ); + return; + } + if (cs->spi_irs_range =3D=3D GICV5_SPI_IRS_RANGE_NOT_SET) { + /* spi-irs-range defaults to same as spi-range */ + cs->spi_irs_range =3D cs->spi_range; + } + if (cs->spi_irs_range > (1 << 24)) { + /* Similarly IRS_IDR6.SPI_IRS_RANGE */ + error_setg(errp, "spi-irs-range (%u) is more than 2^24", + cs->spi_irs_range); + return; + } + if (cs->spi_base >=3D (1 << 24)) { + /* IRS_IDR7.SPI_BASE is a 24-bit field, so range check is >=3D */ + error_setg(errp, "spi-base (%u) is more than 2^24-1", cs->spi_base= ); + return; + } + /* range checks above mean we know this addition won't overflow */ + if (cs->spi_base + cs->spi_irs_range > cs->spi_range) { + error_setg(errp, "spi-base (%u) + spi-irs-range (%u) is " + "more than spi-range (%u)", + cs->spi_base, cs->spi_irs_range, cs->spi_range); + return; + } + + trace_gicv5_common_realize(cs->irsid, cs->num_cpus, + cs->spi_base, cs->spi_irs_range, cs->spi_ra= nge); +} + +static const Property arm_gicv5_common_properties[] =3D { + DEFINE_PROP_LINK_ARRAY("cpus", GICv5Common, num_cpus, + cpus, TYPE_ARM_CPU, ARMCPU *), + DEFINE_PROP_ARRAY("cpu-iaffids", GICv5Common, num_cpu_iaffids, + cpu_iaffids, qdev_prop_uint32, uint32_t), + DEFINE_PROP_UINT32("irsid", GICv5Common, irsid, 0), + DEFINE_PROP_UINT32("spi-range", GICv5Common, spi_range, 0), + DEFINE_PROP_UINT32("spi-base", GICv5Common, spi_base, 0), + DEFINE_PROP_UINT32("spi-irs-range", GICv5Common, spi_irs_range, + GICV5_SPI_IRS_RANGE_NOT_SET), +}; + static void gicv5_common_class_init(ObjectClass *oc, const void *data) { ResettableClass *rc =3D RESETTABLE_CLASS(oc); + DeviceClass *dc =3D DEVICE_CLASS(oc); =20 rc->phases.hold =3D gicv5_common_reset_hold; + + dc->realize =3D gicv5_common_realize; + device_class_set_props(dc, arm_gicv5_common_properties); } diff --git a/hw/intc/trace-events b/hw/intc/trace-events index edd3c49c5f..54777f6da3 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -233,6 +233,9 @@ gicv5_badread(const char *domain, uint64_t offset, unsi= gned size) "GICv5 IRS %s gicv5_write(const char *domain, uint64_t offset, uint64_t data, unsigned s= ize) "GICv5 IRS %s config frame write: offset 0x%" PRIx64 " data 0x%" PRIx6= 4 " size %u" gicv5_badwrite(const char *domain, uint64_t offset, uint64_t data, unsigne= d size) "GICv5 IRS %s config frame write: offset 0x%" PRIx64 " data 0x%" PR= Ix64 " size %u: error" =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" + # armv7m_nvic.c nvic_recompute_state(int vectpending, int vectpending_prio, int exception_= prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_= prio %d" nvic_recompute_state_secure(int vectpending, bool vectpending_is_s_banked,= int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpend= ing %d is_s_banked %d vectpending_prio %d exception_prio %d" diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index b7a17aac31..ea01b2a1db 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -12,10 +12,24 @@ #include "qom/object.h" #include "hw/core/sysbus.h" #include "hw/intc/arm_gicv5_types.h" +#include "target/arm/cpu-qom.h" =20 /* * QEMU interface: * + * + QOM array property "cpus": CPUState pointers to each CPU + * connected to this IRS. + * + QOM array property "cpu-iaffids": array of uint32_t giving the + * IAFFID for each CPU in the "cpus" property array + * + QOM property "irsid": unique identifier for this IRS in the system + * (this is IRS_IDR0.IRSID); default is 0 + * + QOM property "spi-range": total number of SPIs in the system + * IRS (this is IRS_IDR5.SPI_RANGE); must be set + * + QOM property "spi-base": minimum SPI INTID.ID implemented on this + * IRS (this is IRS_IDR7.SPI_BASE); default is 0 + * + QOM property "spi-irs-range": number of SPI INTID.ID managed on this + * IRS (this is IRS_IDR6.SPI_IRS_RANGE); defaults to value of spi-range + * * sysbus MMIO regions (in order matching IRS_IDR0.INT_DOM encoding): * - IRS config frame for the Secure Interrupt Domain * - IRS config frame for the Non-secure Interrupt Domain @@ -47,6 +61,17 @@ struct GICv5Common { =20 /* Bits here are set for each physical interrupt domain implemented */ uint8_t implemented_domains; + + /* Properties */ + uint32_t num_cpus; + ARMCPU **cpus; + uint32_t num_cpu_iaffids; + uint32_t *cpu_iaffids; + + uint32_t irsid; + uint32_t spi_base; + uint32_t spi_irs_range; + uint32_t spi_range; }; =20 struct GICv5CommonClass { --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169406; cv=none; d=zohomail.com; s=zohoarc; b=lpbNdQGLk9ppge/cwwfhJYvqWMxY1Ck13u0x9YR3XXWBQtXcWruH3/m4vPP5JvTDLADgdV5Kbr4hNna49qhqafVvDCg0h3X9vNhT8vRqkVoM4tQNuwlMBonHhvdhB3rSOpsDhM/ooAnbiYEhuqu+VRXjBx1g0ioDimkmSdSpflc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169406; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Cyw1iu3/HzLXP/SQwUPO0JA2XKkIV3045uDKDgmS9PY=; b=VLh8VWnOQoYg4yJTi/TT5SlPFstGkenrLQtqS0MwcpSTCKoO53qJUnG838gJUqh/k4oFtKlPVtb7v9InwrZpbFSdGK5XhWhwv8hHPdBDuwuIEHXXtE4drRedxdtqFV5bh7VmSp2sLeyfDow7lybi+B04diTrYEwDJu3QESnhvdw= 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 1778169406083474.7015627130638; Thu, 7 May 2026 08:56:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11H-0003SP-DL; Thu, 07 May 2026 11:52: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 1wL11C-0003PP-Rd for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:08 -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 1wL11A-0003nM-UC for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:06 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-488af96f6b2so12017605e9.0 for ; Thu, 07 May 2026 08:52:04 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169123; x=1778773923; 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; bh=Cyw1iu3/HzLXP/SQwUPO0JA2XKkIV3045uDKDgmS9PY=; b=HRLzbezszKfrZfqlppxFqAghmeCZg2vfpF2IlVq6D/x9h+dLXxDIQk9Ik4jqkklJEs Gq57l2CLxjRKoX/VsUeEjg1utQwGtBWoLHCYHIiJWFhg7ZAKXc2tEP0O1GPLU7EzKZ3P xph5/aBdm3/kaJRLv1Ef2X/K42fKB4zo7EK6/4MpgzWlxKsOIEbNrSZSJ9dgc1LnYFit ZaA8DUf0QGbUVmOvT5k8LdODVmqF4gvrxPnQmy/d8dH0IcI3OBIujvnzBeOydWX0vQq8 D1t1d85uT7PS2dMwecicRuAweIqMtA+iBHAc/7hfmqZFKN5fZ9nl17jFgP5REFKzM6Gm pfsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169123; x=1778773923; 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; bh=Cyw1iu3/HzLXP/SQwUPO0JA2XKkIV3045uDKDgmS9PY=; b=dHiM4ceQnyS3tK7s146l3UyhHPPWxrk/B7bU3HvdQfPLpTfocUpl1TkRogpD9VHwae unFkELtaM/mpzgIeZG93a4l/CVhnrXNNVfM02wn9evuLCN5ffDaupeVI11Zp5ZpJtff8 rAErZ0k2dVHakQqHVWyB4C/mAKBBjKyXGvw6qp8ydWLReAPfy9jm3fZvvN8Qfbhku+Nh y+zMpGnXOU03EzAWFGifGGk4rD9GJePDPQ7czBUVT7BGpBwudc4IVjwxsZ39Aw5chwvl ZUpvGy+wdsTeueh1Ac/RaUQhv1kwGXvhIXrxrijP+I3XJ6MGBcjc2YlL9IY/KREOaBr8 MdlQ== X-Gm-Message-State: AOJu0Yzz73YSPkFJBDU2Ia1espgCcUVITgXx/GK6lNUZyRE5a9anxS3S iHDwKTclzgbI+J1GCt+eQa7SK4JvJ7+NEzlTUyj+6SioDx2W6tx9tw8YophF7uyRH4suIAd2AWe j/qNT X-Gm-Gg: AeBDiev/LgTqqf2tIJaf1/pza5rt0JIP6am5wINmqbs0VCWK0ApoUixZAGCJf8FBSOq HfmEkV4oAWCR1KmyHzmYY7gb2/M5u9XROnZSvuCknOmXWreTuc+hPE2s9R5zV7tkyaXBwZ90B86 tG5EkniBjzlhStyeX2FjNWGRoPGCG57NYpU021npzEtBDQ+qsUZmKnDQJeC9a75v1QUmB7m0fAB EPknhYm+TwgIfU3cjSCEQTIYK1/zhDBfi+2Lb+7cZvxiZqS4Uhn23aX+E/4mOQgghckYmQWq/mJ gQ8OgkpYgEyxZzrokAYGC/cUm/OQsG9V7PwMBJePuVrxxcqlzLxH0RasAWjxFncjMlJPnf2k4W9 L7S8p/TJ3aQIikQPQmgfPaRC4+4LV/VNKK9ATYOA2/ZVPmJbbPSqM1Huj/4KkY/K7//6foz7dym S9VHTyh0IAJk4JKUpRrHC4DcC+8zIIug2yIy1Htu9LTxMJ+wYrbjbYjWgIybrzJrx7uGI46Av34 zaSlQh6nY2XHBsgCnMWFKk3hFyrgOs= X-Received: by 2002:a05:600c:871b:b0:483:709e:f238 with SMTP id 5b1f17b1804b1-48e51f4652fmr145322275e9.29.1778169123079; Thu, 07 May 2026 08:52:03 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/67] hw/intc/arm_gicv5: Create inbound GPIO lines for SPIs Date: Thu, 7 May 2026 16:50:55 +0100 Message-ID: <20260507155154.1886557-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169409386154100 The GICv5 IRS may have inbound GPIO lines corresponding to SPIs (shared peripheral interrupts). Unlike the GICv3, it does not deal with PPIs (private peripheral interrupts, i.e. per-CPU interrupts): in a GICv5 system those are handled entirely within the CPU interface. The inbound GPIO array is therefore a simple sequence of one GPIO per SPI that this IRS handles. Create the GPIO input array in gicv5_common_init_irqs_and_mmio(). Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-9-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 11 ++++++++++- hw/intc/arm_gicv5_common.c | 5 +++++ hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_common.h | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 64bec16bdd..cb1234b022 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -160,6 +160,15 @@ static const MemoryRegionOps config_frame_ops[NUM_GICV= 5_DOMAINS] =3D { FRAME_OP_ENTRY(el3, GICV5_ID_EL3), }; =20 +static void gicv5_set_spi(void *opaque, int irq, int level) +{ + /* These irqs are all SPIs; the INTID is irq + s->spi_base */ + GICv5Common *cs =3D ARM_GICV5_COMMON(opaque); + uint32_t spi_id =3D irq + cs->spi_base; + + trace_gicv5_spi(spi_id, level); +} + static void gicv5_reset_hold(Object *obj, ResetType type) { GICv5 *s =3D ARM_GICV5(obj); @@ -196,7 +205,7 @@ static void gicv5_realize(DeviceState *dev, Error **err= p) * NS domain. */ cs->implemented_domains =3D (1 << GICV5_ID_NS); - gicv5_common_init_irqs_and_mmio(cs, config_frame_ops); + gicv5_common_init_irqs_and_mmio(cs, gicv5_set_spi, config_frame_ops); } =20 static void gicv5_init(Object *obj) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 3448734686..b58913b970 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -38,10 +38,15 @@ static const MemoryRegionOps bad_frame_ops =3D { }; =20 void gicv5_common_init_irqs_and_mmio(GICv5Common *cs, + qemu_irq_handler handler, const MemoryRegionOps config_ops[NUM_= GICV5_DOMAINS]) { SysBusDevice *sbd =3D SYS_BUS_DEVICE(cs); =20 + if (cs->spi_irs_range) { + qdev_init_gpio_in(DEVICE(cs), handler, cs->spi_irs_range); + } + for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { g_autofree char *memname =3D g_strdup_printf("gicv5-irs-%d", i); const MemoryRegionOps *ops =3D gicv5_domain_implemented(cs, i) ? diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 54777f6da3..0797a23c1a 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -232,6 +232,7 @@ gicv5_read(const char *domain, uint64_t offset, uint64_= t data, unsigned size) "G gicv5_badread(const char *domain, uint64_t offset, unsigned size) "GICv5 I= RS %s config frame read: offset 0x%" PRIx64 " size %u: error" gicv5_write(const char *domain, uint64_t offset, uint64_t data, unsigned s= ize) "GICv5 IRS %s config frame write: offset 0x%" PRIx64 " data 0x%" PRIx6= 4 " size %u" gicv5_badwrite(const char *domain, uint64_t offset, uint64_t data, unsigne= d size) "GICv5 IRS %s config frame write: offset 0x%" PRIx64 " data 0x%" PR= Ix64 " size %u: error" +gicv5_spi(uint32_t id, int level) "GICv5 SPI ID %u asserted at level %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_common.h b/include/hw/intc/arm_gicv5= _common.h index ea01b2a1db..10276d652f 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -29,6 +29,9 @@ * IRS (this is IRS_IDR7.SPI_BASE); default is 0 * + QOM property "spi-irs-range": number of SPI INTID.ID managed on this * IRS (this is IRS_IDR6.SPI_IRS_RANGE); defaults to value of spi-range + * + unnamed GPIO inputs: the SPIs handled by this IRS + * (so GPIO input 0 is the SPI with INTID SPI_BASE, input 1 is + * SPI_BASE + 1, and so on up to SPI_BASE + SPI_IRS_RANGE - 1) * * sysbus MMIO regions (in order matching IRS_IDR0.INT_DOM encoding): * - IRS config frame for the Secure Interrupt Domain @@ -91,6 +94,7 @@ struct GICv5CommonClass { * of MemoryRegionOps structs. */ void gicv5_common_init_irqs_and_mmio(GICv5Common *cs, + qemu_irq_handler handler, const MemoryRegionOps ops[NUM_GICV5_D= OMAINS]); =20 /** --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169382; cv=none; d=zohomail.com; s=zohoarc; b=eVCCYlvLGBOobx/LOOecTDDR7CB5OjfRNgZCASB8u5sX1h1cwDgM65v+dYTepPqC+ccIfWaBmMNfoTDavPQ3deCygEpN7MN8HBLjzYKjuSjzD2C/1vJwhAzKCdgj6NLIau3b12oIOhXEFkKTA59O/Bqa3eqrUtEmHmpKxHk7Xyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169382; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=f9UK8LE8by81vh/f0Bm2hrpvxUssUFOgKHfpWwUdTS4=; b=Lt3RdxNvxt1ukf1t7SvhlzYbLWU+lkqY5vNP6NTgqC/Uc4xmsKXKn0g3fZdCXrLnC9McZo8bvhCVcOGD5oio+4HdbLcoHNj3TT4GpWxBInVwuGY+AfOmyoAJxfQMczgHYE4RmVbVkCcGpNNnSUQsb8TSUPPs2zIX8/NTNU+94E4= 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 1778169382684921.6168478709549; Thu, 7 May 2026 08:56:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11H-0003SL-4J; Thu, 07 May 2026 11:52: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 1wL11E-0003Qw-TA for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:08 -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 1wL11B-0003nf-Tc for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:08 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-48984d29fe3so12821075e9.0 for ; Thu, 07 May 2026 08:52:05 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169124; x=1778773924; 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; bh=f9UK8LE8by81vh/f0Bm2hrpvxUssUFOgKHfpWwUdTS4=; b=w9Wfk4IxB8ACbEIpAiCiE2aTvdLEWDXFB/LuErbhFER8jkBHYFgg3rFrURbAwnJPQb UlRIIP99cdDGrHcbmUGut1K7RAo2FsdpXsFnPMJrONqpAg8ega1o10ejpXG8qGovA8W8 V+pOLi+M42N4aAKCs/IdFYKhWDWZiDFhBYNoBD5Tjrvgt5gJy3qjMTpRnCmpppvTK3zY 1XX5Cbn3HhS83Evnzz5lPiFhcKcvXOt8pqysfuOFalsowpxtTBuSGr/woqnzxZ9Ov+dN 3Rjn+Aw9tmBi+L6Zh0ZA7kFCnMb4X+bFKbge4bVFcduekz+TbaagxYBkQrhFKoIVM1r0 7fZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169124; x=1778773924; 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; bh=f9UK8LE8by81vh/f0Bm2hrpvxUssUFOgKHfpWwUdTS4=; b=l+mvZHoZ7EhjLbQgCTnlmlLpkEartQJoBv/GGbk+AM3xu3FInC0UV/1aXrg9NUyoM6 pz5+7Y+ELplnPBh3/kG5WUzvGeXEbGKHxME30/TBRFaIYzXCRazUXvhPByxhpss82Evj CBRWQtYlarwvLDtJZaAcgpHv1xityoR/hQzpkSRDoYKz+s0u7i8CJ9Y1vSLzc2LEIPwT ExYa6cKC96iVkKoKMn0gR4M7UqY003OpG9F01VkAYYUU0Xb3xknt6RFexoLXO2JzKuyg oGZnAH2MFEKc7ahfYmc07OjfQMzbn8swulFO4L8AxAEIuKxjFx2ZyPPcGskNhG+Ot4Tw 4hVw== X-Gm-Message-State: AOJu0Yzliam/7ySVQ0AzP4wVDZ6l8JCFk2oHOkFz9z7IYWytNOZE0/+8 aBFY/uVrTG+Hqd1UiM2eeByrIFliaUUL0lQu2Ur5p4bZSlBM+pYelBy+wY4IaZWRjn4l3/ihUOJ Q8SrM X-Gm-Gg: AeBDietMwelJykg1j2Cbk9eVjFJJoqvg4FOcVh3/QpOTxG5Zc8wf3E6wDz2cQjFqhEg 1NDaWCDjzMIAWvlEKiVk9ejyd2jU7Zd6l8oz5GfxwNddmbaN3eUsLl55EDmyB41iT3/KMR1YyMz PjYRpsWlhUK2eRNHVj5XUmayLoFgBPdiDvmwIR1/6AG6SjUxXf47Ni3uD42hdKA7tgv5HBnMYTg FxFo3eqAVzff9dwvUikwXc56EIuXFgpkKtY7dK8CRGzJI51/a5uG14NkMV6P01DuVQly/3NJ2B4 AAEXkkmaSO2g8jiKUr79MIj4Olc8cCZpLE9OIDBQSNpG+CM2cQaecPR+ePipf1IZOugCy7UgQqj HMSKDKY6phkHE0j5KmxZYnyk1TtPlWDl82i2ZoKqP9BtNQHzhhSyfrIlA6EBnpj3Pdr4CUkjZLJ Dszm+fpaRVKgakXYnfeM+69Vc4hMLQBVule/XXrikq8X06EQIMGQgQGrSoJNMZGiD4t240bFS3o n9htbTLT3hiOv+bI1+2yf9IeI278PzWQB2C+bY8hw== X-Received: by 2002:a05:600c:1d18:b0:489:1a63:509c with SMTP id 5b1f17b1804b1-48e51dd689fmr134256545e9.0.1778169123988; Thu, 07 May 2026 08:52:03 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/67] hw/intc/arm_gicv5: Define macros for config frame registers Date: Thu, 7 May 2026 16:50:56 +0100 Message-ID: <20260507155154.1886557-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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, 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: 1778169384304158501 Content-Type: text/plain; charset="utf-8" Define constants for the various registers in the IRS config frame using the REG and FIELD macros. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-10-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 243 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index cb1234b022..4c1ec8f30a 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -7,6 +7,7 @@ */ =20 #include "qemu/osdep.h" +#include "hw/core/registerfields.h" #include "hw/intc/arm_gicv5.h" #include "qapi/error.h" #include "qemu/log.h" @@ -22,6 +23,248 @@ static const char *domain_name[] =3D { [GICV5_ID_REALM] =3D "Realm", }; =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) + static bool config_readl(GICv5 *s, GICv5Domain domain, hwaddr offset, uint64_t *data, MemTxAttrs attrs) { --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169171; cv=none; d=zohomail.com; s=zohoarc; b=VnAlXVk/IqlD7bibkI4yu3yjyYaWpoyY9HoniclbtcG2qWEowgAlXhWjd6+20fNtvc0IGAqXyK+7PyZZi2bGDjrZ/5d53nIor43OfwQ+rmVCbVgpnwdrgz6ihIE1Be/KBU4g/m9YdNu4cEPY8GMi/9xHiuU6yj4zHku2XZenJdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169171; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Qf1DrmdeUL5WS//Blvpc/pWWw3ADDfnrndB1PljHxgM=; b=A+byVBuoet+7eJydah16zgPBN0y9JFl2M0UataNnHj5IoSmr2KFT+43jUoKOEtTuH84goPmUHA44w/yCkxAQAioIORlxFOUA7rfynsrgo+wXneCvUwoPSkl5JItCR/KGF64VCpOF1tseFGwuLdCZ/vb1DrqUrXGssp7kqHM97jo= 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 1778169171276962.1288005170952; Thu, 7 May 2026 08:52:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11M-0003VB-0A; Thu, 07 May 2026 11:52: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 1wL11G-0003S2-OY for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52: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 1wL11D-0003nt-Os for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:10 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-488ab2db91aso11857095e9.3 for ; Thu, 07 May 2026 08:52:06 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169125; x=1778773925; 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; bh=Qf1DrmdeUL5WS//Blvpc/pWWw3ADDfnrndB1PljHxgM=; b=Qkn//XsNNxehx/fIvJCIsQ7Q1qG66pPP2zT6aw8CQ3q8dLsnkYM1AFaHk8TSF/3lVE odQa2IrdVMv8hUu8tzLE/k/boASXdGyVDjEVuGruth1OQRmZVKeNEp75J3T+XsOzeL+E 1G+gVEK9sq7fInpUz1S5XwQyj0ddhJiYVHao3Y5Fkn+y/dUibLP5cS+mYwZF35o4kVLC g6vv4/BoETzKBiivBMN8Qmd/ddzDtmDVr47t2Dxh0nKOYLp2lg5iZWQOLa3Cix8Sjwvd br1HG9cVZKbyX8FgktuJhq6awVD1HhehhgEw5zZ/3T/Nx2otlXBCWAIEctlIVg2Zxc3e dUOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169125; x=1778773925; 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; bh=Qf1DrmdeUL5WS//Blvpc/pWWw3ADDfnrndB1PljHxgM=; b=ijbGtlY9PyLlnasg0YoVSFdwq8/IiUdqBSHWy7Lksq5GkvOe3ZrWmZfZ8dmMDIg8+C tC3SArxxlENpMpDS61P3RbJg9Zl1m65OwSy57qdMspz8s6rA39YUzWOcz40VXWMb+UFv h5NPh4bGUS8Q1RKfrIbbSwpN4E7sRckGtRWi+r0t7eOgs2kdAj0NoBZaz9RS1fk0ZSvF k7GcBblrZGuAeGePVzz5CnyjPgA1eK/UWiwhCtKPibuQ5ysr44JPZZAsmLA0ag7dCCcC pDs43/b3dPLdb5lUmQVPz+ycViDOotb5Q409wZyVBtL8tRFDho6sneCZzshYiCVdkDNP iCZg== X-Gm-Message-State: AOJu0YwEvAp3YqFYL5RTZl2t1S/BzH2hkHoOqzh/HyPOY5Yzeg5v2UGj xfnZCe220wGRrY5mtfDyNk+KvmhgH6JDZVYs0gBhO/n04oEpm8mKJhNySPil1LHBE1fIgLGhhzZ IhmHx X-Gm-Gg: AeBDieuw2c2c94Ik0iIHBFp1mAJC7u2fv+ChMx90A7OjynK9J64ZIqXrxnN9eCfitVB XQFF+yfcyCB7M1jfJ2khrSehuTB6nvifa5ORMJSOuPJnIg2pqLig8AIlGHTeCP3N8WJDZnOTwe0 oGi/eVMqLXG4Ja+3dGnPA+nXQWicaWTfV/1YatVdi9SZztNbRNSqvgRDzVpkW1c9aUM+aXTf/x+ 49yn+Wci94CJHd0htl72TjDNt+qACDiVHeC7GkD7sMjrh5TsFAtNhNzcMK41nDN1lhPnOyzbmMf 5HypNi3uFNvJy4CAFpu2RXxoUDIMfl0KY5maOwu0g7vT/WyeUUeSGhzrQ1+g1qXqz0fI1hrf2XL IDrmMGR5nEiOSp+3fPahQF2Svirm9SFwr/pOd3NBVn7iQUClxqLj/kfU5z5H2jDpDOxgOydfBuS /Gcd7IW360HlH2oEk7tBKyvo3B0pzvclTteaEmQx6W/B6g60QkziOyHivwUeJkC6kNQEZCUJ0PA mhV0j5HSKQgiQBWeOO/QHTxnlOgSDU= X-Received: by 2002:a05:600c:1da8:b0:48e:635a:18d7 with SMTP id 5b1f17b1804b1-48e635a1ba0mr14092625e9.0.1778169124859; Thu, 07 May 2026 08:52:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/67] hw/intc/arm_gicv5: Implement IRS ID regs Date: Thu, 7 May 2026 16:50:57 +0100 Message-ID: <20260507155154.1886557-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169173571158500 Implement the IRS frame ID registers IRS_IDR[0-7], IRS_IIDR and IRS_AIDR. These are all 32-bit registers. We make these fields in the GIC state struct rather than just hardcoding them in the register read function so that we can later code "do this only if X is implemented" as a test on the ID register value. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-11-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 115 +++++++++++++++++++++++++++++ include/hw/intc/arm_gicv5_common.h | 39 ++++++++++ 2 files changed, 154 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 4c1ec8f30a..250925f004 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -268,6 +268,65 @@ REG64(IRS_SWERR_SYNDROMER1, 0x3d0) static bool config_readl(GICv5 *s, GICv5Domain domain, hwaddr offset, uint64_t *data, MemTxAttrs attrs) { + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + uint32_t v =3D 0; + + switch (offset) { + case A_IRS_IDR0: + v =3D cs->irs_idr0; + /* INT_DOM reports the domain this register is for */ + v =3D FIELD_DP32(v, IRS_IDR0, INT_DOM, domain); + if (domain !=3D GICV5_ID_REALM) { + /* 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 */ + v &=3D ~R_IRS_IDR0_VIRT_MASK; + /* ...which means VIRT_ONE_N is also RES0 */ + v &=3D ~R_IRS_IDR0_VIRT_ONE_N_MASK; + } + 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; + } + return false; } =20 @@ -422,6 +481,60 @@ static void gicv5_reset_hold(Object *obj, ResetType ty= pe) } } =20 +static void gicv5_set_idregs(GICv5Common *cs) +{ + /* Set the ID register value fields */ + uint32_t v; + + /* + * Fields in IDR0 for optional parts of the spec that we don't + * implement are 0. + */ + v =3D 0; + /* + * We can handle physical addresses of any size, so report support + * for 56 bits of physical address space. + */ + v =3D FIELD_DP32(v, IRS_IDR0, PA_RANGE, 7); + v =3D FIELD_DP32(v, IRS_IDR0, IRSID, cs->irsid); + cs->irs_idr0 =3D v; + + v =3D 0; + v =3D FIELD_DP32(v, IRS_IDR1, PE_CNT, cs->num_cpus); + v =3D FIELD_DP32(v, IRS_IDR1, IAFFID_BITS, QEMU_GICV5_IAFFID_BITS - 1); + v =3D FIELD_DP32(v, IRS_IDR1, PRI_BITS, QEMU_GICV5_PRI_BITS - 1); + cs->irs_idr1 =3D v; + + v =3D 0; + /* We always support physical LPIs with 2-level ISTs of all sizes */ + v =3D FIELD_DP32(v, IRS_IDR2, ID_BITS, QEMU_GICV5_ID_BITS); + v =3D FIELD_DP32(v, IRS_IDR2, LPI, 1); + v =3D FIELD_DP32(v, IRS_IDR2, MIN_LPI_ID_BITS, QEMU_GICV5_MIN_LPI_ID_B= ITS); + v =3D FIELD_DP32(v, IRS_IDR2, IST_LEVELS, 1); + v =3D FIELD_DP32(v, IRS_IDR2, IST_L2SZ, 7); + /* Our impl does not need IST metadata, so ISTMD and ISTMD_SZ are 0 */ + cs->irs_idr2 =3D v; + + /* We don't implement virtualization yet, so these are zero */ + cs->irs_idr3 =3D 0; + cs->irs_idr4 =3D 0; + + /* These three have just one field each */ + cs->irs_idr5 =3D FIELD_DP32(0, IRS_IDR5, SPI_RANGE, cs->spi_range); + cs->irs_idr6 =3D FIELD_DP32(0, IRS_IDR6, SPI_IRS_RANGE, cs->spi_irs_ra= nge); + cs->irs_idr7 =3D FIELD_DP32(0, IRS_IDR7, SPI_BASE, cs->spi_base); + + v =3D 0; + v =3D FIELD_DP32(v, IRS_IIDR, IMPLEMENTER, QEMU_GICV5_IMPLEMENTER); + v =3D FIELD_DP32(v, IRS_IIDR, REVISION, QEMU_GICV5_REVISION); + v =3D FIELD_DP32(v, IRS_IIDR, VARIANT, QEMU_GICV5_VARIANT); + v =3D FIELD_DP32(v, IRS_IIDR, PRODUCTID, QEMU_GICV5_PRODUCTID); + cs->irs_iidr =3D v; + + /* This is a GICv5.0 IRS, so all fields are zero */ + cs->irs_aidr =3D 0; +} + static void gicv5_realize(DeviceState *dev, Error **errp) { GICv5Common *cs =3D ARM_GICV5_COMMON(dev); @@ -448,6 +561,8 @@ static void gicv5_realize(DeviceState *dev, Error **err= p) * NS domain. */ cs->implemented_domains =3D (1 << GICV5_ID_NS); + + gicv5_set_idregs(cs); gicv5_common_init_irqs_and_mmio(cs, gicv5_set_spi, config_frame_ops); } =20 diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 10276d652f..21e1d7a21d 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -65,6 +65,18 @@ struct GICv5Common { /* Bits here are set for each physical interrupt domain implemented */ uint8_t implemented_domains; =20 + /* ID register values: set at realize, constant thereafter */ + uint32_t irs_idr0; + uint32_t irs_idr1; + uint32_t irs_idr2; + uint32_t irs_idr3; + uint32_t irs_idr4; + uint32_t irs_idr5; + uint32_t irs_idr6; + uint32_t irs_idr7; + uint32_t irs_iidr; + uint32_t irs_aidr; + /* Properties */ uint32_t num_cpus; ARMCPU **cpus; @@ -84,6 +96,33 @@ struct GICv5CommonClass { =20 #define IRS_CONFIG_FRAME_SIZE 0x10000 =20 +/* + * The architecture allows a GICv5 to implement less than the full + * width for various ID fields. QEMU's implementation always supports + * the full width of these fields. These constants define our + * implementation's limits. + */ + +/* 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 +/* IAFFID bits supported */ +#define QEMU_GICV5_IAFFID_BITS 16 +/* Number of priority bits supported in the IRS */ +#define QEMU_GICV5_PRI_BITS 5 + +/* + * There are no TRMs currently published for hardware implementations + * of GICv5 that we might identify ourselves as. Instead, we borrow + * the Arm Implementer code and pick a fake product ID that is + * unlikely to be used by any real Arm hardware. + */ +#define QEMU_GICV5_IMPLEMENTER 0x43b +#define QEMU_GICV5_PRODUCTID 0xfff +#define QEMU_GICV5_REVISION 0 +#define QEMU_GICV5_VARIANT 0 + /** * gicv5_common_init_irqs_and_mmio: Create IRQs and MMIO regions for the G= ICv5 * @s: GIC object --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169432; cv=none; d=zohomail.com; s=zohoarc; b=axyE+KetXBZLNtCDWLIA9OwKhcIC/mAKPq3SUZCFWmKKlQEtpx/OzmGE2D8P8kO49G5WxEOZQZ54oVLz19lt2YnSd+7904QcY5fuSm9PVjkRacWHEGVwXQBNjbc6q4rjEMVzqlgU/x2MTGWG1GHcZqbHI4bonn2fiDrEuC4Cczc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169432; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=bdclcwp984Qp8KEWvGCiLv82TgfwbWNN6N3cLZYfQZY=; b=S0HvXabI9j8tqIM02j1OMq7i/42LPxTsAWodzenUOBR5m2b/An/N254af3fankvNAo3eaSaDWyMTov1dZR1GHUXT7eKtr/axU9P7zdFhn5rxf3jVIgjpEQhBQtVknGAPodwTDH6kpEZHO8Sn059teFzp63tRq9KGRsR+FpjFYe0= 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 1778169432330175.8570481338038; Thu, 7 May 2026 08:57:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11I-0003T3-4l; Thu, 07 May 2026 11:52: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 1wL11G-0003RW-2X for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:10 -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 1wL11D-0003oE-P8 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:09 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-488d2079582so11434355e9.2 for ; Thu, 07 May 2026 08:52:07 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169126; x=1778773926; 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; bh=bdclcwp984Qp8KEWvGCiLv82TgfwbWNN6N3cLZYfQZY=; b=IdEB4g+067hpBRREuK5Qx8o8JGmJqB5mtXikKr64rCkBneOkSTgM4aG04NP0Byq3kV MnSraFuB0VzYjMIi49nyXF2cO/wwgeVCmGYSXN2Y79j4qYY0/W07lFux10xN4AO6Zpiy oY1eDfUSm6fQOSr92bADIMi8W0lROPGBf/WERkkJfl2oBuB95z/5b9vq3L+JhaZgVKld Lrl6kKfTE5lY/chhKswee4CPONIcw/d+DLIGMBzprLKi6wewBTIqChZTZxyM00j3Kk1V WBdz+sDQ3LREhzNgEPlOMIjFxku0bWkGbHBKzYMHXxQIT21bAySnwqtDC1PUeGxTRjwf itgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169126; x=1778773926; 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; bh=bdclcwp984Qp8KEWvGCiLv82TgfwbWNN6N3cLZYfQZY=; b=VSlQK7oTUMou3a9feouKlVeUVgslz1o0qiwIIXHrisah8xNvguYqlIpFUZRpKLj5iR vRZ//xXBgW6sqKzYe+m03v2ndJ7jYLsqH7Mg3wtDRqKrL0I5Bg3WAdgMwKahOvtoysyP TWVy78uXKNG0Rbbd/lvWYBaq2F+METYlXIONI61C/0p13S1giv+YeJ9Yn5PPXwuO9J41 q/s3dqmK7K0u84ILji1D2UP53FPJyBZ8e+pQF4kiEHVHDDaJX/FnXVsFNJrkRp3PmJL1 D0577obOL/7MwOuh1NF4A78N18MzyLuH5HhhR4GTkTvCYfjc3R2Xd+2+Ql5KRcGNSmrs 1ORw== X-Gm-Message-State: AOJu0YzTjTIl/ttQKihL/+KtA9cRTsQlmlXYJ9VL71ylKCivaafSR+Pl mrW85yl16f5EY4aAvNOKxwc47TdXdYCd18natI598mjfzKIrM9PVD+ESaQEiFhsWiIDuRLRU4it T1D+k X-Gm-Gg: AeBDievP6jgTWHxow1drQRcl24BPkuhv6oMHr7lPY6mpj+Sj/RZYpeAGhj/AxphMBZZ GQimtCsJAzXxZi5mqfy/FYquITjaLM0RalwjvKJ0Zx96z7CCZn4ManEl8Lu/amAOA/2gIcc6G5g n0DaohjvvrFtrjmmhD7TaTyyO/5661FVRTyyTZVogNXPuq92qsExz2clJ00Nom4yErtUc2umBoH Zooa8uz6LkLkv1zEz3zQoQcRb6oMzP8qR8poTwtCIapBgjWMjx7ozmN307yQhoF7oFi4tu2pd9w 8vSLRlzg5l+OnwH0y7qzDeDH59uxuxJj0sWsCGTe53Mh9nclE+tdl5eJJdaX4o+3iFvQ5ugG785 95lyOPYH1tlrIZEQBciqBCPh+0jKg+U7l1vNmos6PYphJwjtb0XGku1umCu9j5epezGjDY3QNI4 a1VEDh5FcaWpQTAvuxM6absM0B4miKNSHpbvQukVDj7D43lEqcMv1Xv1/iRgOzUr/e3mFd61zwZ vFjPxlPKLSwC5dTSt5bp7SaeqVIPWM= X-Received: by 2002:a05:600c:c11c:b0:489:1e8a:90b4 with SMTP id 5b1f17b1804b1-48e51f37212mr100787275e9.21.1778169125706; Thu, 07 May 2026 08:52:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/67] hw/intc/arm_gicv5: Add link property for MemoryRegion for DMA Date: Thu, 7 May 2026 16:50:58 +0100 Message-ID: <20260507155154.1886557-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169432516158500 The GICv5 IRS keeps data structures in system memory. (Notably, it stores per-interrupt configuration information like the interrupt priority and its active and pending state in an in-memory data structure.) Add a link property so that the board or SoC can wire up a MemoryRegion that we will do DMA to. We name this property "sysmem" to match the GICv3's equivalent property. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-12-peter.maydell@linaro.org --- hw/intc/arm_gicv5_common.c | 8 ++++++++ include/hw/intc/arm_gicv5_common.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index b58913b970..29cc96917e 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -122,6 +122,12 @@ static void gicv5_common_realize(DeviceState *dev, Err= or **errp) cs->spi_base, cs->spi_irs_range, cs->spi_range); return; } + if (!cs->dma) { + error_setg(errp, "sysmem link property not set"); + return; + } + + address_space_init(&cs->dma_as, cs->dma, "gicv5-sysmem"); =20 trace_gicv5_common_realize(cs->irsid, cs->num_cpus, cs->spi_base, cs->spi_irs_range, cs->spi_ra= nge); @@ -137,6 +143,8 @@ static const Property arm_gicv5_common_properties[] =3D= { DEFINE_PROP_UINT32("spi-base", GICv5Common, spi_base, 0), DEFINE_PROP_UINT32("spi-irs-range", GICv5Common, spi_irs_range, GICV5_SPI_IRS_RANGE_NOT_SET), + DEFINE_PROP_LINK("sysmem", GICv5Common, dma, TYPE_MEMORY_REGION, + MemoryRegion *), }; =20 static void gicv5_common_class_init(ObjectClass *oc, const void *data) diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 21e1d7a21d..233233bc3e 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -83,6 +83,10 @@ struct GICv5Common { uint32_t num_cpu_iaffids; uint32_t *cpu_iaffids; =20 + /* MemoryRegion and AS to DMA to/from for in-memory data structures */ + MemoryRegion *dma; + AddressSpace dma_as; + uint32_t irsid; uint32_t spi_base; uint32_t spi_irs_range; --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169528; cv=none; d=zohomail.com; s=zohoarc; b=W1pWWUYkemDwfjI1AG2XWQwLhnjEhiVSLo2l3DBNLjq3aN0+2WZR4apk/wdazgBCAywRej8dDxKY4SMbcozAEq2j+2iKW5fKotSfmu0fQ1TWu0IAhRjqpikmPBUTumWBpszw7MEmXWBL5V+9k5goaEJsOhpPlHIiPag3kCGseqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169528; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=RGheXXRC6x0QXSLragqGnkW/MkrRzCgdH8x0picNC+0=; b=X7NFFCOt7c2HDhgILpoVk4DNnq2+nO4k2QOJphIo3YsKe9gGc1/x/Ec2jjqtdutKJwMK5M8Q+Je+LJ2XIAvikL4nLUUCWT1RAewsMQfbCgh8jaVUNoSgoULlHB2SMYH+F578iKmSpn+FHGUb9WJ+lH92JIBLOh1jfhCJHOT60Qg= 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 1778169528241197.94209659368323; Thu, 7 May 2026 08:58:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11K-0003UR-Eo; Thu, 07 May 2026 11:52:14 -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 1wL11H-0003SO-Ay for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:11 -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 1wL11E-0003oX-It for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:11 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-488af96f6b2so12018175e9.0 for ; Thu, 07 May 2026 08:52:07 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169127; x=1778773927; 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; bh=RGheXXRC6x0QXSLragqGnkW/MkrRzCgdH8x0picNC+0=; b=Y0mWod6Rv0D9eUEQcsbwG5RGKMtmJyAUSshsxZW+8W2zdMKw75YK89lnwCuoOIlfm9 AdtDmFrq+F2fqd1yOTU6n1avJnUFsyneN14JIWbrgBaOp7hCjdudoUePaZvx9pJnFSZl DniWtnsoYBkb+94zpuHpmbJR4G+Ojv0za1euwm2td0TgzioB2thn4gZUHfYh0XsFoDy/ 13EPr/v0UVf0w/IoW6Vyhx87UdK9P3EZ0oUIhTV1caVSXgYzfZHL4N6UEChqudrdQxJN 10WrUXAtHUbcoDNamqD0MbQhKQNWC0Jt9btgNSo3mtTCLFGoZDXfb1TaXNDIBTy630bP KYdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169127; x=1778773927; 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; bh=RGheXXRC6x0QXSLragqGnkW/MkrRzCgdH8x0picNC+0=; b=V6/8B5aXe3sJpSX1iRe0bD+8a/Vh+73rawDW3LOtdw+BkpinEOyklOj+jFBk/eZnWh +FlGq+4z8ffzQXLL22gGPKxQYzVBrs+Nepciv0JzkuLgdoQLpDePavWIKmtsQg6EusuZ nY+xUU5JwF12iotZZPRy6jjzlelDXTu+XOHFYYwB61Jw9hwnGt74MPtm6EidulEfZZOe G9GONxkeFf0J4obsdpBQW2ButaP4a54afgdK2ngCy8gRaE+yaOowCm6pV5pkMj/y/NaO cT4A4kdEayFetMdjsqSB8ro6zbcRf1QGPwrGoVK3pXCsu5iuY0Q02808BkidRLvCAxOI 426Q== X-Gm-Message-State: AOJu0YxHH1BGvyjqABKOaBAiuvACtWO/ZHiAJXH0Rq9nqSfeCZVn6OHX P+qVD/eSIffuEv08F9tPOhP0TULQq/yO7KjadZL6C5/aP8/h7ESuDT5uLLqt9NHoTZBYoQYwa1n ZntNT X-Gm-Gg: AeBDievj4vVdzBQQJJVSYqmWhGR/vnGGgrzlT1Zfk5gTps6Vv0Nff4hJDSZ2nKb0PH/ xOIQTT2zBUS4NDy3CykbaBjyrKIOceMg0CMPmigWGC7uyiG/pDSTzPRBui5fBi7gPuJKBabhVTl D95sVXNPh7zfB8T+9JynFOa3p9PlwDCoi3D0Tc769TtsovLbhf6gH4+bDLMroWn2bgDvHhKCLDs CjRc1BpohutbtNQ4LO6FDKXHJhcmZyy0GqzZ8wYVnSSgS+qH5e12fP83TC3ixIFjDR3dD5jC82d bEYGUnFbUeHOkP2IUI4JldLOmwoSrJFMWwvyRv2Q0HtGiPRe8GlVt7IAi1F0vyy60HIZXjyhzJP T8sfdTEfDau4qZq/DRMRRYcOdd7i4IisP2yAyB6mNSufR6cZTLl30tttrNYr3HmZgQwPEwiZCMr UIjqqIujrUFrPkCWQoE+FPTl9TfD4wdWpHhgEcv9gPydh7cGXnkz7FaMysC8XErHigsdecE4s5c ZlVIYDiISVV5kKw X-Received: by 2002:a05:600c:a118:b0:486:d76c:fa57 with SMTP id 5b1f17b1804b1-48e51f37363mr110562675e9.17.1778169126630; Thu, 07 May 2026 08:52:06 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/67] hw/intc/arm_gicv5: Implement gicv5_class_name() Date: Thu, 7 May 2026 16:50:59 +0100 Message-ID: <20260507155154.1886557-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169529006158500 Implement a gicv5_class_name() function that does the same job as gicv3_class_name(): allows board code to get the correct QOM type for the GIC at runtime depending on whether KVM is enabled or not. For the GICv5, we don't yet implement KVM support, so the KVM-enabled codepath is always an error. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-13-peter.maydell@linaro.org --- include/hw/intc/arm_gicv5_common.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 233233bc3e..e7220b9dc7 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -13,6 +13,8 @@ #include "hw/core/sysbus.h" #include "hw/intc/arm_gicv5_types.h" #include "target/arm/cpu-qom.h" +#include "qemu/error-report.h" +#include "system/kvm.h" =20 /* * QEMU interface: @@ -150,4 +152,22 @@ static inline bool gicv5_domain_implemented(GICv5Commo= n *cs, GICv5Domain domain) return cs->implemented_domains & (1 << domain); } =20 +/** + * gicv5_class_name + * + * Return name of GICv5 class to use depending on whether KVM acceleration= is + * in use. May throw an error if the chosen implementation is not availabl= e. + * + * Returns: class name to use + */ +static inline const char *gicv5_class_name(void) +{ + /* When we implement KVM GICv5 we might return "kvm-arm-gicv5" here. */ + if (kvm_enabled()) { + error_report("Userspace GICv5 is not supported with KVM"); + exit(1); + } + return "arm-gicv5"; +} + #endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169509; cv=none; d=zohomail.com; s=zohoarc; b=HT9Kk5N2n5eQgAy2IHiUmrjvJOR+NdlrJvh7M26+BEHWtTFdeX9rcX956P6KtC6E8esmSx/IvUo54FLBSSjOjLMGyotYBJ/bHKr0yL0XgUtt7wPxZ4ejYJwZ9jQPWcS0s0bBkAeC1AmQMQfIvWumeq3SSjUWgYtDPRkM9qrzR2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169509; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=/TGTY2rfTF+tJN36KyHrpTad81jz0jTI68kPGEzG8y8=; b=jF0uKxfQhovY1SVcBbiilYKVJ08B+ph0krgvrWH/Jb2r+Qe/pKc77CtJakxXjFcAH/F/xNAvSULDNrO7VwhmecJEjnmHDtpZNIOMuoO0vn1CGRPkcsXT3HgpyJs4Yv2irV5LSQbiUhlupVIR5DfUoxEnxfo73c9JFF3+9rVoMrg= 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 1778169509903859.3683356702827; Thu, 7 May 2026 08:58:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11L-0003V3-DD; Thu, 07 May 2026 11:52: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 1wL11H-0003SW-FR for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:11 -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 1wL11F-0003og-8z for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:11 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4893940bb5eso6532035e9.3 for ; Thu, 07 May 2026 08:52:08 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169127; x=1778773927; 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; bh=/TGTY2rfTF+tJN36KyHrpTad81jz0jTI68kPGEzG8y8=; b=x2QTAT1Psi0nFJ4UKpG65sXeLZDFlmplsbiuMr+TV9/18/lLZ8KPmh84lnwluRPO0c EtTAUHyafmTQLQWF+98q+jRJ0wun9uQ0B3hxEEO8u89DP4eFm81dLQcJucnFofO9zxO1 TIBufesqMeXdnyIx7cNIiCp+quxQxkeU8nb0nWecW2UCHIjfsMSwRydu2bI/4skMcCTs /z+46200GpFo9x/T9b31A+/DXQSqvrZpDqde4/kzDoCbvB6sugYsfeNKl6HdxC14CMtO DTkiOnSRefKc+g76FcPkzL7Mav0p0szgs7lQ74m4ZIALcCCWJTgjh9D8ou8GZ41VkjrO 9Fxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169127; x=1778773927; 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; bh=/TGTY2rfTF+tJN36KyHrpTad81jz0jTI68kPGEzG8y8=; b=dzrPK5zTPGzMhGJENaTJRDO+9KTzaR8VwjrJeAb1xhz1vl+lOtEc+26vq26+UN59r8 koWgYAJl5YEZr/aSKEFZohbz6PznAeXGLkfacHXCBC4E7AkCnimy6bQjSp0IQhZ11gdf FLhJcARnivBggSNnYZ41xpY/5unBk+KEIOc5VtK1nBsjDFVuUQsg2TN9aQ1xKzVjHSOc bDflxQyHIhQNRF5FDjaoUtW2z9F/jM/6kkuGblBA96p/RVVHJL4hB144wJbz+s6fhxYW wwVcAdGbCPkAG8cBJbikGn7bwziZUZfDEeMp72T8FuvKWotfhlhyLtERZ/4ZDRz3a9r2 a64Q== X-Gm-Message-State: AOJu0Ywqq1Z1DJ2m2TJR0HxluOrLsdKSAPxqu/dnXMciOM8dypgr3AcZ orgkqoERKJnvi+U7NKXs7KClL/hZh9qBrJKiIozBhE+cQEvKgM4B26iKBpc3a1xtcxzg/fd4Q7M /k1AS X-Gm-Gg: AeBDiesSIKSoPLfp2OrmMIRdfBlTCZ8iM9sEe1O786rnIrx7KAg70zhCE4UGDmWKbKY Qdv5MZwty2I6QHmo2ss+BBKeMyjM5dj0qZl+XhnHKp0ccTTVerB9/PC0047VA4wDvobPXs603PV 9muUeXMbDuHIoY6gXZqrvIHw8VnDSOkArULFl5Hva5YUMhLnFV/Q2MelI8MCoeGzhTo4OrTF14a tjoczmrjl/m+TzJPn3QxGCL2/9H/JT2k8fpqa9H77vDbmSqygWNOmhIMksYs71Mc3/z7ZkIsm8t 4Um7Si5lR6zm4wZgmCXnbqv9r//iRxlkfLBYbj9WET9Z+5cMxHiEDkWziAh1D59qe+gmnUuOjua nNuuBLE+ROqHrg/OolKuMR/s9S1upwxdwVp+t7/s9CUiDsuqUNOHAaAD7TmDWcqQyG4liQNorgB DjoqV2+mOJe5YnuQRE3TOi4RGD3KPK96S9APQhjNz9Hs+qqvPg84isxo8oFjsxO8WssbfTwhE+u EOU6kZx6SmjTuquuO+YdqM0cPK8ICRruhL39wr3Kg== X-Received: by 2002:a05:600c:a305:b0:489:2005:b36e with SMTP id 5b1f17b1804b1-48e51f444e4mr91995585e9.19.1778169127512; Thu, 07 May 2026 08:52:07 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/67] hw/intc/arm_gicv5: Add defines for GICv5 architected PPIs Date: Thu, 7 May 2026 16:51:00 +0100 Message-ID: <20260507155154.1886557-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169510898158500 The GICv5 defines architected numbers for the PPI sources like the generic timer and the PMU; these are different from the ones traditionally used by GICv2 and GICv3. Add defines for them. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-14-peter.maydell@linaro.org --- include/hw/intc/arm_gicv5_types.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/hw/intc/arm_gicv5_types.h b/include/hw/intc/arm_gicv5_= types.h index 49dc1d6e95..7d23752ece 100644 --- a/include/hw/intc/arm_gicv5_types.h +++ b/include/hw/intc/arm_gicv5_types.h @@ -25,4 +25,24 @@ typedef enum GICv5Domain { =20 #define NUM_GICV5_DOMAINS 4 =20 +/* Architected GICv5 PPIs (as listed in R_XDVCM) */ +#define GICV5_PPI_S_DB_PPI 0 +#define GICV5_PPI_RL_DB_PPI 1 +#define GICV5_PPI_NS_DB_PPI 2 +#define GICV5_PPI_SW_PPI 3 +#define GICV5_PPI_HACDBSIRQ 15 +#define GICV5_PPI_CNTHVS 19 +#define GICV5_PPI_CNTHPS 20 +#define GICV5_PPI_PMBIRQ 21 +#define GICV5_PPI_COMMIRQ 22 +#define GICV5_PPI_PMUIRQ 23 +#define GICV5_PPI_CTIIRQ 24 +#define GICV5_PPI_GICMNT 25 +#define GICV5_PPI_CNTHP 26 +#define GICV5_PPI_CNTV 27 +#define GICV5_PPI_CNTHV 28 +#define GICV5_PPI_CNTPS 29 +#define GICV5_PPI_CNTP 30 +#define GICV5_PPI_TRBIRQ 31 + #endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169162; cv=none; d=zohomail.com; s=zohoarc; b=Bmfy+rNPBic173H4T/IYDgBD8yFki4Nbo6VgjBh7CXtFDud55Eizvs1W8R590rQu6PdVAM73rS+AQuWZGBDXExbIYRX9Y2Y49QsBaYvKX6tX6g94iDpYeioqM3yy9ekr/ezOxwupC9Yya2YkGKPSyKU4Ij5taYOhVj8ME2FQO9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169162; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=1B+boeG3J/p68+ah+q4V8HG+OjMDuLmWiyWVg0ncbkM=; b=f42bmohK9Tv+cdbVCv5Z1n3WplszZx9v7lCkrt60+rUMmxns0/IlV7IR3fbbXplngHP5uQSf4oocF2qQwii516BhvmgjcJGuCCWRLAkQRiWBNgseyhX5hO6K88N+E9n1HA9VW1RYqxCjH6BQoe2qQG5ZVDeJDkntegAKb409OdA= 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 1778169162440140.89001996444154; Thu, 7 May 2026 08: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 1wL11M-0003VC-1P; Thu, 07 May 2026 11:52: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 1wL11I-0003Ta-Ha for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:12 -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 1wL11G-0003ou-8E for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:12 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-48a7fe4f40bso11496695e9.0 for ; Thu, 07 May 2026 08:52:09 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169129; x=1778773929; 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; bh=1B+boeG3J/p68+ah+q4V8HG+OjMDuLmWiyWVg0ncbkM=; b=BlvFHV0jSZzsAS9Vh+W+TGLwz7KH4RhjMM1A6/h0Sb1rm/MiPMEehTTBSUBAicYod5 60rLp88t5gYVN4iOSIoNTAYOZj+Ou8tRuDrNUOxlx1CwNarImW53zq/Z1va836rL2xfs JusJAdiK+6Sg4C+/GkvAOxLniJBbI7wbBA5EAlpHLVgbejBhIGNeR6BYop0gLUQySob1 i/L0XsKksZRZH/3/kzWTJOxtj2QvhkbDutANP8p+zcjJq3rpkDI7lGvsANMBzwDj57+k YjoHjJuZs09V7a7nM455OGLE6BF5lsPYYua7CWvxjS5lHVzCAotsbxtpYWhqvJpJ+L+3 lWxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169129; x=1778773929; 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; bh=1B+boeG3J/p68+ah+q4V8HG+OjMDuLmWiyWVg0ncbkM=; b=YUL3jT1RGk9E/38pGiWum0ajOOQyFBU0B+L3QafFCjC/GWXI4ATJkQxZX5M2By97jP EYVqYl8FPGrCyKSqZTETrTnOXNfrsmDVbE0bt56kUqW0hE+jfurhI2bLSSvtGJPDw5Pu 06cyD/dHMiY5AFBxVqm/pwVkoaXbqwlLvcV/RXOITU/HXqqqhtEPomoeLV1C6554Egee YHwNkSrHvoUvVt36ZkV7YPgL0WHEuPWMf95cDzf4p3vjm6ePZUfyyRLFB/+iCJ69qWTh lXf7DVM8uDV9+9ZMrAgexxIk5Pl/8zifBeFNJJGGX4E0ULcKuOrBLMOnHmKnOWeyem6I McHw== X-Gm-Message-State: AOJu0YzbdTIGSASY6RpQn8mfIsB+OzzmQ33jKePvo58N2+LkLOBUYXGA /mMHXjlbkXjVlQgDwKKYvcG3iQsVYtIXcciMzQhgbf3+ycT/JBG+S+gOIG2ZJMdsuhwAaQrfnMZ W+1HB X-Gm-Gg: AeBDies/Zx4thlasoNVsb+DltKgqT4YM4GT5ER7zg5pUJ45TjVK3K7PZfGJUM7Hr99s y/ogoTf9xpR28VadUojngzFnqF0Tpzo1ooKSKnSwMGCyTX/VJ0e1ACyulXdC1wVaoPv6WEInmIs OiiZ6Mo/fj2zP4nQ0zEM4AxBUQ7B7NMNynB7HWtmvfB4qYY5rCGEzORaHGAcIlFROoO0UxIP/Ks H8h/ejt8zMitKqBSD162V2VgWLvohAytdpNP9A1AZbyb2e/sGCyyI8oHUGMtteK+/4k8XVfBbaq tiw9wCu6BR/chnDm+63iiksd+RZ0qDm3SmSAvYKMmpHG9s3F0fBJiqlkMyOLHv7UACC3iC/WPpd yGv3DZYCECnoCLYDtl0RSFBtSf0OhO5i3op/Dfy6QY36JdMyt07CmuJwIl81Iq0e0lxSrEs2pG5 1aMZT4dQpXFlE/835y1CIvr+SageqGdSdVaekZ2SpFLON4sqqe7xMHt4/H2aBwJLnFIK7F1ZhOc rnBF8o5MfrrIsoK4gM9syOtyjVq9zvkKqeFQV703A== X-Received: by 2002:a05:600c:811a:b0:483:7903:c3b1 with SMTP id 5b1f17b1804b1-48e51f35d0emr142049895e9.20.1778169128368; Thu, 07 May 2026 08:52:08 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/67] target/arm: GICv5 cpuif: Initial skeleton and GSB barrier insns Date: Thu, 7 May 2026 16:51:01 +0100 Message-ID: <20260507155154.1886557-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169165594154100 Content-Type: text/plain; charset="utf-8" In the GICv5 architecture, part of the GIC is implemented inside the CPU: this is the CPU interface, which presents software with system instructions and system registers, and communicates with the external part of the GIC (the Interrupt Routing Service, IRS) via an architected stream interface where both sides can send commands and receive responses. Add the initial source files for the GICv5 CPU interface, with initial content implementing just the two GSB GIC barrier instructions, which are no-ops for QEMU. Since we will not initially implement virtualization or the "legacy GICv3" interface that can be provided to a VM guest, we don't have the ICH_VCTLR_EL2 register and do not need to implement an accessfn for the "trap if at EL1 and EL2 enabled and legacy GICv3 is enabled" handling. We will come back and add this later as part of the legacy-GICv3 code. (The GICv3 has a similar architecture with part of the GIC being in the CPU and part external; for QEMU we implemented the CPU interface in hw/intc/, but in retrospect I think this was something of a design mistake, and for GICv5 I am going to stick a bit closer to how the hardware architecture splits things up; hence this code is in target/arm.) Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-15-peter.maydell@linaro.org --- target/arm/cpu-features.h | 6 +++++ target/arm/helper.c | 1 + target/arm/internals.h | 3 +++ target/arm/tcg/gicv5-cpuif.c | 43 ++++++++++++++++++++++++++++++++++++ target/arm/tcg/meson.build | 1 + 5 files changed, 54 insertions(+) create mode 100644 target/arm/tcg/gicv5-cpuif.c diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 88fe3ed287..4e44245a8b 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -280,6 +280,7 @@ FIELD(ID_AA64PFR1, PFAR, 60, 4) FIELD(ID_AA64PFR2, MTEPERM, 0, 4) FIELD(ID_AA64PFR2, MTESTOREONLY, 4, 4) FIELD(ID_AA64PFR2, MTEFAR, 8, 4) +FIELD(ID_AA64PFR2, GCIE, 12, 4) FIELD(ID_AA64PFR2, FPMR, 32, 4) =20 FIELD(ID_AA64MMFR0, PARANGE, 0, 4) @@ -1172,6 +1173,11 @@ static inline bool isar_feature_aa64_gcs(const ARMIS= ARegisters *id) return FIELD_EX64_IDREG(id, ID_AA64PFR1, GCS) !=3D 0; } =20 +static inline bool isar_feature_aa64_gcie(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64PFR2, GCIE) !=3D 0; +} + static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) { return FIELD_SEX64_IDREG(id, ID_AA64MMFR0, TGRAN4) >=3D 1; diff --git a/target/arm/helper.c b/target/arm/helper.c index 7e7677a584..d9751cf202 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6233,6 +6233,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) if (tcg_enabled()) { define_tlb_insn_regs(cpu); define_at_insn_regs(cpu); + define_gicv5_cpuif_regs(cpu); } #endif =20 diff --git a/target/arm/internals.h b/target/arm/internals.h index a632584a4e..6431029db8 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1810,6 +1810,9 @@ void define_gcs_cpregs(ARMCPU *cpu); /* Add the cpreg definitions for OMAP CP15 regs */ void define_omap_cp_regs(ARMCPU *cpu); =20 +/* Add the cpreg definitions for the GICv5 CPU interface */ +void define_gicv5_cpuif_regs(ARMCPU *cpu); + /* 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 new file mode 100644 index 0000000000..7392a98c49 --- /dev/null +++ b/target/arm/tcg/gicv5-cpuif.c @@ -0,0 +1,43 @@ +/* + * GICv5 CPU interface + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "internals.h" +#include "cpregs.h" + +static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { + /* + * Barrier: wait until the effects of a cpuif system register + * write have definitely made it to the IRS (and will thus show up + * in cpuif reads from the IRS by this or other CPUs and in the + * status of IRQ, FIQ etc). For QEMU we do all interaction with + * the IRS synchronously, so we can make this a nop. + */ + { .name =3D "GSB_SYS", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 0, .opc2 =3D 0, + .access =3D PL1_W, .type =3D ARM_CP_NOP, + }, + /* + * Barrier: wait until the effects of acknowledging an interrupt + * (via GICR CDIA or GICR CDNMIA) are visible, including the + * effect on the {IRQ,FIQ,vIRQ,vFIQ} pending state. This is a + * weaker version of GSB SYS. Again, for QEMU this is a nop. + */ + { .name =3D "GSB_ACK", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 0, .opc2 =3D 1, + .access =3D PL1_W, .type =3D ARM_CP_NOP, + }, +}; + +void define_gicv5_cpuif_regs(ARMCPU *cpu) +{ + if (cpu_isar_feature(aa64_gcie, cpu)) { + define_arm_cp_regs(cpu, gicv5_cpuif_reginfo); + } +} diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build index d2364aa39c..4fb2c15f7e 100644 --- a/target/arm/tcg/meson.build +++ b/target/arm/tcg/meson.build @@ -67,6 +67,7 @@ arm_common_system_ss.add( files( 'cpregs-at.c', 'debug.c', + 'gicv5-cpuif.c', 'hflags.c', 'gengvec.c', 'm_helper.c', --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169528; cv=none; d=zohomail.com; s=zohoarc; b=T6ZcGAvLTGVgZfA2G/7YYpbI812BYi5k6l1GMmxX1o8o13OJl+uPpKsX7FQZuPUcRwrCc98DrTmOD9SlJMo/urLf4BIxD40Vma7D90iadesPTWsctxrfZljkt9sPjMnkx9OhbU1BcRwHaSC5jokeWkTnZ6Eb44cC2zZ1h9qJw+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169528; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=vm5QiSnH8IwWNwI3N643Op2tyJpVuocW3kNmorzza+w=; b=h5RfFY8i9KwWYKYC7jHJMat/BChavnYNbK7pHfXD29Yh4NMgeBdIQYfPhpA7grC51FEDrdoMRd8aVrqHOeCei9aDPidNsaznGFWhEfByGi4eUDoej6nq2H65haoB5lhpQaeUVHJLGq/UseprhKfn0oejNq6YW/SuZQue357EsJY= 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 1778169528369547.295753246608; Thu, 7 May 2026 08:58:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11L-0003Uq-2t; Thu, 07 May 2026 11:52: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 1wL11I-0003Tq-NO for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52: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 1wL11G-0003p8-Re for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:12 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-48a7fe4f40bso11496805e9.0 for ; Thu, 07 May 2026 08:52:10 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169129; x=1778773929; 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; bh=vm5QiSnH8IwWNwI3N643Op2tyJpVuocW3kNmorzza+w=; b=URtaOKwDNpffNodKK8KF+cHsd4VMfwI4kvtlv8cYNyRk1WgPw+9SfWr9CBlTgiOx0I e/+CzmYadD9rnqhEYwc6m38LzqZfDTVXKwkaZah3isQdKvHMaiK3YwgpbLBZnwG794IY mVO6kLdfyJ+Zs9OmvdEZ2YCz6i+0R/kG9KfbOYkeqcTNI3xymFERam2o2zU1RdcTAl4v T4gzTXGiWWEFAfOvLSziaPHhyS/nu7wPqGpzL43mQuczXHPe4L+nhYEfzafvfHuvH8+n ve/eNLOWlvF1g4Dcxt6RfO0+tJG/NLUo1uiRFnHvKrnPrujlDcBNZU5BIlk9qPh/nzeT a3aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169129; x=1778773929; 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; bh=vm5QiSnH8IwWNwI3N643Op2tyJpVuocW3kNmorzza+w=; b=Wp0TCnm0/+BrRQ8oTctFutPNl1U5j2t2Vd1cmg0JZUYnpVnkduJw4YYip/cIbJuRb/ j81uI6ZD+QVQZ86SJ2O3qLAhWNoyueKmK5ouamWenSpziTQbLafMBE02BC6GrHWYF734 GqlCE626a/BJDH0T2HlHvYH0UD5OfowROEbRedCUdpr3/oQeac7BUXCcQZ1XLQz/0aBq svBrtlxHcb8jrlqPf99xW1HK11JwobOXpUmbL596jR8zCVPoNh/vAfmNZNxpuKJ++BHg K5fsQXYXXHdqhz1J8wwifpcf8bBNKfLp5icVewOxZJeQKfxlgS9NwyvT50bG0a+AOdj7 ML3g== X-Gm-Message-State: AOJu0YztZFpgvIG7hiyuyx2Nz3vbCjkXumr9PU6o3HeUASgS+9ExlsTc z4V9t2swNid6sYqr9kfcWcsvIbqC+PxdP09ekYMUrurJtAMVsMW+EO3mxD+RK4ZB4ZdpbKsCEPj mboBX X-Gm-Gg: AeBDiesgOsNwONddom/Fx5BzOcXY0hhBaa3HQpfLm6opV4dO1LpT/AdkNaULvF8jXbq psibDZWKOLo4DvRmskQlQt4M/6xjDE3rliwyOAq90YkHTnXCSRrREwa/JB3d338pn/CEJm/NWeb 3XDbgyIa9Ac45akP637dz0BgQdaCS2AJB2UyvkxFYIkiOoCb/dgWFOA/WQvoU9tuTzAMjjl/h3q fx+Uqbf05jAwaBQ44Os3PJsfcF3ZTM4jP/6HTa641vlE1svletv48vj42c8E/cxdYUDqBHPTfZ0 MwV7AO8Vo4ZyurljoVFgwpHRlb/TAlHpBAm3Qj3XVmmwBDEp0OWxWbdS+wBvj/hC0hrm3tJq5nM B3sRYKYloQS/JwSyIHSnseqLI2JkLDvX/kPnJzl3Ki9QU5TZsEguPAo3LeXp55CizWNmpO1AdhE wvizaO5B1/pOq2mr3pR7UantGaakeofHJePBB8vnfILW8+noiZ2ztbewNHdnJuUwVIFAVb/UbZx RNJGT9kxcrRs8IToLWw9C1Ghphd2659ldUmAvb2hQ== X-Received: by 2002:a05:600d:18:b0:488:b811:51c4 with SMTP id 5b1f17b1804b1-48e51f3c4f4mr107777795e9.25.1778169129155; Thu, 07 May 2026 08:52:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/67] target/arm: Set up pointer to GICv5 in each CPU Date: Thu, 7 May 2026 16:51:02 +0100 Message-ID: <20260507155154.1886557-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169529031158500 The qdev link property array gives the IRS a pointer to each CPU that is connected to it, but the CPU also needs a pointer to the IRS so that it can issue commands. Set this up in a similar way to how we do it for the GICv3: have the GIC's realize function call gicv5_set_gicv5state() to set a pointer in the CPUARMState. The CPU will only allow this link to be made if it actually implements the GICv5 CPU interface; it will be the responsibility of the board code to configure the CPU to have a GICv5 cpuif if it wants to connect a GICv5 to it. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-16-peter.maydell@linaro.org --- hw/intc/arm_gicv5_common.c | 9 +++++++++ include/hw/intc/arm_gicv5_stream.h | 32 ++++++++++++++++++++++++++++++ target/arm/cpu.c | 16 +++++++++++++++ target/arm/cpu.h | 2 ++ 4 files changed, 59 insertions(+) create mode 100644 include/hw/intc/arm_gicv5_stream.h diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 29cc96917e..98a432af33 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -8,6 +8,7 @@ =20 #include "qemu/osdep.h" #include "hw/intc/arm_gicv5_common.h" +#include "hw/intc/arm_gicv5_stream.h" #include "hw/core/qdev-properties.h" #include "qapi/error.h" #include "trace.h" @@ -127,6 +128,14 @@ static void gicv5_common_realize(DeviceState *dev, Err= or **errp) return; } =20 + for (int i =3D 0; i < cs->num_cpus; i++) { + if (!gicv5_set_gicv5state(cs->cpus[i], cs)) { + error_setg(errp, + "CPU %d does not implement GICv5 CPU interface", i); + return; + } + } + address_space_init(&cs->dma_as, cs->dma, "gicv5-sysmem"); =20 trace_gicv5_common_realize(cs->irsid, cs->num_cpus, diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h new file mode 100644 index 0000000000..7257ddde90 --- /dev/null +++ b/include/hw/intc/arm_gicv5_stream.h @@ -0,0 +1,32 @@ +/* + * Interface between GICv5 CPU interface and GICv5 IRS + * Loosely modelled on the GICv5 Stream Protocol interface documented + * in the GICv5 specification. + * + * Copyright (c) 2025 Linaro Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_INTC_ARM_GICV5_STREAM_H +#define HW_INTC_ARM_GICV5_STREAM_H + +#include "target/arm/cpu-qom.h" + +typedef struct GICv5Common GICv5Common; + +/** + * gicv5_set_gicv5state + * @cpu: CPU object to tell about its IRS + * @cs: the GIC IRS it is connected to + * + * 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 + * connected to. + * + * Returns true on success, false if the CPU doesn't implement the + * GICv5 CPU interface. + */ +bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs); + +#endif diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 10feb639c4..de9ba141bd 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -39,6 +39,7 @@ #if !defined(CONFIG_USER_ONLY) #include "hw/core/loader.h" #include "hw/core/boards.h" +#include "hw/intc/arm_gicv5_stream.h" #ifdef CONFIG_TCG #include "hw/intc/armv7m_nvic.h" #endif /* CONFIG_TCG */ @@ -1157,6 +1158,21 @@ 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) +{ + /* + * Set this CPU's gicv5state pointer to point to the GIC that we are + * connected to. + */ + if (!cpu_isar_feature(aa64_gcie, cpu)) { + return false; + } + cpu->env.gicv5state =3D cs; + return true; +} +#endif + uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz) { uint32_t Aff1 =3D idx / clustersz; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0b9755533b..91cb2b87f0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -811,6 +811,8 @@ 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; #else /* CONFIG_USER_ONLY */ /* For usermode syscall translation. */ bool eabi; --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169162; cv=none; d=zohomail.com; s=zohoarc; b=YAEpymIvofuCJMx4ytI0FacFjOnKKnDbXHWxtFckPsvI7+eoicWCSK2q/qi9TfQwcrVAP05mLL7N+gG+nmXEJi3PeuPake1YzvM1fSx5Hts055hvpHEgOg9g6yvUeFNZijyIJJFOX8fT4EI+MoZLKKT1dmWl34SevKOUwWAoo+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169162; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Cx6UY6cjzbWmySFBTXHxdQbyXCke8Db8bSXKc5mfifE=; b=McCnWdLqk9WY/PhdKd7XDzrli8lVAkEwDZe/91NmbOO1V4pbKHaNJ57JjntAicq4/MBOKXK39/WmlVhGGDgKIm6E2q4RlQGBYJXPBfN3/e0SaAKSEWqpCtOg5RG1Z7E9rTaiErx2nVRmSz9LvFc209m+nbyrhcbCZSPnrDh7/kU= 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 1778169162127987.7335340966313; Thu, 7 May 2026 08: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 1wL11M-0003VJ-C5; Thu, 07 May 2026 11:52: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 1wL11K-0003UN-6K for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:14 -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 1wL11I-0003pv-8z for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:13 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-488e1a8ac40so10270865e9.2 for ; Thu, 07 May 2026 08:52:11 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169131; x=1778773931; 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; bh=Cx6UY6cjzbWmySFBTXHxdQbyXCke8Db8bSXKc5mfifE=; b=yjpfGEdr4ji+tOZ0xsu7AN8R1/X30k27oFXlPAu0T4+xn/82tTwI7VAchpAxcg9X9C JVOQQvGvahNt66VxKG5XgJfiD50BcKu597M8O8XkBYOJOlaEkiGzOrGCqf5ItvCZIsUg LTKg+7VFVdSxHd4fDXujbsU5VTT9heMHPGUB46L8YNt8xqvZUrnnGRV5AYNGJaAkGaQ8 qTEH6x0ZPn3udGJeqJ+rwxeYqGxyG7EPWpRk+WQfuwYTgMPeLTvDJqrqUyl17A5KznKh UF5J/CgluJY9gCcLPIjeUaDLvjdejSsu10lg3ZH8pectFul0rOfZ6nvhsz1b5PE4G1WU TxCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169131; x=1778773931; 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; bh=Cx6UY6cjzbWmySFBTXHxdQbyXCke8Db8bSXKc5mfifE=; b=A2xDGkLOW7sgJ0xicYDHuKwrMlcXEyBpB5rzLO43DQJTyqIByRA4DPwzzt6w26M1HR Fl6VwENZjox7KKmQTzRb6zuLzmmVasYwWi2wmATWy7q7kD/PgEN8XOdaMS0bvCi5V+Qu 94QF5DeSrMKy7UMLMFuCel+TAM6F4sP6eQLWiBmr0fb6REqG39K3TS+x/pjdwEG0Xlzp FDZyhx89rpPIExELnTyuks48E09Z50R2S2K/hAbFnj52fzIX9gkcM5+NvJOp2mR04ISt zdIphEGDGGshJVJOUBnMkuqleQexGhLKyDY4L53u0CLJWZEZiSMF301XE4Cw7csAv/nt UV1Q== X-Gm-Message-State: AOJu0YzjcOqXX6/xzMGQOdEg6urAHKHB6FAa8IFuD6sxE6pIjYbu2Fek Vf8122O/ps8sUNRSi3rVjYkSkejfn/Nku0vnRbFfvHQ2EH7ccbFXZR+nvGz3b9HTgt5hUKhvliI S1Fuh X-Gm-Gg: AeBDietaxZhHGeExbtGiqDMW9T3V1npCa7xQ8zB4/ph9gFYscbH+Q7/XFFhcZMJw4B7 8DD+QFU6jpG3nDXwEWy9EjlsAh1jstpt2Tj4EvQO/J6GK7Cfputr0eSzWDNwrqyqXzcnL6+so3H YpqHp9UjHDtSZalqEsK8iVcDqwtDQWFS5I3sDA9LfFLG+xE9fCqMbem6aEBGdsQ3qGMYM6aVU83 T4JZ8xxk+s4tfbS0ukV93MSEvPnX0QoYLO9fLQzZ7+gmX6bC2Pqs0xE5hS7gjBf6Q8dd0euDdsz E00pFNAHsULPQkyHla7dGDC881hw06+Hghff+uztqCkMRvu0SxuhiYRIqGOZXZ+g3GuwSrFsyy2 ZDI0HiDvExiejnnmQ1NSc0MTxf6fpC6NNuzyhJpy8hHJbS9qGlF853MazXyJN4BhBylJHJ8ev82 oAMRh4HkF7ujek2c5OBo3cGBSS2ABUnAHd08g+I+sN10rFTdKhWP/4CgPrxr0pUFHJgM8MrO/m6 /l7FrvG6vk5OkW84VhUte2SmpswGuI= X-Received: by 2002:a05:600c:83c5:b0:488:c683:be89 with SMTP id 5b1f17b1804b1-48e51f2a759mr124213765e9.9.1778169130669; Thu, 07 May 2026 08:52:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/67] hw/intc/arm_gicv5: Implement IRS_IST_{BASER, STATUSR, CFGR} Date: Thu, 7 May 2026 16:51:03 +0100 Message-ID: <20260507155154.1886557-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169165605154100 Content-Type: text/plain; charset="utf-8" Implement the three registers that handle configuration of the interrupt status table for physical LPIs: * IRS_IST_BASER holds the base address of the table, and has the VALID bit that tells the IRS to start using the config * IRS_IST_CFGR has all the other config data for the table * IRS_IST_STATUSR has the IDLE bit that tells software when updates to IRS_IST_BASER have taken effect Implement these registers. Note that neither BASER nor CFGR can be written when VALID =3D=3D 1, except to clear the VALID bit. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-17-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 74 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 4 ++ include/hw/intc/arm_gicv5_common.h | 3 ++ 3 files changed, 81 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 250925f004..cbb35c0270 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -265,6 +265,24 @@ REG64(IRS_SWERR_SYNDROMER0, 0x3c8) REG64(IRS_SWERR_SYNDROMER1, 0x3d0) FIELD(IRS_SWERR_SYNDROMER2, ADDR, 3, 53) =20 +static void irs_ist_baser_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) +{ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + + if (FIELD_EX64(cs->irs_ist_baser[domain], IRS_IST_BASER, 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) { + /* Ignore 1->1 transition */ + return; + } + cs->irs_ist_baser[domain] =3D FIELD_DP64(cs->irs_ist_baser[domain], + IRS_IST_BASER, VALID, valid= ); + return; + } + cs->irs_ist_baser[domain] =3D value; +} + static bool config_readl(GICv5 *s, GICv5Domain domain, hwaddr offset, uint64_t *data, MemTxAttrs attrs) { @@ -325,6 +343,26 @@ static bool config_readl(GICv5 *s, GICv5Domain domain,= hwaddr offset, 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 + * instantaneously, and the guest can never see the IDLE bit as 0. + */ + *data =3D R_IRS_IST_STATUSR_IDLE_MASK; + return true; + + case A_IRS_IST_CFGR: + *data =3D cs->irs_ist_cfgr[domain]; + return true; } =20 return false; @@ -333,18 +371,54 @@ static bool config_readl(GICv5 *s, GICv5Domain domain= , hwaddr offset, static bool config_writel(GICv5 *s, GICv5Domain domain, hwaddr offset, uint64_t data, MemTxAttrs attrs) { + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + + switch (offset) { + case A_IRS_IST_BASER: + irs_ist_baser_write(s, domain, + deposit64(cs->irs_ist_baser[domain], 0, 32, da= ta)); + return true; + case A_IRS_IST_BASER + 4: + irs_ist_baser_write(s, domain, + 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)) { + 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]); + } else { + cs->irs_ist_cfgr[domain] =3D data; + } + return true; + } + return false; } =20 static bool config_readll(GICv5 *s, GICv5Domain domain, hwaddr offset, uint64_t *data, MemTxAttrs attrs) { + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + + switch (offset) { + case A_IRS_IST_BASER: + *data =3D cs->irs_ist_baser[domain]; + return true; + } + return false; } =20 static bool config_writell(GICv5 *s, GICv5Domain domain, hwaddr offset, uint64_t data, MemTxAttrs attrs) { + switch (offset) { + case A_IRS_IST_BASER: + irs_ist_baser_write(s, domain, data); + return true; + } + return false; } =20 diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 98a432af33..21b40c35a5 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -60,6 +60,10 @@ void gicv5_common_init_irqs_and_mmio(GICv5Common *cs, =20 static void gicv5_common_reset_hold(Object *obj, ResetType type) { + GICv5Common *cs =3D ARM_GICV5_COMMON(obj); + + memset(cs->irs_ist_baser, 0, sizeof(cs->irs_ist_baser)); + memset(cs->irs_ist_cfgr, 0, sizeof(cs->irs_ist_cfgr)); } =20 static void gicv5_common_init(Object *obj) diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index e7220b9dc7..19e1af8ceb 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -64,6 +64,9 @@ struct GICv5Common { =20 MemoryRegion iomem[NUM_GICV5_DOMAINS]; =20 + uint64_t irs_ist_baser[NUM_GICV5_DOMAINS]; + uint32_t irs_ist_cfgr[NUM_GICV5_DOMAINS]; + /* Bits here are set for each physical interrupt domain implemented */ uint8_t implemented_domains; =20 --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169277; cv=none; d=zohomail.com; s=zohoarc; b=Zcggr4DcRCdbm3cb8xltloVgEm2h6hsw1BURtQ3jzGEbOhvdO3dlvnjyWDrend2cRaiQy8ter1Rrw5emQei+zN9MbNCBM1SlDII8g9FEaUSROayavsRx6bAWp4OPQN9lsrpWdPJgDYgm1uo06FAJ1g7r9WxebNxavUbQwC6qH7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169277; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=UphOHpAU41SGo+BRs+5Ac7zYOlOWgurjrB9SfekNuz4=; b=S803EZau+i5sZ7L//y0DswUWkLcSOIAvbZpekaJKYfE5ishTw92yIvfivD6s0IYh2fb74DYWHOigJJ77uEaKGgqoWO9OhhjWYEW+wZ+XmdwBTDxYsZY9zHcUoF9X80GryWUEzr0LXlwUXYAWPzxLipnieStUgugcmWGHl0NJ4gA= 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 1778169277320939.353692533502; Thu, 7 May 2026 08:54:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11O-0003Yt-Jx; Thu, 07 May 2026 11:52: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 1wL11M-0003Vj-Qr for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:16 -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 1wL11K-0003qi-UJ for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:16 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4891c0620bcso8103235e9.1 for ; Thu, 07 May 2026 08:52:14 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169133; x=1778773933; 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; bh=UphOHpAU41SGo+BRs+5Ac7zYOlOWgurjrB9SfekNuz4=; b=bjSGuJ1sJYipsL1asOYJn8sR8muOTv8mil4WzVmz8OLOZSTkh0Febg4lRfedOMKQFI 0hFAz1mXzsedbv7w81saP2VIgX+TiV+fWzzp1mXoPzTQrlpW/0Zlo9I31hAwTPobhSqA +IN2u2fQUcsx0jCJDREY2hRWiCHgputAL7NZGd1D7Cu9mJpQi9Bqq/eoh5bKmoqoZaj0 G9A7btaiZVn+v5tSGLtNFbySABcGCqtZKeBGPacHKWhWiC5IdWu17MQgWFQSztwd+V+8 asKy4P/XILSLCR4qeLcuCA7PPsnespIoFgNaVBXDFX0mkCBuA0P4qIaxTTQjSIgpSut7 Ijeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169133; x=1778773933; 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; bh=UphOHpAU41SGo+BRs+5Ac7zYOlOWgurjrB9SfekNuz4=; b=cm+MdlBIlHzztq1DeWKrgryVcy4ug5fV4qZKdPhMsmUyyxyNt9z1kpnBqR87RGFuds sEXSbi87wSVMLFFxe1S9NrgvHio4J1NabFjsnQuZ88k+wHA2Nlk6oKp2xX6uJDPPB3R9 p8ojzmHkQXh2RXx2qP1LqWnW2JjUNiuXzHofjlBE/b4sRvlytaI3Ra7ltodEOx+RxKHk re+BDkLDaBBIpKNPoZJDqoLwse8plVMzF0Upy1Oi3nbNbLNPG87yruu/2oCa7yTmclXk THGHsih+1gUcbxOUVgu5vqTf0Uy+TifbvKng1Tzo8eYaw7/d1PWDTFXm1zm6VCQ63RIA kpBQ== X-Gm-Message-State: AOJu0YwelrwlbAvKz9kr42Xi0b+Cr1pXDwBO34X9v31+C/wLLjnw59Jn 6CCFlM7a48s2eEx/StTL3xSQY6yw/r+kAddGfqiGq/S58iLU6qHRT+6+DyYMeWNxG2E0dkbu7DU Muq1E X-Gm-Gg: AeBDiesUTsieSXSAlkM5FB19PEV7Iqi48Kumuwn8NuiAfOwisztnKX40ZVaFVOcScVq YdVgQQQ5TqaFTLfHFAwUM2+Iru/04gSAbHKjYnTVtf/Iitkm8yg4F7kFMJ91f5670fMsOQ3UWpo A/FOp1SHEQvH8z2NHt3AGK5xY9nkGb+EWBDrZ2y4n2qXJ63HISlSzwN1EqYXt3fn5Axy1nNDAfM HIBfpD9nLXUyMu9LxAxqKB3uhNeBLoWomn4AH4uAEbiNP3oVfgLRcJo4cnYH/yslfmt4f/WVhNA FkFbSmC9PREtSnKtC0SVSoYnu2ULh6WZz5J5elKiTQR/UI2SKuamRMlEnjbmcGNjjE7GsMty99O pCUtOx/N8dg4pmMLhbrl01LFJ5hZfRpDn8ZyJSj3nZ8N7VVuz0FYS6Zx519T+7j0aRt1v42pAEe bOlBmEMEk0qoY4BLBl3PeRewOSAk9brikZAUYoGDUWi7FxMUgu8vH+6TjRgPM2w92HhMKoYNcDq VYBW3hA0bD+mREFEB61YrYrier8TwQOKUuOBfWhww== X-Received: by 2002:a05:600c:1d11:b0:488:a916:14a8 with SMTP id 5b1f17b1804b1-48e51f2c7eemr137191935e9.10.1778169133304; Thu, 07 May 2026 08:52:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/67] hw/intc/arm_gicv5: Cache LPI IST config in a struct Date: Thu, 7 May 2026 16:51:04 +0100 Message-ID: <20260507155154.1886557-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169279258154100 Content-Type: text/plain; charset="utf-8" The IRS has multiple ISTs, for different contexts: * physical LPIs (separately for each interrupt domain) * virtual LPIs * virtual SPIs The config information for physical LPIs is in the IRS_IST_BASER and IRS_IST_CFGR registers; for virtual LPIs and virtual SPIs it will be in the L2_VMTE VM table entry. We would like to be able to write generic code that can manipulate any of these ISTs. Define a struct which captures the config information for an IST, and cache the IRS_IST_CFGR/IRS_IST_BASER data into this format when the guest sets the VALID bit. This also allows us to enforce the correct handling of reserved and out-of-range values, and expand the encodings of sizes into a more convenient format for later use. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-18-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 64 +++++++++++++++++++++++++++++++++++++ hw/intc/trace-events | 2 ++ include/hw/intc/arm_gicv5.h | 12 +++++++ 3 files changed, 78 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index cbb35c0270..172c5be0d4 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -278,9 +278,68 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain = domain, uint64_t value) } cs->irs_ist_baser[domain] =3D FIELD_DP64(cs->irs_ist_baser[domain], IRS_IST_BASER, VALID, valid= ); + s->phys_lpi_config[domain].valid =3D false; + trace_gicv5_ist_invalid(domain_name[domain]); return; } cs->irs_ist_baser[domain] =3D value; + + if (FIELD_EX64(cs->irs_ist_baser[domain], IRS_IST_BASER, VALID)) { + /* + * If the guest just set VALID then capture data into config struc= t, + * 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; + 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->id_bits =3D id_bits; + cfg->istsz =3D 1 << istbits; + cfg->l2_idx_bits =3D l2_idx_bits; + cfg->structure =3D FIELD_EX64(cs->irs_ist_cfgr[domain], + IRS_IST_CFGR, STRUCTURE); + cfg->valid =3D true; + trace_gicv5_ist_valid(domain_name[domain], cfg->base, cfg->id_bits, + cfg->l2_idx_bits, cfg->istsz, cfg->structure= ); + } } =20 static bool config_readl(GICv5 *s, GICv5Domain domain, hwaddr offset, @@ -553,6 +612,11 @@ static void gicv5_reset_hold(Object *obj, ResetType ty= pe) if (c->parent_phases.hold) { c->parent_phases.hold(obj, type); } + + /* IRS_IST_BASER and IRS_IST_CFGR reset to 0, clear cached info */ + for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { + s->phys_lpi_config[i].valid =3D false; + } } =20 static void gicv5_set_idregs(GICv5Common *cs) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 0797a23c1a..80fc47794b 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -233,6 +233,8 @@ gicv5_badread(const char *domain, uint64_t offset, unsi= gned size) "GICv5 IRS %s gicv5_write(const char *domain, uint64_t offset, uint64_t data, unsigned s= ize) "GICv5 IRS %s config frame write: offset 0x%" PRIx64 " data 0x%" PRIx6= 4 " size %u" gicv5_badwrite(const char *domain, uint64_t offset, uint64_t data, unsigne= d size) "GICv5 IRS %s config frame write: offset 0x%" PRIx64 " data 0x%" PR= Ix64 " size %u: error" gicv5_spi(uint32_t id, int level) "GICv5 SPI ID %u asserted at level %d" +gicv5_ist_valid(const char *domain, uint64_t base, uint8_t id_bits, uint8_= t l2_idx_bits, uint8_t istsz, bool structure) "GICv5 IRS %s IST now valid: = base 0x%" PRIx64 " id_bits %u l2_idx_bits %u IST entry size %u 2-level %d" +gicv5_ist_invalid(const char *domain) "GICv5 IRS %s IST 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.h b/include/hw/intc/arm_gicv5.h index 42ccef8474..f6ecd9c323 100644 --- a/include/hw/intc/arm_gicv5.h +++ b/include/hw/intc/arm_gicv5.h @@ -17,11 +17,23 @@ =20 OBJECT_DECLARE_TYPE(GICv5, GICv5Class, ARM_GICV5) =20 +typedef struct GICv5ISTConfig { + hwaddr base; /* Base address */ + 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 */ + bool structure; /* true if using 2-level table */ + bool valid; /* true if this table is valid and usable */ +} GICv5ISTConfig; + /* * This class is for TCG-specific state for the GICv5. */ struct GICv5 { GICv5Common parent_obj; + + /* This is the info from IRS_IST_BASER and IRS_IST_CFGR */ + GICv5ISTConfig phys_lpi_config[NUM_GICV5_DOMAINS]; }; =20 struct GICv5Class { --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169531; cv=none; d=zohomail.com; s=zohoarc; b=nqvVIDpwkoLu6aZYQ8dvOZUw2Hv3emPWIY9+mDAkdRbBOhysFgMhjHJeNWpWotyMo7FaEgdtIlS+rw2lPczH9003ucocJ8HpUV66nrPFdCIpd71AVz1XO2I3jJIVWkA/Pyiuk7xqFPqJiXgkOMF0HKWOXiqQKcET1hUugYgivNg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169531; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=DHnfHjOni2hXu8OSZkkvhKl8mPsGzGNAFhD/XpzNrl8=; b=WHBT1ClvA1EOsFKfrbxTZ22KOCBGmRX4dcfVCgG9ui4DRfLMhaWw/ND+3ROTwewnCYXqWioIR4dx2N1PSbLrW3g9BziCgRSryM8eX5Gmc0Bm2CAuN5gv+A9Gv+RbwnISjZZhDwnVikYf/Sll4fiP6KlJYojb1koZOGvFHAiZvus= 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 1778169531754454.71562886610104; Thu, 7 May 2026 08:58:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11R-0003b6-JA; Thu, 07 May 2026 11:52: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 1wL11O-0003Z8-SW for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:19 -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 1wL11M-0003qy-DZ for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:18 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4891f625344so12048675e9.0 for ; Thu, 07 May 2026 08:52:15 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169135; x=1778773935; 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; bh=DHnfHjOni2hXu8OSZkkvhKl8mPsGzGNAFhD/XpzNrl8=; b=bdVhxkeI3HcFeGEIbc2qMpcYEIgY4gKqJ92xYU5ZKfs5zE3YRwvvaVEclw9CgXMixr dSR6tZ2xRjuypB0qfboCBv6SjeajdDwYLJUuvthittBHLCTg1UvcB1uzQrGq6Ao+/tgI 0KGgd6fL8ZwVRFFFez3Tx85N5QVupus3lG7dKIa7Q+xVtVPO4HrdLGYO8o7aXNiBGncR p6AaRGlIAxvaC4YNPDne3F4EOMCrAYxlgKbxYNXBSoytMOLMxleX5+orHTBEClWldk3G eHCbjaJUKiRPUI0dZNTQBOvyk3DXZlppYSGY85OvAO+0m35PBc2ydzRTMEVuNytMO+68 GcXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169135; x=1778773935; 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; bh=DHnfHjOni2hXu8OSZkkvhKl8mPsGzGNAFhD/XpzNrl8=; b=RwI3PBeipNWX2QehDjobDFhZPtFn9Ph3j+kLT3IfE/qVrgYFwPrwTRfUYWWkLVYUQf NQMzKxoCLUVwgCxXVZUcbu2XPQh8BGOLkg/37T1dQq/znAXEWjPTSPdTpZI0mwDRw4Dm 3dmm2XfR1FXmDIe0vfMLIqYNvturC+VdOgjDtKOQUFptBwNEaITYLZWXvqTa7+IX1Y0V O8isLHdmmhXo2FDhESrljvwPxbVmnGaUWNe1IGWE3ARB4QZipYq2gpNh3QsPRLmD26I3 dhd0nPY8a8gRfvg6qv/TDFpCShIOYi7qIz55RDMNPN2ZGEgysMhEhDE25el1demW3+vd ir6A== X-Gm-Message-State: AOJu0YyyyeV/6fY0fIBT6pBAM7gnggZ7yxMcodPYACkXYYxN7sgVCMZi iyMzF9pr9+5L+cJ9layMeCemEb0Tg3xNsoQp3v9luwemSylXvgAe7NdnUYcYoZtb3h0vn1qe37u APULq X-Gm-Gg: AeBDieuJrmcCQ4AcQ1UpbU9qWDKQKI5OiTXcx7kFEIU8kgjR4rvxUUjsWfDuNoCzE+8 6/wgt10eyUE7ktCxrFcuiGBXrVYVCYfI/HqNvj7Ywmv4YUltTkHjtUbp1tBkm/XuQn4Uqv68bz9 r+DDZ+rmL4t29nsDOITjO7xRJIhrE/BKaPkt29pXItm8OsH9FJEU8muRP9lVzf1mPEwhDcQHuIG x/c+yhEG97Qq/c0JNbavudv6qiFFR+pzuq2KfXvPXWGZtwcB5ajcbngFOwWfKCAcyH8yO7wJWXO zknEj6ng/cyI1Zyylzh4qTd78mAApWqFBDiqnPBqPPv8qvGMkB/Rs1DjUGoiw4GUF58QJD7hu0M AFbHyhnar78vmGPBMgO9ZVWbvqeW5h6gRpZQ0+01BDIejCxghS4UH4hDhT1EY6emZ85ywx3W/P6 3kl5WXeuHgKcDhidbzSzDAelc8h3jXX9dn8jdipS/0Yk9UU3i1ihY6IEToAt5Ql/zBh9Bp57sTD wl5Xmfyt2o+w8Ko2bQob2MYWGQaoO8= X-Received: by 2002:a05:600c:4f08:b0:48a:79d8:a8d6 with SMTP id 5b1f17b1804b1-48e6391c7e4mr5254385e9.7.1778169134684; Thu, 07 May 2026 08:52:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/67] hw/intc/arm_gicv5: Implement gicv5_set_priority() Date: Thu, 7 May 2026 16:51:05 +0100 Message-ID: <20260507155154.1886557-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169533129158500 Content-Type: text/plain; charset="utf-8" Implement the gicv5_set_priority() function, which is our equivalent of the Stream Protocol SetPriority command. This acts by looking the interrupt ID up in the Interrupt State Table and storing the new priority value into the table entry. The memory transaction has to have the right transaction attributes for the domain it is for; we precalculate these and keep them in the GICv5ISTConfig. The GIC has an optional software-error reporting mechanism via the IRS_SWERR_* registers; this does not report all failure cases, only those that would be annoying to detect and debug in some other way. We choose not to implement this, but include some comments for reportable error cases for future reference. Our LOG_GUEST_ERROR logging is a superset of this. At this point we implement only handling of SetPriority for LPIs; we will add SPI handling in a later commit. Virtual interrupts aren't supported by this initial EL1-only GICv5 implementation. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-19-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 233 +++++++++++++++++++++++++++++ hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5.h | 1 + include/hw/intc/arm_gicv5_stream.h | 29 ++++ include/hw/intc/arm_gicv5_types.h | 10 ++ 5 files changed, 274 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 172c5be0d4..3588f3323f 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "hw/core/registerfields.h" #include "hw/intc/arm_gicv5.h" +#include "hw/intc/arm_gicv5_stream.h" #include "qapi/error.h" #include "qemu/log.h" #include "trace.h" @@ -23,6 +24,25 @@ static const char *domain_name[] =3D { [GICV5_ID_REALM] =3D "Realm", }; =20 +static const char *inttype_name(GICv5IntType t) +{ + /* + * We have to be more cautious with getting human readable names + * for a GICv5IntType for trace strings than we do with the domain + * enum, because here the value can come from a guest register + * field. + */ + static const char *names[] =3D { + [GICV5_PPI] =3D "PPI", + [GICV5_LPI] =3D "LPI", + [GICV5_SPI] =3D "SPI", + }; + if (t >=3D ARRAY_SIZE(names) || !names[t]) { + return "RESERVED"; + } + return names[t]; +} + REG32(IRS_IDR0, 0x0) FIELD(IRS_IDR0, INT_DOM, 0, 2) FIELD(IRS_IDR0, PA_RANGE, 2, 4) @@ -265,6 +285,218 @@ REG64(IRS_SWERR_SYNDROMER0, 0x3c8) REG64(IRS_SWERR_SYNDROMER1, 0x3d0) FIELD(IRS_SWERR_SYNDROMER2, ADDR, 3, 53) =20 +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) + +static MemTxAttrs irs_txattrs(GICv5Common *cs, GICv5Domain domain) +{ + /* + * Return a MemTxAttrs to use for IRS memory accesses. IRS_CR1 + * has the usual Arm cacheability/shareability attributes, but + * QEMU doesn't care about those. All we need to specify here is + * the correct security attributes, which depend on the interrupt + * domain. Conveniently, our GICv5Domain encoding matches the + * ARMSecuritySpace one (because both follow an architecturally + * specified field). The exception is that the EL3 domain must be + * Secure instead of Root if we don't implement Realm. + */ + if (domain =3D=3D GICV5_ID_EL3 && + !gicv5_domain_implemented(cs, GICV5_ID_REALM)) { + domain =3D GICV5_ID_S; + } + return (MemTxAttrs) { + .space =3D domain, + .secure =3D domain =3D=3D GICV5_ID_S || domain =3D=3D GICV5_ID_EL3, + }; +} + +static hwaddr l1_iste_addr(GICv5Common *cs, const GICv5ISTConfig *cfg, + uint32_t id) +{ + /* + * In a 2-level IST configuration, return the address of the L1 + * IST entry for this interrupt ID. The bottom 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. + */ + uint32_t l1_index =3D id >> cfg->l2_idx_bits; + return cfg->base + (l1_index * 8); +} + +static bool get_l2_iste_addr(GICv5Common *cs, const GICv5ISTConfig *cfg, + uint32_t id, hwaddr *l2_iste_addr) +{ + /* + * Get the address of the L2 interrupt state table entry for this + * interrupt. On success, fill in l2_iste_addr and return true. + * On failure, return false. + */ + hwaddr l2_base; + + if (!cfg->valid) { + return false; + } + + if (id >=3D (1 << cfg->id_bits)) { + return false; + } + + if (cfg->structure) { + /* + * 2-level table: read the L1 IST. The bottom 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. There is always + * at least one L1 table entry. + */ + hwaddr l1_addr =3D l1_iste_addr(cs, cfg, id); + uint64_t l1_iste; + MemTxResult res; + + l1_iste =3D address_space_ldq_le(&cs->dma_as, l1_addr, + cfg->txattrs, &res); + if (res !=3D MEMTX_OK) { + /* Reportable with EC=3D0x01 if sw error reporting implemented= */ + qemu_log_mask(LOG_GUEST_ERROR, "L1 ISTE lookup failed for ID 0= x%x" + " at physical address 0x" HWADDR_FMT_plx "\n", + id, l1_addr); + return false; + } + if (!FIELD_EX64(l1_iste, L1_ISTE, VALID)) { + return false; + } + l2_base =3D l1_iste & R_L1_ISTE_L2_ADDR_MASK; + id =3D extract32(id, 0, cfg->l2_idx_bits); + } else { + /* 1-level table */ + l2_base =3D cfg->base; + } + + *l2_iste_addr =3D l2_base + (id * cfg->istsz); + return true; +} + +static bool read_l2_iste_mem(GICv5Common *cs, const GICv5ISTConfig *cfg, + hwaddr addr, uint32_t *l2_iste) +{ + MemTxResult res; + + *l2_iste =3D address_space_ldl_le(&cs->dma_as, addr, cfg->txattrs, &re= s); + if (res !=3D MEMTX_OK) { + /* Reportable with EC=3D0x02 if sw error reporting implemented */ + qemu_log_mask(LOG_GUEST_ERROR, "L2 ISTE read failed at physical " + "address 0x" HWADDR_FMT_plx "\n", addr); + } + return res =3D=3D MEMTX_OK; +} + +static bool write_l2_iste_mem(GICv5Common *cs, const GICv5ISTConfig *cfg, + hwaddr addr, uint32_t l2_iste) +{ + MemTxResult res; + + address_space_stl_le(&cs->dma_as, addr, l2_iste, cfg->txattrs, &res); + if (res !=3D MEMTX_OK) { + /* Reportable with EC=3D0x02 if sw error reporting implemented */ + qemu_log_mask(LOG_GUEST_ERROR, "L2 ISTE write failed at physical " + "address 0x" HWADDR_FMT_plx "\n", addr); + } + return res =3D=3D MEMTX_OK; +} + +/* + * This is returned by get_l2_iste() and has everything we need to do + * the writeback of the L2 ISTE word in put_l2_iste(). Currently the + * get/put functions always directly do guest memory reads and writes + * to update the L2 ISTE. In a future commit we will add support for a + * cache of some of the ISTE data in a local hashtable; the APIs are + * designed with that in mind. + */ +typedef struct L2_ISTE_Handle { + hwaddr l2_iste_addr; + uint32_t l2_iste; +} L2_ISTE_Handle; + +static uint32_t *get_l2_iste(GICv5Common *cs, const GICv5ISTConfig *cfg, + uint32_t id, L2_ISTE_Handle *h) +{ + /* + * Find the L2 ISTE for the interrupt @id. + * + * We return a pointer to the ISTE: the caller can freely read and + * modify the uint64_t pointed to to update the ISTE. If the + * caller modifies the L2 ISTE word, it must call put_l2_iste(), + * passing it @h, to write back the ISTE. If the caller is only + * reading the L2 ISTE, it does not need to call put_l2_iste(). + * + * We fill in @h with information needed for put_l2_iste(). + * + * If the ISTE could not be read (typically because of a memory + * error), return NULL. + */ + if (!get_l2_iste_addr(cs, cfg, id, &h->l2_iste_addr) || + !read_l2_iste_mem(cs, cfg, h->l2_iste_addr, &h->l2_iste)) { + return NULL; + } + return &h->l2_iste; +} + +static void put_l2_iste(GICv5Common *cs, const GICv5ISTConfig *cfg, + L2_ISTE_Handle *h) +{ + /* + * Write back the modified L2_ISTE word found with get_l2_iste(). + * Once this has been called the L2_ISTE_Handle @h and the pointer + * to the L2 ISTE word are no longer valid. + */ + write_l2_iste_mem(cs, cfg, h->l2_iste_addr, h->l2_iste); +} + +void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, + GICv5Domain domain, GICv5IntType type, bool virtua= l) +{ + GICv5 *s =3D ARM_GICV5(cs); + + trace_gicv5_set_priority(domain_name[domain], inttype_name(type), virt= ual, + id, priority); + /* We must ignore unimplemented low-order priority bits */ + priority &=3D MAKE_64BIT_MASK(5 - QEMU_GICV5_PRI_BITS, QEMU_GICV5_PRI_= BITS); + + if (virtual) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_priority: tried to set " + "priority of a virtual interrupt\n"); + 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); + + if (!l2_iste_p) { + return; + } + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, PRIORITY, priority); + put_l2_iste(cs, cfg, &h); + break; + } + default: + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_priority: tried to set " + "priority of bad interrupt type %d\n", type); + return; + } +} + static void irs_ist_baser_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); @@ -331,6 +563,7 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain d= omain, uint64_t value) */ 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; diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 80fc47794b..42f5e73d54 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -235,6 +235,7 @@ gicv5_badwrite(const char *domain, uint64_t offset, uin= t64_t data, unsigned size gicv5_spi(uint32_t id, int level) "GICv5 SPI ID %u asserted at level %d" gicv5_ist_valid(const char *domain, uint64_t base, uint8_t id_bits, uint8_= t l2_idx_bits, uint8_t istsz, bool structure) "GICv5 IRS %s IST now valid: = base 0x%" PRIx64 " id_bits %u l2_idx_bits %u IST entry size %u 2-level %d" 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" =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 f6ecd9c323..c631ecc3e8 100644 --- a/include/hw/intc/arm_gicv5.h +++ b/include/hw/intc/arm_gicv5.h @@ -19,6 +19,7 @@ OBJECT_DECLARE_TYPE(GICv5, GICv5Class, ARM_GICV5) =20 typedef struct GICv5ISTConfig { hwaddr base; /* Base address */ + MemTxAttrs txattrs; /* TX attrs to use for this table */ 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 */ diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index 7257ddde90..e1649cbb40 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -12,6 +12,7 @@ #define HW_INTC_ARM_GICV5_STREAM_H =20 #include "target/arm/cpu-qom.h" +#include "hw/intc/arm_gicv5_types.h" =20 typedef struct GICv5Common GICv5Common; =20 @@ -29,4 +30,32 @@ typedef struct GICv5Common GICv5Common; */ bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs); =20 +/* + * The architected Stream Protocol is asynchronous; commands can be + * initiated both from the IRS and from the CPU interface, and some + * require acknowledgement. For QEMU, we simplify this because we know + * that in the CPU interface code we hold the BQL and so our IRS model + * is not going to be busy; when we send commands from the CPUIF + * ("upstream commands") we can model this as a synchronous function + * call whose return corresponds to the acknowledgement of a completed + * command. + */ + +/** + * gicv5_set_priority + * @cs: GIC IRS to send command to + * @id: interrupt ID + * @priority: priority to set + * @domain: interrupt Domain to act on + * @type: interrupt type (LPI or SPI) + * @virtual: true if this is a virtual interrupt + * + * Set priority of an interrupt; matches stream interface SetPriority + * command from CPUIF to IRS. There is no report back of + * success/failure to the CPUIF in the protocol. + */ +void gicv5_set_priority(GICv5Common *cs, uint32_t id, + uint8_t priority, GICv5Domain domain, + GICv5IntType type, bool virtual); + #endif diff --git a/include/hw/intc/arm_gicv5_types.h b/include/hw/intc/arm_gicv5_= types.h index 7d23752ece..e2b937fe62 100644 --- a/include/hw/intc/arm_gicv5_types.h +++ b/include/hw/intc/arm_gicv5_types.h @@ -45,4 +45,14 @@ typedef enum GICv5Domain { #define GICV5_PPI_CNTP 30 #define GICV5_PPI_TRBIRQ 31 =20 +/* + * Type of the interrupt; these values match the 3-bit format + * specified in the GICv5 spec R_GYVWB. + */ +typedef enum GICv5IntType { + GICV5_PPI =3D 1, + GICV5_LPI =3D 2, + GICV5_SPI =3D 3, +} GICv5IntType; + #endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169521; cv=none; d=zohomail.com; s=zohoarc; b=YXUPJyK+rO+6yR5reDCxeet/6wA60DcjV6MFLnrf0+lIJ0igt9EmRZ+eThSUQiG7/JzuRkYxX77TZN7FWa6XD28PNOKNwWT9tQ8HRE7YYU/sqDBPoz3N6CKuPG9TOYdrwYd4QBVafpkKMlUGUnFcg9swSeqMrreIJyXT+adkvpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169521; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=EUSOjlx+hsZVcUD1mobn1E9yNS0kI0/ZgIsz2Vr2uNk=; b=i3GUcKqpKN48MK0rA69isCKzQVNmju+O+ivpFIT3NdZoR/1fVMZZIsB9X+/U53OYr7HyM0NIS9lm1z3LyDEqdjWwtZiRa5vSByc6EN+goH/rgGsMEw9D9tvuDv7dUrgv97XzUcrSSv1Gw2wkPT/6NiEL8BLfLOoDvDZesyqRxKo= 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 1778169521989690.8897100987584; Thu, 7 May 2026 08:58:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11R-0003aV-0G; Thu, 07 May 2026 11:52: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 1wL11O-0003ZB-Tx for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:19 -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 1wL11N-0003r3-5V for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:18 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4891e86fabeso12803165e9.1 for ; Thu, 07 May 2026 08:52:16 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169136; x=1778773936; 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; bh=EUSOjlx+hsZVcUD1mobn1E9yNS0kI0/ZgIsz2Vr2uNk=; b=MupjXI4giT7GLMkendVd8G95+OwKkOkBTKiZEQHBO6Z89KEo0tr5UAg42i3byiR0S3 zCIScJBM74iD3ojewY13o0sOmvpT5LTzIkgaE0PcxHx+KpsHGdsXfTKPDF3GE7aXI/WY sWO6XiWc3KGHXUynQqj1xOGNeiSQvmKlcoMLZMRmVkYgYjAF6TqZIS2cYVUPC7bFvogf Bnk/5ToxpcrQCAQgOyB7ygv5gOZiQEN3aWatV4PPDYM5vzsTkV311R/fbcUKTPcMC3wY wFvhU5IMx+g3h4OypsJEDP7nnTEqBbaNXnKChQoEd2QRGZ5I3M1q+Wzff0q8VlKvlNcX 9BZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169136; x=1778773936; 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; bh=EUSOjlx+hsZVcUD1mobn1E9yNS0kI0/ZgIsz2Vr2uNk=; b=AO+xpOJHLF7ic9uaUvacTaN1Tqeo4AMAhDUDUa7Jmiyi9BQcswhtxNUiCdQU8nMdLN G2aUJGDhUgKxZbp62AnfHwQt5qaFCtjQMYXudqrqsLiLZJsNv87aIrlQIABIc/ydZIV8 2QcqCTrYpLpRz8q6q4DASP8wkcjYKfCoLydv3WjTpZI4ZyPrp8DwGdBmtPx2GpuFGHR+ +GOMkmM39iqkzwOXvn2HP8Iq8KODBVuVPpiaE/o8kTG52zS4A3SuafaE85fr4P0aEeDX eWsZyt6nG7kZeuH8q3FE6slcr0LAO+yfF5PFpkaHBidZ2N07Jv+WOluR3znOqkoavOdU BKVQ== X-Gm-Message-State: AOJu0YxOB0yccM/hWNR1GDhPlE7KmA7saEQQxZl1BcQA8YzglyrLO5pw T+pK+gZeVDm56Rk/zTmX3ICB8IZNb5x7RsrhWnmaEvbKZ7oSRi/6DD74pX3fX80LNJuL0aq/qkt 3hRxm X-Gm-Gg: AeBDievb6e7kOQlnZ7I36OZUch2qR4s1OlnhWWG5FRXIEMNFIHOLGr9dp1dJaE9Y3FI baqDjzgknXkDpgUIwjPtl1ICoC9Q7wXOFzqwwJK2mx0QrjhuCXHmXute164t8cKMxadBHEJ9Z0W lbDJZGlK+D2/ZZG3Ktduih0pTxJw32sMIDZ9EUY+pf3fKC0gVqw5/udIzzXH0ry3jewjtEFQz5i ZDPp8PA645Xr2KLaBzk6lpeE6SmlUC49nvZAjUTC29RK5K0orwupEVfUX/kAfLsDHhbEPx3gPUk QIb+QFg2JS+CWxKAseH8jNHMPDjzxsISF5kMOqr/vPp6GFZrvRc5+ajXGx+fKigFFfyGYEfrkfB V4G8etzuDDwCPWhDNiMU/dgV0OyhUnEtMYa43lv0R4ZZA0+npn6dhKPLRdETxZc4BPjnfC+rbkw aaB2rjwW+wP5VZq5q4VWyLipWjv4N+O0jWC7AxGQkvr4LO1tVgL45cB0SHa3ZkXpaHo4LAtr/e/ ct/ljT7XsJcP1l8ZspdmJtwZgDebK66dhc5GurBkJrCXd9xiMhp X-Received: by 2002:a05:600c:3b17:b0:489:e696:836f with SMTP id 5b1f17b1804b1-48e51e15718mr126773215e9.10.1778169135556; Thu, 07 May 2026 08:52:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/67] target/arm: GICv5 cpuif: Implement the GIC CDPRI instruction Date: Thu, 7 May 2026 16:51:06 +0100 Message-ID: <20260507155154.1886557-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169523207154100 Content-Type: text/plain; charset="utf-8" Implement the CPU interface GIC CDPRI instruction, which is a wrapper around the SetPriority operation. As with the barrier insns, we omit for the moment details which are needed when the GICv5 supports virtualization: * traps when legacy GICv3 emulation is enabled * fine-grained-trap handling (which is done via registers that are new in GICv5) * sending the command for the virtual interrupt domain when inside a guest The CD instructions operate on the Current Physical Interrupt Domain, which is the one associated with the current security state and exception level. The spec also has the concept of a Logical Interrupt Domain, which is the one associated with the security state defined by SCR_EL3.{NS,NSE}. Mostly the logical interrupt domain is used by the LD instructions, which are EL3-only; but we will also want the concept later for handling some banked registers, so we define functions for both. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-20-peter.maydell@linaro.org --- target/arm/tcg/gicv5-cpuif.c | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 7392a98c49..0c2bba5ce9 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -10,6 +10,59 @@ #include "cpu.h" #include "internals.h" #include "cpregs.h" +#include "hw/intc/arm_gicv5_stream.h" + +FIELD(GIC_CDPRI, ID, 0, 24) +FIELD(GIC_CDPRI, TYPE, 29, 3) +FIELD(GIC_CDPRI, PRIORITY, 35, 5) + +static GICv5Common *gicv5_get_gic(CPUARMState *env) +{ + return env->gicv5state; +} + +static GICv5Domain gicv5_logical_domain(CPUARMState *env) +{ + /* + * Return the Logical Interrupt Domain, which is the one associated + * with the security state selected by the SCR_EL3.{NS,NSE} bits + */ + switch (arm_security_space_below_el3(env)) { + case ARMSS_Secure: + return GICV5_ID_S; + case ARMSS_NonSecure: + return GICV5_ID_NS; + case ARMSS_Realm: + return GICV5_ID_REALM; + default: + g_assert_not_reached(); + } +} + +static GICv5Domain gicv5_current_phys_domain(CPUARMState *env) +{ + /* + * Return the Current Physical Interrupt Domain as + * defined by R_ZFCXM. + */ + if (arm_current_el(env) =3D=3D 3) { + return GICV5_ID_EL3; + } + return gicv5_logical_domain(env); +} + +static void gic_cdpri_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + GICv5Common *gic =3D gicv5_get_gic(env); + 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); + + gicv5_set_priority(gic, id, priority, domain, type, virtual); +} =20 static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* @@ -33,6 +86,11 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 0, .opc2 =3D 1, .access =3D PL1_W, .type =3D ARM_CP_NOP, }, + { .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, + .writefn =3D gic_cdpri_write, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169393; cv=none; d=zohomail.com; s=zohoarc; b=isdguefziPjnyX/8/2Rq39L+J+cCs92DHW3p5XeFMdg2SHtwWeeCBY/jll4cYmqbh97ew7gM7Bi9Ha1RUl6MTKzNfYveAwcW7L90Bdw5lgjVskzeDlG7v9nkRBNWZWt3whq3iViQEodhKlzo86R0RhkmBGXJHJeGGE7MxsNiPfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169393; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=wa/zQWHYmfpo2HdFtvc+xrKDx1KnPTTV/Qg03fMEQMw=; b=U/YPPI2kUJcIJ631X2qgtMqyADf9IHgvdgv9oJr1sXBPcj91wo3Acgw201yRudn7NlRZzYJWv+QuHKG8JO/ux1tceRNLVCOXsFMRfb86huHzaYu/b6bHtcWoegDqxGcLN5r4+2ZB8bEinbG4jaCi9aPD5zDw2iGhXqk+5TxuskI= 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 1778169393507873.3890954104761; Thu, 7 May 2026 08:56:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11S-0003bO-Cm; Thu, 07 May 2026 11:52: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 1wL11Q-0003a2-A0 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52: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 1wL11N-0003ra-S8 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:19 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-488ab2db91aso11859345e9.3 for ; Thu, 07 May 2026 08:52:17 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169136; x=1778773936; 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; bh=wa/zQWHYmfpo2HdFtvc+xrKDx1KnPTTV/Qg03fMEQMw=; b=kGvJzMz9a3mZEkN98Mo8hw/BASfD9Qo/6zcMoFBslCPEeDDjkbdp/EdQ0NG8JivVM9 apq2O87nWtghomn/TtApBg8VZh8fv0EP3ak9/Mxy2eqtSM/f5OFvhHTCsJQ1rTT2N/Hm v342ESv3IXGNkOqK2eH9h2o1PitjvdGl89H201zMNCKSPtacpXIL3qog+OGn1JvySTFX p3UXF+FN4JNSCuBeccYag+WYoTQOhggWWvlrLabZ8jrMpnpS2P9uRUI5bEkv4X/b4Ex0 H03bI1C1o0YRu5LIpKBBGIS+rK7XcxT8DC4G1i8D+X+iym0rDi3N2MgVOQ/mqcs3Uj6a Vuzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169136; x=1778773936; 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; bh=wa/zQWHYmfpo2HdFtvc+xrKDx1KnPTTV/Qg03fMEQMw=; b=DismiKZwgiq/uJK06AbaIS66UtVI5NBTewCLPJyiHiz2GD55U4EPKKqk1YR9A0IrTX 57r9Ugh8VW0eR81Z9qsxdR2TcueShQTZtKKWHILmBj/+dSethu5iwsb3QTnW9zGF888K skteI2nErF8FzR9mTVw3Gg+hXycV4mkGj0GVsWr6hpySrFSTpRX/kzIywdGRy7pP4nKI f3p+ARFrZwdliuWAGUW+vME3zBDXZNCOdUYMzR3NmJrOBpEkWUYMStK99ehlE5eNvBxK Yk05oTr8hW93kP6hxtZN4fZicQtxOVXJtCxet3vGkUrWoVHKBgt4+2ZITG40E7X8qnYS /iag== X-Gm-Message-State: AOJu0YyKT9WZ9vvbEvJ4bzoMF3O1aekkFq3h5D42rCBvDRZ9DJo3CW4m W7yx/eJ2DapOncxti92OhJe02Lr81n+dKjwNz6se0CmVw546iYlQoZTdor8RAfo6m0B8fGdu/WD kp5+O X-Gm-Gg: AeBDiet3cmPBQLIsWnhULDN+1CNGpr8ICTH9XWu9OizMhjzkYStv9pmwYDk43abQAiZ xy62wsH/uzVTDM8vpe6kiA3/8IVGpAObTOLbyBtGRWXoe9JuVqKcjPNOY+qw1fdfJ6s5DUR5VQd IMvfN2NyzYChEoCuaqpxaXuEblAUimaEAWQ02kpEu4XInDtQUQxwYvB0yhfm49jSichgjjJRj8L NeCH1bYXG1gLQI4jY9foFqvAdTXsmCTO3WQWA0gp6lytEwBIZWqArwFMrPNm7m4QVePFN4RnTh/ yhG0HHAhyHX8dcupDqCnJS0LUqLKLRifH7JoaMUAYd7/QeM8duT4mNJ9FSSprpfMW8z+oXPeNVo cTZbBabO+iVy+T1kpnhqQ0A4blUzAXWNR0q+MP+TIEoyPtpgOVguw7/YoPN6hUQLwUCJI8bBzfV 6T0o4KSttUrfsR60HjYlhVFcIQFlcWYuWRvR9Kx177gpxyOE1+oQrivgTFphtcUqYDuLeUz1G2w QbMMj++dy3akoXkm+q2BdgkJX54nKMHWm4AvAtoxA== X-Received: by 2002:a05:600c:a30d:b0:488:a2ac:a334 with SMTP id 5b1f17b1804b1-48e51e08228mr99027265e9.3.1778169136373; Thu, 07 May 2026 08:52:16 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/67] hw/intc/arm_gicv5: Implement IRS_MAP_L2_ISTR Date: Thu, 7 May 2026 16:51:07 +0100 Message-ID: <20260507155154.1886557-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169394991154100 Content-Type: text/plain; charset="utf-8" The IRS register IRS_MAP_L2_ISTR is used by software to tell the IRS that it has updated the address in an L1 IST entry to point to an L2 IST. The sequence of events here is: * software writes to L1_ISTE.L2_ADDR for some L1 ISTE which is not valid (i.e. where L1_ISTE.VALID is 0); it leaves VALID at 0 * software writes to IRS_MAP_L2_ISTR with some INTID that is inside the range for this L1 ISTE * the IRS sets IRS_IST_STATUSR.IDLE to 0 * the IRS takes note of this information * the IRS writes to the L1_ISTE to set VALID=3D1 * the IRS sets IRS_IST_STATUSR.IDLE to 1 to indicate that the update is complete For QEMU, we're strictly synchronous, so (as with IRS_IST_BASER updates) we don't need to model the IDLE transitions and can have IRS_IST_STATUSR always return IDLE=3D1. We also don't currently cache anything for ISTE lookups, so we don't need to invalidate or update anything when software makes the L2 valid. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-21-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 3588f3323f..7d654a91e6 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -497,6 +497,43 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, = uint8_t priority, } } =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); + hwaddr l1_addr; + uint64_t l1_iste; + MemTxResult res; + + if (!FIELD_EX64(cs->irs_ist_baser[domain], IRS_IST_BASER, VALID) || + !cfg->structure) { + /* WI if no IST set up or it is not 2-level */ + return; + } + + /* Find the relevant L1 ISTE and set its VALID bit */ + l1_addr =3D l1_iste_addr(cs, cfg, intid); + + l1_iste =3D address_space_ldq_le(&cs->dma_as, l1_addr, cfg->txattrs, &= res); + if (res !=3D MEMTX_OK) { + goto txfail; + } + + l1_iste =3D FIELD_DP64(l1_iste, L1_ISTE, VALID, 1); + + address_space_stq_le(&cs->dma_as, l1_addr, l1_iste, 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 ISTE update failed for ID 0x%x at " + "physical address 0x" HWADDR_FMT_plx "\n", intid, l1_add= r); +} + static void irs_ist_baser_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); @@ -683,6 +720,9 @@ static bool config_writel(GICv5 *s, GICv5Domain domain,= hwaddr offset, cs->irs_ist_cfgr[domain] =3D data; } return true; + case A_IRS_MAP_L2_ISTR: + irs_map_l2_istr_write(s, domain, data); + return true; } =20 return false; --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169372; cv=none; d=zohomail.com; s=zohoarc; b=XkcF0Aju4rDcgb4Wzoi38fpRDWqyHFTUW90ryjXAKbPBH/mK60r5aLd800lUIJ0LrWFRsJqK8zJLAuIgaPHlx7L5+2YJwwhh+pEP6V4nnOnwA9ItzXEjxm4ZaAHT4Z/GYVoYGtn273kh7mWqijZXHTn/KmAnabpKYVrIIRcCRcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169372; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=JFL5mQbQIj0i+6/A1+DWIY0c0459IXQVhpW1QSHklPY=; b=Wtv/BrygepHg+lywsae/DObVI/4BgqsMGw2aoQRctr03pzZ0FrI+3ZYt3yPi+P8yH6r32z8eY1bM83VwwqQZMcjaZJIaS8UC1+RelSwkSrBq4/Qp3qPTwiXsXw5mEUWvkaY1FUBcDVvsJr+3uxNhKzKPqDtmLLxYfeM/b+9bjCU= 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 1778169372193693.1437543991568; Thu, 7 May 2026 08:56:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11S-0003bS-TV; Thu, 07 May 2026 11:52: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 1wL11R-0003al-7m for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:21 -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 1wL11O-0003ri-Sx for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:20 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-488a9033b2cso10306105e9.2 for ; Thu, 07 May 2026 08:52:18 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169137; x=1778773937; 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; bh=JFL5mQbQIj0i+6/A1+DWIY0c0459IXQVhpW1QSHklPY=; b=x6zDJ7ozcJTqxlzLc1xfR5ZqvB1RPjK+D2nhvHHAqmsyGen5K75J9AyjCvXK1r6hMW IuvnVXngEzoGEfY98t6wOwuoFDGxgbtTnl3/PE69ieh/jEiuyp1EF20L3U9LYJIGnkRP mQ+Pt7VauyqxiJMp1BpG6bv97BcaLskM5B16SPewNStyRaQ/eeE8tgDnRbSiqJLVldkk aZaq6bbbtBBddg02UwPg4DZ5fI8SGquixS1CyD30rG6Z7PRTL4yTVnL7Nk6me2brdxtJ 07DYSI//rQbbhj5d0szxXJNmLLhvJPBWILsnlLj80NhXe/G85TIWm6oTa20leeRb+U+1 /dfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169137; x=1778773937; 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; bh=JFL5mQbQIj0i+6/A1+DWIY0c0459IXQVhpW1QSHklPY=; b=C66IlF1lXHxXBxpI3H/8lIXdHjNh2VEFwBptRNxfuKJ2PKvNaIR4TpMZZsODU6Oq4u sJyQ0FZRUsF+s4Y+Q+tbddxPdctknzvgNoOF0r1NsvgWjUoG/HVDtwxYCz9JeVHsbw8e KZykGEpgY6XcJ8XFscLBcoRf/x5TJM1pSsUD8wGPQxalblOlPImVnskuFa7zE9J7+C56 ww+KjqFaH61QFNVcwI7AUdt2GRQGko2LBGOU/eQTAwZMB71/8wEMrDNUljFe3tJ6dwFK HbNMTVkpu0s+nIsDbK3U5CNcffOsgB6TmzZGHLG0btjy2QE9Jk7ij4qHqaj9yuLLLU6h n7mQ== X-Gm-Message-State: AOJu0YyHS6QcsaQ0OWTGKeDP5rYB/7QCUDpZgFMLBP6/SrVsg65dBWmd GCAoYK+4XiPbV2ESmysufdumLoT7/f6fMX0wFykJrAGzUNinydr/Y0FMBYSKIx4e8QY6kFPH9Cy IzWVa X-Gm-Gg: AeBDietfQAMufoX94KqXibmJL1YbNDTkVxD0A7Zj74mYlM7oaFi9P8BhmoiZRHlE+qS 4Pivv2l2tpo4/n9qI+Ir8ths93LZypGnsFcq9AxwC8dAd6K2+j0RFMqDCPEAhLmrJneE77JSzJ1 Aumb5AawdXoy2kK5sg0C8JXe3WRC/nv25b1wu1DfsJJk7oOgZmiXcYaX7LpC7PwevPf/FV/e32J Q8TH/9s/GCUBSJ8FdvUxAHniMRL2U/b/F6pGSsfsMNbOrud5Fb93e0248EeHtIRGN3wiK5zPBoX SsTvuzjxktXfFJDHx75jTHB8fiVmOP8OqOZUfOog9xmdRlFVrt7PGqxKF69WwZfCnMaP+tQmho1 vMv3awhYJnyhloL2D6a3cEA2Gz2gGmjU5PNjnutTh18hexQMz3FAcwKMSHctcpDOtSMUJUIIRg9 Wk51DlzfWCFFlJ+yw0SDbcZ60LpuegLWGwo/jTNOh62yPreBkCxnudYgieFuN1cBt2q/bwV1f4E 2+gBPyxnpqTiUHSbaegs0Y7qZanEk4= X-Received: by 2002:a05:600c:3f0b:b0:48a:6fd4:d3d3 with SMTP id 5b1f17b1804b1-48e51f37fb8mr173123565e9.20.1778169137263; Thu, 07 May 2026 08:52:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/67] hw/intc/arm_gicv5: Implement remaining set-config functions Date: Thu, 7 May 2026 16:51:08 +0100 Message-ID: <20260507155154.1886557-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169372871154100 Content-Type: text/plain; charset="utf-8" Implement the GICv5 functions corresponding to the stream protocol SetEnabled, SetPending, SetHandling, and SetTarget commands. These work exactly like SetPriority: the IRS looks up the L2TE and updates the corresponding field in it with the new value. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-22-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 152 +++++++++++++++++++++++++++++ hw/intc/trace-events | 4 + include/hw/intc/arm_gicv5_stream.h | 68 +++++++++++++ include/hw/intc/arm_gicv5_types.h | 15 +++ 4 files changed, 239 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 7d654a91e6..d1eb96fce0 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -497,6 +497,158 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id,= uint8_t priority, } } =20 +void gicv5_set_enabled(GICv5Common *cs, uint32_t id, bool enabled, + GICv5Domain domain, GICv5IntType type, bool virtual) +{ + GICv5 *s =3D ARM_GICV5(cs); + + 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"); + 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); + + if (!l2_iste_p) { + return; + } + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, ENABLE, enabled); + put_l2_iste(cs, cfg, &h); + break; + } + default: + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_enabled: tried to set " + "enable state of bad interrupt type %d\n", type); + return; + } +} + +void gicv5_set_pending(GICv5Common *cs, uint32_t id, bool pending, + GICv5Domain domain, GICv5IntType type, bool virtual) +{ + GICv5 *s =3D ARM_GICV5(cs); + + trace_gicv5_set_pending(domain_name[domain], inttype_name(type), virtu= al, + id, pending); + if (virtual) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to set " + "pending state of a virtual interrupt\n"); + 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); + + if (!l2_iste_p) { + return; + } + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, PENDING, pending); + put_l2_iste(cs, cfg, &h); + break; + } + default: + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to set " + "pending state of bad interrupt type %d\n", type); + return; + } +} + +void gicv5_set_handling(GICv5Common *cs, uint32_t id, + GICv5HandlingMode handling, GICv5Domain domain, + GICv5IntType type, bool virtual) +{ + GICv5 *s =3D ARM_GICV5(cs); + + 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"); + 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); + + if (!l2_iste_p) { + return; + } + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, HM, handling); + put_l2_iste(cs, cfg, &h); + break; + } + default: + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_handling: tried to set " + "handling mode of bad interrupt type %d\n", type); + return; + } +} + +void gicv5_set_target(GICv5Common *cs, uint32_t id, uint32_t iaffid, + GICv5RoutingMode irm, GICv5Domain domain, + GICv5IntType type, bool virtual) +{ + GICv5 *s =3D ARM_GICV5(cs); + + 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"); + /* + * In the cpuif insn "GIC CDAFF", IRM is RES0 for a GIC which + * does not support 1-of-N routing. So warn, and fall through + * to treat IRM=3D1 the same as IRM=3D0. + */ + } + + 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); + + if (!l2_iste_p) { + 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. + */ + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, IAFFID, iaffid); + put_l2_iste(cs, cfg, &h); + break; + } + default: + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_target: tried to set " + "target of bad interrupt type %d\n", type); + return; + } +} + static void irs_map_l2_istr_write(GICv5 *s, GICv5Domain domain, uint64_t v= alue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 42f5e73d54..37ca6e8e12 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -236,6 +236,10 @@ gicv5_spi(uint32_t id, int level) "GICv5 SPI ID %u ass= erted at level %d" gicv5_ist_valid(const char *domain, uint64_t base, uint8_t id_bits, uint8_= t l2_idx_bits, uint8_t istsz, bool structure) "GICv5 IRS %s IST now valid: = base 0x%" PRIx64 " id_bits %u l2_idx_bits %u IST entry size %u 2-level %d" 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_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" =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_stream.h b/include/hw/intc/arm_gicv5= _stream.h index e1649cbb40..af2e1851c2 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -58,4 +58,72 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, uint8_t priority, GICv5Domain domain, GICv5IntType type, bool virtual); =20 +/** + * gicv5_set_enabled + * @cs: GIC IRS to send command to + * @id: interrupt ID + * @enabled: new enabled state + * @domain: interrupt Domain to act on + * @type: interrupt type (LPI or SPI) + * @virtual: true if this is a virtual interrupt + * + * Set enabled state of an interrupt; matches stream interface + * SetEnabled command from CPUIF to IRS. There is no report back of + * success/failure to the CPUIF in the protocol. + */ +void gicv5_set_enabled(GICv5Common *cs, uint32_t id, + bool enabled, GICv5Domain domain, + GICv5IntType type, bool virtual); + +/** + * gicv5_set_pending + * @cs: GIC IRS to send command to + * @id: interrupt ID + * @pending: new pending state + * @domain: interrupt Domain to act on + * @type: interrupt type (LPI or SPI) + * @virtual: true if this is a virtual interrupt + * + * Set pending state of an interrupt; matches stream interface + * SetPending command from CPUIF to IRS. There is no report back of + * success/failure to the CPUIF in the protocol. + */ +void gicv5_set_pending(GICv5Common *cs, uint32_t id, + bool pending, GICv5Domain domain, + GICv5IntType type, bool virtual); + +/** + * gicv5_set_handling + * @cs: GIC IRS to send command to + * @id: interrupt ID + * @handling: new handling mode + * @domain: interrupt Domain to act on + * @type: interrupt type (LPI or SPI) + * @virtual: true if this is a virtual interrupt + * + * Set handling mode of an interrupt (edge/level); matches stream + * interface SetHandling command from CPUIF to IRS. There is no report + * back of success/failure to the CPUIF in the protocol. + */ +void gicv5_set_handling(GICv5Common *cs, uint32_t id, + GICv5HandlingMode handling, GICv5Domain domain, + GICv5IntType type, bool virtual); + +/** + * gicv5_set_target + * @cs: GIC IRS to send command to + * @id: interrupt ID + * @iaffid: new target PE's interrupt affinity + * @irm: interrupt routing mode (targeted vs 1-of-N) + * @domain: interrupt Domain to act on + * @type: interrupt type (LPI or SPI) + * @virtual: true if this is a virtual interrupt + * + * Set handling mode of an interrupt (edge/level); matches stream + * interface SetHandling command from CPUIF to IRS. There is no report + * back of success/failure to the CPUIF in the protocol. + */ +void gicv5_set_target(GICv5Common *cs, uint32_t id, uint32_t iaffid, + GICv5RoutingMode irm, GICv5Domain domain, + GICv5IntType type, bool virtual); #endif diff --git a/include/hw/intc/arm_gicv5_types.h b/include/hw/intc/arm_gicv5_= types.h index e2b937fe62..20de5b3f46 100644 --- a/include/hw/intc/arm_gicv5_types.h +++ b/include/hw/intc/arm_gicv5_types.h @@ -55,4 +55,19 @@ typedef enum GICv5IntType { GICV5_SPI =3D 3, } GICv5IntType; =20 +/* Interrupt handling mode (same encoding as L2_ISTE.HM) */ +typedef enum GICv5HandlingMode { + GICV5_EDGE =3D 0, + GICV5_LEVEL =3D 1, +} GICv5HandlingMode; + +/* + * Interrupt routing mode (same encoding as L2_ISTE.IRM). + * Note that 1-of-N support is option and QEMU does not implement it. + */ +typedef enum GICv5RoutingMode { + GICV5_TARGETED =3D 0, + GICV5_1OFN =3D 1, +} GICv5RoutingMode; + #endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169390; cv=none; d=zohomail.com; s=zohoarc; b=ImDT+7JiXXDxMGxhaCSpI5QtuYW94bSlJopQ+qk+IvTZdmnfq9frqvUtQbPOA9I5zGfe/J5MpBAmj5aivJ2wb0elZ0a095d6bAsjICsPQ/028jI2log+VZmyqyGND1xDdR0vN5eFBFk1VseHyy5zCM/LOjAvCZBTQX4Ep0TYkl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169390; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=6q7pBUaHj3cZmE/VEkADC04g+6hoWqOG0CYGdIYTkwM=; b=DZsOva4fsOZd3qaT8KoZ9mMX6l++yYqA1BO1144QxSmTLcyCTT4G1+V/ZuEDX6Tcf4HGnZPhWY5AzXfN2/KUH0FXHh4g+cPgz7aPEPLxeTsK/Xlo6Qhuvqdo9DPCAW+0P+UbqHfmSDJJ331AR5Y5zKqEv29omwmiBLtkoauoKgs= 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 177816938999620.403841446263527; Thu, 7 May 2026 08:56:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11T-0003c7-Ht; Thu, 07 May 2026 11:52:23 -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 1wL11R-0003bA-P7 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:21 -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 1wL11P-0003s4-M7 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:21 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-488b8bc6bc9so6698155e9.3 for ; Thu, 07 May 2026 08:52:19 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169138; x=1778773938; 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; bh=6q7pBUaHj3cZmE/VEkADC04g+6hoWqOG0CYGdIYTkwM=; b=ZOj/z/eBIwnYe1nXL/s15Q0f/l8eRKUPDGOhpgTiNM1fO5UNoSwBuo3oMbg+wYqHQa aboIy+8GCj6PBXj+OyP6ugsMlerDmL/U/X75s+lQa6Fjwmzp5TIhOobojyFUvRVWtj+k l31aRlJWbM3rjY86tvvuiSwSFJNHJMB43pJpf+F4GY5khpFlyw9+9JWLG3Ly8lfsB/NY A+jAe6B+25k5Sgp8Wf8APTn2WVZQhe2p/qmWWvsFVxCpU5g5Vutix/kWmADflksU3bXT BiaBUZUAmyPzDT6o61GdEKKtTWKDNx6NLkuxTtJOF/1DaD6iCgKp1QkITLr/WKLISksa vJBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169138; x=1778773938; 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; bh=6q7pBUaHj3cZmE/VEkADC04g+6hoWqOG0CYGdIYTkwM=; b=jWmy08rBt0EEVWPwfbXd+oXUNVNF4MjLtLHzPCieijCEjmOwdR+e665suqzIl/j1jS 8yZzPfHmqI9siWt4bF9bmG6RHNsDP8G6in6zI2n1+tfWQghgj/uVdIczzQtok2S9UE5Y Vmz+AuRDzdQEhxCda/Be+x7pPNN0/bdUxXKDY9KbvugmvK0XmjDthf6ODthLASTlM2Kh qzOvt6jqr8DX7xAf9NJDCUd2cOpzmGOWHwV02AR4jqSb8e369lYeCOBpPAbt6TMiMl0f 218YX3pCuhBR8KYD707QxM6o6IoCev2XMT0cNqu64zaZI9OBj89JrtqWFxh96s1cWT70 1EQw== X-Gm-Message-State: AOJu0YympA80Y07s+yN2WUdKByM8Uy7olVRsKvZR9jWziyliZnZSxpJ8 iKLDMU6uzGI6/wSVPilEvdQacz3vSPlGS+Uh6RtexPqD+wgM1VlId6LnjdP0uUqFBh+hjmvNGAe /mtqN X-Gm-Gg: AeBDieuW4iG9P/eneYiukfKiZi2Cj5blyRQnDxru2ilSSuatY1+UoF2ANb5UVVS0INB z7sV47fl4eik4nzbV3mjj0Zi1B+60HczepF0IzqCNLqpUprnHFBhnI7eDgtdZA2f92KDtxbA/wA mBsJs3KLNtqv+RE/q5+Ee2wB6/lAOisZqMyqXRMiX+bcOJ+tEpF9gJwCYTNDnVCg1Q+yYf2OHtk jttwMkvbaJj5SzuSd+DgJEEgVXcL0WQkp7bd7jGBjOAMiglhVLNmFKZN0dEFCB1xPgtGuoUkYG4 gW50uVrkU7KylzirQizPAXPP2xTSNhLT2JgPKWSFX+o+cHaE2DB5U3mnQSk4tjFAwtv9LS3qcRW 35d4kDX/e01Jb3rTjJLrQ/dGduqyX8bsyi2Qm3j6zJFID8jvFb99J4tIWTDUTA0SNMXV2jl2iHD 9xAHYjjhprjM3S2ANPZR7re1mYWq/kZZ4dzQdkr0QBDaVMfrcKM4vOvOBf0sh5YMONQ/6TgoGqe auonCEE6FWY0hs6+5nNC2UgZgOLIK3ghnZ92vlYug== X-Received: by 2002:a05:600c:8485:b0:48d:364:e236 with SMTP id 5b1f17b1804b1-48e51f30493mr147758785e9.18.1778169138093; Thu, 07 May 2026 08:52:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/67] target/arm: GICv5 cpuif: Implement GIC CD* insns for setting config Date: Thu, 7 May 2026 16:51:09 +0100 Message-ID: <20260507155154.1886557-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169392317158500 Content-Type: text/plain; charset="utf-8" Implement the GIC CDDIS, GIC CDEN, GIC CDAFF, GIC CDPEND and GIC CDHM system instructions. These are all simple wrappers around the equivalent gicv5_set_* functions, like GIC CDPRI. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-23-peter.maydell@linaro.org --- target/arm/tcg/gicv5-cpuif.c | 108 +++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 0c2bba5ce9..0c4349f8a7 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -16,6 +16,25 @@ FIELD(GIC_CDPRI, ID, 0, 24) FIELD(GIC_CDPRI, TYPE, 29, 3) FIELD(GIC_CDPRI, PRIORITY, 35, 5) =20 +FIELD(GIC_CDDIS, ID, 0, 24) +FIELD(GIC_CDDIS, TYPE, 29, 3) + +FIELD(GIC_CDEN, ID, 0, 24) +FIELD(GIC_CDEN, TYPE, 29, 3) + +FIELD(GIC_CDAFF, ID, 0, 24) +FIELD(GIC_CDAFF, IRM, 28, 1) +FIELD(GIC_CDAFF, TYPE, 29, 3) +FIELD(GIC_CDAFF, IAFFID, 32, 16) + +FIELD(GIC_CDPEND, ID, 0, 24) +FIELD(GIC_CDPEND, TYPE, 29, 3) +FIELD(GIC_CDPEND, PENDING, 32, 1) + +FIELD(GIC_CDHM, ID, 0, 24) +FIELD(GIC_CDHM, TYPE, 29, 3) +FIELD(GIC_CDHM, HM, 32, 1) + static GICv5Common *gicv5_get_gic(CPUARMState *env) { return env->gicv5state; @@ -51,6 +70,30 @@ static GICv5Domain gicv5_current_phys_domain(CPUARMState= *env) return gicv5_logical_domain(env); } =20 +static void gic_cddis_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + 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); + + gicv5_set_enabled(gic, id, false, domain, type, virtual); +} + +static void gic_cden_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + 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); + + gicv5_set_enabled(gic, id, true, domain, type, virtual); +} + static void gic_cdpri_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -64,6 +107,46 @@ static void gic_cdpri_write(CPUARMState *env, const ARM= CPRegInfo *ri, gicv5_set_priority(gic, id, priority, domain, type, virtual); } =20 +static void gic_cdaff_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + GICv5Common *gic =3D gicv5_get_gic(env); + uint32_t iaffid =3D FIELD_EX64(value, GIC_CDAFF, IAFFID); + 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); + + gicv5_set_target(gic, id, iaffid, irm, domain, type, virtual); +} + +static void gic_cdpend_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + GICv5Common *gic =3D gicv5_get_gic(env); + 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); + + gicv5_set_pending(gic, id, pending, domain, type, virtual); +} + +static void gic_cdhm_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + GICv5Common *gic =3D gicv5_get_gic(env); + 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); + + gicv5_set_handling(gic, id, hm, domain, type, virtual); +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -86,11 +169,36 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .opc0 =3D 1, .opc1 =3D 0, .crn =3D 12, .crm =3D 0, .opc2 =3D 1, .access =3D PL1_W, .type =3D ARM_CP_NOP, }, + { .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, + .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, + .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, .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, + .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, + .writefn =3D gic_cdpend_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, + .writefn =3D gic_cdhm_write, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169319; cv=none; d=zohomail.com; s=zohoarc; b=c3ulU5pl1GUzOjujKwqGtw8YK28S58o+b8NszgLNXlDApnD8p7N8ufH7vMtFSWDjQ/QWnP6wHRLFH+OCOr154h3BvX5EPqCe7xw1WnwEQB1WkZcwocbg7WxAToEKcNxCv9v6bI2O924+OL0wXlEZZne+IvVs6eWvtw8iwlFRw/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169319; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=facN1UwDMu3JSY3ts6JtzkWbj7pqYVHY8oHKersaP0k=; b=CMKIkJdoMXGAKDFdyTgDpIysHeij0nRuxQlslpQ/IjXSQ8aG3H6Lg9WYRLKOBxiCchUEh1H1q6npaRAJVEExCQ7cazBChhMPi5xY49owbwqq37T43K/sUMWiAAGveoe00BeYVP8+34xRN+XhUtJYUAj/OnCqlM+MTKpIb3TtEjU= 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 1778169319715296.7198836636636; Thu, 7 May 2026 08:55:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11U-0003cP-4k; Thu, 07 May 2026 11:52: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 1wL11T-0003bX-1v for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:23 -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 1wL11R-0003sT-9A for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:22 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-488af96f6b2so12020685e9.0 for ; Thu, 07 May 2026 08:52:20 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169140; x=1778773940; 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; bh=facN1UwDMu3JSY3ts6JtzkWbj7pqYVHY8oHKersaP0k=; b=Thk775SOVtRczepkMYim8ASKGHW3zPokdeHfI1af0/BREITs294M7pwAX8RGfSlMSn 3z7nc28yrDMhrFJKkZbniciTowiaAfbD0Uel3lpWcox1gXlDLDF87fE19BsJOTD6rtnE ONjn/jjGLVZTeDvyQoOxEDT8VmnwSnCpJvyczzL5Ep3ZMRuSyhGzcmH0oEEcDtGINOT6 Rrs2twnuaqN/JejwRuRxPGh4hYAKBENgLpkgaB9DFCfoqit0HXkgUPZd1XYJSTu70cvj eMe0RrwXpwDAnOWvRLjNryYuWV3PWInUxGha81fVFweXlqpsaie4+e/vYQZnZb2wpOyh Z3oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169140; x=1778773940; 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; bh=facN1UwDMu3JSY3ts6JtzkWbj7pqYVHY8oHKersaP0k=; b=qU49oWIss3lKao5oRAUeodhInEoSq+nWSa3mosVdanO/LWrGxXLbzl1o7rIXx8y1k2 b3z1566p3pH0JC5esn+wbIxiYi2XsfmpyD8D//73NQ/e4IMLXS0Rg/oHomQprmIyNjBr Wpbmcv62epJEzYi5aoGuGJ83JMFxq96isHlFJRdsLmwAgAq7OQNuG01GM1XEYl96ULwz lqVwsHt9/BgBOqiZPwXIfLwbrBd2if0lzXO1nYnewJN5/Jf7IaBtqZEKj8YufYsYX0Cm O757eVBshs+5MsFf8cuAkQncxySiDRH2SEpEPaSVCqSP6S2tNRqYHus7Vpcoc6sIxcZJ tBKA== X-Gm-Message-State: AOJu0YyOBGgujv1oDZBgJ/X5Tnv6OdWM2RFDfkS9ZD0JjAPdelDpdt5y 2QRZoULZQMSGenSVYB1XLQFR+N61p5UtISfkJAJdgO7aQyaYG8ssxuhQKP62M2M4sNC2sdxaHKi iWKi1 X-Gm-Gg: AeBDiesvco9g131J2nzrQS+vD7w8pUkXz3TyLztYpC7vVGUeGq9OShF1KS4LXO6IpNd O7l7KLtab+6nDjxUsfvAHM3Va1yeZStFJHlYbNGeQlRYUHYQzi8xEP4vElXxmGwMtQSBYKJQxaO XO4LkIlLu5i/qwli8EOUwOgEtoXKSCt1BdpkaiaJZbcuiwyFS6yDHDwscq8qMM2sF3t9XPuzJ6T Mj9QptNrstXeaXy6z54R+qqiYLaDqQF1recsf6zpg+QiiZbcLO1kFYstYqr5JL1/QSlEmw02FhT i7pi34PtKC6B42wjnPUi8Bj+8gqM/nva6Ke7K2lZEMRgtP04cg/JoBhektyEk4Al0mMJXlAydsa jrtDgJ+72+snd4oBvIL+k/oEkRNTPkUN1GWytxNtLBF13fU/HxWcK2d5w1NYmITXAIfSDw8I8jd KSAmO9IFwpET6hOKCO2XE7JKo8h7okHBOdAgIAmQHQM/3vBfdlFLQkGl3EJsYkWrP6QKMriqVew Hi+QaYFaOw5iCyfE3GiEXVr1Skb0Z4= X-Received: by 2002:a05:600d:b:b0:48e:5d91:cffb with SMTP id 5b1f17b1804b1-48e5d91d240mr50277955e9.10.1778169139659; Thu, 07 May 2026 08:52:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/67] hw/intc/arm_gicv5: Create backing state for SPIs Date: Thu, 7 May 2026 16:51:10 +0100 Message-ID: <20260507155154.1886557-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169321855154100 Content-Type: text/plain; charset="utf-8" The GICv5 allows an IRS to implement SPIs, which are fixed-wire interrupts connected directly to the IRS. For QEMU we want to use these for all our traditional fixed-wire interrupt devices. (The other option the architecture permits is an Interrupt Wire Bridge (IWB), which converts from a fixed-wire interrupt to an interrupt event that is then translated through an ITS to send an LPI to the ITS -- this is much more complexity than we need or want.) SPI configuration is set via the same CPUIF instructions as LPI configuration. Create an array of structs which track the SPI state information listed in I_JVVTZ and I_BWPPP (ignoring for the moment the VM assignment state, which we will add when we add virtualization support). Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-24-peter.maydell@linaro.org --- hw/intc/arm_gicv5_common.c | 30 ++++++++++++++++++++++++++++++ include/hw/intc/arm_gicv5_common.h | 27 +++++++++++++++++++++++++++ include/hw/intc/arm_gicv5_types.h | 14 ++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 21b40c35a5..aa5877ee05 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -64,6 +64,34 @@ static void gicv5_common_reset_hold(Object *obj, ResetTy= pe type) =20 memset(cs->irs_ist_baser, 0, sizeof(cs->irs_ist_baser)); memset(cs->irs_ist_cfgr, 0, sizeof(cs->irs_ist_cfgr)); + + if (cs->spi) { + GICv5Domain mp_domain; + + /* + * D_YGLYC, D_TVVRZ: SPIs reset to edge-triggered, inactive, + * idle, disabled, targeted routing mode, not assigned to a + * VM, and assigned to the most-privileged interrupt domain. + * Other state is UNKNOWN: we choose to zero it. + */ + memset(cs->spi, 0, cs->spi_irs_range * sizeof(*cs->spi)); + + /* + * The most-privileged interrupt domain is effectively the + * first in the list (EL3, S, NS) that we implement. + */ + if (gicv5_domain_implemented(cs, GICV5_ID_EL3)) { + mp_domain =3D GICV5_ID_EL3; + } else if (gicv5_domain_implemented(cs, GICV5_ID_S)) { + mp_domain =3D GICV5_ID_S; + } else { + mp_domain =3D GICV5_ID_NS; + } + + for (int i =3D 0; i < cs->spi_irs_range; i++) { + cs->spi[i].domain =3D mp_domain; + } + } } =20 static void gicv5_common_init(Object *obj) @@ -142,6 +170,8 @@ static void gicv5_common_realize(DeviceState *dev, Erro= r **errp) =20 address_space_init(&cs->dma_as, cs->dma, "gicv5-sysmem"); =20 + cs->spi =3D g_new0(GICv5SPIState, cs->spi_irs_range); + trace_gicv5_common_realize(cs->irsid, cs->num_cpus, cs->spi_base, cs->spi_irs_range, cs->spi_ra= nge); } diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 19e1af8ceb..983faa5ef1 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -55,6 +55,25 @@ =20 OBJECT_DECLARE_TYPE(GICv5Common, GICv5CommonClass, ARM_GICV5_COMMON) =20 +/* + * This is where we store the state the IRS handles for an SPI. + * Generally this corresponds to the spec's list of state in I_JVVTZ + * and J_BWPPP. level is a QEMU implementation detail and is where we + * store the actual current state of the incoming qemu_irq line. + */ +typedef struct GICv5SPIState { + uint32_t iaffid; + uint8_t priority; + bool level; + bool pending; + bool active; + bool enabled; + GICv5HandlingMode hm; + GICv5RoutingMode irm; + GICv5TriggerMode tm; + GICv5Domain domain; +} GICv5SPIState; + /* * This class is for common state that will eventually be shared * between TCG and KVM implementations of the GICv5. @@ -67,6 +86,14 @@ struct GICv5Common { uint64_t irs_ist_baser[NUM_GICV5_DOMAINS]; uint32_t irs_ist_cfgr[NUM_GICV5_DOMAINS]; =20 + /* + * Pointer to an array of state information for the SPIs. Array + * element 0 is SPI ID s->spi_base, and there are s->spi_irs_range + * elements in total. SPI state is not per-domain: SPI is + * configurable to a particular domain via IRS_SPI_DOMAINR. + */ + GICv5SPIState *spi; + /* Bits here are set for each physical interrupt domain implemented */ uint8_t implemented_domains; =20 diff --git a/include/hw/intc/arm_gicv5_types.h b/include/hw/intc/arm_gicv5_= types.h index 20de5b3f46..f6f8709a6a 100644 --- a/include/hw/intc/arm_gicv5_types.h +++ b/include/hw/intc/arm_gicv5_types.h @@ -70,4 +70,18 @@ typedef enum GICv5RoutingMode { GICV5_1OFN =3D 1, } GICv5RoutingMode; =20 +/* + * Interrupt trigger mode (same encoding as IRS_SPI_CFGR.TM) Note that + * this is not the same thing as handling mode, even though the two + * possible states have the same names. Trigger mode applies only for + * SPIs and tells the IRS what kinds of changes to the input signal + * wire should make it generate SET and CLEAR events. Handling mode + * affects whether the pending state of an interrupt is cleared when + * the interrupt is acknowledged, and applies to both SPIs and LPIs. + */ +typedef enum GICv5TriggerMode { + GICV5_TRIGGER_EDGE =3D 0, + GICV5_TRIGGER_LEVEL =3D 1, +} GICv5TriggerMode; + #endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169449; cv=none; d=zohomail.com; s=zohoarc; b=QYaTC9O48c+pQ4DHO/Fyna0s/dYr9zxCVXngoDx7OeboAcETGZoGNlZc2FT9p+pUKu/sGp/7w5z73ao8jZJ9UmfeUx99eptRkPpw1luRhkWlzVAppL3kibYtvaXQLTgq4pm8wk8C4RZeIAr9ulIkdtEqRDw+1hFmy2QPxhvpzIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169449; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=mzKl+lbW+z67na7zbBkRxEC+ZYWf7DRAQ11ALD4aoGc=; b=UglNaWX/MRSdqumEIXu2SqbWXztWIxx0tO6G7OfhvWD9Z5KaihzCfuRg2/aHBuZ1u1jukUPGqwWIkTTmTzgNq+u7zoyXDFPOEPcOczWCQZShDmiL63dBixLlnrXUB+omIOgPMU27Ykvigz0SUaTVdc4tWWABao6h3rrf1243yRU= 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 1778169449967734.8756573347646; Thu, 7 May 2026 08:57:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11W-0003j9-41; Thu, 07 May 2026 11:52: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 1wL11U-0003cO-23 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:24 -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 1wL11S-0003sg-1M for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:23 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4852a9c6309so9001615e9.0 for ; Thu, 07 May 2026 08:52:21 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169140; x=1778773940; 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; bh=mzKl+lbW+z67na7zbBkRxEC+ZYWf7DRAQ11ALD4aoGc=; b=vOiLju3vzs9RiDbm1F+BYLI6KdAQ+2ucxKUW8s8ddiy++BIoVoY55RroSkf2r3i9Xe 8wYXa9jr28Jr+728WAVlZ1pjhi0R5lrvEEIR1NfnlGbvJhKfbMr0fOELLpoDSLXrcad7 nBwh1gfuBBF1JfrV8bemy52RC3kXZlhWA1ZW5aFS7uKC5BbruapwGuSolFLtHe9dToVn NSah1MtQjT2tTGeTjw6QgXAdJJiEziDw5dNuPkXSCQs5EM/tW/+uA6/30aa7CCS2mz6U zZyL5wbL3Jhsey/XvrhTyxQqJY9YlBo5pu0AViZpkxliZrG0dq3O8lYwIPqIqoIxblCg 2rgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169140; x=1778773940; 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; bh=mzKl+lbW+z67na7zbBkRxEC+ZYWf7DRAQ11ALD4aoGc=; b=oRd02Tb9JXCY4wjsjaRacAb6om62cwqxLhV2jwPq0C+7m0VCoeucjbSm5i0T4+V4Bu /0xkZgMwxfd4OsWzfFGmYFUprDf2bpmm+EISfc867wsphGRl/Z038g5nFmGrk3yEw2go wbpCs38ssOwQ8NC98QrEHQcdXuJ0wCrDuuLXDyFzhlllr3GIXgt5h3RdcAvtyzOSabrW HConHYJjsJHAMgTtTWB5pe9+ktfARcNDxLd/uclV3CO41fw/Vuk/V02zy4bkwYaDc1ZB g+J/kbBm7GrsFS/B47a0uANHfd5SKSvSrI5w+ZE/zaG6pwpIIM0yL9iBvnfru59WTynm 4udw== X-Gm-Message-State: AOJu0Yx1Fp8fz+8CaDn2fz0J1Jj2nT8H+L/N3hwtkuo3xl2OvwaLHmPA M27WET0zN/tvUcI2EVRd/fxSVGj9ZBezMT8YFmipPgTqMBOucYuxc+thtX1VgccdQv9FcG4VRnQ v2AFm X-Gm-Gg: AeBDiesqA8rOXEaaQ0epmCJGF7m1KvyynLNKndPsZxHX/pw/+eePtsV9ci50ghHZkyc kj9ZUWomSSix2ckDXWrn6OtRFsvjW6I32PVQhZgffhe++aQMs/PwfHsLr0PIie7nUS/VcEDiPoV mwjw2lVdy+QyQQThcGVn+gcG55GUTmUD5V9IrcZjPxD//wNag132K8hCe0F5XpfKpLtu/cPe5AN mX1+dXvm+tE/Cs1+2NZSFKKFkFx8mmRiF54o3qQmaL7TuQ7T7bgr3QNxlTpjeg4rxTIuc5SCbgx i6zUiTps2hQSG1gtqwRQK58hEyHSgBOH5Uu2gTfHgXC6CMUeDY9cNnkwA9PES6Cvc0akMMn0Zn8 +J6XnSPjV+QRYP+MEeK0El9DyciQF4vS88EX1DiKgtf4HCzD+NfE3xRtWgJYhYs393QsY9pPgs6 5ChinjESiujYi4WKvzmOqQwI4lbnGWNfN3vzVbTk3Tq13G0RHhXq7Tc4rgUuPGx1C1T/TAdJjqf GltmFsJ25QMDBvL2eL9zAnP+F+PliGL3Fj2HA== X-Received: by 2002:a05:600c:8485:b0:487:55c:e0c1 with SMTP id 5b1f17b1804b1-48e51f2f853mr148905885e9.14.1778169140436; Thu, 07 May 2026 08:52:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/67] hw/intc/arm_gicv5: Make gicv5_set_* update SPI state Date: Thu, 7 May 2026 16:51:11 +0100 Message-ID: <20260507155154.1886557-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169450643158500 The GIC CD* insns that update interrupt state also work for SPIs. Instead of ignoring the GICV5_SPI type in gicv5_set_priority() and friends, update the state in our SPI state array. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-25-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 64 ++++++++++++++++++++++++++++++ include/hw/intc/arm_gicv5_common.h | 40 +++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index d1eb96fce0..9ca1826253 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -490,6 +490,19 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, = uint8_t priority, put_l2_iste(cs, cfg, &h); break; } + case GICV5_SPI: + { + GICv5SPIState *spi =3D gicv5_spi_state(cs, id, domain); + + if (!spi) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_priority: tried to s= et " + "priority of unreachable SPI %d\n", id); + return; + } + + spi->priority =3D priority; + break; + } default: qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_priority: tried to set " "priority of bad interrupt type %d\n", type); @@ -524,6 +537,19 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, b= ool enabled, put_l2_iste(cs, cfg, &h); break; } + case GICV5_SPI: + { + GICv5SPIState *spi =3D gicv5_spi_state(cs, id, domain); + + if (!spi) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_enabled: tried to se= t " + "enable state of unreachable SPI %d\n", id); + return; + } + + spi->enabled =3D true; + break; + } default: qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_enabled: tried to set " "enable state of bad interrupt type %d\n", type); @@ -558,6 +584,19 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, b= ool pending, put_l2_iste(cs, cfg, &h); break; } + case GICV5_SPI: + { + GICv5SPIState *spi =3D gicv5_spi_state(cs, id, domain); + + if (!spi) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to se= t " + "pending state of unreachable SPI %d\n", id); + return; + } + + spi->pending =3D true; + break; + } default: qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to set " "pending state of bad interrupt type %d\n", type); @@ -593,6 +632,18 @@ void gicv5_set_handling(GICv5Common *cs, uint32_t id, put_l2_iste(cs, cfg, &h); break; } + case GICV5_SPI: + { + GICv5SPIState *spi =3D gicv5_spi_state(cs, id, domain); + + if (!spi) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_handling: tried to s= et " + "priority of unreachable SPI %d\n", id); + } + + spi->hm =3D handling; + break; + } default: qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_handling: tried to set " "handling mode of bad interrupt type %d\n", type); @@ -642,6 +693,19 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, ui= nt32_t iaffid, put_l2_iste(cs, cfg, &h); break; } + case GICV5_SPI: + { + GICv5SPIState *spi =3D gicv5_spi_state(cs, id, domain); + + if (!spi) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_target: tried to set= " + "target of unreachable SPI %d\n", id); + return; + } + + spi->iaffid =3D iaffid; + break; + } default: qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_target: tried to set " "target of bad interrupt type %d\n", type); diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 983faa5ef1..6897f94117 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -200,4 +200,44 @@ static inline const char *gicv5_class_name(void) return "arm-gicv5"; } =20 +/** + * gicv5_raw_spi_state + * @cs: GIC object + * @id: INTID of SPI to look up + * + * Return pointer to the GICv5SPIState for this SPI, or NULL if the + * interrupt ID is out of range. This does not do a check that the SPI + * is assigned to the right domain: generally you should call it via + * some other wrapper that performs an appropriate further check. + */ +static inline GICv5SPIState *gicv5_raw_spi_state(GICv5Common *cs, uint32_t= id) +{ + if (id < cs->spi_base || id >=3D cs->spi_base + cs->spi_irs_range) { + return NULL; + } + + return cs->spi + (id - cs->spi_base); +} + +/** + * gicv5_spi_state: + * @cs: GIC object + * @id: INTID of SPI to look up + * @domain: domain to check + * + * Return pointer to the GICv5SPIState for this SPI, or NULL if the + * interrupt is unreachable (which can be because the INTID is out of + * range, or because the SPI is configured for a different domain). + */ +static inline GICv5SPIState *gicv5_spi_state(GICv5Common *cs, uint32_t id, + GICv5Domain domain) +{ + GICv5SPIState *spi =3D gicv5_raw_spi_state(cs, id); + + if (!spi || spi->domain !=3D domain) { + return NULL; + } + return spi; +} + #endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169208; cv=none; d=zohomail.com; s=zohoarc; b=MCT1WpCzR4uZyVqQ93pxDVUWdJVu5e91lHZTG86mi9leZf1cIjjuTamR9MVe2/gJGIlGY1rXtnAASQlvlo035mOa9paPl+Urxyu6bXSYWT/v+5XxXIzKDCKjrIIg5BZf3we1ZITOdvTcG8jkNWp7aKnQLvo9c7WmepZPs2+CpKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169208; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=XWvtC2A1U9sZwo3Oui0OOqt++IM3K1g6IS43RbM676I=; b=SjreBpiQEv5Qp0ygRZ3g7ZYzkxD9XS8j1ScoJ2mrcvLLP4G6KbMhL7TkCUlSdbBSJNz7FMk7R6huonfNSa2uRWy0DEoIclahD8v7ewbqgMGjRtweSz1LcxwWYb9RTrQwLUT696gU1g60isTKsIkRDhQStn969GE2d4jb0iy0giY= 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 1778169208075665.6050284751954; Thu, 7 May 2026 08:53:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11X-0003oA-CY; Thu, 07 May 2026 11:52: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 1wL11V-0003gs-5Q for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:25 -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 1wL11T-0003t2-6Q for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:24 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-488b0046078so8994265e9.1 for ; Thu, 07 May 2026 08:52:22 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169142; x=1778773942; 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; bh=XWvtC2A1U9sZwo3Oui0OOqt++IM3K1g6IS43RbM676I=; b=vpvNX45G9rBdR6sUJdeww0fqEnvlzq8Hh6i7qYhyGcYdc83gZdXdPguNelwC8NHMy6 RdivmgUG/hxxh+xHDT+aQzlC7JIFCxzkUiRpFk7nlcuAcHOkd87SD9gehA2cDPCfW5Cp JUmQYSnlbg9TEkUIckqxKJi8kvIElZxOdVKcoV6HkgzXABTQSB3THeje7ntcA0arGWil DEr0PoEFqHqTvrMfQSDVGec6v1niBE5U/toQwcDRppAiDCZU455PfouT72/2nrNdKcJc Nvq4ZjIg/NfS+gf77E7gPkiEUx1fbRn+fXisjpxbq4RAikx6aS83RVzNWemjYaWIT14r sTzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169142; x=1778773942; 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; bh=XWvtC2A1U9sZwo3Oui0OOqt++IM3K1g6IS43RbM676I=; b=mrjbcoIMXleo1oaAygqJdxgtoBTqBDxTM5QO1ukPplNm68Toxujh8WR0zvjEMaHm7G mV2TZa5enmj/zBWCTp0AMJ/8i7j0pJhhlY0lDSDNxGSVZaZa1VYAnS3Tw8mqjF4GztTC jHAdEBgaNhteQWyGuJEyKfwrSMuP6GHexObArsVBygf8+ZdgipKivwMSMdi0n2aPH5VJ PqlBU3N/FHTT6XFoLsYoMK4K5OAvXE4JFgjsms81Whlw4kotZN50VfHFfolZ3GI3ZWET AD3cdYCfEQgAYdKL4cZMLpZXRLJoj9ZZ47R5awBz77/90ELsj2UHr2RLf7OV2/2RjId0 V8hA== X-Gm-Message-State: AOJu0YwvyndELoek3TF4N3DjfjbOu6yoQgS8UC3pHjEU8x9zL8O9s0n9 Y3HAb076bSj5REuLyhIf1F0sFrWIXlYAL+yYYao3JmhnfSqwgGZtl5mpOvWrkcYrt4lXw2sLatT FVjAp X-Gm-Gg: AeBDiesJJXf21Y5pv5g9waJCHICA9+OJcRkvR8B1s6LS58WuhvsaG/dKE6A0pWQWVIm iwCpUv77ZhUFPV24aJW2UnG06D9qhcSQoZuZgWwNsLO+87DuIBhbbsh/2yRo9HEt5vRgt+UOIMC pX7J5OteUUu6FZHPExTFzzi2qd87N4/jHDN9XKda3XQX2oQG7V8NFnDRu8TqCEJS4PdQ1tVRmBF dgK2WiWB7jaf7t2Tp0XDIJapOCHYWOPnOxGPk7LVadImUBmOsUlGqUh/2QqOFHit2CuZmDp24I1 bR5hJBe/JWoxZ1UlPgX2QeN/jgqrcuMu6KbjK86Cf+ySXFZQKxr5rAzLQKH4mVvrdFcT3DeBVk8 22nqX8/bGKxzMaz2sSftv6gRof+uO/hJ1yamVahvd/yz+l1UBYRHQ6xAcE622kEhq1AzdXzY6fu 2lWJFnn7qg4yPtlOOWvwRHfj2RuuzQ9BettyTFtrvd79fAO1YzZlvZLU2+2tz34hdw8mYV/hdkt fQKzVHVhXmQmLNFDYNv2gJBg1S1U1P0E2NvAA5Mig== X-Received: by 2002:a05:600d:8451:b0:487:219e:42d with SMTP id 5b1f17b1804b1-48e53f33f08mr91178025e9.11.1778169141308; Thu, 07 May 2026 08:52:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/67] hw/intc/arm_gicv5: Implement gicv5_request_config() Date: Thu, 7 May 2026 16:51:12 +0100 Message-ID: <20260507155154.1886557-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169209385158500 Implement the gicv5_request_config() function, which corresponds to the RequestConfig command and its RequestConfigAck reply. We provide read_l2_iste() as a separate function to keep the "access the in-guest-memory data structure" layer separate from the "operate on the L2_ISTE values" layer. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-26-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 102 +++++++++++++++++++++++++++++ hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_stream.h | 24 +++++++ 3 files changed, 127 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 9ca1826253..04d4391ae5 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -297,6 +297,19 @@ FIELD(L2_ISTE, HWU, 9, 2) FIELD(L2_ISTE, PRIORITY, 11, 5) FIELD(L2_ISTE, IAFFID, 16, 16) =20 +/* + * 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) + static MemTxAttrs irs_txattrs(GICv5Common *cs, GICv5Domain domain) { /* @@ -713,6 +726,95 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, ui= nt32_t iaffid, } } =20 +static uint64_t l2_iste_to_icsr(GICv5Common *cs, const GICv5ISTConfig *cfg, + uint32_t id) +{ + uint64_t icsr =3D 0; + const uint32_t *l2_iste_p; + L2_ISTE_Handle h; + + l2_iste_p =3D get_l2_iste(cs, cfg, id, &h); + if (!l2_iste_p) { + return R_ICSR_F_MASK; + } + + /* + * The field locations in the L2 ISTE do not line up with the + * corresponding fields in the ICC_ICSR_EL1 register, so we need + * to extract and deposit them individually. + */ + icsr =3D FIELD_DP64(icsr, ICSR, F, 0); + icsr =3D FIELD_DP64(icsr, ICSR, ENABLED, FIELD_EX32(*l2_iste_p, L2_IST= E, ENABLE)); + icsr =3D FIELD_DP64(icsr, ICSR, PENDING, FIELD_EX32(*l2_iste_p, L2_IST= E, PENDING)); + icsr =3D FIELD_DP64(icsr, ICSR, IRM, FIELD_EX32(*l2_iste_p, L2_ISTE, I= RM)); + icsr =3D FIELD_DP64(icsr, ICSR, ACTIVE, FIELD_EX32(*l2_iste_p, L2_ISTE= , ACTIVE)); + icsr =3D FIELD_DP64(icsr, ICSR, HM, FIELD_EX32(*l2_iste_p, L2_ISTE, HM= )); + icsr =3D FIELD_DP64(icsr, ICSR, PRIORITY, FIELD_EX32(*l2_iste_p, L2_IS= TE, PRIORITY)); + icsr =3D FIELD_DP64(icsr, ICSR, IAFFID, FIELD_EX32(*l2_iste_p, L2_ISTE= , IAFFID)); + + return icsr; +} + +static uint64_t spi_state_to_icsr(GICv5SPIState *spi) +{ + uint64_t icsr =3D 0; + + icsr =3D FIELD_DP64(icsr, ICSR, F, 0); + icsr =3D FIELD_DP64(icsr, ICSR, ENABLED, spi->enabled); + icsr =3D FIELD_DP64(icsr, ICSR, PENDING, spi->pending); + icsr =3D FIELD_DP64(icsr, ICSR, IRM, spi->irm); + icsr =3D FIELD_DP64(icsr, ICSR, ACTIVE, spi->active); + icsr =3D FIELD_DP64(icsr, ICSR, HM, spi->hm); + icsr =3D FIELD_DP64(icsr, ICSR, PRIORITY, spi->priority); + icsr =3D FIELD_DP64(icsr, ICSR, IAFFID, spi->iaffid); + + return icsr; +} + +uint64_t gicv5_request_config(GICv5Common *cs, uint32_t id, GICv5Domain do= main, + GICv5IntType type, bool virtual) +{ + GICv5 *s =3D ARM_GICV5(cs); + uint64_t icsr; + + 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; + } + + switch (type) { + case GICV5_LPI: + { + const GICv5ISTConfig *cfg =3D &s->phys_lpi_config[domain]; + + icsr =3D l2_iste_to_icsr(cs, cfg, id); + trace_gicv5_request_config(domain_name[domain], inttype_name(type), + virtual, id, icsr); + return icsr; + } + case GICV5_SPI: + { + GICv5SPIState *spi =3D gicv5_spi_state(cs, id, domain); + + if (!spi) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_request_config: tried to= " + "read config of unreachable SPI %d\n", id); + return R_ICSR_F_MASK; + } + + icsr =3D spi_state_to_icsr(spi); + trace_gicv5_request_config(domain_name[domain], inttype_name(type), + virtual, id, icsr); + return icsr; + } + default: + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_request_config: tried to " + "read config of bad interrupt type %d\n", type); + return R_ICSR_F_MASK; + } +} + static void irs_map_l2_istr_write(GICv5 *s, GICv5Domain domain, uint64_t v= alue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 37ca6e8e12..409935e15a 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -240,6 +240,7 @@ gicv5_set_enabled(const char *domain, const char *type,= bool virtual, uint32_t i 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_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 =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_stream.h b/include/hw/intc/arm_gicv5= _stream.h index af2e1851c2..670423fdad 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -126,4 +126,28 @@ 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); + +/** + * gicv5_request_config + * @cs: GIC IRS to send command to + * @id: interrupt ID + * @domain: interrupt domain to act on + * @type: interrupt type (LPI or SPI) + * @virtual: true if this is a virtual interrupt + * + * Query the current configuration of an interrupt; matches stream + * interface RequestConfig command from CPUIF to IRS and the + * RequestConfigAck reply to it. + * + * In the real stream protocol, the RequestConfigAck packet has the + * same information as the register but in a different order; we use + * the register order, not the packet order, so we don't need to + * unpack and repack in the cpuif. + * + * Returns: the config of the interrupt, in the format used by + * ICC_ICSR_EL1. + */ +uint64_t gicv5_request_config(GICv5Common *cs, uint32_t id, GICv5Domain do= main, + GICv5IntType type, bool virtual); + #endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169181; cv=none; d=zohomail.com; s=zohoarc; b=oGB/QRLTIRHrlQo06HzzG4UiAjERLgwTHC3eVUSxSfNajdxtXXETZIsMamzVoEkvSUYy1XVP9xR3iiiRxmZIp708aswBfMMgAQKyORnehCFhNNb8gux3ukpxO4vWenk50MxTev7O2NFlbJMcvoqjt2KPfAaX/qHOurif7RJVXWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169181; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=RgyBHbgnTuAZMgct0W7kYb5/6ElaDq/A+vKEA2nxgy4=; b=iapTbzrhvLp97u2ixmaj/1l0+qXo19vgexmn090H36emSUEOMnoiW5oWlIobg+AnJR3HFH0eq8sW2kwtDOzNaJBdUcGxEWMUm6QVJmIq0UqROnTVbMD06O4kCR04PJZfMtEUXpGmMYzPSPOfCk6HM2tdODWr+xf/9UqUtDT5/2w= 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 1778169181612535.6195461002948; Thu, 7 May 2026 08:53:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11X-0003qH-Vx; Thu, 07 May 2026 11:52: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 1wL11V-0003j1-Rw for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:26 -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 1wL11U-0003tH-3G for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:25 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4893940bb5eso6533755e9.3 for ; Thu, 07 May 2026 08:52:23 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169142; x=1778773942; 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; bh=RgyBHbgnTuAZMgct0W7kYb5/6ElaDq/A+vKEA2nxgy4=; b=p6h3bOF2V5Pep6b0D6V8YNB34YKEtt4UsuwpWk8o92HQAl8GS6S08xMPvICswCOO9d 8q6JEJmiDYQ6+cwSG0SWDKoFWHp4PpAZ4C1VBpMFOdgXfqMR1UWkfpOE95qatnrCVGf+ /g+4oNnjfsYfKvHXmazMEAnCPfJBrTT4bGRmijQ3yR3tmHfxqlNT+MoQeQqx2hElERg2 psIp4lfJrCb2BMe2OmxYlPOdwC5HhReLXDCXQkId6CuXs6ev2nAmgS8XIFc3fHmtm6ne prpxFNuafkGJy7ZQrAqcJO+/rN+gK5Kwn0/XRLa7xjR36guDxZh2k/fjT+6OiqcC5izg INbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169142; x=1778773942; 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; bh=RgyBHbgnTuAZMgct0W7kYb5/6ElaDq/A+vKEA2nxgy4=; b=iuVvj91UESfPk5FwMDEopEXX5Sfnn7Yfz0ayqpxQdC06bt8mckoZ95/4dw77OoFIbr tH2WvcKjT/c1kJOQzv6rZu8j+zniEwQCOyiWYTp1J4NTNJZq27ApXcb7uSmPwGP6HDGC mIQ73SsnFaG0QNekNaYDzsWYahxCZxmsWZabPlekYOWI4SMp2BlFB9cw8rU5Nd+Ys6cS PIX0oe7LrPI71raheN/uNp/TESop1oCq+uyfmCdKI6Bs3qvJUKnXeKrWqUdHpyoIuLPD 0qGDv5GzwUpj0tZvmGkuwdJ2lom5ZkmGIv4jQ24FRixi13guceJYqkG5vdPdqIqPBXqh mAlw== X-Gm-Message-State: AOJu0YwIu1lQ/H0lowEflQr5SM6bR3gAGLY7yXgMiYzJ9Vk2Utwhoeko jTTRjkEAyx5wW9ut6snKRsPiS/T90GPlyOvVCvGlSumbeBfD8We+61V/ubuXXT9S3ebJvPcC32k 1eTLl X-Gm-Gg: AeBDievNmvzaF8muay+YiRd50P7nbsu4vR0mCZbR5o0gm7aUOjmlAl6QG7dAkEyDyc6 Fp4xdEZu967VyP20t4B1e+fqh2U+L4FyXXpDDeVru/fRfKF+o9oLSo7A6S+hpajmCK3ik8QYfYI JfQT4TAcPYzNGALy8w5oObjEBrW6tq/b67FaOW91So2eZAT4CV6a+cyRgWYZPZHkNNLDppk9dnu 2HnNQU/qAEburvLf8XnXOAdTViAjWW1WOE0h4XnTBhq1+XCokLeJhXdid29dOPVBvBNPp7U+hjd nZ7SRgUZR5Tyi2xFD8+MmgBIrFUkuN2fN8TxEqnJCtxNOh56yoGbVfuYkJzV2xFPBtFlb98FbpL Pdywf4GFyLhGmPcneKr4kzNouxx3b6G3d+dwp4Z6BRTZL1gct8PH0j13V9DUBaeOFrbpocCsrhb acnQZo89nS1kd/sSzxd+tvpqnPPZzMYYj8WgW/7D7HiHhejJlq/iqyZ/tblF+9TQMtvNSmy1IGF WEtJnkdqp+cE38OG3NrQupKYVlKWPM/yYWoKftJsw== X-Received: by 2002:a05:600c:c4a3:b0:489:1cd2:610a with SMTP id 5b1f17b1804b1-48e51f258damr136003175e9.9.1778169142294; Thu, 07 May 2026 08:52:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/67] target/arm: GICv5 cpuif: Implement GIC CDRCFG and ICC_ICSR_EL1 Date: Thu, 7 May 2026 16:51:13 +0100 Message-ID: <20260507155154.1886557-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169183001158500 Content-Type: text/plain; charset="utf-8" Implement the GIC CDRCFG system instruction, which asks the IRS for the configuration of an interrupt, and the system register ICC_ICSR_EL1 which is where the answer is placed for the guest to read it. We mark ICC_ICSR_EL1 as ARM_CP_NO_RAW, because we do not want to have this migrated as part of the generic "system register" migration arrays. Instead we will do migration via a GICv5 cpuif vmstate section. This is necessary because some of the cpuif registers are banked by interrupt domain and so need special handling to migrate the data in all the banks; it's also how we handle the gicv3 cpuif registers. (We expect that KVM also will expose the cpuif registers via GIC-specific ioctls rather than as generic sysregs.) We'll mark all the GICv5 sysregs as NO_RAW. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-27-peter.maydell@linaro.org --- target/arm/cpu.h | 5 +++++ target/arm/tcg/gicv5-cpuif.c | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 91cb2b87f0..aa89b457b9 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -596,6 +596,11 @@ typedef struct CPUArchState { uint64_t vmecid_a_el2; } cp15; =20 + struct { + /* GICv5 CPU interface data */ + uint64_t icc_icsr_el1; + } gicv5_cpuif; + struct { /* M profile has up to 4 stack pointers: * a Main Stack Pointer and a Process Stack Pointer for each diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 0c4349f8a7..8cf09791c1 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -35,6 +35,9 @@ FIELD(GIC_CDHM, ID, 0, 24) FIELD(GIC_CDHM, TYPE, 29, 3) FIELD(GIC_CDHM, HM, 32, 1) =20 +FIELD(GIC_CDRCFG, ID, 0, 24) +FIELD(GIC_CDRCFG, TYPE, 29, 3) + static GICv5Common *gicv5_get_gic(CPUARMState *env) { return env->gicv5state; @@ -134,6 +137,19 @@ static void gic_cdpend_write(CPUARMState *env, const A= RMCPRegInfo *ri, gicv5_set_pending(gic, id, pending, domain, type, virtual); } =20 +static void gic_cdrcfg_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + 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); + + env->gicv5_cpuif.icc_icsr_el1 =3D + gicv5_request_config(gic, id, domain, type, virtual); +} + static void gic_cdhm_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -194,11 +210,22 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .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, + .writefn =3D gic_cdrcfg_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, .writefn =3D gic_cdhm_write, }, + { .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, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.icc_icsr_el1), + .resetvalue =3D 0, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169499; cv=none; d=zohomail.com; s=zohoarc; b=fpcaFVHx8nTzbVXwXCmDnvqccsBBhUo8mmUrYVWQJ2NKdPhqa9KiikX2OwMuY1kwGEW43SPkmbAvWC1eqpmz+ESWVwQCx6x9Qcc2hahGpRdIzhQoysOSJPR4QgLNAUBQ1SwItE69rZMPgf5qITXJX3msP09A4qKOBEuuulbfV/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169499; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=6PxEjiAL0LMewzxVDQQEeO72wrHqLuLKT9LMHvMzfhk=; b=UkyaZT2QRqlRovkPrxjxae+HGTfaVMTJ2TbFE1iDDCItrRIGF7HWIB/LOhzu6RuOF5YdPK4J9feo90qLQgw59DUS84Uj1dBwGhQM+xQhcKkZWEnJj9ZYln4vFfAw49Nl57M0perXTL3fu6V6e09ZRFRgCcfjtqZWU9UFqgwWLjo= 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 177816949940573.68584535653008; Thu, 7 May 2026 08:58:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11a-0003w2-Jp; Thu, 07 May 2026 11:52: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 1wL11W-0003lt-RL for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:26 -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 1wL11U-0003th-VP for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:26 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4852b81c73aso9866955e9.3 for ; Thu, 07 May 2026 08:52:24 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169143; x=1778773943; 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; bh=6PxEjiAL0LMewzxVDQQEeO72wrHqLuLKT9LMHvMzfhk=; b=iPEGhr/e3reCJ1kS0dwY5fqOW5Swrf6l2+24mb3ZoYVUWn8EMrY9bspAVqHc3t64qg NCOdQSzu98akgO8bN7ZYvkm6XNCYq4MFQ9nrHjs1ESr+ha/l3jb3Z8iP2CJLFDaYc5NJ GHGNmFkWYa6ffkO6SwnbZTAQDNcJtPFgPm4943TZJCbQ91gvk3zT91QADHDltoNaSbKz SSVFmCI0ZHeaUVnrE8etevkCAc0t9IL1aiKFQw8hNbc2+5zE5FcudVZ5khCY09F41FKI uazN5EYxEEoZJHdADv59sJ13u468nl3/+mQNiDb3n2Ka+gJGnITqKEq6K9xqo1/VgXxf AxbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169143; x=1778773943; 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; bh=6PxEjiAL0LMewzxVDQQEeO72wrHqLuLKT9LMHvMzfhk=; b=XuVv0sZRR6+9daGnRHS8nd5xDmLXnlOuUOaztfpwZoDMPE65s4lS3UFV+1Pd+W0YKn QySsknxoh9vsbv+8bw51WlvckX+ZKY2RfMevW5g8mg/TZs8JswZPCTLVKoYtGUtd3TEd e2oK/sOwGJzjsJxM/9MefvZVHvncHaSsnYnfhDwTOkbV/+v3Mq4IKGl/6Cunn+IZgIPM Btf1YI8b1qN2li7YxLzjrMoScqL3IaABv6QiFHvTYl8xtcZAeBDE/D8jOwV7ppq99Y3l V7AMWq/SjZelacoLLZElZoOuXsuxfllL3VDYbP+GxPww6uYO9bMLP58ASX1PybE7WCK7 oR5g== X-Gm-Message-State: AOJu0YwbER7J6Nrnk5l9B/OmOf2dvqMH4ue+zV/urtXnS8jm5dHijV/G eQ0mACdd+nOzbKa8iAyMJ1CzT51HYhpLKWPp8b9Z75zhCzuMPTdP/sRpowMqXpA/vbMjdKq24n3 Ava7O X-Gm-Gg: AeBDiesvhrjzEv01V7nTm0kpZ2DGk7Qm/Jor+WW6gsCEGV+u3IueFXQo9YBWnNXyo3Y XkYdTsj0WlkZ8U5kZEm8tltlfRua31qSPMKu7jIDl0kpI+m7VzYBgcKx/Uyb3Yiz7hLmk2T9jKN HY551unIORXd9OuTAkaIduK9DZix9k4MF8kfQxqg9u+g4oZ4OqR+LgAdDCbGYSt9XWUwlvNKqwi 388GkCBEa+TBsW/8g9t/TyF+5nTMH97HiCNm90bv3/+DKbSuuaqY6akBk2jw8dj8L+p2ipTvK4P 0LcnOQwLQYx7+ozT/FpbxSYNzdrAeDdKcOyioG0WPGm8l7Fi7YzD+TuDPTSIwiQ+oNw2ESX0OK1 hdKTaotxzKnzUZnUWFYmLnRwGH7DZGCZp3kxuWRBBP9pkh0f8FrmhOQbe7lfb0Ki1nwPJmU9NG2 RO/BZR/z1RoAc5v5mGX0Up4cOPhL0DROYZMo9OmoeTuDio02gTSgFZIXkCHqurzzH+fEqX1lFDC n6VB075GByWS1C0G9uDYewvVT5XW4k= X-Received: by 2002:a05:600c:8011:b0:488:904b:f31 with SMTP id 5b1f17b1804b1-48e51f3bbabmr134562975e9.22.1778169143274; Thu, 07 May 2026 08:52:23 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/67] hw/intc/arm_gicv5: Implement IRS_SPI_{SELR, STATUSR, CFGR, DOMAINR} Date: Thu, 7 May 2026 16:51:14 +0100 Message-ID: <20260507155154.1886557-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169500935158500 Content-Type: text/plain; charset="utf-8" Implement the IRS registers IRS_SPI_{SELR,STATUSR,CFGR,DOMAINR} which form the config access for setting the trigger mode and domain of an SPI. The way these work is that the guest writes the ID of the interrupt it wants to configure to IRS_SPI_SELR, and then it can read and write the trigger mode of that SPI via IRS_SPI_CFGR and the domain via IRS_SPI_DOMAINR. IRS_SPI_STATUSR has a bit to indicate whether the SPI is valid, and the usual IDLE bit to allow for non-instantaneous updates (which QEMU doesn't do). Since the only domain which can configure the domain of an SPI is EL3 and our initial implementation is NS-only, technically the DOMAINR handling is unused code. However it is straightforward, being almost the same as the CFGR handling, and we'll need it later on. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-28-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 68 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 9 ++++ 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 04d4391ae5..6ff3a79745 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -310,6 +310,22 @@ FIELD(ICSR, HM, 5, 1) FIELD(ICSR, PRIORITY, 11, 5) FIELD(ICSR, IAFFID, 32, 16) =20 +static GICv5SPIState *spi_for_selr(GICv5Common *cs, GICv5Domain domain) +{ + /* + * If the IRS_SPI_SELR value specifies an SPI that can be managed in + * this domain, return a pointer to its GICv5SPIState; otherwise + * return NULL. + */ + uint32_t id =3D FIELD_EX32(cs->irs_spi_selr[domain], IRS_SPI_SELR, ID); + GICv5SPIState *spi =3D gicv5_raw_spi_state(cs, id); + + if (spi && (domain =3D=3D GICV5_ID_EL3 || domain =3D=3D spi->domain)) { + return spi; + } + return NULL; +} + static MemTxAttrs irs_txattrs(GICv5Common *cs, GICv5Domain domain) { /* @@ -1010,6 +1026,38 @@ 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_SPI_STATUSR: + /* + * QEMU writes to IRS_SPI_{CFGR,DOMAINR,SELR,VMR} take effect + * instantaneously, so the guest can never see the IDLE bit as 0. + */ + v =3D FIELD_DP32(v, IRS_SPI_STATUSR, V, + spi_for_selr(cs, domain) !=3D NULL); + 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); + + if (spi) { + v =3D FIELD_DP32(v, IRS_SPI_CFGR, TM, spi->tm); + } + *data =3D v; + return true; + } + case A_IRS_SPI_DOMAINR: + if (domain =3D=3D GICV5_ID_EL3) { + /* This is RAZ/WI except for the EL3 domain */ + GICv5SPIState *spi =3D spi_for_selr(cs, domain); + if (spi) { + v =3D FIELD_DP32(v, IRS_SPI_DOMAINR, DOMAIN, spi->domain); + } + } + *data =3D v; + return true; } =20 return false; @@ -1041,6 +1089,26 @@ 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_SPI_SELR: + cs->irs_spi_selr[domain] =3D data; + return true; + case A_IRS_SPI_CFGR: + { + GICv5SPIState *spi =3D spi_for_selr(cs, domain); + if (spi) { + spi->tm =3D FIELD_EX32(data, IRS_SPI_CFGR, TM); + } + return true; + } + case A_IRS_SPI_DOMAINR: + if (domain =3D=3D GICV5_ID_EL3) { + /* this is RAZ/WI except for the EL3 domain */ + GICv5SPIState *spi =3D spi_for_selr(cs, domain); + if (spi) { + spi->domain =3D FIELD_EX32(data, IRS_SPI_DOMAINR, DOMAIN); + } + } + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index aa5877ee05..607b99c2ac 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -92,6 +92,15 @@ static void gicv5_common_reset_hold(Object *obj, ResetTy= pe type) cs->spi[i].domain =3D mp_domain; } } + + for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { + /* + * We reset irs_spi_selr to an invalid value so that our reset + * value for IRS_SPI_STATUSR.V is correctly 0. The guest can + * never read IRS_SPI_SELR directly. + */ + cs->irs_spi_selr[i] =3D cs->spi_base + cs->spi_irs_range; + } } =20 static void gicv5_common_init(Object *obj) diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 6897f94117..c5a64bf86d 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -85,6 +85,7 @@ struct GICv5Common { =20 uint64_t irs_ist_baser[NUM_GICV5_DOMAINS]; uint32_t irs_ist_cfgr[NUM_GICV5_DOMAINS]; + uint32_t irs_spi_selr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169258; cv=none; d=zohomail.com; s=zohoarc; b=bz89VtlaSbw734b7+RrTjawI7jeC9W+OLhoEtKnhN+BzmwyvpSC99Or6OJHSF+ZV6YrMj5x1LVPcX46xOslBp02uFmywFiNJkzd+yH3UWyPlOHeicY0Yx0MCRsekTs4HIlJlNG5dZRRMIfetQtniFGL7M4WpPL2/KzK6s79iS1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169258; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=9kSvZPNJ/0h8DslXFM1DRCfgRBIyBkzr5YFk2QTNNLU=; b=nrmVod98qN+jxnivCygA+CU6xEVY2TwiNSMMJsx1wvtahCDt3bC1Qh9ucxjW6uZqtoWyslqkIxUKrn+ap0tQiVQY2u5pgIt9rubp28q5YKIwKrWwfnulMDjkhGE5U1HLZ9bso406CQDP5BvCNh1ifvykBFcuKxnNi2zkNilN0Q4= 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 1778169258504923.8562166477861; Thu, 7 May 2026 08:54:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11b-0003xF-4k; Thu, 07 May 2026 11:52: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 1wL11Y-0003qT-0Q for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:28 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wL11W-0003u1-1I for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:27 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-488b8bc6bc9so6698875e9.3 for ; Thu, 07 May 2026 08:52:25 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169144; x=1778773944; 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; bh=9kSvZPNJ/0h8DslXFM1DRCfgRBIyBkzr5YFk2QTNNLU=; b=Cw2inXfKMVymbsPbFniVCsUDweQ4iCrA0qxndeAhKnxnrykK17w7+PhDQbkMyiQ2SF 2m0oJG4cqIHhgGOAQrPi6WpcCaLRs40IDl0Lm+LvUAnNoV0seufICA07xAxMkj4N6f6y xkZhJHvifOM91AUtkUSbmj8BmyqYhXN1DTdscy1Bs53D3ppQQGC7IvmgAjky6OSSAYkq l7f2z+efvbnCQ8CZo4/WPqdcD4FINAmabBXO3cHRQSEYVuufY4UMwodRSnkKLP27Bqsi VCY5r2yl8x4MUvxkSdzb6LNx4Fkx6OG92Aakkj5Z68BQMTM64ddnbZaug8JPEk3Zv2IK 04bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169144; x=1778773944; 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; bh=9kSvZPNJ/0h8DslXFM1DRCfgRBIyBkzr5YFk2QTNNLU=; b=QoYkea9aSwPS4Kq5gQi86vTlTmF4WkWuiaeGhqehqaqKf+VHuEau3Z875h1eVWrdMH vwkqjNb/P3Vgp7SMihn36pSQZV4K2kvAKD5gRLHLVLSiWTGBlwI5FLX6lCxJRZ3Vh2ig CF5EFNyf//0lvWN85RZI4cNpnBQxjJFMM6aHceqk3tpbxjl5as6LmZuMlxaVs8fPBfHR XLFKZADVhTgpEFuqFCXUzsM3bTzPrQGg33/k/v99ZNtnTW+RO9vd9UwmswW2IgVx4dSd p8a/14C4uf3BoKpvE52gOKNTJUp1KXxC6H3TNvPcXQzwY1EMPzSlnqzUUJqkpHZ4QeLB Ajbg== X-Gm-Message-State: AOJu0Ywur+qKg3HSh/4H444gU47gGdXKqCgEUCXk+OlqQX2sYVJjQ8un DLVZcM3B5afWlydgYM/QP5zGewYHNzNKmmyhIcMIiOp+L+dsEOXPXLau0WxLjk8IAlfUpdr3kkl 8sFHN X-Gm-Gg: AeBDiesWXgpMWx7/jsgGGzQB9WLnqEjpwAe7fhUgLo6r/tM4SXpQZmp0x/Sy5zJgb6w ubMPuqFkBK2S1DDqqKPTJuwfLb+obFHZqKP7MPoBmdVhNQ60lKHN1muLpYjpr3hfKpXBJ+/7jAo aoHqcsGln+UFS31uV0yNFar/70rfu1OwUmw+04u2j0JkUARa3WKBK3dW8rAf6fsL+2ADGrA2Y9r XV2iO+eSEuYcLKVWLHDPbq3+7N0dbWIAianwa0dwt51RPUZlg1cEAWRh29DbMtzqNYxWiz2MLYC HrRSFGpy9vdsrrVOwkEO7xjHH+UqDy/wcpt7po4GNm0hDRw7MJMwrnNNEMfwrhiO1TN+GRFmLhH fYdZ84fmHpX16D1C/cDu37CM1HyZH6y/0Obv6mGCByP4BwoxmTXA5QPZJl2TptuqPijeLIyVW0+ /EIhaRY2yyx8/7b2AIcY28mn8Is2tw23U4U9EDAUdBI1GQEIminPpH9sCx9f901txugder+IRiO NsKVDELBnozJFxhbXmSAIcO6SGhxB5yiQMTdD9yKg== X-Received: by 2002:a05:600d:10:b0:489:a4:e555 with SMTP id 5b1f17b1804b1-48e51f36fc6mr114720755e9.21.1778169144187; Thu, 07 May 2026 08:52:24 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 28/67] hw/intc/arm_gicv5: Update SPI state for CLEAR/SET events Date: Thu, 7 May 2026 16:51:15 +0100 Message-ID: <20260507155154.1886557-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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: 1778169260863154100 Content-Type: text/plain; charset="utf-8" When an SPI irq line changes level, this causes what the spec describes as SET_LEVEL, SET_EDGE or CLEAR events. These also happen when the trigger mode is reconfigured, or when software requests a manual resample via the IRS_SPI_RESAMPLER register. SET_LEVEL and SET_EDGE events make the interrupt pending, and update its handler mode to match its trigger mode. CLEAR events make the interrupt no longer pending. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-29-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ hw/intc/trace-events | 1 + 2 files changed, 60 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 6ff3a79745..bc887233f5 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -946,6 +946,28 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain = domain, uint64_t value) } } =20 +static void spi_sample(GICv5SPIState *spi) +{ + /* + * Sample the state of the SPI input line; this generates + * SET_EDGE, SET_LEVEL or CLEAR events which update the SPI's + * pending state and handling mode per R_HHKMN. The logic is the + * same for "the input line changed" (R_QBXXV) and "software asked + * us to resample" (R_DMTFM). + */ + if (spi->level) { + /* + * SET_LEVEL or SET_EDGE: interrupt becomes pending, and the + * handling mode is updated to match the trigger mode. + */ + spi->pending =3D true; + spi->hm =3D spi->tm =3D=3D GICV5_TRIGGER_EDGE ? GICV5_EDGE : GICV5= _LEVEL; + } else if (spi->tm =3D=3D GICV5_TRIGGER_LEVEL) { + /* falling edges only trigger a CLEAR event for level-triggered */ + spi->pending =3D false; + } +} + static bool config_readl(GICv5 *s, GICv5Domain domain, hwaddr offset, uint64_t *data, MemTxAttrs attrs) { @@ -1096,7 +1118,24 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, { GICv5SPIState *spi =3D spi_for_selr(cs, domain); if (spi) { + GICv5TriggerMode old_tm =3D spi->tm; spi->tm =3D FIELD_EX32(data, IRS_SPI_CFGR, TM); + if (spi->tm !=3D old_tm) { + /* + * R_KBPXL: updates to SPI trigger mode can generate CLEAR= or + * SET_LEVEL events. This is not the same logic as spi_sam= ple(). + */ + if (spi->tm =3D=3D GICV5_TRIGGER_LEVEL) { + if (spi->level) { + spi->pending =3D true; + spi->hm =3D GICV5_LEVEL; + } else { + spi->pending =3D false; + } + } else if (spi->level) { + spi->pending =3D false; + } + } } return true; } @@ -1109,6 +1148,17 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, } } return true; + case A_IRS_SPI_RESAMPLER: + { + uint32_t id =3D FIELD_EX32(data, IRS_SPI_RESAMPLER, SPI_ID); + GICv5SPIState *spi =3D gicv5_spi_state(cs, id, domain); + + if (spi) { + spi_sample(spi); + } + trace_gicv5_spi_state(id, spi->level, spi->pending, spi->active); + return true; + } } =20 return false; @@ -1259,8 +1309,17 @@ static void gicv5_set_spi(void *opaque, int irq, int= level) /* These irqs are all SPIs; the INTID is irq + s->spi_base */ GICv5Common *cs =3D ARM_GICV5_COMMON(opaque); uint32_t spi_id =3D irq + cs->spi_base; + GICv5SPIState *spi =3D gicv5_raw_spi_state(cs, spi_id); + + if (!spi || spi->level =3D=3D level) { + return; + } =20 trace_gicv5_spi(spi_id, level); + + spi->level =3D level; + spi_sample(spi); + trace_gicv5_spi_state(spi_id, spi->level, spi->pending, spi->active); } =20 static void gicv5_reset_hold(Object *obj, ResetType type) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 409935e15a..4c55af2780 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -241,6 +241,7 @@ gicv5_set_pending(const char *domain, const char *type,= bool virtual, uint32_t i 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 +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" =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 Sat May 30 18:35:06 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=1778169156; cv=none; d=zohomail.com; s=zohoarc; b=h2BdfyFhVXnClqP6PazzMbrNEx/0LcfaAFCoWCxhpF2v9F279b8pmtNYtodEPQF2jomTHnhxZxq+bN2QLjQtCxNdQ5sDi/E0s4zsXDAWReBmTw9npPFpj0/LIi+WEDGLycvYj+z8SnfpnuvIj2xuEpLz1OTOictyOX21mes+0+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169156; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=9oGVwfR54uhD8ZqlC1hsQ13c9LMwPv+Y80P0CRoZjqE=; b=HNzwtSD6UgSEUoT1+eowlXCscJhHsZf4NQhcVRVI8evQGeGDcHj2LcOV1IuexjFC+pKZOH1FV+ThtiMyK/MlvANcDdvX1tMJk8HY/r907DyocDl9YZdwltrIEhqcr+l1hjOr6NoO2foMo9yEirpB7Fl7uKM6+5snEI5MKjIqMeI= 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 1778169156661383.28357016492873; Thu, 7 May 2026 08:52:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11Z-0003ut-Um; Thu, 07 May 2026 11:52: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 1wL11Y-0003qw-Eu for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:28 -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 1wL11W-0003uJ-Mn for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:28 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-48a563e4ef7so9827265e9.0 for ; Thu, 07 May 2026 08:52:26 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169145; x=1778773945; 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; bh=9oGVwfR54uhD8ZqlC1hsQ13c9LMwPv+Y80P0CRoZjqE=; b=bFmEJWOANEAXF+hsGP/Qr+fpAxLsF3Z33EOyQeTJKsr/32N086UlfyWFEbJqHIZniD sqdprcdM86c0Stg8n6U9rKyVgUDfAn2sjpbb5MoTxiXS1RFps28mrf8HV+YALY0bMDya 0hO2z3TaxrG6DSnihPOwVOHk17lnAhfldNfyrZwT0I8v9yfvWtNgUlD1UfDHsysQdoW+ I9ihpaQYQn3TXq6S81gpvHLTJDnGyxL1VALvzLfPHlULuYKYBqLH8CgV7vwCUaMdytHH hOTzmgR1LBj0l2cwVPjMWDyEQ4XF1U5zJga/0qQ0/3OdJZbhc3/D+u3SqfvSuWrfNYmS edyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169145; x=1778773945; 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; bh=9oGVwfR54uhD8ZqlC1hsQ13c9LMwPv+Y80P0CRoZjqE=; b=RS7SWUNOUx/UI/4kSE9txheIBADc+l8EbLXsoBnaQYSAyA5mVzRCAdY6PPUKIn3XQN URJ6aiwK5+XJrwTOGLB/InmIj84cN69RUXrppTS+Hu3+4ORP9TIoCIlC4y1pNCplJL4p eat61c5BYuZMVq60/v+646V+OR+e1mDVhicHY12D4eNxFXzDpnBH1rUwHAfFx/WFQ/4U jK6I53Nn+RxUBPv0UG9KUIWbFNQ2qerIdlP8teI+54VGeWFCfXokAS41N/e9JhcDi5ff gXoJdDxx4sqtLwP7eb5C+JYbr/T2DcnAtSONAEI+/nY07b049TLrTY0Esj99rNSH/IAi IjkA== X-Gm-Message-State: AOJu0YxLo6HB1/iZkd1jo5ZHAS80OdHVX03rN0eHUInFI+APaoBT74Xt YK3l0VZ5cFPROwYgJXF86wuLlOTWpU4+zjAJqgA15Y+7QY/DPK+DE3xmL1tWtfOkBUZhIZqs+ag wYLKQ X-Gm-Gg: AeBDietL1XiHFk71sBXCfCnWQxDaadamZN28gJUlMt4UpgXW5tPZ9dajJWhhHFzxq2Q 04FHpfKLSMHcCC6u/sKzQV5tjwiOuKNcvNcgEpae6+z0mTgJTRKQfuwLndQrek2TIEh8C4LmZtQ 126oh3fImPdppJ2JSNOcINAjZk/6DmHkPk1XF75IWQQynPVTDlq1bBKprRhEumfNr0NKLzHRLQS /g0Evkd3x5EUQFbPo4un6OvuDL/Mvhb00vvOXm7qyGya0ybKkAKGJLtHieiVMgdVf3RgZYQQsib UYqQNTJJCarZP1QsELpa8FVjbCc5sZ2+UX93WXrTk4LciSDb/znfNnLrlA7Up+o/Exm+EysIt8X YZ7XmwnWMMjdGt+hP1U/bY/l+X6uQ9vfxkdrwbJJ0MqRibmwHSURaxF7EzQEOdve5lH8Ae4Oqpn BhaQrstGv46PGl+4CJZnQFi2bRUU4I4rYu3sOy3cDCmfIwjlK36d/YyD4/7H0b1Hoc6aMTettVO vnFVsc+jUZtSmix X-Received: by 2002:a05:600d:8408:b0:48a:58e1:6d17 with SMTP id 5b1f17b1804b1-48e52bd4f17mr102477975e9.20.1778169145211; Thu, 07 May 2026 08:52:25 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 29/67] hw/intc/arm_gicv5: Implement IRS_CR0 and IRS_CR1 Date: Thu, 7 May 2026 16:51:16 +0100 Message-ID: <20260507155154.1886557-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169158862158500 Content-Type: text/plain; charset="utf-8" The IRS_CR0 register has the main enable bit for the IRS, and an IDLE bit to tell the guest when an enable/disable transition has completed. The IRS_CR1 register has cacheability, shareability and cache hint information to use for IRS memory accesses; since QEMU doesn't care about this we can make it simply reads-as-written. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-30-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 13 +++++++++++++ hw/intc/arm_gicv5_common.c | 2 ++ include/hw/intc/arm_gicv5_common.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index bc887233f5..3f397d9115 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1080,6 +1080,13 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, } *data =3D v; return true; + case A_IRS_CR0: + /* Enabling is instantaneous for us so IDLE is always 1 */ + *data =3D cs->irs_cr0[domain] | R_IRS_CR0_IDLE_MASK; + return true; + case A_IRS_CR1: + *data =3D cs->irs_cr1[domain]; + return true; } =20 return false; @@ -1159,6 +1166,12 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, trace_gicv5_spi_state(id, spi->level, spi->pending, spi->active); return true; } + case A_IRS_CR0: + cs->irs_cr0[domain] =3D data & R_IRS_CR0_IRSEN_MASK; + return true; + case A_IRS_CR1: + cs->irs_cr1[domain] =3D data; + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 607b99c2ac..69622e41c0 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -64,6 +64,8 @@ static void gicv5_common_reset_hold(Object *obj, ResetTyp= e type) =20 memset(cs->irs_ist_baser, 0, sizeof(cs->irs_ist_baser)); memset(cs->irs_ist_cfgr, 0, sizeof(cs->irs_ist_cfgr)); + memset(cs->irs_cr0, 0, sizeof(cs->irs_cr0)); + memset(cs->irs_cr1, 0, sizeof(cs->irs_cr1)); =20 if (cs->spi) { GICv5Domain mp_domain; diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index c5a64bf86d..f259d2d642 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -86,6 +86,8 @@ struct GICv5Common { uint64_t irs_ist_baser[NUM_GICV5_DOMAINS]; uint32_t irs_ist_cfgr[NUM_GICV5_DOMAINS]; uint32_t irs_spi_selr[NUM_GICV5_DOMAINS]; + uint32_t irs_cr0[NUM_GICV5_DOMAINS]; + uint32_t irs_cr1[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169407; cv=none; d=zohomail.com; s=zohoarc; b=GqQG6rS9q08lt7AS61Tj8fPjaqVZ6EZW2Pfqf3GBTlNT+AjXzmQsvIOP2eL+wOFaz1Ygz8nk4OA3FxUnnxm29JC/h12jrnjf9O8dN/ecz/+0DfrOAArRL4+dEfEJlDgZ8kcOaZn5fhTKoAghu0pGDrS2kfcYcUxgL0SCuOeYzqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169407; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=UfDVcv98jyHK8QZf2yirTNDFGYOzCBs5DRGWgCmfPs8=; b=MD2CmJbCqcsCm17J/StxguLOJE3sczXkIMKxli8z9svtXcekNbzmCHt4k9jziP4CbERI6tkqN0nXDohJZLfkrtiNZ6N/H5Gw41Y9wj8P6hdGXPjT3WxmcBgtEwTBRnsboIsCEj7Go7y7Njr7pA5LZncxZO5rS2Dc04qaxbm3tQo= 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 1778169407595581.7437010652733; Thu, 7 May 2026 08:56:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11b-0003yF-SP; Thu, 07 May 2026 11:52: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 1wL11Z-0003rG-23 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:29 -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 1wL11X-0003ud-K1 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:28 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-488af96f6b2so12021625e9.0 for ; Thu, 07 May 2026 08:52:27 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169146; x=1778773946; 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; bh=UfDVcv98jyHK8QZf2yirTNDFGYOzCBs5DRGWgCmfPs8=; b=j5wbIOHLXqr1mCtwZEp1gjnYyX5MxH4ZjEtrchYDhsmEuJq0uQGxyu0zALVjrDfiBZ 3RogtJ+pBC5xUer25r1KZke8MeFjcbjO+PX5zx2+Q/EOa+gLbhvad+UNs0AUrOdbl4TP AQ1AZGZSjZE/P4hI7uMS7JrscRIibNJIBrYftjsUEuF6mfZ6zcyaN1vpB3LD5k1YcY5l 7vokUZlJhKnObUq1bLdSL7zm5LZAuJ9nHUSG17fG9n6sr3jApHAgyglDbtXati9zbH9m IwcTnTA+m0IKmW4caclaI4AlFYxCFj2T6uFMOdXC1yANkg+ilZEQbadMzheml+Mqirzh bvig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169146; x=1778773946; 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; bh=UfDVcv98jyHK8QZf2yirTNDFGYOzCBs5DRGWgCmfPs8=; b=dY84N6m7ze5Ygp9w3cQMuZmWJEBFvnVEFjUZ3uixKvYrDDiCrYkGQJzdK6Ys4uSgoZ tsI/rWWA35JDBA0DEucv9ntMzicfpdGSSC5Atzt9SseVZsf9c4qPC7odSKAlF1J40gTc UwtjWchiihEPmxegp4lNsxtFptsp53I+xqlkJpDaEGyA3CctOMkxzDwAJzAePMA9xZPA pAAYkvSLJXWmnpoDpXfTAv6OihMjdkQcQTjYFibTmC3vW2ioLUiSgqsOcP+Lkd47V+pO dK2cvPM5os1tF/FZHTVOEWKNAfL5bNNHmIJNQw+GJ4SY0cTsMThAzbuj5U4SdUvvlOrp lWYg== X-Gm-Message-State: AOJu0YxxtvAaVx8OOnScMY3xDL26ttVKaYiZiBxn236K9PeBPMVbiqCo a85va7T1kAH4412H1oy6NXuE+AleiXdpYC4oko4CZcnesZr32QGAXDdX8eFN8yvUJ4r0N4ovi+r EPZwW X-Gm-Gg: AeBDiesgbecQSdjnEZi5xDLtVre7OtH34X2330F5KREQSxL/d2vtgNY4tP+zmFZGoCB 6QgVsX6y9AjIhAukfV+TgA/lfyngEl8I9/0kkph3yzAJdnP773wIUlcGWZNGVxyKI6JDbcfx1N4 vlycPs9uJJbg8y3iofMMGRVREhJy5rDloSAuvPq+S8LOVEFtY0+XSDGpM03uIEp5oIb58TVLO2Y rjstUwHriny61Md7d5+NfK+GcKqXxF+r3u6VDqgpv4BundU/1HM6jCvFbjvIoDonkaUiu18EtIy 8VMvaBariGfOCvfa0l/535yhXBZMjbC0rY0WfrEibImJHQkDrRhmLELH2YShzYdDvewUqNNCz3v uxGAKL1p3M1Ubc+w2Sm6/An9X1aBlf2XZ1O+/Jxna/0xnSUQIu0SqmpOpyg8vTKIDq1tRM/1nyv nJMGWLe739+DgdD/dyH92J4FZ4uURxm37l9zGbzbzNludyCuGMxHwUT7DrB87ufO0plHEgPJywH nVCmqSZmzvihTTdg0uXLaetQxN9fR8= X-Received: by 2002:a05:600c:4755:b0:48a:7b55:12a6 with SMTP id 5b1f17b1804b1-48e51dd5ef5mr138999165e9.0.1778169145995; Thu, 07 May 2026 08:52:25 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 30/67] hw/intc/arm_gicv5: Implement IRS_SYNCR and IRS_SYNC_STATUSR Date: Thu, 7 May 2026 16:51:17 +0100 Message-ID: <20260507155154.1886557-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169408362158500 Content-Type: text/plain; charset="utf-8" The IRS_SYNCR register is used by software to request synchronization of interrupt events. This means that in-flight interrupt events are guaranteed to have been delivered. Since QEMU's implementation is entirely synchronous, syncs are a no-op for us. This means we can ignore writes to IRS_SYNCR and always report "sync complete" via the IDLE bit in IRS_SYNC_STATUSR. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-31-peter.maydell@linaro.org --- 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 3f397d9115..7b0d9e16c4 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1087,6 +1087,10 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, case A_IRS_CR1: *data =3D cs->irs_cr1[domain]; return true; + case A_IRS_SYNC_STATUSR: + /* Sync is a no-op for QEMU: we are always IDLE */ + *data =3D R_IRS_SYNC_STATUSR_IDLE_MASK; + return true; } =20 return false; @@ -1172,6 +1176,9 @@ static bool config_writel(GICv5 *s, GICv5Domain domai= n, hwaddr offset, case A_IRS_CR1: cs->irs_cr1[domain] =3D data; return true; + case A_IRS_SYNCR: + /* Sync is a no-op for QEMU: ignore write */ + return true; } =20 return false; --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169216; cv=none; d=zohomail.com; s=zohoarc; b=iNFuExTbxlfaSIWkLCcF4bYOiRr71vbrowya5iE4Lg180cPkIMa38w5vnxV9cpx+jH20SGagZ3V2uUEDvKiYzsTBv57EHBq1eIOcDMzCQuT4V+qX0YPqTAQtvWmdNohCkYh8vKdknlflp8WmGMCzMj+X13Cj4fmGE81Adsxl1Ts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169216; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=2WJFdhjP1M6ypRwymI96woMtmQVRg2bYuGrvWFMPWrg=; b=Y3+2b/jedyNmV9oUTfAINA3dF2DmCmNRPa9ysXYavh88Dhujagm6CIFxBxNrsWni6mMBNHLtS6kvffpMwcFqtL3QL3LEBb5hZfAGp3/GHJoPsRKl+r3Svr7FomMzlMRbHUYPiKPROiaoy2mPBbTRoQEL91tMBo4vs/krs4u26AM= 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 177816921661683.43989787404678; Thu, 7 May 2026 08:53:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11c-0003yx-N6; Thu, 07 May 2026 11:52:32 -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 1wL11a-0003vI-4y for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:30 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wL11Y-0003uw-Dv for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:29 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-488af9fdaa7so6671665e9.1 for ; Thu, 07 May 2026 08:52:28 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169147; x=1778773947; 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; bh=2WJFdhjP1M6ypRwymI96woMtmQVRg2bYuGrvWFMPWrg=; b=of7u7piGmLJkZJh4E/XDpNoV4Rcd+FNQFc1D0gbk6lLzIRLWDd1psaCS8oA8T8+0Ly BQVIGEbLbTnKbHS38VdEBLm/l1QYa1duaPCNVABihZbW8tAR3/pyAz43P4UQuLQbwQjX x5xhS6WxH9ARTkLJjkw0J3f/JCJbDbH+knzX8JRZ+tews1xEERYERzQ44iq2rP02vzgQ G4NHBtPRwb2Sa5trJRywj/J8SwbFiPFjlTfoI4qjH3Beu2Sc3OKE18xq4dRPi7wcel/+ hG83cpv85G4Uzi8dNrOr4AlDdFzbRO5Y0HqXKtzuoqjsalceeEpjDil5+NqicKKIDmr3 aivA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169147; x=1778773947; 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; bh=2WJFdhjP1M6ypRwymI96woMtmQVRg2bYuGrvWFMPWrg=; b=e8mY0T0jTqL0e1Zjyag06PlTnQ+S8n0ZXP/aPofoNaJ2jI8z43XsS9tog7wLOa3pZd uqtDLV0D6OKnagVzZqWmjImYUswJAVrvZt3VGIb0zB/RQWpYn1fdQpRFizPz1VhlobXN PYKUaAMKbGi0BhvLYe43Em5KyTWu3hUiLrbENolrDHsz8XhsBeGgFs0Tw8RYfOGTMlxQ otc4MPqJjPTboBiKYFWtJuOrdgJhDKsR7jFPFYsVa9lNHAal/hOy64xEk442tSbDavSq OYBmcWte69AoHD5wITD5SCraQ9FcGW0iWiH3utnHg/nyYOhAIQSGPpgtkxGl024dQx4N 2+xg== X-Gm-Message-State: AOJu0YyQ3gpbLiqmIGTOdC+tccZ5isSPHc+GJ6TCInOTnlYyP3NQ6kyD 8o8FcSvm4g+yrS6nXes8E21cE4AC4Vldt9aOAbYptXP+wlT+yzuthAHFidyVm+yHalwaFQO3XQF CLvgl X-Gm-Gg: AeBDievkhNoqdZIHjn5L/dAG1WCU92vKYPXanGDTumABm6L87H/W9CiRG4A42qvjdvy 7zB8fRAEtndf+HHtPvv0SzqoXs0R+tjc/+W6n6nldr1mZ78LzjH9UaMF+2bi9L3RJTXbNuNGM7l cmhzACo+RQvtbN22TxRpJgSZMaU2gKepBR5e37Zx0yYd4xrNZyGBU/d5SnO33pGoLCx8bwN1piA rhKZHtpRSt3vvbN60J+shwnpBz4dC/xjKoEVoOZyI2UE73m4m1G1IbWOPuodmDARBxK16Ytl2MD Y9U1Z5NgQ8OavV+Zrg7l7xFDWYOJeSiUdWzgnte7xMJ+hxlRvwpO7h2rSkHlbl5V9jSHyKYM1/9 SAzS5fPeTsiF2fCrfpsXThiiHMOLDtjmrxOWdI9rIPo4qbb0LDDw+T4O3Y2dtrYKwH5u8yLcvaT CtqEY+mMM3jvfX0VCBx4pBm/DheHsFnBQzPYLjr+LrH8FdF9k9yK/BBuXNRkgv47B4tDVrWJ6nx BK86p1GqiR9aM3NTG5QAaaXbjz+aoE= X-Received: by 2002:a05:600c:a10d:b0:487:12c:e7e1 with SMTP id 5b1f17b1804b1-48e51e1f013mr107815895e9.11.1778169146847; Thu, 07 May 2026 08:52:26 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 31/67] hw/intc/arm_gicv5: Implement IRS_PE_{CR0, SELR, STATUSR} Date: Thu, 7 May 2026 16:51:18 +0100 Message-ID: <20260507155154.1886557-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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: 1778169218272154100 Content-Type: text/plain; charset="utf-8" The IRS_PE_CR0, IRS_PE_SELR, IRS_PE_STATUSR registers allow software to set and query per-CPU config. Software writes the AFFID of a CPU to IRS_PE_SELR, and can then read and write the 1ofN config for that CPU to IRS_PE_CR0, and read the CPU's online status from IRS_PE_STATUSR. For QEMU, we do not implement 1-of-N interrupt routing, so IRS_PE_CR0 can be RAZ/WI. Our CPUs are always online and selecting a new one via SELR is instantaneous, so IRS_PE_STATUSR will return either ONLINE | V | IDLE if a valid AFFID was written to SELR, or just IDLE if an invalid AFFID was written. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-32-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 39 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 1 + include/hw/intc/arm_gicv5_common.h | 1 + 3 files changed, 41 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 7b0d9e16c4..a95a9dc16b 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -968,6 +968,21 @@ static void spi_sample(GICv5SPIState *spi) } } =20 +static bool irs_pe_selr_valid(GICv5Common *cs, GICv5Domain domain) +{ + /* + * Return true if IRS_PE_SELR has a valid AFFID in it. We don't + * expect the guest to do this except perhaps once at startup, so + * do a simple linear scan through the cpu_iaffids array. + */ + for (int i =3D 0; i < cs->num_cpu_iaffids; i++) { + if (cs->irs_pe_selr[domain] =3D=3D cs->cpu_iaffids[i]) { + return true; + } + } + return false; +} + static bool config_readl(GICv5 *s, GICv5Domain domain, hwaddr offset, uint64_t *data, MemTxAttrs attrs) { @@ -1091,6 +1106,24 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, /* Sync is a no-op for QEMU: we are always IDLE */ *data =3D R_IRS_SYNC_STATUSR_IDLE_MASK; return true; + case A_IRS_PE_SELR: + *data =3D cs->irs_pe_selr[domain]; + return true; + case A_IRS_PE_CR0: + /* We don't implement 1ofN, so this is RAZ/WI for us */ + *data =3D 0; + return true; + case A_IRS_PE_STATUSR: + /* + * Our CPUs are always online, so we're really just reporting + * whether the guest wrote a valid AFFID to IRS_PE_SELR + */ + v =3D R_IRS_PE_STATUSR_IDLE_MASK; + if (irs_pe_selr_valid(cs, domain)) { + v |=3D R_IRS_PE_STATUSR_V_MASK | R_IRS_PE_STATUSR_ONLINE_MASK; + } + *data =3D v; + return true; } =20 return false; @@ -1179,6 +1212,12 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, case A_IRS_SYNCR: /* Sync is a no-op for QEMU: ignore write */ return true; + case A_IRS_PE_SELR: + cs->irs_pe_selr[domain] =3D data; + return true; + case A_IRS_PE_CR0: + /* We don't implement 1ofN, so this is RAZ/WI for us */ + return true; } =20 return false; diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 69622e41c0..180fe338a4 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -66,6 +66,7 @@ static void gicv5_common_reset_hold(Object *obj, ResetTyp= e type) memset(cs->irs_ist_cfgr, 0, sizeof(cs->irs_ist_cfgr)); memset(cs->irs_cr0, 0, sizeof(cs->irs_cr0)); memset(cs->irs_cr1, 0, sizeof(cs->irs_cr1)); + memset(cs->irs_pe_selr, 0, sizeof(cs->irs_pe_selr)); =20 if (cs->spi) { GICv5Domain mp_domain; diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index f259d2d642..59ac1c3880 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -88,6 +88,7 @@ struct GICv5Common { uint32_t irs_spi_selr[NUM_GICV5_DOMAINS]; uint32_t irs_cr0[NUM_GICV5_DOMAINS]; uint32_t irs_cr1[NUM_GICV5_DOMAINS]; + uint32_t irs_pe_selr[NUM_GICV5_DOMAINS]; =20 /* * Pointer to an array of state information for the SPIs. Array --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169249; cv=none; d=zohomail.com; s=zohoarc; b=Hq2iLKLwdfC0B8c6E7ac5bVY4KbJ6RX0OTR45fyYGuc6Tx3mH0nTe7y8kc6xZPa8yBEicXdOxOnRiRy7ADNJXvvtkEpghRffoKQ3wJAZ393pvIzip2XLNKt2LrJPbI6GnjjsJFQHm1W2zu51FKKKThivXe3T3PijvhW402OZc5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169249; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=zXdu13PwmRztjQL5k37gA2iPoUui6l6kZDs+nlsW5EI=; b=niuV5E7tpbg+7xmlHx3ULPbu7aHC3+j3NCbv8TBTehK+w44rc8aPiSDF7gzCCHa8KAQt7uSpZzmJL1znWh3BdKEsP/FRs+gt7ZBq96pkQADZEDE7242FygzZFR4Xn1xleUHk0w0w6bPGIT/ldj2RL3wsnqsA22NXSHnaV3yvRZ8= 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 177816924941580.88781401481572; Thu, 7 May 2026 08: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 1wL11b-0003yN-Sa; Thu, 07 May 2026 11:52: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 1wL11a-0003x3-U2 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:30 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wL11Z-0003vF-6H for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:30 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4852a9c6309so9002465e9.0 for ; Thu, 07 May 2026 08:52:28 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169148; x=1778773948; 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; bh=zXdu13PwmRztjQL5k37gA2iPoUui6l6kZDs+nlsW5EI=; b=RiH8v/zKFtRGrIBFEsail2t7srFJflpX9jc3Auf6VTG/TnBcsy8zouEKa68MrB5fox LSOO9JJwqa24Hwdvafg/PeaVGeOkWH4Zbl4iCEOJvzE7Hw7lCjDdf1gDLSPZgyu7ZgEI 5ufXERXAOKyItRBNqYzcVP2kA80E28yQnZOmydvMip+8Qk+ou1r6kygQ6ldZWjw1by90 aE4tu6unVpfMgF4yQt5uCfeDoh4GhQ/cQUrxr1+T3WeYJQxiz1NnaEeJ0PMhXyUyWj/4 zG8plPFDXzqv9/wGAQ6376Vv4h3y/EDbaA2vV9oRuN2PWWeZsLbFNGloJzoDtM53Nt5+ 6arA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169148; x=1778773948; 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; bh=zXdu13PwmRztjQL5k37gA2iPoUui6l6kZDs+nlsW5EI=; b=hsFyQkvBTlAqWVzUNegh15dUcf8zZt4/M2TpjgV/FHQS3U+FnJsUX36viIuTnpJDvv LQWWwvjg1cdyR+RMjPHgoF0lcfYj2qFgsvCcHVAY52+K9zAgQBX2xu/aichxw5SU8wOR 3R01v/RqsRUHc7UDXg24+n7FCb4J0nVQzERpztMFvj4PwVcvpWEaKbvHO377U7iD7KhQ TNSbQK6mLbubRZUT7RtFZ9akI8K2wMf5Q8f2f0eS8tgki8ynLB4t+0JYUGW37oic0R+G rbj06wZJGt1MW9lp/0e7JLEGGRSbQi9b1j+DN2gI9xD/8ZJ6urS9iUSNKM25UFAxe1Ln p1Lw== X-Gm-Message-State: AOJu0YzxzrWqpTdub3KBoXemy62YHcVUgovANBnNJBaV+QuzBd1pl3J9 8QROD7Kd/NjnVBzSquebo7pU6deE8xzyK86PmyuXMZz+hzph4GpT51Z3NXh8mRFe/GzZDP2eanJ RDAlH X-Gm-Gg: AeBDieupvjZx2Q/9Ygee5DalMS4dm1YaSA2wtNYVOjrb9ShHXEKj+wOoAnR4yP4VXkR VNtP6UyFjjS1xIyl3dTn1oIH7IoTIqt/qicSWLgl7w+JKqLWwOBOSMU9WPlXm+nsspcN3c0xX31 p7UIWJjUxRGn1Y/2nOV0xA92lsiVKhqmG9EgjUEQf+Mpqq6Or9wuT7v5ZXH8okDsLnvd97FIIvk 1bemeegXRbKwwlz7dley55eoMiwWViSLEPp6IpFgY2g4DLNvVqZ8fOMNSEo6TjmqzIBJXNNB66k BP+Oa2F4Egjpog0TRpWjxkhNAAPKlXzT1AIybHPWtZ7ppIj1t6KP6iokUR11uUnxH3FRa1ZISIj tH1R4aouiy+VBabBe5zImoauJLX5G6askPqzI9Zx++SPDFhglGLA/9fwXzG3vtgx/RVMc3WDq3p qXK7LkwY6hECB2XzbxbsJM8BVRWdOPnpR2KrarmG1ZRR4Lp0CdXo9BfZ6CZUOfqG5VQLKn4ltx5 pFuW/4AMp/f3/2cbIr06pZU97ZDCiY= X-Received: by 2002:a05:600c:3548:b0:485:3abe:ab86 with SMTP id 5b1f17b1804b1-48e51e0a6a2mr133838205e9.4.1778169147708; Thu, 07 May 2026 08:52:27 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 32/67] hw/intc/arm_gicv5: Implement CoreSight ID registers Date: Thu, 7 May 2026 16:51:19 +0100 Message-ID: <20260507155154.1886557-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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: 1778169251426158500 The GICv5 register blocks all implement the usual Arm CoreSight ID registers; implement these for the IRS. Although we only have one callsite at the moment, the ITS config frame uses the same ID register values, so we abstract this out into a function we can reuse later. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-33-peter.maydell@linaro.org --- 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 a95a9dc16b..866c1333c3 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -285,6 +285,9 @@ REG64(IRS_SWERR_SYNDROMER0, 0x3c8) REG64(IRS_SWERR_SYNDROMER1, 0x3d0) FIELD(IRS_SWERR_SYNDROMER2, ADDR, 3, 53) =20 +REG32(IRS_IDREGS, 0xffd0) +REG32(IRS_DEVARCH, 0xffbc) + FIELD(L1_ISTE, VALID, 0, 1) FIELD(L1_ISTE, L2_ADDR, 12, 44) =20 @@ -310,6 +313,31 @@ 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) + +static uint32_t gicv5_idreg(int regoffset) +{ + /* + * As with the main IRS_IIDR, we don't identify as a specific + * hardware GICv5 implementation. Arm suggests that the + * Implementer, Product, etc in IRS_IIDR should also be reported + * here, so we do that. + */ + static const uint8_t gic_ids[] =3D { + QEMU_GICV5_IMPLEMENTER >> 8, 0x00, 0x00, 0x00, /* PIDR4..PIDR7 */ + QEMU_GICV5_PRODUCTID & 0xff, /* PIDR0 */ + ((QEMU_GICV5_PRODUCTID >> 8) | + ((QEMU_GICV5_IMPLEMENTER & 0xf) << 4)), /* PIDR1 */ + ((QEMU_GICV5_REVISION << 4) | (1 << 3) | + ((QEMU_GICV5_IMPLEMENTER & 0x70) >> 4)), /* PIDR2 */ + QEMU_GICV5_VARIANT << 4, /* PIDR3 */ + 0x0D, 0xF0, 0x05, 0xB1, /* CIDR0..CIDR3 */ + }; + + regoffset /=3D 4; + return gic_ids[regoffset]; +} + static GICv5SPIState *spi_for_selr(GICv5Common *cs, GICv5Domain domain) { /* @@ -1124,6 +1152,13 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, } *data =3D v; return true; + case A_IRS_DEVARCH: + *data =3D IRS_DEVARCH_VALUE; + return true; + case A_IRS_IDREGS ... A_IRS_IDREGS + 0x2f: + /* CoreSight ID registers */ + *data =3D gicv5_idreg(offset - A_IRS_IDREGS); + return true; } =20 return false; --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169479; cv=none; d=zohomail.com; s=zohoarc; b=SeHfSIIpMwsimqfnzhoAu255ZIfPILhKPw09oqiFyx8NYSm6C/bHhYjKo6DLoTNScrLXPA33mzemqgz5PRMwK7K+4W3t9DGS5jyUkoeIJvFyShz6MkPBbZZLKgCr1Ilyoz1Od4vkv2UdrzQsfIQY85DLD5bm88SunOc9MOwsf0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169479; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=RODeQt9i+bgayBzEiwJIi4pCrFbJ9M8QFpaPNbna8o4=; b=iTNggDxuX5dN4ecrFBQ8eSZJnxRpGuA2oSoJjh1TBScDF1rybjhz4bQ8sPfmZnv8GO77CwMkBh2cbP/S1dDG2J+HzDJ0ltNiFHP7b0pWnWNt66dE5RQIRZnjhk4dAqIxCqwgkk3aIn3TTmaevEoBZKWetjedGGWfFepfKQe/QTU= 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 1778169479237178.72441787795412; Thu, 7 May 2026 08:57:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11e-000417-Oq; Thu, 07 May 2026 11:52:34 -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 1wL11c-0003yk-9n for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:32 -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 1wL11a-0003vZ-7l for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:32 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-48909558b3aso12269425e9.0 for ; Thu, 07 May 2026 08:52:29 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169149; x=1778773949; 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; bh=RODeQt9i+bgayBzEiwJIi4pCrFbJ9M8QFpaPNbna8o4=; b=Cs9/DKr4XkFKCZU7aYkr2NA/iYn/duDRrgXhQt0QSD00GZLs+OPh0ONNlMjR9KwSOV d9pqzZFrOhNMwGpVXldZp89LihPwdYKhJH5YHwwiH16N+1AfSnNeEY0+HMtZkGRBNY8i 6W2kg3SuuEpCr44OjSyoimzcZKGTjiz9M+ca2ZZWFHCCaSSP6zZgN0el2n6vk7seTKaU YNewD1S7Dd6bF42xnEj6O2pQ+AuCeAxUr4G/BUfg3tyLv0EI2e17vBvmqmcfs9GY8q6z zq2c0dbqjCGW0R3AP7+qrMLIX1hd4jqnOvAES6VG7aak7oBV/H3YJbxztpQF/w6oNPNs v4Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169149; x=1778773949; 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; bh=RODeQt9i+bgayBzEiwJIi4pCrFbJ9M8QFpaPNbna8o4=; b=s3w3CLRs+2jQetKZwngM7QdO8AkYgUpH5sTCKNQxGNXKxVva2QKRnk6VUsuQE88o0J xbuV+F4XF3P6OJ9P0HNIO5f0epgYzBGhM6i008ZTNWkF+B/ljr4cbtWBz1fKXbQIbZon cCkp451xezvby4WNLgMcFC88E/i0OHkn4btDOyXUzBidPJqy8yqwMiRfHoOx/ydeX+n/ OT2gwjovd5SHos8hAaWhmhzWtGyQF42I9pvt5toDZt9EM2XFJlAfB+jI7fC4RoR3C+oZ iXpA2Gwp27Dp8IhHrrZg7lncmNxWiYA0p2gRFIImcZ86UJH6Z9WgpU63DsxHmPrxYyVz h15A== X-Gm-Message-State: AOJu0YyUhgfS1fdnNI48f/M/kR7i1pMqyq44qrcM8i69OJN/+fA2z2ZX BKwCLCzJ3rdSy0Z58xnywDLuDB+1guC2sy5kTymyaje3FjC59T3S8NI8ijLBLlpeocdyJQAmPu/ rnNAK X-Gm-Gg: AeBDiet6TSjFmXleIbYnBs0hroRdV/4hwlr102kSjetdOBklQqrmm2yeJEhET4O4q+E ROpFjisAKKUWim1xpb6jezmNIfS395HF3JoLgxfvjYX9XBvjwv8Vxc4KFDDsBxJmlgcAWYufF12 Ir8HK0RtKCqRUmDSiW6y6iVHWDSikSzKORxiBwWXugykTJzhOnpWYStqYwC6ir2qBbqIHlNcbc9 hve9RB6m2NvPC67OzoVfAmisOycsupH6a0dBnzc3ZxxJNYcUAsqwu2iZ+9AFEBXP27gwaBqvI3A DBb2yUF9IzqALcwmlTvCgXgOpwdiygQmk2zE5+ZfX7SayschByVUBK/3HAi6mp+9zWQLhMJPjVx kJWb7nGyP1eSAU32ljiCi5SDP24b3sp9+GmiAa/6As9tvrevq0Lu081jEa16LLruM1+yz+wqyXQ ejLUxbUJaEQRrxspk3En72bGQEdZo8SGMIveobYmENPFt267q4OTYe8kYganPU0vyiG7z5U5+gj HziO2gwcLWLFrAmpwyfwEZzTSt0VepF55zcve99uw== X-Received: by 2002:a05:600c:8b06:b0:485:4388:3492 with SMTP id 5b1f17b1804b1-48e51e223ccmr139244685e9.11.1778169148567; Thu, 07 May 2026 08:52:28 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 33/67] hw/intc/arm_gicv5: Cache pending LPIs in a hash table Date: Thu, 7 May 2026 16:51:20 +0100 Message-ID: <20260507155154.1886557-34-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169481065158500 Content-Type: text/plain; charset="utf-8" The GICv5 stores information about LPIs in a guest-memory data structure. Iterating through this to identify the highest priority pending interrupt would be expensive; to avoid this we will use a hash table which contains an entry for each pending LPI and which caches the L2 ISTE. Typically only a few LPIs will be pending at any one time, so iterating through the hash table should be fast. We can access an L2 ISTE whenever it is valid, and can freely cache the data for as long as the IST is valid. We only need to ensure that we have written back the data at the point where IRS_IST_BASER.VALID is written to 0. We add an LPI to the cache when the pending bit is written to 1, and remove it when it is written to 0. Handling of checking the cache, and of adding and removing entries, is handled within get_l2_iste() and put_l2_iste(), which all the operations that read and write ISTE words use. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-34-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 116 ++++++++++++++++++++++++++++++++++-- include/hw/intc/arm_gicv5.h | 2 + 2 files changed, 112 insertions(+), 6 deletions(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 866c1333c3..989492d4b6 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -471,15 +471,22 @@ static bool write_l2_iste_mem(GICv5Common *cs, const = GICv5ISTConfig *cfg, =20 /* * This is returned by get_l2_iste() and has everything we need to do - * the writeback of the L2 ISTE word in put_l2_iste(). Currently the - * get/put functions always directly do guest memory reads and writes - * to update the L2 ISTE. In a future commit we will add support for a - * cache of some of the ISTE data in a local hashtable; the APIs are - * designed with that in mind. + * the writeback of the L2 ISTE word in put_l2_iste(). Not all these + * fields are always valid; they are private to the implementation of + * get_l2_iste() and put_l2_iste(). */ typedef struct L2_ISTE_Handle { + /* Guest memory address of the L2 ISTE; valid only if !hashed */ hwaddr l2_iste_addr; - uint32_t l2_iste; + union { + /* Actual L2_ISTE word; valid only if !hashed */ + uint32_t l2_iste; + /* Pointer to L2 ISTE word; valid only if hashed */ + uint32_t *l2_iste_p; + }; + uint32_t id; + /* True if this ISTE is currently in the cache */ + bool hashed; } L2_ISTE_Handle; =20 static uint32_t *get_l2_iste(GICv5Common *cs, const GICv5ISTConfig *cfg, @@ -499,6 +506,25 @@ static uint32_t *get_l2_iste(GICv5Common *cs, const GI= Cv5ISTConfig *cfg, * If the ISTE could not be read (typically because of a memory * error), return NULL. */ + uint32_t *hashvalue; + + if (!cfg->valid) { + /* Catch invalid config early, it has no lpi_cache */ + return NULL; + } + + hashvalue =3D g_hash_table_lookup(cfg->lpi_cache, + GINT_TO_POINTER(id)); + + h->id =3D id; + + if (hashvalue) { + h->hashed =3D true; + h->l2_iste_p =3D hashvalue; + return hashvalue; + } + + h->hashed =3D false; if (!get_l2_iste_addr(cs, cfg, id, &h->l2_iste_addr) || !read_l2_iste_mem(cs, cfg, h->l2_iste_addr, &h->l2_iste)) { return NULL; @@ -514,6 +540,34 @@ static void put_l2_iste(GICv5Common *cs, const GICv5IS= TConfig *cfg, * Once this has been called the L2_ISTE_Handle @h and the pointer * to the L2 ISTE word are no longer valid. */ + if (h->hashed) { + uint32_t l2_iste =3D *h->l2_iste_p; + if (!FIELD_EX32(l2_iste, L2_ISTE, PENDING)) { + /* + * We just made this not pending: remove from hash table + * and write back to memory. + */ + hwaddr l2_iste_addr; + + g_hash_table_remove(cfg->lpi_cache, GINT_TO_POINTER(h->id)); + if (get_l2_iste_addr(cs, cfg, h->id, &l2_iste_addr)) { + write_l2_iste_mem(cs, cfg, l2_iste_addr, l2_iste); + /* Writeback errors are ignored. */ + } + } + return; + } + + if (FIELD_EX32(h->l2_iste, L2_ISTE, PENDING)) { + /* + * We just made this pending: add it to the hash table, and + * don't bother writing it back to memory. + */ + uint32_t *hashvalue =3D g_new(uint32_t, 1); + *hashvalue =3D h->l2_iste; + g_hash_table_insert(cfg->lpi_cache, GINT_TO_POINTER(h->id), hashva= lue); + return; + } write_l2_iste_mem(cs, cfg, h->l2_iste_addr, h->l2_iste); } =20 @@ -896,6 +950,39 @@ txfail: "physical address 0x" HWADDR_FMT_plx "\n", intid, l1_add= r); } =20 +/* Data we need to pass through to irs_clean_lpi_cache_entry() */ +typedef struct CleanLPICacheUserData { + GICv5Common *cs; + GICv5ISTConfig *cfg; +} CleanLPICacheUserData; + +static gboolean irs_clean_lpi_cache_entry(gpointer key, gpointer value, + gpointer user_data) +{ + /* Drop this entry from the LPI cache, writing it back to guest memory= . */ + CleanLPICacheUserData *ud =3D user_data; + hwaddr l2_iste_addr; + uint64_t id =3D GPOINTER_TO_INT(key); + uint32_t l2_iste =3D *(uint32_t *)value; + + 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)) { + /* We drop the cached entry regardless of writeback errors */ + return true; + } + return true; +} + +static void irs_clean_lpi_cache(GICv5Common *cs, GICv5ISTConfig *cfg) +{ + /* Write everything in the LPI cache out to guest memory */ + CleanLPICacheUserData ud; + ud.cs =3D cs; + ud.cfg =3D cfg; + + g_hash_table_foreach_remove(cfg->lpi_cache, irs_clean_lpi_cache_entry,= &ud); +} + static void irs_ist_baser_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); @@ -907,6 +994,7 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain d= omain, uint64_t value) /* Ignore 1->1 transition */ return; } + irs_clean_lpi_cache(cs, &s->phys_lpi_config[domain]); cs->irs_ist_baser[domain] =3D FIELD_DP64(cs->irs_ist_baser[domain], IRS_IST_BASER, VALID, valid= ); s->phys_lpi_config[domain].valid =3D false; @@ -968,6 +1056,15 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain= 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); + 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= ); @@ -1428,6 +1525,13 @@ static void gicv5_reset_hold(Object *obj, ResetType = type) /* IRS_IST_BASER and IRS_IST_CFGR reset to 0, clear cached info */ for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { s->phys_lpi_config[i].valid =3D false; + /* + * If we got reset (power-cycled) with data in the cache, don't + * write it out to guest memory; just return to "empty cache". + */ + if (s->phys_lpi_config[i].lpi_cache) { + g_hash_table_remove_all(s->phys_lpi_config[i].lpi_cache); + } } } =20 diff --git a/include/hw/intc/arm_gicv5.h b/include/hw/intc/arm_gicv5.h index c631ecc3e8..fb13de0d01 100644 --- a/include/hw/intc/arm_gicv5.h +++ b/include/hw/intc/arm_gicv5.h @@ -25,6 +25,8 @@ typedef struct GICv5ISTConfig { uint8_t istsz; /* L2 ISTE size 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 */ + GHashTable *lpi_cache; } GICv5ISTConfig; =20 /* --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169352; cv=none; d=zohomail.com; s=zohoarc; b=e3wVAcmi7FrcggrfqeeAQlJq3UtwxVzX+/Ku42y2BhvLU3I74kpzFj9P1vUobsPGLzjHCdjfwbeBaKtgWejelN20G6L0edaoE9Hu0j48JWd6Yig/I6ZorOPbCCO//XUycbu0+rFVb/0ndfs6J1fjZBaSpxoxgyEUaYpierQ28cM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169352; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=aWyOb2Ci72/c/DPPe8R7R972eeRddihClu5NChd3Q54=; b=buLdUv2YOfU30rtrkSFzJWjluLyldSP+3oFT0xrm2FVuPb/G6P3ZkXIBgH2Gkhohh0WJbU2X45idP8NiwMm25Bhk9IJ/aA4GlJSoFPMMWSVztY7dTuTfVJEJoNcETDrmM1AViOAYiBwFYswlhuT5tG/rftDoAca/Voj+0boombc= 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 1778169352741468.8525832756584; Thu, 7 May 2026 08:55:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11f-00041S-9C; Thu, 07 May 2026 11:52: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 1wL11d-0003zL-0E for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:33 -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 1wL11b-0003vk-8j for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:32 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-488a8ca4aadso9856665e9.3 for ; Thu, 07 May 2026 08:52:30 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169150; x=1778773950; 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; bh=aWyOb2Ci72/c/DPPe8R7R972eeRddihClu5NChd3Q54=; b=bexv15/JbUTOvDVInyNKMv+bfXs+5rr+1FxYey+ppyxnt90cAqiwk+u9J1hH96kTLc 338QSPqkvCvJQnX971m7GFHK3awcvqLHuxlcxk1ZJ7CR12V341DCcZ+YCQljUtoAonzE 3YrtOQI3kMEo1acPL0Eih0QypwpkEZAm6RPQK2rfoA0ey+9IBLq2pYL8il+K29TWFdj1 xtnn0ie/+4JfDqVfv5UoNRr8DD+FZ/5rRvXv7BtJ4TTRPg/3N1BIy3rv99wpB1UGyobn nEQgxiU5bEeVw7p5FVYDGjyHEgbE70/VYOA0YLLfPsuADPotLI+1vzVn6Qpr3CS2PBzO AZeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169150; x=1778773950; 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; bh=aWyOb2Ci72/c/DPPe8R7R972eeRddihClu5NChd3Q54=; b=gmfSteBjy4n4q0P9JZrg86+r6Tf06FtDwSq7CC+MyYb7RgJYeNHOpIMwZXhoZPuiPq tIWSZ0u3etyKGAJ6IGz2z58FNP5vlDjIpQ8/TyOzdA8+qByFOBUeXPiLq7a7M8Kn5t+0 Fr6Nlq3cY01d3zgk7HOLG70r6/gCLtH9heC86LHj8siAEzTPzGSKWbWsIsmCel4oyrHC yNcqHKM1Z573mtN41JK0XE4204ruYsAhNiRX7JIfZdU+VKT8uoAIfX7R0FQzWWbYq+j5 mLbJ4CDOsbz7uMACQqrq9b9aWDM+D4JudssYOLsPK/cCujYFBMCct8aiVTNp/kGSUmH3 MIFA== X-Gm-Message-State: AOJu0YxHXYPhlbf8xGaOnjpvUAmikigJGsQQ0ySXs8BKLIfbdH1alJzR gi2IF0uHWPRhuncyJahTL14Q1FsPa9LLjq+io2FOD3ne88O1EoZvH/GtM99WjSHGPNkjWcxSZGt Z4/VM X-Gm-Gg: AeBDievD+zqiOuk6A6nzqxxOPhsq4U0aqJnbd+3thZAvAbZ+MZW6V5BVyiBRMFw+/rt Zd5Y48Asts7wcqNMro3MM0bJPfO0kUjv8swFBXBSSnRUOLH6IKtDH60Sk4O2yODOP3OPf/lzEGt xoJ8wuf2PRfbVBo0gAT2yhth96DNk2/5SrW80tbvxvvveoo7jPNdcIyP8X9pNXac8h6whmj2jjH 8n5WiAwJNZd43ygyCIyoV0A0Xqrh0WeJ8MkyGdnUMb6dAZK+v+DrRXqLm+rFBh/N6y923V+WyJd dah8xpRID7j5VXZbc2KkVWWIA1DU8DAsWyBiwXUsigRhRvwbqmvT9JPf8mav/yhIhpCsb0edqRF vbBv/8pUKWV88T7L0u+dD5qeZSZIcRVmUFEuaZQTq8fXRWHfqZzbxySlcdVDVQsu/WfI3A2IHw4 2a9UQgSN3c2Lfjw7VDHp8cH0dbFUFT3Z9pujgnB0MGXHmvNDW7BPyB1j93O6NDevXAFwWjv+Gf0 Xyzf/mHZ0wQM2nxcPckISzAPZmrKFaO5hhQ49xgWQ== X-Received: by 2002:a05:600c:a111:b0:48a:7b7b:c2b9 with SMTP id 5b1f17b1804b1-48e51e0bb44mr110786115e9.4.1778169149417; Thu, 07 May 2026 08:52:29 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 34/67] target/arm: GICv5 cpuif: Implement ICC_IAFFIDR_EL1 Date: Thu, 7 May 2026 16:51:21 +0100 Message-ID: <20260507155154.1886557-35-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169354385154100 Content-Type: text/plain; charset="utf-8" The CPU system register ICC_IAFFIDR_EL1 is a read-only register that tells the guest what the affinity ID of that CPU is. Implement this register. In real hardware using the stream protocol, the IRS tells the CPU its IAFFID using a DownstreamControl command as part of the handshake process when the IRS-CPU link is brought online. Our analogue of this is to pass the IAFFID as an extra argument to gicv5_set_gicv5state(). (We could have the CPU call into the GIC every time to ask for the value, but this would mean we had to search the cpus[] array for the right CPU to return its IAFFID.) Note that we don't put the IAFFID into the gicv5_cpuif sub-struct, because that part of the CPU struct is zeroed on reset, and we must keep the IAFFID across reset (we only set it up when the GIC device is created). Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-35-peter.maydell@linaro.org --- hw/intc/arm_gicv5_common.c | 5 +++-- include/hw/intc/arm_gicv5_stream.h | 3 ++- target/arm/cpu.c | 5 +++-- target/arm/cpu.h | 2 ++ target/arm/tcg/gicv5-cpuif.c | 11 +++++++++++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 180fe338a4..b155486af6 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -173,9 +173,10 @@ static void gicv5_common_realize(DeviceState *dev, Err= or **errp) } =20 for (int i =3D 0; i < cs->num_cpus; i++) { - if (!gicv5_set_gicv5state(cs->cpus[i], cs)) { + if (!gicv5_set_gicv5state(cs->cpus[i], cs, cs->cpu_iaffids[i])) { error_setg(errp, - "CPU %d does not implement GICv5 CPU interface", i); + "CPU %d (IAFFID 0x%x) does not implement GICv5 CPU = interface", + i, cs->cpu_iaffids[i]); return; } } diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index 670423fdad..136b6339ee 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -20,6 +20,7 @@ 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 * * 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 @@ -28,7 +29,7 @@ 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); +bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid); =20 /* * The architected Stream Protocol is asynchronous; commands can be diff --git a/target/arm/cpu.c b/target/arm/cpu.c index de9ba141bd..29346609e4 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1159,16 +1159,17 @@ 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) +bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid) { /* * Set this CPU's gicv5state pointer to point to the GIC that we are - * connected to. + * connected to, and record our IAFFID. */ if (!cpu_isar_feature(aa64_gcie, cpu)) { return false; } cpu->env.gicv5state =3D cs; + cpu->env.gicv5_iaffid =3D iaffid; return true; } #endif diff --git a/target/arm/cpu.h b/target/arm/cpu.h index aa89b457b9..c7c410bed7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -818,6 +818,8 @@ typedef struct CPUArchState { void *gicv3state; /* Similarly, for a GICv5Common */ void *gicv5state; + /* For GICv5, this CPU's IAFFID */ + uint64_t gicv5_iaffid; #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 8cf09791c1..005e2fa8d2 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -226,6 +226,17 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .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, + /* ICC_IAFFIDR_EL1 holds the IAFFID only, in its low bits */ + .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. + */ + .resetfn =3D arm_cp_reset_ignore, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169442; cv=none; d=zohomail.com; s=zohoarc; b=lMKaw12nwBd2Q9Z1zsNwqMBGr2neNBKGOY0rMnA2tYuCBjY3EfDJeySR/6kVUi0zWoN5Nq994KzYg8NNxwIYt26xh7lm20XW6lt8B9wehwOvnTb1/znhwEtWJEQGV0JOdnw0SACrr4eynXYpDZjvl5Ci2x92B5dEH/yBTdN/HaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169442; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=DrRjECe0L7G9Owd4QfAts2Da6Pk4ELwgWzfZ+b6EEn4=; b=PIE0fwDMxgRZdCCIBZUOSSoNj+1HK1xhR+GNOH62XP+YkaPzSJo3S5E1xDMqFwvxOlILSMgkr9AJ6qKY22+o/bA/q4HhwBR2iQHHeGfOiFMH5FpqMmxGpv4TyC3znEZGPf3Azav3Vx1L9PDaxdFrJEVtTzELYXctjQ+GwvTk6NY= 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 1778169442849865.3278527977733; Thu, 7 May 2026 08:57:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11g-00043M-AT; Thu, 07 May 2026 11:52: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 1wL11d-00040Q-Nv for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:33 -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 1wL11c-0003w4-5Q for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:33 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-488a88aeec9so12900005e9.2 for ; Thu, 07 May 2026 08:52:31 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169151; x=1778773951; 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; bh=DrRjECe0L7G9Owd4QfAts2Da6Pk4ELwgWzfZ+b6EEn4=; b=asgJ0mDkeASEbykiZc6U/dVqEcXPMeVxH5ecPR6b+gABNZflYKqq+7cuDxjazNZCf3 SVS1lbm9fvAftTwhZbsd5UVQ6u2OejRMqMDdjOl6Oxq3spgy6Zb+1C4b7dRgGDJ8lqD4 SjRKvYI3WoOpITGbQJtVBr6cOYBCPP32NXbrcGXsTwZRop15SKLpVj0fEcev62BW0Kdh ItH2WpGi7uAKCTD+KpUURmbFjRqp9rU0qygz4XLyvtF5nAGOUBngHvD88H0CHpZNHc35 ZeeHVHXPi0X7t1MkzSIufJJxgpLGOaZL9nozop+vkxXFH47EswsWHXO9D4fPOXOhC2Ei MJng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169151; x=1778773951; 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; bh=DrRjECe0L7G9Owd4QfAts2Da6Pk4ELwgWzfZ+b6EEn4=; b=ge2YZKnFloRamI7ZvP6tVF4mT2r0S90A5VGuq8ra0HtEzxmZdB12JQ9ldLmmFtCwh5 AcOiyWXJIt/ytbI5DfmyDoU6Xn9LJWWmhOCwo5J85KKcUyvS3tRfXEnxTWPhp4iVJ+rg AV2J2sesECdJAB05E9H6WBqmRVnSgcmRs3Tl7T2fed1J9CEDSFwCYD5HOF4UPVEHweIH Av624r0JlftQtk4TF22p6NNGGhhnfcQFFsl/BSfprErxiPNcJ/0WmikuRmLH9NRVfeMH 0zMulCFxce3oMBDYO4wrmHsQ0Za5Oin1J6tX/wSeaQMfvek2xT6toa9EYvgmjHJ5d+38 SX7w== X-Gm-Message-State: AOJu0YzJOyqxjxSipg3jeKuFiCgCfK2vUVVll0/unC74VSCIxcCrM0yr lhxnrrwgN1u+0WCEtr5m4XQvelgFcWx5s9NHyFzUtwVn0/1/E8jBcouZsnhL405NbX0nICSbDyD btS2b X-Gm-Gg: AeBDietgw9j79kSIVD7A0MknjqZqRDsZG9flkISEBTyZiUQkvUocVU2Y6QcwZoOk2yi aUZ9+eajGhPQHFHqRpwajwEQAcNngTKCirSnBTGSNPWhwrNA2G3y3o/l0+ZbAKAEZjd3tfnDdcQ t1xTjJVxodlI6IF0vNLXgt0C9XCS1oSRGb5efJxIwZfXpc2JHo50fP3M+u/73TKAVyuqvwhH3vf /4Ty+D5mjyqmCelTfz9nmfbNNvbD+3McgAIP2lqaai3k83VHteBL91+8Jl/XhpTsnWGtc7C7Bnl cOUUcY3bU4ETVCNXd9ia5YE0crOUNpuQLKiCrlJN+cdCiSROrZQwWSkAnJnTazBRcahQIt/zjpN Aj89cD8h9cNxUmwlj5vCrCF3fC8aXWd3YaYyAEimJe8w/fsv7/x5muTcRPhwMHA9Pnlaq03fbpq BQHrztBSoh4emy5cJlQ8rX2+tfyPqi9OfEPRr5YdRMlNWQYucuqTAXq1skCQ7pQkgIjA6zF+3fp PyV1OhyfTkgGXNaoJ2U0ia9q+LjYTK/BIaoL7w6Juab+5erird0 X-Received: by 2002:a05:600c:47d3:b0:48a:9428:5522 with SMTP id 5b1f17b1804b1-48e51f37358mr86808755e9.16.1778169150464; Thu, 07 May 2026 08:52:30 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 35/67] target/arm: GICv5 cpuif: Implement ICC_IDR0_EL1 Date: Thu, 7 May 2026 16:51:22 +0100 Message-ID: <20260507155154.1886557-36-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169443793154100 Content-Type: text/plain; charset="utf-8" ICC_IDR0_EL1 is an identification register; we can implement this as a simple constant value. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-36-peter.maydell@linaro.org --- 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 005e2fa8d2..497c09474b 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -38,6 +38,18 @@ FIELD(GIC_CDHM, HM, 32, 1) FIELD(GIC_CDRCFG, ID, 0, 24) FIELD(GIC_CDRCFG, TYPE, 29, 3) =20 +FIELD(ICC_IDR0_EL1, ID_BITS, 0, 4) +FIELD(ICC_IDR0_EL1, PRI_BITS, 4, 4) +FIELD(ICC_IDR0_EL1, GCIE_LEGACY, 8, 4) + +/* + * We implement 24 bits of interrupt ID, the mandated 5 bits of priority, + * and no legacy GICv3.3 vcpu interface (yet) + */ +#define QEMU_ICC_IDR0 \ + ((4 << R_ICC_IDR0_EL1_PRI_BITS_SHIFT) | \ + (1 << R_ICC_IDR0_EL1_ID_BITS_SHIFT)) + static GICv5Common *gicv5_get_gic(CPUARMState *env) { return env->gicv5state; @@ -220,6 +232,11 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_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, + .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, --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169375; cv=none; d=zohomail.com; s=zohoarc; b=ZG8D186DahwV3OOAy7bZjYJEE9UykvO8vJ72puPZUVjpczO3qF3CdGUqZSrV3vw1Z9mSZVngz3HEDzn44H/3Sp99xcljN52SLlEiD7rRuP/6+1RKWoEUhrUjZEYoZHpJnC64OlnTxsBuWazScwvBj6Jg+gq5evDiQt0bC9k+Svc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169375; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=4LLXc2AzW0iFxiRZ2Bd0TLDJJVzDJvcAwb4iYjjgrJ0=; b=SnoCXLVJY68aI4sqQ9B6aF6kbRni4Pwv3ca3EsUrNX2vbkHN265prL8usCYPR+X8uGfGv9gESCrqWV3Lrn7rC2DaZC26b9FjPQ53RaQF5yRt4M0LF7ZwHpRA4wRulErPE+TIVKpzar+MmqozbMqhYJFzqZdew9NYSOS3g4z4LTw= 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 1778169375908352.4932452852463; Thu, 7 May 2026 08:56:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11f-00041g-Mr; Thu, 07 May 2026 11:52: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 1wL11e-00040j-DV for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:34 -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 1wL11c-0003wE-Pl for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:34 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-488b0e1b870so15305115e9.2 for ; Thu, 07 May 2026 08:52:32 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169151; x=1778773951; 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; bh=4LLXc2AzW0iFxiRZ2Bd0TLDJJVzDJvcAwb4iYjjgrJ0=; b=OSBAxL6aXARslVB3zr6hZvNetblUDo+fREzS5RrnyPyZR6+7S0/IqtAgebq9XVVoCG Q0KrZgPcu0HvciVr+90+PSt6u3cQrNhmx5SXzs0Y72EUXrKuA1AwlgpgMBOGufCqJVOM xvXOE/kAuHHb8TWltC0Yv8N4OpUEj5RtTaIKKX0Ev2jIgEB11lnL4DMU22v6ket4zpf7 B/jHiRNZ1sd2l/B7LlyvH503uEN7tsF/mwHt7bsodg9SwXqT9iy2jJQuThnU63p8J1Jf TP5QQvt8GdbYKbot0AFO34R9i/nH+MeQWHeEDX7Fg0wTS/Da/YDERVXrDhTUrCeEgY2q FxzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169151; x=1778773951; 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; bh=4LLXc2AzW0iFxiRZ2Bd0TLDJJVzDJvcAwb4iYjjgrJ0=; b=ZCW0X9bvTIUXTa7zgFWcVWqCZyaEHo8VVmXsuBiVqaxZSDt5UlULnF7ToRZajE+wfE qKEAfxWKc3aMc6DNVZJ8MIkuCvtYQVsJpUSOZgCVczK+yp+Y8DaUN/oRA+OwF+cQ22c0 y9/0myOJwtFiqnUdrf0tnSVVifqrZ6ZENwfd1PgfhLsCotU2Bv2yIrCo13jkjXgjWTGj Mo2n96ya9FZ6kALKdsmjnaGc1q7/Inte6cjVJZChDGNj1zFw2WpOPVKTt/pE68eMd84b mri9MhX54FhpTq2bIvs1YnirWBM0a91EyVf5xf/21vI9/kYAf+2jyiMpEooEK6cnKzhy tAaA== X-Gm-Message-State: AOJu0YyDUWIOIJ7Ht0866yMw2aoNyzQRWDCfsuhG+xV6GJzcsI/QX730 rsQIeNOnN5J+fOBAmztP2cAviBEY04s1qkggJYGw+yc4p5CTFgqyKeCM0qKQG0bHgdZf3YmpSmb Tqn1q X-Gm-Gg: AeBDiev5n4OHsbGhGm3K37fbKKMX5ymOsUKQcZZ0pWQkig8HPMsJYYFdGtHzoOIG08f uGenv1vyBn8hSsT6Z4KDLkpbaiBTHp2F+8LM2sJwAXuBTF6jbrVETIh6DsviGPmglj7Aer72gH/ WBta8NWZewowB6phzQ+k+IUClO4RHDT0WU8BQkf3H0gYFCzFlNMzYd7LsrlMs8eJ1O6WaGCSKBA 6IxS4nNzP/hBgQLe7GJrUXWfKZDGOYzdwJzNEGfLq3JzVj6rIxP9ykNTpdqvbxpdPnbqIbHrTcb d/tkGrtDaDvSsSJ8DVpxP1N7841C6/sn6NCd3/0TZFDJ+YU0GEtRHYXyedMLhY0xvl+P4WqmJnP wrp8jqkB/47HjxeRe8sZD0qxGKWO40gT3rujR8lSEt1FJ/bnMkQi1bsuSc36jFLdgt73htZ3Pyr 0tIOlGCfntCOsBaQXsNMzhVLZmTY4exDfppA/Sw9/nj2UV6/kHdWzKTvP4QhUuruAozKz2mkqi4 dYe73IfnMWYIoC3f+ERXuRoJITVJQkshTZOr3bpcA== X-Received: by 2002:a05:600c:3b17:b0:488:acbc:b2e with SMTP id 5b1f17b1804b1-48e51f32c94mr141105685e9.17.1778169151346; Thu, 07 May 2026 08:52:31 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 36/67] target/arm: GICv5 cpuif: Implement GICv5 PPI active set/clear registers Date: Thu, 7 May 2026 16:51:23 +0100 Message-ID: <20260507155154.1886557-37-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169376214158500 Content-Type: text/plain; charset="utf-8" In the GICv5 PPI state and control lives in the CPU interface; this is different from the GICv3 where this was all in the redistributor. Implement the access system registers for the PPI active state; this is a pair of registers, one of which has "write 1 to clear" behaviour and the other of which has "write 1 to set". In both cases, reads return the current state. We start here by implementing the accessors for the underlying state; we don't yet attempt to do anything (e.g. recalculating the highest priority pending PPI) when the state changes. That will come in subsequent commits. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-37-peter.maydell@linaro.org --- target/arm/cpu.h | 5 +++++ target/arm/tcg/gicv5-cpuif.c | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c7c410bed7..ac0891d498 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -256,6 +256,9 @@ typedef enum ARMFPStatusFlavour { } ARMFPStatusFlavour; #define FPST_COUNT 10 =20 +/* Architecturally there are 128 PPIs in a GICv5 */ +#define GICV5_NUM_PPIS 128 + typedef struct CPUArchState { /* Regs for current mode. */ uint32_t regs[16]; @@ -599,6 +602,8 @@ typedef struct CPUArchState { struct { /* GICv5 CPU interface data */ uint64_t icc_icsr_el1; + /* Most PPI registers have 1 bit per PPI, so 64 PPIs to a register= */ + uint64_t ppi_active[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 497c09474b..6672cda37f 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -175,6 +175,20 @@ static void gic_cdhm_write(CPUARMState *env, const ARM= CPRegInfo *ri, gicv5_set_handling(gic, id, hm, domain, type, virtual); } =20 +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); +} + +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); +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -254,6 +268,30 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { */ .resetfn =3D arm_cp_reset_ignore, }, + { .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, + .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, + .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, + .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, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_active[1]), + .writefn =3D gic_ppi_sactive_write, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169443; cv=none; d=zohomail.com; s=zohoarc; b=nbsuiTjZojoeO5G8mJRFzzSqdIEla+agOMvwAZHHhSsWFVGB54VyUYMIe9NAtaLhswOtXrj7oIEXb01NLIafR7CnxJy4rvKi/DUDZot3uQVKyjqt+VIs3ri098A09z8Xx3Jy12JEc3TaGLBXJydNZvyQIV8mwiuQVE9l8udvODw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169443; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=7RSKbC4/1FXYT8ot948h8jarJjuqtFpAfnwH4gEg2nA=; b=dUN1BYqHh81H8MAPrGvIRiy4IeFqiIo3/IOVeDpwX0Kwe90X4n+4XZ6d2r47f57adFBel4freMv/jX8pOM4g+Lim760Tj/VZTmaOvQQQE9ERPG3E2auVrc+Ku+750QOJ/d1N/boJbx/Yg/XsZQUpxmfsdgsFv9PlbMFvAKK0yUU= 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 1778169443764256.43479449780364; Thu, 7 May 2026 08:57:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11g-00043K-6C; Thu, 07 May 2026 11:52: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 1wL11f-00041U-Ax for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:35 -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 1wL11d-0003wW-M9 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:35 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-48a7fe4f40bso11500445e9.0 for ; Thu, 07 May 2026 08:52:33 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169152; x=1778773952; 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; bh=7RSKbC4/1FXYT8ot948h8jarJjuqtFpAfnwH4gEg2nA=; b=RNWoC4ZuFdScwCLSTKuYJIA9sEVo1Li1Hc3Ys9jNR7yYcMTpbvU8VedqYFD9Cy2QHM icgupXdqD5X/4VApkxPlprpm3oxupAnDCKjkkQwRgH+1NYktfmMk63y/2FKNnyRZzV78 97VPMziocQ5kR6rvpJfLedaUEr0MnUjo3Tk34vh43FXjBolMMugnBcX/Hna5GiNRvLxV lQWML3lktWlfZWvGfQ7swRXjVuSWBLKsGJd2Q7RIgtIDBRKvr3KSi2PeC2P8sHH+fo+D 6H/9Jvzt6Z9KYiP/Bhx//YuvT8nHoHiqVWk4kVd0IvaePrXt1nLbCrYG0SlgLx2TuOoL 31UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169152; x=1778773952; 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; bh=7RSKbC4/1FXYT8ot948h8jarJjuqtFpAfnwH4gEg2nA=; b=NuanYyePwwaqIEXrEvNBlK3ou7RxI2n3a+oQS1HqMQ9Eti3htDBm/ot6ayNr38k61R rb4FEWO3kfewpxXxowwa2/oirwIck1E3LAtuOJMZJ02J8k9p8M6a8GQwqM/iahRMAL4d j9nVFc/uVwO3y8ZuGhoNzEPNpSQ0Jwpw4L6AoT7NVmIm13la4lPwacpOZPvF1c+my06i Ycnjo7FEvtLd1TZiTb6AFBNe/sO6ZqsFHMV1TqbicmP0TxgfZ0TtiaL8lDz9zyyFoaX3 Ea6Qt5xpYxSHnWt+hhyPzA1UCaOIEI3x4ngqDjSQJTOjDLnXNSifZ4ukK7NPss1C+gwU QDSg== X-Gm-Message-State: AOJu0YzBDraipaUVCXZ4cywZnyUpNWOmaysaYu9/SkNATqbTTYh7/u7X +gxDNYQvTIFk+1N82BKiKVfzd0XVYoypBZoDN5yIGipttX6eyKR6k8nofFCRkwnjsaO9OyBww8X VqyhM X-Gm-Gg: AeBDiet+kL3rXjKLxPbc9x3fuPttB9Zj9zx4Ed/vRSSjMTiG9To8EtlxtpqkWJss90x tPTCGk4m6xGV+KRFaUVUheo8dyXYTNfWLv4+YcwUi9p6ufjUN6ZGEGEE9Li8MJb14gz07kePV2k FW0uiBA+6PuwqsMJ+lYR0FzkTLEG4yUEgC3GFVYFj01lgbAeG04ywyM5MJKTmNwNDtMzf8+V03Q DfoC7AgLJhm22DSJiq3jzou1n72JmzTUdMbjAVWiwnMlhbRhOdx0z7fHnDYqgLDSPD64HEejahj nlQVB77WY9lCxm+eZBbYcOYRi76Nd2ew+B37FU+QssoC4PtZ0l1iVGJT1+zQRh+dXbq1w6q39Kp H4GOxiJqNDDcqr3TUJtYLmnphJqrJEd+kJA6PWTp4SjlF+PZJlFtJTBqWWMxOTG/HztsSXyuwvU 8tRjgntplPmZwN+HahLuAeU9XfKdV7BGVYqldGa7c24xAuC/qNvxJwj5xu54lAcpl7DOgVi50TB my6TKpKqIgMVUs9y/crQhUe6pLLqhQ= X-Received: by 2002:a05:600c:3151:b0:48a:7605:751e with SMTP id 5b1f17b1804b1-48e51e0837amr134866565e9.4.1778169152177; Thu, 07 May 2026 08:52:32 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 37/67] target/arm: GICv5 cpuif: Implement PPI handling mode register Date: Thu, 7 May 2026 16:51:24 +0100 Message-ID: <20260507155154.1886557-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169445911154100 Content-Type: text/plain; charset="utf-8" In the GICv5 the handling mode of a PPI is not software configurable; it is reported via read-only CPU interface registers ICC_PPI_HMR0_EL1 and ICC_PPI_HMR1_EL1. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-38-peter.maydell@linaro.org --- 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 ac0891d498..b8bbc91a16 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -604,6 +604,7 @@ typedef struct CPUArchState { uint64_t icc_icsr_el1; /* Most PPI registers have 1 bit per PPI, so 64 PPIs to a register= */ uint64_t ppi_active[GICV5_NUM_PPIS / 64]; + uint64_t ppi_hm[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 6672cda37f..e65bd56b3d 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -50,6 +50,16 @@ FIELD(ICC_IDR0_EL1, GCIE_LEGACY, 8, 4) ((4 << R_ICC_IDR0_EL1_PRI_BITS_SHIFT) | \ (1 << R_ICC_IDR0_EL1_ID_BITS_SHIFT)) =20 +/* + * PPI handling modes are fixed and not software configurable. + * R_CFSKX defines them for the architected PPIs: they are all Level, + * except that PPI 24 (CTIIRQ) is IMPDEF and PPI 3 (SW_PPI) is Edge. + * For unimplemented PPIs the field is RES0. The PPI register bits + * are 1 for Level and 0 for Edge. + */ +#define PPI_HMR0_RESET (~(1ULL << GICV5_PPI_SW_PPI)) +#define PPI_HMR1_RESET (~0ULL) + static GICv5Common *gicv5_get_gic(CPUARMState *env) { return env->gicv5state; @@ -292,6 +302,18 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .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, + .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, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_hm[1]), + .resetvalue =3D PPI_HMR1_RESET, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169387; cv=none; d=zohomail.com; s=zohoarc; b=ZDdWcoSYWYjHNvR4gP//Sds1D0D0BEDrtwBwjM1TkNqFujN0SO9SdCCEfJiC29PiuU/p31tkE2pEQnNXa6GqrCJ4zXjwR+3rMamxoB9c8HVFbNaSr4r5ISnAFR1/Gqg0tQOEFy/9DVuB3MuR3K6kv4fx2pMDuIfbgfCHSlNXbAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169387; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=vyF3xatdii2EbkKcDtk1f097Dh6knDLHwXdlLIZ+UoU=; b=TUi61FXWcuFOsDOVaV9xtWpPGXbF1YDDjoIfpdwhy17fXuDvF9dwE1p+Q2FLyoi6wFZAatJrazBvGK1U1g1/c5PEQxgiyLITHQQQHgIHBfqwhZZJtD1oYfGnbCs1yXOXtgNFUfIR3yaCX6wdiRFfidgtOZfrH5XjMO9x1iiGuWg= 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 177816938726056.032073271808486; Thu, 7 May 2026 08:56:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11h-00045I-An; Thu, 07 May 2026 11:52: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 1wL11g-00043Q-BL for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:36 -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 1wL11e-0003wt-Ja for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:36 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-48334ee0aeaso8131745e9.1 for ; Thu, 07 May 2026 08:52:34 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169153; x=1778773953; 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; bh=vyF3xatdii2EbkKcDtk1f097Dh6knDLHwXdlLIZ+UoU=; b=AkAvMW4cNJnZR9eFc7yCd869Pr6MWpEbbrOLLT3UtsTUsWZwg4GiyU6JT72CGfuP7Y Urev1yBZG3m+GqjPtH0AgO8cqjenrBtTp+TEjbZyjSSQmcKRnHdsFzEUCOIYFtY8yFME o1Wv5hXSXmuk2MMNdvcm3zIkqWgah28WN43Kmy5fNLCIhkEX2M3kvicxDBIfEIPdbj6H CpcaNlgGY5RrLNgf+ca5/nzWUFd/YB6PXZWa4fznUiIvGgrFeKCuecsF5RbRBW+FBkdf I3r41PZKdhkAKQqUmiIx+T8P6MFt/PVxyHKiUOcJhDdpkHtCPJlGn7d2GByerbV5Opcw f50g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169153; x=1778773953; 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; bh=vyF3xatdii2EbkKcDtk1f097Dh6knDLHwXdlLIZ+UoU=; b=nPa5GbiPDk5DwqVI0WJPm8OTOSN/aW00PUVl0jq8CpVQtHTieP9EFhfCQJH8bFvTfN szvUd6snp006UfruyaiIAzmz4AN3n7BoT46dra3YZyZbDMG9SiwU70/AjCG1advl1/Ew c558grk1UKTKRUuD66Pxm8TfkxCanaMIq8oTLPUefQcdC5Akfq0vGO3LrnWJpbk7Jwfk ir7rQsWOP2u3Q+hGq6bXcKpw7hTMW83IQmXc6BEcPF9GxzpxenWh9Bz2RLFC+Weanl5U lOrBLrTupLz+PfC7Sn5p9hA8thu4rBDkBY6+0o5phr8x7z54wm8HlS+aL8QzxU0vrnL3 PP2w== X-Gm-Message-State: AOJu0YwumiWQNOQxDmaeQ6ALzHnjEXOmaR4DGZckCRLfb5kAevioEMre SD5+wdPNRV7axlmcAMm8yCJ719oYAepH3i44y3BiH3418nLx6Recfj6Ky5gOzBAhm6q/6W77Rfx zkuSw X-Gm-Gg: AeBDiesFRH6pH0ejr4GfISRsXNuxE4cAXEA0QCwOEcwfJvC+a5WK1FQ+LiZbjbALhC8 80QldZpB/chrNX/8jSaM36Npp0q3+5zI9857C3onfrBzkMptcanpz90M36nthrptLNTRPB+Pzl2 0Pe+Twyh+OWDlFSv0q9z43ZitFLnwJWNaGK23oNAyUbuInmruesRgIoqXcL8heJWOqSSePOXrIk JH2jv1fgK2xxi1M9xG1idC2jHYOb5pjiN6sDVnU7Yeyf5ccQZ18WUaOrgUwMn5vhRHgh7YZp9DR /zJrhLbAEUFnSnFSRPooMDCrHNg6vlFvaX5rZAxBKLWbwLxIzsgdSPQ4cY6X9FFfoBjhFR8bqur M1pPRyKujrpK6KKrRzW07TPwNdXYBYdJL7vQX8VLBLMNAN70T3pY66ss2J4Z5qY5xWnPyR/Pf9M 7wuUob/2HsRGyuYc6A3HbcNSPd8+BwgFO31Tzwa6XWPwVhBjtX1ZEr2SYZQFcpbf2XltrCAbfal LOF/LgUpL9qS3d/qGFe8Z8r2OCRS9Y8kyXiQ5hjEA== X-Received: by 2002:a05:600c:354b:b0:486:f634:ef1 with SMTP id 5b1f17b1804b1-48e51f32a7amr141627975e9.17.1778169152958; Thu, 07 May 2026 08:52:32 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 38/67] target/arm: GICv5 cpuif: Implement PPI pending status registers Date: Thu, 7 May 2026 16:51:25 +0100 Message-ID: <20260507155154.1886557-39-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169388254158500 Content-Type: text/plain; charset="utf-8" The GICv5 PPI pending status is handled by two registers, one of which is write-1-to-set and one of which is write-1-to-clear. The pending state is read-only for PPIs where the handling mode is Edge. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-39-peter.maydell@linaro.org --- target/arm/cpu.h | 1 + target/arm/tcg/gicv5-cpuif.c | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index b8bbc91a16..b0fc90a994 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -605,6 +605,7 @@ typedef struct CPUArchState { /* Most PPI registers have 1 bit per PPI, so 64 PPIs to a register= */ uint64_t ppi_active[GICV5_NUM_PPIS / 64]; uint64_t ppi_hm[GICV5_NUM_PPIS / 64]; + uint64_t ppi_pend[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 e65bd56b3d..ee97d98d7e 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -199,6 +199,26 @@ static void gic_ppi_sactive_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, raw_write(env, ri, old | value); } =20 +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); +} + +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); +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -314,6 +334,30 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_hm[1]), .resetvalue =3D PPI_HMR1_RESET, }, + { .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, + .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, + .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, + .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, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pend[1]), + .writefn =3D gic_ppi_spend_write, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169500; cv=none; d=zohomail.com; s=zohoarc; b=C2VkI2J+y2adhpryvoc9m6hmEIefv8YfcCdnT8QLhVb4Fs5ff1qU7G2kKnPLgn9QXBLpvSetxPjVXus7KYI9WN0RWBQd/9JxKfpZBLhDFXsMmQojcpQTRfn6wVW4U3cmMSi4giclaP9xavs1lpgBnnmfN/+3rcrHOgR5OJMnSwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169500; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=0Oz4bj5Nice9THOmF6naZCylbKzTECKP9+AuU7nwypw=; b=X16MQu3D2VrMDBbkMbHH/GryMqwR9Ao+iyAHeVqFLICuHhBeTh9jeKpmzItOWI1oM8VOLY9dvx7utwrZKWHB1f3jlBTHZ6DQYFK0cqfgp3qSfq5FCUc8sAH8o90zVgWG9lGiaEjIE0pMZ0AtE4MChgYv4OF6kll+c8o/NAXQ/gQ= 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 1778169500554818.7984947448718; Thu, 7 May 2026 08:58:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11j-0004DM-58; Thu, 07 May 2026 11:52: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 1wL11h-00045P-CR for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:37 -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 1wL11f-0003xE-O2 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:37 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-488af9fdaa7so6672325e9.1 for ; Thu, 07 May 2026 08:52:35 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169154; x=1778773954; 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; bh=0Oz4bj5Nice9THOmF6naZCylbKzTECKP9+AuU7nwypw=; b=fliexAXAMbiZ7s+D/qdzKHZADMYL/VlAvutoY5BymdPTW+DdGsaq+NZYTAPa8Y0QwF 7yHsV++ogo0ZFLZQo//uvb3IDT6Dm1eMB6WpHJj/qorhss+FSjPB1PA54Blu/pWQaMqr rSqT7V6HgZvPu2VBO9oG53E4cHOZRhCVcmvDmyHmGY5xSkglZ0BS+b55QboiB0SAZYiG fL2Q3SeBCWRFhRA3Cn1udxzcHMiNtoT2IWqxW0jVvVNn8zqLJaP58BPTfGwq0MwdSQPA Po/3HPBRq0Ejo7wqIAo8lc0qnf11kJ45wGZoM1M0LhfgJ5YdDvEW770sNUZBN9SejvZZ qCFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169154; x=1778773954; 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; bh=0Oz4bj5Nice9THOmF6naZCylbKzTECKP9+AuU7nwypw=; b=WMIH3+AhDQxINUFiuTdLlwN4BgynJ1lBHHbtlX2VquS8v095oJ7OzdjT/MINANE7xP eYIuuGtBlfD9pyDIN74A0UzHQvZhIAmpy6PUUpyII0JtV8tScl1Uol651Zoj9kJWpdZW NDDzHMuM0a0CWklSgXXx/xj8FCxMTQpsKpfWdNPF972Hq6dTM6TTC5xU5VUH/txIQDMU I2JUEhFTGFwk/ps22M4qM5q8CijIiSfT9AF0iNLhjsiV18hBeSMLG/g5YghGHGo53VZv qOZmubqEssxVJErHMG3U0IWpZmd76EB8WXG/Aj5ghrVoq2gW5XhCZBWXE8Nb0tuVmbsh oHFQ== X-Gm-Message-State: AOJu0Yw582jUy5bFfnHQFM/FYqWn17tboME3AelM/M/9502aVfL8rwKX JXQljdP1q7T/laYnN1mA+XtTlV+X7hfMWcCmupvElaXBe6tdmoJOnpVabQRjS3jkQUUFuyh9xSr Z8jMU X-Gm-Gg: AeBDies/icAVI7t/wksaENawhD6v3ZfWY+eYTOdOgEflQxhgtchdGkmHiFFmsZ8QR1h WRyHuyUXmEyJ98vYmjiZom8/l8YhN56mGofuj770q/ZdMPg+BjQvn4PE3bmwnHNMUMLOAa2mdkj 2CCVnSkVyR9+XJbCm7DPRVP2dk3WNsOOrR70724Cl9xbzaEOWHsK0NnaffrFkzq8g9jsQTzH6Xo o1W1Z7yDDwoz6MCvQaaW4h+t3o6uB8kZdz+ImfWIui/l05SPhyxK3lnCWG4H+makl/YDAMF6gB0 GCXVllNrQIiY1R910FcVpTDVLjnahptiN9Bq/E/5+ktMP4Yp6TbTIQB3BqPAMSEnnm0vPDDy28m sGfD8TRq3b+HFxSz9mTR+Vjl7vR4D/X1WuUZ+JbR87kJNuQ2lXYbELEnksOGZ8odJIRcEAEWgNH eX+C4VNJ9JiwytoG5LsySmFEDy606X+fc8PiSc7ODMH6Bt1kfLNKgXDXEFkn0DQj0TcpOuwRDab e2l8XwcnSLIu4O1hgcHFZsjyjWmW78= X-Received: by 2002:a05:600d:8408:b0:48a:58e1:6d17 with SMTP id 5b1f17b1804b1-48e52bd4f17mr102484465e9.20.1778169154128; Thu, 07 May 2026 08:52:34 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 39/67] target/arm: GICv5 cpuif: Implement PPI enable register Date: Thu, 7 May 2026 16:51:26 +0100 Message-ID: <20260507155154.1886557-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169502768154100 Content-Type: text/plain; charset="utf-8" Implement the GICv5 register which holds the enable state of PPIs: ICC_PPI_ENABLER_EL1. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-40-peter.maydell@linaro.org --- target/arm/cpu.h | 1 + target/arm/tcg/gicv5-cpuif.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index b0fc90a994..9b12b0114b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -606,6 +606,7 @@ typedef struct CPUArchState { uint64_t ppi_active[GICV5_NUM_PPIS / 64]; uint64_t ppi_hm[GICV5_NUM_PPIS / 64]; uint64_t ppi_pend[GICV5_NUM_PPIS / 64]; + uint64_t 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 ee97d98d7e..09cd56cbfa 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -219,6 +219,12 @@ static void gic_ppi_spend_write(CPUARMState *env, cons= t ARMCPRegInfo *ri, raw_write(env, ri, old | value); } =20 +static void gic_ppi_enable_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + raw_write(env, ri, value); +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -334,6 +340,18 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_hm[1]), .resetvalue =3D PPI_HMR1_RESET, }, + { .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, + .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, + .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, --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169174; cv=none; d=zohomail.com; s=zohoarc; b=WVJi8GlGJfRIRQGBSS2GhKA4zhwYndC1J/gDk8LZyHIHzMeegr1kr1KnraksWCCuyDjVvuzqjpNVIQMZV0VvzyaghxIjGE3FP9mEjE582/agpLthFlT/h8Ykc2YGROgQejXrEgVrZ0mRpvEHehWa/OSI3JgOP2sMbGDr2pOdpHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169174; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=HgYzGVTUWzglc6pPiX7cv3PCWRiy3vSKkGuTnANNYrM=; b=di1VEsyhlaUhLzaQ2O6gBGAlV8orqmS6SxTlPWLO/hp1p03J30e35bm+/SA/qSYBnensmXBh2VIYmFjahYC5jn3x2SslorYT58ER0kJNMJoWXvTy5qlF950e2TIXRNF7gMUtqxReAYzcMc3FcRXR8M7F/IWVnbiszsOY1pyv+l8= 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 1778169174062567.7788257240036; Thu, 7 May 2026 08:52:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11k-0004OI-Tv; Thu, 07 May 2026 11:52: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 1wL11i-0004DI-Pp for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:39 -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 1wL11h-0003xV-5R for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:38 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-488a14c31eeso7393955e9.0 for ; Thu, 07 May 2026 08:52:36 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169155; x=1778773955; 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; bh=HgYzGVTUWzglc6pPiX7cv3PCWRiy3vSKkGuTnANNYrM=; b=i+mhz3c6nG64UMJZqU/rNbIoBqB9/aRJkNELoGZZMgjXZKOSoGUnRYydHnBJ/TWHzT 1sGUIvaR9E6XaObXz7lCm796GQ0ZgSYQMiPFTXfppTpkWSJ2J/OyWT11e/iqscDc2zNc iEPifliu/vPv46FHQB3qNsncHTVzhlDCiDFhx6xzhh9W8Y82+6DzxceFpkF9Fa8xn99X UTN9NMkrTkB8xO4K0dYZqh8FOEA6YGaP/N7QWwkzl1yzLTts7YwSCBZ4POp3lfuxxN38 OF+zQpxi5ojR6eRiH13iWOOOuTZ7JEp0KTccS3a/Vsr01SFOh00A5zquL9fqz7LwfFyL DZTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169155; x=1778773955; 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; bh=HgYzGVTUWzglc6pPiX7cv3PCWRiy3vSKkGuTnANNYrM=; b=W2UpqaPsf4x4daa5bmBL0G4z9u0sxH+fU5iUSEloBP5QoSPTj56q3XQG12I4s8tBlY 9s38HTf8R8eXOhhA25H0AtBxamOvob6pkIHcAupKujLOb55r2jBSF1+LavlGOZvd9ikA /wfaClrO/9ukzWpR5OPG4g5EaubrVfpIfUxwz44bOD962ybpjWZeZt+3LAVDOjB26Ser sZznGzE4KJXAPrnYBaHxaCyNHvpNXnkJEp25ckGafGEAuf5ffa1sAyJfdWJrxC5/wKqN PpANgMh62ZrpoDWik2lZGgKdtGNbqW0EST48sN4syeVqCje7NKafWT+67uzNKVeCEJua 7oMw== X-Gm-Message-State: AOJu0Yxa8r5LXxMvwgDGiOBQvnv4aaxF0/4FvT97BYinHxLI1eNogyPn R3ezI8xyGNlbyN+A7082qmOJoGL9vFAIhvQ3EpPyREEgJJ3apa4gl9DPNfgnsnQ1ybYK0Xi68tS jMeuj X-Gm-Gg: AeBDieveI/UQUDMk/yIlzhnOc0jHutyk1y1xgaOBt39ieDvAbdiNoaggd69ME6mdGFE NpQ3VifiKPmyqibcNpK+sMx1Wcurr6YVHUpacURz7Li2SqQBbSkapSPjYycFkwKxKFsFEJznCR9 ac4T86N9jYWXdGYDOY9h+XTVUizHqPx1wna70A6SCOINrkH8IdUFvkdS5ehCgjlyWciAZHGOE9L yO0B9bz2D9XuVCw7MUjxe7u2ofAs5X2gsGMIcgMx+noK0LSgGLK/BzmF1gm15jDoXvc8upw6mzV sre91+/ariYLCRspnzt/7NeUgdUs8/drUv9ttLzNBBFu8jR0v/hmQ0k1RgXmmW6JfKJ+89HwhRj A44vUu6YUN5jnqiaiUkV2W6cK/3TpkqylRMGyRiQs2dUJAcxbtEohMKJM7/Om91g6F231n475Q9 8utcVD8kDZnfeKzDX3lNvFraOT/+hfqlabY8JnEBr2o3MsKcKtznBcBrEA0aQrcLsJW+Qr83aq7 mehpH4dfArIC5v6LOQ1ZzWBbv23PVw= X-Received: by 2002:a05:600c:8b04:b0:47e:e2eb:bc22 with SMTP id 5b1f17b1804b1-48e51f183demr132794175e9.5.1778169154943; Thu, 07 May 2026 08:52:34 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 40/67] target/arm: GICv5 cpuif: Implement PPI priority registers Date: Thu, 7 May 2026 16:51:27 +0100 Message-ID: <20260507155154.1886557-41-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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, 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: 1778169174978158500 Content-Type: text/plain; charset="utf-8" Implement the GICv5 registers which hold the priority of the PPIs. Each 64-bit register has the priority fields for 8 PPIs, so there are 16 registers in total. This would be a lot of duplication if we wrote it out statically in the array, so instead create each register via a loop in define_gicv5_cpuif_regs(). Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-41-peter.maydell@linaro.org --- target/arm/cpu.h | 2 ++ target/arm/tcg/gicv5-cpuif.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9b12b0114b..cf7f8f8fac 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -607,6 +607,8 @@ typedef struct CPUArchState { uint64_t ppi_hm[GICV5_NUM_PPIS / 64]; uint64_t ppi_pend[GICV5_NUM_PPIS / 64]; uint64_t ppi_enable[GICV5_NUM_PPIS / 64]; + /* The PRIO regs have 1 byte per PPI, so 8 PPIs to a register */ + uint64_t 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 09cd56cbfa..74132ca097 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -225,6 +225,12 @@ static void gic_ppi_enable_write(CPUARMState *env, con= st ARMCPRegInfo *ri, raw_write(env, ri, value); } =20 +static void gic_ppi_priority_write(CPUARMState *env, const ARMCPRegInfo *r= i, + uint64_t value) +{ + raw_write(env, ri, value); +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -382,5 +388,22 @@ void define_gicv5_cpuif_regs(ARMCPU *cpu) { if (cpu_isar_feature(aa64_gcie, cpu)) { define_arm_cp_regs(cpu, gicv5_cpuif_reginfo); + + /* + * There are 16 ICC_PPI_PRIORITYR_EL1 regs, so define them + * programmatically rather than listing them all statically. + */ + for (int i =3D 0; i < 16; i++) { + g_autofree char *name =3D g_strdup_printf("ICC_PPI_PRIORITYR%d= _EL1", i); + ARMCPRegInfo ppi_prio =3D { + .name =3D name, .state =3D ARM_CP_STATE_AA64, + .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, + .fieldoffset =3D offsetof(CPUARMState, gicv5_cpuif.ppi_pri= ority[i]), + .writefn =3D gic_ppi_priority_write, .raw_writefn =3D raw_= write, + }; + define_one_arm_cp_reg(cpu, &ppi_prio); + } } } --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169228; cv=none; d=zohomail.com; s=zohoarc; b=X4e0VpBWTfBJNXJaL5d89f5g2vXRd30+U0ELa8ib/VypNH8NNFzvB6OzkD40nq2SCazCsvZNx98d9U5IUQ4msdiyjib0jyRQP9IhM3yx/5peAaT+nAs2/4XLXz2cuF2loMQUfuAXImcqlLkNgBLCeN5PtXzf4TVl2yPjZE7AmUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169228; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=x2jByYOcRCS9jxQs8w1Al6UoyCvhrIi2zp66CXsq9Dw=; b=UZ8qLHz/dJgi/usU6bwqjs9+XX1t0RrtftYcyY1BjLgQiyDfMb7dSehEajWa0IDV1v/lX7rhk2El/ZwLS0s0R776KroWXaMB1wZMIuE8IKuRuRZ6iJSOThduUywD1GNHIV2o7diGKzMEv6r8sixEqhNZYOae1vGsgHQA9oxwftc= 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 1778169227990586.1141840582069; Thu, 7 May 2026 08: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 1wL11l-0004P2-0c; Thu, 07 May 2026 11:52:41 -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 1wL11j-0004HI-K2 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:39 -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 1wL11h-0003xi-FH for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:39 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-488e1a8ac40so10274535e9.2 for ; Thu, 07 May 2026 08:52:37 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169156; x=1778773956; 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; bh=x2jByYOcRCS9jxQs8w1Al6UoyCvhrIi2zp66CXsq9Dw=; b=O0309RBqq2BAUXtTwvJ2ETGCleMa38BK8f0VmPyfbvcBcHi2jLdnfwmFjjbuIvCbrL dZZL3bF/VTTlIeKnlpmUYNekx2lZc0CZ6qDl8vGVRJTttLEBnKux0oy6ZbWlj2+AuPYS p/IMhyzPKht+dW0hr1IQtLpP+5/Ogi+VJ8SEfSwQxml9lMACyQe/es1SLyXLpY9cyAp1 0b6L9mQcJeG082eLQXOAQOKdmQcfIpKHZMr2zfRD5OpRtaHvtBrRDqTSmMS8ovmIvNvk maSnkXa+74inexiZ9UybFjmuEbZJxRnW202ZWGWIIuPayfQ9vVrRfMMYByTbY5VPwjic TEFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169156; x=1778773956; 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; bh=x2jByYOcRCS9jxQs8w1Al6UoyCvhrIi2zp66CXsq9Dw=; b=JgpAvMCns3slvOmqYvK6BPQxLi0hrgdpEk3HDU6AtrDb2aAM3NYhAPNZQ+SlSYXUh+ Z+T+UW1V8cXFLLk6VsnPdhPb3AnO9JOUq63XZO/8ELVuZGk4tcocsky+VBHsBiST5LdL jRHE+t/j3NSWM+szbgx9YqQAhgl0KYs2XVTAK4xvqXZlJTsPBWl44969LCVn6U9fZsuf n8Hoy9WPhIqvL9dPXXeKuMtRSKWHcRy+YkbODlLhoAku+AUkRTdukPPMNRBC/bBpGQqD WdxGPaZy4wmw/FOQD+cWa9oHNRg6NHn4cBK2py0har6hXdwrH4+XCP80Y1k1ujHqlCLj h5AQ== X-Gm-Message-State: AOJu0YwIqohffPVp1YMkDNsgGImRyWfh3HUFazByqHxE7wM90c7Y1w2A AiCZslV5m99PMjWt2d1CGdJoK9NXGm30X6Y6VBSroGLGlF7oTmCkzzfHCwIhWqZEp3ffBT2gW/r a8ckN X-Gm-Gg: AeBDietlsZQWNAn3B1uP2T86eb6llk1OGQgxMqDN1CX8wFzyjwvvz66onzr9AhLUgEn Q5qxInAB/0xGDwUI9e9h4NFCxgRS73i+v2FYL2CPmbgW2aJ5DH/Q2WDDfXDRfciyz73qKQkbQwY FskoCouMBotacRYDHDORYIEDfgkkXro/7QZmLJ8B8NZMabkPOFniuOx2t3bYFiFlKkAgMVOjWxm geWUpy+Oq7dfdMp8lqNa0FYXuOZbioZKHplhBZ2OqHanjwwiVcGELn5yiEeBMQRrX5W/9BTiPNv /YfjZx+Ggtm1QdUaNZq+sTnFQoeG6TM4YbwYi5IogUgODl/vLXPXTZ1QZ+gWWcyhNHsW6eFcJ7R a0R1MoNk1glI94qDMuqEpBbg9/txmTgpZGUcKRDWk9YK/tv+QnJabEKot9Z9gmeKcTR7HOA1G0K A2bFh3o0kK/hlVDUEKHVL5LS9A67ynDTjqwe8n0XFIg2Rlk8h4Ld1wkSg0ECIMSDfh2duUDI3Jd ay6mwel1/mYGnR7qVF9p6D6wVdkZ2c= X-Received: by 2002:a05:600c:a405:b0:489:1a3a:9e45 with SMTP id 5b1f17b1804b1-48e51f54230mr118107145e9.26.1778169155778; Thu, 07 May 2026 08:52:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 41/67] target/arm: GICv5 cpuif: Implement ICC_APR_EL1 and ICC_HAPR_EL1 Date: Thu, 7 May 2026 16:51:28 +0100 Message-ID: <20260507155154.1886557-42-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169229369158500 Content-Type: text/plain; charset="utf-8" The ICC_APR_EL1 GICv5 cpuif register records the physical active priorities. Since the GICv5 always uses 5 bits of priority, this register always has 32 non-RES0 bits, and we don't need the complicated GICv3 setup where there might be 1, 2 or 4 APR registers. ICC_HAPR_EL1 is a read-only register which reports the current running priority. This is defined to be the lowest set bit (i.e. the highest priority) in the APR, or the Idle priority 0xff if there are no active interrupts, so it is effectively a convenience re-presentation of the APR register data. The APR register is banked per interrupt domain; ICC_APR_EL1 accesses the version of the register corresponding to the current logical interrupt domain. The APR data for the final domain (EL3) is accessed via ICC_APR_EL3. Although we are starting with an EL1-only implementation, we define the CPU state as banked here so we don't have to change our representation of it later when we add EL3 and RME support. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-42-peter.maydell@linaro.org --- include/hw/intc/arm_gicv5_types.h | 2 ++ target/arm/cpu.h | 2 ++ target/arm/tcg/gicv5-cpuif.c | 60 +++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/include/hw/intc/arm_gicv5_types.h b/include/hw/intc/arm_gicv5_= types.h index f6f8709a6a..5966ebde05 100644 --- a/include/hw/intc/arm_gicv5_types.h +++ b/include/hw/intc/arm_gicv5_types.h @@ -84,4 +84,6 @@ typedef enum GICv5TriggerMode { GICV5_TRIGGER_LEVEL =3D 1, } GICv5TriggerMode; =20 +#define PRIO_IDLE 0xff + #endif diff --git a/target/arm/cpu.h b/target/arm/cpu.h index cf7f8f8fac..76db5a9197 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -34,6 +34,7 @@ #include "target/arm/gtimer.h" #include "target/arm/cpu-sysregs.h" #include "target/arm/mmuidx.h" +#include "hw/intc/arm_gicv5_types.h" =20 #define EXCP_UDEF 1 /* undefined instruction */ #define EXCP_SWI 2 /* software interrupt */ @@ -602,6 +603,7 @@ typedef struct CPUArchState { struct { /* GICv5 CPU interface data */ uint64_t icc_icsr_el1; + uint64_t icc_apr[NUM_GICV5_DOMAINS]; /* Most PPI registers have 1 bit per PPI, so 64 PPIs to a register= */ uint64_t ppi_active[GICV5_NUM_PPIS / 64]; uint64_t ppi_hm[GICV5_NUM_PPIS / 64]; diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 74132ca097..33e4762ef4 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -95,6 +95,16 @@ static GICv5Domain gicv5_current_phys_domain(CPUARMState= *env) return gicv5_logical_domain(env); } =20 +static uint64_t gic_running_prio(CPUARMState *env, GICv5Domain domain) +{ + /* + * Return the current running priority; this is the lowest set bit in + * the Active Priority Register, or the idle priority if none (D_XMBQZ) + */ + uint64_t hap =3D ctz64(env->gicv5_cpuif.icc_apr[domain]); + return hap < 32 ? hap : PRIO_IDLE; +} + static void gic_cddis_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -231,6 +241,44 @@ static void gic_ppi_priority_write(CPUARMState *env, c= onst ARMCPRegInfo *ri, raw_write(env, ri, value); } =20 +/* + * ICC_APR_EL1 is banked and reads/writes as the version for the + * current logical interrupt domain. + */ +static void gic_icc_apr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* + * 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; +} + +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]; +} + +static void gic_icc_apr_el1_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + for (int i =3D 0; i < ARRAY_SIZE(env->gicv5_cpuif.icc_apr); i++) { + env->gicv5_cpuif.icc_apr[i] =3D 0; + } +} + +static uint64_t gic_icc_hapr_el1_read(CPUARMState *env, const ARMCPRegInfo= *ri) +{ + /* + * ICC_HAPR_EL1 reports the current running priority, which can be + * calculated from the APR register. + */ + return gic_running_prio(env, gicv5_current_phys_domain(env)); +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -382,6 +430,18 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .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, + .readfn =3D gic_icc_apr_el1_read, + .writefn =3D gic_icc_apr_el1_write, + .resetfn =3D gic_icc_apr_el1_reset, + }, + { .name =3D "ICC_HAPR_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 1, .crn =3D 12, .crm =3D 0, .opc2 =3D 3, + .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, + .readfn =3D gic_icc_hapr_el1_read, .raw_writefn =3D arm_cp_write_i= gnore, + }, }; =20 void define_gicv5_cpuif_regs(ARMCPU *cpu) --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169402; cv=none; d=zohomail.com; s=zohoarc; b=f1kqcOGt6Gcy2Jrlkv5ipvjWte69Oww1UwLP78bzSDU6Qdee5Vq/Ar5ebG7no+2raUBuRJkalBKxoH6PLunup9uaDUnsq0cbjiB+GmNUyQ3MgUn7sNT8REROft4NacRwM/iJ5e16BlnpSwrGsFEmhnTp2aTN/e0Iq1w4VjFi7Rg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169402; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=eJtMnPBYtkfA68rC6IgUqGua6khlh7OyNCqY+9Ynqxs=; b=aROHm07sis9UgGnMZeLsFZ/2k9NduEjl6I0UW6h6MBzl2LzHymePwzCYgTbq61B8gk/RDaCqG2+K14T5IHIJ/OKc+T9WeF53gnTub/GNFmDW/05wwM26osB6b3KLdA6cItCumehddOTuWJCpk9jpsSG/uyyYHqUpj8LQAjM3uUw= 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 1778169402811122.66618532712675; Thu, 7 May 2026 08:56:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11m-0004Xt-Rh; Thu, 07 May 2026 11:52: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 1wL11k-0004Nw-M6 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52: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 1wL11i-0003y5-8b for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:40 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-488a8ca4aadso9857585e9.3 for ; Thu, 07 May 2026 08:52:37 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169157; x=1778773957; 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; bh=eJtMnPBYtkfA68rC6IgUqGua6khlh7OyNCqY+9Ynqxs=; b=gxchTLTeleUql+5troXJCe1/tJKJoH2alJTM00Bl9N1oEXBK5K6OgOuVO398yhaAC2 B42NLWNB3vqmSZQagb6ZcjP8vjv/twRYy2fWIIs6/sYr+DVcl3SDRzsy09Da16GJlVim a0ATWGnaPG54ow5r74U/Cr6rgPnqZXWHfl3HuHEh9EfwxwEt7czMbIRfujFHnW0RiSWl yKZouwBHgYfuPRm4nYlpRPOMCSc3BNXukmriLnIJjaMSe5RNSan2FI18yCj6lg8oO2KE dNUmOfF80RKAb31+7hWAJLECww8Smr2wfxF51lJB0fFC73N8+Gk0F/YXsf1gO7VyjRaa 9xAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169157; x=1778773957; 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; bh=eJtMnPBYtkfA68rC6IgUqGua6khlh7OyNCqY+9Ynqxs=; b=B8lLlCjWVxv2ICks92lVMHR/IawUHvNI/aB5ESpvqffxjVbBZX3FZodYqZ4u1B0iUg n20iE73bxeXR5jKdjIMcpbg8DSAKI81LcgzZfEwg2QVjkjVkrhirZChpiyPj1ATY6Tnb YLmQB8RVcMYkY0LpDivuozNz2cvRmlmx73d8e3lqiYgHD1ncvBsIkNh3pQh7c6lensiE Z5YEl4OqjTQSETySFrZA0De9jr4/0vgLv3vN0UD/J7hVzt87rfrEajg9YGxia7ARsAmE K4QDn6ynsamhN1B8QIDU05HLL7MuC4Oi+W8ZOBiwIpsBZNRETwlpyZ2cvFy2CEO4lnS4 /Zvw== X-Gm-Message-State: AOJu0YyiXQXOVLnbYcqduVN7BGXo1/cCnN2AfVO9mynH1Au6tg3O2UEO CZJ0uGmuMxgwdkOx6CJU8j5FwyfBwG6xkWdrfUyPbzFGt7QsXg2oLDRnhqjMOiI7n8LBfHpHR+B qR2sQ X-Gm-Gg: AeBDievVhItstoqaqFo/34xQ/V+Z0tTZqS8vvANDhFwTcRtOCPbnHgIfJ4d+qKR6ag9 AVITXk3plFVgL5WmgZmip4GBNvy3KISy1WFPI01tq6BjujXuAffF6Hm9c9wc3vDLEERkZonRWdo Y+n4kaZ7LTX3hgl2Pfe3/boBrIoFCK3knpm5XhH54aZ/lR+xc8MDNVO7uBisZDWWP/A36Gee/sB 164tlQAvPMjKugIHlsg0wlReAkCdYM0uQWgLLUuNbBfOmIhqk2ikaFWuU91ImDbzQ3cKu3H5/Ep T2aVu1jN4zJffWIOd5R8OIlWBdIjVSnjykFizsbFRC4Rv9nfvsSTXxGpz4X2J7YVdqMrJlmExFQ CmtIpeEiBHQVgGnbqPeP17qdJ6vrrnCEDZ7ns0d1TWBxtT/L+ekcUOLO537y/o/aWa3UBvW4EIN GlqgckSNUH/EhqBWrk9/nGsRZOyPWwpK+0DohB0YWaLyPlr2/fUsXTzLqqVnfDrIWFD/YYvbCCS qq86Z3sFCIEaI7eLmhodKybFJcryYrGx0weO+QNkg== X-Received: by 2002:a05:600c:8b06:b0:485:4388:3492 with SMTP id 5b1f17b1804b1-48e51e223ccmr139253455e9.11.1778169156619; Thu, 07 May 2026 08:52:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 42/67] target/arm: GICv5 cpuif: Calculate the highest priority PPI Date: Thu, 7 May 2026 16:51:29 +0100 Message-ID: <20260507155154.1886557-43-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169405131154100 Content-Type: text/plain; charset="utf-8" When the state of PPIs changes, recalculate the highest priority PPI. In subsequent commits we will use this cached value to provide the HPPI info to the guest, decide whether to signal IRQ or FIQ, handle interrupt acknowldge from the guest, and so on. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-43-peter.maydell@linaro.org --- include/hw/intc/arm_gicv5_types.h | 21 +++++++++++ meson.build | 1 + target/arm/cpu.h | 3 ++ target/arm/tcg/gicv5-cpuif.c | 58 +++++++++++++++++++++++++++++++ target/arm/tcg/trace-events | 5 +++ target/arm/tcg/trace.h | 1 + 6 files changed, 89 insertions(+) create mode 100644 target/arm/tcg/trace-events create mode 100644 target/arm/tcg/trace.h diff --git a/include/hw/intc/arm_gicv5_types.h b/include/hw/intc/arm_gicv5_= types.h index 5966ebde05..eaed42f49f 100644 --- a/include/hw/intc/arm_gicv5_types.h +++ b/include/hw/intc/arm_gicv5_types.h @@ -12,6 +12,8 @@ #ifndef HW_INTC_ARM_GICv5_TYPES_H #define HW_INTC_ARM_GICv5_TYPES_H =20 +#include "hw/core/registerfields.h" + /* * The GICv5 has four physical Interrupt Domains. This numbering must * match the encoding used in IRS_IDR0.INT_DOM. @@ -86,4 +88,23 @@ typedef enum GICv5TriggerMode { =20 #define PRIO_IDLE 0xff =20 +/* + * We keep track of candidate highest possible pending interrupts + * using this struct. + * + * Unlike GICv3, we don't need a separate NMI bool, because for GICv5 + * superpriority is signaled by @prio =3D=3D 0. + * + * In this struct the intid includes the interrupt type in bits + * [31:29] (i.e. it is in the form defined by R_TJPHS). + */ +typedef struct GICv5PendingIrq { + uint32_t intid; + uint8_t prio; +} GICv5PendingIrq; + +/* Fields in a generic 32-bit INTID, per R_TJPHS */ +FIELD(INTID, ID, 0, 24) +FIELD(INTID, TYPE, 29, 3) + #endif diff --git a/meson.build b/meson.build index 5fbdc75a0f..2c95d6995a 100644 --- a/meson.build +++ b/meson.build @@ -3688,6 +3688,7 @@ if have_system or have_user 'hw/core', 'target/arm', 'target/arm/hvf', + 'target/arm/tcg', 'target/hppa', 'target/i386', 'target/i386/kvm', diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 76db5a9197..f27f2e6bcc 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -611,6 +611,9 @@ typedef struct CPUArchState { uint64_t ppi_enable[GICV5_NUM_PPIS / 64]; /* The PRIO regs have 1 byte per PPI, so 8 PPIs to a register */ uint64_t ppi_priority[GICV5_NUM_PPIS / 8]; + + /* Cached highest-priority pending PPI for each domain */ + GICv5PendingIrq ppi_hppi[NUM_GICV5_DOMAINS]; } gicv5_cpuif; =20 struct { diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 33e4762ef4..80bb1cd391 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -11,6 +11,7 @@ #include "internals.h" #include "cpregs.h" #include "hw/intc/arm_gicv5_stream.h" +#include "trace.h" =20 FIELD(GIC_CDPRI, ID, 0, 24) FIELD(GIC_CDPRI, TYPE, 29, 3) @@ -105,6 +106,57 @@ static uint64_t gic_running_prio(CPUARMState *env, GIC= v5Domain domain) return hap < 32 ? hap : PRIO_IDLE; } =20 +static void gic_recalc_ppi_hppi(CPUARMState *env) +{ + /* + * Recalculate the HPPI PPI: this is the best PPI which is + * enabled, pending and not active. + */ + for (int i =3D 0; i < ARRAY_SIZE(env->gicv5_cpuif.ppi_hppi); i++) { + env->gicv5_cpuif.ppi_hppi[i].intid =3D 0; + env->gicv5_cpuif.ppi_hppi[i].prio =3D PRIO_IDLE; + }; + + for (int i =3D 0; i < ARRAY_SIZE(env->gicv5_cpuif.ppi_active); i++) { + uint64_t en_pend_nact =3D env->gicv5_cpuif.ppi_enable[i] & + env->gicv5_cpuif.ppi_pend[i] & + ~env->gicv5_cpuif.ppi_active[i]; + + while (en_pend_nact) { + /* + * When EL3 is supported ICC_PPI_DOMAINR_EL3 tells us + * the domain of each PPI. While we only support EL1, the + * domain is always NS. + */ + GICv5Domain ppi_domain =3D GICV5_ID_NS; + uint8_t prio; + int ppi; + int bit =3D ctz64(en_pend_nact); + + en_pend_nact &=3D ~(1 << bit); + + ppi =3D i * 64 + bit; + prio =3D extract64(env->gicv5_cpuif.ppi_priority[ppi / 8], + (ppi & 7) * 8, 5); + + if (prio < env->gicv5_cpuif.ppi_hppi[ppi_domain].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.ppi_hppi[ppi_domain].intid =3D intid; + env->gicv5_cpuif.ppi_hppi[ppi_domain].prio =3D prio; + } + } + } + + for (int i =3D 0; i < ARRAY_SIZE(env->gicv5_cpuif.ppi_hppi); i++) { + trace_gicv5_recalc_ppi_hppi(i, + env->gicv5_cpuif.ppi_hppi[i].intid, + env->gicv5_cpuif.ppi_hppi[i].prio); + } +} + static void gic_cddis_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { @@ -200,6 +252,7 @@ static void gic_ppi_cactive_write(CPUARMState *env, con= st ARMCPRegInfo *ri, { 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, @@ -207,6 +260,7 @@ static void gic_ppi_sactive_write(CPUARMState *env, con= st ARMCPRegInfo *ri, { 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, @@ -217,6 +271,7 @@ static void gic_ppi_cpend_write(CPUARMState *env, const= ARMCPRegInfo *ri, 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); } =20 static void gic_ppi_spend_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -227,18 +282,21 @@ static void gic_ppi_spend_write(CPUARMState *env, con= st ARMCPRegInfo *ri, 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); } =20 static void gic_ppi_enable_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { raw_write(env, ri, value); + gic_recalc_ppi_hppi(env); } =20 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); } =20 /* diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events new file mode 100644 index 0000000000..7dc5f781c5 --- /dev/null +++ b/target/arm/tcg/trace-events @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# See docs/devel/tracing.rst for syntax documentation. + +# 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" diff --git a/target/arm/tcg/trace.h b/target/arm/tcg/trace.h new file mode 100644 index 0000000000..c6e89d018b --- /dev/null +++ b/target/arm/tcg/trace.h @@ -0,0 +1 @@ +#include "trace/trace-target_arm_tcg.h" --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169492; cv=none; d=zohomail.com; s=zohoarc; b=QBPt+A5cG1ZXcM3PQlS7k4yAzR8hWl28cjdeM3rsUZTH/oY3DploWLgCZgTZgbvMSLoTlHnLJGCUeRnrOryBjG8fsS8T/eFJMDakHxUJjTRiI3ER5rQ+k2LOL/ec32YEOi77L7ia4yyKpyEF6EdEe2sNSEXdSnnHxCHp/HInAY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169492; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=xqC42QqeAJ1FUP4DDssazelQjVzwech+QR4/L/J9pFg=; b=cElfTxf2BpoKI9edRei/wjdFgJd0kIXqoeQuZvnLbIiPR1htWceDVpodZRhs0WgDVuKSAlNxFPh58wSRGyG1MLyD0CrTDLQ6cxL47Rpa5v5U1M8PyxgbSXl6Ocl7plMzoQVPkFU8p2nj96o2hTgSaR4KdChsY/O44XY7r4gTBWY= 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 1778169492323293.5855007183659; Thu, 7 May 2026 08:58:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11o-0004n1-PM; Thu, 07 May 2026 11:52: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 1wL11n-0004ZQ-0Y for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:43 -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 1wL11j-0003yE-DT for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:42 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-488b150559bso8032615e9.1 for ; Thu, 07 May 2026 08:52:38 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169158; x=1778773958; 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; bh=xqC42QqeAJ1FUP4DDssazelQjVzwech+QR4/L/J9pFg=; b=Ef8nfe7TifnzC9UhH+MO/C/CCbYX4+mkpabK/DBeUSJXQnsgD5DhzEpFdRTe8elEsr E4GwKYFAYPnf4f7X5DIvpq2ro42YyYVOqZhzOuC3VGxUJcktE1ZfXFye1TqgAVAvD1g+ 5KOLke4LbQoYfNnD7rCXBJ7xpMxvNc0bhzHLzfO2/HCP9bA2n4cMfNauOBHyPi9EquUf Jq07zJuSKN+s1rf2oD/EiHYOv3DlBJhRrtpGwS47GetgOXqvV18qmpz+xjG7WahrhvRk LJm7pibs3/Emn7y6d0ekMYFI/lLG13BEgda1ZQr7vsj9Jiltr7uWV62od8B5CW3sSzi6 TsnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169158; x=1778773958; 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; bh=xqC42QqeAJ1FUP4DDssazelQjVzwech+QR4/L/J9pFg=; b=PUGtA+Hm0rZ5ZooEt+AIr37ZQ1SYB9AC9C1B6EVDy9hrpFdpd+INsVF+3R/pHlPVUt OraA3msY8ZfC/UoWs4TD07d919sPjmZEUlFYI0rnXkf8TlgvGohN3H8awP9hwyWHmpT/ G3GjUhJb4Y3XZEx/CXs3mPOnObe5s95OMZZPL16FrybIY2l5RAASETebicv0bHUqbhFn fqCZ0PBzPUUtiQispCp1EBgba1ZKGL1XcPSsbHhLv2HPX0OiWGBBtWbk5VKWJBSbOvO8 ERV5Hxx1ImCuuYZk9QVLM8ZsIrODGIKypCo+kdM0/039Tr6FVdFT3lzI5AsZQJfJSeK2 AHXg== X-Gm-Message-State: AOJu0Yzs/nQAgKlT/oMPYBmfCnoyCjripDfpsRUbPiBNfkHwuSHGD3yd swc8np/tcRqhFdjURHzbVONCXIEk5kcGFEsJKVKKquIzZoDRJTg9mWLtGrOiLeu171lcCB6QCNv fsgPs X-Gm-Gg: AeBDietgkMLd1HxfJ72QBTZMb3OJIdKUSx8NBHMidDnLl8DJXiH1xsAUYCgxLDrnmXY wjAuqqR74C7deYAlPCipHGBbzeXRuZR2iGYAvyBPzPz9iZk8TpCC2aryjYYGDYl8gbs1sbAKkia RrinksljLaozSgYjqBJ+jHls3rDa+8PKEF7DHRQQjY8+ntlSijezJmjlUy2TVSIE3w/G2nP6I4s Wy2BwlB5YyNxSzJPOU8VU1X4FllLqIL9aq9pLFon3gLgVSun1Iqu3+4K4VZpjLiLhHdkX+TaXbW 0BzNP4FLSeYDcoyvMJ8dNf9BzGG3S159rB2Lqye5wjvE5nqo0DwhH0PZe2eGo2imkTtSLzg9bIm yJPozXcN+YHAh/jmEuRIhvxrAFmDnjfhZIT2AoZmZgdF40p+k3244oxRrvHopnBuPheT94Nzeye r3sELBy0+CD4l2ke/Hq2x+ji0vUeM9b4EIGntQVWrvfatchDSXWAoLZxzA9qIIt0RRpV+zEYTxc iAlc438M6NUdwX3Lzj8k6AfleBt6sk= X-Received: by 2002:a05:600c:3e8d:b0:488:bc6a:528d with SMTP id 5b1f17b1804b1-48e51f40b12mr147894075e9.22.1778169157455; Thu, 07 May 2026 08:52:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 43/67] hw/intc/arm_gicv5: Calculate HPPI in the IRS Date: Thu, 7 May 2026 16:51:30 +0100 Message-ID: <20260507155154.1886557-44-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169494823154100 Content-Type: text/plain; charset="utf-8" The IRS is required to present the highest priority pending interrupt that it has for each domain for each cpu interface. We implement this in the irs_recalc_hppi() function, which we call at every point where some relevant IRS state changes. This function calls gicv5_forward_interrupt() to do the equivalent of the GICv5 stream protocol Forward and Recall commands. For the moment we simply record the HPPI on the CPU interface side without trying to process it; the handling of the HPPI in the cpuif will be added in subsequent commits. There are some cases where we could skip doing the full HPPI recalculation, e.g. when the guest changes the config of an interrupt that is disabled; we expect that the guest will only do interrupt config at startup, so we don't attempt to optimise this. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-44-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 202 +++++++++++++++++++++++++++++ hw/intc/trace-events | 2 + include/hw/intc/arm_gicv5.h | 3 + include/hw/intc/arm_gicv5_stream.h | 24 ++++ target/arm/tcg/gicv5-cpuif.c | 9 ++ 5 files changed, 240 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 989492d4b6..12cbf9c51e 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -376,6 +376,157 @@ static MemTxAttrs irs_txattrs(GICv5Common *cs, GICv5D= omain domain) }; } =20 +/* Data we need to pass through to lpi_cache_get_hppi() */ +typedef struct GetHPPIUserData { + GICv5PendingIrq *best; + uint32_t iaffid; +} 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; + uint32_t prio, iaffid; + GetHPPIUserData *ud =3D user_data; + + if ((l2_iste & (R_L2_ISTE_PENDING_MASK | R_L2_ISTE_ACTIVE_MASK | R_L2_= ISTE_ENABLE_MASK)) + !=3D (R_L2_ISTE_PENDING_MASK | R_L2_ISTE_ENABLE_MASK)) { + return; + } + 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); + ud->best->intid =3D id; + ud->best->prio =3D prio; + } +} + +static int irs_cpuidx_from_iaffid(GICv5Common *cs, uint32_t iaffid) +{ + for (int i =3D 0; i < cs->num_cpus; i++) { + if (cs->cpu_iaffids[i] =3D=3D iaffid) { + return i; + } + } + return -1; +} + +static void irs_recalc_hppi(GICv5 *s, GICv5Domain domain, uint32_t iaffid) +{ + /* + * Recalculate the highest priority pending interrupt for the + * specified domain and cpuif. HPPI candidates must be pending, + * inactive and enabled. + */ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + int cpuidx =3D irs_cpuidx_from_iaffid(cs, iaffid); + ARMCPU *cpu =3D cpuidx >=3D 0 ? cs->cpus[cpuidx] : NULL; + GICv5PendingIrq best; + + best.intid =3D 0; + best.prio =3D PRIO_IDLE; + + if (!cpu) { + /* Nothing happens for iaffids targeting nonexistent CPUs */ + trace_gicv5_irs_recalc_hppi_fail(domain_name[domain], iaffid, + "IAFFID doesn't match any CPU"); + return; + } + + if (!FIELD_EX32(cs->irs_cr0[domain], IRS_CR0, IRSEN)) { + /* When the IRS is disabled we don't forward HPPIs */ + trace_gicv5_irs_recalc_hppi_fail(domain_name[domain], iaffid, + "IRS_CR0.IRSEN is zero"); + return; + } + + if (s->phys_lpi_config[domain].valid) { + GetHPPIUserData ud; + + ud.best =3D &best; + ud.iaffid =3D iaffid; + g_hash_table_foreach(s->phys_lpi_config[domain].lpi_cache, + lpi_cache_get_hppi, &ud); + } + + /* + * OPT: consider also caching the SPI interrupt information, + * similarly to how we handle LPIs, if iterating through the whole + * SPI array every time is too expensive. + */ + for (int i =3D 0; i < cs->spi_irs_range; i++) { + GICv5SPIState *spi =3D &cs->spi[i]; + + if (spi->active || !spi->pending || !spi->enabled) { + continue; + } + if (spi->domain !=3D domain || spi->iaffid !=3D iaffid) { + continue; + } + if (spi->priority < best.prio) { + uint32_t intid =3D 0; + intid =3D FIELD_DP32(intid, INTID, ID, i); + intid =3D FIELD_DP32(intid, INTID, TYPE, GICV5_SPI); + best.intid =3D intid; + best.prio =3D spi->priority; + } + } + + trace_gicv5_irs_recalc_hppi(domain_name[domain], iaffid, + best.intid, best.prio); + + s->hppi[domain][cpuidx] =3D best; + /* + * Now present the HPPI to the cpuif. In the real hardware stream + * protocol, the connection between IRS and cpuif is asynchronous, + * and so both ends track their idea of the current HPPI, with a + * back-and-forth sequence so they stay in sync and more + * interaction when the cpuif resets. For QEMU, we are strictly + * synchronous and the cpuif asking the IRS for data is a cheap + * function call, so we simplify this: + * - the IRS knows what the current HPPI is + * - s->hppi[][] is a cache we can recalculate + * - the IRS merely tells the cpuif "something changed", and + * 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); +} + +static void irs_recalc_hppi_all_cpus(GICv5 *s, GICv5Domain domain) +{ + /* + * Recalculate the HPPI for every CPU for this domain. This is + * not as efficient as it could be because we will scan through + * the LPI cached hash table and the SPI array for each CPU rather + * than doing a single combined scan, but we only need to do this + * very rarely, when the guest enables or disables the IST, so we + * implement this the simple way. + */ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + for (int i =3D 0; i < cs->num_cpus; i++) { + irs_recalc_hppi(s, domain, cs->cpu_iaffids[i]); + } +} + +static void irs_recall_hppis(GICv5 *s, GICv5Domain domain) +{ + /* + * The IRS was just disabled -- we must recall any pending HPPIs + * we have sent to the CPU interfaces. For us this means that we + * clear our cached HPPI data and tell the cpuif that it has + * changed. + */ + GICv5Common *cs =3D ARM_GICV5_COMMON(s); + + for (int i =3D 0; i < cs->num_cpus; i++) { + s->hppi[domain][i].intid =3D 0; + s->hppi[domain][i].prio =3D PRIO_IDLE; + gicv5_forward_interrupt(cs->cpus[i], domain); + } +} + static hwaddr l1_iste_addr(GICv5Common *cs, const GICv5ISTConfig *cfg, uint32_t id) { @@ -575,6 +726,7 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, u= int8_t priority, GICv5Domain domain, GICv5IntType type, bool virtua= l) { GICv5 *s =3D ARM_GICV5(cs); + uint32_t iaffid; =20 trace_gicv5_set_priority(domain_name[domain], inttype_name(type), virt= ual, id, priority); @@ -598,6 +750,7 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, u= int8_t priority, 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; } @@ -612,6 +765,7 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, u= int8_t priority, } =20 spi->priority =3D priority; + iaffid =3D spi->iaffid; break; } default: @@ -619,12 +773,15 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id,= uint8_t priority, "priority of bad interrupt type %d\n", type); return; } + + irs_recalc_hppi(s, domain, iaffid); } =20 void gicv5_set_enabled(GICv5Common *cs, uint32_t id, bool enabled, GICv5Domain domain, GICv5IntType type, bool virtual) { GICv5 *s =3D ARM_GICV5(cs); + uint32_t iaffid; =20 trace_gicv5_set_enabled(domain_name[domain], inttype_name(type), virtu= al, id, enabled); @@ -645,6 +802,7 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, bo= ol enabled, 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; } @@ -659,6 +817,7 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, bo= ol enabled, } =20 spi->enabled =3D true; + iaffid =3D spi->iaffid; break; } default: @@ -666,12 +825,15 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, = bool enabled, "enable state of bad interrupt type %d\n", type); return; } + + irs_recalc_hppi(s, domain, iaffid); } =20 void gicv5_set_pending(GICv5Common *cs, uint32_t id, bool pending, GICv5Domain domain, GICv5IntType type, bool virtual) { GICv5 *s =3D ARM_GICV5(cs); + uint32_t iaffid; =20 trace_gicv5_set_pending(domain_name[domain], inttype_name(type), virtu= al, id, pending); @@ -692,6 +854,7 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, bo= ol pending, 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; } @@ -706,6 +869,7 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, bo= ol pending, } =20 spi->pending =3D true; + iaffid =3D spi->iaffid; break; } default: @@ -713,6 +877,8 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, bo= ol pending, "pending state of bad interrupt type %d\n", type); return; } + + irs_recalc_hppi(s, domain, iaffid); } =20 void gicv5_set_handling(GICv5Common *cs, uint32_t id, @@ -767,6 +933,7 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, uin= t32_t iaffid, GICv5IntType type, bool virtual) { GICv5 *s =3D ARM_GICV5(cs); + uint32_t old_iaffid; =20 trace_gicv5_set_target(domain_name[domain], inttype_name(type), virtua= l, id, iaffid, irm); @@ -800,6 +967,7 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, uin= t32_t iaffid, * 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; @@ -814,6 +982,7 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, uin= t32_t iaffid, return; } =20 + old_iaffid =3D spi->iaffid; spi->iaffid =3D iaffid; break; } @@ -822,6 +991,9 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, uin= t32_t iaffid, "target of bad interrupt type %d\n", type); return; } + + irs_recalc_hppi(s, domain, old_iaffid); + irs_recalc_hppi(s, domain, iaffid); } =20 static uint64_t l2_iste_to_icsr(GICv5Common *cs, const GICv5ISTConfig *cfg, @@ -942,6 +1114,12 @@ static void irs_map_l2_istr_write(GICv5 *s, GICv5Doma= in domain, uint64_t value) if (res !=3D MEMTX_OK) { goto txfail; } + /* + * It's CONSTRAINED UNPREDICTABLE to make an L2 IST valid when + * some of its entries have Pending already set, so we don't need + * to go through looking for Pending bits and pulling them into + * the cache, and we don't need to recalc our HPPI. + */ return; =20 txfail: @@ -999,6 +1177,7 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain = domain, uint64_t value) IRS_IST_BASER, VALID, valid= ); s->phys_lpi_config[domain].valid =3D false; trace_gicv5_ist_invalid(domain_name[domain]); + irs_recalc_hppi_all_cpus(s, domain); return; } cs->irs_ist_baser[domain] =3D value; @@ -1068,6 +1247,7 @@ static void irs_ist_baser_write(GICv5 *s, GICv5Domain= domain, uint64_t value) 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 @@ -1223,6 +1403,11 @@ static bool config_readl(GICv5 *s, GICv5Domain domai= n, hwaddr offset, case A_IRS_CR0: /* Enabling is instantaneous for us so IDLE is always 1 */ *data =3D cs->irs_cr0[domain] | R_IRS_CR0_IDLE_MASK; + if (FIELD_EX32(cs->irs_cr0[domain], IRS_CR0, IRSEN)) { + irs_recalc_hppi_all_cpus(s, domain); + } else { + irs_recall_hppis(s, domain); + } return true; case A_IRS_CR1: *data =3D cs->irs_cr1[domain]; @@ -1311,6 +1496,7 @@ static bool config_writel(GICv5 *s, GICv5Domain domai= n, hwaddr offset, } else if (spi->level) { spi->pending =3D false; } + irs_recalc_hppi(s, spi->domain, spi->iaffid); } } return true; @@ -1320,7 +1506,12 @@ static bool config_writel(GICv5 *s, GICv5Domain doma= in, hwaddr offset, /* this is RAZ/WI except for the EL3 domain */ GICv5SPIState *spi =3D spi_for_selr(cs, domain); if (spi) { + GICv5Domain old_domain =3D spi->domain; spi->domain =3D FIELD_EX32(data, IRS_SPI_DOMAINR, DOMAIN); + if (spi->domain !=3D old_domain) { + irs_recalc_hppi(s, old_domain, spi->iaffid); + irs_recalc_hppi(s, spi->domain, spi->iaffid); + } } } return true; @@ -1331,6 +1522,7 @@ static bool config_writel(GICv5 *s, GICv5Domain domai= n, hwaddr offset, =20 if (spi) { spi_sample(spi); + irs_recalc_hppi(s, spi->domain, spi->iaffid); } trace_gicv5_spi_state(id, spi->level, spi->pending, spi->active); return true; @@ -1499,6 +1691,7 @@ static void gicv5_set_spi(void *opaque, int irq, int = level) { /* These irqs are all SPIs; the INTID is irq + s->spi_base */ GICv5Common *cs =3D ARM_GICV5_COMMON(opaque); + GICv5 *s =3D ARM_GICV5(cs); uint32_t spi_id =3D irq + cs->spi_base; GICv5SPIState *spi =3D gicv5_raw_spi_state(cs, spi_id); =20 @@ -1511,6 +1704,8 @@ static void gicv5_set_spi(void *opaque, int irq, int = level) spi->level =3D level; spi_sample(spi); trace_gicv5_spi_state(spi_id, spi->level, spi->pending, spi->active); + + irs_recalc_hppi(s, spi->domain, spi->iaffid); } =20 static void gicv5_reset_hold(Object *obj, ResetType type) @@ -1591,6 +1786,7 @@ static void gicv5_set_idregs(GICv5Common *cs) =20 static void gicv5_realize(DeviceState *dev, Error **errp) { + GICv5 *s =3D ARM_GICV5(dev); GICv5Common *cs =3D ARM_GICV5_COMMON(dev); GICv5Class *gc =3D ARM_GICV5_GET_CLASS(dev); Error *migration_blocker =3D NULL; @@ -1618,6 +1814,12 @@ static void gicv5_realize(DeviceState *dev, Error **= errp) =20 gicv5_set_idregs(cs); gicv5_common_init_irqs_and_mmio(cs, gicv5_set_spi, config_frame_ops); + + for (int i =3D 0; i < NUM_GICV5_DOMAINS; i++) { + if (gicv5_domain_implemented(cs, i)) { + s->hppi[i] =3D g_new0(GICv5PendingIrq, cs->num_cpus); + } + } } =20 static void gicv5_init(Object *obj) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 4c55af2780..6475ba5959 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -242,6 +242,8 @@ gicv5_set_handling(const char *domain, const char *type= , bool virtual, uint32_t 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 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" =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 fb13de0d01..b8baf003ad 100644 --- a/include/hw/intc/arm_gicv5.h +++ b/include/hw/intc/arm_gicv5.h @@ -37,6 +37,9 @@ struct GICv5 { =20 /* This is the info from IRS_IST_BASER and IRS_IST_CFGR */ GICv5ISTConfig phys_lpi_config[NUM_GICV5_DOMAINS]; + + /* We cache the HPPI for each CPU for each domain here */ + GICv5PendingIrq *hppi[NUM_GICV5_DOMAINS]; }; =20 struct GICv5Class { diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index 136b6339ee..60c470b84c 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -151,4 +151,28 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, ui= nt32_t iaffid, uint64_t gicv5_request_config(GICv5Common *cs, uint32_t id, GICv5Domain do= main, GICv5IntType type, bool virtual); =20 +/** + * gicv5_forward_interrupt + * @cpu: CPU interface to forward interrupt to + * @domain: domain this interrupt is for + * + * Tell the CPU interface that the highest priority pending interrupt + * that the IRS has available for it has changed. This is the + * equivalent of the stream protocol's Forward packet, and also of its + * Recall packet. + * + * The stream protocol makes this asynchronous, allowing two Forward + * packets to be in flight and requiring an acknowledge, because the + * cpuif might be about to activate the previous forwarded interrupt + * while we are trying to tell it about a new one. But for QEMU we + * hold the BQL, so we know the vcpu might be executing guest code but + * it cannot be in the middle of changing cpuif state. So we can just + * synchronously tell it that a new HPPI exists (which might cause it + * to assert IRQ or FIQ to itself); this works as if the cpuif gave us + * a Release for the old HPPI. The cpuif will ask the IRS for the + * HPPI info via a function call, so we do not need to pass it across + * here. + */ +void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain); + #endif diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 80bb1cd391..e6f21d53b6 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -157,6 +157,15 @@ static void gic_recalc_ppi_hppi(CPUARMState *env) } } =20 +void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain) +{ + /* + * For now, we do nothing. Later we will recalculate the overall + * HPPI by combining the IRS HPPI with the PPI HPPI, and possibly + * signal IRQ/FIQ. + */ +} + static void gic_cddis_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169352; cv=none; d=zohomail.com; s=zohoarc; b=TkFCKc5eDlUraRp+oY7yfXLOog7lu913Z1/Bvwb6YYYV6VO8SHWb237RAZ7br2X9lwoV93k1RWJiuqXQuxnVI8g9i0oKTfr7Yfq6LUghdIxoGvyT/g70jnzycQheJ+3u8p7jhwSMFbqbZXN0MbtqHbyYpq8mK7A+j/45zlnZiFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169352; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=/LAMedYRFDy6rCDw1/38CGkQbibECB3iBhdeGcNo77s=; b=ArQVeNRCuC0c+vI1BXyE8leOu3koZnavHtao/YlZ6bRAPo5z1tg2qwoM/vss4OMa1AZK+1bkwBSpvXvaFiqA4pJrFjTFkXRHdGClkL4wFKYcALwPi2P7mqgPs9nXu9QTIdi1iMgK/6aQI8FKKV9K8Uzs9rgZdhQBqogBr7545S4= 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 1778169352370197.42228130907563; Thu, 7 May 2026 08:55:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11p-0004pm-B2; Thu, 07 May 2026 11:52: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 1wL11m-0004YT-SF for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:42 -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 1wL11k-0003ye-EJ for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:42 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-488af9fdaa7so6672655e9.1 for ; Thu, 07 May 2026 08:52:39 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169159; x=1778773959; 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; bh=/LAMedYRFDy6rCDw1/38CGkQbibECB3iBhdeGcNo77s=; b=JHb15rl2Zl8E69QHInD1o/Ewk+kQ+Lf5n7o5tpRdXOV3Y1ILszqnC//D5RPZCF8oPb iXP+1fcdQ+M8TdieXYj4NxSeaTrcv7iF9Zd6s/lQSWp6RbCBQZQvQOQdQFvH3v9ss2PQ OpV3bbmvWV5GPdJy+Bly+3tuGVwqc8GguuSvqPv6q0omZAbvx1J0rZbCl5z1XsGZlbNw tcNmubr7oPght/pHFC3e1Fvy/3M9OGchmUL5IhkpPJKECtxB+nrx0SziQXUNqmxv8+9w wNZ2hV4pJ7ny0FfLdIekbG3XhLVotEnjaxr+3MH88GLxWBmhCCo3uBOUDgWhmnMvXxbt uP+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169159; x=1778773959; 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; bh=/LAMedYRFDy6rCDw1/38CGkQbibECB3iBhdeGcNo77s=; b=k/3h2X44pz3RZH6Y9tWyy0/WwXMNzjx9h8EBKN/yyRIbCpJ37HLyiO7VxRKWTZwInd UXJppzoD7fpGndmox9y5Na6mHtcydCFlNzkv6R9tcSmd4s+/tD4+eN4DyOwXc5TGvoM4 wW/snLq3lhHktoIgIDYPksVYSzg2qN2Mm8KCjDPv1cEuPJOdteUUMOgC/+gg1x/g1/DW RVnNLXsOZ5DXPZTFOoH2DEJ148dZwTYeNGD/7A2fKeaaluAME9KkeaDYp+8DqI/WE10Q vFT5KE/TsfgtbnyP2u7ny8+dqLK8t8EiXXDU0mmzKid8OJkg81pYBZqeK1TP0GSdpL3A 5GMQ== X-Gm-Message-State: AOJu0Ywl/wI/l2+BOwp5rPwd2ggHLsiwtr8174+X4qrMykY1JtV6elOV jn8XUktsyCykLUgQsz/V/0cjqT8Lbrnmv6BVW5HcOzDioIK0hFNne7qBbWjAH+9qybYT1Xsi0LV 7gQ8J X-Gm-Gg: AeBDieunyfTOa4iWi54UnCYsfvRhB99ORqWjnKm6zXRvy0O7XoRt7KGgLvNwt6PcG76 /dnYYPR8lKWaejjDXm1+iswyyEFv6q71xz98z2pzdUVGBQ0U+pozKKMKav0SPPstzvrdgTwzJ1C nt5uzd2r0TseblBBlIArU3G5k5ccxLIVun41nBcLgUYp+w12qNXTu+KfFBX1i+4eAvixokWeGmA GVP3hJ2YZr8dOTr0MIjOPyo3F8iaT4yTbXSsZ6VKhW1u8NAqo5WX1F+o+BwLNY/SG6pIkXZKTwk LlFWk0HpBMgdYPJjmIRF00XI9j1EwUa7KC6dN5iIe35bA1QEbjYPEOinjuD03bR1fZN6PFDJA9y SZVYmK6BCezR2/BM752aTJWj590YC3pRSSzd28rvdpZNWAppIX6P8iKDwEGPGLnyBhLNb/u4gzg cNrde4MTekp4IT4IP+AZAwrFACRlno+zYPpHKblAfNeiZhe25GMUgKJ4QCU3o4Z2jqulXJOIz8R p8kAxtFVSCOG8QJ X-Received: by 2002:a05:600c:a10d:b0:487:12c:e7e1 with SMTP id 5b1f17b1804b1-48e51e1f013mr107824275e9.11.1778169158380; Thu, 07 May 2026 08:52:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 44/67] target/arm: GICv5 cpuif: Implement ICC_CR0_EL1 Date: Thu, 7 May 2026 16:51:31 +0100 Message-ID: <20260507155154.1886557-45-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169354392154100 Content-Type: text/plain; charset="utf-8" Implement ICC_CR0_EL1, which is the main control register. This is banked between interrupt domains in the same way as ICC_APR_*. The GICv5 spec assumes that typically there will need to be a hardware handshake between the CPU and the IRS, which is kicked off by guest software setting a LINK bit in this register to bring the link between the two online. However it is permitted to have an implementation where the link is permanently up. We take advantage of this, so our LINK and LINK_IDLE bits are read-only and always 1. This means the only interesting bit in this register for us is the main enable bit: when disabled for a domain, the cpuif considers that there is never an available highest priority interrupt. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-45-peter.maydell@linaro.org --- target/arm/cpu.h | 1 + target/arm/tcg/gicv5-cpuif.c | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index f27f2e6bcc..afe7f71a04 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -604,6 +604,7 @@ typedef struct CPUArchState { /* GICv5 CPU interface data */ uint64_t icc_icsr_el1; uint64_t icc_apr[NUM_GICV5_DOMAINS]; + uint64_t icc_cr0[NUM_GICV5_DOMAINS]; /* Most PPI registers have 1 bit per PPI, so 64 PPIs to a register= */ uint64_t ppi_active[GICV5_NUM_PPIS / 64]; uint64_t ppi_hm[GICV5_NUM_PPIS / 64]; diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index e6f21d53b6..23d51bd798 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -43,6 +43,12 @@ FIELD(ICC_IDR0_EL1, ID_BITS, 0, 4) FIELD(ICC_IDR0_EL1, PRI_BITS, 4, 4) FIELD(ICC_IDR0_EL1, GCIE_LEGACY, 8, 4) =20 +FIELD(ICC_CR0, EN, 0, 1) +FIELD(ICC_CR0, LINK, 1, 1) +FIELD(ICC_CR0, LINK_IDLE, 2, 1) +FIELD(ICC_CR0, IPPT, 32, 6) +FIELD(ICC_CR0, PID, 38, 1) + /* * We implement 24 bits of interrupt ID, the mandated 5 bits of priority, * and no legacy GICv3.3 vcpu interface (yet) @@ -346,6 +352,37 @@ static uint64_t gic_icc_hapr_el1_read(CPUARMState *env= , const ARMCPRegInfo *ri) return gic_running_prio(env, gicv5_current_phys_domain(env)); } =20 +/* 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]; +} + +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; + + env->gicv5_cpuif.icc_cr0[domain] =3D value; +} + +static void gic_icc_cr0_el1_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + /* The link is always connected so we reset with LINK and LINK_IDLE se= t */ + for (int i =3D 0; i < ARRAY_SIZE(env->gicv5_cpuif.icc_cr0); i++) { + env->gicv5_cpuif.icc_cr0[i] =3D + R_ICC_CR0_LINK_MASK | R_ICC_CR0_LINK_IDLE_MASK; + } +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -504,6 +541,13 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .writefn =3D gic_icc_apr_el1_write, .resetfn =3D gic_icc_apr_el1_reset, }, + { .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, + .readfn =3D gic_icc_cr0_el1_read, + .writefn =3D gic_icc_cr0_el1_write, + .resetfn =3D gic_icc_cr0_el1_reset, + }, { .name =3D "ICC_HAPR_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 1, .crn =3D 12, .crm =3D 0, .opc2 =3D 3, .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169495; cv=none; d=zohomail.com; s=zohoarc; b=jtambtfv0+S4u40Nb2WaFpm8JmaF6Nv8GgX0tXfxCy85n3UwmEzjQGO5uAuQnFU2Y6a6Tj8hfF0VuwnDa2gx4FM4leNs5CPfDUP21tXkb2T9USBujKxrJkSA0MvLu0DmvqCRjjFT/0Ypc6u930VomiVjnRmbrZ7ytxaySIeBSdI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169495; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=kWpQNIQ4Q8qcCBMqzQLlRZfn9wSrTR/FaBxSyEWVI9s=; b=FtyBddbTexbuz/ZEG+M3wM5P/qzkR9m7d8o9+zwn5fsmsYHYHUvPbWs/Hq7GGg7S2FeKjti/Io3gqkQoLew+dhJKGai9rchnLrsFBY15JArttX+f+XHiseUNrKsvVPS66cDVkHbdBPzHDB/WzLi3PbTwpTruaFbiXipiAdxGJpA= 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 1778169495496282.32765419684495; Thu, 7 May 2026 08:58:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11o-0004mb-MV; Thu, 07 May 2026 11:52: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 1wL11n-0004ZW-0t for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:43 -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 1wL11k-0003yl-SU for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:42 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-488b3f8fa2bso21634665e9.1 for ; Thu, 07 May 2026 08:52:40 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169159; x=1778773959; 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; bh=kWpQNIQ4Q8qcCBMqzQLlRZfn9wSrTR/FaBxSyEWVI9s=; b=WXZRmv0ha3e7cL69UkWNRwiEZKT1I5OA4SdBfeC2N8z+UthPnAC00iYrAYm/gWQfnK l+U1SbYFzCPrAYMto1D6by1slT225F197XYNTFECUyV/WGRkEU6aVa0e5RnU3ChzLHkR ZpCLa3KXrjaTE9UEsb2AwdQSZcuaz6Zi3KCojFFZ9hRmA+D7diNvoSTOIeifgIN/W6M/ 8AqOjib4axSW1NQ6Uea3ica/oto/IAxLWTWuAO9RuEsuDNdeOA8eGxi1E1JM3vrKfkmc O/wk5q7p6nTAI1haVGc/qVGz1CqT0F56QCq9Ke7W3F8kCMpJyHFvtkuEogf2fq8GEqU3 PSXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169159; x=1778773959; 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; bh=kWpQNIQ4Q8qcCBMqzQLlRZfn9wSrTR/FaBxSyEWVI9s=; b=BVV2xI4+VWYKkn2bpOkoWFgmn2iCEy/o9R0mq/5s2/XeQmB/FDrSUglkMN9Z5pfR9v YKgljzPS/ndyVBCGy7g5e1RGx/8jWYpQWUTV4Lq3VHyaMBkCyumb8BXBhB/S5QSyAxjR nxszvoSzYK9+O54RVujcd2S5zrTievVt1tThz7hGHBuY6ji5SKkXT2yeefLHGy5794A7 LsBnkPVwfZbrObfmVqPYUy8qiCPgPIpx10u5+AdUNICliXQz2OWpVafpI1eenfgO4Dg/ AlSrfxxEc4pnx8tZzZWkIGXyiWUDVFh/vMZVIkRbWDA8JVHuo5QCH0SBaHiXQwZZDKFK Zp7A== X-Gm-Message-State: AOJu0YxuZFXfTUrNQFe203DxNUzw4wGqwxXcZL86t/OFdZi61gCpyYVU BKfUaHV3uorznAYZR+DpDX+zoEisd3uXu4/tQUg8PEfiYg/OSa52kBHc3+5kvi2AFCMvSAoQCi1 dn+RT X-Gm-Gg: AeBDievqIHVnVHQaUPukVgVLbzby8WMpJhO2Vdv/tBu4IlpMHSAIL1VHrZOH97ypTou e48iTPd6GdwIw1vjQxPcG/jX3pbIhNTuiFIUJ+xytTvZtDJQLvgbSAP2G5RNdL6gAg4yEGqiOxz RUzZKs1qEX5FMZC2JrqW7+FW09BiVx8JtLJoMsAqKHSRM5nYcYMbJRWtigfrWYfGSI5LmBtnJDl +poBX96imke2HRHEFPGO8uvFwOsMT3HL80TF0I6OZ3uZ29arbflU2FfuAIGd6oqB9qfmVliNMN4 yqmnNzpHpFl7TNTBenATerokbyEmaL11K0MJNxfZ6XmbqBIMu2cxzg5UqolMqwHFh6TOpN+3DeS wRD6NI/t0lyAwCCI70FjhKFs2AZtdu0BnXku8XymAxC+CwgXVXvvfeA5s4eznwnQzgtaYJg1l6q pvXOR80eQsqGTElyHNsWOmnFUZ4Crv7TiljbsKLz45DTFgx6dP89XdDfphUlNlvNWYkF3Il8vkI K/YM9Zc3VQS4Nak0s3Nhqo71WTJQYQ= X-Received: by 2002:a05:600c:4e56:b0:489:1abb:5559 with SMTP id 5b1f17b1804b1-48e5dfd6508mr52806055e9.5.1778169159208; Thu, 07 May 2026 08:52:39 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 45/67] target/arm: GICv5 cpuif: Implement ICC_PCR_EL1 Date: Thu, 7 May 2026 16:51:32 +0100 Message-ID: <20260507155154.1886557-46-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169496709154100 Content-Type: text/plain; charset="utf-8" Implement the ICC_PCR_* registers. These hold the physical priority mask for each interrupt domain -- an HPPI is only sufficiently high priority to preempt if it is higher priority than this mask value. Here we just implement the access to this data. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-46-peter.maydell@linaro.org --- target/arm/cpu.h | 1 + target/arm/tcg/gicv5-cpuif.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index afe7f71a04..9d2c27f7df 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -605,6 +605,7 @@ typedef struct CPUArchState { uint64_t icc_icsr_el1; uint64_t icc_apr[NUM_GICV5_DOMAINS]; uint64_t icc_cr0[NUM_GICV5_DOMAINS]; + uint64_t icc_pcr[NUM_GICV5_DOMAINS]; /* Most PPI registers have 1 bit per PPI, so 64 PPIs to a register= */ uint64_t ppi_active[GICV5_NUM_PPIS / 64]; uint64_t ppi_hm[GICV5_NUM_PPIS / 64]; diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 23d51bd798..07ebe3a816 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -49,6 +49,8 @@ FIELD(ICC_CR0, LINK_IDLE, 2, 1) FIELD(ICC_CR0, IPPT, 32, 6) FIELD(ICC_CR0, PID, 38, 1) =20 +FIELD(ICC_PCR, PRIORITY, 0, 5) + /* * We implement 24 bits of interrupt ID, the mandated 5 bits of priority, * and no legacy GICv3.3 vcpu interface (yet) @@ -383,6 +385,28 @@ static void gic_icc_cr0_el1_reset(CPUARMState *env, co= nst 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]; +} + +static void gic_icc_pcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + GICv5Domain domain =3D gicv5_logical_domain(env); + + value &=3D R_ICC_PCR_PRIORITY_MASK; + env->gicv5_cpuif.icc_pcr[domain] =3D value; +} + +static void gic_icc_pcr_el1_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + for (int i =3D 0; i < ARRAY_SIZE(env->gicv5_cpuif.icc_pcr); i++) { + env->gicv5_cpuif.icc_pcr[i] =3D 0; + } +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -548,6 +572,13 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .writefn =3D gic_icc_cr0_el1_write, .resetfn =3D gic_icc_cr0_el1_reset, }, + { .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, + .readfn =3D gic_icc_pcr_el1_read, + .writefn =3D gic_icc_pcr_el1_write, + .resetfn =3D gic_icc_pcr_el1_reset, + }, { .name =3D "ICC_HAPR_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 1, .crn =3D 12, .crm =3D 0, .opc2 =3D 3, .access =3D PL1_R, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169251; cv=none; d=zohomail.com; s=zohoarc; b=j2so6H5h37VpqPrel/8PkyepppqjcVyrgmIZ/fI1t4SySmYQdpo6wi9TqPVg548kQ1S4wxCnx3ICx6SSgIFk3kP3Kccpv+F1d4a0dPYzqKzR3Tyx1pAH0Dc6cC1BIwukyWIGaHt/L7rUAGcN6TBT+AL+iQl8j3lFqEhJ6y6o/kY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169251; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=0uKJt+OphwE2k5DECXia92MWndnWedOH3NjDI4wh+v0=; b=DXZz4hanIu/cCUeu1ytU+8THm8Rf9ut5Cc7xdNMc4DEsAtZy2wlTVQKYmeacdeL8hfk3cWqhuZZhQErsBXiaKKSB//eObOHoAfNC6s85En/fa6SUYt1pMr6SEeklI4RkkrfN4nQr/es+dOdXUjxrss2waqDY4QfiE/lUR5y5XJk= 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 1778169251562208.1780919246495; Thu, 7 May 2026 08: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 1wL11w-0005L2-P9; Thu, 07 May 2026 11:52: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 1wL11t-0005Al-KZ for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:49 -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 1wL11r-00040W-Ji for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:49 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4891d7164ddso6753895e9.3 for ; Thu, 07 May 2026 08:52:47 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169166; x=1778773966; 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; bh=0uKJt+OphwE2k5DECXia92MWndnWedOH3NjDI4wh+v0=; b=lhqBi9PcYW8j4jhcQ7RsNwQ4NVWaj4+WrRJqA0BICbKhU7ze9PgFdwnXb/suHSkmY0 YQP1h68Srk8tMcdUe2k0SmBsb2HOGeqtrG4mW8byTZIlFGO/isJvMNxKK/uhp3y6yvWg Z2RSNGIv2Aj6DYGySnOBC/luYLBRmhSGAqK7VGYryCoQCZOKz0sSxQ3vM3tS16AAovtv 3gFSV8oBlR7tIj7xjo5IOGdR6NEQqeQSA+FozM0eMsg1sEnJZhWsplwk2d3uvR2dEQ+d phzl0sgR24z4WvJwUoX+KdBnfPh3ms1hL3CIuZZyJ7U+6rgHlKTQwGvnUwIsOw8U5dBv znYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169166; x=1778773966; 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; bh=0uKJt+OphwE2k5DECXia92MWndnWedOH3NjDI4wh+v0=; b=fkAUcMJkaVkYI07gOjeDTmqvqJWLYfl8PN3eP/8p9qu7s6ePKHSTIS5yxQ8T+4EEms yAVFb3bhLHcUzAI9pGbh162DjbsTCV+pywNUUbE9fcg32gKMHKVMXeG1JHtky4oEt0ft LBQxyMTwnnXNoyf+Vghhi+iDvLoLUstgFlGpHWv0h9JV/2JVTJGST5KbY4cY88Lri3w3 o16a8oW8NPt226I/jkw84OKtRPA8DxGgubd/ww0tbSswPCyO18T21oPzgaBXgqVPTWPd Y3TqPMV0cNCtgMgz0PmlqWgdY/V/WNzHOQMy+8ocrQ6C59mrjuBjGcCKBP4KOR9aiLVy 2ywg== X-Gm-Message-State: AOJu0YxPD8eCCBbyEpOs/wCM+RIhkTz6cnRrqmK9HARHqFwMQEo8bda4 LlJv3p8i3+v/RzgA7N5GadRRWxFTZF60RfLvBpSXCYCQMd3aYBXrhzfh2cEj7D45cb+17DbbMlZ L2Z+z X-Gm-Gg: AeBDiesJBDx3FbtQNhG2/lNbvJumfgTHPVFIsldMGoBvB51XlIjWahcXj52cKaM3l+B qRkBn6jvqoIxsRpIij3veo+Wi34EEA+GB+fVWxLeqvivwI7biND6aNYff3njsaMir6j8417/c1f KBBpHkO5eaBAFGufZaart3BYFjdWvnJTLUleodb5skToWSfN5zDysogUzCquBdF//xJXFlpxMqB jl88A580rIGq5JioH8SxKd5Brrjwdh5rvgr5Gzm0m0SVp7zMZ97iIL1cXfVwX3tZJFpeg7w1fd+ DIjptToyw0e99Pa/rE+XJ8B+6tXfcpwWmepiZRPdm+31yBne0CIMx0Q8oO5rzV+BV99orVyoWpH cf4Tdrd/R8SCsFtOPHoVAVI5W3C0g9afnJi9YZcDdK0+v6mj59E8l2wIuSomNNkjwPCASBAeNEv yF+Dj6aK3ywWYv2krtcOnx6bbM8+7xOaM+6n0lJ5DtRFfdriSjOHTD1GS/F3977UgKauyeeBgeO RS/Bf7899R7Gusg X-Received: by 2002:a05:600c:46d2:b0:485:364e:9328 with SMTP id 5b1f17b1804b1-48e51f32aebmr133265455e9.16.1778169161829; Thu, 07 May 2026 08:52:41 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 46/67] target/arm: GICv5 cpuif: Implement ICC_HPPIR_EL1 Date: Thu, 7 May 2026 16:51:33 +0100 Message-ID: <20260507155154.1886557-47-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169252851154100 Content-Type: text/plain; charset="utf-8" Implement ICC_HPPIR_EL1, which the guest can use to read the current highest priority pending interrupt. Like APR, PCR and CR0, this is banked, with the _EL1 register reading the answer for the current logical interrupt domain, and the _EL3 register reading the answer for the EL3 interrupt domain. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-47-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 10 +++++ include/hw/intc/arm_gicv5_stream.h | 13 +++++++ target/arm/tcg/gicv5-cpuif.c | 61 ++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 12cbf9c51e..605cf6fd6f 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -527,6 +527,16 @@ static void irs_recall_hppis(GICv5 *s, GICv5Domain dom= ain) } } =20 +GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5Domain domain, + uint32_t iaffid) +{ + GICv5 *s =3D ARM_GICV5(cs); + int cpuidx =3D irs_cpuidx_from_iaffid(cs, iaffid); + + assert(cpuidx >=3D 0); + return s->hppi[domain][cpuidx]; +} + static hwaddr l1_iste_addr(GICv5Common *cs, const GICv5ISTConfig *cfg, uint32_t id) { diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index 60c470b84c..cc1c7cc438 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -175,4 +175,17 @@ uint64_t gicv5_request_config(GICv5Common *cs, uint32_= t id, GICv5Domain domain, */ void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain); =20 +/** + * gicv5_get_hppi + * @cs: GIC IRS to query + * @domain: interrupt domain to act on + * @iaffid: IAFFID 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); + #endif diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 07ebe3a816..e7fe4f0fa1 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -51,6 +51,10 @@ FIELD(ICC_CR0, PID, 38, 1) =20 FIELD(ICC_PCR, PRIORITY, 0, 5) =20 +FIELD(ICC_HPPIR_EL1, ID, 0, 24) +FIELD(ICC_HPPIR_EL1, TYPE, 29, 3) +FIELD(ICC_HPPIR_EL1, HPPIV, 32, 1) + /* * We implement 24 bits of interrupt ID, the mandated 5 bits of priority, * and no legacy GICv3.3 vcpu interface (yet) @@ -114,6 +118,51 @@ static uint64_t gic_running_prio(CPUARMState *env, GIC= v5Domain domain) return hap < 32 ? hap : PRIO_IDLE; } =20 +static GICv5PendingIrq gic_hppi(CPUARMState *env, GICv5Domain domain) +{ + /* + * Return the current highest priority pending interrupt for the + * specified domain, if it has sufficient priority to preempt. The + * intid field of the return value will be in the format of the + * ICC_HPPIR register (and will be zero if and only if there is no + * interrupt that can preempt). + */ + + GICv5Common *gic =3D gicv5_get_gic(env); + GICv5PendingIrq best, irs_hppi; + + if (!(env->gicv5_cpuif.icc_cr0[domain] & R_ICC_CR0_EN_MASK)) { + /* If cpuif is disabled there is no HPPI */ + return (GICv5PendingIrq) { .intid =3D 0, .prio =3D PRIO_IDLE }; + } + + irs_hppi =3D gicv5_get_hppi(gic, domain, env->gicv5_iaffid); + + /* + * 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.ppi_hppi[domain].prio <=3D irs_hppi.prio) { + best =3D env->gicv5_cpuif.ppi_hppi[domain]; + } 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 > env->gicv5_cpuif.icc_pcr[domain] || + best.prio >=3D gic_running_prio(env, domain)) { + return (GICv5PendingIrq) { .intid =3D 0, .prio =3D PRIO_IDLE }; + } + best.intid |=3D R_ICC_HPPIR_EL1_HPPIV_MASK; + return best; +} + static void gic_recalc_ppi_hppi(CPUARMState *env) { /* @@ -407,6 +456,13 @@ 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); + return hppi.intid; +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -522,6 +578,11 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .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, + .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, --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169498; cv=none; d=zohomail.com; s=zohoarc; b=Ged7DY4YbHYGj728smNoo4/qOE2eljUJyX7WEeQtQ4zUYKa698r1XwM5+xUjNj7g6eSAcPtnU4BT+2sBOkNEON/hQY/hAnBpUrpAc5l6iZu8nF4Qfk1VjOwyQyZv4HL8vIAD3QFpMYHstc0FlqzB8ynSP1GVED0FWrkY7BXCrlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169498; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=GC/uWd3jRSbyTP7ymiXKyAkRj9xECMCtg5dzSRpnoFs=; b=n8uyE0+7uliOh+Zl+KEwK49Km4+huUln03q1TB9kHgKZsM/l3DMYmr0CkEEAL8q8lYsxjRBFXcMZhUCP0M7A7SfoPI6yhbzKp79PfiMMfrOzI2LZkJQgYRlFXNAD+FqjHIIIeOo3lNP6hDY73qfllIZqhPzRcfR+BeGEv63gLfA= 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 1778169498223558.5351174043267; Thu, 7 May 2026 08:58:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11t-00056w-0C; Thu, 07 May 2026 11:52:49 -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 1wL11q-0004uJ-CR for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:46 -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 1wL11o-0003zl-IW for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:46 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-44c4cc7c1cfso870127f8f.0 for ; Thu, 07 May 2026 08:52:44 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169163; x=1778773963; 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; bh=GC/uWd3jRSbyTP7ymiXKyAkRj9xECMCtg5dzSRpnoFs=; b=TL4a2Xdkan8oooW71cKNWqERZN9NQXoVSaoeUETVuyGdOKj60ZUWPnWeE8ceIflj6t Hp9E1G0gXkigFpOE59qYdthoT6bviAOpLKFCorcgm+D7dUHtlzh4zO1kxMpYu7TdirBw gijw9yEqmsmow1Wgy8XgLAalQPh7mLayD1jHnw0XGWzm9UayjQiUCsSvD1ATG/e84J+S wAIsfbMuYTMaC3/NCQyWsqf32JZ9hCojEF3FxauPHOX+upqpKYBZVC4EfRQdvhuwggKL aRozRYxOasPwkivY3ssFVWB3KaVxM6cDPB0zsyS64orWqEIyATADdqSmzovKh2p37KXb FL8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169163; x=1778773963; 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; bh=GC/uWd3jRSbyTP7ymiXKyAkRj9xECMCtg5dzSRpnoFs=; b=QNVgAQDnDm3jiRkbkgSL0PLE5xHTr3TxDbrsdPg7xWOhCjY9MrCnDodnvtCRMS3FJ8 vWr4FbeGKnFRbCb854zs/MWTH9pv+8mSNfneGp2PMzJcXnFsSV3wIfzz/j3mtTRjbOxU DfOf+nnCMz2T5msQeOI7jpSIEnSncWVNogJKZTs4xhrbUXhJYQz6qKcBgHFaC22iJ/hO 7xy7Q237e0mzEblEDtJ8AnLehbW/uqbFLb/+lk1crAfpDCV+1oOzlWv2Vk9+vggfjfSD u7ETx6Zeu4tdUpT9H0RVqRDYgKS1MS7MlUPaS4xgv3vBP/esTnhII3af/91oOaG1qBdd dlVg== X-Gm-Message-State: AOJu0Yw4YD6booPPSHHisPYvsBqeSXk0afQD1FMYUx0Q0l+QpuuCIQjJ fgCtzCSNj2ygSZuVM6KOEyk6TlozyUXXf+RjJROagkBwwup1XXKpZT6Y10lXNtwdtj9Q/Iz3/gR PtXBG X-Gm-Gg: AeBDietXhIZeogXUasfIeZz8Hlywckiu3pJdnIowpEwPQ+1FtY58fAQ7ylHqqSxIkK1 7P3Bm+sipOGLIaQG4PjE+YleDbFPKeXfscRKHNFLW5yXZEZfN5CF4gm8VBMAdGyh0pE5tDniQIM iOosewDWrq+ciLyVFhduV+26HQrpb9fH6jxfNwNUQcpA0mZO2WGFYAfljxRpUHHffiyp7lH481Y 74uOLnZNqc/HE8ZuWD0SPH4BieWK1qabxet/Q5HIlT9JgfAgFpa25uPTII4CSGbFe/m9CLpXSP7 g5ORM0KSL4QWQT8i53O/qlXHMJMdojfbz8D2LGb9zYf0Lwwq9HaTYvdMvcBkFI1Ed2p8wuYPK5c wG8tftG6ywwG+tKVmGCxDDBj5DlTHgEXFFLtNoSbfTUb3yOW1jIcu1Pj9Cz2/8+pybcukbw7+rr uuIGz/68JPfOOgQJ84xG2FFjlUs3QKTdOYPP0xbv6SQIehWcUkleEQmnLLBd/EEZ7cqPG4aZebT WRa650In9XMLKnKIaYJTv782RaOTZY= X-Received: by 2002:a05:600c:3055:b0:488:ac01:72de with SMTP id 5b1f17b1804b1-48e51e0bc2fmr84299555e9.5.1778169162767; Thu, 07 May 2026 08:52:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 47/67] hw/intc/arm_gicv5: Implement Activate command Date: Thu, 7 May 2026 16:51:34 +0100 Message-ID: <20260507155154.1886557-48-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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=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: 1778169498980158500 Content-Type: text/plain; charset="utf-8" Implement the equivalent of the GICv5 stream protocol's Activate command, which lets the cpuif tell the IRS to move its current highest priority pending interrupt into the Active state, and to clear the Pending state for an Edge handling mode interrupt. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-48-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 58 ++++++++++++++++++++++++++++++ hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_stream.h | 23 ++++++++++++ 3 files changed, 82 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 605cf6fd6f..942f3eba2e 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1095,6 +1095,64 @@ uint64_t gicv5_request_config(GICv5Common *cs, uint3= 2_t id, GICv5Domain domain, } } =20 +void gicv5_activate(GICv5Common *cs, uint32_t id, GICv5Domain domain, + GICv5IntType type, bool virtual) +{ + GICv5 *s =3D ARM_GICV5(cs); + uint32_t iaffid; + + trace_gicv5_activate(domain_name[domain], inttype_name(type), virtual,= id); + + if (virtual) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_activate: tried to " + "activate a virtual interrupt\n"); + 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); + + if (!l2_iste_p) { + 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: + { + GICv5SPIState *spi =3D gicv5_spi_state(cs, id, domain); + + if (!spi) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_activate: tried to " + "activate unreachable SPI %d\n", id); + return; + } + + spi->active =3D true; + if (spi->hm =3D=3D GICV5_EDGE) { + spi->pending =3D false; + } + iaffid =3D spi->iaffid; + break; + } + default: + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_activate: tried to " + "activate bad interrupt type %d\n", type); + return; + } + + irs_recalc_hppi(s, domain, iaffid); +} + static void irs_map_l2_istr_write(GICv5 *s, GICv5Domain domain, uint64_t v= alue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 6475ba5959..636c598970 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -241,6 +241,7 @@ gicv5_set_pending(const char *domain, const char *type,= bool virtual, uint32_t i 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 +gicv5_activate(const char *domain, const char *type, bool virtual, uint32_= t id) "GICv5 IRS Activate %s %s virtual:%d ID %u" 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" diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index cc1c7cc438..7ac24f0f09 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -151,6 +151,29 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, ui= nt32_t iaffid, uint64_t gicv5_request_config(GICv5Common *cs, uint32_t id, GICv5Domain do= main, GICv5IntType type, bool virtual); =20 +/** + * gicv5_activate + * @cs: GIC IRS to send command to + * @id: interrupt ID + * @domain: interrupt domain to act on + * @type: interrupt type (LPI or SPI) + * @virtual: true if this is a virtual interrupt + * + * Activate the IRS's highest priority pending interrupt; matches the + * stream interface's Activate command. + * + * In the stream interface, the command has only the domain and + * virtual fields, because both the IRS and the CPUIF keep track of + * the IRS's current HPPI. In QEMU, we also have arguments here for + * @id and @type which are telling the IRS something that in hardware + * it already knows. This is because we have them to hand in the cpuif + * code, and it means we don't need to pass in an iaffid argument to + * tell the IRS which CPU we are so it can find the right element in + * its hppi[][] array. + */ +void gicv5_activate(GICv5Common *cs, uint32_t id, GICv5Domain domain, + GICv5IntType type, bool virtual); + /** * gicv5_forward_interrupt * @cpu: CPU interface to forward interrupt to --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169485; cv=none; d=zohomail.com; s=zohoarc; b=RocHh9LyDtdE5CkDnKHP53VzVlWpdpyARn2sfZ1mX6Ki+ONel32lyJpV8tL5TVwrRHWWDl4+hx4C8SZzdkrAhCqhFUA4Awo/ilxWMh7g06XzeTRL/FQbu5NXJoffJcz/1jAuyBMgQ0dr8zBf6PGmSoTxB/u86/6tWhklFla1H24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169485; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Xs/VyWB1wsEFra+dTiNs9oicQWO6xGZ5XUVh0iNByNg=; b=BdT5JwtfBxrKBz+MTPyoOmcIzDz3uXzVHxOkCAfZoyz9jFirIXnmLnXR8JQs2woS/RU9vsVgHt8ezJtKw2MeLDssd7r+5ELj4HGE1mOpg25WB7vz6YzISDkfD2uM+p2c4k6qOClJqCKMCE5wyUKfwCtfw0qK6upAZBjWF6WEp8s= 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 177816948540777.1989487801801; Thu, 7 May 2026 08:58:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11t-00059O-Dx; Thu, 07 May 2026 11:52:49 -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 1wL11r-0004xX-1G for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52: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 1wL11p-0003zv-4Y for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:46 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-488b3f8fa2bso21634945e9.1 for ; Thu, 07 May 2026 08:52:44 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169164; x=1778773964; 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; bh=Xs/VyWB1wsEFra+dTiNs9oicQWO6xGZ5XUVh0iNByNg=; b=g8aZXcxC2TAoKEawpJxKY0RAGrrpb3SOrKVqMrCr1uAc38FG9VTKrIDSlShWINFE24 PddnEeG78m41T80EqYtIaVza7R7mo2+NjHAQvbafAMeA14u2hLycZkWkGX1f2rckt8UH EMnTFfLja82LW6xR/0i9CE22FLC0GXw/AR9IyPsOV3Y6MxFo0XBdP5UaV3866WmV3Aiq tumq6eUt536kbkXwF3GJ0/YBV6KLhMoRZlkM8KMmQMWa2NNx5dVLG2Ttl1g4DW8Qh9zX /7O2Nvi2Qno6adR0pMV8RHVqT37n82M2wV8w19hpIKOPHOb2hhWEY0p21ybH0n6afnv4 J7Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169164; x=1778773964; 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; bh=Xs/VyWB1wsEFra+dTiNs9oicQWO6xGZ5XUVh0iNByNg=; b=N/S9iOsbjjQuJR/soS6/qbsL4X34cUSRBt6IPPj1Z96WHaYCu64uo6pq5vGt6LNWSS 2Jypgv8SeMi8H72imU6nHvID7cR0UfPrVmb0FZDkPVkrsGTh+RE3GI7rOsBQaCXfUiGI /okxotDT95SELRJKDNaO/lXFGjEHvFNyZ1KX4i9bCuKKh0v8Chrfw+VbhFcw9LL/2StU KWheOndWZ58tyhQZJP3jEV3pW0GuRGSTN+KjHFM0B2IhFO96Mf9xozwszV2u6K7puZJL eElnmFEwmC7txZ4EdqpmeU1Kb11eBYbBrGSe1C2yvHHKfOvQU9lZ3xa9qX/zhw5WhsbU 83HQ== X-Gm-Message-State: AOJu0YwWqUHqwJmLGx3qI0Oa9wlwFg6p4Y0i0LDmhJ8C6hCA3pkhmedN qHTOnouJYjVilNdzE+pNe1G2U7tYsxRMYKEDA80tgiSQpAk7TuOnXkXe2Bkph2FEajRYlhVVpYn 8MbWA X-Gm-Gg: AeBDiet8sq13ssHITDPu8eOEU7zbrUpOZSqck7PHSJUsUG83KCYwtCvMAYGEe8VsU6e uP/qN90kvKzkwKjpSjo4oiloCOOM4BDOUab3x+tEpj9SRBhK0RWKDQKIwtXiKrPTqCHSH1kRtsN t29HlF1xwARCgRNOWH176otjaYBnZZZjEpQkbuDZ4t5d5FHa9FPNDcIxtCR8tYiZxG56WkSsoxw jjXZCIgzFLcN/W/6tzVpBbfQa7ax0xFiLE5VwIJ6SGJ1t3aHj69db2bTvdQwyeiZjPXkMeb1aL+ AWgiWtfr9x8u8KjTQAyt9W/KOHRqbNfg+W+z1i+IGb/sfsYcsdcjsVq9FPGi7XtGrVsr1YG1Pp6 IMXJ2CBqLzNIhrdfDjJaMM1qeRHvP/t1EzHL1GcfVG7BsTmiBNv3qRLTdPBuM5sytlBOQhRLBjP 1B44igVM4Tkth6IYOP1tGQKvsH9TLBTXr/xjduJCuEyXKPCXPPjL3BAWlnR+X6tPRdh22OyPrDB 1pPzwGs1tEaZbkjrv5fthU9HiDOmAs= X-Received: by 2002:a05:600c:a10a:b0:48d:50a:6ef4 with SMTP id 5b1f17b1804b1-48e5dffab24mr40395615e9.11.1778169163627; Thu, 07 May 2026 08:52:43 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 48/67] target/arm: GICv5 cpuif: Implement GICR CDIA command Date: Thu, 7 May 2026 16:51:35 +0100 Message-ID: <20260507155154.1886557-49-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169486810154100 Content-Type: text/plain; charset="utf-8" The GICR CDIA system instruction is what the guest uses to acknowledge the highest priority pending interrupt. It returns a value corresponding to the HPPI for the current physical interrupt domain, if any, and moves that interrupt to being Active. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-49-peter.maydell@linaro.org --- target/arm/tcg/gicv5-cpuif.c | 101 +++++++++++++++++++++++++++++++++++ target/arm/tcg/trace-events | 2 + 2 files changed, 103 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index e7fe4f0fa1..52abe175bb 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -39,6 +39,10 @@ FIELD(GIC_CDHM, HM, 32, 1) FIELD(GIC_CDRCFG, ID, 0, 24) FIELD(GIC_CDRCFG, TYPE, 29, 3) =20 +FIELD(GICR_CDIA, ID, 0, 24) +FIELD(GICR_CDIA, TYPE, 29, 3) +FIELD(GICR_CDIA, VALID, 32, 1) + FIELD(ICC_IDR0_EL1, ID_BITS, 0, 4) FIELD(ICC_IDR0_EL1, PRI_BITS, 4, 4) FIELD(ICC_IDR0_EL1, GCIE_LEGACY, 8, 4) @@ -463,6 +467,93 @@ static uint64_t gic_icc_hppir_el1_read(CPUARMState *en= v, const ARMCPRegInfo *ri) return hppi.intid; } =20 +static bool gic_hppi_is_nmi(CPUARMState *env, GICv5PendingIrq hppi, + GICv5Domain domain) +{ + /* + * For GICv5 an interrupt is an NMI if it is signaled with + * Superpriority and SCTLR_ELx.NMI for the current EL is 1. GICR + * CDIA/CDNMIA always work on the current interrupt domain, so we + * do not need to consider preemptive interrupts. This means that + * the interrupt has Superpriority if and only if it has priority 0. + */ + return hppi.prio =3D=3D 0 && arm_sctlr(env, arm_current_el(env)) & SCT= LR_NMI; +} + +static uint64_t gicr_cdia_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + /* Acknowledge HPPI in the current interrupt domain */ + GICv5Common *gic =3D gicv5_get_gic(env); + GICv5Domain domain =3D gicv5_current_phys_domain(env); + 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); + + bool cdnmia =3D ri->opc2 =3D=3D 1; + + if (!hppi.intid) { + /* No interrupt available to acknowledge */ + trace_gicv5_gicr_cdia_fail(domain, + "no available interrupt to acknowledge"= ); + return 0; + } + assert(hppi.prio !=3D PRIO_IDLE); + + 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, + cdnmia ? "CDNMIA but HPPI is not NMI" : + "CDIA but HPPI is NMI"); + return 0; + } + + trace_gicv5_gicr_cdia(domain, hppi.intid); + + /* + * The interrupt becomes Active. If the handling mode of the + * interrupt is Edge then we also clear the pending state. + */ + + /* + * Set the appropriate bit in the APR to track active priorities. + * We do this now so that when gic_recalc_ppi_hppi() or + * gicv5_activate() cause a re-evaluation of HPPIs they use the + * right (new) running priority. + */ + env->gicv5_cpuif.icc_apr[domain] |=3D (1 << hppi.prio); + switch (type) { + case GICV5_PPI: + { + uint32_t ppireg, ppibit; + + assert(id < GICV5_NUM_PPIS); + ppireg =3D id / 64; + ppibit =3D 1 << (id % 64); + + 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; + } + gic_recalc_ppi_hppi(env); + break; + } + case GICV5_LPI: + case GICV5_SPI: + /* + * Send an Activate command to the IRS, which, despite the + * 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); + break; + default: + g_assert_not_reached(); + } + + return hppi.intid | R_GICR_CDIA_VALID_MASK; +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -520,6 +611,16 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .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, + .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, + .readfn =3D gicr_cdia_read, + }, { .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, diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index 7dc5f781c5..13e15cfcfc 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -3,3 +3,5 @@ =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_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" --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169434; cv=none; d=zohomail.com; s=zohoarc; b=Gdsn19m4h/FjqX40wdlCkOJ5AiiNkd1zM++y1ZUJ0q79xMVOUYxypDe0FMsFGuOZNerRUY0rhzVty0SgHsuu3hYLJ1IeNM03T4I0b7nruuRoFcF5j9nBP4Z6o9OB667K+h6ywwOV7rtkgpj0ZoF2gAQXXYmq/ICO6mv6IpTa22w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169434; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=s4SA//SBEYf0uzY8+aoVUwQDVhHqm5NWkavOs4X9AHU=; b=Jf2riCmnAsfZzOT82xrmnptO/Nv5yNHsQmVSa2XEK+B6ytdXUKVDOZAduNNmPzFsn9BKOI1InDbNWyRbssiVlM0923HMf534GCiMmjgrcixOKYqQNdazDaDDjQ2qU1/jnpbMWy+ZlcpGBF4f0f3mDLMuBSxLf+EcPE2/BWbU4FI= 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 1778169434164482.5267690578137; Thu, 7 May 2026 08:57:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11t-00058N-Ap; Thu, 07 May 2026 11:52:49 -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 1wL11r-000528-Nm for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52: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 1wL11q-00040A-29 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:47 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4891c00e7aeso9362145e9.2 for ; Thu, 07 May 2026 08:52:45 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169165; x=1778773965; 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; bh=s4SA//SBEYf0uzY8+aoVUwQDVhHqm5NWkavOs4X9AHU=; b=zU16M9Z+bBXLLHoObCqa+kBxK7mCFNdni/qXBqsi+w0Tco9BIoVt9gkmOfMH3CTujP qAojjTY+kqo8ALf7HcQAZzAKqWz4lwfmAC2esMgAQcHm+avxQue4ipcDxNGW9jpCetqE k3cpfgTCy1RbuIMmdt3bGlu5fdSuqDvLzurgQNZJWSM3FFh1KJ7dhrcMP/0rKAmhJr+g T9brsy93MU0wnITxJvSUjizN2O0F947E2NzTbZ1TTPvRYUo1KbCvzkWIgWqGjxzj4901 DHcyK0lZtIIoVaSKpuSpQfSERbQgXEqdVe2DscVmsdA9ZC7/M8Po1mI18GHR7xEzDtrv Wkew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169165; x=1778773965; 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; bh=s4SA//SBEYf0uzY8+aoVUwQDVhHqm5NWkavOs4X9AHU=; b=HIAlA19S7WyfxbU74IrMfpO/fNjF0Zp2ttEPHLeeaF7ipXxIKdIYBDaIGqKeFFCnA+ ICjGlt6awVwj903Joa0eTu1CZyh4fkdVAwlackJZ0mOZ33XxQ6hvBTwIfuALoBrBwa7M owyrC4M3pU0+eY/pY2YvpuCnLY7ThhaVlXok8U/b73g3IndIvAAdD2+rAnuF1+L9Dfn9 kdqAeqDryYgofpPQUBp/e6j3oQEBWO53pyTFJBYiReLNRNfHBFSNj1EoAH/AqRV+ZIjx 5XI6OPVye67WcZ6u8sF9ynMj4HcrfzIdrGqxyQ5duLtfYJ7hVssq1j7FnzCV5ytaK7Vj R+Fg== X-Gm-Message-State: AOJu0YwsVtwi5VxcgtbX3APAayLt1l4FJ5K5Hw0nwYRT4a7QUuQGwIeH 7ARCGRP4HYTd5AeMgyAsghuXB1FhVfO58sk+TR3tI4bFQNUosP9ORYWqUdYSpuYcrTl8Yvb1Br+ /SlbN X-Gm-Gg: AeBDietGiYHGHZaPt4yMlpZfNtjzgzDN7r5LuuUaaH6SQqbRGONfP72nlP7g3QV0mvM /N9IeKTpVjrN6ZxDnE0wA/koOifUrZSkzmNLxivJqbBNHU1wDjYxdo1meWuATmGvOTrQIX6GUXG HQ8PMrq+V9o8RKSJeoJ5L2EMP8CnwY5uhpEEziulKo5j0B+gyjWybxGrmpv6BuBdX1Zww0yUfnS b0cVN9y7Eb/9DnVcnux0zcsdgmIZ/Bdf0SH7VJKExr69+GfK5ECeJ47mlzJxFvppGh9/9RZAPw7 itgtz5UXPZUOmcN66TpsBCzswwDUl42bmRlHbVxB55HjwwXq/6+yoDN5uZ5N08uS4ySgn+i/HMl kEXhuA56UKPzsBgdCbP5W+HWIwBd2Cq12tiJvtGQYlUZlBDxEmNAitQMAD/Lb5pDTljFSBrCiC0 bNG7oYNUemAtbNVMajMLjDAap8GcImHysKRXV2/kqyDUQAfgWqqCVCY0zNIGUZtzGrQXwE+BVdF SzYUuI040pevbgWIRUbvCEl1HrDbOaFD/ZnoPzlMg== X-Received: by 2002:a05:600c:a30b:b0:489:1c1f:35f9 with SMTP id 5b1f17b1804b1-48e51e1773bmr103996645e9.9.1778169164471; Thu, 07 May 2026 08:52:44 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 49/67] target/arm: GICv5 cpuif: Implement GIC CDEOI Date: Thu, 7 May 2026 16:51:36 +0100 Message-ID: <20260507155154.1886557-50-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169435673154100 Content-Type: text/plain; charset="utf-8" Implement the GIC CDEOI instruction, which performs a "priority drop", clearing the highest set bit in the APR register. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-50-peter.maydell@linaro.org --- target/arm/tcg/gicv5-cpuif.c | 21 +++++++++++++++++++++ target/arm/tcg/trace-events | 1 + 2 files changed, 22 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 52abe175bb..5e613362bc 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -554,6 +554,22 @@ static uint64_t gicr_cdia_read(CPUARMState *env, const= ARMCPRegInfo *ri) return hppi.intid | R_GICR_CDIA_VALID_MASK; } =20 +static void gic_cdeoi_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* + * 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); + 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; +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -606,6 +622,11 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .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, + .writefn =3D gic_cdeoi_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, diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index 13e15cfcfc..fcb3106a96 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -5,3 +5,4 @@ gicv5_recalc_ppi_hppi(int domain, uint32_t id, uint8_t prio) "domain %d ne= w 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 Sat May 30 18:35:06 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=1778169274; cv=none; d=zohomail.com; s=zohoarc; b=KN1WQxK/ZBRRFY7FhxOP7SWxBh5S0xO5R5NovnY9+I2rtdmmZe6DzarlSzahSHGrOS/kD5sQ6mtcv0JP53XAr7YrTiga6tFaeTszBWmwCvgkIkCcJVT4CYy+Rzs94gy3YHAr2ClCM4YZzmsXhvxMyjBwlldvoXZrpTPhYB+6gYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169274; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=P0gAQQxsh9I1aOtpvt/kztG4Nh8b9O7yCDf8P41bgao=; b=JtWxYlAvSdaeyFdFyjzO9DUDcQKXh2hnFtW+zmoDr3+nBbwy4EFT5XnLIL/DAvPJl4XByYqNpkaVQZuRwAQYjCTvicVTE1atxPDi+7E12IDzivkNlKKXygAlgSN2lBOWv1dckUXrAsslCNxevz7PZAhc23k/7gMDzpaLVGyAmZs= 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 1778169274624785.6084092025693; Thu, 7 May 2026 08:54:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11v-0005Hb-Fh; Thu, 07 May 2026 11:52: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 1wL11s-00056B-NR for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:48 -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 1wL11q-00040J-T3 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:48 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4891b0786beso7557595e9.1 for ; Thu, 07 May 2026 08:52:46 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169165; x=1778773965; 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; bh=P0gAQQxsh9I1aOtpvt/kztG4Nh8b9O7yCDf8P41bgao=; b=Owl3j5ANe2PtHJrstRMsQGumt/zpF3d/rh8+rp0DBIDIfLTya8i4d/nRKRKci6o0xU KDLqZ/NH7j+zFeOq9dOTMUDGUULJ5sBIIu1WhJYNxdDIVhibhB9O03Rd3sIX9lyQ3zQb I24PieULjX5fYsZUYwjfn1R/2ScvvlZC5Y3y7DMyWToasHNxYtLYdkqmq9BAjAEWwLq5 BsHTiexv0mhB1w/lrzqXvVOPoRMPz+wSL/tTvTr1IRIRQ1Ugu0gW+xW91bl0VZ2Xz0OB vgHFED9h/ffFDkKqCkit9QNnEyGyd2f1LHnCl8ESfed7SdftPpVtbtvA+MMBI1VOOefK 6KMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169165; x=1778773965; 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; bh=P0gAQQxsh9I1aOtpvt/kztG4Nh8b9O7yCDf8P41bgao=; b=c2d2/xBrAySExwhqTvdiY0Mrgx8jS075UKC84G7S7w5+Fy7xH8pI9qGXsc0168/lI6 o2OQdYUvN+wNCq0fXrJcP8dP6Pikg/cIaswm6y24etT5HCO724ljrpS6aytL8KjCOWw/ wBY/8lE2MUHwKJODpLWKE2xw5bvlDM9HhqSCr0weF/kOg6fWrl+dz2dVbBBSJ764Izr7 vtyASdhcY7V1Mr/IxDrQJq/FSHUFjTJUZBCStqhyveuKMQ1iBZsYIemZxfzch8uKfPBP A3NsulukA503x8lxAV5X+MlDcl1F23knFQyB6d2sL8Llpw8M0zdTTVoaQuTyKOedmWjY iXKQ== X-Gm-Message-State: AOJu0YwfGbaIhk8NeUJ841YSh42G7Tb4TsUWUaQEnXch/WiXMwC6ZQ/B unvcsCo9Dbzm6zVxXsNkvE4XNLSNB8IwbpWsGfr9f6C6s/RP2OPg05q7bMt+He/rOlU+DAZtKwp 5DSBJ X-Gm-Gg: AeBDievl8uxLF2F+/SLQsQEMFtMm3aTyJHqoKPIUtTG4YMkAHAZvNYZUJpNmDdA7XRN oIl/bO+xi+1tJghqSYWBPZxOQF/nh69TIJPyKNQSFYWNuqH+LjLxNpZICT12m+Ze1eyLdNk8ZyY DQNZbHzCcZeY9B64SMYJMs6iE5bUKGfp6YPEw9RPHcHSL9PUA2C5yWAMjtV3USDXvMnfvmtySsD KcGBLQSDRxULzvEciwv0RBs8B+kxW8VSAu3dz+pNuUUjGcA+H/Yx0PnKlV8tlFTekJnmuJazz9K Swfj1slkZzJ51tqi94JnPsh98ukPWktsUUtuono2+9XMfu6bHZEVZ3alhjfLXW2K1YWbPiOV9KR dWr/OIzVMyOpIKfac3V9BD4VrEiQAs//nTzzKo1ElEKEc3Wan8dXAPeLYy41yVjH2hqIKP4HGcm VreuZ+i9f4oyycjsYbtfSAQDW634gcM60u8QFcAOBwRSjMVZps125w5h3AxYwMu9HQ3FdLcEzUd iPCk7FVlTHbsefkw5rUxTi6xnmteLI= X-Received: by 2002:a05:600c:3b0f:b0:48a:7965:b943 with SMTP id 5b1f17b1804b1-48e51f4e9admr141468305e9.29.1778169165304; Thu, 07 May 2026 08:52:45 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 50/67] hw/intc/arm_gicv5: Implement Deactivate command Date: Thu, 7 May 2026 16:51:37 +0100 Message-ID: <20260507155154.1886557-51-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169277147154100 Content-Type: text/plain; charset="utf-8" Implement the equivalent of the GICv5 stream protocol's Deactivate command, which lets the cpuif tell the IRS to deactivate the specified interrupt. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-51-peter.maydell@linaro.org --- hw/intc/arm_gicv5.c | 52 ++++++++++++++++++++++++++++++ hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_stream.h | 14 ++++++++ 3 files changed, 67 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 942f3eba2e..493d664625 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1153,6 +1153,58 @@ void gicv5_activate(GICv5Common *cs, uint32_t id, GI= Cv5Domain domain, irs_recalc_hppi(s, domain, iaffid); } =20 +void gicv5_deactivate(GICv5Common *cs, uint32_t id, GICv5Domain domain, + GICv5IntType type, bool virtual) +{ + GICv5 *s =3D ARM_GICV5(cs); + uint32_t iaffid; + + trace_gicv5_deactivate(domain_name[domain], inttype_name(type), virtua= l, id); + + if (virtual) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_deactivate: tried to " + "deactivate a virtual interrupt\n"); + 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); + + if (!l2_iste_p) { + 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: + { + GICv5SPIState *spi =3D gicv5_spi_state(cs, id, domain); + + if (!spi) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_deactivate: tried to " + "deactivate unreachable SPI %d\n", id); + return; + } + + spi->active =3D false; + iaffid =3D spi->iaffid; + break; + } + default: + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_deactivate: tried to " + "deactivate bad interrupt type %d\n", type); + return; + } + + irs_recalc_hppi(s, domain, iaffid); +} + static void irs_map_l2_istr_write(GICv5 *s, GICv5Domain domain, uint64_t v= alue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 636c598970..c6696f0e0a 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -242,6 +242,7 @@ gicv5_set_handling(const char *domain, const char *type= , bool virtual, uint32_t 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 gicv5_activate(const char *domain, const char *type, bool virtual, uint32_= t id) "GICv5 IRS Activate %s %s virtual:%d ID %u" +gicv5_deactivate(const char *domain, const char *type, bool virtual, uint3= 2_t id) "GICv5 IRS Deactivate %s %s virtual:%d ID %u" 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" diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5= _stream.h index 7ac24f0f09..3cc9f61155 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -211,4 +211,18 @@ void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain = domain); GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5Domain domain, uint32_t iaffid); =20 +/** + * gicv5_deactivate + * @cs: GIC IRS to send command to + * @id: interrupt ID + * @domain: interrupt Domain to act on + * @type: interrupt type (LPI or SPI) + * @virtual: true if this is a virtual interrupt + * + * 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); + #endif --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169200; cv=none; d=zohomail.com; s=zohoarc; b=LThn6QmTe/6WT77mrZx9pzVKJQqV8X+2YKANQ8JNLtoJiYF+B+5DrGtGmUI6xgqjKMuvB7txyRGRMvEux712kzGoA1r0WViZlO2tMV4v0Jk/0flK3POdU5PggBvPuZP1ezBRSiVNwXqUPN8qKU0rWseKXbFusH+ntHCYRJZo8CY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169200; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=6KpHX1ryLYosOGLgFW7TiOUDrkT4gCAlAvCWeyLY/oI=; b=HyjDV9oa8IZ5L+8bfmtI6H2in546tzQWILVEr2JtcLjCqj28aBeS5/JxQLMnlJRMW09YcuPmw1v7Qjtai/2FvMMP7SU7ooUBGtkCblb/K/1FMgqHQ/Vf8IkOfqxNpJI+vMc6HBqmQ6Qcf+u0zFhZxfcIjN0J0vv0oW2RJ/vqmus= 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 1778169200174219.24261882473536; Thu, 7 May 2026 08:53:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11x-0005PR-GG; Thu, 07 May 2026 11:52: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 1wL11t-0005Ak-L5 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:49 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wL11r-00040c-Uu for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:49 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-488a88aeec9so12902015e9.2 for ; Thu, 07 May 2026 08:52:47 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169166; x=1778773966; 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; bh=6KpHX1ryLYosOGLgFW7TiOUDrkT4gCAlAvCWeyLY/oI=; b=xmdVPEHw+tyEfx0VZ157s8dWnNBl6O+2F+KgwX2DukkFJ7vZXNKs5Opxqz6/jdssar 3l9YpwUlOapEl6MJgLDEkHlWBEN8EGaEA/3hpDkfy6TaGwjbInvQiVrLGhoKjF9axpaG 1mpTBru+l1mEtO6AiJ5FMXGjl4Z5LZOAyR/J28lfirk1V622Do5fzAGSMnOYaOsViG2p MXQ2QvJvXbMi2rBfbygkzW1XmShxEC2eC+wysobrvaqph6aVIerhV0AbhcrKijoPZX9B Q276IOdhPStnObVEn6IqDuFFX0oEJaoPBsvsPxHFLZtlmQbunxVdMUslCIRcSpkEC9Av UUCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169166; x=1778773966; 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; bh=6KpHX1ryLYosOGLgFW7TiOUDrkT4gCAlAvCWeyLY/oI=; b=VrDRmFHQ3vzYTPg8UrOYhStvSDHFkdTuG5qCRcmJTSF01zBKg93m+9pEpMOh3zN2Ue sHoc8OdeapJkddwE0/w0tvCH9GWUk0EkbwrBuHdy3yO7QiHbzdO5uIr0pTlc+0VMw1GP IRIV0M0BCBaFZIRs4gJDO6kynWTWP8dEqcvX7sylgW1FrT270jMto0JFnm0B5Luoz5oy oVMtKYWa1Uh+eK+mhSWRPOSxAy/S3FA9/K82TUaNyisiah+HrlHZAxI4oGPFytq1BdLX XLRyO8p4sWYK1n4obwUXLfNQqybrA+UJ68YvoVKDNGmiiHPczlxyKIsTOR+8OrKLcjZH A/2Q== X-Gm-Message-State: AOJu0YyxrZANJA6z9U4X/GB27FatAiPb+D76fLG7KFseNqKrZb4Bcy6y prNpTdQmZ96C7uAmY/qr0LbaeKvJspXJLAnHoa9flKT843XTeYCBMenZgJr/23PL1ZgKHdaLi2P lJ63O X-Gm-Gg: AeBDievqUJb0OZWvd18edZ2cT62gnISUpxNEhLbMwUJtlfMmWz+Pa480mvByB/q4anv sdxq99uKEUMGIkuWlq7RJCL1H/zCnMzLDq2qVQtEbkQlXW0f96kUNAXsBUYZ2WVWwIsJWegY8hp C41Pr8WKJb1bRDnojpBDMpvkZKKbGRNA48zQHioxJaJxBnZU09tLM9mLyhn6lNsVhs6lA9HoJPu 4WKV/8iiJwlj1bt5ynkVjl1ly9V7gQegricX2n/TqNBjZ4tkbTUuzfwUh7AAV6mZEaYy11pMvuU /au/bk4u32TdHWAj9HHUAVm1uDeKQfZKiPabpJ7eUMwqqP2Wr8Q7BvTD3rP2IS8qKs/cbVfAM3b mr8sAZA7l0Bj9HaaPUgNPg/kquB5xWqa/mbkxGzMTagR7sfiUrKoWKdk8Q5jXuBBNzl3PdDdu8l MHOemziznvpPKuSfKtU+rWL5V+rCLhKD9ATz0Vx2FjQFVzdlVTCjIjVwkTFNVahtAn65OlR7esD 3W5WsUX7Qrz5KoqtvkFhP2xcKEapocR3hXKugo6Wg== X-Received: by 2002:a05:600c:47d3:b0:48a:9428:5522 with SMTP id 5b1f17b1804b1-48e51f37358mr86818975e9.16.1778169166123; Thu, 07 May 2026 08:52:46 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 51/67] target/arm: GICv5 cpuif: Implement GIC CDDI Date: Thu, 7 May 2026 16:51:38 +0100 Message-ID: <20260507155154.1886557-52-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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: 1778169201294158500 Content-Type: text/plain; charset="utf-8" Implement the GIC CDDI system instruction, which deactivates the specified interrupt. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-52-peter.maydell@linaro.org --- target/arm/tcg/gicv5-cpuif.c | 49 ++++++++++++++++++++++++++++++++++++ target/arm/tcg/trace-events | 1 + 2 files changed, 50 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 5e613362bc..9dc754ff3a 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -17,6 +17,9 @@ FIELD(GIC_CDPRI, ID, 0, 24) FIELD(GIC_CDPRI, TYPE, 29, 3) FIELD(GIC_CDPRI, PRIORITY, 35, 5) =20 +FIELD(GIC_CDDI, ID, 0, 24) +FIELD(GIC_CDDI, TYPE, 29, 3) + FIELD(GIC_CDDIS, ID, 0, 24) FIELD(GIC_CDDIS, TYPE, 29, 3) =20 @@ -570,6 +573,47 @@ static void gic_cdeoi_write(CPUARMState *env, const AR= MCPRegInfo *ri, *apr &=3D *apr - 1; } =20 +static void gic_cddi_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* + * Clear the Active state of the specified interrupt in the + * current interrupt domain. + */ + GICv5Common *gic =3D gicv5_get_gic(env); + GICv5Domain domain =3D gicv5_current_phys_domain(env); + GICv5IntType type =3D FIELD_EX64(value, GIC_CDDI, TYPE); + uint32_t id =3D FIELD_EX64(value, GIC_CDDI, ID); + bool virtual =3D false; + + trace_gicv5_cddi(domain, value); + + switch (type) { + case GICV5_PPI: + { + uint32_t ppireg, ppibit; + + if (id >=3D GICV5_NUM_PPIS) { + break; + } + + ppireg =3D id / 64; + ppibit =3D 1 << (id % 64); + + env->gicv5_cpuif.ppi_active[ppireg] &=3D ~ppibit; + gic_recalc_ppi_hppi(env); + break; + } + case GICV5_LPI: + case GICV5_SPI: + /* Tell the IRS to deactivate this interrupt */ + gicv5_deactivate(gic, id, domain, type, virtual); + break; + default: + break; + } +} + static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { /* * Barrier: wait until the effects of a cpuif system register @@ -627,6 +671,11 @@ static const ARMCPRegInfo gicv5_cpuif_reginfo[] =3D { .access =3D PL1_W, .type =3D ARM_CP_IO | ARM_CP_NO_RAW, .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, + .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, diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index fcb3106a96..c60ce6834e 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -6,3 +6,4 @@ gicv5_recalc_ppi_hppi(int domain, uint32_t id, uint8_t prio= ) "domain %d new PPI 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_cddi(int domain, uint32_t id) "domain %d CDDI deactivating interrupt= ID 0x%x" --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169188; cv=none; d=zohomail.com; s=zohoarc; b=InxGmn6aTk2QOjwRJ6JG7iwzWKegUSXDy54fH0VxExSjcfG97AwCdYhKL7pxf1YFapa0NQAuMxtmWAHEXjmDaiPK3VPJs9IcduzHU/bQeSbxYPlEDc4d403/rDiKAkAudxtjMoxUuAHyUZv+/fNa4jgSZpGKctFZRn/yVPMAJJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169188; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=H55FNyA92XWr1Xn6E9kb+2RAwZYK6j7XqkAEz4Sr6o4=; b=IglSL+w61w00SH4/lZkJvLgz40Wh2e6eGclyJeZ7FqRZ/u6bIbwuuJboTnNLM8l1iT7H2APXQyCb7a1XR/Xye0NyNsM2qh671teHc2vCC1h2GphERhUlHlzvWeS0gwBbe5GJUo53njKaRAC84SuG6OzWcknWxLvNfth8K6v+35I= 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 1778169188966756.3087736410093; Thu, 7 May 2026 08: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 1wL11z-0005Xd-Ai; Thu, 07 May 2026 11:52:55 -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 1wL11u-0005E3-Hf for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:50 -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 1wL11s-00040s-K1 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:50 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-48a563e4ef7so9829715e9.0 for ; Thu, 07 May 2026 08:52:48 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169167; x=1778773967; 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; bh=H55FNyA92XWr1Xn6E9kb+2RAwZYK6j7XqkAEz4Sr6o4=; b=ecRWCHMi3l7eK/uQRowu6YI7k4q1OKWWnJsVTbAzzJqlNxicG2h2G9W3wbziR5TZmk Qa9qhoeG0s+2egTA8a2AZPzKjoQbHkTCBEoyDP1+z3LrGi/QLOeOty2UGL8v07ceFFJh xPCxpnq8aLDrrk9Bo7QbFLRRIaoeTTrTleGaocg8ewLbH/fhJ9raH+T9qETo2PI6nVk5 zUQQ5IpuJnqSrsUxHaAWlLNcvQtlf8ouUjORC1ACVsgEI1Ef+tWIaBR7EoanTT1P9/b3 wi4UUJLBfTrCARuu62pDQfEYvCjR2QK6QtDI/s9v16iuX39ONcO0w3Qg9YAYxRBuGXqZ OxTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169167; x=1778773967; 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; bh=H55FNyA92XWr1Xn6E9kb+2RAwZYK6j7XqkAEz4Sr6o4=; b=MW8jv5D99clpoSzuOfACPbPGi4jJ1bVlQ+Wj1j9zi+V0U7bl8ofVuOhf9+usL+lT8a Q7NhrRHaNer9Bo5I9pmYlXH+4tAzgRNSiU7N/Eb3XwFcECwCmpHixgNrB0QtQQehRsJL yLYl7K/lzMd0vlaQQ+J/EIu1ROwNWWUb+Xz4lILyzGk6cQDLvQjRrH+PGJ1vH+smhBLG FUapkRcEglnE2AJrVJ56uqvoR/eewQaxuIpcoWmrclRrd/PF7IIdki8US0V7UfS+KBb3 iEakfZdGlBfc1i0my4HOqVhGk4iiar1L94/GFio04mZ1vVc4RIeM2wy02dRV7HH2dAXI nnww== X-Gm-Message-State: AOJu0YyoD+jCI166KG1poble64VMwIgQ90OJFq1SkFSD06QqATuTzvFz ucRfcrUyFre4pntZNsaTNHeM+I/+gxKgwYEMGkdJz45PoqHnpVgnjJqe6+LbjLKgzKGxMAX1ZAq zg76Z X-Gm-Gg: AeBDiesNNYCCzJoW3acPBHmXVsBh1OMsnLmXx4Wps6bq/E4FR1CeoMiHiE03AGDjnhc l3AUB4pA22HUuP3e+u0scSC1QXEPqAfHJSl/Sxan9dU5XeECky6+TlF1EIeG1pEnAybxTk3xbVQ ku3ZSdaOVbtMG+W/90OjVvvVyN2iwyoIZtpZwHYJxbf/okFi8ZL5xUc3/ceZfl431cih7iBnuaz ad5b+iNMNQdzZ6PPctxPaGCI05UeKzUEbwBQXMsgoYCS7hcIjRo+TpY7zcxjo481kelAlOvW9rI 3MmtGB8ctXkwrAwuG6laZFBkM3DEjW3w7BydQdtNCSWRQI4i/R+7ORQYaJrpcrsDZVAeNTSMgZS rTZV83ILNAUeAezogpnx9a/LMQbg+PPZXnnxo08bbsy6oonRYaOj+D292TcCMX24YIMXS2B2LOi 82avqsaxCl/TYCsV18KF/OTMWxpSYR5iurgghnMuNOU40b2SexUoZal6YgLH7HUl8v6IVugi5wx 3tkuhDN+Ns15MnitpQs1e10Ih0PDZY= X-Received: by 2002:a05:600c:c0c1:b0:48a:581c:ead with SMTP id 5b1f17b1804b1-48e51e1ee16mr105000935e9.10.1778169167037; Thu, 07 May 2026 08:52:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 52/67] target/arm: GICv5 cpuif: Signal IRQ or FIQ Date: Thu, 7 May 2026 16:51:39 +0100 Message-ID: <20260507155154.1886557-53-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169191919154100 Content-Type: text/plain; charset="utf-8" The CPU interface must signal IRQ or FIQ (possibly with superpriority) when there is a pending interrupt of sufficient priority available. Implement this logic. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-53-peter.maydell@linaro.org --- target/arm/tcg/gicv5-cpuif.c | 87 ++++++++++++++++++++++++++++++++++-- target/arm/tcg/trace-events | 1 + 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 9dc754ff3a..27ad98769c 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -170,6 +170,84 @@ 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) +{ + /* + * Update whether we are signalling IRQ or FIQ based on the + * current state of the CPU interface (and in particular on the + * HPPI information from the IRS and for the PPIs for each + * interrupt domain); + * + * The logic here for IRQ and FIQ is defined by rules R_QLGBG and + * R_ZGHMN; whether to signal with superpriority is defined by + * rule R_CSBDX. + * + * For the moment, we do not consider preemptive interrupts, + * because these only occur when there is a HPPI of sufficient + * priority for another interrupt domain, and we only support EL1 + * and the NonSecure interrupt domain currently. + * + * NB: when we handle more than just EL1 we will need to arrange + * to call this function to re-evaluate the IRQ and FIQ state when + * we change EL. + */ + GICv5PendingIrq current_hppi; + bool irq, fiq, superpriority; + + /* + * We will never signal FIQ because FIQ is for preemptive + * interrupts or for EL3 HPPIs. + */ + fiq =3D false; + + /* + * We signal IRQ when we are not signalling FIQ and there is a + * HPPI of sufficient priority for the current domain. It has + * Superpriority if its priority is 0 (in which case it is + * CPU_INTERRUPT_NMI rather than CPU_INTERRUPT_HARD). + */ + current_hppi =3D gic_hppi(env, gicv5_current_phys_domain(env)); + superpriority =3D current_hppi.prio =3D=3D 0; + irq =3D current_hppi.prio !=3D PRIO_IDLE && !superpriority; + + /* + * 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(). + */ + 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); +} + static void gic_recalc_ppi_hppi(CPUARMState *env) { /* @@ -219,15 +297,16 @@ static void gic_recalc_ppi_hppi(CPUARMState *env) env->gicv5_cpuif.ppi_hppi[i].intid, env->gicv5_cpuif.ppi_hppi[i].prio); } + gicv5_update_irq_fiq(env); } =20 void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain) { /* - * For now, we do nothing. Later we will recalculate the overall - * HPPI by combining the IRS HPPI with the PPI HPPI, and possibly - * signal IRQ/FIQ. + * IRS HPPI has changed: recalculate the IRQ/FIQ levels by + * combining the IRS HPPI with the PPI HPPI. */ + gicv5_update_irq_fiq(&cpu->env); } =20 static void gic_cddis_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -430,6 +509,7 @@ static void gic_icc_cr0_el1_write(CPUARMState *env, con= st ARMCPRegInfo *ri, value |=3D R_ICC_CR0_LINK_MASK | R_ICC_CR0_LINK_IDLE_MASK; =20 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) @@ -571,6 +651,7 @@ static void gic_cdeoi_write(CPUARMState *env, const ARM= CPRegInfo *ri, =20 /* 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 c60ce6834e..2bfa8fc552 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -7,3 +7,4 @@ 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_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" --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169422; cv=none; d=zohomail.com; s=zohoarc; b=W3MFcVu+woiz/BPveyQnxbe0NsrrAduH7Eh+UuHLnbF+8Q0D5jUqrI8DbBvFl2CUB/EhQg40YtluEobqrAib1zken79n46F3h7++igFPjEBMX3jYKVy8VVMcEtsWCP1EZ5WNDGc+MEdAMhnw2dJzgkNpTdJ84odtSyZEfwoaPSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169422; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=XsFeWKZW9AodnzAAvDj5JSQ1dtOxWY1ouaFHOvVYjBc=; b=f10xjuH189nA7YDaTStvgdrQPznOxSCDaj4NX9SpptMGKK8KXBSwITk3BTxqfUeYok0iyYVTFyi7CZrk+i4PKa0tCczPz/IzVdi3N607f6ERveaKEmqubFzdkH5/BddLPRF+pjDh/m/djoH5zIJ92JsDE041bsd9OaDHgd2CmQo= 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 1778169422160797.529994613731; Thu, 7 May 2026 08:57:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11x-0005Pk-Og; Thu, 07 May 2026 11:52: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 1wL11v-0005I6-IE for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:52 -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 1wL11t-00041A-HV for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:51 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4891f625344so12054795e9.0 for ; Thu, 07 May 2026 08:52:49 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169168; x=1778773968; 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; bh=XsFeWKZW9AodnzAAvDj5JSQ1dtOxWY1ouaFHOvVYjBc=; b=hvpHeqzmWJKDhK4g1e5xYMEuFJo2uiJrZbuMjsGZSESqrJed9T4JDQxGQbOR5ULmMG 2RdA+sOuitN2ID5Cv06QZqw769ZmbvqrOaEo2g3WC1ZzmiYCQxOwC8f7pLbfD3zXw35x IGZJDczY4H9CsSr4kEnuat64ym+0qquUtxbpDx+2OCvYeyVPi7HY465lxSwxHSgmgX92 M2vFeWnp3wJR4v6jU49/6G7Ymi/wLCcbQSevTBHQd4lqfp4qn5cBXyiPVaLAMqUsXQK6 q6SZNf90WCDyV90E5zaEvgTcJ8cdvUx8/Uk1jrTSdE4/fY3LeMFm5biAE0YuhdZnpPWf nusQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169168; x=1778773968; 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; bh=XsFeWKZW9AodnzAAvDj5JSQ1dtOxWY1ouaFHOvVYjBc=; b=i/JEWTDOYNLwXlW2dH7HXUT7Xr7GDScF2fZ6V3LPJ/u4SQbLplFw861D37h8QEKQCp sTiT4x1NNm0S0LTj6WQoaqApHbRQcggoe+pGzGXn4Vdlp4Hge0OHXcswUiB0fhBwg9tY CHh0kPoAIKm5WtZolxLYjyEgH8ySOEh7qITBDBxWW+29vJ73ju41BNLZdJJx1atnk5in PWPyh9Kf554qBt49a6Pl8hKKJnpw6p41yhSdPk0bjtZ+VZXwdCar/Z/msUJfuCfdvTkZ IsIoHaOISz/RH7Gz8nerIEle2rfVVXC/KAYfvN35+4lgVtJGdJVfosnaGUC+c4FAVJNd HknA== X-Gm-Message-State: AOJu0YwokOWVlydCDSrjlNFvO1itIAuAPExYcHvX3mYCc4bQy6hoIqZE RH29o1LBb12B8peEWEFVEr6+6XOSgs5P1zVAodQ8IuHS3Xp9A0VA4NSAee91/w1LSQ0oJjj3itu yl/Y+ X-Gm-Gg: AeBDieuPjJYI+jGoGbQuyzFr8wuRAZA/fCb2XEvqmWYblFU8V3rmAR/vlAUYea8KFkf s8cxjVY2Ud+/7Kq9GIWyaDzjVBY8vOBJ0Tww4LUOToo75SWX/rt066qDK7xseyrGuHUNU+f1q+z 7ZVJTvAZkHkDBCwJy1mwirFO4Dhz5t9b2/mDkY0/QcBrg0N7+Mt0iZCR6CrFDkxpdb5IFlmRVkR nxIii9o6P6+gx/eO0SRcP6e/FW6DkFDs4UL5rkjJ7/tVLO7nZyGIOXsI0r7zQo5o2yp6c5pXmyF AS6PLGaRURJbR6enLqvdfzbVesn1k0TwH/onMZWYf/IZiyU0fo6zGCogybEN4TC6ryqGIBzs3JK PPh17FGu/iE1lKmeLmRFAohP0AV06RucVCoveYx/CUBGuS2ula8rpvd/TvvOwVAqZ6PctNPDI3B 3mXLOjgpIgkqn2L0CG005dSgwI072JKEIq7xNas/R9Qn+rKk3XCXpxSXXGaSllCv/rAf+K52FW0 nccfncATa7ryOumCFjZ5d38CEXmt24= X-Received: by 2002:a05:600c:630f:b0:486:f893:56c6 with SMTP id 5b1f17b1804b1-48e5dffab3dmr54373965e9.10.1778169167916; Thu, 07 May 2026 08:52:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 53/67] target/arm: Connect internal interrupt sources up as GICv5 PPIs Date: Thu, 7 May 2026 16:51:40 +0100 Message-ID: <20260507155154.1886557-54-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169422514158500 Content-Type: text/plain; charset="utf-8" The CPU has several interrupt sources which are exposed as GICv5 PPIs. For QEMU, this means the generic timers and the PMU. In GICv3, we implemented these as qemu_irq lines which connect up to the external interrupt controller device. In a GICv5, the PPIs are handled entirely inside the CPU interface, so there are no external signals. Instead we provide a gicv5_update_ppi_state() function which the emulated timer and PMU code uses to tell the CPU interface about the new state of the PPI source. We make the GICv5 function a no-op if there is no GICv5 present, so that calling code can do both "update the old irq lines" and "update the GICv5 PPI" without having to add conditionals. (In a GICv5 system the old irq lines won't be connected to anything, so the qemu_set_irq() will be a no-op.) Updating PPIs via either mechanism is unnecessary in user-only mode; we got away with not ifdeffing this away before because qemu_set_irq() is built for user-only mode, but since the GICv5 cpuif code is system-emulation only, we do need an ifdef now. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-54-peter.maydell@linaro.org --- target/arm/cpregs-pmu.c | 9 +++++++-- target/arm/helper.c | 20 ++++++++++++++++++++ target/arm/internals.h | 6 ++++++ target/arm/tcg-stubs.c | 4 ++++ target/arm/tcg/gicv5-cpuif.c | 28 ++++++++++++++++++++++++++++ target/arm/tcg/trace-events | 1 + 6 files changed, 66 insertions(+), 2 deletions(-) diff --git a/target/arm/cpregs-pmu.c b/target/arm/cpregs-pmu.c index 47e1e4652b..46df6597b1 100644 --- a/target/arm/cpregs-pmu.c +++ b/target/arm/cpregs-pmu.c @@ -428,9 +428,14 @@ static bool pmu_counter_enabled(CPUARMState *env, uint= 8_t counter) =20 static void pmu_update_irq(CPUARMState *env) { +#ifndef CONFIG_USER_ONLY ARMCPU *cpu =3D env_archcpu(env); - qemu_set_irq(cpu->pmu_interrupt, (env->cp15.c9_pmcr & PMCRE) && - (env->cp15.c9_pminten & env->cp15.c9_pmovsr)); + bool level =3D (env->cp15.c9_pmcr & PMCRE) && + (env->cp15.c9_pminten & env->cp15.c9_pmovsr); + + gicv5_update_ppi_state(env, GICV5_PPI_PMUIRQ, level); + qemu_set_irq(cpu->pmu_interrupt, level); +#endif } =20 static bool pmccntr_clockdiv_enabled(CPUARMState *env) diff --git a/target/arm/helper.c b/target/arm/helper.c index d9751cf202..8240f1b384 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1343,6 +1343,21 @@ uint64_t gt_get_countervalue(CPUARMState *env) return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / gt_cntfrq_period_ns(cpu= ); } =20 +static void gt_update_gicv5_ppi(CPUARMState *env, int timeridx, bool level) +{ + static int timeridx_to_ppi[] =3D { + [GTIMER_PHYS] =3D GICV5_PPI_CNTP, + [GTIMER_VIRT] =3D GICV5_PPI_CNTV, + [GTIMER_HYP] =3D GICV5_PPI_CNTHP, + [GTIMER_SEC] =3D GICV5_PPI_CNTPS, + [GTIMER_HYPVIRT] =3D GICV5_PPI_CNTHV, + [GTIMER_S_EL2_PHYS] =3D GICV5_PPI_CNTHPS, + [GTIMER_S_EL2_VIRT] =3D GICV5_PPI_CNTHVS, + }; + + gicv5_update_ppi_state(env, timeridx_to_ppi[timeridx], level); +} + static void gt_update_irq(ARMCPU *cpu, int timeridx) { CPUARMState *env =3D &cpu->env; @@ -1361,6 +1376,11 @@ static void gt_update_irq(ARMCPU *cpu, int timeridx) irqstate =3D 0; } =20 + /* + * We update both the GICv5 PPI and the external-GIC irq line + * (whichever of the two mechanisms is unused will do nothing) + */ + gt_update_gicv5_ppi(env, timeridx, irqstate); qemu_set_irq(cpu->gt_timer_outputs[timeridx], irqstate); trace_arm_gt_update_irq(timeridx, irqstate); } diff --git a/target/arm/internals.h b/target/arm/internals.h index 6431029db8..86b41b4724 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1813,6 +1813,12 @@ void define_omap_cp_regs(ARMCPU *cpu); /* Add the cpreg definitions for the GICv5 CPU interface */ void define_gicv5_cpuif_regs(ARMCPU *cpu); =20 +/* + * Update the state of the given GICv5 PPI for this CPU. Does nothing + * if the GICv5 is not present. + */ +void gicv5_update_ppi_state(CPUARMState *env, int ppi, bool level); + /* Effective value of MDCR_EL2 */ static inline uint64_t arm_mdcr_el2_eff(CPUARMState *env) { diff --git a/target/arm/tcg-stubs.c b/target/arm/tcg-stubs.c index aeeede8066..8d97449cfc 100644 --- a/target/arm/tcg-stubs.c +++ b/target/arm/tcg-stubs.c @@ -43,3 +43,7 @@ void vfp_clear_float_status_exc_flags(CPUARMState *env) void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask) { } + +void gicv5_update_ppi_state(CPUARMState *env, int ppi, bool level) +{ +} diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 27ad98769c..bc44a7fc11 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -309,6 +309,34 @@ void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain = domain) gicv5_update_irq_fiq(&cpu->env); } =20 +void gicv5_update_ppi_state(CPUARMState *env, int ppi, bool level) +{ + /* + * Update the state of the given PPI (which is connected to some + * CPU-internal source of interrupts, like the timers). We can + * assume that the PPI is fixed as level-triggered, which means + * that its pending state exactly tracks the input (and the guest + * cannot separately change the pending state, because the pending + * bits are RO). + */ + int oldlevel; + + if (!cpu_isar_feature(aa64_gcie, env_archcpu(env))) { + return; + } + + /* The architected PPIs are 0..63, so in the first PPI register. */ + assert(ppi >=3D 0 && ppi < 64); + oldlevel =3D extract64(env->gicv5_cpuif.ppi_pend[0], ppi, 1); + if (oldlevel !=3D level) { + trace_gicv5_update_ppi_state(ppi, level); + + env->gicv5_cpuif.ppi_pend[0] =3D + deposit64(env->gicv5_cpuif.ppi_pend[0], ppi, 1, level); + gic_recalc_ppi_hppi(env); + } +} + static void gic_cddis_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events index 2bfa8fc552..bf1803c872 100644 --- a/target/arm/tcg/trace-events +++ b/target/arm/tcg/trace-events @@ -8,3 +8,4 @@ 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_ppi_state(int ppi, bool level) "PPI %d source level now %d" --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169533; cv=none; d=zohomail.com; s=zohoarc; b=RFfMPt4uApqn2Qla/aGXkOpC/CWV4cALQjWwMHYH9pQvPQKMVkXa6T00mQuiuZNGE1mJppS+cfhZKKs1NVAdra4zVBC5wrmFadbgMdWSKFOAHzEO9H009nI60C4FtSPGjBSgWjo6HYrStEIe52vRLvMRG7GIDuPahFQCPWi8+GI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169533; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=A/aN2QAxKTVLKMwN6ey26q9bUhfrDOPQ9xOMl/smTtk=; b=HPv707to5WyWVjtRRbK59LStuvcAIPHaoww7Gvl5O+LWRPpYV448RdaANxpsMQt4c76CIno+d+4fdH5LHOCSMQ40axUShViWwybBpbmysnotW7v7PdNp/jKro5C0iH4LSJsJ5l844Ye5zXgFcrP0wG6/+DO5SMg8acfB5upCAAk= 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 1778169533271930.7875352018799; Thu, 7 May 2026 08:58:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11y-0005V2-FJ; Thu, 07 May 2026 11:52:54 -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 1wL11w-0005Ic-5U for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:52 -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 1wL11u-00041N-AL for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:51 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4891c00e7aeso9362635e9.2 for ; Thu, 07 May 2026 08:52:49 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169169; x=1778773969; 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; bh=A/aN2QAxKTVLKMwN6ey26q9bUhfrDOPQ9xOMl/smTtk=; b=X6OTwgYQCSUGumxPduiHA8KvOC5D+lO2aUqwCJCh0Wscm9CBLf1+/gnLvEMDdOTDSX 3zbBBiYc/6WzNDDBmZoTlIJ1AHj26Z24iMXX5FIXP8SU17oCf2Zf9igWpq49cfR5hzyy tFIA1f40tdt3DSSi1L0+npfFqVo4raNe0mNChvhY3/cs74l6E1M0/YKQs7eVjHNFsL5u ezcSSLYY2IB5BNG71BSZRNq0MtQ+JJRDG9YwXCbDl5ooYsThLKoIowyVl3sgfX6DDMHP K2qgPXhVVA7ZTE6K0WYnZ/TjIRdO2VvAlDkwXxsRaO1biH4Vv8y27+RnHAXN0WKXPBCG QZ6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169169; x=1778773969; 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; bh=A/aN2QAxKTVLKMwN6ey26q9bUhfrDOPQ9xOMl/smTtk=; b=UoWVsYzhxzQTnuQNN5U8C9H4RQoCMRRgDOkiLQNOuMrsupykVmhGAM9NVT7AdyDJLq Lv6BGvByRnAvuMi48qOABQuEsJe4mNVyZ/tHB707HD+VxX1KpX3FaK1WjX6vrjPRc8qf ganyU8tLrQ9d4Yxjw37Bhh2/uUzlaRGHDtbTaEqA6lnD98WdDY88zN8PcyX+S6OMEr/V 9stJxATKB5ghSfxfPTkKTMf50qGFKdP9Nvdwuc1yhJsufngCNYlJ6RYvgQIoVYlb8oUI T0tUFbF4ONkMPcNvBzqmEj4Tz1/kTBbgM20LNj0tpoKP7C4J5jMequADMnRupl4SI3GP GLxQ== X-Gm-Message-State: AOJu0Yw+mdF0FAorx8icMU+NJJ2D3vm1+FqACtH2TVeKulIUjTS/bC0s Qd2fKMM1sIkYcxq5yy539b2u8fFxk6sBKVE7rNRU8eQ00JAfptp3VhJ5w8asqnlCzKEGfIYS3ga GChUT X-Gm-Gg: AeBDietB7t7K1s9qqHyiXgYsPXoh/7SKQWjJ/M9zhI2v3wJTGj4/HT9hHxGWwwJUbwM O4b/CGp808RT8v2JrM+QJ+KQVryLUNSeEsZvALMBMOOv+4Yhan/RxcVrVrNzn0gpjrKj1EnqQB/ zsaSNcrK5uxFl3GJWFMrmIB8N7shuq3S2d7CHdsephCJKwghHMFIC9JcNCdx0JkEG5Nl784MQtW W2l2u9E45BZgAdFFdl9u0edGvlPl0knxP2SjPFGBhDyI6aNxoG1Wg/FL0v8PKr4pt5WBfRg6Nwd zk99uesmeDHZWje2v1SzklxTv38IwGYBa82GsJxnwH3BntiOhWwoo9BF8YfyAXNs0QitZEPIV86 yUZHICSMqoBaQ3C2QNIAyklpj7mtxSrFXRCc5qP1BRHkkSS8TomH5VNHOjyvOjUSpeGfRDB2hqi R3UhFxvRgYOCX1M7xWjB6bMtRvEyRDMoS9aRoxAdALY0CtGKYMITpVXuvzpv2Ff32dFXcoDqu+A xzQHjvj+x4/wQ20GBkH2tEY4IA4TuU= X-Received: by 2002:a05:600c:8b0c:b0:48a:7a10:4f47 with SMTP id 5b1f17b1804b1-48e51e0a620mr146357125e9.3.1778169168715; Thu, 07 May 2026 08:52:48 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 54/67] target/arm: Add has_gcie property to enable FEAT_GCIE Date: Thu, 7 May 2026 16:51:41 +0100 Message-ID: <20260507155154.1886557-55-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169535349154100 Content-Type: text/plain; charset="utf-8" Add a has_gcie QOM property to the CPU which allows the board code to enable FEAT_GCIE, the GICv5 CPU interface. Enabling the GICv5 CPU interface comes with a significant restriction: because the GICv5 architecture is Armv9, it assumes the Armv9 requirement that only EL0 (userspace) may be in AArch32. So there are no GIC control system registers defined for AArch32. We force AArch32 at ELs 1, 2 and 3 to disabled, to avoid a guest being able to get into an EL where interrupts are completely broken. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-55-peter.maydell@linaro.org --- target/arm/cpu.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ target/arm/cpu.h | 2 ++ 2 files changed, 47 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 29346609e4..330e9be473 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1270,6 +1270,9 @@ static const Property arm_cpu_has_el2_property =3D =20 static const Property arm_cpu_has_el3_property =3D DEFINE_PROP_BOOL("has_el3", ARMCPU, has_el3, true); + +static const Property arm_cpu_has_gcie_property =3D + DEFINE_PROP_BOOL("has_gcie", ARMCPU, has_gcie, false); #endif =20 static const Property arm_cpu_cfgend_property =3D @@ -1526,6 +1529,11 @@ static void arm_cpu_post_init(Object *obj) object_property_add_uint64_ptr(obj, "rvbar", &cpu->rvbar_prop, OBJ_PROP_FLAG_READWRITE); + + /* We only allow GICv5 on a 64-bit v8 CPU */ + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + qdev_property_add_static(DEVICE(obj), &arm_cpu_has_gcie_proper= ty); + } } =20 if (arm_feature(&cpu->env, ARM_FEATURE_EL3)) { @@ -1826,6 +1834,12 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) current_accel_name()); return; } + if (cpu->has_gcie) { + error_setg(errp, + "Cannot enable %s when guest CPU has GICv5 enabled", + current_accel_name()); + return; + } } #endif =20 @@ -2163,6 +2177,37 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) FIELD_DP32_IDREG(isar, ID_PFR1, VIRTUALIZATION, 0); } =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); + } + } + if (cpu_isar_feature(aa64_mte, cpu)) { /* * The architectural range of GM blocksize is 2-6, however qemu diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9d2c27f7df..a0a1d7fbe3 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1031,6 +1031,8 @@ struct ArchCPU { bool has_neon; /* CPU has M-profile DSP extension */ bool has_dsp; + /* CPU has FEAT_GCIE GICv5 CPU interface */ + bool has_gcie; =20 /* CPU has memory protection unit */ bool has_mpu; --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169236; cv=none; d=zohomail.com; s=zohoarc; b=GVVimvr6L1qC9pN+v5IAXsI4/hQkMOiS2oJZ7iePYXZSACMQOBybwj94Up6IemCkv81iBF4IUrmP4zQg7/OuL4YTgAdL0XMQHRYXPaaD4iFbaaKS+XjTH7SKlPGkC8WVXNF3C2+RzLybubnzRR5shfwbVfm/cU7iIOJ02xCdqSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169236; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=wnWhtlm4IAr1WhwLbB5MRPiTCqVb37Q2LdPl5T2SX8w=; b=gpV7dnsHNjw0z0Rmt4aX14xVOxhmk+Hs6tNkXuHvV6IHbQuTxSeYd1IEUdNDXPK92O/nu7MPyOkTvxNqw65T1bd6IpTiZt4POk7rMwrT+JXCCdcf0L2+rLAjKdIvgwcJhhAONJBgvCwBxz+2xGt6Fo55JalRvPPtaIOzNqAHoC0= 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 1778169236663918.8035497562603; Thu, 7 May 2026 08: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 1wL126-0005t3-TE; Thu, 07 May 2026 11:53: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 1wL121-0005fA-0E for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:57 -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 1wL11v-00041s-Fy for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:56 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4852b81c73aso9870625e9.3 for ; Thu, 07 May 2026 08:52:51 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169170; x=1778773970; 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; bh=wnWhtlm4IAr1WhwLbB5MRPiTCqVb37Q2LdPl5T2SX8w=; b=dRkQoIucKqNPEUkUnRSic2f1RmFwknFReQTH9+BNxaOi1Oo+S0gQblfhrh2hA3ME/D hfgT/G1xfun+rpXkA+m1we6d+byvwjQMgSQPHKsmM9Wx4XESBpsHiYXL6kbDMDEPUixk dBt8xRiaptwpe6WHW6YJ5Uiyzv5ce0hEMSr2pWs2NiBhyYe5S69ASV3wq0MDmN34DVsC jUaBj8OntsfYBYXRzYsyIpYFW52YkoPM7HMuMVfxsWRx+5BLP6F+kUIA/yvrY4xk29wg GvOqUM6PyaHGonlSLd7ntyoiVe3L7SMQBf4p2bEscWe2FNnH6WU0b24dGASvrlT3vlS+ xHgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169170; x=1778773970; 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; bh=wnWhtlm4IAr1WhwLbB5MRPiTCqVb37Q2LdPl5T2SX8w=; b=drMgxVo0cKYoW4l8U5oayKVUWXhMTFtoIMLojWVpAjf1MS6e8i5CMAWhC9W1K1R7uL 8noofMFJ8J7t6Q5qAsyEv7CICogDGlL3Nd5KF7l3Kh5G2BJ9FO3UKDp0xbzFpnYDsBNd OZpKf7nObye4Pg5P5ZicRdiqHSi516qpIsyz1je4JexjJYp8PVLEA4Qw+0um4Z+hzD1x LeIo/w5cn5zJYwVxmz+VyMDdfVo48eh8140wYNFnLchKazWknS0Sd9JGuQF42bYcx9Qv GGORQQzR4hmSrMBOQdPqKP/V/0mNi/taoGcFb4YWGzx0NV2OBs6LWmxv3AdzhbTkMxuA ah3A== X-Gm-Message-State: AOJu0YzmlO03UIgahEc/e3dT8aW5qOugeNvqnJwaXGvIK9jyNHshi6Hu edVeSi4RX9ysJ61uTZBj0AXMaW3ooNT5+hoh5XuKVhKzg3b/Ul5C8S9Qt6EIlwTZiWvYEBrztik cE29M X-Gm-Gg: AeBDiesvImPVQEmhFnSSu50fmht8PQ70u5FhRZaAqGzKnVQmZBkBHdOh0osafW+hQoF qoiP9faZx7T4jqFABZBmNYVEX+JUXez3toNf+rCjcZ9AOWLLmMEYePOKsSZE1wc11feJ09TdeIO v06uCSwVVV39iFdL75ElkRDlFLoYfG8y5L5GBoQwxHzAHAiY4DHtlmxQ3wOQR9v4nXDaaYASxCD CJL/MKaY8Qu05d9tALLICUvaRHXOXpdWUzX07y+joCmkY+X6uXCr6T0iiNrn/37Sv/GNf+UZHLO 7WetWvrATRRk/zQYw8hpW+bQOeR6xfKBDYRs6AohwCDUCO8nIOO3oasqMBDpNxn8A5ogflqGQew uYxxqZXnAW+9N/CeUhQBujKH5oHU/1DWsiZ7xBnT2Ii20OEu0NSqMylM15K9MP5zzKOb3lPBu8B 5XA8OmvBxGGjhjvAr51dxZ5z70wFU6XUFXwGjDsca07t72h6/bLp5OohJdpp1u7JSVfZzXGfLQc MR2ygDwDwvOp+RiXYyTZnSYzZ40KsI= X-Received: by 2002:a05:600c:c4a3:b0:48a:6fd4:d3d4 with SMTP id 5b1f17b1804b1-48e51f46e38mr141491395e9.29.1778169169686; Thu, 07 May 2026 08:52:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 55/67] hw/intc/arm_gicv3_cpuif: Don't allow GICv3 if CPU has GICv5 cpuif Date: Thu, 7 May 2026 16:51:42 +0100 Message-ID: <20260507155154.1886557-56-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169237383158500 Content-Type: text/plain; charset="utf-8" The GICv3 and GICv5 CPU interfaces are not compatible, and a CPU will only implement either one or the other. If we find that we're trying to connect a GICv3 to a CPU that implements FEAT_GCIE, fail. This will only happen if the board code has a bug and doesn't configure its CPUs and its GIC consistently. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-56-peter.maydell@linaro.org --- hw/intc/arm_gicv3.c | 2 +- hw/intc/arm_gicv3_cpuif.c | 14 +++++++++++++- hw/intc/gicv3_internal.h | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c index 542f81ea49..e93c1df5b4 100644 --- a/hw/intc/arm_gicv3.c +++ b/hw/intc/arm_gicv3.c @@ -449,7 +449,7 @@ static void arm_gic_realize(DeviceState *dev, Error **e= rrp) =20 gicv3_init_irqs_and_mmio(s, gicv3_set_irq, gic_ops); =20 - gicv3_init_cpuif(s); + gicv3_init_cpuif(s, errp); } =20 static void arm_gicv3_class_init(ObjectClass *klass, const void *data) diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index 921d1fdfde..67a0bba4b0 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -16,6 +16,7 @@ #include "qemu/bitops.h" #include "qemu/log.h" #include "qemu/main-loop.h" +#include "qapi/error.h" #include "trace.h" #include "gicv3_internal.h" #include "hw/core/irq.h" @@ -3047,7 +3048,7 @@ static void gicv3_cpuif_el_change_hook(ARMCPU *cpu, v= oid *opaque) gicv3_cpuif_virt_irq_fiq_update(cs); } =20 -void gicv3_init_cpuif(GICv3State *s) +void gicv3_init_cpuif(GICv3State *s, Error **errp) { /* Called from the GICv3 realize function; register our system * registers with the CPU @@ -3058,6 +3059,17 @@ void gicv3_init_cpuif(GICv3State *s) ARMCPU *cpu =3D ARM_CPU(qemu_get_cpu(s->first_cpu_idx + i)); GICv3CPUState *cs =3D &s->cpu[i]; =20 + if (cpu_isar_feature(aa64_gcie, cpu)) { + /* + * Attempt to connect GICv3 to a CPU with GICv5 cpuif + * (almost certainly a bug in the board code) + */ + error_setg(errp, + "Cannot connect GICv3 to CPU %d which has GICv5 cpu= if", + i); + return; + } + /* * If the CPU doesn't define a GICv3 configuration, probably becau= se * in real hardware it doesn't have one, then we use default values diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h index 880dbe52d8..c01be70464 100644 --- a/hw/intc/gicv3_internal.h +++ b/hw/intc/gicv3_internal.h @@ -722,7 +722,7 @@ void gicv3_redist_mov_vlpi(GICv3CPUState *src, uint64_t= src_vptaddr, void gicv3_redist_vinvall(GICv3CPUState *cs, uint64_t vptaddr); =20 void gicv3_redist_send_sgi(GICv3CPUState *cs, int grp, int irq, bool ns); -void gicv3_init_cpuif(GICv3State *s); +void gicv3_init_cpuif(GICv3State *s, Error **errp); =20 /** * gicv3_cpuif_update: --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169178; cv=none; d=zohomail.com; s=zohoarc; b=YSWW5tfZ/l7Yr83ASr+mrGaI8+K2mhOMf3P959G9FG/HI3odD5otReutbf92ah2i51LjGCrs+l8KQCwOlpRx2D9enQNj/xVNkRfTAcA4FuIEegX2ws8PSp9q+ihp1GDSoWUthoqh3TKu5s4xvOs4GZm6IZX9SOhMqa8DWpxpKtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169178; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=z/cwKccCO6TzDm0KBf/XNX1ldLGoAizL2obuZ6Hd33w=; b=CqcKPDgwCwbPLYksw1oJ67FTS7qM/2oqYqyn0wKSnqqTxO5sCcWdBlDO0Dm3w+bgKS9nOqegIJGLO4Y+jrudKOYxV/rBsTk0fdSscoLOrbsVOdXAuyMfiS3JhlsRbczEsvvcLKqv5KE8Hps02qp3QIyooiNUXPjsHAwvcqGRN1k= 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 1778169178026563.3942603872886; Thu, 7 May 2026 08:52:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11z-0005Xe-Da; Thu, 07 May 2026 11:52:55 -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 1wL11x-0005RH-WB for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:54 -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 1wL11w-00041x-6U for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:53 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-488d2079582so11441885e9.2 for ; Thu, 07 May 2026 08:52:51 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169171; x=1778773971; 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; bh=z/cwKccCO6TzDm0KBf/XNX1ldLGoAizL2obuZ6Hd33w=; b=hZ4YWo+DmvFZutzEIUgjw0WhNUUtRlICBjMH/1hzOmyl3QBIl15fMobn3f6DZanSw+ xEboAJJ/F94zl5QgGiQNicJB9J5CJmoTZKEg08CoqtrXy/ISIgyKX18sOaNNkwV1l5jt Urnqo9oR4dCmwFus4ZE1Icm7xj/FWw1Cg5lu65MLAyhRz0vWnnQsrmHkjX5vEUCj8Fdv C59awN/VlhTcJLdvgyOW3vilCTmHjP9+lHa6NySvuRwi85RecyG1/tQEtvmg8nO3C5t/ FzZg5wjdbyzae9TZtz/btOzBJgf1BwUOMIlsQShWeWyucV6L2bBrGaSwjHyeTllzq27e Rp1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169171; x=1778773971; 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; bh=z/cwKccCO6TzDm0KBf/XNX1ldLGoAizL2obuZ6Hd33w=; b=IvE4/owJU8J26iCkHAtpqAu9dpf2tN39/m9E64jqotwxsBBX0WF81RT94CzurVS+VI hH+Ipce1uwQPqU3Qy4ID00v52v9/bI02G2Bm43HI0FWkWcinoQrH71MD7Xw1Oeto6fMz 6LMNqlKTvqXv98x0MV/R4hQ48c9IQw0YCWf+QpO9t/ZerldMs0moTqdj32A38FDqv+JB /4Xiw8kZ9Inx7e9JALfDTNoxvVD3UFfToUb7hl6BKw6Je3VZmBscr6ZFvjDDXT16yA4J 4JbGXH5rEQm3mjwtqLzdgAA1sU3iPuouU+RqgsjAIuKNlQS8opduuFzbVfUCWRo2ZKMr pVTg== X-Gm-Message-State: AOJu0YzZg9GC6Ui1wXTKRZg1woq+vBx3rkOW5rfB2TG4pBHl2AC80ian mkzl069ycJfn3aDPxvEMczWsKG9D6CgAN6LsGAfpquRizRJNY3zxAxYlbCKJgRx5EyQ70E41umT 9xPx1 X-Gm-Gg: AeBDieu53PaslDPfbLsok+Zut8wt9I4QM+wuSd8lKfkH0wQ2ceXWvqPAYkPQOXn8UIC x2+1GCgCbo9RhhoElOygaKqrkOnswc3lVJbsnZwqkqwTh/bNuBij6RzyKh5p735cYLB8V6wZ6Xt Ujy1R9mBKZZFGz3/2qrCi8fAQJaKNxSjJoPjA9nnM3nj3c3jC94v/gapNXHKX0fzgz5RwiKKVQe 0gqLJGhm03Z0+WeFGV3FY6DP9+JVvXN2+aZEl4IOOf7gZeZRdrQ7gRk//iMpw9w9VzTEj7xaNAf Kc3vpqQaH6MsNzfrG1zuYkSXD3X9apNx1MZFPuF05gwXMhLUKODnCH19sRGxux1juDnlGLr1EO4 jGCKi4h/wQmifigKE7oo3moPS85nklogWT1B7nwLVExlEg+GVqyOkbgK8wPLptelEnJq1XDZs6q +liDft/kMc+Y1OO3PAZsEJNgHcdnj5+l39+IFZJp9wJmxkNxQYOgA6pZhjWxuR7PVZ9yOQcPI9g hGNIR9IL7dhzKnQP4qnywXSe3m9qwA= X-Received: by 2002:a05:600c:8011:b0:48a:80cb:1bb4 with SMTP id 5b1f17b1804b1-48e51f3b00emr133225655e9.22.1778169170501; Thu, 07 May 2026 08:52:50 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 56/67] hw/arm/virt: Remember CPU phandles rather than looking them up by name Date: Thu, 7 May 2026 16:51:43 +0100 Message-ID: <20260507155154.1886557-57-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169179020158500 In fdt_add_cpu_nodes(), we currently add phandles for each CPU node if we are going to add a topology description, and when we do, we re-look-up the phandle by node name when creating the topology description. For GICv5 we will also want to refer to the CPU phandles; so always add a phandle, and keep track of those phandles in the VirtMachineState so we don't have to look them up by name in the dtb every time. The phandle property is extra data in the final DTB, but only a tiny amount, so it's not worth trying to carefully track the conditions when we're going to need them so we only emit them when required. (We need to change the smp_cpus variable to unsigned because otherwise gcc thinks that we might be passing a negative number to g_new0() and produces an error: /usr/include/glib-2.0/glib/gmem.h:270:19: error: argument 1 range [18446744= 071562067968, 18446744073709551615] exceeds maximum object size 92233720368= 54775807 [-Werror=3Dalloc-size-larger-than=3D] 270 | __p =3D g_##func##_n (__n, __s); \ | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gmem.h:332:57: note: in expansion of macro =E2= =80=98_G_NEW=E2=80=99 332 | #define g_new0(struct_type, n_structs) _G_NEW (str= uct_type, n_structs, malloc0) | ^~~~~~ ../../hw/arm/virt.c:469:25: note: in expansion of macro =E2=80=98g_new0=E2= =80=99 469 | vms->cpu_phandles =3D g_new0(uint32_t, smp_cpus); | ^~~~~~ ) Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-57-peter.maydell@linaro.org --- hw/arm/virt.c | 19 ++++++++++--------- include/hw/arm/virt.h | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index fe19030886..58e05acb8c 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -595,14 +595,14 @@ static bool partial_cache_description(const MachineSt= ate *ms, int num_caches) return false; } =20 -static void fdt_add_cpu_nodes(const VirtMachineState *vms) +static void fdt_add_cpu_nodes(VirtMachineState *vms) { int cpu; int addr_cells =3D 1; const MachineState *ms =3D MACHINE(vms); const MachineClass *mc =3D MACHINE_GET_CLASS(ms); const VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); - int smp_cpus =3D ms->smp.cpus; + unsigned int smp_cpus =3D ms->smp.cpus; int socket_id, cluster_id, core_id; uint32_t next_level =3D 0; uint32_t socket_offset =3D 0; @@ -656,6 +656,8 @@ static void fdt_add_cpu_nodes(const VirtMachineState *v= ms) qemu_fdt_setprop_cell(ms->fdt, "/cpus", "#address-cells", addr_cells); qemu_fdt_setprop_cell(ms->fdt, "/cpus", "#size-cells", 0x0); =20 + vms->cpu_phandles =3D g_new0(uint32_t, smp_cpus); + for (cpu =3D smp_cpus - 1; cpu >=3D 0; cpu--) { socket_id =3D cpu / (ms->smp.clusters * ms->smp.cores * ms->smp.th= reads); cluster_id =3D cpu / (ms->smp.cores * ms->smp.threads) % ms->smp.c= lusters; @@ -665,6 +667,7 @@ static void fdt_add_cpu_nodes(const VirtMachineState *v= ms) ARMCPU *armcpu =3D ARM_CPU(qemu_get_cpu(cpu)); CPUState *cs =3D CPU(armcpu); const char *prefix =3D NULL; + uint32_t phandle; =20 qemu_fdt_add_subnode(ms->fdt, nodename); qemu_fdt_setprop_string(ms->fdt, nodename, "device_type", "cpu"); @@ -689,10 +692,9 @@ static void fdt_add_cpu_nodes(const VirtMachineState *= vms) ms->possible_cpus->cpus[cs->cpu_index].props.node_id); } =20 - if (!vmc->no_cpu_topology) { - qemu_fdt_setprop_cell(ms->fdt, nodename, "phandle", - qemu_fdt_alloc_phandle(ms->fdt)); - } + phandle =3D qemu_fdt_alloc_phandle(ms->fdt); + qemu_fdt_setprop_cell(ms->fdt, nodename, "phandle", phandle); + vms->cpu_phandles[cpu] =3D phandle; =20 if (!vmc->no_cpu_topology && num_cache) { for (uint8_t i =3D 0; i < num_cache; i++) { @@ -847,7 +849,6 @@ static void fdt_add_cpu_nodes(const VirtMachineState *v= ms) qemu_fdt_add_subnode(ms->fdt, "/cpus/cpu-map"); =20 for (cpu =3D smp_cpus - 1; cpu >=3D 0; cpu--) { - char *cpu_path =3D g_strdup_printf("/cpus/cpu@%d", cpu); char *map_path; =20 if (ms->smp.threads > 1) { @@ -865,10 +866,10 @@ static void fdt_add_cpu_nodes(const VirtMachineState = *vms) cpu % ms->smp.cores); } qemu_fdt_add_path(ms->fdt, map_path); - qemu_fdt_setprop_phandle(ms->fdt, map_path, "cpu", cpu_path); + qemu_fdt_setprop_cell(ms->fdt, map_path, "cpu", + vms->cpu_phandles[cpu]); =20 g_free(map_path); - g_free(cpu_path); } } } diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 13e135a460..b74ffada7e 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -176,6 +176,7 @@ struct VirtMachineState { uint32_t gic_phandle; uint32_t msi_phandle; uint32_t iommu_phandle; + uint32_t *cpu_phandles; int psci_conduit; uint8_t virtio_transports; hwaddr highest_gpa; --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169304; cv=none; d=zohomail.com; s=zohoarc; b=Q5RYiMSHaK+WNcmhQyiiN3xbfWuV7sDwAttFlOrdYs3ko06tPpMoDW/5HGPmQj1uZqX2W7BBwAHZviW2D4iXVYtQDR9O4zWL7u23QSoWNfnATKF8cH+SvglX7WP007Meebkpo/UKkib7bsy2KVSJ9m6KPaCgXg9KBDE2NK+5Uzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169304; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=qmukM0rLu6/TpUZJMyD0+LRnOOucPeGB4MUjHA3sUKU=; b=WjvHCJGXvQBBgsR55BnEnAbxDnAJF8Mi7CAtyA33VZ0mFN575VjhZnXld7ltfK5SCi5cjQuIpQQZxCMSPtI1Ftg4Vo6nL4g1F5Y3neFaUtTLz9BcC3Y2GOrj8lG07Q66gX9Izk8BySNf1Ornd1rVn6a4Pk/7Lelyq/vOibwsrHk= 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 1778169304348315.66056332350263; Thu, 7 May 2026 08:55:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL11z-0005a1-U9; Thu, 07 May 2026 11:52:55 -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 1wL11y-0005Vn-K2 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:54 -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 1wL11w-00042F-Vw for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:54 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4896c22fcbaso10538695e9.0 for ; Thu, 07 May 2026 08:52:52 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169171; x=1778773971; 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; bh=qmukM0rLu6/TpUZJMyD0+LRnOOucPeGB4MUjHA3sUKU=; b=ikPn8yOAEJn8OEVTWJVlnWqKouN44EdQy3nCz1X3vVSOwkJqiBol8rdUp77IKq0Uch NiJw6SPwSHBhKLOYGOls/9ywwu16OsxcBhVrHSqr+Fj1CNdRZ8N2m5B7V4wXMFMbGC+H WID4hjTNU9EfofZwuf5FYFB4m6roBn+njbJyaEq8awgkr+UO547wWqeYs36uwwNG8h8i iIUp8NwaVad/i/lhM1ekN6Rl0GN8BIZdv7Sa4w4pvEKPnyTejOl8WR7uIq3eRiLam5VL qMNLKEMQtbBYJkHByFEXCwJ0fsCmHTyqOBJ/o6XxJWZFi3NDm68ghf0CwovrUunNdHKe af1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169171; x=1778773971; 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; bh=qmukM0rLu6/TpUZJMyD0+LRnOOucPeGB4MUjHA3sUKU=; b=dl38cWyc+HKUGblRKcioH9qXlQkCRGOo8pv32MzedQpVztaU5N8wu2etOK6PJkrCx1 5GvKkRcEDs4R0OcSUOQ9kRooz/3cQlqp5UBQgOUWpTbf2HI2TfDwDxeL8gHcoodpGh98 GY3hEqbv2K7ypgNI80GxWebfWOl5k+N3cI1SEgPaw1g/90GS7F3oDCsI0/UfSJHwNgDx uZ1XqBD9yswSHrClHdhfXL34UrGmNHq86Eoy6hFIvcy3qGykUJSxvFfM9/TYLyf1ejKi YjLudGwmXG0t/xft4j58Yzu0fSn5j8RKmj/9JBowYXBYAFRN/zfe3wSIbBu6HzgG+tAI Ri+w== X-Gm-Message-State: AOJu0YxpnEj96HWzMY7gGAumkB37xoJYNae700xZkSa3P6E5VeszzaKS euI1k6qzXLNDs2t04wS7Ox0+eMzhtTBbMcaC8G/s2VCjtcv6qwv4FvVlrcaEMwo6d5mGlhPNa0e +6Npv X-Gm-Gg: AeBDieu2yYHssua6rXuwoWVAGtWKMfufR2BSeXQla+bvayAQQUQdKyLnk1tOejqCsD2 n294zs54jQRKM8nm2fsffx/IaVljGoppJyeEfHMqLQYTV697wnQ6naKlNmd2rfMlFSz2O1bKXLt KejORWJ0R4t2g3dSQNfQu0kmXJFxxC6tW8+bYUdX3mDFXPkH1GCOT3ajczxouOlC2bVJZQn56DQ XVJSxhsZZLdXbAcZ+T0C3yYM3WKSQC0zoKxXwAUWqBRxWDdwt6Ssq9Pvd5NyptWyLay10c73qor 0H7o18FE1iBllToM7Ec65nUmn1XR2bNJGD0wEpUZRLiGIUtLI5AGHgnXGN+uXySSqBBkFLH/r/Z oVtJOD9o7Ldbp14xGTeUUklyHnb33Bm3poG0ppCV8Wz4yRw0pXn1v0OTMf0cJTMwm4jE4L4aAlu SbGAQ3fwGgP+ktK8ek5VO3K49xj7kcjisWeX2tXF5hWJgL406vtduvIpwglCYu+BWo5t9jw+qKZ RhoKiplfbHeG+6u X-Received: by 2002:a05:600c:354b:b0:486:fa35:aef2 with SMTP id 5b1f17b1804b1-48e51e0c802mr134888425e9.4.1778169171409; Thu, 07 May 2026 08:52:51 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 57/67] hw/arm/virt: Move MSI controller creation out of create_gic() Date: Thu, 7 May 2026 16:51:44 +0100 Message-ID: <20260507155154.1886557-58-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169305567154100 The create_gic() function also creates the MSI controller; however there isn't really a strong linkage here, and for the GICv5 it will be more convenient to separate it out. Move it to a new create_msi_controller() function. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-58-peter.maydell@linaro.org --- hw/arm/virt.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 58e05acb8c..a8d7f47040 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1285,11 +1285,21 @@ static void create_gic(VirtMachineState *vms, Memor= yRegion *mem) } =20 fdt_add_gic_node(vms); +} =20 - if (vms->msi_controller =3D=3D VIRT_MSI_CTRL_ITS) { +static void create_msi_controller(VirtMachineState *vms) +{ + switch (vms->msi_controller) { + case VIRT_MSI_CTRL_ITS: create_its(vms); - } else if (vms->msi_controller =3D=3D VIRT_MSI_CTRL_GICV2M) { + break; + case VIRT_MSI_CTRL_GICV2M: create_v2m(vms); + break; + case VIRT_MSI_CTRL_NONE: + break; + default: + g_assert_not_reached(); } } =20 @@ -2856,6 +2866,7 @@ static void machvirt_init(MachineState *machine) virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); =20 create_gic(vms, sysmem); + create_msi_controller(vms); =20 virt_post_cpus_gic_realized(vms, sysmem); =20 --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169493; cv=none; d=zohomail.com; s=zohoarc; b=U87YV2DXX8vuq0egS8h/1+Y0Q7oKE+MtHLBOcyU4JzEO4vLLeResb28DZqvdazFE/1zbs7/KqVqyV7wyJFTDxYQOjMynI58QB+y3EP3GH2ieuWaeaKpDI3eYOP1VSdGpNE6ZpufR5CkzuDYyYmTDfGJaY7Vxyma4IQIBrJIoFmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169493; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Mfq83WZ4PULn58rY5bmuikLWUST1RAMZv6NSXVPx6zs=; b=Z2wdkkFLAwgAWso5wfR65IQfU+mEPY6oI+J8xrgcbg9vK4JvI0GiBliAzHD2ojY/iZLn7sQ5KNtSCFw21oHLm02MDYXCvM/acRtU7bR0nIfmxw0aUgFWE4Rged9f/y3BWrPHx7nKy8cnFhJNAmBRQFqs6gOEx+h1HNy2GznB0BI= 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 177816949387599.70726827039039; Thu, 7 May 2026 08:58:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL125-0005r6-Qt; Thu, 07 May 2026 11:53:01 -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 1wL120-0005aR-0N for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:56 -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 1wL11y-00042W-0l for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:55 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-488b0e1b870so15308575e9.2 for ; Thu, 07 May 2026 08:52:53 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169173; x=1778773973; 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; bh=Mfq83WZ4PULn58rY5bmuikLWUST1RAMZv6NSXVPx6zs=; b=QTNhF8nRSoO4JPF7NXghN8IUSqMf+eICAlH/SrFfrK0zZKhf1aFHyhNQSm/FjiKk8K IVGsc1MvPNcI1SBF1rpklsqpYDQVOC1whHAQMffyRH4Catu+LW/SaKVeA1FI9lMG1Oez 8sP30jDseSKyhO6vM46lJ6mYf0Sq+KEzE3k067MYV2X7weLFb2NmzxLrms4nkZu1pLXk oJG3L5YTm2UXX79M3swyTWcERU80CDo/kyuWMLOa4ZVx9SQlrrA9w4BFeYTCwZQnO/XD t+tzrk/LaT3IEKxEJgwoGTK02c+rmi6TmJLtvyHxjtbmgPPhEQAXxK8q150TcXqvQ5Fq AotQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169173; x=1778773973; 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; bh=Mfq83WZ4PULn58rY5bmuikLWUST1RAMZv6NSXVPx6zs=; b=YOTIxCj3Mqbri46E7MplBN0bG46jPx/JaBgM/dseyJNd5Zbw4uMIENgdOSOXlY4cQP +qKy37XPFI5UQ8Jt9pXIETH+psFgOC/bdZBzF4WhqK0u2POFr9q5WRKCD0fWOVHPgrpi AQ7DUqgRfD7nz/qrcVIKTxlT6wFuYUcVWtL7a2KRIvVnS91mPjLzikZko9PUDtn0GVHc 0334Tv+DZA/uiDpPMX4rJzVLxNNaTEggSKvyQPMUDaPJ4UGjkynRtpDlPzlGHx2lB3ZN i5ynVdmq/60Zh0j+KZF8xxSLI+iOW/EDpZArdMzzAgWx3YFgpkvfinjhuG7EXHalnTs0 TKPw== X-Gm-Message-State: AOJu0YwIyIYXmivCisE+JBh+gTikyi5MIe4lt6Ya6bIqBn3zbVfNm06A mkCSOSnOQoxqCQ8lrrQOkP93Fed4BpIGXZOKpczQ1/6jYGL6tOsGqDs4zALMSFc1gm/reIMGrik GQxmo X-Gm-Gg: AeBDievb5MUUt8nnm+vuRS5e5Vm1n4pp/ATMQd131/V/6sA3EBYtuHi1e4XgRr3vUDP 0xwTd/nE9gBXBgG46IVVhiFV9Q013p/SSmcZYNVAPRdAqV7QsejhROK0gv08l50O6jxVqAVpQlC Ji8BFy9nH8lPolmrOJ+ORm/DGtEGvZ2y4H4nDYF7AOkYn8rfO3d41jcSDgn6/UD9/ETy4ppcMEA nTIe/dwiDW6au28n56tRZn9XvW+LtulvNM4aZY9CQWz3xI4RMM52Em1hwDUHnWt6T93DgzW3Vx7 ZvX5jv4Qa64GRKsiBASDaUiDyYmqCOtlwZbb8bgK0EFQiAvIE/LVvBeJnFRIec+xIgCFngYzusP cDWmjtnkJKuXKeE3a9MhT48zt1yZQbo8UPdEczZso7x/xidwkMydjFaxAV4+BQuTGDMgr7j3mTt x+LlN4nnRDsEneVIfHTACW+fInIXgdaRnkFiDzreCyvGqzyVA/1hRjGPKKZZnMxWIwIAAClcEB4 3XL8bzU77AT7gR6DksaZthKm8d84qI= X-Received: by 2002:a05:600c:8115:b0:48a:9540:1a3a with SMTP id 5b1f17b1804b1-48e51e196f9mr134765025e9.8.1778169172427; Thu, 07 May 2026 08:52:52 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 58/67] hw/arm/virt: Pull "wire CPU interrupts" out of create_gic() Date: Thu, 7 May 2026 16:51:45 +0100 Message-ID: <20260507155154.1886557-59-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169494997158500 create_gic() is quite long and mixes GICv2 and GICv3 even though they're mostly different in their creation. As a preliminary to splitting it up, pull out the "wire the CPU interrupts to the GIC PPI inputs" code out into its own function. This is a long and self-contained piece of code that is the main thing that we need to do basically the same way for GICv2 and GICv3. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-59-peter.maydell@linaro.org --- hw/arm/virt.c | 126 +++++++++++++++++++++++++++----------------------- 1 file changed, 68 insertions(+), 58 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index a8d7f47040..57f56a86c9 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1120,13 +1120,79 @@ static bool gicv3_nmi_present(VirtMachineState *vms) (vms->gic_version !=3D VIRT_GIC_VERSION_2); } =20 +static void gic_connect_ppis(VirtMachineState *vms) +{ + /* + * Wire the outputs from each CPU's generic timer and the GICv3 + * maintenance interrupt signal to the appropriate GIC PPI inputs, + * and the GIC's IRQ/FIQ/VIRQ/VFIQ/NMI/VINMI interrupt outputs to the + * CPU's inputs. + */ + MachineState *ms =3D MACHINE(vms); + unsigned int smp_cpus =3D ms->smp.cpus; + SysBusDevice *gicbusdev =3D SYS_BUS_DEVICE(vms->gic); + + for (int i =3D 0; i < smp_cpus; i++) { + DeviceState *cpudev =3D DEVICE(qemu_get_cpu(i)); + int intidbase =3D NUM_IRQS + i * GIC_INTERNAL; + /* + * Mapping from the output timer irq lines from the CPU to the + * GIC PPI inputs we use for the virt board. + */ + const int timer_irq[] =3D { + [GTIMER_PHYS] =3D ARCH_TIMER_NS_EL1_IRQ, + [GTIMER_VIRT] =3D ARCH_TIMER_VIRT_IRQ, + [GTIMER_HYP] =3D ARCH_TIMER_NS_EL2_IRQ, + [GTIMER_SEC] =3D ARCH_TIMER_S_EL1_IRQ, + [GTIMER_HYPVIRT] =3D ARCH_TIMER_NS_EL2_VIRT_IRQ, + [GTIMER_S_EL2_PHYS] =3D ARCH_TIMER_S_EL2_IRQ, + [GTIMER_S_EL2_VIRT] =3D ARCH_TIMER_S_EL2_VIRT_IRQ, + }; + + for (unsigned irq =3D 0; irq < ARRAY_SIZE(timer_irq); irq++) { + qdev_connect_gpio_out(cpudev, irq, + qdev_get_gpio_in(vms->gic, + intidbase + timer_irq[i= rq])); + } + + if (vms->gic_version !=3D VIRT_GIC_VERSION_2) { + qemu_irq irq =3D qdev_get_gpio_in(vms->gic, + intidbase + ARCH_GIC_MAINT_IRQ= ); + qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interru= pt", + 0, irq); + } else if (vms->virt) { + qemu_irq irq =3D qdev_get_gpio_in(vms->gic, + intidbase + ARCH_GIC_MAINT_IRQ= ); + sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, irq); + } + + qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, + qdev_get_gpio_in(vms->gic, intidbase + + VIRTUAL_PMU_IRQ)); + + sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_= IRQ)); + sysbus_connect_irq(gicbusdev, i + smp_cpus, + qdev_get_gpio_in(cpudev, ARM_CPU_FIQ)); + sysbus_connect_irq(gicbusdev, i + 2 * smp_cpus, + qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ)); + sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus, + qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); + + if (vms->gic_version !=3D VIRT_GIC_VERSION_2) { + sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, + qdev_get_gpio_in(cpudev, ARM_CPU_NMI)); + sysbus_connect_irq(gicbusdev, i + 5 * smp_cpus, + qdev_get_gpio_in(cpudev, ARM_CPU_VINMI)); + } + } +} + static void create_gic(VirtMachineState *vms, MemoryRegion *mem) { MachineState *ms =3D MACHINE(vms); /* We create a standalone GIC */ SysBusDevice *gicbusdev; const char *gictype; - int i; unsigned int smp_cpus =3D ms->smp.cpus; uint32_t nb_redist_regions =3D 0; int revision; @@ -1226,63 +1292,7 @@ static void create_gic(VirtMachineState *vms, Memory= Region *mem) } } =20 - /* Wire the outputs from each CPU's generic timer and the GICv3 - * maintenance interrupt signal to the appropriate GIC PPI inputs, - * and the GIC's IRQ/FIQ/VIRQ/VFIQ/NMI/VINMI interrupt outputs to the - * CPU's inputs. - */ - for (i =3D 0; i < smp_cpus; i++) { - DeviceState *cpudev =3D DEVICE(qemu_get_cpu(i)); - int intidbase =3D NUM_IRQS + i * GIC_INTERNAL; - /* Mapping from the output timer irq lines from the CPU to the - * GIC PPI inputs we use for the virt board. - */ - const int timer_irq[] =3D { - [GTIMER_PHYS] =3D ARCH_TIMER_NS_EL1_IRQ, - [GTIMER_VIRT] =3D ARCH_TIMER_VIRT_IRQ, - [GTIMER_HYP] =3D ARCH_TIMER_NS_EL2_IRQ, - [GTIMER_SEC] =3D ARCH_TIMER_S_EL1_IRQ, - [GTIMER_HYPVIRT] =3D ARCH_TIMER_NS_EL2_VIRT_IRQ, - [GTIMER_S_EL2_PHYS] =3D ARCH_TIMER_S_EL2_IRQ, - [GTIMER_S_EL2_VIRT] =3D ARCH_TIMER_S_EL2_VIRT_IRQ, - }; - - for (unsigned irq =3D 0; irq < ARRAY_SIZE(timer_irq); irq++) { - qdev_connect_gpio_out(cpudev, irq, - qdev_get_gpio_in(vms->gic, - intidbase + timer_irq[i= rq])); - } - - if (vms->gic_version !=3D VIRT_GIC_VERSION_2) { - qemu_irq irq =3D qdev_get_gpio_in(vms->gic, - intidbase + ARCH_GIC_MAINT_IRQ= ); - qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interru= pt", - 0, irq); - } else if (vms->virt) { - qemu_irq irq =3D qdev_get_gpio_in(vms->gic, - intidbase + ARCH_GIC_MAINT_IRQ= ); - sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, irq); - } - - qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, - qdev_get_gpio_in(vms->gic, intidbase - + VIRTUAL_PMU_IRQ)); - - sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_= IRQ)); - sysbus_connect_irq(gicbusdev, i + smp_cpus, - qdev_get_gpio_in(cpudev, ARM_CPU_FIQ)); - sysbus_connect_irq(gicbusdev, i + 2 * smp_cpus, - qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ)); - sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus, - qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); - - if (vms->gic_version !=3D VIRT_GIC_VERSION_2) { - sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, - qdev_get_gpio_in(cpudev, ARM_CPU_NMI)); - sysbus_connect_irq(gicbusdev, i + 5 * smp_cpus, - qdev_get_gpio_in(cpudev, ARM_CPU_VINMI)); - } - } + gic_connect_ppis(vms); =20 fdt_add_gic_node(vms); } --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169291; cv=none; d=zohomail.com; s=zohoarc; b=gDOQiTlXk/KpTbeCHBZpXJwmdoKNdmU9W1tO035XuF39fxy7Hxohvy7ELSKk9a6eR7zrxEeVq67UQTbrknf3tjCLFkWJlx6dJH+8iFmxAwk4nXAXfs7t2i2pvA5oVKUniXtwCWPFDKxv32qVwcHRe/1fJZ8hAKElVo3LHF59U2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169291; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=bDQ9CNZN1AP0UdFin3eH4ri58X8eMrz779lTm/Wdc10=; b=Y6+G2qC6RhNPvoamKgyB0nFh5ll8hEynhfOWmNfmN//p4DBGcdx016x6Mxp9m08GzcqUQ3HrsR6U2aeM7RClpNIr9Ze7OOhne+BYtbXIX4GFfX1wc2ynNIbKOtNRSZA3NAhjH9W8xYdOspEl27gib2vPsmWHT7aABRiaBvfb4rc= 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 1778169291194335.3121574532879; Thu, 7 May 2026 08:54:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL122-0005n5-Ud; Thu, 07 May 2026 11:52: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 1wL121-0005iy-PM for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:57 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wL11z-00042q-Ld for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:57 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-44509921fbcso570810f8f.3 for ; Thu, 07 May 2026 08:52:55 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169174; x=1778773974; 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; bh=bDQ9CNZN1AP0UdFin3eH4ri58X8eMrz779lTm/Wdc10=; b=gWM5v7yh0WSnGkEXILR9VYJZi/BIGt6+e/fAcbHNHI3ES7D5QUUya3oWisep1qchU+ Z20VCz2I/I9w54Wgu4ARG/ybvTzE/z2P4RGibm/unfjbeJ7l8wyT0tKIsl8rfSPT/IKL 409vIrYwp1f6T4p3Qd7oViUiXhlLSoludYcqHUWN16cHy0e0JxCA4HoYuDn2qgIkuShx 7BDmu8bvxOU1L/UygwGGitMaqqgFgSVSNFLULVbZeVNh/2rFkowrwvKeximoxrCO4Nn2 xWLiUTri3xP5s2DKEUfRhOx29tSvSbpS5eq7Imt0ng8NGvf7hKIcDGspwODG/TLc7u4x Yogw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169174; x=1778773974; 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; bh=bDQ9CNZN1AP0UdFin3eH4ri58X8eMrz779lTm/Wdc10=; b=cKIdJeSRQ4f01sQOrdlRsgD0U/Vd6Fx6zz44Q7zcWdHpH3KUSQJMq0yDBEwR4bzyqv uJ61hU98mNsfGGfNEo2lCrtDO957wecLcDpZKoLa09M4X3JuAepj/bea9e7de2FBazD/ ZmILFsMvSfFtpvHofJ5P9OiNsbfvGB1RvBXadu4jTTjuZVjx5cKnQLX8cA9WVkRA5wS3 r6ZSjT9hBHc3WxRrEgWHcSYy7qCddIXWsEENy/AEGMb9vCddQtTAGuVWyhu3ow3aGftB YKuG51VR/eAqfdI9nr3SV+jeAJxDut8224FHZO/e5tXRqWQpQw7A4gJxOlVQDjZWRb9V nrbg== X-Gm-Message-State: AOJu0YxCRU9fdyZWVbRxihC3aGO7BkE3ahx0QdQRWNtWhLYwYrRJ2Q4b +kxq+kKgYYOQnQaYV61Sq3iieO6ooK/xfjylOsJh6hJYR7nw+E8ZOnPfSbU9+mneRpxD3kN0ZSP JGFSD X-Gm-Gg: AeBDietmysrzsKcKAp3CUgFUYoL3qieWAXUq+vYvMrXOUPY4j2tuyjC7JZDzGSno4b9 OUKX8xlfCPTtscOlvTeY1OiE0XNAoRtchmhgVNXS9agYcDYnAdAZWyqcBAESGzvyPrnldVWVH6t Ut2I4x+vn3Zn5PWuZukKrEGWS3UswxneFgXW8QXMjfrz9JlkH4Ab6wR5ZEoxdnD88xTUD3UJ66U QNtqcBDcWS2JFztdoj/gxs98eTwF1GEV/GYd1bF5KSi6FOIZy8SLRTeLN+26V+2s6nP/6o1qqSE Aov9t8QbU3PyuiCeTavZjV19D5mKW83LMmesP7hhwYf+dHIjwoCXM2UNF4uyKiske0Eenfx/sAW qb/4tfivysq5Ye2+zcpXfD//hcvjEixvGfU1ET4iWFq9S+P/QZWCofdgycGyvZNjkMVOcqB4F1R TMBBtvvKJuMoPOAONgq5sT0Tl07eocs6wsDAa5Q2XrIGOvwMlER3C/YTAM3epp+z2kJ0/D3xCeq VmWRnabDxiLu0ocVG6PNoWd3WvSPpFLvdBmSJ8Woori6I5V/nJ/ X-Received: by 2002:a05:600c:a08b:b0:489:1ba8:5bf0 with SMTP id 5b1f17b1804b1-48e51f4119bmr138775365e9.21.1778169173265; Thu, 07 May 2026 08:52:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 59/67] hw/arm/virt: Split GICv2 and GICv3/4 creation Date: Thu, 7 May 2026 16:51:46 +0100 Message-ID: <20260507155154.1886557-60-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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: 1778169293506154100 Content-Type: text/plain; charset="utf-8" Currently create_gic() handles GICv2 and GICv3/4 in a single function, with large sections that are conditional on the vms->gic_version. GICv5 will be different to both. Refactor into create_gicv2() and create_gicv3(). Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-60-peter.maydell@linaro.org --- hw/arm/virt.c | 139 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 56 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 57f56a86c9..2475d583cc 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1187,26 +1187,58 @@ static void gic_connect_ppis(VirtMachineState *vms) } } =20 -static void create_gic(VirtMachineState *vms, MemoryRegion *mem) +static void create_gicv2(VirtMachineState *vms, MemoryRegion *mem) { MachineState *ms =3D MACHINE(vms); /* We create a standalone GIC */ SysBusDevice *gicbusdev; - const char *gictype; unsigned int smp_cpus =3D ms->smp.cpus; - uint32_t nb_redist_regions =3D 0; - int revision; =20 - if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { - gictype =3D gic_class_name(); - } else { - gictype =3D gicv3_class_name(); + if (kvm_enabled() && vms->virt) { + error_report("KVM EL2 is only supported with in-kernel GICv3"); + exit(1); } =20 + vms->gic =3D qdev_new(gic_class_name()); + qdev_prop_set_uint32(vms->gic, "revision", 2); + qdev_prop_set_uint32(vms->gic, "num-cpu", smp_cpus); + /* + * Note that the num-irq property counts both internal and external + * interrupts; there are always 32 of the former (mandated by GIC spec= ). + */ + qdev_prop_set_uint32(vms->gic, "num-irq", NUM_IRQS + 32); + if (!kvm_irqchip_in_kernel()) { + qdev_prop_set_bit(vms->gic, "has-security-extensions", vms->secure= ); + qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", vms->= virt); + } + + gicbusdev =3D SYS_BUS_DEVICE(vms->gic); + sysbus_realize_and_unref(gicbusdev, &error_fatal); + sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base); + sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_CPU].base); + if (vms->virt) { + sysbus_mmio_map(gicbusdev, 2, vms->memmap[VIRT_GIC_HYP].base); + sysbus_mmio_map(gicbusdev, 3, vms->memmap[VIRT_GIC_VCPU].base); + } + + gic_connect_ppis(vms); + + fdt_add_gic_node(vms); +} + +static void create_gicv3(VirtMachineState *vms, MemoryRegion *mem) +{ + MachineState *ms =3D MACHINE(vms); + /* We create a standalone GIC */ + SysBusDevice *gicbusdev; + unsigned int smp_cpus =3D ms->smp.cpus; + uint32_t nb_redist_regions; + int revision; + QList *redist_region_count; + uint32_t redist0_capacity =3D virt_redist_capacity(vms, VIRT_GIC_REDIS= T); + uint32_t redist0_count =3D MIN(smp_cpus, redist0_capacity); + switch (vms->gic_version) { - case VIRT_GIC_VERSION_2: - revision =3D 2; - break; case VIRT_GIC_VERSION_3: revision =3D 3; break; @@ -1223,10 +1255,11 @@ static void create_gic(VirtMachineState *vms, Memor= yRegion *mem) exit(1); } =20 - vms->gic =3D qdev_new(gictype); + vms->gic =3D qdev_new(gicv3_class_name()); qdev_prop_set_uint32(vms->gic, "revision", revision); qdev_prop_set_uint32(vms->gic, "num-cpu", smp_cpus); - /* Note that the num-irq property counts both internal and external + /* + * Note that the num-irq property counts both internal and external * interrupts; there are always 32 of the former (mandated by GIC spec= ). */ qdev_prop_set_uint32(vms->gic, "num-irq", NUM_IRQS + 32); @@ -1234,41 +1267,29 @@ static void create_gic(VirtMachineState *vms, Memor= yRegion *mem) qdev_prop_set_bit(vms->gic, "has-security-extensions", vms->secure= ); } =20 - if (vms->gic_version !=3D VIRT_GIC_VERSION_2) { - QList *redist_region_count; - uint32_t redist0_capacity =3D virt_redist_capacity(vms, VIRT_GIC_R= EDIST); - uint32_t redist0_count =3D MIN(smp_cpus, redist0_capacity); + nb_redist_regions =3D virt_gicv3_redist_region_count(vms); =20 - nb_redist_regions =3D virt_gicv3_redist_region_count(vms); + redist_region_count =3D qlist_new(); + qlist_append_int(redist_region_count, redist0_count); + if (nb_redist_regions =3D=3D 2) { + uint32_t redist1_capacity =3D + virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); =20 - redist_region_count =3D qlist_new(); - qlist_append_int(redist_region_count, redist0_count); - if (nb_redist_regions =3D=3D 2) { - uint32_t redist1_capacity =3D - virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); + qlist_append_int(redist_region_count, + MIN(smp_cpus - redist0_count, redist1_capacity)); + } + qdev_prop_set_array(vms->gic, "redist-region-count", redist_region_cou= nt); =20 - qlist_append_int(redist_region_count, - MIN(smp_cpus - redist0_count, redist1_capacity)); - } - qdev_prop_set_array(vms->gic, "redist-region-count", - redist_region_count); - - if (!kvm_irqchip_in_kernel() && - !(hvf_enabled() && hvf_irqchip_in_kernel())) { - if (vms->tcg_its) { - object_property_set_link(OBJECT(vms->gic), "sysmem", - OBJECT(mem), &error_fatal); - qdev_prop_set_bit(vms->gic, "has-lpi", true); - } - } else if (vms->virt) { - qdev_prop_set_uint32(vms->gic, "maintenance-interrupt-id", - ARCH_GIC_MAINT_IRQ); - } - } else { - if (!kvm_irqchip_in_kernel() && !hvf_irqchip_in_kernel()) { - qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", - vms->virt); + if (!kvm_irqchip_in_kernel() && + !(hvf_enabled() && hvf_irqchip_in_kernel())) { + if (vms->tcg_its) { + object_property_set_link(OBJECT(vms->gic), "sysmem", OBJECT(me= m), + &error_fatal); + qdev_prop_set_bit(vms->gic, "has-lpi", true); } + } else if (vms->virt) { + qdev_prop_set_uint32(vms->gic, "maintenance-interrupt-id", + ARCH_GIC_MAINT_IRQ); } =20 if (gicv3_nmi_present(vms)) { @@ -1278,18 +1299,9 @@ static void create_gic(VirtMachineState *vms, Memory= Region *mem) gicbusdev =3D SYS_BUS_DEVICE(vms->gic); sysbus_realize_and_unref(gicbusdev, &error_fatal); sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base); - if (vms->gic_version !=3D VIRT_GIC_VERSION_2) { - sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_REDIST].base); - if (nb_redist_regions =3D=3D 2) { - sysbus_mmio_map(gicbusdev, 2, - vms->memmap[VIRT_HIGH_GIC_REDIST2].base); - } - } else { - sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_CPU].base); - if (vms->virt) { - sysbus_mmio_map(gicbusdev, 2, vms->memmap[VIRT_GIC_HYP].base); - sysbus_mmio_map(gicbusdev, 3, vms->memmap[VIRT_GIC_VCPU].base); - } + sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_REDIST].base); + if (nb_redist_regions =3D=3D 2) { + sysbus_mmio_map(gicbusdev, 2, vms->memmap[VIRT_HIGH_GIC_REDIST2].b= ase); } =20 gic_connect_ppis(vms); @@ -1297,6 +1309,21 @@ static void create_gic(VirtMachineState *vms, Memory= Region *mem) fdt_add_gic_node(vms); } =20 +static void create_gic(VirtMachineState *vms, MemoryRegion *mem) +{ + switch (vms->gic_version) { + case VIRT_GIC_VERSION_2: + create_gicv2(vms, mem); + break; + case VIRT_GIC_VERSION_3: + case VIRT_GIC_VERSION_4: + create_gicv3(vms, mem); + break; + default: + g_assert_not_reached(); + } +} + static void create_msi_controller(VirtMachineState *vms) { switch (vms->msi_controller) { --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169454; cv=none; d=zohomail.com; s=zohoarc; b=eKzh/5DoVuRGWFKbldMDSZ/5WURhS9KaepKK5lBffaEWlpPELxCDVP1ZeKcWoWC/ncCF7nRq4hNUUKGbdmJbEfKqv0oJpQS2eQ2dNAy6i8iW5hL0tB7gHqQGWliGjqEFg2xHy3bBWH+ZrWXR5AZY6fccMJErhIKU+aTg+cZe8j4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169454; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=0vjExETreirHyQEBenl6DOZ9G0i3KJ1YXzOqbb5GT7w=; b=kV2S4P2xLegXVvitNjaIGQXF4ctpKTM4efRxRhu1mJtwg0VucN8Jgywk8K9FvOTKHUKTyPiGBWvTKlSSfsIE4yltGtK8TsMnrn55qyhANTnZuFckG+jY7yBq3vWQ8VzWynPm/3mpCTG73KnJ2JqxebtBRK85IcVu/1nCuU8qafg= 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 1778169454515747.4754109408095; Thu, 7 May 2026 08:57:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL123-0005ng-Cc; Thu, 07 May 2026 11:52:59 -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 1wL122-0005kR-4Q for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:58 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wL11z-00042t-TL for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:57 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-488b8bc6bc9so6701555e9.3 for ; Thu, 07 May 2026 08:52:55 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169174; x=1778773974; 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; bh=0vjExETreirHyQEBenl6DOZ9G0i3KJ1YXzOqbb5GT7w=; b=ys5GkSirO0rwFpMWji9B8qlgPplBYburdyRDKlUFJLhZpHmVd0cYVLwzptYbWtR44F b4aOIK7tLz0/tyQ1x3sYADMtu1tD2y/PsqZgCjZz/sNuTPPxzIuh8RcjiE1dPihFFLdG CzbNdtQOAtVW75g9PZ/P45kjjVaQCf8EAKZ/UUSXryZbHPS32jxp4tbrS5jnzDGOTwIq m2ft9PcDhBxjcVxC7boKlA0qNh1bVikdND/nAthVf48iQbzy95MesqQM1O7Xsdxw3tgq sTBi0y5I5jawjiHf5nHKq0VG6ouJT5G9xKJ6odNW3R/6B63wlCuH+7r5dqBOqhhcG1Ss 9mRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169174; x=1778773974; 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; bh=0vjExETreirHyQEBenl6DOZ9G0i3KJ1YXzOqbb5GT7w=; b=GLpfr/zl8l0lcZyZkr+9GrAcEZc5mx/l6JgCAlepE3F+uzQdOMzSgwNzJu6/3wghKK eRZStwQKMv242rXxDfxpkz7UI/p3xmMrA1c3WZD4BqTVJzgwg8yRLGACkDHrmhmdn4IU gJHBwKbhRRsmMbp+yRaUZfMEWon4JI1m4kGO8gK6/O0WfZ81Xh9Fm9foy+eRfaQGaM79 vS/BvmULeiYtoZhvMeqW1Lm3hMSRubDERR3b3/AVluEkv0Mua5eM0e1p0aaoi8MON84X +Fb41ZGTSZcRslWqsU1GkM57UUvWO9LL9gcpG9chlNdevnsVoN+Z4QICWo/1UDj2nzpe tYCg== X-Gm-Message-State: AOJu0YzdTPTdEW9QhThl5o55bQn/jCFRTBsBG3XArzvubd6Rd21+KirE oCWpbminyHAWhMsXrUhx9lBlIBrU0LBrzbBtMPmR8BWW/lA0K0/FrETkxh5+dIixm8pquMOE27q Ng+PB X-Gm-Gg: AeBDiesXXop2YlYYppivHGB7CBtqQut0AS3UMnlZlpWVfR5n9S5Y8DJFdEcwq7W6PYL /Etjz5oHp2RMjI3+/AnEyXJP2cYZFKJBuW8pPBp2dkF3Uzo2tX3A5MKqePdfQWKx+eC92/brsWN awHp/GOOH8wtgTFGAk2ZAkJQBmK9JyEt28mNEebk1HZMSwqWG5s0b22U5Am3TEXerUZrqJ3/mbZ EfiHFE80IaWUgXatUv67C4Cfl1PxflK+dgMzN+kxJSb9xa0j/2U3f7w9O3L5kLShF8EDMS1mD7V P/JjZsIOFwJ0hDo8ZtnAovPJBGKVP4wKqA/AvyPDvSV4Xm6Hkr5Hq35Icfe0A1dFQF2gwbH/eR3 VbP+YGeDs2/YM8lzQvwnGPJK3Rt3BDP/oSEeVkt9mljHxjXktINSD+jdRWtguBUZulWUIUqPlMm Uj9XEv0U1WbxBMTjBnCsdhc+pl1jZk2lTNxqd0Z1zPxLgJvPcMPLKBpeLxaSvAgi66i1zKzFKJJ Ae1YImpJ4ipcNkgok/xf1WJ5lMSX90T4GCf/eoiig== X-Received: by 2002:a05:600c:a10d:b0:487:12c:e7e1 with SMTP id 5b1f17b1804b1-48e51e1f013mr107836585e9.11.1778169174149; Thu, 07 May 2026 08:52:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 60/67] hw/arm/virt: Create and connect GICv5 Date: Thu, 7 May 2026 16:51:47 +0100 Message-ID: <20260507155154.1886557-61-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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: 1778169456735158500 In this commit we create and connect up the GICv5. We do not advertise it in the ACPI tables or DTB; that will be done in a following commit. The user-facing gic-version property still only documents and permits in its setter function the existing set of possible values; we won't permit the user to select a GICv5 until all the code to handle it is in place. Although we currently implement only the IRS, and only for EL1, we reserve space in the virt board's memory map now for all the register frames that the GICv5 may use. Each interrupt domain has: * one IRS config register frame * one ITS config register frame * one ITS translate register frame and each of these frames is 64K in size and 64K aligned and must be at a unique address (that is, it is not permitted to have all the IRS config register frames at the same physical address in the different S/NS/etc physical address spaces). The addresses and layout of these frames are entirely up to the implementation: software will be passed their addresses via firmware data structures (ACPI or DTB). Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-61-peter.maydell@linaro.org --- hw/arm/virt.c | 101 ++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/virt.h | 14 ++++++ 2 files changed, 115 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 2475d583cc..cf4d430454 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -68,6 +68,7 @@ #include "hw/intc/arm_gic.h" #include "hw/intc/arm_gicv3_common.h" #include "hw/intc/arm_gicv3_its_common.h" +#include "hw/intc/arm_gicv5_common.h" #include "hw/core/irq.h" #include "kvm_arm.h" #include "whpx_arm.h" @@ -184,6 +185,19 @@ static const MemMapEntry base_memmap[] =3D { [VIRT_GIC_ITS] =3D { 0x08080000, 0x00020000 }, /* This redistributor space allows up to 2*64kB*123 CPUs */ [VIRT_GIC_REDIST] =3D { 0x080A0000, 0x00F60000 }, + /* The GICv5 uses this address range differently from GICv2/v3/v4 */ + [VIRT_GICV5_IRS_S] =3D { 0x08000000, 0x00010000 }, + [VIRT_GICV5_IRS_NS] =3D { 0x08010000, 0x00010000 }, + [VIRT_GICV5_IRS_EL3] =3D { 0x08020000, 0x00010000 }, + [VIRT_GICV5_IRS_REALM] =3D { 0x08030000, 0x00010000 }, + [VIRT_GICV5_ITS_S] =3D { 0x08040000, 0x00010000 }, + [VIRT_GICV5_ITS_NS] =3D { 0x08050000, 0x00010000 }, + [VIRT_GICV5_ITS_EL3] =3D { 0x08060000, 0x00010000 }, + [VIRT_GICV5_ITS_REALM] =3D { 0x08070000, 0x00010000 }, + [VIRT_GICV5_ITS_TR_S] =3D { 0x08080000, 0x00010000 }, + [VIRT_GICV5_ITS_TR_NS] =3D { 0x08090000, 0x00010000 }, + [VIRT_GICV5_ITS_TR_EL3] =3D { 0x080A0000, 0x00010000 }, + [VIRT_GICV5_ITS_TR_REALM] =3D { 0x080B0000, 0x00010000 }, [VIRT_UART0] =3D { 0x09000000, 0x00001000 }, [VIRT_RTC] =3D { 0x09010000, 0x00001000 }, [VIRT_FW_CFG] =3D { 0x09020000, 0x00000018 }, @@ -1106,6 +1120,49 @@ static void create_v2m(VirtMachineState *vms) vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; } =20 +static void create_gicv5(VirtMachineState *vms, MemoryRegion *mem) +{ + MachineState *ms =3D MACHINE(vms); + SysBusDevice *gicbusdev; + const char *gictype =3D gicv5_class_name(); + QList *cpulist =3D qlist_new(), *iaffidlist =3D qlist_new(); + + vms->gic =3D qdev_new(gictype); + qdev_prop_set_uint32(vms->gic, "spi-range", NUM_IRQS); + + object_property_set_link(OBJECT(vms->gic), "sysmem", OBJECT(mem), + &error_fatal); + + for (int i =3D 0; i < ms->smp.cpus; i++) { + qlist_append_link(cpulist, OBJECT(qemu_get_cpu(i))); + /* + * GICv5 IAFFIDs must be system-wide unique across all GICs. + * For virt we make them the same as the CPU index. + */ + qlist_append_int(iaffidlist, i); + } + qdev_prop_set_array(vms->gic, "cpus", cpulist); + qdev_prop_set_array(vms->gic, "cpu-iaffids", iaffidlist); + + gicbusdev =3D SYS_BUS_DEVICE(vms->gic); + sysbus_realize_and_unref(gicbusdev, &error_fatal); + + /* + * Map the IRS config frames for the interrupt domains. + * At the moment we implement only the NS domain, so this is simple. + */ + sysbus_mmio_map(gicbusdev, GICV5_ID_NS, + vms->memmap[VIRT_GICV5_IRS_NS].base); + + /* + * The GICv5 does not need to wire up CPU timer IRQ outputs to the GIC + * because for the GICv5 those PPIs are entirely internal to the CPU. + * Nor do we need to wire up GIC IRQ/FIQ signals to the CPUs, because + * that information is communicated directly between a GICv5 IRS and + * the GICv5 CPU interface via our equivalent of the stream protocol. + */ +} + /* * If the CPU has FEAT_NMI, then turn on the NMI support in the GICv3 too. * It's permitted to have a configuration with NMI in the CPU (and thus the @@ -1319,6 +1376,9 @@ static void create_gic(VirtMachineState *vms, MemoryR= egion *mem) case VIRT_GIC_VERSION_4: create_gicv3(vms, mem); break; + case VIRT_GIC_VERSION_5: + create_gicv5(vms, mem); + break; default: g_assert_not_reached(); } @@ -2254,6 +2314,11 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineStat= e *vms, int idx) /* * Adjust MPIDR to make TCG consistent (with 64-bit KVM hosts) * and to improve SGI efficiency. + * - GICv2 only supports 8 CPUs anyway + * - GICv3 wants 16 CPUs per Aff0 because of an ICC_SGIxR + * register limitation + * - GICv5 has no restrictions, so we retain the GICv3 16-per-Aff0 + * layout because that's what KVM does */ if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { clustersz =3D GIC_TARGETLIST_BITS; @@ -2399,6 +2464,11 @@ static VirtGICType finalize_gic_version_do(const cha= r *accel_name, return finalize_gic_version_do(accel_name, VIRT_GIC_VERSION_MAX, gics_supported, max_cpus); case VIRT_GIC_VERSION_MAX: + /* + * We don't (currently) make 'max' select GICv5 as it is not + * backwards compatible for system software with GICv3/v4 and + * at time of writing not widely supported in guest kernels. + */ if (gics_supported & VIRT_GIC_VERSION_4_MASK) { gic_version =3D VIRT_GIC_VERSION_4; } else if (gics_supported & VIRT_GIC_VERSION_3_MASK) { @@ -2427,6 +2497,7 @@ static VirtGICType finalize_gic_version_do(const char= *accel_name, case VIRT_GIC_VERSION_2: case VIRT_GIC_VERSION_3: case VIRT_GIC_VERSION_4: + case VIRT_GIC_VERSION_5: break; } =20 @@ -2451,6 +2522,12 @@ static VirtGICType finalize_gic_version_do(const cha= r *accel_name, exit(1); } break; + case VIRT_GIC_VERSION_5: + if (!(gics_supported & VIRT_GIC_VERSION_5_MASK)) { + error_report("%s does not support GICv5 emulation", accel_name= ); + exit(1); + } + break; default: error_report("logic error in finalize_gic_version"); exit(1); @@ -2510,6 +2587,10 @@ static void finalize_gic_version(VirtMachineState *v= ms) gics_supported |=3D VIRT_GIC_VERSION_4_MASK; } } + if (!hvf_enabled() && module_object_class_by_name("arm-gicv5")) { + /* HVF doesn't have GICv5 support */ + gics_supported |=3D VIRT_GIC_VERSION_5_MASK; + } } else { error_report("Unsupported accelerator, can not determine GIC suppo= rt"); exit(1); @@ -2545,6 +2626,9 @@ static void finalize_msi_controller(VirtMachineState = *vms) vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; } else if (hvf_enabled() && hvf_irqchip_in_kernel()) { vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; + } else if (vms->gic_version =3D=3D VIRT_GIC_VERSION_5) { + /* GICv5 ITS is not yet implemented */ + vms->msi_controller =3D VIRT_MSI_CTRL_NONE; } else { vms->msi_controller =3D VIRT_MSI_CTRL_ITS; } @@ -2560,6 +2644,10 @@ static void finalize_msi_controller(VirtMachineState= *vms) error_report("GICv2 + ITS is an invalid configuration."); exit(1); } + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_5) { + error_report("GICv5 + ITS is not yet implemented."); + exit(1); + } if (whpx_enabled()) { error_report("ITS not supported on WHPX."); exit(1); @@ -2736,6 +2824,13 @@ static void machvirt_init(MachineState *machine) */ if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { virt_max_cpus =3D GIC_NCPU; + } else if (vms->gic_version =3D=3D VIRT_GIC_VERSION_5) { + /* + * GICv5 imposes no CPU limit beyond the 16-bit IAFFID field. + * The maximum number of CPUs will be limited not by this, but + * by the MachineClass::max_cpus value we set earlier. + */ + virt_max_cpus =3D 1 << QEMU_GICV5_IAFFID_BITS; } else { virt_max_cpus =3D virt_redist_capacity(vms, VIRT_GIC_REDIST); if (vms->highmem_redists) { @@ -2782,6 +2877,12 @@ 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"); + exit(1); + } + create_fdt(vms); =20 assert(possible_cpus->len =3D=3D max_cpus); diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index b74ffada7e..3ba33b4bd2 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -66,6 +66,18 @@ enum { VIRT_GIC_VCPU, VIRT_GIC_ITS, VIRT_GIC_REDIST, + VIRT_GICV5_IRS_S, + VIRT_GICV5_IRS_NS, + VIRT_GICV5_IRS_EL3, + VIRT_GICV5_IRS_REALM, + VIRT_GICV5_ITS_S, + VIRT_GICV5_ITS_NS, + VIRT_GICV5_ITS_EL3, + VIRT_GICV5_ITS_REALM, + VIRT_GICV5_ITS_TR_S, + VIRT_GICV5_ITS_TR_NS, + VIRT_GICV5_ITS_TR_EL3, + VIRT_GICV5_ITS_TR_REALM, VIRT_SMMU, VIRT_UART0, VIRT_MMIO, @@ -119,12 +131,14 @@ typedef enum VirtGICType { VIRT_GIC_VERSION_2 =3D 2, VIRT_GIC_VERSION_3 =3D 3, VIRT_GIC_VERSION_4 =3D 4, + VIRT_GIC_VERSION_5 =3D 5, VIRT_GIC_VERSION_NOSEL, } VirtGICType; =20 #define VIRT_GIC_VERSION_2_MASK BIT(VIRT_GIC_VERSION_2) #define VIRT_GIC_VERSION_3_MASK BIT(VIRT_GIC_VERSION_3) #define VIRT_GIC_VERSION_4_MASK BIT(VIRT_GIC_VERSION_4) +#define VIRT_GIC_VERSION_5_MASK BIT(VIRT_GIC_VERSION_5) =20 struct VirtMachineClass { MachineClass parent; --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169262; cv=none; d=zohomail.com; s=zohoarc; b=lJ70pIrUavVVcJIspUUKU9HWrwuYNR45s31g37HNwOlZUWCQhxGokiTUk2pgT5xNtNryhsoWmYucfC3qxLLvphM7jSVbBRXUTfsDUSFxOayFB2gAZOs+p3YujuGM2Hdnns+kEGPSTtM12pW0HwoS/TDc9+R1II7UhG7c7xPb9dM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169262; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=+AgOP944w5f4wu7taCG9qXhAvfN+5wdVybT+wso3JIY=; b=NNaLQsLVQLJ3kUUfQVmy9xFuaRP5Vw7ISoIw63qr2pYFnCYBKXlv+IKCs+z2kHFImeKW2iM5rnitqCoAibcRy1PQPbrhElyoV/I0Go9JXpmiH05AQv98c4I4Vq2I8YK9ZHu0pzvgPorta2zCwXPLvH568c3+Y+CYIPn1Hnk+tv8= 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 1778169262019473.6806993007191; Thu, 7 May 2026 08:54:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL126-0005sx-Ss; Thu, 07 May 2026 11:53: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 1wL122-0005mV-Lz for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:58 -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 1wL120-000435-Op for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:58 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4891e5b9c1fso10562225e9.2 for ; Thu, 07 May 2026 08:52:56 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169175; x=1778773975; 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; bh=+AgOP944w5f4wu7taCG9qXhAvfN+5wdVybT+wso3JIY=; b=Z32vyBM9kUP5NFu5Mbz0XbGVHrRGdwg8DS2ZJw+BOwDbdidNiImj6m4NL0ADiw8E5z 8Z1v+i6qiZHImdcfE4FV8Gdo8rDKzF9J7rxVSvFIOcCwgQEe+Nx5yrC2lBz8NrL/ry/S fscm0wddK/aOAL4dsBtuYmz0DxdGw2orHHaq2RSlc0uZWKCvPMYU+kT7B2oVuwAoqucm JfaDGfWN8+vtnDnMcBYs8MzA6nx43nC6+havjHjlZ0TRrY+PhXg5owTXlMEXjZJOEnXA PGMCutAfZwbRprwEPTF3gpRAgcqXLE9+4laVzmcAAmqXGYg0VMZCi0Z277+ENfvewmmM 6+vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169175; x=1778773975; 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; bh=+AgOP944w5f4wu7taCG9qXhAvfN+5wdVybT+wso3JIY=; b=KlQMgEgobqmlRB9eRIrmZsYDeaRDZpokgStTSWsj0l1Al5VE4y+h10oeYHTYZszP2m s3qJNa2owfjpp02+feTJSAMeUXXBNxIXmMhrgwt/5eqftWDqKEh/XIg70QwvOpJYEr3h SbU5D5fhJmn3QN3jJUqHqLbodiPhh1Z7LRTmv2cA7bjmRRScyzBgONfoixVqehW3EjHK Q7PNS/epB+2+RxnU/TW14uJTDTdAAQBXrmPuGOKKkUVhyAAKzUtUMP9Z02zUXzSrBKyp fwkCL1y1OCD4UdmqtpUiibOaHDQZTQqg/KQ0l8CvB3gY65aThr31bVnUxkwWOgoUKziO LjsA== X-Gm-Message-State: AOJu0YyoGIakeuzithxvcp6RcJJez256Uvykc7HzSmf1waoXzZCe4uJ6 sTkswiSSrW9na/2AjZ//dCYtYzi8/NxoYFhWhXSlGLChT/ljYidSG67UB47Bblp6pm19tqgB0tS 6gZDu X-Gm-Gg: AeBDietAlnTbz33oRFryd+d44+HZxuuqvi+I8OzkwpivdKRfuMl1bgsRJ578Zmqhk+/ c9oDST8nZPT8gnu3n9I29NWUT44haMiaR02Bh3pKWBo6co4sSTQxMf9sgkyFcGbLpUeH32Uxbjl GO6bDfSKY3oh3Yqw+DE3LlxOBAlGob+xE8NCiwaNEzwPR2F85qghpBhOQaCr2v1UZ2lcCwlfeaS TrQxoMGcBezJbZB9gd80+VUK5ge0t4783Uj4nDHc0Vgwl86vHvJG++QImMGHL32g2YeVxgm8kN4 JTOz2fMIkHGG3qhqUVd9GntcvAV05ku8jx9j+McFK1Fmdrbez1PY8ASDrxMvLXPcV66fW4SuYBm 42gI9jiQVT47Sgvs3e9SIU1X383jVu86qv7Nb3+IVTtQJQa0unvSnDCRRSg/9E/W8/av0koMi3H CSm4cJx/cJmYBEipyN+aNJIj1Wen6wlDsHRVLhHshXZA464+o5Bo1JLDOIK3XrqbZQWS5l0I3MW SNozL9TC/0JRN0hrNKjyaVK9zC59JjaZ68ehhNBMQ== X-Received: by 2002:a05:600c:8485:b0:48d:364:e236 with SMTP id 5b1f17b1804b1-48e51f30493mr147794285e9.18.1778169175002; Thu, 07 May 2026 08:52:55 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 61/67] hw/arm/virt: Advertise GICv5 in the DTB Date: Thu, 7 May 2026 16:51:48 +0100 Message-ID: <20260507155154.1886557-62-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169262979154100 Advertise the GICv5 in the DTB. This binding is final as it is in the upstream Linux kernel as: Documentation/devicetree/bindings/interrupt-controller/arm,gic-v5.yaml Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-62-peter.maydell@linaro.org --- hw/arm/virt.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index cf4d430454..3caba6e5d3 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1120,6 +1120,72 @@ static void create_v2m(VirtMachineState *vms) vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; } =20 +static void fdt_add_gicv5_node(VirtMachineState *vms) +{ + MachineState *ms =3D MACHINE(vms); + const char *nodename =3D "/intc"; + g_autofree char *irsnodename =3D NULL; + g_autofree uint32_t *cpu_phandles =3D g_new(uint32_t, ms->smp.cpus); + g_autofree uint16_t *iaffids =3D g_new(uint16_t, ms->smp.cpus); + + vms->gic_phandle =3D qemu_fdt_alloc_phandle(ms->fdt); + qemu_fdt_setprop_cell(ms->fdt, "/", "interrupt-parent", vms->gic_phand= le); + + qemu_fdt_add_subnode(ms->fdt, nodename); + qemu_fdt_setprop_cell(ms->fdt, nodename, "phandle", vms->gic_phandle); + qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", "arm,gic-v5"); + qemu_fdt_setprop_cell(ms->fdt, nodename, "#interrupt-cells", 3); + qemu_fdt_setprop(ms->fdt, nodename, "interrupt-controller", NULL, 0); + qemu_fdt_setprop_cell(ms->fdt, nodename, "#address-cells", 0x2); + qemu_fdt_setprop_cell(ms->fdt, nodename, "#size-cells", 0x2); + qemu_fdt_setprop(ms->fdt, nodename, "ranges", NULL, 0); + + /* The IRS node is a child of the top level /intc node */ + irsnodename =3D g_strdup_printf("%s/irs@%" PRIx64, + nodename, + vms->memmap[VIRT_GICV5_IRS_NS].base); + qemu_fdt_add_subnode(ms->fdt, irsnodename); + qemu_fdt_setprop_string(ms->fdt, irsnodename, "compatible", + "arm,gic-v5-irs"); + /* + * "reg-names" describes the frames whose address/size is in "reg"; + * at the moment we have only the NS config register frame. + */ + qemu_fdt_setprop_string(ms->fdt, irsnodename, "reg-names", "ns-config"= ); + qemu_fdt_setprop_sized_cells(ms->fdt, irsnodename, "reg", + 2, vms->memmap[VIRT_GICV5_IRS_NS].base, + 2, vms->memmap[VIRT_GICV5_IRS_NS].size); + qemu_fdt_setprop_cell(ms->fdt, irsnodename, "#address-cells", 0x2); + qemu_fdt_setprop_cell(ms->fdt, irsnodename, "#size-cells", 0x2); + qemu_fdt_setprop(ms->fdt, irsnodename, "ranges", NULL, 0); + + /* + * The "cpus" property is an array of phandles to the CPUs, and + * "iaffids" is an array of uint16 IAFFIDs. For virt, our IAFFIDs + * are the CPU indexes. This function is called after + * fdt_add_cpu_nodes(), which allocates the cpu_phandles array. + */ + assert(vms->cpu_phandles); + for (int i =3D 0; i < ms->smp.cpus; i++) { + /* + * We have to byteswap each element here because we're setting the + * whole property value at once as a lump of raw data, not via a + * helper like qemu_fdt_setprop_cell() that does the swapping for = us. + */ + cpu_phandles[i] =3D cpu_to_be32(vms->cpu_phandles[i]); + iaffids[i] =3D cpu_to_be16(i); + } + qemu_fdt_setprop(ms->fdt, irsnodename, "cpus", cpu_phandles, + ms->smp.cpus * sizeof(*cpu_phandles)); + qemu_fdt_setprop(ms->fdt, irsnodename, "arm,iaffids", iaffids, + ms->smp.cpus * sizeof(*iaffids)); + + /* + * When we implement the GICv5 IRS, it gets a DTB node which is a + * child of the IRS node. + */ +} + static void create_gicv5(VirtMachineState *vms, MemoryRegion *mem) { MachineState *ms =3D MACHINE(vms); @@ -1161,6 +1227,8 @@ static void create_gicv5(VirtMachineState *vms, Memor= yRegion *mem) * that information is communicated directly between a GICv5 IRS and * the GICv5 CPU interface via our equivalent of the stream protocol. */ + + fdt_add_gicv5_node(vms); } =20 /* --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169481; cv=none; d=zohomail.com; s=zohoarc; b=bfY9/1HBGIpSmMdNyZah/54uAxjc44e3jwUBEpioIxEeDX2ndqzIC2JDdmypR7Z2DnoL2/15CKZsR6KoA9i1SS5/lN5q7ZmDA7L8MsC4ZKAthkniOov8HkTqZTgdoK/NleAF4BRyV7in4mHEYLVO8OBqDE9bU3VvuEEHLP4cPdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169481; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=g3Ne1jJeN18OBsdPIflujrejDJaHthbKJQHwQQvf22Q=; b=VlDiA5O5SpqyQWeP+OulrrFPeOXemxD11RMnEfi45GstJKlpjUiEatFn1MRBoN2bm9SgJDheRrecxJCm0fJ7uxcg6aQZgJdGBD7UjYeh4gsw+IbekKW0PuW6xStbH8Aa5Ab81vbnQb7YwOcMqsNEOXZCmArZRL1qDPP60RmT+SM= 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 1778169481761143.7606578337883; Thu, 7 May 2026 08:58:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL125-0005qu-LM; Thu, 07 May 2026 11:53:01 -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 1wL123-0005nK-20 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:59 -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 1wL121-00043E-E8 for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:58 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4852a9c6309so9005185e9.0 for ; Thu, 07 May 2026 08:52:56 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169176; x=1778773976; 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; bh=g3Ne1jJeN18OBsdPIflujrejDJaHthbKJQHwQQvf22Q=; b=fWtIzvFEraOjYz2flSEWZin3W3a9g61A2kIaT62yHx3zIU2FhbIcsWsi/vIddpFpe8 AKrDtBjrRkqF4dGptdPZJvcUkOgQD1H02m8HmC8BiDqFzLvWf/CyQ1akkjyEzY/Ayx6R Z2TD+wZ5up9ifbzN/6udAo6kazZ90+k/HGRvl/szVav1vw31B1PeTclWxOezbw0bCToi vwWhdS6/b0DngYuqfmKbpsVM3JF2XnZdd2GsJ9ELoSXt9SLoKM5kVvWnP9ekrsUMCK42 pCDTt9LmFya2RUySPXUkaixIkCRqySj7Vxvt+UF0KLmpjHNy3M5Ji7vIgQgbOlJmG/Es OgnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169176; x=1778773976; 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; bh=g3Ne1jJeN18OBsdPIflujrejDJaHthbKJQHwQQvf22Q=; b=CqFWVtq+B9O9LPs+ZsVvsJcI+1bbxAWISqoIGdoUCPhfocga2WDbUfetm4hDu7UNhT o8F8/91G+Go7FzR607hvRD/Ohf6dYhFGUgABmZ+YEZ6I+Rm4ri71Lbp+Ij9/DlpmeEnj 7MOBHQ+Rp1YPde74ELG0NipdpebvmaNPn8SV60bZqS63iCmcJSL8PjErvWXVv/9MHH3Q uTpHKAMwU5k2SsvvKCkPWsXYbL66wgDzgnaE9EE4sY0nDX4ZtSjdBziKNvt+qIkVTSQn NIHf4wwcR8KdGUy18I+9W4rvTp+S7C65q+QCJ5EOiOoqOqzRIoWj8n565Sc0Q6Zg92IT Iq+g== X-Gm-Message-State: AOJu0YzKqjLIVdGvR5pRmbBunB5O5JEGPvq9gqjj1lF1MgLGTbVRUVAD lKr6RXDNLIJcfDHlV1wQdrHZwSefL8K++P0gcob9G+AYCVceAy6bKXpui0JQc3sPrA8gq4OmrJV Zq+U8 X-Gm-Gg: AeBDiesJhwKHbAJLKF7NG3+WKHua5rDAMT0qKqGj/ULq/WTBsj1mKeybgyHB/Px4Z2y 0qdwH5SNP4rg7xeFNmqZORGvkz4tVQcDTwu3ou2QX2KWdG5VqlwbeishvRvUpiRE0302TxCqsBg 4pD4atpGAZVNAZDkkL/JtUBGxgUnoLP+lWPw60KJnFUKvo7JfqHM/R45d+Br0Wa3c1PrzVwjDzP dvG8N7jsHEh0a5iJ75/0i5k6ZZjFbCKysbxdQQHtQJPAGqI/ReMgGyB9Tec0Js0B8psGQSlT0lh uqNVzycJ4yDyrVNJylrukIIChcggNNK9FqlDUBcAvGQ9jzYW7ozU1a1UvgCaTIiBEFnGNqIliHr nVEs9SAZZldfL2IKF4kKfiI+O2DFQso2qGfHAAzeCxTduGT+JpEu+ueDFRNtFfxhWrRBWprN3Kp xirroz1jH3Py8eEBLz84w9WgraCyvUwn+XbFnU040DlFeXgIu5IlS1B6KgwmbEdyKmbyvJ7LswK D2Kxxyq+n2N9768 X-Received: by 2002:a05:600c:8b0c:b0:48a:7a10:4f47 with SMTP id 5b1f17b1804b1-48e51e0a620mr146365155e9.3.1778169175914; Thu, 07 May 2026 08:52:55 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 62/67] hw/arm/virt: Handle GICv5 in interrupt bindings for PPIs Date: Thu, 7 May 2026 16:51:49 +0100 Message-ID: <20260507155154.1886557-63-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169484520154100 Content-Type: text/plain; charset="utf-8" The GICv5 devicetree binding specifies the "interrupts" property differently to GICv2 and GICv3 for PPIs: the first field is the architectural INTID.TYPE, and the second is the architectural INTID.ID. (The third field defining the level/edge trigger mode has the same values for GICv5 as it did for the older GICs.) In the places in the virt board where we wire up PPIs (the timer and the PMU), handle the GICv5: * use the architectural constant GICV5_PPI for the type * use the architected GICv5 PPI numbers for the interrupt sources (which differ from the old ones and don't need to be adjusted via INTID_TO_PPI()) * leave the irqflags as-is Add some commentary in our include/hw/arm/fdt.h file about what the the constants defined there are valid for. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-63-peter.maydell@linaro.org --- hw/arm/virt.c | 23 +++++++++++++++++++---- include/hw/arm/fdt.h | 10 ++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 3caba6e5d3..09474c55d1 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -500,7 +500,15 @@ static void fdt_add_timer_nodes(const VirtMachineState= *vms) "arm,armv7-timer"); } qemu_fdt_setprop(ms->fdt, "/timer", "always-on", NULL, 0); - if (vms->ns_el2_virt_timer_irq) { + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_5) { + /* The GICv5 architects the PPI numbers differently */ + qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts", + GICV5_PPI, GICV5_PPI_CNTPS, irqflags, + GICV5_PPI, GICV5_PPI_CNTP, irqflags, + GICV5_PPI, GICV5_PPI_CNTV, irqflags, + GICV5_PPI, GICV5_PPI_CNTHP, irqflags, + GICV5_PPI, GICV5_PPI_CNTHV, irqflags); + } else if (vms->ns_el2_virt_timer_irq) { qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts", GIC_FDT_IRQ_TYPE_PPI, INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflag= s, @@ -1025,11 +1033,18 @@ static void fdt_add_pmu_nodes(const VirtMachineStat= e *vms) qemu_fdt_add_subnode(ms->fdt, "/pmu"); if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) { const char compat[] =3D "arm,armv8-pmuv3"; + qemu_fdt_setprop(ms->fdt, "/pmu", "compatible", compat, sizeof(compat)); - qemu_fdt_setprop_cells(ms->fdt, "/pmu", "interrupts", - GIC_FDT_IRQ_TYPE_PPI, - INTID_TO_PPI(VIRTUAL_PMU_IRQ), irqflags); + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_5) { + qemu_fdt_setprop_cells(ms->fdt, "/pmu", "interrupts", + GICV5_PPI, GICV5_PPI_PMUIRQ, irqflags); + } else { + qemu_fdt_setprop_cells(ms->fdt, "/pmu", "interrupts", + GIC_FDT_IRQ_TYPE_PPI, + INTID_TO_PPI(VIRTUAL_PMU_IRQ), + irqflags); + } } } =20 diff --git a/include/hw/arm/fdt.h b/include/hw/arm/fdt.h index c3d5015013..995652c27a 100644 --- a/include/hw/arm/fdt.h +++ b/include/hw/arm/fdt.h @@ -20,9 +20,19 @@ #ifndef QEMU_ARM_FDT_H #define QEMU_ARM_FDT_H =20 +/* + * These are for GICv2/v3/v4 only; GICv5 encodes the interrupt type in + * the DTB "interrupts" properties differently, using constants that + * match the architectural INTID.Type. In QEMU those are available as + * the GICV5_PPI and GICV5_SPI enum values in arm_gicv5_types.h. + */ #define GIC_FDT_IRQ_TYPE_SPI 0 #define GIC_FDT_IRQ_TYPE_PPI 1 =20 +/* + * The trigger type/level field in the DTB "interrupts" property has + * the same encoding for GICv2/v3/v4 and v5. + */ #define GIC_FDT_IRQ_FLAGS_EDGE_LO_HI 1 #define GIC_FDT_IRQ_FLAGS_EDGE_HI_LO 2 #define GIC_FDT_IRQ_FLAGS_LEVEL_HI 4 --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169265; cv=none; d=zohomail.com; s=zohoarc; b=ghVZX5TE3AFcyHER6bbBX4D9YDpJOhDYrVbsOdoibhHW2TU25nNDDSNKYqD2GO8jjCMz3AiIP35FlUOV1pAqH+XsLXcLE3yWzfSpfD+LAyKwbndPWS3j0x006QupjeoiJVwTPRVZ5i3XpVc0f6Cxckaqe7uYOSweVEdLj6U629w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169265; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=A2rbZVeHCOSUq1JlEYVxVfCFNJM+6hAsFXZx0ftnNdg=; b=edZxYvQJU/UPtCzDgv+vAPdLUiQv8HYMYfw1DFb4ccd3icFm+u7q3a57x4B6T+tAWVTCCEeBIusJNhhA4eZn7jbMEmwxX1eLmw+YnmgkMqrdoLjn+dvYYkSdCDYXbEIRr+NzZle0f+kuS86q/QyJmxiIYI9kIb1bkdzcLIak21s= 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 1778169265110592.5394692535543; Thu, 7 May 2026 08:54:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL126-0005s7-9Q; Thu, 07 May 2026 11:53: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 1wL124-0005o6-0q for qemu-devel@nongnu.org; Thu, 07 May 2026 11:53:00 -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 1wL122-00043U-9B for qemu-devel@nongnu.org; Thu, 07 May 2026 11:52:59 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4891c00e7aeso9363485e9.2 for ; Thu, 07 May 2026 08:52:57 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169177; x=1778773977; 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; bh=A2rbZVeHCOSUq1JlEYVxVfCFNJM+6hAsFXZx0ftnNdg=; b=sID4SS0T6x5qa8RLPbHvwIkVi2OKSPGcZ8t7nqzPFrpeshZMX9e4Gk/ex0i/ITmTi4 s1BYePi93r14CSC+7pnEAey8cnS4S3oczAn0cRTYuhVI351BbYLEAlTUqYjj0ArYLDMH fs4EqQQaes2UomB8P2cVewCUzlCQtY/hDRepwoCajR/lTWrjvCrFn4kXd/A1t1NGggKn 6Yi/RtJ3ocu3UjKIR4yqDlc4Dqszs2xQyuNrf6bF7no6DGzkWWIPvwsw/YFJdbUkNzLd RQJh8WWlR3ge4rUMZnNI5Y1TRnraJ7q+ezXbJGJraL5Sfi79Er0kp5GD+ah5jHuM/7Kd guNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169177; x=1778773977; 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; bh=A2rbZVeHCOSUq1JlEYVxVfCFNJM+6hAsFXZx0ftnNdg=; b=sOmTH7iAp4Jxj/25xaJnYhap1n/KqKZiOX4Wz7T7SrH0tf2DVaFiF3zuAjGRMJNTnV qGfkhy3SH7dZI/nOmKS8EQkUfuMj13cjFOgtBebvXEy9Pr2vIJLlGsD6CeDN8Um10URu sha/0dNrvuo17vk+eHDKgWhYidImvPiFsnUzb4uKGRsD5z+tbx+iVZiifkiT0r3PjVrZ v4EUHRRrfuF8Hb6b6SIwrGd+HsTMTkg/OEEvtli28SnzxjjDfdSq2k5IYPitiX5xrxTF PsFSiosSK00cNxku2U9NBUrIFrKYF4wU0TOk14hgEkkTx5g/+mKBV1Z5Vdifb21QGUF8 yf7g== X-Gm-Message-State: AOJu0YzLh2Z8YpYfB9pXW+aDfi+tupo8/+wGyS2DJ2CScf6o1AKZkI1t le7U6afHO84GGOxx6OP7mO2grb2tVxc4poLTY6SB0Vfb3w+Jr699oH9f1yKOaCvT/pTEEzrH9w/ BXB78 X-Gm-Gg: AeBDietAqkAIGflF0I7spQNZGkiH3Yb4Yb+XbBXRAai9kAry0UFRJtf5vXYKL8Mz20V EAGMNfe5EcDsnbnADgju+KSw1ghc0ZMQGvlwNV4lRQlTmEbCseL6sLVozS2f+hEHfQ/yoMHIebJ FOD2DJPJoND7CKRXnJjd2BwAbIvoaj1YFH1t4iaWtGVJLrh7pQPkAhJ0TSXUv7cLQ8ht7h2C5Mr 257gKxBJQy9MOarO4IsjQNtkKR0Qtu7Mripo15EPx65LjHvg0Na5yHjlkUXiYnlO6Ck6FrYF/4o BlOJ9Al2L7pIMlRw9Cy1ulGYkCZpp5y+S4QITvtymYp5I21q3UnkMYj6eKVY13mNX9TkSB8cKKH ukSZg/giwLTApgycluiYtuxbQ7qC0HKF/Gr9TCn8GgcqxkWrvfZMi9vVSnApIY86e9V77ejUItC vIxNv+mnbft+oBJqqAJgZNu3ZEufyKEWQg9hX++vSZJMXqWvNc2yuXNEPbLq6sfWRVqauNN7X4J FmighBtra1xzhwUchhK7g5gz/QlTSA= X-Received: by 2002:a05:600c:4e0c:b0:48a:54a6:b29f with SMTP id 5b1f17b1804b1-48e51f2f793mr144296915e9.17.1778169176781; Thu, 07 May 2026 08:52:56 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 63/67] hw/arm/virt: Use correct interrupt type for GICv5 SPIs in the DTB Date: Thu, 7 May 2026 16:51:50 +0100 Message-ID: <20260507155154.1886557-64-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169265552158500 Content-Type: text/plain; charset="utf-8" The GICv5 devicetree binding specifies that the "interrupts" property for devices connected to it should use the architectural INTID.TYPE values to specify whether the interrupt is an SPI, LPI or PPI. This is different to the GICv2 and GICv3, so instead of hardcoding the GIC_FDT_IRQ_TYPE_SPI constant when we create "interrupts" bindings, create a new function gic_fdt_irq_type_spi() that returns the right value for the interrupt controller in use. For SPIs, the INTID.ID and the trigger-mode fields of the "interrupts" property remain the same for GICv5 and the older GIC versions. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-64-peter.maydell@linaro.org --- hw/arm/virt.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 09474c55d1..7da92e7746 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -375,6 +375,16 @@ unsigned int virt_get_caches(const VirtMachineState *v= ms, CPUCoreCaches *caches) return num_cache; } =20 +/* + * The correct value to use in a DTB "interrupts" property for an SPI + * depends on the GIC version. + */ +static int gic_fdt_irq_type_spi(const VirtMachineState *vms) +{ + return vms->gic_version =3D=3D VIRT_GIC_VERSION_5 ? + GICV5_SPI : GIC_FDT_IRQ_TYPE_SPI; +} + static void create_fdt(VirtMachineState *vms) { MachineState *ms =3D MACHINE(vms); @@ -1510,7 +1520,7 @@ static void create_uart(const VirtMachineState *vms, = int uart, qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", 2, base, 2, size); qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts", - GIC_FDT_IRQ_TYPE_SPI, irq, + gic_fdt_irq_type_spi(vms), irq, GIC_FDT_IRQ_FLAGS_LEVEL_HI); qemu_fdt_setprop_cells(ms->fdt, nodename, "clocks", vms->clock_phandle, vms->clock_phandle); @@ -1552,7 +1562,7 @@ static void create_rtc(const VirtMachineState *vms) qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", 2, base, 2, size); qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts", - GIC_FDT_IRQ_TYPE_SPI, irq, + gic_fdt_irq_type_spi(vms), irq, GIC_FDT_IRQ_FLAGS_LEVEL_HI); qemu_fdt_setprop_cell(ms->fdt, nodename, "clocks", vms->clock_phandle); qemu_fdt_setprop_string(ms->fdt, nodename, "clock-names", "apb_pclk"); @@ -1671,7 +1681,7 @@ static void create_gpio_devices(const VirtMachineStat= e *vms, int gpio, qemu_fdt_setprop_cell(ms->fdt, nodename, "#gpio-cells", 2); qemu_fdt_setprop(ms->fdt, nodename, "gpio-controller", NULL, 0); qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts", - GIC_FDT_IRQ_TYPE_SPI, irq, + gic_fdt_irq_type_spi(vms), irq, GIC_FDT_IRQ_FLAGS_LEVEL_HI); qemu_fdt_setprop_cell(ms->fdt, nodename, "clocks", vms->clock_phandle); qemu_fdt_setprop_string(ms->fdt, nodename, "clock-names", "apb_pclk"); @@ -1752,7 +1762,7 @@ static void create_virtio_devices(const VirtMachineSt= ate *vms) qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", 2, base, 2, size); qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts", - GIC_FDT_IRQ_TYPE_SPI, irq, + gic_fdt_irq_type_spi(vms), irq, GIC_FDT_IRQ_FLAGS_EDGE_LO_HI); qemu_fdt_setprop(ms->fdt, nodename, "dma-coherent", NULL, 0); g_free(nodename); @@ -1952,10 +1962,11 @@ static void create_pcie_irq_map(const MachineState = *ms, int devfn, pin; uint32_t full_irq_map[4 * 4 * 10] =3D { 0 }; uint32_t *irq_map =3D full_irq_map; + const VirtMachineState *vms =3D VIRT_MACHINE(ms); =20 for (devfn =3D 0; devfn <=3D 0x18; devfn +=3D 0x8) { for (pin =3D 0; pin < 4; pin++) { - int irq_type =3D GIC_FDT_IRQ_TYPE_SPI; + int irq_type =3D gic_fdt_irq_type_spi(vms); int irq_nr =3D first_irq + ((pin + PCI_SLOT(devfn)) % PCI_NUM_= PINS); int irq_level =3D GIC_FDT_IRQ_FLAGS_LEVEL_HI; int i; @@ -1996,10 +2007,10 @@ static void create_smmuv3_dt_bindings(const VirtMac= hineState *vms, hwaddr base, qemu_fdt_setprop_sized_cells(ms->fdt, node, "reg", 2, base, 2, size); =20 qemu_fdt_setprop_cells(ms->fdt, node, "interrupts", - GIC_FDT_IRQ_TYPE_SPI, irq , GIC_FDT_IRQ_FLAGS_EDGE_LO_HI, - GIC_FDT_IRQ_TYPE_SPI, irq + 1, GIC_FDT_IRQ_FLAGS_EDGE_LO_HI, - GIC_FDT_IRQ_TYPE_SPI, irq + 2, GIC_FDT_IRQ_FLAGS_EDGE_LO_HI, - GIC_FDT_IRQ_TYPE_SPI, irq + 3, GIC_FDT_IRQ_FLAGS_EDGE_LO_HI); + gic_fdt_irq_type_spi(vms), irq , GIC_FDT_IRQ_FLAGS_EDGE_LO_= HI, + gic_fdt_irq_type_spi(vms), irq + 1, GIC_FDT_IRQ_FLAGS_EDGE_LO_= HI, + gic_fdt_irq_type_spi(vms), irq + 2, GIC_FDT_IRQ_FLAGS_EDGE_LO_= HI, + gic_fdt_irq_type_spi(vms), irq + 3, GIC_FDT_IRQ_FLAGS_EDGE_LO_= HI); =20 qemu_fdt_setprop(ms->fdt, node, "interrupt-names", irq_names, sizeof(irq_names)); --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169290; cv=none; d=zohomail.com; s=zohoarc; b=hUdJMVqvvk37Mi9Y2HBWDhZDI8MdDABGCOA5bAzCV6D2XOjUrM57bziHEvTrwleM9CTdwUVKrFYJY3lcVWmsYSyOcylW6cttFRqmzE22qXgZym44yowtTRW7bOWN2sIumiP/9N/Xq6hi8Q+6Bi2Lo4ZQb2KV01wLAHBfDt/O3ho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169290; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=4eok6cHwZNCAp1lJxTQayrYIK7Kwl6hC9hZNWKlxPbM=; b=abrcDmIKjHz0qBhlGyNLOzC79M13NvJiqA9PwPorW/XWo2Qro+ufAaKyHXs9K9jRn2K+TgaRdwCm0PE3lOgaNSC1aVub/K+9JgPaH7MDD5lxfc6gymMiQHLa+MUT00pysdgo5ppbnYdrwjJQcrF+fO9ssDNoNLc0BXm35L6b2jk= 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 1778169290384104.70009718369408; Thu, 7 May 2026 08:54:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL126-0005sM-Cj; Thu, 07 May 2026 11:53: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 1wL124-0005oh-PH for qemu-devel@nongnu.org; Thu, 07 May 2026 11:53:00 -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 1wL123-00043p-8y for qemu-devel@nongnu.org; Thu, 07 May 2026 11:53:00 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-488ab2db91aso11867565e9.3 for ; Thu, 07 May 2026 08:52:58 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169178; x=1778773978; 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; bh=4eok6cHwZNCAp1lJxTQayrYIK7Kwl6hC9hZNWKlxPbM=; b=R+97yiZv86OEnylrhnp8V0cGf7Xp3N5cOFl31fRhxPbfK8oIeW9RcYEliU876FWtD4 6Q6/QgmCf1xHaP2nD+VTy2/AdOY5If9yxvuAAeBvwVsR/zTUDfLgVHDkHMaELZpRYarR OE6wk1I3UeF89EWkAQGXev4TVBRGnlUYUDRYVNtmN8qMqw2t0PBHmP6bYmRUYyKDJ78k hzzeXceMzEzq5eVx/VE15Ufv8rU/1zMWhLnQ9VtbsUx1bGVE2pHC01ZD+BSKxn23g2E3 N7W3WPXKOhIJI2l/puAniSN0Z5jvg7PWiIxEg9+1jypYOY7Zamn6OvbthBuMibxZlk5Q RCjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169178; x=1778773978; 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; bh=4eok6cHwZNCAp1lJxTQayrYIK7Kwl6hC9hZNWKlxPbM=; b=p6poE9bhOJtvk8Oc/VjK3PQPCLLTlU5K2/k+xPvq2wcIETMDI21HVheMkDBcbWQpmR YqaaoWXlzGB4LksoFfZXPBLlg5X3kwNp4UDKndt7lYuGMPmD2CG973SxXfZOo0BmuFxh VXU43HqT+mKmLE0PWtQdJHjC5GbG7LNBqdAJYiAviIRuLi512bsJsa3hCbhmfLS00YD4 ODoVz1d0e3yLimBxjUdzkBnP8IxQMCDqvX0umFFk9CixJ0C8rqO+JRljvJCOo3PHhHSz kdVMy8aKebK0mApBPPxmm/AyvZ1p6vQftytg0so8JCgyhkFvoOXBmlWOcIUmYBXxRvgu aifw== X-Gm-Message-State: AOJu0YzdgnW9mAdMhP5uIIsnCLhD/hWxKtTVge2eTW8SsysGWt97djhU TrIFhluP5A2okHR/gj6xL9YH7aKP29+9zpC7R8s9Kv5HJeWC4MlgRP2zs+6GtOv5F19akF3b4rQ KAQIH X-Gm-Gg: AeBDieuFzLYw+44zpwyc9Q7G89RYeJlAVu3j1zE2Axow7ArLBSW3yDRiPwIMpbMZixb lHIve4H6yva0bFzy9bQ6klF+knzLXs+yPLSgikf+HS3OXhKUl5mLZyvwn4LaO+ODHE8uqDHNk2J T1ip9DBxM1jpMYw5AGTMOK88YUzMxfpMqN0q+GUPd/kChtxzld3LPIloqEC5PRP+bjInmDpptTr VrNiakhCB4eIUEOsjT4g4OdE4hkmERGfg9bQTrjbSDPAi3QNStzGt1fjrqcOYHI2z4nqdjra8I+ bLDhOOBJKEMYNF9gugdC9tX4dyYv7lSewSCCGxfGWUb0MQl2v8Oognk+vRg1GVg3kzqhfrWfsXh L4oSj8LZVgEr+vSLEP7VzIIL0k7UYPJThxMpwyXOF73SJjdjT7I68l5Xw5Bk+NyM+m0FIDsGpUu +gzabUKukLzqoLrF9Nd6p/v4oBuxnpH+oAe1jljgOPps88GcReC/gBAGKco+SgVOjoKwnB2VNwN cFft3XDmTmjjYAT180GaS7x9iJysaw= X-Received: by 2002:a05:600c:a110:b0:488:ae6c:42c6 with SMTP id 5b1f17b1804b1-48e51f2e8a3mr105669375e9.14.1778169177652; Thu, 07 May 2026 08:52:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 64/67] hw/arm/virt: Enable GICv5 CPU interface when using GICv5 Date: Thu, 7 May 2026 16:51:51 +0100 Message-ID: <20260507155154.1886557-65-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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: 1778169291363154100 Content-Type: text/plain; charset="utf-8" If we are using the GICv5 in the virt board, we need to set the has_gcie property on the CPU objects to tell them to implement the cpu interface part of GICv5. Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Message-id: 20260327111700.795099-65-peter.maydell@linaro.org --- hw/arm/virt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7da92e7746..75b20cfc9a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3017,6 +3017,14 @@ static void machvirt_init(MachineState *machine) object_property_set_bool(cpuobj, "lpa2", false, NULL); } =20 + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_5) { + if (!object_property_find(cpuobj, "has_gcie")) { + error_report("Using GICv5 but guest CPU does not support i= t"); + exit(1); + } + object_property_set_bool(cpuobj, "has_gcie", true, NULL); + } + if (object_property_find(cpuobj, "reset-cbar")) { object_property_set_int(cpuobj, "reset-cbar", vms->memmap[VIRT_CPUPERIPHS].base, --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169376; cv=none; d=zohomail.com; s=zohoarc; b=bRT0jggA1dZC7kPiuePI5Qwsin25hiiwUdIcY/zNnj9d/AggaGKJYF0JibnWDRl0Wh5c9llXC9/QtbT5tG9wveHWxqNVQJKSkXOt4s+q0dkmt6XYioAMdGL7iaw1LvWnHzOktmaZvFIQwpAzs9E301YDpUKXSu8afk+600hRSvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169376; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=l1DRfi7wMTnOi0BVOQSA9ApUBAxlQZ2UlQV8+IjhEyQ=; b=Bn6hLqRjRA3So4RYOoQudjx9bNqHonvm+0zan3roCl5YI6LHRLaY4nYMjBzbu/w0PICCTrpYgLPmYA7BVvUiBhYCWrlP94FSLA3p4/rB6mBb9rwIulZmBcCkxoe4vvVWCBg2+PRuodqrIjVKIu+ENaitNAJ5nXgyDHVJFNfWTl0= 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 1778169376738691.590286486146; Thu, 7 May 2026 08:56:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL127-0005vs-TI; Thu, 07 May 2026 11:53: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 1wL126-0005sH-BV for qemu-devel@nongnu.org; Thu, 07 May 2026 11:53:02 -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 1wL124-00044E-GA for qemu-devel@nongnu.org; Thu, 07 May 2026 11:53:02 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-488e1a8ac40so10277355e9.2 for ; Thu, 07 May 2026 08:53:00 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169179; x=1778773979; 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; bh=l1DRfi7wMTnOi0BVOQSA9ApUBAxlQZ2UlQV8+IjhEyQ=; b=thFh+9aaUgWWz53pa1SXcPyz7c6Q7ZHCikiYCyhGlbVwoJElVVkML6mI91yRl/kEty P4l1pIEMoz+B2eou8w3kP1sVW0QZy4yKqVLjJ5/c0MazPymbEzFtUNKz6t2mYVzSWSW+ 3eRryXYzuDkunmdkuhVSP//Brjyl62ZX5RwxVxnAoach5vBmj4n5GVhBFN026H5M0RCD URtvTn3qLOMqo8SQwnQcfPwEm55MYIf3CTHXDj8QIk9wmWgSIVgrLzAqvDmEXMjPobYL 2qQUt0sO5YNYL5VhVnMWBDicRliX7jT0IY88oUjWZHzp56hg4Yyr46UWIzH4rat6qJuR WQmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169179; x=1778773979; 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; bh=l1DRfi7wMTnOi0BVOQSA9ApUBAxlQZ2UlQV8+IjhEyQ=; b=XZCyRVONIY5vaFbrNNDD/wC/JifN8IlLrmrh/l7m9xoXydir3s3DPJGJq6+GTFRDzn WNQ7jxMgyTiRyCjodDOmHgkTllVgBiLHPDvZ89yVDfolAyZVaUII1jWU/+/ZpMarly5i lXspybSiBmOgeAye5b/evCFokIwvaVIB/h6BexCVcDVx67OMI+u9RB6/ocL7Z8KV9w/a XMMNftadITEQTao7xKF2nYDSFtwKO3KF7Agfds/51hZhgoaT56RmbZ6+Cgerhl6LS1Vy +WZm3xDo+0foM7bXyvZahvzPL4uCD6yOra9FPqLwssVm5WEQUgsPas4SMzIGj/ow+glo EYiw== X-Gm-Message-State: AOJu0Ywp2048rpPlFZ0qDT4+dKCxEWasAFJgBV7qZDkxtoGzjY57ibhm aE33selXRR0ETM1I9v8XVEUy8e4ZAyKYYqco4AdU/0YyTr5E/gEY1ZAJqOcn3BrH++7eJi+/OTx 43AJ8 X-Gm-Gg: AeBDiesposcdeqsN8HlePw+rbyg4dA39H/jcKvvCyUSQINr4uyIteq0peBcLP/Aba9J Bt0oxLhSBkHx/R4fconBy3m/cFgmpt8Gz1OVYx4hIPCm8sZWUFXdT2LADYUGRmKp8EJVhGLB782 VgeF6wdP2V2H33iSNrLot1FWcvbM8EnSzdcH9rf4Kb4znIxg7/lJbnXsLBMxaRffjHurUq7nzf2 EKjI192BzlXKOYkbZQU+ENqPpoLEFNh1CRVKJZILYUBFmludYf3FCaxOO6eF9yKyV0x5jcNczR6 TgG4SZq2u2XDLXBwOFBnz5wneHCTQ212IV8G5gKn1OdI14pXY5mpVwawkAn1vmpfR1OWE4S2zui KqUCP2lYSTNCuZ/QifjViO5Pvwv9shL0t3bnFu50WMog/7yjElrN9zceMdTxy2DmqStLb9+P+Vx iZGFWmgmJKOj1jCr5HkwXXkexZKNDiaJ0pNgSYsST3N5f4gdkkktvfjpGhGRJe5NQz97mx5Lq1O m6QkXJln6o9mbXZE5VKv88Vrr3w3v4= X-Received: by 2002:a05:600c:4449:b0:48a:89d9:a419 with SMTP id 5b1f17b1804b1-48e51f2e67fmr137884255e9.11.1778169178673; Thu, 07 May 2026 08:52:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 65/67] hw/arm/virt: Allow user to select GICv5 Date: Thu, 7 May 2026 16:51:52 +0100 Message-ID: <20260507155154.1886557-66-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169378796154100 Allow the user to select a GICv5 via '-machine gic-version=3Dx-5', and document this. The 'x-' prefix indicates that the emulation is still in an "experimental" state as far as QEMU is concerned; the documentation describes what "experimental" means for the user and what parts are not yet implemented. We do not make 'gic-version=3Dmax' enable GICv5 here because: * the GICv5 architectural spec is still at the EAC level and could have minor changes between now and its final version; only users who specifically want to start working with the GICv5 should select it * QEMU's implementation here is still not fully featured, and selecting it instead of GICv3 will mean losing functionality such as MSIs * the GICv5 is not backwards compatible with the GICv3/GICv4 for system software, so silently "upgrading" an existing command line to GICv5 is just going to break existing guest kernels The last one in particular suggests that even when the emulation moves out of "experimental" status we will probably not want to change "max". Signed-off-by: Peter Maydell Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260327111700.795099-66-peter.maydell@linaro.org --- docs/system/arm/virt.rst | 19 +++++++++++++++++++ hw/arm/virt.c | 11 ++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst index fbe3ca9e12..f811e662d6 100644 --- a/docs/system/arm/virt.rst +++ b/docs/system/arm/virt.rst @@ -161,6 +161,25 @@ gic-version GICv3. This allows up to 512 CPUs. ``4`` GICv4. Requires ``virtualization`` to be ``on``; allows up to 317 CPUs. + ``x-5`` + GICv5 (experimental). This is an experimental emulation of the GICv5, + based on the EAC release of the GICv5 architecture specification. + Experimental means: + + - guest-visible behaviour may change when the final version of + the specification is released and QEMU implements it + - migration support is not yet implemented + - the GICv5 is not exposed to the guest via ACPI tables, only via DTB + - the way the interrupt controller is exposed to the guest and the + command line syntax for enabling it may change + + The current implementation supports only an EL1 guest (no EL2 or + EL3 and no Realm support), and does not implement the ITS (no + MSI support). + + Note that as the GICv5 is an Armv9 feature, enabling it will + automatically disable support for AArch32 at all exception levels + except for EL0 (userspace). ``host`` Use the same GIC version the host provides, when using KVM ``max`` diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 75b20cfc9a..10b1954382 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3570,6 +3570,9 @@ static char *virt_get_gic_version(Object *obj, Error = **errp) const char *val; =20 switch (vms->gic_version) { + case VIRT_GIC_VERSION_5: + val =3D "x-5"; + break; case VIRT_GIC_VERSION_4: val =3D "4"; break; @@ -3587,7 +3590,9 @@ static void virt_set_gic_version(Object *obj, const c= har *value, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(obj); =20 - if (!strcmp(value, "4")) { + if (!strcmp(value, "x-5")) { + vms->gic_version =3D VIRT_GIC_VERSION_5; + } else if (!strcmp(value, "4")) { vms->gic_version =3D VIRT_GIC_VERSION_4; } else if (!strcmp(value, "3")) { vms->gic_version =3D VIRT_GIC_VERSION_3; @@ -3599,7 +3604,7 @@ static void virt_set_gic_version(Object *obj, const c= har *value, Error **errp) vms->gic_version =3D VIRT_GIC_VERSION_MAX; /* Will probe later */ } else { error_setg(errp, "Invalid gic-version value"); - error_append_hint(errp, "Valid values are 2, 3, 4, host, and max.\= n"); + error_append_hint(errp, "Valid values are 2, 3, 4, x-5, host, and = max.\n"); } } =20 @@ -4192,7 +4197,7 @@ static void virt_machine_class_init(ObjectClass *oc, = const void *data) virt_set_gic_version); object_class_property_set_description(oc, "gic-version", "Set GIC version. " - "Valid values are 2, 3, 4, host = and max"); + "Valid values are 2, 3, 4, x-5, = host and max"); =20 object_class_property_add_str(oc, "iommu", virt_get_iommu, virt_set_io= mmu); object_class_property_set_description(oc, "iommu", --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169498; cv=none; d=zohomail.com; s=zohoarc; b=GctobzXXGx9rqfwy147bHU5uB1c+5uWyCbI0kVzlnwmsZ7/YGvuPkXAbhNJAE4DhSSVWBFdbnmMkPVAXTvw0n8An+taLJ5FnslHxbFixUMQBv+AqlUDJoaY3gpQiteYggVR/L8AS83T9u+Ul59REh9uB1TK8nrHt718OX6plJKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169498; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=jvs97UJqpkItC+Flr/HO+1YZEx5wGbwu0BJu/UWvSl4=; b=chM8GzdV8LuPIh7RbSox1Vy3scVIzPH8cBCUiwhvUnil/dT8RlfMwxb+lJ3/KUdAdcZtcDY2LcYcbbp+AOFYzT0DCL7vcy12UhmIOa/+KWTnDhn5dHVaY6/wABU8zNTY075gZg+Fida8+4G9zsuJOSlv9HytgOsySulDimgdpLA= 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 1778169498336921.1441593720125; Thu, 7 May 2026 08:58:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL128-0005yC-JA; Thu, 07 May 2026 11:53:04 -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 1wL126-0005sy-QI for qemu-devel@nongnu.org; Thu, 07 May 2026 11:53:02 -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 1wL125-00044P-1x for qemu-devel@nongnu.org; Thu, 07 May 2026 11:53:02 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4891e86fabeso12810155e9.1 for ; Thu, 07 May 2026 08:53:00 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169180; x=1778773980; 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; bh=jvs97UJqpkItC+Flr/HO+1YZEx5wGbwu0BJu/UWvSl4=; b=AoEiqFLJZXovxS8yjHp/Y6wwqzEyYkWkQU0U7GCN33ECOleaiDpp7vC8Ff51/a9ZMf Mr/rKXithTAp0AXpLj1wE7KNZigT+sNFbCM74BHGA4lGKvMaFQMHigxjE5bxvsSaSJvJ Ghl6OSA4U6FPZz4C60CAK2Wzi6Cy1ZwlUhdgz44ruBPW8xN2Zb0T4sSr/wwmknyQn8gq BFGs9NzN2Bi+m30WLjXvk7yzLSNTYospDqwvaNl9G+nb4D49+EdffpM5KbON+1Wbprbx fH0qRQHY26YF00mLwdpAKw6a7mdY+FeyrPgyEgvrNyXOXeDd9zg8Infk2Z1YWBAqrQT2 etyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169180; x=1778773980; 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; bh=jvs97UJqpkItC+Flr/HO+1YZEx5wGbwu0BJu/UWvSl4=; b=HCVJSZ5UhfTad9BrIGw6OpeReGqlpPRu7KO5ybhxU9WDccN4oFDYy1dmy7xWR+EgBc xwUjHSGSi+6abHk8CtPMEoWuhYezQYG62g8AAroFQOg5RJruP/KfeyKXP8oula9k0F7h cUPBlYH2XmxEup0+eTLaQ55D6dklEVBRMfAxGMwH13hX0CxTol7616zAspnrZhob90zA UPH5FrOdfJYSKuLmeH2hrKZmXebSUXzvH+xbFpRLvkYeUNq+KpcKDhsjfbhzE082mzRM yNvhAaJuAnPa26neAwpb0tUzHyGQrMMwFxBv3kTcTA8VRTOgM9/UFaBzCVn42mOgMCBQ z/Og== X-Gm-Message-State: AOJu0YyibWmG+k2qZCYRt9en3POKP20rn+zIclg2+GLZdZQ/N1IodVZA JAckRAYyHocrH4iY5dxNX84xZ8HiPr10PCB6sHi6QT1irhb7m6jD7zAZlDyxcQ+tN5o2UaqB9fF U06xU X-Gm-Gg: AeBDiev+O3IbEf62lEIloP6gRoTpuDNQEj5ns02cbNDHYL47CAE7FbZt9fv3NUGahVU Xr0+LP3meNFw1LX7KiFjLwfXrG1QOhfWbjgYB0fEEG8g1V0+EOn1cgcmQAHLKyM7RvzTgkWh42L Qq1NE7Ujg2oa0RB5gsnVFsfjL/4k+zCSRXi22PPesNq4Al9D5iS343c2dh/SxkRhTbCAFK2s54N VHduR1uH+BkfF2aAR33tCa8LZ+iPJARHgDw80uiK4IBoxBOh5ZIqGNVX8jQXM80e4iEhkEpBwTI 9AGh5nUa2LQFRzETahxioicmBcd95Wrabyh0q0l+Z1HZ6FgNOLTRX/e88EWLTfUlZP2zpjTplkW mqFrUnuCcxBqFLil03bDa6xtK8FxBBaY/M74o2LHOdJGVKxACuoNXCBugEooCesCz7y4iDFXx4d VkYQwytE6LnTfG78fOdZSHoD2IDh1gTuORc3acEu0q7g9dr0a3N49gjKgI520Efg+KWZxpIYsAb jUsbf8DH9ajfxvXtdnUcWk8FvJZxgA= X-Received: by 2002:a05:600c:3b17:b0:489:e696:836f with SMTP id 5b1f17b1804b1-48e51e15718mr126809725e9.10.1778169179450; Thu, 07 May 2026 08:52:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 66/67] target/arm: Report IL=0 for Thumb 16-bit BKPT insn Date: Thu, 7 May 2026 16:51:53 +0100 Message-ID: <20260507155154.1886557-67-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169500718154100 The Thumb BKPT insn is 16-bit, and the ESR_ELx syndrome register definition requires that we set the IL bit to 0 for this, and 1 for the 32-bit A32 and A64 BKPT/BRK. We used to do this correctly, but accidentally lost it in the conversion to decodetree, because we converted the A32 BKPT first, and then when we converted the T16 BKPT we forgot that trans_BKPT() was unconditionally setting IL=3D1. Pass the right value for syn_aa32_bkpt()'s is_16bit argument. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3474 Fixes: 43f7e42c7d515f ("target/arm: Convert T16, Miscellaneous 16-bit instr= uctions") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-id: 20260505103726.419195-1-peter.maydell@linaro.org --- target/arm/tcg/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index ce427c5a3c..c744b16345 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -3580,7 +3580,7 @@ static bool trans_BKPT(DisasContext *s, arg_BKPT *a) (a->imm =3D=3D 0xab)) { gen_exception_internal_insn(s, EXCP_SEMIHOST); } else { - gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); + gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, curr_insn_len(s) = =3D=3D 2)); } return true; } --=20 2.43.0 From nobody Sat May 30 18:35:06 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=1778169241; cv=none; d=zohomail.com; s=zohoarc; b=cGTAaAZ8HZg2nxyoK1uHU2ygjgiVKHId0sn/eAfkRQ5/g0GA1dfR9jPlgrAnN7b9gze8uVxoScCdUbzD/FsgRouWJQxh201864vtGjGG3IzmUkN5t5/1//kx1loyVAOx8OAOPC83KJol/JqIJvVAuvyVGHB8j0Q78/tSvDb/FYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778169241; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=SuI/0Iy0vf4QgZARr662releQeW3onqVv+qjOrLL2hU=; b=PbF2xMar4n+u0vadFW2v5rLuhJORinOgRv4fs6Poxcv3Jj0kTbpBJNsrptpIAzQD3gBJNg+U5pKWJdSMsEQRAVFEgbSTMvsz2qr98KnmPvG3WWZ33G3h0Ii8RPwxXrh0Buk2BMy5x9TK3ocMoR89cp+Tiy1YfPNKOixBYOfymvw= 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 1778169241968929.5682309301816; Thu, 7 May 2026 08:54:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wL129-00060S-Is; Thu, 07 May 2026 11:53: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 1wL127-0005vm-Nk for qemu-devel@nongnu.org; Thu, 07 May 2026 11:53:03 -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 1wL125-00044p-OX for qemu-devel@nongnu.org; Thu, 07 May 2026 11:53:03 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-488af96f6b2so12026125e9.0 for ; Thu, 07 May 2026 08:53:01 -0700 (PDT) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5312df8dsm41552195e9.18.2026.05.07.08.52.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 08:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778169180; x=1778773980; 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; bh=SuI/0Iy0vf4QgZARr662releQeW3onqVv+qjOrLL2hU=; b=UsReYeasiiKHY8vQ1bqj5c9XxFkAsTeE95MjqoG1O/HJTOx7ItcgruNAPx/y1SAIMU ut95m1YpOz5D5dAGKUehx879CcCSG6h9bw6caTGB2K+LgapeOKujk+j9sERihXtYg4nN vo4B6ut2kmLNwvifrBAIzgUitzh95swp49sn8P8dwCEAJICSadgMqAkrxFwr17jcLokr +O19ffZ+bUg4x4+JRoF0DwLN8d4qdEy2BmwOhq0ZbWlhf5+zuhczvf42a3rTzYfu/zTV d1Bx2QqjFZDnVtEFU2/CVWi7NUYIAJkBwymFQ9dUWLjkkorEU9qmNKFdp54+eDO3V34B OlPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778169180; x=1778773980; 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; bh=SuI/0Iy0vf4QgZARr662releQeW3onqVv+qjOrLL2hU=; b=J0fuOhSyobOAJisbIHby0kFjVX3IfIF2qJ6fGlvYRauRNsxphyDM9tpTy4XV3DQjb0 5w+Ze8MaBTtJXYi9IkcEtecYjP7epsjxOCOXx1G8ukgvoUPT1vy4KEy2bNHzNIsBl6FO E+uQ7WqNCTM6Sjh/3XKEJvB/hXT23UoTVZypUvYu6X58DLrcxN8TaMjue95kR7ZmcGhV SIYbxjC0dWfHBakB+5Rsto/ZXIzKyJOrxDaJAcb0tuI5/DLbH4tVUw4FQILzZgHFRju9 Z3MXUPhT0d73/W4cIe+jP9jqGxmaDU2E+2aiXVExMdGDLmvRVDXEukpE3pS+L5jZiZKG CiZg== X-Gm-Message-State: AOJu0Yx8hOCp/59+qY2g3djqhWz9DG4dm+7KCQcor7yHA3E1RhzgcBUi q6RT7QBovcr8mBJda7Ku0IpRRfjn49rSshzr35WgLWFC1UeYnB+CrAK/+mV1aukOEfl1/xDR6UV odkGo X-Gm-Gg: AeBDiesl0hO3f5Iz125fymilBiIle4kvW4yZjLxCigJFdV5BJClMaMgfEci0WQkHcNV UYv5DEsIpYO3aotj4sQquLP7HgWy9+VwkamOoWU5woc7dy35z3WpTuhMJhQqc0/5vEcNvv5x5Kp Gm/fidfA5Gtjh0YZaJLFAdYjeVsO0nqU1kb7boMcz8yD1jKsF97t8J4Omso62MHL0naNi9StMyj /mEHPP2MzZBF26vwfHg2fYIEFMiGLUYpe4qB6v2rTEbN9IURqmjSdgyfsm8BxgOByuUnNGucQQn TolqAEmQWCq7sYf5OqsTTJk4zKuCJzxKuw6FuiOZXx85e9IlmsA5ckZg6Jyqxzt1XjWVK/L/4c/ iyHx+atcNHcuT/4tqWT5GE9PN0JLTVy9niSrYFL5wuigN6WfAzkbNTj4Rleokjqxh2S/VHXDy9e R64Y+UoJJfqAZeMT6spT39QM1GKy7RbKZhqmIN/AVu+4iLBZJu31Vx+uPSsyd/fDLGwGgRNoohL uWFhJKFcLI0kN3uCq1dKR6Gwuy5whA= X-Received: by 2002:a05:600c:3548:b0:489:1c1f:35f1 with SMTP id 5b1f17b1804b1-48e51e09706mr134453345e9.4.1778169180217; Thu, 07 May 2026 08:53:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 67/67] hw/misc/bcm2835_rng: Specify valid memory access sizes Date: Thu, 7 May 2026 16:51:54 +0100 Message-ID: <20260507155154.1886557-68-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260507155154.1886557-1-peter.maydell@linaro.org> References: <20260507155154.1886557-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::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: 1778169242682154100 The BCM2835 RNG has 32-bit registers only; specify this in the MemoryRegionOps so wrong-sized accesses are rejected rather than getting to the assertions in the read and write functions, and for clarity add the matching .impl constraints. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3394 Fixes: 54a5ba13a9f ("target-arm: Implement BCM2835 hardware RNG") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260501162700.4092512-1-peter.maydell@linaro.org --- hw/misc/bcm2835_rng.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/misc/bcm2835_rng.c b/hw/misc/bcm2835_rng.c index e4d2c224c8..4492e325b4 100644 --- a/hw/misc/bcm2835_rng.c +++ b/hw/misc/bcm2835_rng.c @@ -93,6 +93,10 @@ static const MemoryRegionOps bcm2835_rng_ops =3D { .read =3D bcm2835_rng_read, .write =3D bcm2835_rng_write, .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl.min_access_size =3D 4, + .impl.max_access_size =3D 4, + .valid.min_access_size =3D 4, + .valid.max_access_size =3D 4, }; =20 static const VMStateDescription vmstate_bcm2835_rng =3D { --=20 2.43.0