From nobody Sun Apr 12 00:56:26 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=1771866267; cv=none; d=zohomail.com; s=zohoarc; b=Xzvkf5GQoLOtZuiwNnAeNqt+xBaH7WWITKcgCodxXyDi46dioUuLTp9yYXOSYA/PyW7Z5PHKd4+5/CRSjrvBqz9+FvW50C2U5QWfj9oBb0cHDPsKGFIblIurLHfnB6cwsZ5bQ2rig+Qu23g1aJ7pb7X9Yho8G0eBrzdNVK0aRuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866267; 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=lfcmTJ7ZFiBmTNCLyk9Egoe7KSwSf53JXY1tR6tWykw=; b=QeMhPFkzwAqa6IAYbDnijcFRbRTW3FlOo8uve+BkkSSli70yKAaOTH0aiVM6XdK/i8ITLT8aaFNVci21fHilUAFUNFdVidfHvlUycho+l+7GiljzGOPM+IHB9OobCLRY0eoE2bQs5PM997ld1/ZfgyWktguuXL/jIH89FKBXv0I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866267741175.84101515150155; Mon, 23 Feb 2026 09:04:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKB-0001Dr-BA; Mon, 23 Feb 2026 12:02:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZK9-0001BM-M3 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:21 -0500 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 1vuZK6-0008U8-9u for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:21 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4834826e5a0so57107095e9.2 for ; Mon, 23 Feb 2026 09:02:17 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866136; x=1772470936; 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=lfcmTJ7ZFiBmTNCLyk9Egoe7KSwSf53JXY1tR6tWykw=; b=n5metzxNLJK2AmRGhdaV1YhvYMl1BHgAxodcMb+8JHGnIfiPROwAFLAaJIOYC4Wrhh IdhaLaucYJgfOmI2NlkA2DrFiDAKZX/xpq9COaF23rcTxyNPfIoj0O2yz71iK9dcTIsM 1pkGzbmbRBb+oOXsK+MVFzV/j/Xa7qBCj7pJvkXbxBnp+0PStBwsXu5HgIEoR2N5/prQ UAFHrNcSqw0//ewXArbnfWQklQsM81y9Gx97hO7XDE5Qa3GFCeLcAIE+G/Fvn1uLJstE WFCF4IToMEfxAxlYaXcbLvfnboxazCeAnM0EH1jIeh+g7Bbvj9J+5FMCTDA+aWoPXf0O xPyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866136; x=1772470936; 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=lfcmTJ7ZFiBmTNCLyk9Egoe7KSwSf53JXY1tR6tWykw=; b=npSiUMyEnlPzumkjquvfIP7Fc8BobxC0R17NOCluRA43YvibjMly6toc+PNdCWTgAm 2gaSbHZGfnODBwR6rQwLdhqosqcGQ6VFowAi93jvyZJxjSpUPH9eRg99bu4OnUvU3E1+ e3SZLG6IkMYYoc9PgQn2EVQmybIAcGQ8Lt9I1/lK1zDB9vyXcox6iRTlg9MqgtVAS0kE H2DBa1zVnGhnfdHXxrOMbPJNMa8JIracaxGPFelSTDwlf2FrtY2cfJXitKKF1Vv2HzY5 tgg7vtLm2grMNcW5PrD8SedJ1pn8wvbs4OUp/IP4pSb7wNVgcEHYec/Yz2ZFIPQ+JVB3 3dBA== X-Forwarded-Encrypted: i=1; AJvYcCWJr8k9sNEOJrGMnftgG6RtjD+6x5Jb+bKB99jXwDbjuki75yEO3RkgqUt8E0UB6WkZaYgjBBKn9FHO@nongnu.org X-Gm-Message-State: AOJu0YxU+hfQw5+vuzAp0SSLgF+wJFTAMG8jnIfhcQ+ZB6fJQqFpyPIm shLb6HQ4qdCkEHqFQGTdlDSrSaGesw1tbHtbpDk8KHlrKQpungsXK6fAcd1v6kFU/Ms= X-Gm-Gg: AZuq6aJWikLDzs+kdiCWpLKGIY/9i13ga1ELiecq94fsfw4GmSeywuz+WJP4LUcnADZ lth9urEQIckW1+JSGf+Z0g2i8PpaOpDf/vcMzgA8617Y2ZjdwwMwxYZ2hBU+hIIlHoQGjwqJ8zM no7IoQZaLJQjR06UimgtOnNrYfZf7J00oEfFhyVHK1dpxbRrivUV05OdGQ3tE1nHBGZ2F9zdsMt k7+W42FHRZFWrbg4DFmVahKm6oLtWznX4MQsPYq+FNNUmuCQyQx6ZmXfel0vNnq6GhkegNTLBWN mzgPvLFAEg7dW5G5ovuqwOcxEbsC6fm+8i5erHecO9WFIaNHvTGOhsxMX/VvsHZqst/tVpv+Gxm e4jsOnIWmP8xIkcwd2xLxXmzQxCYiW0NRNyz4p2YywaFAk577IF647F23xFlFsDwWfZvFGkHSBS FdDcBeG7IwnZ+nEM/kMXB+h5Oh/ObhQ0W+5dwgppU/ZR2esa6Go7tFfHyKbQAynkFmPMWRphlwf uy9VaJtDUz/jbOm8niQ5qHHDdLSI5c= X-Received: by 2002:a05:600c:a11:b0:483:361b:deff with SMTP id 5b1f17b1804b1-483a95c9e16mr164522645e9.14.1771866135388; Mon, 23 Feb 2026 09:02:15 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 01/65] hw/core: Permit devices to define an array of link properties Date: Mon, 23 Feb 2026 17:01:08 +0000 Message-ID: <20260223170212.441276-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866268673158500 Content-Type: text/plain; charset="utf-8" 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 --- I want this specifically for the GICv5 interrupt controller device I'm working on. I'd like to be able to pass in links to the CPUs connected to the GIC, so that we don't have to have the code assume that it's connected to CPU numbers 0,1,2... the way the current GICv3 code does. I think Phil also had a proposed series a while back that wanted to do something similar with one of the existing devices. I figured I'd post this early for review, though obviously it's a little unmotivated until I have my new GICv5 code into enough shape to submit. This is tested, but with my work-in-progress code. --- hw/core/qdev-properties.c | 78 +++++++++++++++++++++++++++++++ include/hw/core/qdev-properties.h | 40 ++++++++++++++++ include/qom/object.h | 19 ++++++++ qom/object.c | 42 ++++++++++------- 4 files changed, 161 insertions(+), 18 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index ba8461e9a4..f8181b0d91 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -669,6 +669,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 @@ -950,6 +951,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; @@ -1059,9 +1066,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 d8745d4c65..936d06023a 100644 --- a/include/hw/core/qdev-properties.h +++ b/include/hw/core/qdev-properties.h @@ -168,6 +168,31 @@ 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) \ @@ -219,6 +244,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); diff --git a/include/qom/object.h b/include/qom/object.h index 26df6137b9..48fdbf353e 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1750,6 +1750,25 @@ 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 ff8ede8a32..90b8f3461e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1895,26 +1895,13 @@ 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) { @@ -1931,11 +1918,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 Sun Apr 12 00:56:26 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=1771866232; cv=none; d=zohomail.com; s=zohoarc; b=hb3w4S3mF4JvwhpN8KzS1hGRUam0uKGBWNH3kwuTJfjlyb/4/rd2+vzvjZln9v6dv+FrrvYSFk86wWnyWSDoQYTJIhoc5qADv3PVLG++MzOeLP+FXIGchUuEAkShQ9aPbfbf5kWYGbDoNqOWO5++k4Gex9dPHQn+7VKIBFawq1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866232; 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=QC2jCmUmDa22pq2M5e1IUAC/xLyvzU6A+/CopHKbGoc=; b=LPhRum/OGAsuamph1nJFUhY8X06MbN/OyQTt1iFeHDIBZK50m6OA9bYC+Jto2u3XjyX9tAgpS5fZa4KacxkwCQDP5d/tKJKEHvbmG+t/j2fGTSeEhFtWsUIYdQGzsJBiQ7J6IyhBJIqpvB1WqvxX+s2S3iIQPjVJaXGZdjJnVR4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866232367555.0481100754174; Mon, 23 Feb 2026 09:03:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKA-0001Bf-8b; Mon, 23 Feb 2026 12:02:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZK8-0001AA-SZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:20 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vuZK6-0008UE-Bp for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:20 -0500 Received: by mail-wm1-x342.google.com with SMTP id 5b1f17b1804b1-4837907f535so41149275e9.3 for ; Mon, 23 Feb 2026 09:02:17 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866137; x=1772470937; 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=QC2jCmUmDa22pq2M5e1IUAC/xLyvzU6A+/CopHKbGoc=; b=r+jNM1/qTLbNKGTBa1+KkH5GxpFsJRaVb6+AKqUzF1tDdeegUVkPgHyDGLHyVhKjyF CKvuOTJYjmsjLZ/SlKSwwLmje1E7bdyNdUK/axWINDiIzKQEV91POGAgYZXAdz2g4dDQ K8lTsvH8jOMHSpCROlPO7H3sHRjwX+9cZWXmByTBkttxmlzIZ5PSBeYB8T5BRcz6eFJE O3th+LeyaoAPR27Dg4N2sW1RaQ8nJUXhId0Pc5q3JrdFh+PP0KnjrcmSte6CvMfgM4Cd ciEQP+XREEsTYj698PMlYiDYooiRtbT84GLcAHEbdbejgBhnAVi4BbGnG8NuSsi+PA92 IvSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866137; x=1772470937; 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=QC2jCmUmDa22pq2M5e1IUAC/xLyvzU6A+/CopHKbGoc=; b=U8CjFi3d/he0RjIRTEz54zz2H9TTx8UZmjL/LYKYRVMGshTktMmIa3jqRv4BtwZBl3 8T/xG1zYTGON82gTXdV9X+CJAq60wwGYBSlYfDFKYfuEQPAA1UEDt6/Rv/1O1BmwUKLw bGZfd56zMO69WJ6ldK2/YAzMM5L/qpKVAzCeODrUp5Z/6kHVOAkloNhP3BVM0jYlQora J+CDiyT3Q9FM16e7SDFNegQsNLGW5DPlvuV2DLSD2LgIitC1EPGo92K1oKMmo5BR6lmS KFCthJ6bnsgk/WE2mFSQgGRmNwXo+U8h4+5phL9tcsAJZsNWr7v7XvIy24Bf54WCe7bD d2vA== X-Forwarded-Encrypted: i=1; AJvYcCUHtkhb80Ahq9f31w6HJTvx9qI6lsOozTbfMqYJI1XLlRwLP/djx7Fnkvn0GUzgnnudTnP6zwow5Wco@nongnu.org X-Gm-Message-State: AOJu0YyQfn3EuLufMlrfZIno+ND4gcNMpRlGT7mXRivzgfxSaZ3e0rpd 5AJMgqUFessLnv+DJGaqsYK8h7sftUzqxH5u2BgOVbRKgavBBnY3s1hY0s+IsLqNdad9dyGbqr7 e/tvhLhE= X-Gm-Gg: AZuq6aKxj0pzX3y5g9yLedbbg8vF0HXuIOGR/AGYZx7vV/133psC/SVsi6ddBj6OV0A I9OuzRlUw2e7OX481rq3aj8DrAzOwOFcjDZCkBBjVbsl4YR7q4payAhalf7xZTJ9+TBEbmi3ugk ix341r9visLYygUllD3oWSMz9a0dcfNweMlo1PDGYDy1HCy+plcP5MdAPmzRtw8kAHmXUWXqVXP CJgoG0tGfq3xJ4vfI5vHVPF8tXoPx+8jUzrT5lcI2or5Eapk5TiWsfDRbs3zoa1dAczrVgS3yu+ JlVVftTHd5eCLilv7qM4hgjRQQSykA2ndPBl+cKMW3iT5lh0EBWA3whl33pMA7+HHHB/kl8yXnV puZAqJCgd4QXWdWWZW91aAj8gyzjs/nUIPAESOR97TrE6Oa2jpz7cqjhtEjbz9SxI7Ljot2wUSK 0cU+uaxrn20mBEnNf5fEwt8YLhTxekwTsbBtyZLwUSPfrcNUe0Hd9yfNTLGZzO9i//tbAaex/BZ c39S2q/oVMlT46ZR8cd03HqhjOe3R0= X-Received: by 2002:a05:600c:8b27:b0:480:69ae:f0e9 with SMTP id 5b1f17b1804b1-483a95eb3bamr185842405e9.16.1771866136485; Mon, 23 Feb 2026 09:02:16 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 02/65] hw/intc: Skeleton of GICv5 IRS classes Date: Mon, 23 Feb 2026 17:01:09 +0000 Message-ID: <20260223170212.441276-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x342.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: 1771866234265158500 Content-Type: text/plain; charset="utf-8" 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 --- hw/intc/Kconfig | 4 +++ 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, 141 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..a3241fc1eb 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -35,6 +35,10 @@ config ARM_GIC_KVM bool depends on ARM_GIC && KVM =20 +config ARM_GICV5 + bool + 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 96742df090..e4ddc5107f 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 Sun Apr 12 00:56:26 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=1771866681; cv=none; d=zohomail.com; s=zohoarc; b=RRwf9j2TmQFTk3OkI6BMo+PPnCOyWBpu9i3QQyzx1crCubTSDzVK59hZHfZq6s02D0S1Im3zu4hUPn6VCUPwC6mN8a4QM9J4mcjxKFnLuZo9s8zTs0xkXOGlQthi7MQFDY5cZXA7xa6dmb+/07EETbafTHnsqQceVDWRhP5LXJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866681; 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=kPtDe6w1LWavMJnFSy0nCTCbHx5GgbeM6ZGU53JeD94=; b=ENQkxcB+ylhyI62rc/NApLAXS0wiBmRmO38X/cUZMKw1g8lq0qgWRfLhBwqIBNg4AX3vEZMl8iF1lF4GHgywOd15h/1H9Ny1FRBxh7ky0YlGKEmhLm9y61Qu6l7AoKhcpeTTeATUgq7XP9ZcPU7peKL+nBNhhoCsKGXwUjA8U0o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177186668099611.755625026313737; Mon, 23 Feb 2026 09:11:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKD-0001IT-F8; Mon, 23 Feb 2026 12:02:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKA-0001Ba-4e for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:22 -0500 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 1vuZK7-0008US-ID for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:21 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4836e3288cdso30463545e9.0 for ; Mon, 23 Feb 2026 09:02:18 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866138; x=1772470938; 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=kPtDe6w1LWavMJnFSy0nCTCbHx5GgbeM6ZGU53JeD94=; b=U+2uh3XLm0nvZ1TNoUual6Pd0/IDHtDvLmG8SP+nnefPh6sdSm252L131i90BQWGjb w/qIY1rb5xv9rc5SMbwBkN3zP9FFY7L4j7nUt/jciqfnl909M/7/uU17mizoj4aXkNHV oY7qNm+DM638lsl7jCP/A9XG4uZcEzlZl2G0TQ3wbxMl1mZ1WdCfVT0N67kDPDJZGzJ8 ZzohlqJ9zcDlwFIQx3Ae+rCZSMHe5Pgk83OvxeWK7vNJHdUNTB+OuhEvuB1n5Pd40Hdu ofWcBueVNpP8WDKJzswrJvdJY7WGNgxWmAFUpmDl550O8D14drpndWoozwR8P7VKv6w8 LfBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866138; x=1772470938; 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=kPtDe6w1LWavMJnFSy0nCTCbHx5GgbeM6ZGU53JeD94=; b=UyEVSvDpUh1tNU/1sNFRRwHRib2Swie4fDIP3C9CSqgHMZtlfllLhU1QPJV8BdvFDr CSJGbGxQAejSGLE9vW91lAVdNKNGLnlZC7HOeJ7M1smSdVlSao1CI+gHaXExFBSvZ1Mf de2mGf0OybzHINFjnXqDnkmLuuu2ms/dw5K2dqFslAFY4Q9q/zYrPtb05bEPpU4f6l6c jSpkoLVjo3N/BuNGGd7OwzMBI0YVQt3dcuodZlv2VclkX132ysBYHeIgy4FT2QTq+hPD PmmU7n46Dk0l/FjeoXhcDTvUNb1VUjqWieAjHJGmHtr3hNXva2p6GUqCQSJFxESg4Swk t7QA== X-Forwarded-Encrypted: i=1; AJvYcCXn4YSk5QXg4vCXUyZ/k6z8ZFWFo1b0sqBkwrSgHXeNeyrb8S52D5OInsmxcgG30xu5/swX0xeUEnyP@nongnu.org X-Gm-Message-State: AOJu0YwjoRn6CTAkAWeW8hfs0rB9fXpk+ADo2yLtDw2ghAOSw3WJaCTx 5pJdDdLTV9Y3OXJGvytfYSY+LXCIZw08BHVcVk/xLpYjr5ZSHfMfRDsC8MH2c/QdLTPShYii3z9 QGMJ5 X-Gm-Gg: AZuq6aJ9WO62g2GcQGCsaRj8BI0ugd5NGA1Yr22YQRyA0rsgaJmTugmIu6rlmQ8hJNf XrtrnYWWpHnEAF3o/8QUWdX+VutUKoR2NOQxH4CkhjAIRfJ3eunUHuySAz/XUFrVVDDreDb6ozf k/b1xEEwvTYZeqLrwhEfJmOsbiCoQ1Rm1yk6EDszegnQD13F3IJmvEpwR9AbiwElZiot7F1Ont8 1nYKwMXr3fYOlVWCQttDlh8BzYVz304srOerCJZUQ7YplC3hvyDx6tvK186bXB0TzLBg5S1GonI 5ds83enaPt0EDWAyKOWzxciO/5Fo6QRyQ3PlmP7RH4clbJxVeGl9HZLTYfij5amONT2mJKpQF7u 3+Qm0D4FsdZ3R8NCFHmElOk4OWqsovTK/LIYeG/XY2q/DKMzq1aG6IDwGqJpmTINWpCbAej9AZ2 jIXy+lk2bMYqYGcO3gWgsJIvAblOUSMg6K14/4Y1H8yBMDv1vQNc07z8aEH4reHqFT1AzrDSMbh fgN8X4p6y+ae7y+BWsCoZOFs5QusHc= X-Received: by 2002:a05:600c:8a0a:10b0:483:a2b0:d210 with SMTP id 5b1f17b1804b1-483a2b0d22fmr170457205e9.7.1771866137541; Mon, 23 Feb 2026 09:02:17 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 03/65] hw/arm/Kconfig: select ARM_GICV5 for ARM_VIRT board Date: Mon, 23 Feb 2026 17:01:10 +0000 Message-ID: <20260223170212.441276-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866682909158500 Content-Type: text/plain; charset="utf-8" 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 --- hw/arm/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index c66c452737..91a15040a4 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 select ACPI select ARM_SMMUV3 select GPIO_KEY --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866672; cv=none; d=zohomail.com; s=zohoarc; b=dIV8t7Qe9PRyGJA+ZpdtWRz9hI3osn7xhvTKQBc7ecJjLSWO1SIM58KdS8mTZGxVpCT5dXhvUO0U8HKjr9LnVJvt34ZhVfxZv04MSJteQZoH/a4xuCm3W8jsX4tzUCQXGTcEpyLs814hQyx9D/zSGAMvhOWAiWHjh1cvvs6qqTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866672; 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=VtZnSTrAdZDYVk7EjD3fTK7vrjYFNEe+1oEHJx6dAb4=; b=fbFQ1DWNXA77QulAh5EDgw26xj1CCdT5jd4EW4Qx/O0o6Uq61FsHa95PWVsD7NVmg0XlCIqW+Y/k1hQ0XmDBKR4/Xes8HdHLhmX1y16KbuZeI/z7SjOs2G3EurPcCmc820uMSBQGXzIUkZCe7qXYEuddnY8NOanPyegl5Tk9hDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866672140871.0806636699034; Mon, 23 Feb 2026 09:11:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKE-0001KK-5f; Mon, 23 Feb 2026 12:02:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKB-0001EN-GK for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:23 -0500 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 1vuZK8-0008Uq-HG for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:23 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4806cc07ce7so43123495e9.1 for ; Mon, 23 Feb 2026 09:02:19 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866139; x=1772470939; 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=VtZnSTrAdZDYVk7EjD3fTK7vrjYFNEe+1oEHJx6dAb4=; b=ORJeWMUwYwWwhIkC7Ohyb5f5c8IAqUPYy2WNQt97+sWcZNM/Ef/IAZJ5sOECokygmi S8mpCLhawXZcRWAAvsSKNsCMJ9VkCm7mJvCMtGXXl4w2rr8s5jfMwEe7LuJt3E/1egUC bKeU2oS0osNZoGXX14niwodAv7y2qD5S1IKBY3hnndiaFRFz4OCnQipfWLu1+NiaG9Qt MQjHwkZSOTXTEOsj/D4u/OXNTK8bNtfb3C/G6gMjTbVUtLpqadsveymcGPe1i25h5Fm3 YVvyPkwJDO7BE7dehaXoMDudisrMrsaMLeZP4nFrH0PXepCy0YfwhRXq8NdohUjaOtBg tn0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866139; x=1772470939; 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=VtZnSTrAdZDYVk7EjD3fTK7vrjYFNEe+1oEHJx6dAb4=; b=WDcEWtGJeBmcMUQqVr8Ty4maearuYirQRZ3C48jGaWatIQuHOQ/8yYia9fB8cSqGW1 UXePAB+TXxitbzze7SXEnPjiQIyQN0Q5jqhwh64HH8RkGxq6D1lU4fvYrvDh/hyMGsq8 uDM01hD0YYjJiOslQXYy62LhJdKOsUlgAywabvpsaAYvIkz1Rkd2KSkeNj8rLd6j+X70 eWNNuA/awEvyjZip/FYDhhqax3MTkRlGvHCF1+CpEiOx0ZtDvBt8KSEnDz0GBq1mFpN/ rZ1D6EOOkDGE47Yz8W73JwUAYTD0eM68lYv5LbjuXXZgD65NpmtJbdehhNrzGAwBfyQ3 X3sw== X-Forwarded-Encrypted: i=1; AJvYcCVL7hW1bJTIi2iVIHj3RpTuQziR07+6ApEpqPkcz+uS1DEtnjFE95urwTfiN3w9UhMxy7mWm67c/lwu@nongnu.org X-Gm-Message-State: AOJu0YwVK5v2cAUr2TFnDMJGlCDN+o+tvNclXiRlQ66h2w5jYBBEQy7g ZjvHkzBPZrb0OnNsDI/23MKOOwz9NOoAGjFgIDEWo2Nxza0i2NnO6fU02Yjo/EGkDO4= X-Gm-Gg: AZuq6aJTVKBLjYAy2mat9dtRrMXVom2ICtGO539Zbg1aRj8kwXE7HWjX8LggWOhw3qe 6xJh20ejQcjPcdnr5zIFYvPdsVRSS8GsBI9Ax2EI83Nfw+sJJE0613X5mZvaEQ5VWkB+/A6hMJF Seh/cGl8YL21ggxVS0ZcpXkpfb0vRIu/caEtu3+u6CZWXbfbnr/4OY1DckNzzXaDHHo82WTKGpR U1FHCmzmd4N5c6nm2T3d0iIErXHQzo0RhMiy+novwmBRZFaW6HXyVIDoUDKPXcDfs9sfk3x0IMn +ELcHR8mlJ7WMZkJndz3JaRrQF60/hLaj459v4eyzI/Gzuy97b8vUociphHv5OMLGDtJ3uCkt3a 4DOuTkpvPpfESvyDFFhsmTCX3aK4Yz7t/y9NIkyYWRCFG5v/wWF1MV0HGznIwg0jNZdmFnrtKWZ M0IWYOEX2au4jQGeJGKh1Aa6HFgn9r6/eQjutPo62lrxga3guiqob13mIj5nTwcb7K64u5AmIhk Vg2MZBbU2n2HhD/WVHuYtPfrnpf/TQ= X-Received: by 2002:a05:600c:468d:b0:480:7162:fa48 with SMTP id 5b1f17b1804b1-483a95c8f2dmr164256725e9.13.1771866138551; Mon, 23 Feb 2026 09:02:18 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 04/65] hw/intc/arm_gicv5: Implement skeleton code for IRS register frames Date: Mon, 23 Feb 2026 17:01:11 +0000 Message-ID: <20260223170212.441276-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866672985158500 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 --- hw/intc/arm_gicv5.c | 193 +++++++++++++++++++++++++++++ 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, 313 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..0eb4348e81 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -8,9 +8,178 @@ =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) + +static const MemoryRegionOps config_frame_ops[NUM_GICV5_DOMAINS] =3D { + [GICV5_ID_S] =3D { + .read_with_attrs =3D config_secure_read, + .write_with_attrs =3D config_secure_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, + }, + [GICV5_ID_NS] =3D { + .read_with_attrs =3D config_ns_read, + .write_with_attrs =3D config_ns_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, + }, + [GICV5_ID_EL3] =3D { + .read_with_attrs =3D config_el3_read, + .write_with_attrs =3D config_el3_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, + }, + [GICV5_ID_REALM] =3D { + .read_with_attrs =3D config_realm_read, + .write_with_attrs =3D config_realm_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 void gicv5_reset_hold(Object *obj, ResetType type) { GICv5 *s =3D ARM_GICV5(obj); @@ -21,6 +190,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 +223,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..cb80c8821c 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..8ba2e5c879 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..143dcdec28 --- /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 Sun Apr 12 00:56:26 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=1771866509; cv=none; d=zohomail.com; s=zohoarc; b=T7jhXp5BQMK9YylFBzK1DzZsBw+C4dFN4NFNDS4tbFHg671E47855rQIwcBtT1FXapv0N7LLVQe3rBCzPZQuP2ezQHloCwquB3oTpNk/oSrMzMgjbRvUSRaJVKRdioorWtloDg3j17z4v1Mk6V1jI+9Vn+dYonVcBuE7EAQBklc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866509; 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=Bp3RXdjJyq2zUkMPFoXr57Ilr22nwEt2DEhIgGusj+Q=; b=cq9zvNrWl4ByUw9ap2h+bQIEksAHc1IBY/reVGf1BwoOjIPzyBFRS9khWRCm28R6QJOxILANVR0EopATaW7SlVxHcbozRb+pz4zIetK6QVVNQZ7xuo2sWFhWGoRYdtwmyIZ0tU3tId+E8vdHflAvDmSshRTVEkcOpzy/UU8/YSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866509623543.7006690823915; Mon, 23 Feb 2026 09:08:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKE-0001KF-1d; Mon, 23 Feb 2026 12:02:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKB-0001EM-Gf for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:23 -0500 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 1vuZK9-0008VL-UX for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:23 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-4362197d174so2920754f8f.3 for ; Mon, 23 Feb 2026 09:02:21 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866140; x=1772470940; 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=Bp3RXdjJyq2zUkMPFoXr57Ilr22nwEt2DEhIgGusj+Q=; b=OxZ9v46BKMhJwt8TwEKAcCSe3Q1PCbjwhH1sQ24HIhDhQHEuLOsxaYhK5++D3jN/dG ZINsItsXfmpHJPoRWODIpRKmLZ4J3jbxrmpsAkfePLA5eiPMTNZrvfs+fT1YSqIBxwud GIH0XOsH9xCOB01JiN6QcQEW+6jnH+9kyRo1uAoVR0QffwVQO5TdTOfn0XBMbcnj9T5e bj5gvBBp/1cgm795QRG1jATPPVFkjHhZc6HFM0LRBvpsaOGVuBnWSIL57iIkDp0hsUfy ndfXV3VISxPjSCzG37FbBPo0wXUiA7Ps9t7IrBmUHd+KXbhz1ZkektHidbTW58XexeQT MroQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866140; x=1772470940; 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=Bp3RXdjJyq2zUkMPFoXr57Ilr22nwEt2DEhIgGusj+Q=; b=CcGy5hzrsZgATDyGibM59FwjL7SLBCNAydK3obBr5YSLcNowyT92qB1qtlLXrsiKec REMYzYtwivrU57Nh02W3EEzAv5kme+EtqQAy0TxQh7tU3TmJmRdtRenC20ue+AzggE00 sxcKA4aV6tl9KvLb5rLzP2X+ay/+Iw0b9Sd7NX1C9dEJiF2II23wxKLDcbV02MRBdSN4 LUTUJiF2L+xvxMB1KaJPpdwTW4/ifuoUp/vcDXkiUUE9TAHcEFYmz2CUBQ1Ibw290Bx4 PMf7vQAg3avcHfWrRzkGtx2a3KuzUAturD2eBSSLS9sb0gJSk2Sq4nV0sF0ZeT2q6Nfz gaLA== X-Forwarded-Encrypted: i=1; AJvYcCXuPxMFdRw0cwbaJkTQ+AC9X+LkbC2GtOiiL5fB4A25TSxBV7v9z1OqgtZmLhWyD5+OBPF6xxz9Fl52@nongnu.org X-Gm-Message-State: AOJu0YyasZECinwMKlL86jit2rm3YRtT4iMyeh8M0dVAEevVK75mp8fY SDnNBkK+0KbtkOUN7LM21z7iutnn0RyTzyoAVi3B/039Wdci9kstez9plvF/89pPLb4= X-Gm-Gg: AZuq6aKbU+kga7ZQZLgpRdj3B1DRHUNyoSXBng3GI3LDgYgll/0zUsxxfUb4AQ1rC+t CmrRl3O802G2PXVSgincD5/8nei18U4gP+SoLTEZxInckd+YsZjipXUzOHnboOeMWNMADS43oHN gkWvV/2YC1zvEG2tnffiXfy2c2plZwqluiEeUOtzhZ1V3GODKdppCYiD00ekT6K6oJ4yxiUkJRx E96kmQhNqphtXRLKgcMrsiV6ZkIEvpM/cR37i4bzu3pDjUJ3ynrwbmIEMtkf+KyLD4nQ1l0SQRN 0gmTtxh04fU12NVQkiXCB9rIRLPs0g8ZUQdn62ZwpvQN48JBaJWRaYHWnxgfJDVytEsn7rBxPCM F/yGRiQp4Jt2NevrbspS0mdWVVbZrNaTkrTnkJ61zLaHuLbO+6xXIcXmAC1oBziOsBeqKAXMRvz /Kxx3BmwCwcEN2jjC+dhJwpnrHEFDlSaAb+/pmhhkBkBCB/7EZMSORi2dLymeYkwSnF90hTpd6D 9pRn63/DOx5B3NfKN/Qn9U+4YD7iwY= X-Received: by 2002:a05:600c:a00d:b0:480:690e:f14a with SMTP id 5b1f17b1804b1-483a95bf2f3mr162385865e9.14.1771866139684; Mon, 23 Feb 2026 09:02:19 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 05/65] hw/intc/arm_gicv5: Add migration blocker Date: Mon, 23 Feb 2026 17:01:12 +0000 Message-ID: <20260223170212.441276-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866510054158501 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 --- 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 0eb4348e81..73a6e629df 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 @@ -194,6 +195,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 @@ -202,6 +204,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 Sun Apr 12 00:56:26 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=1771866301; cv=none; d=zohomail.com; s=zohoarc; b=DwQX/0SRgmurwg1V0hH4+QIbKcy4fuOOqm8ydyxiQcSsK5ZuU34I/h2FKUDmPxCdpdrZ1ZPDvGxBrLhG2j1o5FpOyZeqbbNOlU5BDCzsdBhaCEV+Bx6LSrVX7mUgz0UNqm4CA3BSwlcUZ53Nfv5DCfartkOhoYtrAn6NAx/ns8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866301; 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=5cft2ROe5R4C7Ip3bP/3xgfz9mph6PasFRNc4x+3lY0=; b=YM029QGxzYVC7gbSPUtoM8smrdgZcREKXnOSqr/5Cvcegg3gSka8z4fmLqWVbiczTninRpB/ORr2d7MnINRvxgY4sa2YwyNfQ04pLoWEOFcuq3S3Olq7RXdlLgxxrIJeopnuahdF7gTLThXKqGF/ddNuSSwthOT/cScE9FWrMM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866301107308.99217783495817; Mon, 23 Feb 2026 09:05:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKG-0001Mt-M7; Mon, 23 Feb 2026 12:02:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKC-0001H4-Ge for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:24 -0500 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 1vuZKA-0008W4-Dh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:24 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4836f363d0dso40269255e9.3 for ; Mon, 23 Feb 2026 09:02:21 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866141; x=1772470941; 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=5cft2ROe5R4C7Ip3bP/3xgfz9mph6PasFRNc4x+3lY0=; b=STW3xIMnlEKKmeCabu3QzBTWp4dQ2co0b5y0JP+ysA+wPnguuDx3mWhvCLHVPMC9TP iAyWq4HlEBUmubkmvd2FW19p8n2cWzeXjX4xlTRIfptl8MJW0//+WjOr+MLnh5yVdr2N ydt1aSGkvVY+8ZtiVJGMWfNR/6eWpl9Eo84j+J6aCVZ+vFRcG87MaEKYlm2GuQ+aRlXZ nXqnF2wySVbaHhyrti7XAB0j9XZLJ5SmwPxQnwzZssyJb82hynU4Pf/vlKZvpwRR8Wnh 3lDBWPLmWUpygIm5RtkwMK99dF0RW8X8R4OguofLc77nTHbxBC7mCw/4eT8IZF11VArA Gj+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866141; x=1772470941; 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=5cft2ROe5R4C7Ip3bP/3xgfz9mph6PasFRNc4x+3lY0=; b=uLskmAQYeugoRdtVi2YJVWyd4yQrQa0NZGMPHDsVv3Mp6ONKa/8BYaBw4xAsvrSXNJ 0SgFGZtOwUikf+dQKlSkUXu2/sw8G34qKTlro7q8IeMHjTNGWk5W8u21703HyUltYimh 1QE/NcxHLEOxT6fcMxKuWGuGy8uHPYPKbWhA/GM9/QWyl8F82E1ci3jjnPrIhemYGkre lWJquNuL98JahqPsC/4cVJDaUM8T9nbfxvTloOL+uzYetnvDNesTiOFnXPp5oMQjse7E EKYEblD2a0kjwfxKmZdfbr9vIBFecO4LQBacFtklxUertU+BNFND0NmSZyiycae1UzCi 0+/g== X-Forwarded-Encrypted: i=1; AJvYcCWP66Yruymi2GN6fk6nRacvrt+icuDhJNxR/+HtnT4c/LwHnwAuJa2NzjkqSvoFpqkym68WTzdGnPe1@nongnu.org X-Gm-Message-State: AOJu0Yyb888HTc7Orer2LEhKGQMYVClxRX4HYit1IdeZv8+ZJ4ifxAXT GX2aJalx0YiUrjfC3fPXsBLeE12jqdkL76cjpiFfzx3eTNDIXEaQPcPXnxIlNnG0sKE= X-Gm-Gg: AZuq6aLEuS6PB5ZwQ+h71+msZtqdf2x72Apv6+Lfyw85biKgh0e588o0XEhHBtOZcfG iK6ZQMRzzEsjGx3lJ8mTZShfT/zTj3jLl/v4z1b84tG0s26RmayqcYdy9TdjF3Y1e4Wi7El5orG pTQWP+1MRPZdkKfLWKdqIzbIYTWavpx5VZU/g1/FnbMGStvm3JcgzCyU2tIzO3qShDbBHKp5rrr p9yoGRSptd0rbxBA7pKCX+tlk4cRT2wLBNxBKd5YIKBOJOD7yWX4h5aMk893W30aFQL65m4r3wr Cy/dgUOLUvQUfp9Y9SncoLk7kCIObeHkwaswsCSeNYCVDczwh2Kg38rb1gxAh+47VnSYyRz9WIn jiBhJY376AoITLbOdh4wL1h8/Xjm7Zk9zerrEl6CLy7J4KrhkbKO+zvslls1O1cVxT+fGp5ko3R 3H17nbHVAHEHRMlhOKWUWTdj0Bw2J2M5XyKd3b3SuzkqvG7Ya7CLVdl8JjKxMNLgIKSGHrVWHWZ T1sX2ep1Otq97/6jugTpkmKtflysBjBicWNaVuF+A== X-Received: by 2002:a05:600c:4fd3:b0:480:4d38:7abc with SMTP id 5b1f17b1804b1-483a95f8eebmr160065125e9.11.1771866140779; Mon, 23 Feb 2026 09:02:20 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 06/65] hw/intc/arm_gicv5: Create and validate QOM properties Date: Mon, 23 Feb 2026 17:01:13 +0000 Message-ID: <20260223170212.441276-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866302638158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 cb80c8821c..c8b6704fe4 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 8ba2e5c879..b22f020a53 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 Sun Apr 12 00:56:26 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=1771866810; cv=none; d=zohomail.com; s=zohoarc; b=DDVXk2N/1vnqHIluk7C4OBc/LcayfU3LmQ/yK/1b+xHddYRAVSo/qIaR0HvHFqxXt8ycDDesO0Fn4bc3W1kIu+eWKziTmCTdUL6y8lse5q5zX+n5yL7JoKhBUyE2TAWwbgKMK+dSihx3y6JJKb+u23ANNJO30SBarPlXowXuYaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866810; 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=pgbI5Qqmzf+DxfEbRHQMqpET1e5tAlZwB7KWYK/P7d0=; b=FdH58VdBzjWeBcQbdZVGk7nhwoJg93pdO4FXu74bM0DkgNKn2Y0gKaQojFvwHN3rJmufBK/AYDbQ2jZJbqt79oxe7GQVbeW+/ufCHYRr1B+MnlQuSKPRKVoyFGkPF3MVSG4TMsCKLAuF4qBQ6AgzgpgkKZ0P6ljp88+9iS172BU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866810949272.7734738891605; Mon, 23 Feb 2026 09:13:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKE-0001Kz-W2; Mon, 23 Feb 2026 12:02:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKD-0001Ib-EV for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:25 -0500 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 1vuZKB-0008WQ-L7 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:25 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-48374014a77so47446135e9.3 for ; Mon, 23 Feb 2026 09:02:23 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866142; x=1772470942; 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=pgbI5Qqmzf+DxfEbRHQMqpET1e5tAlZwB7KWYK/P7d0=; b=k5HXl6gExcFnJ1fxyB00K45ax3M6VPMupSnznJe3Phfg1a3vgyXE0Gz627KoJInyNW yoXsv4hX1qVtyLhKyi3CXNGWhk0bnscbL7T22OY5bRnoKKxgYQSJ9OdELhNl7gKWciU5 emxeftfebOEXqAIBNcAgbGH+svNGv/BW8I8AuNevVc9Uetwe4GtV7pU1ml1Gcyx5TITm Yu4XfJYLW0QutTwGxpOiBFb80D16zpGr75ns7ciij4N3ufH4E2fvBAkNd+UnWy2bbbPa 5R1TqugnIYrZ4sVw6Xv+djSgTuYA0pxjWMT0Oh3QZxJDLi9XT/QW9SPXzTnHaGA2nn11 nDXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866142; x=1772470942; 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=pgbI5Qqmzf+DxfEbRHQMqpET1e5tAlZwB7KWYK/P7d0=; b=u2UNBtZnlW0fgI7jACZ5iL23exE0+yN5s8zsHObZXDq1qnM6yp4Hu7TWr9gE/BlhVX yw75v4PzQtdl1lurF6saPhhj1/nb6o4jccqn1P9Okio2yZw6qXgRAPxE+B4SvvNUlCPQ Ph3vMGRQ8+jAbWJ79CeSNJB4CTFX824+k0tRsuIyxhQWce6r5bfMC3cAHr2uOl9+MgW2 ycKFOLHAWTM1c4ddPALD2Vvobkwgii2eJqlbfgeDfHwcUpPLkXDzACvB6vIzpD9wc9Lw 8Pe5NHOacgdne9WvlZzFSWm+37dKvWz06z4hBC+fA2ZDp2X0lmMtVl/TQLWaCPVAN2of xbWA== X-Forwarded-Encrypted: i=1; AJvYcCVrp3tmHDfXLS9k7fcVCjio2E2Kp3qf9DLbeY3FNNOb+IbPdJEuolvyr7aiVix6Oi/dTO92sKs4V4f1@nongnu.org X-Gm-Message-State: AOJu0YwVwLv68V3cjonciv1xO2dEdUthesW0eOeh0NeOXws4n3GnPgK6 e9kETWQsi1Koy8zxe5Ty2aTKkCZhqJNHS8cf+UlByzcwAqBWuQBALmcGe/LCUzZDIue02Uvixi9 6Bgr/ X-Gm-Gg: AZuq6aIvds08pNbfQ3NkRmoFGRF1CK36RnLam/y6lF6MYMdVUJDJLuy+x8HZ7Y/2FZ3 85tCRZjRgkM9IT65ZoeqvNpt2eEBBt9dyPSdg5F/1pKFe9BeNzueG+eZBX0QWj8atJAArJ8JefY 8VbO2wrXYUK8rOTIWl0/5s8mpn9sueQFh6UL8q/PW3vT4KNn+BR1ItFHmfSVbaWEAD/W1aBq6Fo Ml4Ay/bfTi5F/r+zrCi9j5jPe7kDhPwlThUXXRkVN9pUdDyvlLDFY/B3EfUl4MOu4ZsLt418qE/ HNYpa94i+K84uvsHgfqC1YYg80x/KkvqzVPkJ95CD9RsY+tXiNmA430MvMKq3SA8HXaqGnk6tsO WjS/rdOA6cJFFJsEmgxmMxPUaBKFRnKIupo2rRkpoakcWHyzB7TqVpkAkUBQLHrtMplYl1UcIxV R1mmbIyBIJ5jFIW/jFjmGNd1smrsbAFBwrxv1DgvMupVKI5X0HAomSv1U+3MttpIjGEACNSu8d1 RRUsKEikVufkvlk64wen10v24JxZF0= X-Received: by 2002:a05:600c:3e05:b0:483:6fc6:1e20 with SMTP id 5b1f17b1804b1-483a95b5410mr161846545e9.9.1771866141963; Mon, 23 Feb 2026 09:02:21 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 07/65] hw/intc/arm_gicv5: Create inbound GPIO lines for SPIs Date: Mon, 23 Feb 2026 17:01:14 +0000 Message-ID: <20260223170212.441276-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866811731158501 Content-Type: text/plain; charset="utf-8" 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 --- 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 73a6e629df..7ef48bb450 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -181,6 +181,15 @@ static const MemoryRegionOps config_frame_ops[NUM_GICV= 5_DOMAINS] =3D { }, }; =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); @@ -217,7 +226,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 c8b6704fe4..0f966dfd1b 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 b22f020a53..be898abcd5 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 Sun Apr 12 00:56:26 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=1771866820; cv=none; d=zohomail.com; s=zohoarc; b=nlAYrd1FITVXDd8R6+3I4+rWr2JIjWMRjrkU2wPKB0wwJU0p/KzSZwPsHwlwmdmW5hI+NYY7RMyxz1TPp4gIxzV+LHALv3Y2a5GhPnknVUV6GzxmW8X5cg0j+he6Kx51Pce+R1ABqqop1ucrOIZ2NG3e+EvJ5HdJvGLQ9yblpKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866820; 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=pqW9rM/0GD/85HW/dEUCbk4fqpodu9kP2QyiPy7FS58=; b=br4Cd6kR5DZXwtTTG160/P/w/1ctvt+BH/MEsU6ofSTrH5T1EFgkmwwHTGmxEOJ9vECLz9Cotwi40U1VPBQ6eGP73hlQmAZVEMKKGWhqXx9XaxXlAXovYAblGeUuvk+N7sXyF2TV3Moiw8CnKZD+l991n3X5FbXGILy87i4eIqg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866820452737.6810954699295; Mon, 23 Feb 2026 09:13:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKJ-0001PM-Fp; Mon, 23 Feb 2026 12:02:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKE-0001Kg-Q1 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:26 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vuZKC-00005K-Tn for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:26 -0500 Received: by mail-wm1-x342.google.com with SMTP id 5b1f17b1804b1-4837f27cf2dso39206455e9.2 for ; Mon, 23 Feb 2026 09:02:24 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866143; x=1772470943; 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=pqW9rM/0GD/85HW/dEUCbk4fqpodu9kP2QyiPy7FS58=; b=SqkqXLQq8NXEXv52hTgd4P71TPmdd9I8TvJfBGz4Rqsm2idEKwOhQhPsy2vX+eAIwG gjjk7ua6KWDqUB4tXcBxBYRDU4TWG+Vf4ZCslwFxQIlsyoZSNxXEw2jWgd2DckihVv5e h8PsxBjBQs/RGReEW3jk/HwblbEqPvM//tIW6LFDLCrkaY1b9yoQwAJ3NhQ70r0TN80d g0tHSkeYfIQ5ZuaRw8ja4odVcpyvjSUeaMnJ1O0fYTTru3Upu2z1CyTcgo+QuF5G24M5 jqX9x/CqNTUd/QnLSoL2FfG5Z79wHkf1FhfkPQxvNgGJ17DPIbaRHZbz2XhPq2FdtmQo aHkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866143; x=1772470943; 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=pqW9rM/0GD/85HW/dEUCbk4fqpodu9kP2QyiPy7FS58=; b=Ja2ufsW6OY8HwAl7uRYKSetmbBw7w/PKqoahCdyrtLYZ7dScsItRQc7VC4IRg4lyBL ElI3Mf8RNGzTfc0nK9m7dVeIpX4mqWpJuSK0YJ034ozXArl40UjBAPBUp5VfT3fCPj37 jxBEGcSwDS4DMLhXTUGPOFX8TjT5QwV+sKAOOWy3ijbxotukcp5MfWL7N2XqF/Yv/V90 90E+0sNYeLT15kqUEQ2123MDjg3PK/cDgToJG7Nj1PAfz73oWaTFzxwHXw13ovZ7H6mG g2W8gzWIxDEFTvT8NqBOEON0lObLX55faYwbUiDNTCq/yMhXvxEZ++0fau1jShroZHes kPVw== X-Forwarded-Encrypted: i=1; AJvYcCXT3bWXiysCWqFM9PeydjvsQHURytj5kU7go7GbXePc8CzcEFNDqx71gb0Qp9y3+tKrccm+Xm1IIHtC@nongnu.org X-Gm-Message-State: AOJu0Yx7caJXcZNT7B4x/VmPcCdHHuoEOfO2TnlaCQNCy5yOIiYkJxrX G3wWv3B6KeB0yq+j5nEVOrB9h3k4Nv6I9ehILL8sVBkWMga9JIGM7mAE5jkg6rZz1h8qRGD7+xO 2B/Ygp6g= X-Gm-Gg: AZuq6aJg0QkjK6oQm3IwHow20QNlgcwUEN01tLT7f8IOHYQKpZtn9dTO816tR03Vbqr NB3mx3U02VM1fMZ7XZlQf1xBquZ6N9IpOBHJxO5iTXQiH22uX1kGPYZin9oNiH+hrtz990AmTmz zxQc/2k/9cpIm6cI20iw2UZhAi/CXJ+pvCmEgTmzJ6q/eMW/SLyI3Z/oXXzMSo4+u6t8OHHMoGo DVxtEh7soBP+6thzot0FwqrdxpHtt8eW5wEAd+kHp6Ut9b8meUwjacM+6rc8hqpiobT8zlnQorc Z6CvVGVg7UKzLo9Ol1srtcouTNStGPn9LLjXlS7PnX41SgFjp3tg6EO/v+xb5VClXUxchoB0HRw 8Xxxv/H+1DdGK9aamvDwscS/tATjkc0BKuPXIjBpoyjM+daaLWXElqBpb4s6cl45vksO6sHpnBk wMz/991r25Wpaza8ebmsu5knhWXYq0u4exhSaPcsjZBQ3DWYOdq1J6wahU18t4fro7q3s+qAjt4 YkRaXziEihv9dbF7wQT2SRM8iUKY7k= X-Received: by 2002:a05:600c:1386:b0:475:da1a:53f9 with SMTP id 5b1f17b1804b1-483a96087d8mr171816225e9.14.1771866143092; Mon, 23 Feb 2026 09:02:23 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 08/65] hw/intc/arm_gicv5: Define macros for config frame registers Date: Mon, 23 Feb 2026 17:01:15 +0000 Message-ID: <20260223170212.441276-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x342.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: 1771866821875158501 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 --- 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 7ef48bb450..db754e7681 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, 5) + 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 Sun Apr 12 00:56:26 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=1771866395; cv=none; d=zohomail.com; s=zohoarc; b=moXrbHQt5o2oUuEjHS7qEHB+eqmMQ4ZDpXX3Zv1M91MB9y1dV/0rQ5U7nZRAdtOOpC2+hwnLULGyhW66xGkr0Gmlo/tn1n51KWCfKgieVRrQXKx7cz2x1qH7Esw/CKYtWFFSfurM7Blxoyx38QeeIdyNzkJW+yn3nlrj/4Gq3Ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866395; 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=3CiLooo2/Er7yqErGfmdNwNkycKNCQ+U0Fgk+KNKPMo=; b=XKw5iGdUBJWLlJWWWtpvX43JdNyUueicEZw6tC6c0v3JK5tM0cdX2JJQuURJsgkGAqXt3qgZ094osLdWxVi3h2aiBIuMkSWmbWWL+SejvCaXsP1Se/jcTABKP2wAWRVDOzqRiS6LT5NoXfJmIF/24kMQP67Tu3MjmqSCciMv0UE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866395025701.4756982765729; Mon, 23 Feb 2026 09:06:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKH-0001N3-2v; Mon, 23 Feb 2026 12:02:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKF-0001LU-K7 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:27 -0500 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 1vuZKD-00005p-OA for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:27 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4806ce0f97bso36855455e9.0 for ; Mon, 23 Feb 2026 09:02:25 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866144; x=1772470944; 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=3CiLooo2/Er7yqErGfmdNwNkycKNCQ+U0Fgk+KNKPMo=; b=Gk8EFRWF4KqC+rxYuYYbKh9Us7KizUiTT31OIThBrFDBcNtVrMfjZh6hHkf2/C/NBy VF21+Fkylo8NcRn2hSx2QG9Q0Vooods5pJwHLz31OpfHhQvWXrIP0sR09S8Jp3LP8gZF WbHxyBbDqIkvu15Sl5PMtj4xBI7gLSEEzzWmP0iIAGaso8jrdfGYDFHxdFu8IweRmMNP DsIS/P+YncxLdok85L/2UdNVMwxWqF8q2Mh9f6eHRgwETK+MIV6RlrRMDhPVOBkPB3G8 /VURs+MUC4we6ecd5Zg9Ph1D+6QCVtc5C4TUpuxYjMpLHuZ7Kix4EAXwfHNAhh6wsyWG WGyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866144; x=1772470944; 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=3CiLooo2/Er7yqErGfmdNwNkycKNCQ+U0Fgk+KNKPMo=; b=wk2d0heJWa0Wk7oN4I9PErKLGUMlCmq03ywWEq+WbA71G0gMfUPFrzLTo8YcXwci4b WTEhDwVWm6h41QrmHQTWAbb1Nll3JiPN75lDnpErFNw2d0hgskNe1h1dHgK4Gr7CyElu YXvAu5UkMUJfrnXGGIFHUxKiczctumK5lBKwC2bUeOlk+uI2fsKGs7m5p06DapkIclhK /ss9aFdMokGgCrofmxcbO2JHte4uvI0w2k7ykd0gQ8AB4Zpjz2XSUcnjHpPEq7DWWw75 Q29Uq+80DE0HcnrnST0N16srrpoc323r/8ClJk7EmMmSBzQ5e4MHqCHnjJHiWZ5p2CLJ N5yw== X-Forwarded-Encrypted: i=1; AJvYcCXu3YwgrT4/YrNvOpGH5n4H9WNSaZhoxIBFQRHFJdrsiRaPgfOCis4zQ1hPZVNRMKAJaq6QdiLFtWdl@nongnu.org X-Gm-Message-State: AOJu0Yx1LcMqEUkdaGCcsfo2wMNHBtrJl0vOxxWtjbjPjoDOid1MWEeA F4gJzSUiPXAMSEoJNpkrXcJJxg/8HQcnvavSuzX54OH6N0C7GbEe2CxzR9Hr+6jg8mk= X-Gm-Gg: AZuq6aKYk0ettLqEH1HTl3c6e5JroJ7GFacOF7XivL5R93ih7xCOpXw/BtAUD4qMYn5 r6Oz6ZY6eXu5nF1G5ghjLw7ffXgA6moQIJolLYOhrNq921PAhxz4aLx0vOC+yfSTLf7zZc0WF9a aAbV1spcezQWG4eAp1PKvKjgL48qTA1Ah1jmPY02gNQt8OWZBjuhv0vv8pgz+gwsavAUmNXgPBu BCVpbos0K6q+qQsyzrnEjzA7EtKlv/Sxqyy28100GRmGywDtyFRN1lCRluY7fCwyBy0q9dP0c/E Fhw0SPcP86n1AwARoShiMmNtoLbUd9DejweJtl+yDA2PlMs+d/ebHngt6b0dqL62MNisO3Y3sdH JaFQV0U2MQwTY1LkESLbPgjVFzBgXDxK/Ov17hzXmk8+c64Xkewokfjz5lEo1bRMItFGI0i8Gho Bdm3rsHBHUO2zBG23lyfP+LvEfI1wHSS0c401q1SRxmePkhDIlUU7GOkdeOhZ6Nnez6911f6Ciw 7tQ7cfb/mKtHM+hodVXmDOhxLF13rU= X-Received: by 2002:a05:600c:4589:b0:480:1e9e:f9b with SMTP id 5b1f17b1804b1-483a95dea3emr195439745e9.16.1771866144121; Mon, 23 Feb 2026 09:02:24 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 09/65] hw/intc/arm_gicv5: Implement IRS ID regs Date: Mon, 23 Feb 2026 17:01:16 +0000 Message-ID: <20260223170212.441276-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866414272158500 Content-Type: text/plain; charset="utf-8" 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 --- hw/intc/arm_gicv5.c | 112 +++++++++++++++++++++++++++++ include/hw/intc/arm_gicv5_common.h | 39 ++++++++++ 2 files changed, 151 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index db754e7681..f34bb81966 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -268,6 +268,62 @@ 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; + } + 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 @@ -443,6 +499,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; + + /* + * We don't support any of the optional parts of the spec currently, + * so most of the fields in IRS_IDR0 are zero. + */ + 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); @@ -469,6 +579,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 be898abcd5..bcf7cd4239 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 an arbitrary product ID (ASCII "Q") + */ +#define QEMU_GICV5_IMPLEMENTER 0x43b +#define QEMU_GICV5_PRODUCTID 0x51 +#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 Sun Apr 12 00:56:26 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=1771866616; cv=none; d=zohomail.com; s=zohoarc; b=cA2+sU3s0LXpyrfCcGu0eppR4yNDbVVzklxKzjI/r6NYuNWB/dokqs/KWTef2h4w7lq2EO8ubjgus3RbH8zaYe+RXIjTIHbbV8X3ZZ6Vlz90m6AShHEXaanMbgdzxjaZlHU56s1YKYdBNuFq57uYJjlbEv1C+ZUAxj4s43US+R4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866616; 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=eG7OK00yaSbdKOgQYurB1+UoGEZISqkbJe1azzpynuk=; b=nhW+SQRd69jlW/ZShKdVDcEEEJVkFuHeJx/dQcKGl6d5fEtUxHnFKhZt7ra9IRbV1Mkeyq812lo6pDVARn1RZXFx5suCaVbNVdn2ItUNALTQ8FtwqpOrn8A6xDrqrcnbLALl6ets50/+KqYl+YB19cCQS82+XgA96bpEh2vpTRg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866616679818.2920233561007; Mon, 23 Feb 2026 09:10:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKI-0001OV-EF; Mon, 23 Feb 2026 12:02:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKH-0001N4-1D for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:29 -0500 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 1vuZKF-00006Y-CY for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:28 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-48336a6e932so28241815e9.3 for ; Mon, 23 Feb 2026 09:02:26 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866146; x=1772470946; 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=eG7OK00yaSbdKOgQYurB1+UoGEZISqkbJe1azzpynuk=; b=XCbJIREdifcX9r5hWOoB373TZ7ktgJAnuIexGVnHVcP0U3v/KFOzwQXZYDbi6HPqsZ 6E+9hzcGRGWJ1Ng8Al2e6tAj7jYmPhONKop4ujfSvVfjw0IMriYOzHYlp0Alo1nLN2kM +JlCz3U6mG2JcjsQNBJc1BVXDsDNIOZX0aPxDGrSMYFsAwuiiHGrriwS1Wm9+FONRwl6 aTFoayPVFNddgw+o28xGdFX5T2BRlNC2/rrHueC8mwt0dDmf+6kAoVLabJSmJsUyXrOp 8MRByTAqkkNgXnkx6HbcqvVEEYP8AKvuRPUvXCJhHbTtSET95Qib2IpmWuSfssNQ8EZm VCSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866146; x=1772470946; 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=eG7OK00yaSbdKOgQYurB1+UoGEZISqkbJe1azzpynuk=; b=XKuKesW2mlqEDI0Sb/yo2SFL0dlVYMKpWGZ9wHUHYVfb+7/00I3izqrWTH0DN1qWB6 Gt+AnfpyhPF36NJOyKTGSGES3v+3bModu+K33KN0AqM/cSLktDFdADXiFHVyCsSrKlsf dOflSSo9Mmh/noWwh7nRcy8Daf6z4UNVaFyiTOrOnos6IjPznwIO7WXGYxiFPmdvFN8w N3pk262f50y1pqkfKLcEQxBVfkMxPP5m9kdvYAg8COfeK6Bp6adOQ9gN7orHzsoc5cKM Xg9tbHraQOLaYhMOhS/FOFK4kNvwf9k61HFWDxakd2UrCueS7oFmeazQN7qAZtqkp/Vo RRSw== X-Forwarded-Encrypted: i=1; AJvYcCUrXCRPpioYBghz8wuIFA9bT6tHHmPyTI86MO3ryrI2DElEi4K55EVTM338AWF/iN51TPIfXE63XlcC@nongnu.org X-Gm-Message-State: AOJu0Yzc6iUHkrs74tEsp8WOxAO5vLrqZbZRwiKPlG1lvYamx7XLGyfR nf5JYh3wkZ0gXKVhSKp1bsaPYPfGtxhRRImvTjAT9lCRTWj/Jze/TCcTwBfdx72TbAGJ00DhHSM saL+3 X-Gm-Gg: AZuq6aLceiyw4rn/E0mQvZYBQCHKwNKHfaW3u6c9AtAKY1WrgHTyS4jxEU0xpb4+ble h8BsGb7ITpjsMK8q+CbtSeP3nnmMNqTFiuWmPLxmOtdR6gydKsApEfLXVujhos2/q8gCPVWpeON +Eazw324CGvg08PD3Y9AacfFI9eyAvzAAHWzukS/ykuvHRmfMGVzR9K1YiQY6FAhBJavamvC1lX u1xzyVEQJvVd7DwlcV94XR6gaL4rw8x1dv2CuajAjX7HMfP/MDZNyWMSrzRbTk8/vTrN748Ts3/ LH3Obtm9V21+YOGJSs5S8OpbyIebQjyDm0EuirbpWgBQ/wL+1f2MrVEiudvgUkQl/BcCrJ1IFXd ahCU14/dN+k05rC1Z+57/dBaqEmoDQ/1WdRxyFS8KRngeMyxy2KECdTbndzNDKnEBpHlRi/PN0U LNVcz5RFKELQTl6fwhOpNskwVce1VO6Gnf3TIUBdzEOVEmhx/y/WW3GkH6vvq/qa0m/+zfiBkO4 cnjM+5M36dCeJiXdrGei1ZClw1PT9c= X-Received: by 2002:a05:600c:c104:b0:47d:264e:b35a with SMTP id 5b1f17b1804b1-483a96076a5mr126421315e9.13.1771866145874; Mon, 23 Feb 2026 09:02:25 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 10/65] hw/intc/arm_gicv5: Add link property for MemoryRegion for DMA Date: Mon, 23 Feb 2026 17:01:17 +0000 Message-ID: <20260223170212.441276-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866618577158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 0f966dfd1b..274d8cd255 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 bcf7cd4239..3bffa2cb1d 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 Sun Apr 12 00:56:26 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=1771866685; cv=none; d=zohomail.com; s=zohoarc; b=KFKLy8KM16TI7AkrnQV9eorDJpO6/gZFalLsKoc+TJcE3Cdw3wW3Ah06ZABtNlghldljEIl4dmh7tT8PoBIt7QFEAupyjPm5e1wG0b4kB1bWkIc5SjmBtIhUqINFSn590KWUV7R8A8gwlgOx4cXCg7zAvFJ4xxfEzlSCagf5qEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866685; 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=ceChrM7CQ4Ylberwabnc+XrtHRBLvAP4BZtWSnP7bSk=; b=T5GbgzidpZl9+GAFiWdJODWhl7Z9zmxe11uNaxmgsKhFjLdRkTQTl/b8MnNYBytU7VC+wTHlYTzgCakq0e/WvfRvPKOSQaqrZjj/IhHpnOt0aPsk3nl3UaZQ+z38sfwLuQ7LxX1fO1mqiNAEhX0XrEnyFCPLft9JDuh4UrMVZoY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866685117560.756258866389; Mon, 23 Feb 2026 09:11:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKL-0001RD-1l; Mon, 23 Feb 2026 12:02:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKI-0001Or-U5 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:30 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vuZKH-00007F-Fo for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:30 -0500 Received: by mail-wm1-x343.google.com with SMTP id 5b1f17b1804b1-48374014a77so47447265e9.3 for ; Mon, 23 Feb 2026 09:02:29 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866148; x=1772470948; 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=ceChrM7CQ4Ylberwabnc+XrtHRBLvAP4BZtWSnP7bSk=; b=RPf8I28jTmaDQcuIe4Sx2Z2PbVSLe173HQsfqWCDl36psZBP64lTe1E5XoWta2S/zH LVcBeE1f89NGlcRf1RbPifxW4RrKS2lRpl/Gfjo7yOv+mfyA1+YuP83Z3dIQ3dx82fb8 tj3CF5oKltlMmnvczK+1BXPJaeHpUWAU9MYC1+b7xLDrO9jO0Phwpes9+uMjFpY9mjV2 sSOmJdaC+AUpLduv/htQtZf+TkoxuuFEA7vRtfuNQwmBS/EQlsYholcEohzXIMLoq7cN +jm7WgsiutQIFwcU0Cw9hylj943/PnOwytIykpnuPGNhljga8NFDQ7hip0cUXyEOGWak ZGww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866148; x=1772470948; 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=ceChrM7CQ4Ylberwabnc+XrtHRBLvAP4BZtWSnP7bSk=; b=g3u0+sMCpJPbpZ4vzfyHQ3ZXDk8CoEGaFMNYlJJOar/eGJCsX8wV2TgBoxFE57D0hR GPGg6OTvowhFmHGldGUvsp0LLhOqP2CZY22jl4XSdsI+akBX9+bC/ZI/LVP1Ck15O5zq rma61+2uEgKc3IMXWBCSDJ9T/Jop2GUDFtg1NOGb7VcbCBhapiADz09x7dOTUNmmvl1y LVVRH/Y1BZgoZXwN5lkvcq6HYHCebPmqnd1JO/benM6GPeNfTc1GUCQTtYCLjfSCMnPY C7e8IYqQsHtn2WnzO/vyjiCVuHwkraYxXDtUcrWRFCk+jz8xDJqsZW40rGbFJQxZmHVt KMTg== X-Forwarded-Encrypted: i=1; AJvYcCUOOEBZ7bXEry4rMSyNzhqSWy+CZlx5288h+Mgew/l7BQWWTYEo6oj/JhmUiWS4zAAsZN0r7aVtx4G3@nongnu.org X-Gm-Message-State: AOJu0YwcqWVOwOb2bD346NsjNpLFiKWDr/z1LKvmF8+Q6Hd0HXOnl8lA 7dhDe+YoqA/VQF25xbloYd0M+45IROUvEIVlICDxvw4pMzNkdJkVEHZvdS7lCowc+30= X-Gm-Gg: AZuq6aIp5mvBkAkjVBr8C/VEzMaTabMS3XqwoppadDMPyV3FC+j+6TBjQuaHebAnlwL fNx4r4sZzM/fk0g8ZHB/duScapO8YuP5LLDO42OX0ujEGOAU9EUz+zkXt3hvWnbv4xi31oooKuB ywqozxA68xRnGlHl666zp9HMBYHbKXjMe5x9uETSXFie82s8VvndvWIMMVFZLavp7bSRbSJ3tI9 QC7m4jdrB83uLsp5QwPWWmXR+2UlLMHX+aXpEWDnTECaDbbMg9qTlJBDagc3OJHRZZSiwbkE+Ta wl3EqAcYjPlcahivujTezqvO4pG5KeuRlpe3w8YSZFQz/LqcAp5aZAJb3QwNiKTaENwU/XxQB3r zHdW4mJWg+ZdEXxC432t8GEftZu9GK/YCi+bv0MqlLDUhvvIDlcxnxqfFjYddUad0j1zi0C0ILh np4OAvX+inpVxsu2LXVsGIGw0nuI/tpldnx88OtTBAPEV1tFXFyKoaBgA6aR70M2L7dLcUBlTSs Jda61JPREMYPaW9cqbESa6Fm0mEetU= X-Received: by 2002:a05:600c:4452:b0:477:63b5:7148 with SMTP id 5b1f17b1804b1-483a95a859dmr150164455e9.6.1771866147947; Mon, 23 Feb 2026 09:02:27 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 11/65] hw/intc/arm_gicv5: Implement gicv5_class_name() Date: Mon, 23 Feb 2026 17:01:18 +0000 Message-ID: <20260223170212.441276-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x343.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866687106158500 Content-Type: text/plain; charset="utf-8" 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 --- hw/intc/arm_gicv5_common.c | 12 ++++++++++++ include/hw/intc/arm_gicv5_common.h | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 274d8cd255..620ae3b88f 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -11,6 +11,8 @@ #include "hw/core/qdev-properties.h" #include "qapi/error.h" #include "trace.h" +#include "qemu/error-report.h" +#include "system/kvm.h" =20 OBJECT_DEFINE_ABSTRACT_TYPE(GICv5Common, gicv5_common, ARM_GICV5_COMMON, S= YS_BUS_DEVICE) =20 @@ -157,3 +159,13 @@ static void gicv5_common_class_init(ObjectClass *oc, c= onst void *data) dc->realize =3D gicv5_common_realize; device_class_set_props(dc, arm_gicv5_common_properties); } + +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"; +} diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5= _common.h index 3bffa2cb1d..7db2c87ddc 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -150,4 +150,14 @@ 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 + */ +const char *gicv5_class_name(void); + #endif --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866312; cv=none; d=zohomail.com; s=zohoarc; b=FKjDJ4+mPkjSry/pYoV3FKZG01bBNR1ivotVwzjnY2WhQVNdcJknhTVna0M39ZfzLmxDjOXNjIAVD3rnYg5uMNQf1Kd6my7JhcV/qqBj+si5B6J2NavLKSCaCsU5sjc2TosBmcfAETNuCDi1IRVZ3nlZhkD7YHHMzko9wg/cbQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866312; 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=sngzmWpFYqov4tsRiPEbrCo+XLB7I8a4AeFdOGirVho=; b=CGZI/Rz8E7I7ONTAAfTWCVbc5kob8zoKoNYO5MqKOikB1MA6MYbtRFPw1W37I9JV/43UshR2Iz17C7tHjQ0bH/GucTxr977+YlF16e6Z5C6Z6gqhaiD0lLsJqJwxhF6NSwU9UsVt6B/gj+RWqN21Ag3oAfIm6mq8gt8JnOtoNXg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866312230627.9633207202396; Mon, 23 Feb 2026 09:05:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKN-0001Va-LU; Mon, 23 Feb 2026 12:02:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKK-0001RB-AH for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:32 -0500 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 1vuZKI-00007c-Kj for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:31 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-48373a4bca3so27425535e9.0 for ; Mon, 23 Feb 2026 09:02:30 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866149; x=1772470949; 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=sngzmWpFYqov4tsRiPEbrCo+XLB7I8a4AeFdOGirVho=; b=b46WDa7qPdAvTMHuoQPVU2eKaCo1w9pMyO79mXtdbEN+PggUqVE36pmuTC0AuWiFEQ 0FaO6hLG5c5THhJNOes89tmbTEb3Y9+29dXe2BZrWPng+BE6oTptcWKuXnsTAxTeYD2f vHu0/gSDE2npYNInWkYcx/tkYCaTkkYF2X93OsgXcekqjaqRlKZwCefnFU9Vr6Olaesj eYl8tD9bF28RsgMUFrICKTYq/COBPKvHkzvWK2D1kUtQD8UkzdQuCmupVjis6Wi6f4R/ Ur3UMhNN0wQnbYz+1iI0S0nPTM6gLqux1TEDLRs/IhMzqg9MnrEbrC0cfl3rA0uJLJ2l UGaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866149; x=1772470949; 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=sngzmWpFYqov4tsRiPEbrCo+XLB7I8a4AeFdOGirVho=; b=hj0DH5ikQJs/V/Pi57XM+HDPuOi5kn1BbH78xD6wuLj2Kc3u5MPz2Rw5sNDvwPVRWB cOASWx+bP6dpMUh98c6KcGnI62WR3ErKez0Q88D+DV0H6QPqNWUz8HhOnYAFxAfI2dpS i6zssFv9UL7MeCNwJU+/SWmZwriWQBeHDTJ5fhgtPYuVimb7mQM4YnBpJg32/QQf3tGX S5CiPsi4dMlhaWK+Tr75kTkxRAMynPtdpus813dwSZ7k5yeR9OW5tm+z2av38YE0ndoG Avo5wpQ0X6Sge2wSsW/gyCsxDaOTqxSKVLXi9Ppff16tJtm8wf3hW8Dh4jlT+t4dUpvy zMrQ== X-Forwarded-Encrypted: i=1; AJvYcCULGl6eBxd0uBc9QRLr6H+/MY23H+4xnUCY0UVu9Pb/F3jm8NBsrblZ/LAwxt/TuCYP1NT36CJ6PkRb@nongnu.org X-Gm-Message-State: AOJu0YyV8QdBzW0k8WN0YUEaZyZle114IRO/5WdWpi+VX1ZjMpX1VyNc uUOsSgTEhswVkBP9UcSso3AfgLFzFcoK7ecy8G0ir1TGkpf+oenoijx9liVwMr+XSdOVC0caVJo ZgVPY X-Gm-Gg: AZuq6aKoM+DsQ78n/AAlvrL1cnIPI1CEos1K1YU9wvl96qOGL/AtfmpAqMPPfRzJfOA pmQTrXsuy+jScJzVaaz1pZkLrboXUrVGfKMYsQvv5JOKZ79tvd/DT+grrvsVEXQawO8aKX7u7cv 9vEJoxN6FI+vEtrlyjB7EUaZYdr4OwqqmChF3AHqB5zHJi5eWg5Kr5sGDbMPPUPV4MjhFhdrlup 1A0DQ4Ld/20ZMcKbXhlvSphnfY0WZtAX04yKuv2tpgzY79vijVmk2HKs7/rBiDu2UShNCxnItlf w6fTpxibmiso2hT5d+Vu7CPSVTAwuAwLLK4ha1FY/ydsHTUJdNn2iAc0Otc5bzfMSMyEQb/Up/H cpGJeCp1UfWMPB1PgNkLeOeHlHKmviY1y9YW4Y4rvBon4JOZHZpvUL4s69kWcQ3Zmd/wzhyE36h Ud9NnjEymB4OKKvlHRlAvOY7H98B7cnei2Wzl/arw3acgbqtqaVtfdSLCgOxyHmhq1HKWiZpzSJ FAYvA/qGn91y7Z7bdH6ePWEjPe9YY4= X-Received: by 2002:a05:600c:6211:b0:477:54f9:6ac2 with SMTP id 5b1f17b1804b1-483a9566b78mr139437995e9.0.1771866149008; Mon, 23 Feb 2026 09:02:29 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 12/65] hw/intc/arm_gicv5: Add defines for GICv5 architected PPIs Date: Mon, 23 Feb 2026 17:01:19 +0000 Message-ID: <20260223170212.441276-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866312768158501 Content-Type: text/plain; charset="utf-8" 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 --- 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 143dcdec28..9c7788b1e6 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 Sun Apr 12 00:56:26 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=1771866361; cv=none; d=zohomail.com; s=zohoarc; b=itrbLqb0wp+weFWZVsNBbgmo7SVUb+rn+avKApoJmKz6idJpAFg/z3Mk0TyxgpYA4NkkY6fwsOxrgLYoylyMH7Mfw22unTQwH4dCKwxNdNgygo5+9Sf3i2FdpF19TjEKHH1rQmXV6M0djZDv6tXDYsBzwVIENp8/QMda/GvK4i4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866361; 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=vu8NALcSqni2ue7OROnSn9kpXExYg7A/4C4f2kfjzgg=; b=gkEuh/SBBM9awUPe1naaDgYJh9r5wrrdQ3j5k9RGPuxBYjCDswUDvvb5KjFyrwC5RuDT9vlacw+NYzqzTq3JjKMG4igQc7+A8TkoSX/JTtSM9Eyf4d3nM79ihO3nocJQuhWyvM2h10b99NKJBmoaL3h1K1nkfwhFz61jhzZyBO4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866361416903.4273978901978; Mon, 23 Feb 2026 09:06:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKO-0001W3-GR; Mon, 23 Feb 2026 12:02:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKM-0001Tq-54 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:34 -0500 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 1vuZKK-00007z-7p for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:33 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4837634de51so20463345e9.1 for ; Mon, 23 Feb 2026 09:02:31 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866150; x=1772470950; 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=vu8NALcSqni2ue7OROnSn9kpXExYg7A/4C4f2kfjzgg=; b=ZpjJ/m2ie/s7FxKVqg/FWnRVILMIdnV1DneRt2JYAvmVsudyCAYjkvhcRyg5Sem4Iv bLAmdXdFFpufrV9xfjHd6jh5GH3t/GsvV9+qEBWQi16swvdWfcA6ZdLJ9OdsJb7h5mKc RwJTNVD9cN5eCu3mRTM7XvQi9UpeBMNAvfoSRlsSGBp4DY82eeWNrQSwq7npa7bPPMH/ j3pdJhqg5PKbl61Nl4HN4Y4ZHZJPqGxa9DYko5o7UksGIwFjp50oGfegXBR9eBn57FMi zVU6tssfVDwDnQpIlEoFByuXAw/PYMmdbNF/vr0/WtW/3s3Va/cu6DWU+HgkldudWbzJ g1IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866150; x=1772470950; 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=vu8NALcSqni2ue7OROnSn9kpXExYg7A/4C4f2kfjzgg=; b=T/+d2iDmJx8OQECbD7ohsPFitSSmLiSIa8vV0v9SIl/a/QbUkebNPvd6hJ/UY15zPm 1hRyU2pMOQB8IFIleb2kZxWjMU6EdDARtAdkprA5J+vK5dmwNdCWC7b2KhBDvI5r6S0G 6spof9/YAeN4Iy7o4uG8HRM7m/rgVEXgGQhQJQxtV2wFNLYe8kQEbXVuXP7Limm8WzJf FUTmyB8ZU/PhNI9PGmEBdaRct4IbKu/ZJRhU9TDig7sahwJPKN+KJUXP1GbV6cShNi/d MCF9PcPi6+vPVo/HR9TucfHdfG6A76CJOaTygFYOw9vgSiOydS/SHUaxUzdBfM9Pd4AS w/fA== X-Forwarded-Encrypted: i=1; AJvYcCXPfICSuEAGyzCzAJO8zfQwlGDwe6ccdXJZQxHEkpJ4UJVeXEz5rL6ypKJUA42tlJmbzqBgER/S+UHt@nongnu.org X-Gm-Message-State: AOJu0YxGoCHmuumQbCuEOC1p2t14MJlfcrxhV/OqlpQC0HiHD/7jAz3s +cIxjJ2MRr5V/0RzXTPIytKtqAj4/ubhZU7pSjTPvwJyNjz/dcBWI5f1kw4X+Oqb/5KkrdPXr5V ecCCV X-Gm-Gg: AZuq6aLbEqkvknFnuFH6UpZ9x1lsjnZUgydSEx+nhyKLUdiIEhsomoNioykUIppe4Co Q2lAFkBKQw3KBz7GAuAwr0aCvhMQ6vFcr3UOn43Fp2+mdldnoWzZeATrx0tmO6HdN7OVMfT65wQ wDFmtTrigoHpYuAuoFgXX103Xdt85CCxjHkNLKa9+PvPV2WQNlBeGhlLaJVkcB0w0wuUKL11NxE lJxfRGZiXIAvWLPsBxqVmRbuEBWmuKzcVjB7JKIjXEh66i8ZoOrlYXes3ZuINtBBSJki0RQvMo0 n1CQbjsjRf6IWGMzGHUFAF92AmodT0H4ybxjLWfuuf4nrqguick2a972Dm/SWR6rCpYd7TjW/hL 9pO22/G7OM0pOWsy9n7HQQbm7Ka64OBvPAPSGAiPBvVs7G/j8VPP2Nz1rUob4OK23m1TS51Q0dj HaO1QPI2dQGp0vG5XFOzMlJGVf1RZOq/QTwDDXi9eXTnpJBTXNA5dRZcG9LFeq6gR7tzwCuTAlV xWy9mAYmArL1vNAERgO+igkxVARJqM= X-Received: by 2002:a05:600c:3553:b0:480:53ce:45d3 with SMTP id 5b1f17b1804b1-483a962e3edmr169574395e9.18.1771866150293; Mon, 23 Feb 2026 09:02:30 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 13/65] target/arm: GICv5 cpuif: Initial skeleton and GSB barrier insns Date: Mon, 23 Feb 2026 17:01:20 +0000 Message-ID: <20260223170212.441276-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866363092158500 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 --- 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 b683c9551a..e391b394ba 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) @@ -1159,6 +1160,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 6bfab90981..5e7cc039aa 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6315,6 +6315,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 8ec2750847..9bde58cf00 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1797,6 +1797,9 @@ void define_pm_cpregs(ARMCPU *cpu); /* Add the cpreg definitions for GCS cpregs */ void define_gcs_cpregs(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..76c2577c09 --- /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 5f59156055..a67911f8dc 100644 --- a/target/arm/tcg/meson.build +++ b/target/arm/tcg/meson.build @@ -62,6 +62,7 @@ arm_common_ss.add(files( arm_common_system_ss.add(files( 'cpregs-at.c', 'debug.c', + 'gicv5-cpuif.c', 'hflags.c', 'neon_helper.c', 'psci.c', --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866296; cv=none; d=zohomail.com; s=zohoarc; b=cduHYp9ubxOe/MMfN9jsYCHe1Yvn57GuDrDRttO9vdZlR+3DmBgKWq6e4O1zV5q+Lgm6l4Dzhq0JLefzTWGLgrDHb7GUaKERFTRdUQ9UVUB+l8c3ifMO5cHBYWms6dWZJ1JzKfmDNPGqwC9clo/Swfjbes1OrXd6lvhX6D3MGAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866296; 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=dKOYQWFzPxR9pIFAnXPm0w2KogR9R3k5m6huzTb6ybI=; b=XVmkfTGQOYf0n+8ZtDR48QmSDhIkCqmJwUD9x43qgP2/nJvmDwyTaVzPOnSgimm88UOL8puB4a+qYMJimQpoXGZIH7Qq1XcbW+BW8sN2QoDjC5IIzme/Qa7HUqQkUXcxzX39W2RJqO/JxfyuO0sFyPFJ0vwPvqjwsa8ScHHRXaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866296404716.0866604085448; Mon, 23 Feb 2026 09:04:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKR-0001fT-B4; Mon, 23 Feb 2026 12:02:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKN-0001Ue-3n for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:35 -0500 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 1vuZKL-00008K-1Q for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:34 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4806ce0f97bso36857035e9.0 for ; Mon, 23 Feb 2026 09:02:32 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866151; x=1772470951; 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=dKOYQWFzPxR9pIFAnXPm0w2KogR9R3k5m6huzTb6ybI=; b=bPco4e6U/0BROPb3lnhllmAc1M8/xQCFA/WLSwQkNuY+ErSdfDzx6B/vytO0NBd31S jMwKhK66vjNOchjPgpTDPCJ4je4kv7GtnPpZI1pXYTXxTWtEQsx50s2wH596R5/Kq6Vm jzDuQDmLV2vfl1VYJtpr2CpTpJSMoCOdKlnZOG0i5GyK1RVkdTQuEjzCny4evad6Ttcm AJyPlcCZWcSsbBYGWaJBZKcLg29bbspziKIVP1bLfnSdnnZMBMS3r9p6s2fjiEMbMsO0 /QQxEPcw3BbAygonExaQGs8XfylCNGw0kz9Mv4TK8LamWECfHx+Huq1XQU5cWptYRhZY YafQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866151; x=1772470951; 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=dKOYQWFzPxR9pIFAnXPm0w2KogR9R3k5m6huzTb6ybI=; b=EuYTGpg2+U/7bKawn6E/3QXwRCXtnvMU3cnZl0TgvVjNDxhrEUT+lA4ZdJaE7yBDXZ 1hwQIlMymQ3bKqTLCzAshDYyOXtuppJD7/3ZEekUii65fBIe2f97tKpmAt791aM1oIHY 75eNLaF8PK1W997PDGGZ7Pic5YpdTZz5PTM8evrUIyi1Jvm08po8Wh9Lc8NM2sJJHqDJ s1ZizHOCeEOwRig3o9GD/A5l8+6wJc630uXc7XkSNMIOGQad9VVN+tn73SsLXiHeebee g8JN3DVRZAaf1vYT5L011+9ZP+rsjAlnqDY8QhEpdttpRzWU3h+jyxBaO9pKWrHFh9Qn BZlg== X-Forwarded-Encrypted: i=1; AJvYcCXZtTOaOmGW+/cv5gdalGLflDb6bASXvSza1tv++8T27YpIdAWpWKx3KxaipSTQzWFoIW5BxdTf7l7v@nongnu.org X-Gm-Message-State: AOJu0Yz2BCPGu/fFMFTBWzBt/jxyuGKCnFGhVeqJJMH+6uHYLH9mVfG2 oDzMSHz3WTaN0oMplVr4YOgzqQ200ArS2kLHyH4eK3ttMU3ykyF1Cvg9KVGYvYR9xjjwxvjrqwz vFIs9 X-Gm-Gg: AZuq6aJgsGtmZpL27Tkg1+upieaoUx4TnhY9GGb+OhBVfnIpPDfBqX1mVHcI4gKlEsG 7rqDHswdiWtqAEk+HKi2yO8e2FkHRBvdxwOerxQbwNrKhIRbO4f7LxbVmTvvptYFwXDlDN6Hb+o aeuKakLh7oNutqh2kqRKBp2s2f1CsEfxkTieEQai4IZBZjO6j9Ct1EKlBxYhYxoMyjMYgO1kpmw qhWodt9k1cT1XtgXFq5xTHCDVC8vj1Dcxkfzmy3W+bl3dzXZa0gja/nXJgFPuQY7ni+NYHRFVIx gKPbePkimWkCJopOWFRpCgSmY8pQ3bF3BqYGVyXMupmMXtlxwahMVmfOa+85xhkNOBU1jOZRXQW b9zN/alocjApBvIZHjy2n2BzQ/Rf6YtfWIc4SEvhFImUz4Am/Bn9jzqeYT6VpVjl+taN+pPSHPx fJIYT4KOuu1Du8DfJOqFf95fjFD8xXoFx4xkixZLFvp3surjth6Ndhrv8CRpWHwYFoYmhjY8mo6 HWs0tivc4F2DUqcRjE1cJbr0bF/6D0= X-Received: by 2002:a05:600c:4749:b0:480:69b6:dfed with SMTP id 5b1f17b1804b1-483a95e5ab8mr160397335e9.24.1771866151442; Mon, 23 Feb 2026 09:02:31 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 14/65] target/arm: Set up pointer to GICv5 in each CPU Date: Mon, 23 Feb 2026 17:01:21 +0000 Message-ID: <20260223170212.441276-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866298643158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 620ae3b88f..046dcdf5a3 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" @@ -129,6 +130,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..9b9c2e4b60 --- /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 10f8280eef..ef2afca6b9 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -41,6 +41,7 @@ #include "hw/core/boards.h" #ifdef CONFIG_TCG #include "hw/intc/armv7m_nvic.h" +#include "hw/intc/arm_gicv5_stream.h" #endif /* CONFIG_TCG */ #endif /* !CONFIG_USER_ONLY */ #include "system/tcg.h" @@ -1085,6 +1086,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 657ff4ab20..16de0ebfa8 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -812,6 +812,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 Sun Apr 12 00:56:26 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=1771866321; cv=none; d=zohomail.com; s=zohoarc; b=LiyB32C+L0vKGglHFlJb25pErIhvN7/+AXk6BY329NRPLMTS0rUxVVSgjCNndebwTwi+1Kcy01ypDQ6e1u+B+kU0BB5DtHUH4DZSSWYVKbsGNft1Vvx1MTDsTTV+VYhUjpe/nbTQTXc7O206dl5qSb0xAHoxxInzgpf1Pn+E/zU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866321; 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=rI8w6+BLR7AIEMKcPcd3cXRfHRMFTz+JQnWzwQz4nis=; b=BE+Xf+qlbnmgJu0RSRcz6sE4oRgpHmZuLFVzRAAh+fwAgyreCz+w9May0fX+/l5SBbu7ToRSKJFEuay3R25KhAUHAG3VQSq+9f7uH62klVbM399bNJY02wgFYLC5n/e++qhfkdHQ8Vm+e/tQmhzxb/pAiOJwQ1+6cMWZghDNuKs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866321601896.825815361934; Mon, 23 Feb 2026 09:05:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKQ-0001bR-Ha; Mon, 23 Feb 2026 12:02:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKO-0001Ws-OV for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:36 -0500 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 1vuZKM-00008c-GX for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:36 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4806f3fc50bso52094655e9.0 for ; Mon, 23 Feb 2026 09:02:34 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866153; x=1772470953; 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=rI8w6+BLR7AIEMKcPcd3cXRfHRMFTz+JQnWzwQz4nis=; b=vxugCIrntowNVHB6OHyqNmBAMPlxTghbaah7svHNaDLK/JhYW6Jl0LFZ1mHe7yZ4ck ZXUUv+XZIB2lMa1xPWe+a7qV+NVK8gpgkqMkzjajnYqox+ILgheL068XNrRyhWd5Yfus ca+0DhBaO6RI02CdMg8DmNA+4Wrpz1R/wjl2yq51llX/03SA+VyXZjvAu3msC0+o5T23 sYIDrR9/thRlBm+g5TI2P/i3Q4DhB1hLMjwchb7a2SMsOdetRBfzU7WluZ2SAVEqONQ/ MQP13oP/oTXahL05x77iEtHGcLaNBO/2JP99Xt4yHxbuyL/VvUEYF5qFdtKrExh6t8MQ LEgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866153; x=1772470953; 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=rI8w6+BLR7AIEMKcPcd3cXRfHRMFTz+JQnWzwQz4nis=; b=Eshgxsidvx22nsL52ZC/RZiIixl4xJHtWtCZ7PRTQJi/LqMw9y794oqa2NaCKd3o+T sYv+R4JCjUIqD2zRLvae6sf8t0q8IbGG9+qVRTHi4eQdEEMnX7S/yy5vjf/WbE/zUQiw wKhtQdTXu+3mOYlbofZv9jKT6LB9U/bzA6l3wHVkCBdFdqZ0ZjEg5ow+a8a//7exdMwG hQ8JowOMLXxu6n1GTF4Wc6mXEWw2DyX1FGlTmbTvG4XLgUvJcYpliyWPtphxdLSprGNE yrd5nmM6DDCQsIIyAZys5pKqte0umxgBh3QKdtj8pES1mvwRu5TGTgK1oNzZ82iQaDCW jUGw== X-Forwarded-Encrypted: i=1; AJvYcCV4bGhW7TGpKBNn1D7o3Rh7zkSf8bsixYQltnKRybGoX7J/3w7QNoFky/IhpEd2uMftRtTaUjHt43OE@nongnu.org X-Gm-Message-State: AOJu0YyXtXWcDZctIZ0+TddFOnmY687rXRi3GML4I9LmOHNe5s6mP6K+ cVG2eXugtYvyv63XsBnmwF67l8tPBEBBx3eyT18LcHaWiB5Q6ynM6HlPkyKf5BYTNYI= X-Gm-Gg: AZuq6aJtJTca6YTzSxr1ga1cxbnE62RLZwCiUlDpmrgbBciCDrlLFb8c5eOtyn8oBx6 n8Wbh6lkB69ZfokfvdpcrQbdENUUKb8hZOsHOFcUzG1r+6jy+gh4hb44008xZE7nS0xZ9abqrEZ m1TCivgqVT15+p7u+R/eEX7Ol0Y/bf9PXrzd+1e4bOqveVkUOncIFd6k0WbcKDD3NKMjef5IGOZ JStHu1vkmgJiaAMV3waCKbd3wjkjjE3L+wVOOBMl+n2PNZibd/kddo1M/7zC7GZA0L8invOZWlw OtlCbtYClISGRsir+1VkQfGKN0XH9wyAlazaOweBtBUj19SRkI6rK6xAxqq8s8QkfDZheyNT4xp 1AKchLrhjJkghupGBp3CW53QjbyeZfQyHm3/yJiz70d6ipgkVEq5B9dU8HTn0fVhte/deGgZnhB 693O8mdZ4GLIDjG3iI4/4ViRz8SRFNMLzFe8v6TmxnAsvSz/td+TZ06O1sGvKAdTtQJTH0B4ov7 l54I06Hsci6Bny4vbVi5akd2KhT+6Y= X-Received: by 2002:a05:600c:4744:b0:482:f564:d613 with SMTP id 5b1f17b1804b1-483a960892bmr163968095e9.15.1771866152838; Mon, 23 Feb 2026 09:02:32 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 15/65] hw/intc/arm_gicv5: Implement IRS_IST_{BASER, STATUSR, CFGR} Date: Mon, 23 Feb 2026 17:01:22 +0000 Message-ID: <20260223170212.441276-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866322729158500 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 --- hw/intc/arm_gicv5.c | 71 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv5_common.c | 4 ++ include/hw/intc/arm_gicv5_common.h | 3 ++ 3 files changed, 78 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index f34bb81966..f5933197ea 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) { @@ -323,6 +341,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; } return false; } @@ -330,18 +368,51 @@ 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 046dcdf5a3..751df2001c 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -62,6 +62,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 7db2c87ddc..2a49d58679 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -62,6 +62,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 Sun Apr 12 00:56:26 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=1771866520; cv=none; d=zohomail.com; s=zohoarc; b=S+z1ui1NEX2n90/mmR9wxmhAyg/6/KgnSOsN38MmH0jfUG+cJE4TuoWfSwOqmC6vWUVkvpp4t72KHAwpRlwmCtmbSDecjh8D/CstIFfroZD3PlNuPQ/i/WXY0bbY9pKbcR33ff5vvhr3hvUAvhXqbLMuzswGCHMc3fFagjqhvUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866520; 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=uYeQtsFSRqumgTT/VZl4v9vn04UeGUZO9JJK+qvvYwg=; b=SXWj3B07VvkJtRqW31tlqITXj9x/C6XPk7dlkB/WkDpH6MFX5jan+Tn0ha636ONmqBDWDPYwJQbQ1vvCDwh9uq7FlL0AjQWDabl2mO8kYrrv0LaonkNTicz92/LrnQ2GpizKOo2r7nM4zdPyU4udw5Y4KajfgR7GmRXpYTKbFKs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866520702877.8282313433957; Mon, 23 Feb 2026 09:08:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKU-0001rb-6J; Mon, 23 Feb 2026 12:02:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKP-0001Xv-HT for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:37 -0500 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 1vuZKN-000091-K0 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:37 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-483a233819aso44117555e9.3 for ; Mon, 23 Feb 2026 09:02:35 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866154; x=1772470954; 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=uYeQtsFSRqumgTT/VZl4v9vn04UeGUZO9JJK+qvvYwg=; b=m2gKnqxYO5HZYEI4ji+/gu2pMQSaQyp1/lzHl+P0DWmNhCn5SHlqMNJpwDXxjkst1c +0WilnH/ubZmJjusSDSN7XayYVLczZPjTHu6488BGlAZQo+9TrU4fEGgV9yljjajwLjE 3yAAZ+qBZyS1j3fKE1F0X43KxmcB1vLOCHLN/+R6jE1npY5Z76xvO3E24bNjel0n3LqL JGi/bXWTTnQftIPuQMNais64CVq2CYOZcjAcPowPXjEMmNb8nGD1LSwFxXYQZvmgeFhY xfPtFw2nTnR1aM/IOLPQZM0mEbGTzULNizHcr0Mttky0y/K93HqE2WjLOgsG4BQe6jr2 7Rtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866154; x=1772470954; 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=uYeQtsFSRqumgTT/VZl4v9vn04UeGUZO9JJK+qvvYwg=; b=mQPh4YMlo8boZnL8Z+AVqMlmjzfjSnFcX9giI7TzQlzBhasMob5e5VJPEpZt82t1uT 2SAzWS6xRB9p8unnLLGZj5BaMH7gB4d1LAqBt061BskdD8zLPHvU0M/bDzkumluvsSC6 DmfOwKu1aoLhWmcxLIOiZ0qZ0PH9rZ2X1EZxn5zO/khCU6UfEGU0TdlO3LacS2xWued7 NaRlpxSJfMd7Y6XNcRU/5/ftrnoxPPOPWEWvs10cxZFhXOhsdV10kGZbKOgAOwFoXRmk 2m/YWbxFoX+PAopS/FPh/c2gKruGX8XCnOMzQuOXzgoXc9D2xw9epEz1v0FZglaW8fgm VdKQ== X-Forwarded-Encrypted: i=1; AJvYcCXh8cK5AISwsjKlyWaJ+hEdI6mzpCfRo9qV836rIQgMZr4C0WboFO4qwqiGl7I2vZlSFucTxUekHeUU@nongnu.org X-Gm-Message-State: AOJu0Yy1wY3/qZgeiwwrbjjgXEM2UVwrwg4EDR9KRemOjjFZoMBFxtnq lUIsZOaMbGe2cfVt2cyQh90X+nAzuJr3KsF/SWpyBA1jG/FN8d9WxJf+3oh74MqnhD4/TOdnnR3 KXg4v X-Gm-Gg: AZuq6aLU7Yfs8m9dLZKuhyREUxyIaPLKHZFt8LdzaF7JZcX5LWB88xdYGDtoO6rnXgG wulG+vkf5rV1wUUyPLCIay/Q9vkMv+75l7kxPUNSsAN0qHbD5+PDuvuoK0X6iUd1CFyTlra0o9w NOv7OgxEk/tw2atz9vsIXFY70+P9TBOw45Hh+AccFhjskc7MssloNyqKN8yEiXumejmaJXuW/M6 slOWMvyYRyOLcB0mywmYsQe7R64JhPGNAZfUy5lqgK2CxlRo8R4N7wWVaUr0XE0yZs/g3E4jWh7 +F3QSoFXGtu4nRWhtwhLIvNbAL2KmH+GZ9khtX/GkpoqEqpEMdznT75NnCtsY3NsG7ZR7Cu4d4c +1yWOsUPH1DxxA/TBwpyree6a9ve7713TgDI5STTEPVIB0nuGWqzjVGdf2hXcrHZZ6s+HIM4f+G cPptN0eOINNM1eBhKt3joboPUJK2Z0zSFRHi5M9w79QbU3Ooqpa4bgGnsccVfjohvKxoRLB2Km/ Db3dHnhmch1C6jpD4rBe1BOGZkTTFw= X-Received: by 2002:a05:600c:8011:b0:477:7bca:8b34 with SMTP id 5b1f17b1804b1-483a95eb3eemr140245815e9.6.1771866153957; Mon, 23 Feb 2026 09:02:33 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 16/65] hw/intc/arm_gicv5: Cache LPI IST config in a struct Date: Mon, 23 Feb 2026 17:01:23 +0000 Message-ID: <20260223170212.441276-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866522068158500 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 --- 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 f5933197ea..3f74069e01 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, @@ -568,6 +627,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 Sun Apr 12 00:56:26 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=1771866564; cv=none; d=zohomail.com; s=zohoarc; b=d66srrXWr6k3BvjC/dE5fsb1ogz7HWlSGjVWHGXiqvFLBXXQSF6kun9NZNlmAITfcIB6MYmzBKP4yqpq3D2bUBgm3j/kAxCBmJOKzPnFU2DXxZIMWiKO0F7lch7ym711OvQdkvjRvJfS9YB01pyF5A3hbf/WKb68iav5Z8Ryr84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866564; 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=C2axc4EgJtazpkiTdEYOe//e5XiNyQzRdx8f1Gu4DKY=; b=Kc63EgLznVZIQONxVDLBdw7UIo86B/drDn2JYvgn0iqmImLYAFqkpyWTN9FvNcRUhB+/HGgxPlQgEXEPa3KagfD2nPcAk208lDNl1QIly/W5VICrKeJiH5GJrvXxj+FbDzQjVwUQ/LHSxoztUoyLGyac0YdC4xiecoGJjiPQbyA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866564525697.7020797439924; Mon, 23 Feb 2026 09:09:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKT-0001pJ-GA; Mon, 23 Feb 2026 12:02:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKS-0001lH-Ev for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:40 -0500 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 1vuZKP-00009R-Bg for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:40 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4806cc07ce7so43126615e9.1 for ; Mon, 23 Feb 2026 09:02:36 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866155; x=1772470955; 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=C2axc4EgJtazpkiTdEYOe//e5XiNyQzRdx8f1Gu4DKY=; b=t480HLajqsYcvpMf/HAJ2zL/LtOzFXaDyyL0qWokwnAzK30zTv8tZO96k5JQWIihl7 42Y7mp6KyNnqw4PJNE2Bb9se/cDv1VHXb98OVtwf2CRSDl5qK2T6sX08ZL+fflU33g5S uZaYYJqFRM105+OxFeT4PdWoIS58Xs3pDb+BvE2FCZMLySxLuvlhdkd8E3NGq8a9sGHY CMv8us0fvq/5PKtvQkYuiFb1eV+C6si3K+OA80qv+QGlw4ErR/Emrv8ylQ/QHUjKMwR+ gN0TyNivExZfE9BJ3zXaivVaNiPzpUHTUxgthN3JtJ6y8fDHhqAO2HVVtzzAGzw5fC8Q Kpyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866155; x=1772470955; 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=C2axc4EgJtazpkiTdEYOe//e5XiNyQzRdx8f1Gu4DKY=; b=qAFGXj+Sy6JAdA91e73UojnUyH0WAPm0IYPeKxC6NHAJV6FPrQqYY+wR4t3ZJGKdeN k9W6SIG/LFoHGvloJfSWFWf9qMrrtRJzDwqgg7Rofv0LM/oJQcvWRVKtKkApjdPC0kA0 cVYD8mzpdbkiIE+FwtPGE3uukCwt7FPNdg19P5VCzTZ5lT7lPF4MJ/G2jOFPmh9AhRIo TK2NoMFHR1vK23kLFuKTobHXCP+k44w7Xb1MMRVPGPmm7kK0fMgLaeCi024m6s1xG3wB umq7BlPwlQLmH9nXcqKbDWq60/YXqyE903ehy8YofUzcSC8JzL1SKAtEKqV2vdwjDKC3 nYwA== X-Forwarded-Encrypted: i=1; AJvYcCX4hl3MoCFelqBMMgM6cShtqZ2NGahbYpl9G4jVGySKkqT4uasQGrvzlaSHZqNUqMYRI53rb7dgPP8x@nongnu.org X-Gm-Message-State: AOJu0YzQjJLGy18Bj4/EBtjA0Ng8ih3k297vj2Mn7NZHR0sv62qG/2w/ CohegFfD7LPKXb9vd36hAnHxnHfeE9QbejNQHLFKtMSFNkpuEPqHrb4+DUNGnL6gWniTthkBSdf 8+Ava X-Gm-Gg: AZuq6aJkS1NzFT56PUJRx5uePRvWjlzcJhrMU/cARa8ct9w3avQ0te9MeYN/e+7J6mc q1Dla84bfN/QLePmm5dQXJ7MGb2Z2L6mVDKQ6Q/9CUnI1Jhl20AWcKaEyOm7zFDXrE3g5QArrXF pyBxuOEsgQHVLDymYL59LkF2qMTnVbopo0iA3g00I7BV0Se/U/V/e+xHBNSinuis1t8XHt0Ld0t ynEODf7uA+KSpNi7eAaOlTMt4Wo6wV43tFOnBver91mGnKrWAHwUG7Hr/tWzu9yKPC7ar6gXoeA 1h3tssRYxf2uSftPPO7ikUpjZ372ydkJOp/HETQgEIoL6lLWoMHPvzODQ96ohKSvVt3gO2XU7/d Mq8PjVxR2cl8+i7iZGlaONfSjvcwbHD3pekctZ1UAQyGFTr7AEGxrSsy0jvrPEGZXLXgTEyQ9De Bvi+1DoyA3hV/oRpJLZUXcaRdxV7UQMi8BvrRq0FamwyKUKGbOZMFjC/5DQEUQmEXSJJv/9fZlZ hesIzVAbShtk4447CZRaN4PxvvyHTk= X-Received: by 2002:a05:600c:6291:b0:477:8985:4036 with SMTP id 5b1f17b1804b1-483a95b5a7dmr154171825e9.1.1771866155260; Mon, 23 Feb 2026 09:02:35 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 17/65] hw/intc/arm_gicv5: Implement gicv5_set_priority() Date: Mon, 23 Feb 2026 17:01:24 +0000 Message-ID: <20260223170212.441276-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866566326158500 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 --- hw/intc/arm_gicv5.c | 228 +++++++++++++++++++++++++++++ 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, 269 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 3f74069e01..8572823edc 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, 5) @@ -265,6 +285,213 @@ 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 virtual) +{ + const GICv5ISTConfig *cfg; + GICv5 *s =3D ARM_GICV5(cs); + uint32_t *l2_iste_p; + L2_ISTE_Handle h; + + 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; + } + if (type !=3D GICV5_LPI) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_priority: tried to set " + "priority of bad interrupt type %d\n", type); + return; + } + cfg =3D &s->phys_lpi_config[domain]; + 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); +} + static void irs_ist_baser_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) { GICv5Common *cs =3D ARM_GICV5_COMMON(s); @@ -331,6 +558,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 9b9c2e4b60..3239a86f1a 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 9c7788b1e6..b4452a7b7d 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 Sun Apr 12 00:56:26 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=1771866704; cv=none; d=zohomail.com; s=zohoarc; b=eMmKJujK3Y2AP0T0zwdVHXkg30jomIMiWN5Wt3UzfZ/LSQCH3a13omMIe3XWomnsnmf+6CnfpTq7YnT/FMxSirbj5kkZVwT0KUCzhI4SYeH1/wK4d1iwfjIWyakCPGkK8Gv+QMqPyKU7GHBx977pi7eKVXSW3hYfFsVSGFRIYps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866704; 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=CF4qyxmU9fhPcJpbwrYJ7dJ4Eedw5NYEVJqhMcT19uk=; b=eo8Vr3JqLQV7p43g+3mPo5+zOE2CJH3igFdqiY1nH0+Uz1aUxYqf1bjnnNJVhWU71i9hOg8wH9yN67ohZjiWrBjnZ3V9I1HtLiWiYQVnd9Q2GrN3tu+ggGxIV40RPTd18HSq178/EJthxjPxfnvuKwSAbXKOEPvDickJwTfIB9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866704586726.1945306266415; Mon, 23 Feb 2026 09:11:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKV-0001ue-IS; Mon, 23 Feb 2026 12:02:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKT-0001r3-V4 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:41 -0500 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 1vuZKQ-00009s-5r for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:41 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-483a2338616so28946745e9.0 for ; Mon, 23 Feb 2026 09:02:37 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866156; x=1772470956; 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=CF4qyxmU9fhPcJpbwrYJ7dJ4Eedw5NYEVJqhMcT19uk=; b=TiQkNjWbZhFjVcJrH5+NBa+EInZ2SoS+Lja6Ex9AAA9i+DwTJZZzS8mm4LaibaV3Qk kUFIljSG1jfTzHkG5RIVX3qWbphj6ybyE3rVj5Dq14WqhtCCykLYGVtAacBItVqPZ7br kRtQJFamtX1i21PHB5S3eczYxEaZ0flSvvMt1lyiFnST4iAsmRHq/ZWxVZyjKELImlGr zowm7G5vquuU6tBvLIiG/kqz/zmK5tHfV7lYm65pClPX8+6iyw8IjIQ5mRB4dvSkzHbg H5GXlxodoYAX6idOhjuJApPyzNmPqJuP3OI0Sz+KBXFDc4nXQuO8gBCNYZ+RH/pOiMk3 ecjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866156; x=1772470956; 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=CF4qyxmU9fhPcJpbwrYJ7dJ4Eedw5NYEVJqhMcT19uk=; b=MmUkRLLe+y3xTK7IvPoPBoyioh8lKmnj7sg+n/odrhf6TJ5cw2I+3azvwxafqTDeVR SIyi9bgU+B0WEFpct6GyvVO4qkijDPRZfEvESleAcCzHxDkeYBhapshgGmxxLGUHOBal NukYzRe8Y9qdI+aeV/nvbO4XBT5L2gsUuVOlLvZ/br5RA3uUap8GOTkIy4vH7ak4PynQ ofRU/JpP0vzvpretySNN4D2grc40L/J5DyY9oI+lZf8qXtJdBTTeGOGhiIZyLNQPB4sI 4RlGaFzRIZ8uzMVkK+yP/apgUlDDHpHyhpMPRDi5FCbygJamX3/0Ahr1drR4RzBEcvZe Jtpg== X-Forwarded-Encrypted: i=1; AJvYcCWsESdamd086L/U4ZG372pZMAuEjhQhjPR3Gc1ODY22ObZ3o74FXqeFgdoHT+lGI8QP0zFYsD8dUUTE@nongnu.org X-Gm-Message-State: AOJu0YyuqT9gV4bsNtBz+7ypZXBtGjBVllv/R46TuExrhCbiVwARaoZE PtkinngWPRm+hQ0RK6DQvmd65pC1jgK492jaDKIoYZCoXXxeccZ0MRBTxd2NxF94TrI= X-Gm-Gg: AZuq6aLo6IKFIaxs1Yq/i2u7TG8DI0bsT+0NnibJIpkXnmP2E3HtNSGOAgDlGwnTHuG RS1SlJnB92AJjKU+9H73StiLWwOgoW16t3Bvxm+yApWWvUVMvIky3QVfwnRj065V7Z0S1qBUaEU u36LuOL6/G/VFNoD6V91/yBiqfxIh3/AXCqBU5q2wX6lt5i1i4GoPQTAsvIWm0sygrHZFrqIT7f esmyvskm5KIOngEuMxG6TPEVZGeDdVrGDJM0d0LuYa6noxh+8m8mbGRSrZTeEXwIRzZ1s4VqvCm 4qXUhX/iusWIFNYh1BB3bm2GAefMVULPrb9v/xy6ZHzh2th1R4T1Rxu2d9Xc9V+9btenLQpXF1M VOtb2FPfvMNZMugXf5TzL3hSM5R028e9y6w8zINyen6V7gdGhLKGpX9K3Xsl5RXOzJrtOLPKhoV m2TQ/ivvZyGUdKZJX9qnyspTtyP1En7lWNJY9phw9GRIhk6MTpmQ2YHTlvSo5f+da5B/SQ06Sc+ SnT6CjP1pRnDzRsUtXG9Bw4o5fP27o= X-Received: by 2002:a05:600c:468d:b0:480:7162:fa48 with SMTP id 5b1f17b1804b1-483a95c8f2dmr164281835e9.13.1771866156489; Mon, 23 Feb 2026 09:02:36 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 18/65] target/arm: GICv5 cpuif: Implement the GIC CDPRI instruction Date: Mon, 23 Feb 2026 17:01:25 +0000 Message-ID: <20260223170212.441276-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866705112158500 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 --- 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 76c2577c09..072b38e785 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 Sun Apr 12 00:56:26 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=1771866511; cv=none; d=zohomail.com; s=zohoarc; b=j5YEtxPg6QrBliJG8abpUSWa9Vv8nuLAe9sFR4ijs5ugljTjv/yH4dzUkQZ3dr0mma9m5i9+f/4IR8b/rLS/Z00WEge/+7RrVpauY8RxlKXQ8KThNclnazsU3SperY5hjYTMBBN6ol5Yn2fwcErIacyRWm97ZEWRM9zQJfwGRR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866511; 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=Pxugm0oWVUcgkpDMORCz85xFJuuEUVhItUG4r6MiPs0=; b=QBMu9sOlyV2tJaEZhAxGtncZb2yFMQ3czyizfNac6nS7AS14GO2eM3UDUxX05bIlrxkqc5/s6dB/sCzVDh6Sm7T72lM8PLwSICnYuBHT4x5RnGCCqbXOACYEJmSlM3TIjyOs81kFIFwxA5NrHxw7lIzvWEM6LNvD7HANgDQpHCA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866511180889.2945271719371; Mon, 23 Feb 2026 09:08:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKW-0001ym-BV; Mon, 23 Feb 2026 12:02:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKU-0001rL-2O for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:42 -0500 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 1vuZKR-0000A9-61 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:41 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4837907f535so41153205e9.3 for ; Mon, 23 Feb 2026 09:02:38 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866158; x=1772470958; 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=Pxugm0oWVUcgkpDMORCz85xFJuuEUVhItUG4r6MiPs0=; b=dEzfcDi8EPrNZGt1pK/smxvIwn7w+4jNuj3P7otqjonLrRWlZp98NSY9NgT5soKMMT kIewJ9eVU5Fh/bpqoYQ15ywlXxfTbq/iq9OoZWAVDmIK1+vFWebpL99VXV5HMgGyqMFs 21Neee8HtKeAo2ITDuQ6Jk2uu327plLyBANKt24H/fnxSLrU8rWLI0NwA8mae6yNefPX r5znTxVwtzavhivah68mYNpw1h+nT8Cuvyz2yTgPhzVqhzl06fcAnpoRhn/kF1tWukwQ gDYofSa6iK0TFQUZCL8FuKLAyULB/CiM18iiZ7FqmCsosdUq5o5CtHblw6uc4PoKERbp gmlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866158; x=1772470958; 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=Pxugm0oWVUcgkpDMORCz85xFJuuEUVhItUG4r6MiPs0=; b=AswhJJcX12O7nx05d+/cigho0fV1r7hhVx/QAwgcwSMRB1+BvpzStKe58dIyLej6Vl 1+t5uy9v+MeTB/4k7O49jetMed9ucbFTGJ9YktAaEKO0RzNjVD+aX3DTbE3NIcr8qHtN V2SkXQ+Ond2lk5VPFmRRp5M3oCdtl8/toexBMtRqyNSNI3W+gQbwn4Ct7Y+1J9Cf2MyJ XK9McvL3VTpG9g8NgCuMkRBlWYanM46M5vfdJ2j/i8XP8HAsB8QRk6mDEmzHniJbIuSj 7jpJPXBq9CBX3bWQw7zLCkYdLwXMsZopAwGnJIkvkXR6qd0U7Vib2PmHW6OyE8I3VAAf EC7Q== X-Forwarded-Encrypted: i=1; AJvYcCUdLsnpNQqJnNVA4H7rJYJ2mbpnqnzu3hZmVMZyTvWk3mePrDddOPnAw99bXcBOObOaUpoYW1o0D92i@nongnu.org X-Gm-Message-State: AOJu0YyQgqiKSBVgF8+G37lVQyoufRzBzO+bywseBWrdd8hrPPGDLz1U Q2kBNmuILiX+VjQZHHUMoUtTN80vJrQt7oTj4HpzCkZ5lBOSDdp8PHHczUtX6yu9deUTqT0j147 a8OI7 X-Gm-Gg: AZuq6aLf2coCc4YTWyWtbKO6PtukingoPiN8PFOiVJ6Z5CRdMIAL+YEx7ZwxO/cIaqt JsVGAMky9i8j9HeXBGZpdqPulkoDLA9H4NiG8NZbzittIaKHXdrw71HM/iLnkDPYy5uIgvfkx8Q S9IIQ26hgHqA0kOkIAW7i5EG3AvoQVjQUfv3NCBateoWpeT4Kg3Cd38YhMubkinBbhN+oWTE8B/ EE7tSp7cSg01ojNgpiTkIHvEYG1Ipto8lYW9rnyDwyp3RK605x92ykTd+sTu83c7Z3zT+2gVyqY ULjpEVEM7oTMPrQMi4wd+aQ61rDfxETfkhVzlW9UTY1Lc7c49jxF2D2op8QKn2fYXG5pr7MYeJW V05QmzJIeAlKwQXVUowvAlWVmIDKGgS2zaGMHxjnCMn4PpgnSS13Nl5acE4oDLU7+OErOhulZ1V AtOnn/lDn3UDGNlcjiI9wYmjGHeV80u1XpUny6V80fHNZMiLVvN1SYBRbcYXOmRKbELdQ67IBfg c4PeJ5GTDexq35eQeS0lGHJAT/tVvM= X-Received: by 2002:a05:600c:3115:b0:47a:814c:eea1 with SMTP id 5b1f17b1804b1-483a961602dmr194302305e9.35.1771866157552; Mon, 23 Feb 2026 09:02:37 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 19/65] hw/intc/arm_gicv5: Implement IRS_MAP_L2_ISTR Date: Mon, 23 Feb 2026 17:01:26 +0000 Message-ID: <20260223170212.441276-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866512021158500 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 --- hw/intc/arm_gicv5.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 8572823edc..af27fb7e63 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -492,6 +492,44 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, put_l2_iste(cs, cfg, &h); } =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); @@ -675,6 +713,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; } return false; } --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866714; cv=none; d=zohomail.com; s=zohoarc; b=h1gMXyhZhwXi3rjkMg60LyjehQndos3ft/1eyf+rX0h8L7lVuAiMF5aFiFWyahL9F1QottLmx306o+eUkGX+sNn7fa/36Oe7WIZf4DmX5bEB/VZUL+N7GDX7fWyRUH9Su25w6pcbamHHcNMD33Z93b/bLz616PtVy4eCbix0Tzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866714; 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=jYvTvJG/7tvhpdlK87g5RK3IBoj9LMlQcWK3SacPSog=; b=WWooF+uvW94J0Qj79dIB625LqjLzUaWxo3dNLb0w5BIDcaMDD6H+WTHX9ybyIlVqPgxXEWG2MOAYnCuWxj2ZCNGWVmcrINyPKABDUq8IcBOVlg1MgKJp46TDZE3ZDm0aEq+KEtqdhuXV5ExKLgZYnKoNGXN+CVuyNy+KXoNvkrU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177186671423153.057574000974114; Mon, 23 Feb 2026 09:11:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKb-0002HR-Uo; Mon, 23 Feb 2026 12:02:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKV-0001wL-Vc for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:44 -0500 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 1vuZKS-0000AO-3w for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:43 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-482f454be5bso50770095e9.0 for ; Mon, 23 Feb 2026 09:02:39 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866159; x=1772470959; 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=jYvTvJG/7tvhpdlK87g5RK3IBoj9LMlQcWK3SacPSog=; b=s8feSO4dY64TAIcE/+s6igbqIlnkRV7QiAP4qg4zdv0zqgAZyPMw3XTZV7pzeLOidv 2Yg/oVnVE5HovGwSi7M3DSFl/IIcJiQqBxcVJHVXI70b67Yj9X4geSxHGkcZyEf7fs5G rEKb8S5abD5pdYfkGZfqjvYUtG1FDevP5/VZ+tfcCyyOBpRVnZYkdsPh720yqbhH5z/z v36WoVD2mWBEXYM6bhNNMBxdcBzpJMNYPwB3vFk6cFB8eQyrnoc1x6vDyM6AiFtb9UTm ONKWQQIZshDUjemeXkw7ZJqvFpYHohvgd+pVVrFAMWLL+FrEnE3QkvMZ9hFHrTL2orSw uo3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866159; x=1772470959; 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=jYvTvJG/7tvhpdlK87g5RK3IBoj9LMlQcWK3SacPSog=; b=helvmbOeKaO13SIwjJL74lTD0ZpSfLmavCvpH5sUXIu95kafsBelHomStYE3AXTEbD y2p+Vm4T2NgiS2OsGKiGEHb2KJ6rwA4gwWRm8RbE/uL9pMlcYeTBcfh8XxBI1lgyX+1h 9Cmtrs+DvgvaqHUaBZPgSeL3ONFJZUnWk6N3fnZnxRsoRANpwbwkgzI34IDa/lTelwpZ C2o8Du39ZjLFnEQ43BhCBimmDnJ8mrNlWWTYOmPND+pmRqezu+KX1nK/3AP45PRaTUJC QQSqJrftKgQvuySUje5W5W34oQp79BWeHIPZDQkj27vdKnx2J4diRTvbzbWp/7WHUi4o 8HWg== X-Forwarded-Encrypted: i=1; AJvYcCU1cy8Z/tUY9hpHagIjDm9GT2LqMn8y1QsfmmHyArpDduJ/2ygyj0R+3ZcgJVmPlFvLSNuY0U9H0Htv@nongnu.org X-Gm-Message-State: AOJu0YzlChFIAHRDC2R0TH1vQxVeNnJOtAPxVViIqIEBM+DchaoqX7+D OXOAAEGjOQ7BPYa1Nvt3nxBBSLc/MrMNMYXf3bUClaNYXsIB4Icp16kGFx5kvzSidFNbtbwUkpu ZGnHB X-Gm-Gg: AZuq6aJB5jQ7uTG3Xt0/GNpXnBImy0GdUVFCB2LuNjprgO6Doh9Ex1xHmyqJ71qT/2t EAjO+/gFobXX+SZ9GOmTZn8HRX3y9gsruVlw8BmvpWmQk6Oit/1Xp6Moy6s/v9NHGHqB28pxAfj IrFmL/gM5wAZHUhEfrkCFlk9dAha7EKH9PKNBIEzOcZuFO61R5V30IJyv60YM5bkFIVqEn4FAlz Nq2sNatJFouHjahfAO0jGvAVMs79Pb4pAwT24TIOIH0riKfArt+nofHW0/6zKFakzJZOkoPHbNj WS8q/+UCu7pRZwbDJ7XJEvGUNEbev7GiiFTg8Ed76raCncHsTDtGHBsg9aMa8e0Q4PYHTSSdyXb eLXhfslmRvAYahvUTnT3A9qdsa0ZTwSaUx+1GU4/Psimwheqs4J5GPiA3wd+YeJhfCUfjEgfIk1 h9mOTawhDQ14nI+pbe89Cu/9DBeBg+gWrsljmDTRhPnMVbE/OLYzNNc7zWBMrXXfrCKbhN9Xd1K S03bKDaZIyyZA2wZJT/KfGYPIZfDoA= X-Received: by 2002:a05:600c:1d1c:b0:480:4a90:1afd with SMTP id 5b1f17b1804b1-483a94a99e4mr143926575e9.0.1771866158504; Mon, 23 Feb 2026 09:02:38 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 20/65] hw/intc/arm_gicv5: Implement remaining set-config functions Date: Mon, 23 Feb 2026 17:01:27 +0000 Message-ID: <20260223170212.441276-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866715219158500 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 --- hw/intc/arm_gicv5.c | 133 +++++++++++++++++++++++++++++ hw/intc/trace-events | 4 + include/hw/intc/arm_gicv5_stream.h | 68 +++++++++++++++ include/hw/intc/arm_gicv5_types.h | 15 ++++ 4 files changed, 220 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index af27fb7e63..3c6ef17573 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -492,6 +492,139 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, put_l2_iste(cs, cfg, &h); } =20 +void gicv5_set_enabled(GICv5Common *cs, uint32_t id, + bool enabled, GICv5Domain domain, + GICv5IntType type, bool virtual) +{ + const GICv5ISTConfig *cfg; + GICv5 *s =3D ARM_GICV5(cs); + uint32_t *l2_iste_p; + L2_ISTE_Handle h; + + 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; + } + if (type !=3D GICV5_LPI) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_enabled: tried to set " + "enable state of bad interrupt type %d\n", type); + return; + } + cfg =3D &s->phys_lpi_config[domain]; + 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); +} + +void gicv5_set_pending(GICv5Common *cs, uint32_t id, + bool pending, GICv5Domain domain, + GICv5IntType type, bool virtual) +{ + const GICv5ISTConfig *cfg; + GICv5 *s =3D ARM_GICV5(cs); + uint32_t *l2_iste_p; + L2_ISTE_Handle h; + + 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; + } + if (type !=3D GICV5_LPI) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to set " + "pending state of bad interrupt type %d\n", type); + return; + } + cfg =3D &s->phys_lpi_config[domain]; + 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); +} + +void gicv5_set_handling(GICv5Common *cs, uint32_t id, + GICv5HandlingMode handling, GICv5Domain domain, + GICv5IntType type, bool virtual) +{ + const GICv5ISTConfig *cfg; + GICv5 *s =3D ARM_GICV5(cs); + uint32_t *l2_iste_p; + L2_ISTE_Handle h; + + 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; + } + if (type !=3D GICV5_LPI) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_handling: tried to set " + "handling mode of bad interrupt type %d\n", type); + return; + } + cfg =3D &s->phys_lpi_config[domain]; + 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); +} + +void gicv5_set_target(GICv5Common *cs, uint32_t id, uint32_t iaffid, + GICv5RoutingMode irm, GICv5Domain domain, + GICv5IntType type, bool virtual) +{ + const GICv5ISTConfig *cfg; + GICv5 *s =3D ARM_GICV5(cs); + uint32_t *l2_iste_p; + L2_ISTE_Handle h; + + 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. + */ + } + if (type !=3D GICV5_LPI) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_target: tried to set " + "target of bad interrupt type %d\n", type); + return; + } + cfg =3D &s->phys_lpi_config[domain]; + 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 her= e. + */ + *l2_iste_p =3D FIELD_DP32(*l2_iste_p, L2_ISTE, IAFFID, iaffid); + put_l2_iste(cs, cfg, &h); +} + 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 3239a86f1a..db0e3e01c6 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 b4452a7b7d..15d4d5c3f4 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 Sun Apr 12 00:56:26 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=1771866614; cv=none; d=zohomail.com; s=zohoarc; b=QAGM6Rf0GXKWtBuctZNwBJIjsFGVoDRrTFOdn8mNkV2bsuCZx5+JMcK++xm7LYjnIhSq9wSdl5VXoFRiuPesk5TX52164e+Dj0efw4gum2kOkGiXxqXYEoMgHZpVAdnQ3Rom5Opk44PwauANS+09lYgqg1VxN/r3NPayowRAbTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866614; 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=FzYN9ygidJdhGyDwIINOqZeaIIMy2JouxjcXfZjOhMI=; b=X53ec2md5UPA5N0tJ62fhUKWa4Dcg9pMmU0faCz9HT6JnpSLqQmMFgEdB2d32BGO7dYjV4+gbXClc50nZzH+fy/9QMZNR+0z4EZBHu1efYhamTmeK0M29PddJhxsyIBP610ws8Xo7qsUfwn78u8LxItA3sR847HkMyLQ7tTRy0w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866614410702.8721232402335; Mon, 23 Feb 2026 09:10:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKc-0002Is-Ls; Mon, 23 Feb 2026 12:02:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKW-0001zM-IS for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:44 -0500 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 1vuZKT-0000AY-0I for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:44 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4807068eacbso36217965e9.2 for ; Mon, 23 Feb 2026 09:02:40 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866159; x=1772470959; 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=FzYN9ygidJdhGyDwIINOqZeaIIMy2JouxjcXfZjOhMI=; b=HvI3vFygYfFA0/R1Z2ZTccUtH/6Y+NLQHq6xONzzkMQfRBThv2p4TJ6MhOHdEVNSu4 H27rGofG2EjDABHbeMLhuy2dzwXDvoZZvVFn6phrf5lC8bHkq2H6OHWxbUC5iIZGmuoK 8Zcv6LYk5G3eVxhOHnLlxuimo+e3XyM2sUVciUrLVgCObNHkA1o+/a3DxEunGNs9YH9c u3NdOXrcjji7b+IelJ7JcdPJlTeIfZNDGU9fy5IfDrgTw8X/Ib0hTtgvEennCkZbvUXT hElO5ZTbC/nk0tQlion5GDg4J8nC5cI9tCgY25owWqkGEjIucHtJW52L/LssmoOEinlM Aaug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866159; x=1772470959; 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=FzYN9ygidJdhGyDwIINOqZeaIIMy2JouxjcXfZjOhMI=; b=Ya7u6pblhv7p8LwKOsiB7DDRieV99ozyn6bMgXkBFwwCbo5qbpVn3KJcQL4u8KRp+X gKkiw1DnzAS27/ebv51zpNdf7j7VMnQnCDBYowu/Z6Wi3AIFiXr6hHW3s/9wp8OAJfsC g8nIXRbz1skex8q8O3QkHfVW1vbwL21V5ZemPIzCoxmJMK4H+929S1QCXl49jcm3eUnE 2j03jmXuSHpV2FXfgTgvXACnsN9qENWR/jyzoGGGGkCUd1UOB3B8S3X8ahJZHiOznDBj 2g74SAxAI225GPkek9QsI3KZuphZK3aQ9HZnioe/aQMgPMJShJnUL2c7erqhGWqagqW+ i3+g== X-Forwarded-Encrypted: i=1; AJvYcCUMQUG233aUO6o48wjyjuBtYhVwcmykMmmphmgZzhqXqEWXIfewQt9xaCZGWriJkR9IikNUPiM5QjxR@nongnu.org X-Gm-Message-State: AOJu0YyFPc678Wu1Mo0IMGTYo3ekhke4BH2UfD85p6aw+3bS4hj1qe8Y Z3udeWvq03gHJBqYrZqaWS4LWISqwV0zscgb/NoO+HF4+wnPqqBhsjPXhG2ZK0gAI28= X-Gm-Gg: AZuq6aKH/UnW6E4J/cX1fVldL1blE/5pqx4brURpHGd5pLt1h4TQJS5EylLha1JMFSs zW+bqcrd2eU50uecCP9M484uLUp6RI6s0KCy3S7QnSSU8oJviYy60T3TbQScCdCbwKmUBy8peLr QhLE/td9KTJNExgXURU/JJAPCWxjMpARm+3Sh5vNzUyCl5049rIeyeMa60HdDs6XJhsJgzpDQch jUsNmsb4nMJxnuiOAfy6RRqK/vgYrzfhCqafPux24g6/mJBaIKNPPZqy+UlRRWiUBM0tU25KN+1 0+8V/cKjMnsngaU3ynDy6WYl9NuVRzVivdDzX/pbXi2pBMRu7A857Q1lZNPdRB05S5CNvf56KSu 2pkPTodq6HA0+ntLDImyeDv0rD5/x24sH500FHZWF6b1pQ8gXyqLRZdETkCYKZ9ttO68ZQQ7InN 3qWjoQ27KsdvF16X6a4cGBqIxPcdfGLG9nG/aRgsJgg1+agh7gSDOQQ/JNN1KGfH2uMNaw57D/6 TvNYOIAj9Ub95gVXL8cL5pcjJEERFA= X-Received: by 2002:a05:600c:6990:b0:483:6a8d:b2f9 with SMTP id 5b1f17b1804b1-483a95aa328mr156841225e9.5.1771866159369; Mon, 23 Feb 2026 09:02:39 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 21/65] target/arm: GICv5 cpuif: Implement GIC CD* insns for setting config Date: Mon, 23 Feb 2026 17:01:28 +0000 Message-ID: <20260223170212.441276-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866614636158500 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 --- 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 072b38e785..c426e045d9 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 Sun Apr 12 00:56:26 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=1771866262; cv=none; d=zohomail.com; s=zohoarc; b=lZN1YCcKifZjSGIrrFDB8eAN+rh/ksVL3p/QrwXRHUlwT7L+Md1W5bfnO30lhQOIQxw8BCpwaPbc9fFBpjvZfsvUzA5CEzWhp9wuXh+gATHeUYllRc6VtfiLzxtZs2gEXHrydeG3K39k/7393CjEtartBjLlEn2u+ypASZUqckg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866262; 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=YSGaWkW1wD7oBj2WDkS2uPTd2Xxikc7+tsPaDDJCviE=; b=XrwvEcxUX8MEPzz8cdpfP14No9t35V2qwz3xwQsVCE9IHZvSNf2vgeveprTMPdVuedQDFHG0QTlUnRlDKSiBwKBXPB5j42tkrUe4MKnoXYn5wyI4IIM24NLHSEy4PWfRwZRNvHFOYEJPSf4SKtSbHkOx3jN1mDe9rwrZFZBhu8Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866262423953.8068582496903; Mon, 23 Feb 2026 09:04:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKY-00027b-V7; Mon, 23 Feb 2026 12:02:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKW-0001zr-Sm for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:44 -0500 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 1vuZKT-0000At-U8 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:44 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-480706554beso55472865e9.1 for ; Mon, 23 Feb 2026 09:02:41 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866160; x=1772470960; 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=YSGaWkW1wD7oBj2WDkS2uPTd2Xxikc7+tsPaDDJCviE=; b=pMha7Ny67BcPFXfAfgWBLy7dWoNW5YIt5zQeAom6qxg0g/WMzBLnyNivWVNoHf3xDU BfsdhaWe2/IGtzpv+1Fuptgedq38iAX/Cs07ppgd1BgdnPauGgy/u0v2fhJWQBzxmu8F os6YzXqqumrF6VTGsK0/MtYdhQ3bKEC7PO6rMA3ujzMoceXjnuCfwbZ6o09aE1cFbZuQ hNXFYDSEucr+D3zrMD2+SptMiJ9TpKyCYAhfnZw0FQONVL73fcCTKTjCnxb9/ITMqyeO RKKeNwY8B9dusSIL4uuyErqhIPSULE76Bzbd/nJAA7ofmMe7KemYkYBaNtV5Wf5aAY8g vfHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866160; x=1772470960; 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=YSGaWkW1wD7oBj2WDkS2uPTd2Xxikc7+tsPaDDJCviE=; b=RYJg8altDM9OqYaIyaPVS/rnL6iVUb6Cj+dYwgYKQVRSZSfHQqqJ/QTnQdJDQM0Yr+ B5hSd3Ilgrk3zVlYTUt/MNXAFz+XH0YA9RPoTpHwK+79WpWeVmNk+2Yr3/kW1kt0gvgS L1rBZEaRz+4UPiqYALZC2qaN1/l/6bRuO7ubHEivJqYkx1yRbld9vGns+mNuYgbot437 IJ756q/rR0tfYMiwijKo2SUOfLAHwkK9LTClJo0DIzlhukpte65LyyXn/H+q6doKyrdp SBE1zneJmoR+1FrYSojhk2YHcVU54ZHN34aivOwlogcqq3gLvNmW44NakUzC9ZsNL06s JkKA== X-Forwarded-Encrypted: i=1; AJvYcCUpTGegKjp/v2hokMb0UylsvYB9gkpYfW40gRPqjfa0T81jaaqoZ468SG1MQ/FyId00s/Rlyc2DcO3L@nongnu.org X-Gm-Message-State: AOJu0Yz7YOJMcdebJHqsCzSgPt3nk0nonPvXZgYCeOM/j2/r8BtA/455 fu1bl7nmIX8gnrq64wrWTjAeYbmU0Xsrj7bn2TBuW232yZVZN0XXW4+1ycwgOEuDTkHs5cZBew3 7yli3 X-Gm-Gg: AZuq6aK7oL4JjnPuAEnlX7JLfglNGDpYEN11ISRS8SJKI2GnywqMgDYAVOQpbkMJesb H2EFw2DeZ7wYmK45OcTRac+3yFPYc4DBxzrjry3w0xBV6rikukEGc4EztdGI5umA3krAabMF63j /2yLdkrQOYBdXA2VLrUcbBs/LsHOYd2NeA+3OQr1q5G6nsDEt6GQkHFabngqwR8mR4e9aPwem2/ tsaIYLiOMt55qnx3l6zlx5/dwepyklLxntdUW27Jzbgs5Un1EvZ/AoUrtjeBSPXxlrWiGn0sA2N KdUNPW4PaajOBauK8zZ8XqyqfAm8YWnYplC1Qmxeb8Ee8olHDCRvgYOd3Q6pFHeDnZm5NdME6Wj sKPMfZpN3xtxspFYOq5Xz8wJFzs3dKwA7Yh0U/bcQlOzjTDTbctpZrbwkrDDeUlGI9SC5tP7yxz mX/y3qUQFv9VC2RKIjpy1DQjJ5KJClFIt3XiKTqljqE4XzlWGJVnKe9Hotn8y6oXIaGPEziKBb+ wRVRl19Q9SuE7WIOOINeKXwQcdZ1YM= X-Received: by 2002:a05:600c:3590:b0:47d:3ead:7440 with SMTP id 5b1f17b1804b1-483b427b0ecmr46929795e9.32.1771866160236; Mon, 23 Feb 2026 09:02:40 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 22/65] hw/intc/arm_gicv5: Create backing state for SPIs Date: Mon, 23 Feb 2026 17:01:29 +0000 Message-ID: <20260223170212.441276-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866264324158500 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 --- hw/intc/arm_gicv5_common.c | 30 ++++++++++++++++++++++++++++++ include/hw/intc/arm_gicv5_common.h | 28 ++++++++++++++++++++++++++++ include/hw/intc/arm_gicv5_types.h | 15 +++++++++++++++ 3 files changed, 73 insertions(+) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 751df2001c..8cca3a9764 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -66,6 +66,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) @@ -144,6 +172,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 2a49d58679..c29eab2951 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -53,6 +53,26 @@ =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. @@ -65,6 +85,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_ran= ge + * 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 15d4d5c3f4..30e1bc58cb 100644 --- a/include/hw/intc/arm_gicv5_types.h +++ b/include/hw/intc/arm_gicv5_types.h @@ -70,4 +70,19 @@ 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 Sun Apr 12 00:56:26 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=1771866653; cv=none; d=zohomail.com; s=zohoarc; b=BdX8ZGHgZBE1yLYMR7WjVSI86yYt/42nv2R5EKl0gIM7euUSkIAcSnaRLO5BWK566/yg/sJTdVCQKMbkC8cpA8bXnvuivtPTP/euWe9g05WH9/Dh4riQWze1luhugZgppVHcIIISuN33E/IKo1+C9vPYx3uZb6WfTJG7GHsomZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866653; 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=JwcHn/CjQkHfmGibiCn3O/oR20qiscSiOE7DixcXUno=; b=B20R/h12BUxzwCHds29Bgv6UZW1Tj/17fPJt2zRSkO/FZAFmmT02Y8CQ7yKU2n1z9C1MqX2jfS0xGCp7DqJGQdEULc6bR6pJI4FxFGzyOojWo9KtGEi4U3urn5yeIsudNFE6i6rheyS9YSn90mXaIhwwHY17NvjX2tDcqg/XSfE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866653004647.2177969716832; Mon, 23 Feb 2026 09:10:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKb-0002Gk-6T; Mon, 23 Feb 2026 12:02:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKY-00027a-FC for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:46 -0500 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 1vuZKV-0000C0-SH for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:46 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-483a233819aso44119505e9.3 for ; Mon, 23 Feb 2026 09:02:43 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866162; x=1772470962; 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=JwcHn/CjQkHfmGibiCn3O/oR20qiscSiOE7DixcXUno=; b=lUaBDTDqUrWwC0ckv1WCsTRChyfWaIblI2vrbWiz2PdUdP419gKsPb3FjdtZKSgm+N pRMsOwC0wBULgjaQ6hkVARDcGrqev4AcIAno+oDfsZRHMjiXLorebPYRpMX/nNeJayED tE1irGwSEKSN9t8OotP61Q0lKHQJDmDJn93/Jhs2Kj6QVkrXgnaufMCAZ37ghIZEyH3p dYb/V1l3e8v9v4Dfg3YhkuOCp6E9BM0SzLBa889bhc5g/LRxf08m8tzxE1kPW+xrSMPw fxkbW7meoxfOfx+8ioCTnvtbZhCTgsxQBubKZcjnnc5pBFJDWZU0LMZk1Lr77h1PWDzD qdJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866162; x=1772470962; 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=JwcHn/CjQkHfmGibiCn3O/oR20qiscSiOE7DixcXUno=; b=eGWQR3cZ2vwb2Z/j859vTk1pCJDImcgI2c/2KxP9uLVa9CviwdXdRy6M7J9Z8hfv80 vfoXxy76mLuwfAm1upcrgrntKSpHR0cURwq4Ah7ESWn8sLWqy8ikUqVXSJDngAJLt+Dq JzFIaEdxhldO/BrBAvvcvkonrfeXsER3AsE1Q8fnNOwHAsQiF8x/m2KB2P9kBIIAMZmf CZbP2E/maTW8Xl6fqqr5KrtYUJx2Wt7lYx47c1rtq+sFU7/oZ5tw1TJaTBghjyQUQjOL /MzNKq/wNSkU7/rH50tQKAMPlwaDMyBNXALQN8gHZdalJK42j+J4hq/+NhpVTIXSd6NT YE8g== X-Forwarded-Encrypted: i=1; AJvYcCVfV0154MIOqS+QxtE52z6vdWZoWN3UGax4WjAuxyZwOw1mRwMjp/EhWhowoJcr5YkhOHkZpNDosBIV@nongnu.org X-Gm-Message-State: AOJu0YwGytjlG+DCFycsnNCK/813OlmV/Ck0dQ027kWPod8xWYhr+Z2n SEeO4XtDvMRauCvcIf31zlzcErLhRYyHrpmxt5TOGe7J9McsCsM1LFgt0LR9LiZsNHQ= X-Gm-Gg: AZuq6aJ8/FHz7sM+nTXE1zrW6T2WMJSnt5zsIzE/JKloTOPD2wf84goXr6wmHZyf6W+ QH59QoD77eBBIFNOMUloeN/xkEsrNJ79qnmwjIadUxcBKpFSURvO6Z9t+ZqrviVpCMuGY2VRcbY 67RKPYLN7N5fJ+3JqyCaFaN9D9TzYDAZwoI61kxf4/qdnHemnyFI8UlPjlpYEgTZVX+I87YT4wz kpdlAmJtdkvX6aJSGOHg2SBt82kzZ7k/y66FJ2sAK445Ltb4KGg8TIiz2NTggiCvCbg50ZCuznq 6vclPQl+bhpqWunqrimE+m552wyqx8/iti5yd+MryciLnOxghIbDfM5xOSaPYmP0DI9+GouFUCO MOLM/fzqYLccedLQXTkBpsy3Bmb1ojGCidlABHuAbJ3PsubWKcdftUgZLZYbjqfUSzOffUgS3yg rIJhlqaROqjGoFdTUapseiCV5ljKk8rVVe5NBy+y4bRK2W8CMGEwjeh4EeJtJEHZxdom4SRtPjc ml33CwedClbMNnYoAuLfGLExZE9Lgw= X-Received: by 2002:a05:600c:3147:b0:477:6374:6347 with SMTP id 5b1f17b1804b1-483a962e3e2mr138417725e9.22.1771866161175; Mon, 23 Feb 2026 09:02:41 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 23/65] hw/intc/arm_gicv5: Make gicv5_set_* update SPI state Date: Mon, 23 Feb 2026 17:01:30 +0000 Message-ID: <20260223170212.441276-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866654888158500 Content-Type: text/plain; charset="utf-8" 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 --- hw/intc/arm_gicv5.c | 59 ++++++++++++++++++++++++++++++ include/hw/intc/arm_gicv5_common.h | 40 ++++++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 3c6ef17573..4d99200122 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -478,6 +478,18 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, "priority of a virtual interrupt\n"); return; } + if (type =3D=3D 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; + return; + } if (type !=3D GICV5_LPI) { qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_priority: tried to set " "priority of bad interrupt type %d\n", type); @@ -508,6 +520,18 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, "enable state of a virtual interrupt\n"); return; } + if (type =3D=3D 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; + return; + } if (type !=3D GICV5_LPI) { qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_enabled: tried to set " "enable state of bad interrupt type %d\n", type); @@ -538,6 +562,18 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, "pending state of a virtual interrupt\n"); return; } + if (type =3D=3D 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; + return; + } if (type !=3D GICV5_LPI) { qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_pending: tried to set " "pending state of bad interrupt type %d\n", type); @@ -568,6 +604,17 @@ void gicv5_set_handling(GICv5Common *cs, uint32_t id, "handling mode of a virtual interrupt\n"); return; } + if (type =3D=3D 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; + return; + } if (type !=3D GICV5_LPI) { qemu_log_mask(LOG_GUEST_ERROR, "gicv5_set_handling: tried to set " "handling mode of bad interrupt type %d\n", type); @@ -607,6 +654,18 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, ui= nt32_t iaffid, * IRM=3D1 the same as IRM=3D0. */ } + if (type =3D=3D 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; + return; + } if (type !=3D GICV5_LPI) { 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 c29eab2951..1a1d360c68 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -191,4 +191,44 @@ static inline bool gicv5_domain_implemented(GICv5Commo= n *cs, GICv5Domain domain) */ const char *gicv5_class_name(void); =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 Sun Apr 12 00:56:26 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=1771866676; cv=none; d=zohomail.com; s=zohoarc; b=QCGsIF6SBt7ajDok2cH28W/S3VaMzIMOtD5SxTaSMF6No5+khNi+2ytcX8AqpJM/QB85MRJv5FHURoFOxT8VXX9IKbfS8YCGfcpBD1ywWday5daZRscKdkIVJQJBkA8fk9fwfa02wLbWWTRwuh1oesPY4Q7qMho4Qk2cNFEJ1j4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866676; 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=cuGfpXqHYLjAz/e03DHfMF0KD4B4dSvsbR1oBLz0niE=; b=Dmt7A9DqaEASi4F1SdnRgMoh3ArzvY1SG6keXuTe586vKYhp4nH3UKW5pYVxXW3mnrCuOZDiC6nN0fex5i8ISjj+FaTZUPFuyjc/KsPcbMlTooPu8VRAGPj7ysT2kXWxQblqztg8nkzFIbuRXdoE9e/uePQhJ2BAjdepl3N6Xb4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866676383185.4498636246559; Mon, 23 Feb 2026 09:11:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKZ-0002CQ-Ro; Mon, 23 Feb 2026 12:02:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKY-00027Q-9y for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:46 -0500 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 1vuZKV-0000Bu-RM for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:45 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-483703e4b08so36480915e9.1 for ; Mon, 23 Feb 2026 09:02:43 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866162; x=1772470962; 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=cuGfpXqHYLjAz/e03DHfMF0KD4B4dSvsbR1oBLz0niE=; b=daXtnGVe/jTmdaKKipNh1JLTEZw7KdnqU/LFWsdz09Luf2qr4UX1fjtZ4BfxqofO2v DMy2TEHKRXmBNmDuKGM/7VQXRiaAYOIu4JIGb9BkT76PaiEq5CrVdr5qRFKIrnKdxTgF OsBS1LK2oM56HarAxE88Z+8WvWALwiRvEWxTkLKVWhJNI2VS806QSBX3eY1v+ttc/2EM q83bikdksbMH/3Nj3ii+wO6FyNXMGuccfkvPJrVyZd32zDei8rpk+9f1Jkl0XZHhPjcz JVil6eEquLxzPVOMK7+9aNkfuPEFVhYKYrhlIb5fdG/JSUl565ygqOAPWTZIFX0UTWtd CMkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866162; x=1772470962; 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=cuGfpXqHYLjAz/e03DHfMF0KD4B4dSvsbR1oBLz0niE=; b=pLCxHCPg+jNUoPmVtF+spZhC7iqkDcFv4LwLxYa9O/GexRJ4/bIHzA8ssEevn++JYf 8zme0WdgIvvy3fx70EjCuX1qcfu4d+sTHpwA26RjBg2BjO4EGyNGIEZVbRkvtvFFvZwh awVlFxpSpk7RaTwWa0dnNx3uD6RhNu+2tHEHV1Nqjmk+fXSUdWqcTLE25HapWQ/srpZx 6/+SkoZu2qdTTEfUFcz9znhsvHzzEBLnEp8eSR1Uu9xT+0CUy9BvlfOW9VZI7kz91tTW HNoa98El2sFeVEKQ6REM5uFkkfSnpveWmfH0h0yTDYRiSyniQUXDAJpsLiCmKwuVI8te fOXg== X-Forwarded-Encrypted: i=1; AJvYcCU50FJPJ1+As6nIAtUqIxj6v8V+Pb1xCOOvDbJPAgu0gIfbVAN5ABq8rSm1vUGKqXFmKSsQZ/Opn9/I@nongnu.org X-Gm-Message-State: AOJu0YwLf22VIgllDxghxjhe3VQbqkO1rV7NnW0Hg3B4xClT7nBgAKST gu8CZDra5gMvfzLuoUlRNtIPwrmFcnvTnpp/tVz3VHdrbIAf2cjOgmp7/nfmWG3focDb0Ha4jv+ BYQtV X-Gm-Gg: AZuq6aLMmT+H2Ygw8eBJu5dLYhE0D5sajeLYOO+v5SNpaGnAPsUl3rNfeUxm1ZqLSAc x13C6fGcKacpOeHVOj+ZgLMTpeKkqDC2t1tKpZ6eFwxOSzEAIKbSLlbv5h1THBCimVDBCi1mJh8 Pa3yzYaZ4ZmVnW+BaTQRxDSOEar6A8mmt9qAwBgKOWVR1rvOwocMpVWjjqg7pvVTT3uaeI11G80 d3LnHrpDU9lgE9nmB1R5ZAnDHKjh2tzplolY6IQtzBBnFVUnbq9i+Mscz7dopo5a/opM/r4C0ro /JWmqv+/IfdI+wrOSNXflWPE73xUgxekQVd3lJRGZMH+hRlh68tkdp08oDvbG6l6j3hgnuPcv9H xVw5ESnujIxvtlzHOAZxeN8wCrl+I+SK9XlhEdvKfx3OsmIe6PlDs8qnYOEJfnMp2oPTJNLdqo5 uqqMCafFp1PR8AOgiyiJOUZ0eDIjJxcsIYe3wgTgvvdwivZ/5rlrblB5kXcI+VI/oA+4je6m7pV 6wFgshGWLFnRj//o9zCn4RGeMq1+V4= X-Received: by 2002:a05:600c:1989:b0:479:1348:c63e with SMTP id 5b1f17b1804b1-483a94c99admr175465385e9.9.1771866162121; Mon, 23 Feb 2026 09:02:42 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 24/65] hw/intc/arm_gicv5: Implement gicv5_request_config() Date: Mon, 23 Feb 2026 17:01:31 +0000 Message-ID: <20260223170212.441276-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866677025158500 Content-Type: text/plain; charset="utf-8" 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 --- hw/intc/arm_gicv5.c | 92 ++++++++++++++++++++++++++++++ hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_stream.h | 24 ++++++++ 3 files changed, 117 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 4d99200122..51b25775c4 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) { /* @@ -684,6 +697,85 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, ui= nt32_t iaffid, put_l2_iste(cs, cfg, &h); } =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) +{ + const GICv5ISTConfig *cfg; + 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; + } + if (type =3D=3D 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; + } + 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; +} + 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 db0e3e01c6..1f00e8ffff 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 RequestConfig= Ack + * 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 regist= er + * 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 Sun Apr 12 00:56:26 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=1771866677; cv=none; d=zohomail.com; s=zohoarc; b=Qz2WHs4afeOkO8q6OkJWASFPv9jui1jVkzRfLMVnC77qnV/zljlJkTFMhqxXWoUyRoZbPZq1e1urLPrN6amalMTEmYRsX8D1+1sD5Va1e2v9HLs810yKaPeuRUWG3IzW1k41BI+Dq5u2lnGatB7lK1HUqv2Ud+VCzQ6lTbW6bfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866677; 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=F/dI1qFmZ1RsBVXqA0SGOU0duWbHv0A4HX6TOb0/aiw=; b=Orc8iaqJNHcWn8l/99gymAQLsvOXIrjHWPTTQTZWQ4lroMFbuMSIN+WzIInxZ1Y3JRLgYpHeEeOQaor1jfsdTqOLeNrGJE5ikwHHqSqojMz0foPnCJ/zMtio0Yf0FybUq0cIKQiNXynyDSVcRFctTGop5c7GuvhbqYoCOE1Aw+Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866677398571.9377209486821; Mon, 23 Feb 2026 09:11:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKb-0002Ft-38; Mon, 23 Feb 2026 12:02:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKZ-00029M-3W for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:47 -0500 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 1vuZKW-0000Cg-Uu for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:46 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-48375f10628so29376405e9.1 for ; Mon, 23 Feb 2026 09:02:44 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866163; x=1772470963; 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=F/dI1qFmZ1RsBVXqA0SGOU0duWbHv0A4HX6TOb0/aiw=; b=a2s1EFy9to+CR0rhLUtOz9XtH/nS0nsUo0e9P64+jFBvPmo6rIuDlKxzlTCT+YKhw1 4tSkJ93rWI/kNCHQzpAjKUT8h9h+C4LMN5o49Vnjz91niuGc9svQicDTyIxm81ofgfjY EpDax5y2WkNnH8EodSZG8Yjvq5c0uu6lLPgQm88LEUUP0l++XlsFW/J/J/nYKSoO+8uN O397bdNeKHIXPWFTS+WyY6bkw3lMyd31f0b2ax7rBMfMKtAbUAbO1hfL1mr3JdkdY4gt D+SFJqAiNvP2GIrPCGloy0Jz78CgYTIUjUvO8UpooI6BFX9rLwhG3KmzptZtOSPtcrjd XZgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866163; x=1772470963; 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=F/dI1qFmZ1RsBVXqA0SGOU0duWbHv0A4HX6TOb0/aiw=; b=rUonMGHmagNQABMQD3RGNGk9WSm6ejMCckBvJMB+3lxkgyVcC4nuU3duGrxFklHDHu ORn8+Ga/5c/QVdeAiP6F2353IcCciiCiMjC2GjwmUXu5t4JtuhvhMe1AbM2Vsqsnult4 gMHF1yyEFeYVGjaLrV812hkP7Gp4/K0OgOrgdRNpdCC2XcCLiH38FyDkKJAJzkPFyC8y vXCiLChX3SL1v6Jq56h9cCS9R56GF2j4IXNkJkqEzFNA992t0TWRUMDc8UtsO3Wa4hX3 zVlMHDbLUc1i1mbMzGFYSAbm8efS6q/m6BpdSP7yX28rQieX12yx9SmgNGeNKx2M/Wet JN9A== X-Forwarded-Encrypted: i=1; AJvYcCXwHHmfNzP0oCMnPVLLKkz99lz9hkzKnNiZHweyFBW7/tHWyWwfLgTeWStL1h/uWSRUO3pkZ+XFf6Zi@nongnu.org X-Gm-Message-State: AOJu0Yx/iamZUKeTaz6cezgvVKWND0pkfM0OhatWWveX/EwPqiVamnxv qYZrthlYkkuJMf/6LbSQAiZSAqO6z44VsRnZKqU3iCX0lzjd762E+n0S0RTFdq7QNsk= X-Gm-Gg: AZuq6aIeitblKXxE21/ddorwrAwxZRXti7dqIMFawnU4+ANLknaoxn0ES0jtr+1Vqgu huWyCFv03WI5C/d3TCZgwhycE8jD2Wf84c3M6boQwNa5VP/2N5K8kPnwI/9UpYujwlKbe1j1WyT XdD9qxPE4VwcYaZjQGsCaZGDCoshGDYIH5ta9oWnVqtg3oDFVMxGM3cwk3fgYko4lHt7gTOovU/ BjJ/7eW0y7IER3XvTXm0OuPcoPMReHzMH6mH3N+cz3O7BWtWCElunME0eoQxxi2rgwP0sjxW3ub MuMJ+rmFQXxLG67JoEkYfU4wgKW1YvUxZSxbdomNPuSXMlOv9c5S5wXiksspYLYWo9zualQzaiu B2rg5u5doQBBA3nccS/bCWeshqS1wgp0Y61/SsJfCpH/qwR/CFavcGAM06WllpM3F/39BMmWhxO PmHPc7EsSb5pznujuH0bwFip0kNl0dbzuhQNoLacEK22e/0I4qUHp+0m1m0VAapzlyQIXcQGSei QzdgLn86TeWp2hhvNNBLNKT4EbWHFw= X-Received: by 2002:a05:600c:638d:b0:480:1e40:3d2 with SMTP id 5b1f17b1804b1-483a95f5a62mr142636435e9.29.1771866163326; Mon, 23 Feb 2026 09:02:43 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 25/65] target/arm: GICv5 cpuif: Implement GIC CDRCFG and ICC_ICSR_EL1 Date: Mon, 23 Feb 2026 17:01:32 +0000 Message-ID: <20260223170212.441276-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -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: 1771866678942158500 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 --- 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 16de0ebfa8..1fdfd91ba4 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -597,6 +597,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 c426e045d9..4420a44c71 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 Sun Apr 12 00:56:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866655444823.597999499728; Mon, 23 Feb 2026 09:10:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKc-0002JL-SU; Mon, 23 Feb 2026 12:02:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKa-0002Eu-Mv for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:48 -0500 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 1vuZKY-0000DH-4W for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:47 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4806ce0f97bso36859255e9.0 for ; Mon, 23 Feb 2026 09:02:45 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866165; x=1772470965; 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=5UcrJtBZzxsU4kxR85chi5yChlMOw/kzpqfr9OMvMYc=; b=IWn4zxidW0Zi9zkCxbCXMnQv6mJKkMhv/XiZ12Jc303OlpvH+vGysuVudRJ9nAy+ex S2FduW6m/lkLT3+C881MbfLRzXcN8QfX50NJy1UyvK4qj8XhullnC1BrhBw2ThiW5aLd QUJO0ik5v3GUEdZJz+7LAP+Vn5+cn9qQApkWswnTkME3lEyxaOLWhm/lDhON7IvfLPZj 39rK1J5egUFWaTuFEBDuOHIOKzgx763840zz4aVu8imUFLWbHcM9Z4Oy8/OehYqP9A6/ 0UpnwDGsOpglFAJZKCyKdQZ1Tw9XwCKu7jmeSTDS0fszoaUsy0C4X9b68X6b2dZBhTuh zb3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866165; x=1772470965; 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=5UcrJtBZzxsU4kxR85chi5yChlMOw/kzpqfr9OMvMYc=; b=norg+MYp2jH3y2OV1bt7D4CsGnNIoKU5Btv36hrm3rwlHood3dnULf36vBbYwRCd3S PgwJHhH/lCDnAvnEV4e/LdBBxMtZACeKfO+pwEC8bzPrYMMqNtklWtTQpx+00jGRZKJA urHb2hNMkAg7kLhw4yO9Qo9HY/r1C1tFvK7Vn2D+Yicqepx6OaMl8LAhA6q4b/WHVRUX Ihhc/0WxzCgj0nTXZHc0yKd4VmXw5SLtDqH5/x+EomsPPit9ZNE1hM0Rj02xZjmUj8tD 6BA06ll/KKkdqREhiGLGYmlOdEZIN5kekDk0k2s9NeqWw/mnpYSnqhT5dqqtNfa80tpn 7dsQ== X-Forwarded-Encrypted: i=1; AJvYcCVzhI84QijVuof7Gy39IHKSZmRA0tZQqx+CaH9dCZ7o3Y8lRQPxLN1oSSL/wcR8Rk6R5zidjv1gz5vN@nongnu.org X-Gm-Message-State: AOJu0YxjXAqdF9wzxvYCGMmjfHVW/nKvMiacMcYU/LRZOh45WetiQt33 qcEedqCrwg5px/hmLn3ze2dx2OiLr1FhsLNcNlSUGppPv+D+fLVQTI4xZQLRecNGVfkDhQWOwG+ A5uf5 X-Gm-Gg: AZuq6aJw1ZA0hGortp5lB23ikvn/LeMxI4dpZ0lqFzfc0TZ+d0vvy3VmRWEUCXmcSjk L8WRno8q55w3LqjxWg00/EAMAgndezIlumuR26HVWrchkttLDNDKETEzwvhbGJSq+hNxyNpzWyF ElYPVIyxgizViRdtLWyS9vEalvzHcpIZQdCLMRouxQ87JOM01eGUUrO3XXxhZbFQKiBtzM4VLWK 0rbRl4b69qWnWjLA8VAf9ko9Yq2zX13+/hYrxIB1+s+hDWYY7r5UTndyJTKMJR8LWweBgZg/+ZR GXO0R4fQ0MYzDR4VTxBNSX7x/0SrSQ3GA8eq2lKuOd2VA5mu/IqDFdy9Nwf5cKpTI8nDaWQNefY 7XG1D8kqgxSMetromcYnF/gndTZuVTA6tn01IMDjgkkArJOyoXmUlEzjOaoqT63qS4C06yGC4nP kkuLRAJSKhW211rc0WsIrY4MZ9rtdUGELwc3UnpPRgosqlZcPkC/6mEZUNulZg5jz3aizUangQf jb2zre9KETwwgcv2ao2fhiNmJ7tw70= X-Received: by 2002:a05:600c:6206:b0:46f:d682:3c3d with SMTP id 5b1f17b1804b1-483a95b71b5mr170727465e9.13.1771866164379; Mon, 23 Feb 2026 09:02:44 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 26/65] hw/intc/arm_gicv5: Implement IRS_SPI_{SELR, STATUSR, CFGR, DOMAINR} Date: Mon, 23 Feb 2026 17:01:33 +0000 Message-ID: <20260223170212.441276-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1771866656857158500 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 --- 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 51b25775c4..9f4d44f975 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) { /* @@ -970,6 +986,38 @@ static bool config_readl(GICv5 *s, GICv5Domain domain,= 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; } return false; } @@ -1000,6 +1048,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; } return false; } diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index 8cca3a9764..e0d954f3c6 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -94,6 +94,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 1a1d360c68..5490fdaf8b 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -84,6 +84,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. --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866557; cv=none; d=zohomail.com; s=zohoarc; b=lwTSuJI7WMEcV5eFmF/0MMo+TigmtK2bUT9+fECsNuOblvk01Uy4H03rZlWNWpctoTQetrBlry/lYy94yzrcsCSXiPXmCqI0q4npJ3zKxB3ZteSJhC3AKVOC7KSMQm26nWoK3CERCDqXA0pjnfJhYVThq2ydinHHkmBHI49XF2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866557; 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=A4hIy6Kcu/S1hR9Ar9eqjjFF1c+deS8g8DeFKzdYWAM=; b=ZpMQA9QqCmjq0aiUCQH3w77TDwrKHDA+iLi7wrJz0myKy+NSY4K1LvGNPX1swNsdTN8L3DyPCDaYFDiLYFPJJp2qFLoMWNskIhw0jWBE0szYlsG/QIMY/7M/3Hq8GnfaON8Z8heb1BC+uCgjKSjJkhkO6x4AfcL+824wH0qTq14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866557169715.9400505940589; Mon, 23 Feb 2026 09:09:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKd-0002Ja-Fl; Mon, 23 Feb 2026 12:02:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKc-0002HX-2G for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:50 -0500 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 1vuZKZ-0000EA-Dg for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:49 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4838c15e3cbso39664775e9.3 for ; Mon, 23 Feb 2026 09:02:46 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866166; x=1772470966; 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=A4hIy6Kcu/S1hR9Ar9eqjjFF1c+deS8g8DeFKzdYWAM=; b=HUeFNmkGKpfMKKJ6SEsY5yyuiRBZDsyYz684Los8NW+Tsj/+a9i4gW2NbVW3GiNs6x VIa6rmBI0/N4DEc5u+ozKcofhzqAgQ51yniH4J/aooCNEAehypt0u3RbHbYx+OApdKrK NNfH6xcqQRWHcZcznRVwO3PcNe2ue8fvao9HULgRVNB+FMQc+axl7m1qYtm73YURWV2V In4ZxGmp8dkuVJ08tkcQCzLLmyQi+d1ld3AWAjOeWadnlKEN0DcMrVN0kUe3SLX3TjHT 8pc+uufbot/f8p0t4TozW5Wa8VMD6BeiyIUbgFWfpmGTKvmhh9AyU9J7rlOyZVnHNoQ0 wUjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866166; x=1772470966; 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=A4hIy6Kcu/S1hR9Ar9eqjjFF1c+deS8g8DeFKzdYWAM=; b=nPoK71sPFZVC63kM+/fQ3JxcjQXXTCDxA8+CZAw7DHvsTuhvRnuiT04b6LdC8h4E/H 3syZ4Q/TQiY7h2GaNtToTPoKYvyiJpkmR5q31pM68fNmnCFCL3AtSPNlWLhM4sPdNZO8 ifVP9ZJZ9vmBZEQIdSskSIF/DrD7V3DvX8qnxox66c9sVvuqMurd67QWP1+8cxp3bKoe c1nhk/C7IchMjp0lylarK8fZvnD9iJ8yug06BPSosQ0RAiDpCJedimc3dGAIDBikHgM2 rMfLO3A9TPrdKYvSSCGTEMAbBZ37XKQdSkbhM1VjrA9X8UerzTo0R/1c+prLT8inkI29 xr6A== X-Forwarded-Encrypted: i=1; AJvYcCVhIBBt9tXR6YQXSjFa2+5tVSVwvS1J7Ixv0IqAQ0+STRkRmguMvIRSDSOJ1ysA8/3tb9IF4rcOjqQV@nongnu.org X-Gm-Message-State: AOJu0YzHSB/2XVsxw0Nuab9PU+8tVptf0fNfL7RI0m9FjEWMzQbfSwNb Xi+O4etJJG/MLcaTqp9cVNGJZMkU0AQaRJyrskP2sZ+lWNYFOBSzZIs4Q+AffzyiKOU= X-Gm-Gg: AZuq6aJ7n9CHeOkyWYlR0EYEXgfF2tR1ekeCHpLGKugppF7YvWitY/yeJNTclRvWaJM LFOoByjxM+lJYkJ+Vw9b+IWeJ6tJIXogWMPSQ7Y2zW0MMjN/lvMPPghTvIrQxqL//wX3rY98Oci 1RCYVMYJuKRMXBSZ9tEwXBLTbZSgv70OHMDrBmPJjU8NXmYU7lY6pPzA9CRKUnSDNxbnP9mK13b wcx6/I7yTSYhnYVRdv6ySKcUCYoxOdRFJdFqFA+XMYeO0w0TpPIxZMcxgTYqS7Cx9JHYOLA1BHd 7SokPIhPOxTFyDiLknzGZdEUnMcYUZ4HbgoUVQEQziAjq7aiTr8WNG9dUFx+LjlDzRh7Tx8ZgMz Mitm56lYhivOT5KyWx5tj6uPSHre26n9p0fba0NiPryhhTWlM+2JZd9haZxNaLj7GQ2ngwPq6sq xKGiX/L4JJZVd3k64AoZtLDZh/RjTmgNAuKyyUcw23HOI0MN84vGdfImANu77uy5j4WQMKHmmir aU6HAHomBjRuWFQLEJ/ApjFCGYW+XYjwb4Ow5rUbQ== X-Received: by 2002:a05:600c:3b0a:b0:47e:e2ec:9947 with SMTP id 5b1f17b1804b1-483a963df7amr151995955e9.33.1771866165623; Mon, 23 Feb 2026 09:02:45 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 27/65] hw/intc/arm_gicv5: Update SPI state for CLEAR/SET events Date: Mon, 23 Feb 2026 17:01:34 +0000 Message-ID: <20260223170212.441276-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866558285158500 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 --- 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 9f4d44f975..d1baa015d1 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -908,6 +908,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) { @@ -1055,7 +1077,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; } @@ -1068,6 +1107,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; + } } return false; } @@ -1236,8 +1286,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 Sun Apr 12 00:56:26 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=1771866381; cv=none; d=zohomail.com; s=zohoarc; b=BixJ/VAa+WShzF6yG27A4Fh4HPbes7J1Wlsai9zybDqjvenGlGo4sIpXVf/9a4AUFU3Muofy3Wt2d+hboOEma07q1D/RSHzWHuZyRBHIknafTDH8jIC4dxD/CpNlt0LvpbX6MFTlhshCQJ5pskrcwnJgjmnoIEZ9tSl0oRsFFJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866381; 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=OWTRxMPzfjQP35RbB57Fpzqp0nJNEuo2Ib1GI+1oX2E=; b=mSKz4cKPlEtIh1xDc4pERpkBJYhnCwqV73WukfnDWXEnoA+BtxCxrHWj3CPPPLcOFPbLguX//vCkH5i3a2yIrV7opx2Wag1MgZM3bOG4sPyYmACCxW5skbpQrJecIxG/UeFIINnEZvR0qRa72fohZH/Dv6T4Kg0jtW+4dcBGQp4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866381285326.2213069202983; Mon, 23 Feb 2026 09:06:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKe-0002Kd-3r; Mon, 23 Feb 2026 12:02:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKd-0002JU-AW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:51 -0500 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 1vuZKb-0000Ee-7R for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:51 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-48375f1defeso32334425e9.0 for ; Mon, 23 Feb 2026 09:02:47 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866167; x=1772470967; 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=OWTRxMPzfjQP35RbB57Fpzqp0nJNEuo2Ib1GI+1oX2E=; b=W9pq+A5OG608byHUyTRn25o5ANgAxZKoD4SjkyB9eeKIADm6u4f6LnusTmj/XC66ns cIl1srlD6WnFJB50eg4RUnlbfLll04QqEMqIracqTCsB/EEXmGPGLb5BIRkzZnratQsE R0UT95eS/iHrCu/jv1bZWiMGvJMGrmBlEsgUN6/+ZLzoSAnLJ9r/LaBc57zKNcdIZoId tMPxjA9jMvp02jQZA7ZiCAhfsrkE9DVYHhFP8MWkdrCWYOWmBdUJO8twUjcITktVppqb htPx5vqVtr65CR8i94YubFM00JRj5bKeiRA9XsBBf53pxZmWIkEarXruTz7D+XST+DNJ Bmug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866167; x=1772470967; 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=OWTRxMPzfjQP35RbB57Fpzqp0nJNEuo2Ib1GI+1oX2E=; b=cP0W2N+WYMGxjvZ8DXnN3M4jCUNLJr6ppu1bruFpE/AhmBIChSw2nyfNhbWeuiZMqw udaCm6Z6+JDJnpiDGXZyJUroFHDf2qVn7Pan4Qi1j41j7Yql7DeXQ+LshfDv6hiELX5j Q2zTS5rvwSiGyhWHzI+Rg/pBqK99QmghTi54/NJ0Ycssqcto4+QXo6jzGHWAVGU1lWW3 su82yv6xHfB8jNvfeYO7EgUHV7qcyUikL+bDgs4m8omFI1IBRR4P6ChtwZ4KlXAfDRne Yp0w2+mYhTSJVhlAJ4aHInPTRbuA0sFVQQsJJ7UDGPV8/eo15WKr1Rg7pNK4jFxRsojm gyQg== X-Forwarded-Encrypted: i=1; AJvYcCXvtQI96+YymzMsNPhIjeHDFCKvygL1X2Uyqf3o/MFNYCYV39ZElTm0G91NnZZMUCfMYo0pZRaEezUK@nongnu.org X-Gm-Message-State: AOJu0Yy1tq2MtzuzLVpxKtMl+i4icPU98krxqnz2nhmSnOYVQA13fW9g XlLldtlgE7JQrgrUbkorIyCpNVZj3lh2a2EuzYD02KvDveToxsQHlz90DLZ/rJuI9sk= X-Gm-Gg: AZuq6aL5jshhl5jQzmygaZ4u/cQq1ZHG29qUqfQIIi4+3LrDiw9S9YPEGKyF0cDmC6I KNHEv4beRajlVLTxX+5N7py8Pp+4OYAWWl8Lb8O4UExeOi9d0nmJLBsXc13dL+s995Qgq94WuB6 0Qn2/b+26dJwEYDKK2nhkfyKCo/bCRnf4i/wHRgZoZ78N8CAM+CFvbIKGLAsSJ7OC0vGF+HXoqx vWJG5S6TN7QfHVL3OPmL1G4BE33cE8DDEIOS3qqfx4qlxK3n7CNsrC5GsqrPEUpW8mmiQvBCHEJ VORLzNfb/pR0lv2rhiy6EMeR+PGf3apeyQCIXWLdfkgOrrzhxSTyzlhe9ELh2C0N5iyfzCZ9FUL BDp12vNbrFlqvhvAjSUtPewWLVbu3DSvrluqK/btyj940692xHTDKoWDiqyAkH/PzJJ+WLNrDNI UQ1WtECHGz41nCwoWIaYFWFQT1dfUO4Mebm3+5lDsN7qp+oRjJAj6Z8lWP4YR1orMeiyM5zO5mD 9m/fLIyDu17jcL01Q271XOxxcN+k7Y= X-Received: by 2002:a05:600c:c3cc:20b0:483:afbb:a064 with SMTP id 5b1f17b1804b1-483afbba23cmr77215115e9.1.1771866166714; Mon, 23 Feb 2026 09:02:46 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 28/65] hw/intc/arm_gicv5: Implement IRS_CR0 and IRS_CR1 Date: Mon, 23 Feb 2026 17:01:35 +0000 Message-ID: <20260223170212.441276-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -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: 1771866383145158500 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 --- hw/intc/arm_gicv5.c | 14 ++++++++++++++ hw/intc/arm_gicv5_common.c | 2 ++ include/hw/intc/arm_gicv5_common.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index d1baa015d1..5f4c4158c4 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1040,7 +1040,15 @@ 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; } + return false; } =20 @@ -1118,6 +1126,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; } return false; } diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index e0d954f3c6..b358691105 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -66,6 +66,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 5490fdaf8b..00b1dc2b45 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -85,6 +85,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. --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866269; cv=none; d=zohomail.com; s=zohoarc; b=ie9yIdgQMt7coew3lhFF1oaAZuGN41GIN+nKmXOTgE5jzH70G4JIhS3h3b298uIPVvsTO7te7ANH7EcZ6ix9etx8YGNOR7akZ5Y7wbzG6/2mcLJqSLfcnj1Kd9VCzqB/P+Y+fSwWufka52zsDgEFdVhq00Qcwyw+m2/fm+DRUHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866269; 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=2cboAhFeHVHRYQSjMCx5mj0gc79Tc2QBuh4TMC+EX3s=; b=g3LNHotvIYOOZlhme5u+oH/UiwQKn89jPxxAOqV6fEmd8lg7TgRQo1/NveoA9krW3RButG1YKyMoiU4frmWCakXaNWzGhKTd/e28RP5p+k2Z+6i6uRYTPatLJeDejCnvdotbglSmSWY4OOZLPCrhojkREF5IUnqOXAeugPncIq4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866269671925.9015181971462; Mon, 23 Feb 2026 09:04:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKh-0002Pw-NF; Mon, 23 Feb 2026 12:02:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKd-0002Jm-IS for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:51 -0500 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 1vuZKb-0000Ez-Mb for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:51 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-48069a48629so47254085e9.0 for ; Mon, 23 Feb 2026 09:02:49 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866168; x=1772470968; 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=2cboAhFeHVHRYQSjMCx5mj0gc79Tc2QBuh4TMC+EX3s=; b=Efg8Q+WVH1W77D5YMiu/m0qADogdR8LI1wEtu+TEHZKPOgQhXwJzYkJAj9shdf6rx3 CNe7ccygdvatoKAbISHcH8TxPcysbvrLKrGBEhbezwIu5iJ8ATfMswrAWIJ5hBzP3S4s gxX+8oI8FKXR6rXJ2IacEex/VaaslSLaD+9Nm/IOgIRvI1QJIe0w5Aknew8paGpXuSiT D6RrOm2wmbE5Tb/SWS7vSwnnqowbf16HxenVZDqBHzEi/Gbd6bawqzce3oPfmR31DjHg qc9Abroy+6lVTBpmT2xsOeB6S0cew8YxdPkkkT74IEh4Gop3ZdXflYLz5OegCKJbl0qv vaUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866168; x=1772470968; 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=2cboAhFeHVHRYQSjMCx5mj0gc79Tc2QBuh4TMC+EX3s=; b=PMN3jib55ssSKGjl/b3yn4rDd/zyMQKTFE/JsCUNxxWJTjBR98Rg1RkFVGkRxx1hzB dRRtqP698Ejby0RS6/M2ER8OuGajI0xTRHLN/KV0FSeWHi1S2THgTtkcWqapTjyjagtI 92mJ6SRrAbYSNQhixxY4mn9fx2VpMSfPbaseTyWZywa3NGGgQwz7w/XfZK3v1wRBCu40 +eQi4L/EftYedIwmQy5ZELyt4Fj/m7mMrQEK71Vt/0+2OuLwmICd3gE6eCPCtvxERNY1 pV4AIKY6QQo7+SOfEBXVek+jgWD4ULHnSk/eGl7JIcIe14awVCNvnlRiMjJENHq6xZuh 7VMw== X-Forwarded-Encrypted: i=1; AJvYcCUebxlx4TIDo/zKumH1Rz+wCtQ1g2ZsGhScejjWvTFOlln+T64SN6LHVcjhLZ24U42dVpPHVTY5KUy6@nongnu.org X-Gm-Message-State: AOJu0YxUXPhlbOoSkp8jbuqBpXUsXHcW1UiU6qOe8RHccs2LLWxT8URr 8pqBM0VGfWnaSbjv+0tFU6hYDKWdvbgM3Tn5BoP5HsyCDDMljNCGJFI44/1pfrp7xY4= X-Gm-Gg: AZuq6aIokMJ4pNXb8VP9HRsdgn/ulxEZt7LU9ISoSw1uqTsushE0vstKh5ua1otW8bA IB3pl89lWA/Tb1RiNJ1dCoxVf8V+c6lwdKXgJPOXm+KBZfdHLfRprTIsFHrs/1k9d++0fM/Aco2 J2g2VZFnRdJ7+chop8J+QhPMCSRcw65rg1UlX1KxArJUdx3NXradnJyy1EAJhJz2eP7I+rgMrkA re+5sFH6Ef+SkMFnjI3+sHdW1oDCtP4MUAL8rRMV+9M5Gs/+R0U4ONP8LZF/w5yySRkiv3Tzrp6 E4E+C11txt5lJXBVWeGjAardP320ARuXjyeZBd9PT3oJtPVGh7NS2U+ir/CLwUzP2T249sujTk6 R83pVFHqCXsR1Wd7D0yKz1cDsX2LW++olK2Xju66qUDfq9G2A3cJ5e3875fjOwfhLs9/u7MU+qV K7WB51fFZXaVr7c3XIZFdN9SeYOqLIcBgU1Wg21jurFqOF/3Ldewauxp6s8yxYGp+XR5qdfGhkO YH5mqlCUbNuEQfmpjandl5OTJVMuSAPC3KucJI18Q== X-Received: by 2002:a05:600c:4f8a:b0:480:1d0b:2d32 with SMTP id 5b1f17b1804b1-483a95beb5bmr166518165e9.12.1771866167675; Mon, 23 Feb 2026 09:02:47 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 29/65] hw/intc/arm_gicv5: Implement IRS_SYNCR and IRS_SYNC_STATUSR Date: Mon, 23 Feb 2026 17:01:36 +0000 Message-ID: <20260223170212.441276-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866270354158500 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 --- 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 5f4c4158c4..d0ba8fe669 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1047,6 +1047,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; @@ -1132,6 +1136,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; } return false; } --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866541; cv=none; d=zohomail.com; s=zohoarc; b=LkQJZDO403DLW2UXIUCmt/QZZyPLfMspZCA+i1eSZLQanZKjFNSW+YAr0jMDziIEUNQ8cDUNYYtHQDo1Ew+GWa9JFIA8NGN3wbBM+RX+yQdaTSa+4RfJezh6aeFPpVWKFoWNP/RBXVUZSISHObQXfqt/5dns3zMGPppzk9cAi9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866541; 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=lwouxz/o/dkwKMhTRSd+FjgJjYJhHe7TZXKPF0VtHa8=; b=capiKTTu/j+rtHyV9okmc/g445IP6Bcl4EHajYwxGNUcl1VSANaFOGMxZOgJwxYabG0adG91rk+xuhUHGzuaUBNwPZW4XrRHws2ms3LYlpTiB82faYQp5rqcQRtskYPNy5aSGxBpMEDdZHpBnAdYh8y28ZVgQnL7fBvZrrXT01g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866541885639.9272867021527; Mon, 23 Feb 2026 09:09:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKi-0002Rj-K6; Mon, 23 Feb 2026 12:02:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKe-0002LT-Ob for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:52 -0500 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 1vuZKc-0000FJ-69 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:52 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-48374014a77so47451825e9.3 for ; Mon, 23 Feb 2026 09:02:49 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866169; x=1772470969; 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=lwouxz/o/dkwKMhTRSd+FjgJjYJhHe7TZXKPF0VtHa8=; b=dbiCcWdAGoU9hzeb1mbdj3vcRD4/gOIo0TCPJ7z3+ySyQpLpXVu3ByptpI/Ly6UbEs 3FtvksYHeg9Yow+xnMDCQN+VVq94GF0spjteyyc3mPnyqQ6bAOC9KbcQctBzBT6gW5wE 3VsVefRHY7kdrW1QNzNFWdiTMAsWx4zgLWyjS0jf/H+ODabp3mCTl2KPETXW4Lyy95yj ad/fLLptLxDuEAt3iT2VeufAh0tDZyKhlW/HXHmvRp+xNc8aG3ycZPaKaGePmQpaVCDF WxgbPNnihrPdb4B2I32ZzS/VsqEvNxYnF9km2bY4OreWVjy79Iy4gsK4Q2JpTeeLiN8z vYEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866169; x=1772470969; 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=lwouxz/o/dkwKMhTRSd+FjgJjYJhHe7TZXKPF0VtHa8=; b=f+xBBW4xk4IgFUtgdhzqsHQfLfnl+VfyyH95Ca2DxVSSF4NgZVMgNfW1G0gIcJnO7Y f8iJuvBWUKh90Glz7skAZNziwiH0vT0DWKaRZq7N8on6Xs5jhIIkZbLqxF73eXVowsdl NO6U1vtEqz2FGA2FU9/8W973NKKuOCAnd+LXXlZ8SdTjKXDUVkLWtYLQf8Nu5bvQ5XHQ Z/Acc+p4eluzlxM6t+4CM9DgeiKpLjVu04TkmHeL+AI18CBk3qQXbSF53PsvULZ35P/5 wSjA3pHGJJrKZWw+yjFuHKPssF87X3HIxmMKWSR+iMyPma6Bf/C/X0ZoPyqwDdW4Dyh9 hrYw== X-Forwarded-Encrypted: i=1; AJvYcCU5Fik6udwJoYiyKa0natsi1baBqDX7JidNYlA3Fp7vMCxuo/afmv6WykHKpGp22hKiR0l3ZDUtHw2T@nongnu.org X-Gm-Message-State: AOJu0YzKYMXpcVXQyj3i9hEtKuKxoOcyusEnQLtrA4mhkOKY4dsh/eh6 yIjgUmSKMWag9WXubF9R+Cz9JZIKtquuCdwUD1349V0JMNSCfZuFrzlohAHD89LjUF31pyZRT/c Cz1GU X-Gm-Gg: AZuq6aIYQG1B6nTywnCIy7n4iTb6RsKcTXpP+nuxGrshsQ0g46xbpDfekhjhScAYprP S+SlMHLkDkW79FQPZ9fBXwYYGgItN7F0PE+4xotmTvi38FltAixl2WUT0tU2+i18MYMt3kfJ3bO JUJvSiTz+IU5ENDdDMnDJdQIsIyBinQytDVKO33OlNlcIYVN63NbboJ+PTJuNAzYw1BHhkZQ9kF Yj79QySWE5AWgoAZAUH5YdUDVNtvfamEvmn4XIkW4U87DkRamOWyv82iZ7IImsjs9ZQ/iNxPqqz sbuSoWQ2TSfqYFimzcCv4QJC+uLA/1hNE86nCAGsIUqGqyjRqsyn1DoS13OUKgc3VR5C9PVs2R7 c1huUQGeXyzTwcJxYK46q76QBQkiuSEcFie1Bj+YKjY4xS56c0r1m03B0xVzNd+j7w+Ss1ghgpL Pv6wkbcKOKbT5Ok/vojMsL7/9qM4d4BzeFP1C/ngNTziy4rFnCHwyRpm1GwWVfF7uB4JzHKhcUL UlaaQyAFYh9z9iS67YA+FX62ld1AUjKWVGskaftrw== X-Received: by 2002:a05:600c:1e1d:b0:480:6999:27ec with SMTP id 5b1f17b1804b1-483a95bebcdmr171897625e9.13.1771866168578; Mon, 23 Feb 2026 09:02:48 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 30/65] hw/intc/arm_gicv5: Implement IRS_PE_{CR0,SELR,STATUSR} Date: Mon, 23 Feb 2026 17:01:37 +0000 Message-ID: <20260223170212.441276-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866542130158500 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 --- 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 d0ba8fe669..0f32bdf357 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -930,6 +930,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) { @@ -1051,6 +1066,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; @@ -1139,6 +1172,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; } return false; } diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index b358691105..bcbe88cde7 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -68,6 +68,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 00b1dc2b45..5254e68fbb 100644 --- a/include/hw/intc/arm_gicv5_common.h +++ b/include/hw/intc/arm_gicv5_common.h @@ -87,6 +87,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. --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866586; cv=none; d=zohomail.com; s=zohoarc; b=YQmhIXuK0ghbUQt/ZeAeBh/XEqvt0OYPCZKsvoqe8dAjYVHFqM3i92lKkHAyLFQgdTTBFGi44VnIkeqgX/eCjhVCkMtLN4euTpW2CEQg+5O9qXlNuA3rfQAArQo8PnF1ypWchk7dXdLhukhLkTlgyHYcD/JNYVmUFDJKOkwV3+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866586; 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=cG9UQZiWYcMzTWYtwzGm/gBDPA6lWtqbwXkGQvPrL5w=; b=dTBE1Y/UObD4cwXD0aMDsr8ki/syEH/C29mrkF1ytzpwzy/H66ikuIH753U1yx82SvWtdBRitroKfHMBrA6fx8/Nsdf2yEScZsOVKt0ksUpPeX6/m6z1H8UneHjJrQ5sR8MvntJzvHmEWoHwXWB75IJhEeNn+kKhOXt3QvLY3YI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866586395359.1585121008584; Mon, 23 Feb 2026 09:09:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKg-0002Nt-3r; Mon, 23 Feb 2026 12:02:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKe-0002Lr-Tn for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:52 -0500 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 1vuZKd-0000Fm-4F for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:52 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4806cc07ce7so43130135e9.1 for ; Mon, 23 Feb 2026 09:02:50 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866170; x=1772470970; 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=cG9UQZiWYcMzTWYtwzGm/gBDPA6lWtqbwXkGQvPrL5w=; b=LNX6S9fJIW5aHHvxjIZ1xI+BjerUOIegJFJl3KtuX/cvf3nvuQ8h9dBma1YIqmFaLc jO4sOKolW+kqw082dW/RvaBWvzu6xlGsLVQGBe+E+GSm6ZTFSck9A23m21TSDZe9zbWf 1dNbuLWGQ6beJUuEN8Us4U92Hd0J4kXa4iRvTYJXgEJZRYrYBaTajSsOj+B2chhxqsCw MCkbHd2+rqvTzdyi2X5ZUobB/mpCGNiQwSIZJ8SDrYAyES51IevmhmjIM8CHT6SjCDYt XR5ihv1/HYWpSXCj3UMKXEt30IxaDiW54Q/YD4STPMS3H9qC3pSDNRo80yorvdwmhs41 Rq3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866170; x=1772470970; 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=cG9UQZiWYcMzTWYtwzGm/gBDPA6lWtqbwXkGQvPrL5w=; b=NrIXM6ms2cDkqxWegZZFIJuU7J3RPtg+YQX5S2mVi5quD3o6ZJbZw4F7jCu2AejWpE ZTFxvtmDSR1UTGa2jb0UI0bmuJjLT8Hom7C6eVygQ3oiRrekofO9yi1/E7ZCa/3422cz t86sWXi7O67s6p82dOCvfBG2HafN3feBk0uVnL0Xae43/yU4DmASbU2L+0tomqQbdfB7 uYwlfblu1NHf5Mli1pJtPp1kt+5J0KmzO9NHnxCqb3lT9MRyU0eFy11x45sW5yGvJ90e Xh3UGVsIo9FU6Y4XDLUtpUEWT0PsRnBWUKNHUgVkvfkRzXnNY02ogwY8aQrBYKTiPIrQ Tgcw== X-Forwarded-Encrypted: i=1; AJvYcCUG0ygu4l0Mng8UXwimh/aOMOF/nk3ZH+Yrvo0v15961/J43JiHoEa+JhUoXP1VB/d4tEZIDbvV6V7a@nongnu.org X-Gm-Message-State: AOJu0YwFqUkq1GFHc5S3d/OrCyXY79TvCNgJfFQ9bs7ruTGuUQVTfc20 pIhHWMzWuFzFdnjP5CfyibcJFTAHFBGCmvRg76fOy3MjngCKIwlABjwxaGpVR9FRx/I= X-Gm-Gg: AZuq6aL5qveKNavEsyM88X2VeM8Vg96RftI2ze+x0MHrWkq2Kae5fNBe4ScYjNA5C2/ mKCmB6iSG4X8rSHfLVyxVyBLHRFMTqSKjbthDyqTBCyDRLgbUFvktWWXQumGFd7lQsC+MR0gymu QCD54loM4IrYLUHBgdlloYRYTxgMKsa45JP3DVqR637Q/U/TtmYq93Is2wknRVTvD6JQccrryE8 gKg+qC4vnIARUMfmgwuipd2qA1uDUcA1+lt8lX6rFNHvRinT96req1TQgU3viGfKgjnYn6JDavT Hs2fCmS9EUZ9vyamN/VOZfYd5h+DrQ/AR9O0+oSzmRK6zrmlg9Gl9d9xnGk088eU9RILfOrdveh +Dmaxt4WpQWcQZbI23O3NXCzJgZH3lrsrbygbOZRWiCX7XVlH8OyBhnB+f42PkodSSSi0BQCYDc Jg85ktwwwpClXDxohNAYtvgTKmHEqaDlG0rf+fWQHYW+4G2GZ7VoJ94vjO0SRpRKL4CbYJiskpt g5Srh9f7QAslRITe6WnfIRaQLcOes0= X-Received: by 2002:a05:600c:1d0e:b0:477:98f7:2aec with SMTP id 5b1f17b1804b1-483a95b58c3mr129810345e9.3.1771866169490; Mon, 23 Feb 2026 09:02:49 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 31/65] hw/intc/arm_gicv5: Implement CoreSight ID registers Date: Mon, 23 Feb 2026 17:01:38 +0000 Message-ID: <20260223170212.441276-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866588438158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 0f32bdf357..fa7692ca0e 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) { /* @@ -1084,6 +1112,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 Sun Apr 12 00:56:26 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=1771866324; cv=none; d=zohomail.com; s=zohoarc; b=XsDKDrTgUX0qjVKdVN/lGm5UX64oQtEXXWTRI75oAEqdA38wBphvyqwZmsjvyRLIFAeQA5UHjMDbChFKbpj+WKERLdlGAxNUuXyyKm0+o53Vk6HPwEdU8C2W/602lGuRR9GO53DdtojGo2cdubbIV36Sf/tL1W+9d+9B8dBKpWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866324; 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=oJkPB1+usEO1iILLwjFfPn1z9uieHX7lfkftnDGLpWQ=; b=RjBCOy2+s7eImgS/a5ZmexRuPwIv5rE47d8kI94j+YnomXX4XtY7XH0Fz/Wr+vExj/rHt/u1FSjT69B9K/x51EQHcKOre6jpUH3rb6PqVFGVbsSPrPnu6Nhqf7uP4espFGYoVyC41VJfvQ2GWDHq/E2Hltr8CT/XmKJZSlXKncQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866324621282.54813043172373; Mon, 23 Feb 2026 09:05:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKj-0002S4-53; Mon, 23 Feb 2026 12:02:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKg-0002Og-HM for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:54 -0500 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 1vuZKe-0000GE-6C for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:54 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4806f3fc50bso52097995e9.0 for ; Mon, 23 Feb 2026 09:02:51 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866171; x=1772470971; 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=oJkPB1+usEO1iILLwjFfPn1z9uieHX7lfkftnDGLpWQ=; b=tvlAZCI+J5/x8pDYcd2sitm2WKc8II8CH+w8Htcze+T4RjiO8iTf2oghWVWFyBbxPw peoJq5GUHxp+RYcBNamcfrahBKwFfpscY8K7T45caAaXcewOJNVXlPkt8GSStxbdtFus 1CoJV0NrPWkCMT6yi1cBLyksO4upHyLRDpgZwCbS4viTf7Q0ZetmsvZIFeDIQjWVojNg t8lVcfpBP0VgSu2sMFFUd2IznSbeOZXljFHpz0IXbVOr9eYpCGZZhj88yebrdWH/vbJM CSv2P9xUrW+uWFR0oCFCkGDX+NSNIlgr4v2n0QiO0goGaxLeGbMNLJNZfsniYpKCpOOa mCEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866171; x=1772470971; 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=oJkPB1+usEO1iILLwjFfPn1z9uieHX7lfkftnDGLpWQ=; b=dIqUIzFSk9G8zyDVrfj4V8UpHUeX1QjzY6oT0tUligDhNjQo5fTLqkraTcy+9DQGSc 2dviEDIpOYc7+Z77fljmuuOozr8WSJMsseQ3QHjVnE/pQZI1Gf0YXTGdnPosI2lcIXqZ wfv1oDABb54OSnZQhKURGWgIc8WyS9Og6Qmepl4xzV/tqzcMAPNDMkRiFA6rsH54GhW5 b44JVtZYEogayiYU0gNLhuNTb0JblIwSLyoFdYp0jexjdNuXlhFy3z48tloYcdddSl0Z hSZcYQCL+sFoBwDCwH4ZqVfp4XyVPtulQbp0F4krJfZ7G9eHyoXr9RhuePWizrtriGX0 5zTQ== X-Forwarded-Encrypted: i=1; AJvYcCWlqRcZjQrV06n/+qUdsR2EuK8HtA4k8i7rCvdMs3hXjrnodSD17xcyC9WgQQ12ft6pzylSkufAsUId@nongnu.org X-Gm-Message-State: AOJu0YwlZl+UpIziZMmU8Hvco8Ar8bHcgOWRgWngJUS4o0El4i+NaTB9 IFGlMeOkgCFpWRjwZD78JZaB3xkWX12lCxLxyyv/O5rk7v7DKSyp5goFV9yPfiIpX3GB5fBe1BG GC34E X-Gm-Gg: AZuq6aL7lokX4bqlkmAWyhD5/cvy8ZzgOIIDl3MYyzgAKyHPIWyP0M9CKRln7SvO437 KTmxdC5OathOl+zgShc44bsB+wILqww2aXBYKiuWuas3AuYOKcW5ItzoI1oTtOyQSeSMKnML+t0 M2bHk2nOKZrOuyJx0pCy2YZfdkWzb2XGesouvVPlH0/Gm2wFttIBrhPkkDAOvy4/x0+ppL2rAyM 061T/h18roz6ZXNlJBE479ZaaXWhclaagJohSYOsQD8hm5OIttK/DmP6yenr+vHwFL5ZGk8G99J QuDZsD15+3azTlgsr727cDe2uVFBKOMaspLJSnQYIG69NVTnYvepqbRZa4vAxpezTI+Tsx1OPJw NWMP8wEldWdWNTkC9Kn5rplYU8KX81u15znW4/VF32NGVKa3FsaMx8frzXIgPyW5xN45MKa3L9J ZL1Agzaag/UzLYVFFx030hN+lJegfaitUaX4Z7pcCFGSx/ZhMuwdE4BnLoc+3QzLbGbTMCsPmhB r6ISIqXY0ukdgLHY0pbJ6TPtNRQiXcR6BtKrID/Hw== X-Received: by 2002:a05:600c:8717:b0:483:612d:7a5c with SMTP id 5b1f17b1804b1-483a96375e3mr149074005e9.25.1771866170516; Mon, 23 Feb 2026 09:02:50 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 32/65] hw/intc/arm_gicv5: Cache pending LPIs in a hash table Date: Mon, 23 Feb 2026 17:01:39 +0000 Message-ID: <20260223170212.441276-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866326930158500 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 --- hw/intc/arm_gicv5.c | 110 +++++++++++++++++++++++++++++++++++- include/hw/intc/arm_gicv5.h | 2 + 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index fa7692ca0e..30368998d3 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -474,10 +474,21 @@ static bool write_l2_iste_mem(GICv5Common *cs, const = GICv5ISTConfig *cfg, * 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. + * 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, @@ -498,6 +509,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; @@ -513,6 +543,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 @@ -857,6 +915,38 @@ 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); +} =20 static void irs_ist_baser_write(GICv5 *s, GICv5Domain domain, uint64_t val= ue) { @@ -869,6 +959,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; @@ -930,6 +1021,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= ); @@ -1406,6 +1506,14 @@ 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, + * we 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 Sun Apr 12 00:56:26 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=1771866366; cv=none; d=zohomail.com; s=zohoarc; b=SszEukasRSvWPFOhuYdCJ/7IPapIQqLN1wcgQ+esv99NSXXlKTwq/vv3MCIX6301E/AmRV5FeGKtbpSeQgaOjnig+2isLqvc+LUA0+JTq4UbdQOyPWzVHja3pQ3jDC4eCm+8RGrUqeh+Q/nZOmlCwjREbv/9LiuBQzoXWOg+7RI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866366; 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=GFX2oLIEOhrVQeH0JfIITp46cEANNmny594ZuEVDUzo=; b=BhJmgqqDp6mZM5s6s7JKp+Q9yNMw7tfUyU4ozXRh4izQUkyyIYApM4cVhv4vNtydcO0L/py0qMhzJw5TF8OqJcaZkN3kqN7LaqdPukwqfagw13pRNYXWkjn1XM074+NKFLw0QEe27SLn2u5kSLFBHxVTMtbdkfLXSMbSb1FPvzk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866366907461.40547455437536; Mon, 23 Feb 2026 09:06:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKj-0002SI-AK; Mon, 23 Feb 2026 12:02:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKh-0002QX-TE for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:55 -0500 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 1vuZKf-0000Gq-8B for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:55 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-48336a6e932so28245135e9.3 for ; Mon, 23 Feb 2026 09:02:52 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866172; x=1772470972; 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=GFX2oLIEOhrVQeH0JfIITp46cEANNmny594ZuEVDUzo=; b=EAW2xRRn/8MDYs1d+BmeePlqhzPA5jJm13tm4AKK3Uu/yY1LwQELJYOmrs8fZ0ic3c lZXYzVC1d+xPthhBySoUu+szKdKZuVFgwDz+Pb5Qp2Ybu0t1hJ7XEslqJbTmox8rC3Jv VC5M6BoFqm9WfWnpHF649Q2BwHVy9ZVM1i92mdl0vhaNJ498azyoqV4f/+vZUJ0S1Aks r/kl7S/ToUpBdrHkWw8Eu3OwZIfH7raMTZatAFOTaPpiBGgLqNvFYdpmzwfwanjUcOrQ itvlEtaxn5dsNlmrGSzGuHvtVEMDMYR6EbIFMZQ38y5YvR0wmeV6wkFUxStrrYWTRIQo Bs5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866172; x=1772470972; 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=GFX2oLIEOhrVQeH0JfIITp46cEANNmny594ZuEVDUzo=; b=bcN8+98yTnKFn96MYqD8o0Y2/EWzoqX/TKok6qqYofC14DderKdBLTlQqOZvz6tZJY SWewHA+v5Q9GMneNH6WcfZ0/WaFD3u2CLZRo0Tngm4+pkVsziqyGxBIoUZbxFtuCZUDI UU+8fE+ClrUVra9fYc4NzIS54faAw2jhrXoBXbhmuNur5L4HXhHlL5Ah1heXLhOmVszt nS2fVuDzjCbwNlJ1Y530+ZyWqd1BBk4ToH1klkxzTh36nYOqvyNfEqX0wprJeVamezCd 8GAsWXPjTp29WIr90GLE1Io7TAJZ88TuNTCQYA4y4ng8yUuWACPNFa+svNgdru/CKkTd LYNg== X-Forwarded-Encrypted: i=1; AJvYcCW/ZxbUoqYfjACq04dPzxgkxBvD4zi4Cg6yi2GshwpsE+ssPlcBIN/GsSQIvGDw17RLPdkGBL+3AsgM@nongnu.org X-Gm-Message-State: AOJu0YyY9CGP+NrqeNtbHmF++siOoMEbTsHqWXEm0JuEIvXiT76jySlt k7oCN5v9b+qwdya3M85Slqg2AMb/LmsxDT/BgoQh70++E7kHyeW1J8lxYEKkHt42L5mP2Hn2Lni 9x707 X-Gm-Gg: AZuq6aLbPowmQFXlnp+zOtD2aHCdxK0cmwjg/FKJYl9EKrQskPlk6ROd8s51n+GRQRb oLL9RvzOPdzjz6nIGnCT9gwJNWNXqQXyGeMTKfbrYBEe3i7yCQ89ShI1xR4/gji9+cgosk1zLGc ZztTnRj3Gl8VyNeTxef3+lTKLggJ+vrOgSha9I0igdB1yBKpPyvUNNQ9LuG20VrvPAJgKM6x2Kb ExVWHFX1J6Dh8tdXPm6MW308qSE/fXmQWxn0Va+PR9puL6uFYglwFnk52N5E8XdEV0Qy/eof0Wp FZIGByBvqlK3nwwT1Xgsb7r2GjM+epjE61JkVdl8xfAB6mpzWJCxdqerwIupBg9nECWotru1bpG 2sHrMTKLgiz0vVKYJSEnzwQysA6MhxnqCKby7b2wv9dDQr7hGFn1Hi+HdTboVK/vGDiCfxmKEOK p2gzbRBZTtj9NqXy0LKUHCI3j11SHevDpOBqTbSR4Rrdj5AsY8cvTb5nnFbU0UK43vcx2yPk+O3 sjRgWbRa+d8cgb12bVecvCI9JUjb0obppvxxBD6dg== X-Received: by 2002:a05:600c:3516:b0:477:9b4a:a82 with SMTP id 5b1f17b1804b1-483a963df3cmr193925005e9.35.1771866171550; Mon, 23 Feb 2026 09:02:51 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 33/65] target/arm: GICv5 cpuif: Implement ICC_IAFFIDR_EL1 Date: Mon, 23 Feb 2026 17:01:40 +0000 Message-ID: <20260223170212.441276-34-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866369123158500 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 --- 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 bcbe88cde7..8feb492a43 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -175,9 +175,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 1f00e8ffff..7b5477c7f1 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 ef2afca6b9..551be14e22 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1087,16 +1087,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 1fdfd91ba4..a32c5f3ab1 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -819,6 +819,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 4420a44c71..c591e249b1 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 Sun Apr 12 00:56:26 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=1771866404; cv=none; d=zohomail.com; s=zohoarc; b=UNJ5/CIvm+4TNGs3VDPRUCrC+ZbmQwUSahs0AbiUnYw5cu4Bkl5jcKFbrF3QdL5LvCL7P40rhGa7SSqA9AbprhVdCKidEmlG+EwalzB7tteHMfZ5fSp4OHMXErY2AHGy9WeYIcnqz/m9k6hG0D/UKzk+TdertI3Vd6BrrQN9pdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866404; 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=2coO5QjLP0oc9KsM/+Txuq5tlHPzzz+22aLdjZKCFt4=; b=bVTKlkunu7hAxboZ/rSW3megAQYq/VCvEnqW9D1GuSEx21jTxNeLu6Oy8K+PWiS82ST3pUrbIrGb0vC8E4JqsDg+KUCrSi9chlEcN83bpklZGNS/u/tcZEmbf9i+1/KNOcxYxw79Pep2vexa+Ns8R/BatAsUBPTfRup3OolFx1c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177186640455081.39807444174596; Mon, 23 Feb 2026 09:06:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKj-0002SE-9J; Mon, 23 Feb 2026 12:02:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKh-0002QS-Rq for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:55 -0500 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 1vuZKg-0000HK-9Z for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:55 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-48371119eacso52939055e9.2 for ; Mon, 23 Feb 2026 09:02:53 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866173; x=1772470973; 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=2coO5QjLP0oc9KsM/+Txuq5tlHPzzz+22aLdjZKCFt4=; b=QwW8NC2Q5ypGAhzcYos7AtqSq7YNYH17WPTX5XN1lECE+Ft9sX2D2W902hOwGWrGHm v8FDek4Nile60ixjoyPOEF/x8osVcUBkWyR17pq/6c2jrUovA+iOMjLRn4HTeewhyr1D O/1YHuoTnTQhoZAHbFqy9KVQDCmafApqFHSX0aTM2c7FPUPKYsT9FUoDfzvvrOT1gBQu ehUA3UXXrMBBo2wRjwolfZj4+gqK2hzIaIIMVPlogiXr5z+VNHJHsokiIOsvQIFh4fFx pVXJFxFguU+0Qt4/ehe9x5jIeXAdRdYNc3qfxWh3uW4vYI/EcrA7ndxzKh08x0khJS9P qpNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866173; x=1772470973; 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=2coO5QjLP0oc9KsM/+Txuq5tlHPzzz+22aLdjZKCFt4=; b=ILMHsK/LrsS44AcxX507yUWqrf9MEbikw3/93zyl4kfnfvi1ZgALF8iDNTGJKmPkEG Y0+1ywOG5EGM4sojispZyaU9jfXiC4IUF4ElgQTqBAcgMe/V2Rt22u6afjV+79pkAxd5 iCAJfRlGNY8UpIjNlTERXMKKYmwOggoKrdG+EdgWHUQ/qZwGmlYVUxcvXXa4DY2fGvqF SyhGW3HwMz26Q1c063gjDRgujDpnIcjs8SE95ocMgXKycHgfzBrZdaeo7OAb1WY14amt Zc8B5ucjbGTmWxsD11odqO6yFlv9oAtJJ1odwiSJnx/0GlFPwEoMdnBYrHRSi5RAIhlN eVRg== X-Forwarded-Encrypted: i=1; AJvYcCUCSPIPSgCyFXri9SNuCBVxiZU8AndjNSxfy2/04pWLh/QPERzESu6me61zc4V/YcGx3LP25Ky9VADJ@nongnu.org X-Gm-Message-State: AOJu0YzttRExnbu3vojiyF3GM4uU1h5v5ia6aPoweoDVjMEdk+vA8V9m frY2Lrn2sHjLhXSxbzS1HzRJeEMf7f2jjk4b6H9FBAF+NuE9AzHTfngfd7ePucMOPXrr+grMkEZ l4X7s X-Gm-Gg: AZuq6aKNb4MJ1QVGFHUXDnObZNbvugsVHEV/cGKzMmlnU54n1MwXH4ianqVSplT8gtP YeYOjXtxoK9X1/F+J6k89nFv82/WwNdTlR5IL6hN9+eTam0h9WooWSdV9IcprcdjmqH2utNQcL3 oVZsk204KoCbyf2KBcb+i80pCC1kWY08jyW2nexTvW62bRD0dBvXrRfCXL3yH1bi+31SPwgiGAj 5ZDtwAXF/maFFt+7Tyeo/mkfjaoYlnFTiWJ5cRnDZRsxXF5EmU12lOzAYp/IG4+eVMMwnpsxYjh yf9LvPBOmkTIqyDCjecMNSl+khAi9BxubxxVOjhc4+FGXHqUkGoj5N8dOA40+KDQTFqWemDUl7h wD9mKHtgHauv9V7Ar657uAPVazudwqRcVjQQkm5ZmNB+S+2FnzCAj//4prFsNhdtR3xcZ/wAiSo cx7Pqu4bWhwDBSNPzJ9nu87VFIvyuy/9YEthw9cpQX8yIfU9kj61M2mbwyTLd2Y0Qw+CmqX8WYh Au9AgA007jllXH1pti/vhobAt/s4KIAnc7irVoFNw== X-Received: by 2002:a05:600c:c166:b0:483:8e67:e696 with SMTP id 5b1f17b1804b1-483a96088eamr162999475e9.15.1771866172677; Mon, 23 Feb 2026 09:02:52 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 34/65] target/arm: GICv5 cpuif: Implement ICC_IDR0_EL1 Date: Mon, 23 Feb 2026 17:01:41 +0000 Message-ID: <20260223170212.441276-35-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866405306158500 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 --- 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 c591e249b1..36d1c196a8 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 Sun Apr 12 00:56:26 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=1771866232; cv=none; d=zohomail.com; s=zohoarc; b=W8gpJaZ7A0Og5Vf6vCSpZ0NWoWGzqHTyGbkJXmrL8z1qIQrSn6gxfqLfi6BCN7NTxjisSGLTuFA1Uj5+fC4Ly/F4LxNAUtuwsrebIORWFeEcJXAq1desEnf5kj9TFWKWGbxGR7zKCswBgXEoxvVh4ywlQljbG1u19KfQJinUwdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866232; 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=/Mw22eOdEKGVrHgSJcdy0DJe9ef4kO7Rp5jrpc0VMn8=; b=iE0jBE5672MYbJ6R/07StQvcHkUzLkDY7CWh9X2heK0SqD9gcft1QDvdsOspDW7a4op72NsHM/bomws5cVMV8ZVKAvy8aB/hrO3z9yAIZGPfYpeDd8AWMSlnOVS3hAttWysl09iUjx/7bAHaOF69uaThpQQK+WmIIrYj9NqbZss= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866232790557.6933097197451; Mon, 23 Feb 2026 09:03:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKk-0002Tq-TJ; Mon, 23 Feb 2026 12:02:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKj-0002S3-2Y for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:57 -0500 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 1vuZKh-0000Hg-Dq for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:56 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-48329eb96a7so26660115e9.3 for ; Mon, 23 Feb 2026 09:02:55 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866174; x=1772470974; 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=/Mw22eOdEKGVrHgSJcdy0DJe9ef4kO7Rp5jrpc0VMn8=; b=qJADO7yvPw292zSD2Jkki4HHi5KIPUwQBhKxqg/tgZCsWlU7AkxDFc0X5Ygu8/6+nI YXgoUWDNb+UtCi8BTNvuv8q2Cx754s0F3wL6aNWOgaNiaLHbPGGsbVBptDXq9CPAb/DW CflsoIAZNOFPv+YCzdZPwRcfqMZN7A+Vp30CXTod8poK/DF9QaU15ysx6IZuTcipZJNQ mw1SnSoemNDke9RGey4JIsyDogkMjnxoTzpHFyUJ7txo7wfpezsPawThgpTyZwJqXiNG 4OzpNwH2xqefj3XNSLi49E2RdajjuLZPnf+xWySwypWrEIsux/Cp+x8SzcKcgOgtz4T3 iXiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866174; x=1772470974; 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=/Mw22eOdEKGVrHgSJcdy0DJe9ef4kO7Rp5jrpc0VMn8=; b=YEQNCL7Yh9nAIK4KoCbkYlH7g/slW11ZWb/4jsuqvRySugRqmjjIF95tIVYphcYAb6 nh1zJeBSFy6+YqmKTWOvmwxLB2mwsh3mRJ5PwFu4pczh0a/cTwmlySzo7mC61ajoOV3V /oTMKjWhutz/e2yOXXjd5TbovEgX7PektsZdo2h9oPxWjoi1vPQs1VtI0DFBekJ7prWJ vJUJsEMaVGWvmjocLY1niRfyq5P42kvtm0jVv4TIt94MshiW34vTdMT5WA62bqVLvya/ rQCnEfeg3g3ClQ0UmnEDnjA85CYzsKqqPmpOyYgwOvbcEHbAQ57kSpi4eZYSbjQuObrY +krg== X-Forwarded-Encrypted: i=1; AJvYcCWpC1skLeZgKzDrq5k4el4r+jVySMZiSxTb+rEYvvRnlZB2HTzVfYeIO1BKAbKY1kEUutFr1PXnXe5c@nongnu.org X-Gm-Message-State: AOJu0YxYRZqxyqMyvCVPaGbMpo6fT0haEHlRry/YQW6QHMDg+R07slpG xkBqrZ9FSdqsJesmbHEPCJY4rdecdmRYw2Ev5yKGZWvgY6XtvmBEx0xAGid0s5mbZZ4= X-Gm-Gg: AZuq6aL+Yk3F0WO89XOXQtG+RZfrcXjedAt2bCEIPNlt8RrT+yG2OYUEQgyByu2Y9vU N+k/oqGdudb0SymB9g2J1S3ps/Uk/oEaEN6BCgjRTwXxTCjqaBfdV9vbozWINH2ve9BxVYWEGA/ bxgYtRaQ46gJQ4S3NsHJwMqe3HjZkfcKOwvGbqQlXTjXPXfBX+PYvHgUy+6XcRvvibZPCrl7OWj 0qjqxMOGmq5xqKxT5qRvC0UG9KlOJToHxJ0hw0ddzKq8x14n84iiOzSXU3nN/FdsiSGeEf9b9OT zggZL1r7bi+lgSymot+5iAWAbpGCS2FxdT1p+6w2XuB0b/YkFETn7pcuSdk6c/s/vJ/BO9Hyv9G +XOU1m9VMe4at0xcXk9BgEUottxTrkPsQp1qp9AwZBzIYLfLE2ev/CbffIyWVuYcnKELQE8gOAa NgG733pfDfEjblISoZt/HWemGEenNwlYs8PuC9QE/G5W81JIlKmGrSt4P7aq0K62U1jSmoCdpC0 t9nNZG/EM328enFVWGKzG/vdBo9zrLc4dE14eOxLA== X-Received: by 2002:a05:600c:1c22:b0:483:79ad:f3b9 with SMTP id 5b1f17b1804b1-483a95eada4mr163288105e9.28.1771866173689; Mon, 23 Feb 2026 09:02:53 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 35/65] target/arm: GICv5 cpuif: Implement GICv5 PPI active set/clear registers Date: Mon, 23 Feb 2026 17:01:42 +0000 Message-ID: <20260223170212.441276-36-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866234243158500 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 --- 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 a32c5f3ab1..dd4dc12feb 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -257,6 +257,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]; @@ -600,6 +603,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 36d1c196a8..0132b13853 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 Sun Apr 12 00:56:26 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=1771866634; cv=none; d=zohomail.com; s=zohoarc; b=Rjm60hG84r6JrBzJ9K/jTMAqtUHFOKxnSUqxy70xUlQSPu9rPU+ANW7XKiZZ/yGW37TZFG0k46RVG3otksRSTwegiI13NXVHQrm1HNttbkEvKNUqgQ97LQvgwbdYyAbSonb0VmOYlMRm5ax4f4TZAUJZOEjjveRxEbyxj6kUD+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866634; 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=+BKZSnMQQmK+RzmCczuCw9qZHXksHwgTCftkHrZV+kE=; b=ZRErSYoE6hLksKMZGQuzKXsFvNCoUiwcLNjv/fid/+PXJMLgzhgxxWXs79+pboLxV0eYYGBpAlMrU5cbCBrnj646Pf5mHXAZRPMJ8Zm40GepUCl+VwUfvSbywuT5v4ITXfH9oioQNqHsZsUAjvrim5i41xPdno/AZ2XbDl+rIug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866634520897.213014463162; Mon, 23 Feb 2026 09:10:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKm-0002VS-Ac; Mon, 23 Feb 2026 12:03:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKj-0002SY-VA for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:57 -0500 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 1vuZKi-0000IC-BU for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:57 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-48069a48629so47256025e9.0 for ; Mon, 23 Feb 2026 09:02:55 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866175; x=1772470975; 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=+BKZSnMQQmK+RzmCczuCw9qZHXksHwgTCftkHrZV+kE=; b=K1JgSGymOW7RkBdVRyL3QXnDUA8RCEjUkJIfiYFa4zEuFRgUuUKsFscC5FVvK/NkVT +n7rKvSlTDBXIRhYauoBgf3F5nmKU7GIVzEiYe0zpm0csU3b8YEoflA/8bj7JoFX+q3J ot6lE4WYNZagc7izLHKFZcFUSjcBHi26qL9lcZl8XI/lgZKwY9nGdZdJEnlS6gTyiUhb /KyHDgFgfylzY6dz1w+cBkHlGYYg1B7FRQyK4d/7v50Y/r+TpavXMnCT/FOzt5VYVPPx THqu6oowIX9h08UOKaREdTFDlpeBRm0yXFFaeRlIcRDfPINMpzYtMahrVQTHWDrTeyw/ xGeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866175; x=1772470975; 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=+BKZSnMQQmK+RzmCczuCw9qZHXksHwgTCftkHrZV+kE=; b=OXXwVnupEfr5wnlRkAbDqRUQl5ZZz/qZALNXOzJvnqcdWevOpCzwvsltQ1s0voiwMW WgoAxRkFuquvr+Ptp1Bj7DjhwSylJ8VWVDveGI+ukzv/qrO2GVfqJ6N/syKaYq411LmN JZD9IF/BFUq4/1hZT0RfAIJc6MSVjUS3qEcMWqvryLUEBhdiljnrUneeKBJJbN2O9wdf XzURE0raD2+VJRIUq/NuMOzzt5hew9eCEba5BJpbr7NPDUgpw+kTLxgEr+YkLxLIynCb OJt/uTsJ8yEgMzTpQ35m8sV/zzYa8JX/eqB8amOEprpVEOmyKcW3/5cENEMdO4D+4rfx kekA== X-Forwarded-Encrypted: i=1; AJvYcCUG1+qSVVY9yTJ/8eGTYgG0z3SiumjFMRJPTpzJvYY0bN2kd+JyP0p9YqzfkdThbBs0C8/AiYr0MvRE@nongnu.org X-Gm-Message-State: AOJu0YyasUp3VkgAtd3PKfE3efSGW1TelFghC6iqPiIblQ0KOyXmt8Is 7Evp4qYdB7jiepEY5j8oUFtOh00Il1NOL7f3gM9shNJfr4nW4lrJWyC7fZQlj89ArJn0+drkyco CyqvG X-Gm-Gg: AZuq6aLAKXNH7sDLHMhgaU8GH009KcsQFJbwgSt9AkjrCQdK0as+S+IN0OkHNbZbE5b L3UaBsW9op4W/SuKuWa+QT1nrd/PxZqWaMnexMk8eXS8+f7KWFCPsGjZ0iWG44iS3OnNTUlwNZE ODUEKKhqoF2gRh2kr+VUpXRZKJy4LgGltVmzA49XgzyC5+8TOu79giBwS3YM+nEERCb8j494guS nk6Peakx27xvyoqWczTUAUxDXu0m5rY3UdTQHsj1PjOUolVXPv3tyIpuBRdppBjkl0n6AZ6DXu0 TIGmRiDMRInApkKBGBTURsNTIWmZsqMRBxDiLnA8HcIwTeDYTDdrhnHgzFTjBp8zlXsnXlwUrEZ v84qTui6TF4eePr7UBpMW+ln0Z7eegQ3DRRgzJPZcSI2Qk5DmgzsZFEEmQRr33bbpVag5yF79x1 44zjNKJd1WlIKOU0Oqd9pLl1apyE9tJ+iX4BhF1dhADPXfLT0BYiFfVZkaeC7Va9M2BEuAA1Aq1 T5D6tBes/S0Xs8nxLXFZvMDLyJwYxY= X-Received: by 2002:a05:600c:1e28:b0:477:5af7:6fa with SMTP id 5b1f17b1804b1-483a95fe96bmr132780755e9.32.1771866174849; Mon, 23 Feb 2026 09:02:54 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 36/65] target/arm: GICv5 cpuif: Implement PPI handling mode register Date: Mon, 23 Feb 2026 17:01:43 +0000 Message-ID: <20260223170212.441276-37-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -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: 1771866636696158500 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 --- 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 dd4dc12feb..4574f7005d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -605,6 +605,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 0132b13853..6fbc962131 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 Sun Apr 12 00:56:26 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=1771866647; cv=none; d=zohomail.com; s=zohoarc; b=l9itxjB8/2lA1ldlm9WupjPeBkWbF24aDfiX9buPwRydQ9vdlVaGn1eg/DmkafM+KNnoP3dNmsK8KCYHCqpxBZzS1NTl8LwvzUlec6WQ3oxWBloLcPBF4vbCs0ol7Y6NO8sRxcGE/ciCBcYu7M5HUYtr3yT95FFfZGHsjTEE6tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866647; 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=HXAErUH26qog8NLwcGHpVWf2yib3kbn8Xkw9zUFi3XE=; b=TjZKXJR57YKPjeNDCiKuaZKWijci8/TIh+T8U6ubFoLVmAHk/BUlfwFHK5YSseOsj0EBTbiaz8pLnQ9AZXvfbQgtRX/qg18XLOpQfSLGzT69mlLAzTFOBvUVuEyVZg11/YMoGvrKCXLYTtkpbEXY8zmGlvL8jDf/iBvfKOT6RCs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866647970396.4616050673967; Mon, 23 Feb 2026 09:10:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKn-0002Wo-9w; Mon, 23 Feb 2026 12:03:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKl-0002UF-C6 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:59 -0500 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 1vuZKj-0000Ii-OF for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:02:59 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-48336a6e932so28245685e9.3 for ; Mon, 23 Feb 2026 09:02:57 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866176; x=1772470976; 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=HXAErUH26qog8NLwcGHpVWf2yib3kbn8Xkw9zUFi3XE=; b=n1BRVyzd3r3M5hMt0jlbZhSHfWAmwO4q6UUzNbtc9tG2x5HYPVE0ac7WMoak8qvcTg tgwi/t1zCct7Eom1vGNnKXIZpZavqTn+8yJWDrkKC5+rXc/2E8vXwzzYlcQFej6yq0tf Gd/xNLeF/J7GnRSNPYCexQQmLMP3bt2DPNQ1ZLLHxeDsoCNeE6qyNI0acSP5K+Zkn+YG yTArkkzdLdhpDrXsua3hUz773Uu8B/ARAYdDjN7MrKd8Ew9M45NzBZFvlwMkYe59UlI/ f+PS0pAQqVr50l38IwaV/aGkLrPnctlW+dYp+kAnWGxcrETN4fwe8v4DAfDC9JbwWfyy 73aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866176; x=1772470976; 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=HXAErUH26qog8NLwcGHpVWf2yib3kbn8Xkw9zUFi3XE=; b=dH0jNJ+H1ky2PcgdePmHicTVvYNUrMnt6M++0eqps0HifNNNX6NB8/nhatV38qKTW4 u97WyXeFQhgutE4P0Wb7k/HW7YTH05fZ9vQQD1XnAogk155TnJPw/5qbrlaf1fzhiRCw KtsMlN6ZF8NTzCgMAYtqDqROqqOSY2d5coH+ISlCRh4PfxeyIHkBbX+q8qd+qcEvppCH 7TyZGZ0/VSgllyTqxqbiZ2CtfuqgqFaXl42zGKUiCHia7k9HYiUAb4lCJOXyoh4PE8sF DBRAmPGvLQAbqqDevMKXptbD0/CWcHEyT3FxG8HTKmiemem/ONJ+QT66OJFHyDPoP0WQ w0Ig== X-Forwarded-Encrypted: i=1; AJvYcCW3x14YApvrUtm1jA1W8Clnm/0+HPTbw/Wsgr45/QYVNPR+fgxCgW4RDAR8QopqdsO4f7MYyc8ZuY9f@nongnu.org X-Gm-Message-State: AOJu0Ywqvcva64IsnQRoWK5bJjbM8yqS6qtDJsntH/TrUmeT9t3Qgeku d0Tb0TVNrRp0NB9WpwO5mHjP7zHZcFAVaQpdf+bBeLnYhX60p4Gmqsh+q8VTN+Ec5I7RxngxlHQ KNOCp X-Gm-Gg: AZuq6aIIn5dIVDJep6twpI0F3vcqjzI4Wd6zg9CBhMyoJ80ay13Kz+WOMvJdzQA1VDo M8TmEFF5ntt9TNujTnp3VEnOl2a0Om2pUkVhGdYF2MGfD6NGA6zbpqLX0K3rCF0fHMuG0sTWcL+ 1XC6NTdNkmM/kZHqifzp+ey5rdXdAoY2h0gsnTvIIdcQ16Gd72XfbebmmFxYEwan81YyrpsOTuF wdgVx5haZP5vsh2/o0nnY1YmD51S7vKQxgzprxBlrvgxEClz3WHpQ2KVvFlgA6TI9IMXC7Q3aaU OGuu7aWSHvCwu9vxspdslpbiXbpkzwGCHueWuAqiUmUhF1nehEEf6KJ+cesC4v2MrguSmESrTPw R3tYeSOpiw0HRtFZVSKrRU0DUgWRroZwz1sBVN7TVA+IXj4eZDNfGpptsGaumqNqB8l7Q5B0/iI K+R/OofLTg2fy8byj+sTLJ9ElXOKNtTP1DdIMOivIXzOSgK9NeFgpXjOTwiLjvrB7Zg/9L2uuvA dw5jnava5zdK+OW9UNroXEV/GGy5wI= X-Received: by 2002:a05:600c:3106:b0:483:afbb:a077 with SMTP id 5b1f17b1804b1-483afbba2afmr85773125e9.1.1771866176102; Mon, 23 Feb 2026 09:02:56 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 37/65] target/arm: GICv5 cpuif: Implement PPI pending status registers Date: Mon, 23 Feb 2026 17:01:44 +0000 Message-ID: <20260223170212.441276-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866648796158501 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 --- 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 4574f7005d..980abda3ca 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -606,6 +606,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 6fbc962131..4647fd40ba 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 Sun Apr 12 00:56:26 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=1771866716; cv=none; d=zohomail.com; s=zohoarc; b=K/mgNOLXYV6X7CQGr3pskbnGO+e8KJDx2h83qr5neTuyVUMwvalxX/nyQWmkmXgcYbAvAVOpT5qJJEDXX93knVDmUMuqJ8c9SVhZUUfAOLIazpjcGKRfbtKErutNcZPRf5PZcG2AvIK8IIGF2BXu8ugz3XP8BKSUF69fhYG7MJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866716; 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=d/expR217T5l2ZpgIxw9igXVO7ZIf/mmczK8CZEhS9Q=; b=Fh+pYQZIl1PqFPx3mdzTo+cfnJTclTYmSWsu8mkOIPPzmf60X8Wly6gw3XrvMeDONcCXuEfcs79R9+FZNyPFtxWgN4EoVA5hE2MP/aCTlD5U9ij7qoFPAwzshnrPdQrjHuaXFIDmj0e2PLJeOz2AuNVSjKR8SWN3298BhAi5xfA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866716520667.3855322914994; Mon, 23 Feb 2026 09:11:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKn-0002Wr-Ty; Mon, 23 Feb 2026 12:03:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKm-0002VT-BF for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:00 -0500 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 1vuZKk-0000JH-Ob for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:00 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4837634de51so20466095e9.1 for ; Mon, 23 Feb 2026 09:02:58 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866177; x=1772470977; 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=d/expR217T5l2ZpgIxw9igXVO7ZIf/mmczK8CZEhS9Q=; b=o2lWedMp5lMZpGjfZiKeFAMyr1kg+DTWcmp2R9F7sw27aEUXGUnAw9mCujtyAq5weX URv+YNSKCRoPDUkZIrh1XZiGqinTASul7Q4XoGDdr/i4YFBYG+1iV1QIfm+2+NXIZWtI wn719pv+nD6Bae8Bx6zn221fpeUXxDLVnJEVpPj8xzs5He7uNGpNJ2clcM6r9Y+fhV7i SbETqLbqJhpWev4qm42prIC6oK9j2x4G79oXru0UBNJzWzcCpVUzMOKx9ZIbP5HnGsuL zvRhRc5A8hQBU64NDp+O2ohMDANTqTqSGX8aYF/I8LpKI8ZqFrZ7zbdKpR+Dt3dtvOA4 aYmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866177; x=1772470977; 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=d/expR217T5l2ZpgIxw9igXVO7ZIf/mmczK8CZEhS9Q=; b=RQ4SwYOihbF/TxWbeBF3D0EK9oxKmw8Ok1yrUBmHpAxLb4qShdPL5rHTfXiHE3Y6sh JJ+t4XNI0m3FmxFxhA9lD86tE8F8Li6jmgFui014DZ/g4EknNcrYfMfDydlaKl//bI1V tEHEZkTiQ2jmAIiBHzo+loNZ+mNVraxe2KPXVtH9uOzRDUleRULDxHiMb3K1tq6MgAOw /254TBI2yYAnxcLOSKpAaxHzGNM0ZsnrrPLVjjXdnABYM8U/y/lqUuR/pX80BPuRQUJk kFfhomQe3ktT7ADgdlb4GmBhJOKfqDIJ1EOeJmGyOGtUzf2kAZ8y+l+kJV6XXDDkj0Jt Fcig== X-Forwarded-Encrypted: i=1; AJvYcCXW+sByiVCI7n2uqPhnC9mL60IFGUCU6jVFrMX1jwsePo8CD9u10Px4gOlixha/f9OzE6MYpLobULVr@nongnu.org X-Gm-Message-State: AOJu0YyyzM0iAZbHq00nNE0KOLKRkF1Eib+IGovuzf610VAG0/IWDdTL DIr/+QIO6VJv3tYjN4PezgMiOUJDrtGoNjUuS/hq+pOVopBelMnqoHLBt/sixQ4aQnM= X-Gm-Gg: AZuq6aKYiLMjbuFd7WE494h47MQ9qfm1mgR1vWhMiDNX+n4hzllvp1xpgH/LX6PrkZD WaDImFa4KjWiBpo7rlx1j8+pNhxtUzeAORmjAX931zz6gUZ+DB5idOeqUskT9UVb1x4eSGuPBZn ifo/cTCEt2Aq0JCVHJtjYGOAVUCvnLtvJyq23M+3rIgL3juPjBeiYYstvcE2HN6jaWuA27/Cgvz Huu9nXvrv/9U5LpftjFoagaNj/k1+pCUMONYWcjBcWJ2EVndqjQLlghrptr89PnEnytoTCBbY4y BPctQ8amHKLKvz/fIujc9omhVeoQXTyHLtlyow8rar6MYuuW/JnaJq/XTWbz55RchzQQzMZhh6F cODLimfaSzDwRK0BPJnGQYvZ78RrmTg25Ue023WnVGSs/lm67rke6Lmzesb1OWKv53LKkLsrbFv HuppQNbJvvAl5KSw5UpaS3lYhTGk9hJaHtOUqZlIqwD69x0UXxdJL9bU1JdpIREswKlbNmsKPP1 XL+GXS1d0pP6d7+S9vzmL0fedS2+V8= X-Received: by 2002:a05:600c:6217:b0:471:14af:c715 with SMTP id 5b1f17b1804b1-483a95eb550mr137670155e9.3.1771866177201; Mon, 23 Feb 2026 09:02:57 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 38/65] target/arm: GICv5 cpuif: Implement PPI enable register Date: Mon, 23 Feb 2026 17:01:45 +0000 Message-ID: <20260223170212.441276-39-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866717163158500 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 --- 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 980abda3ca..915a225f8e 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -607,6 +607,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 4647fd40ba..c54e784dc4 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 Sun Apr 12 00:56:26 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=1771866813; cv=none; d=zohomail.com; s=zohoarc; b=kOs03rR4wUu3h7UzzgJOd31GeIeN49oxBNT1tYFfPw1XQC14wsvDikCLD9qteSMvZvWCWoQTowG1vXNMpTrqoF4H6fovTvk0D5F+Hxx5rskQIdgIsKy2V99CecjXRuMGKKPP6HQ3lJjpiS6+u4CSI21qHDw/2l+E+4dhyprM2Yk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866813; 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=dBwNvGbCOD54Qlf9QuiSd9BdBjRvsnVDp48/gZ6uiLM=; b=FCItpxiTjZAebMOrJ4gB0D7V5qjlt54yca8iWDUdIkHJ1o2NQ0Zb8GM7sZgESf9DVmmFP5+XKmkvbW1C+6sgG1EdQRRuCvBrpv6+YSd+cDL1VH3kY1kzVTEC/L2v6tFmrSn0C3rj5G7LwTqnbJhwGUexLiRccJl0deJngapEHFU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866813696563.9779472484363; Mon, 23 Feb 2026 09:13:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZKq-0002Z2-HH; Mon, 23 Feb 2026 12:03:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKo-0002X3-1j for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:02 -0500 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 1vuZKm-0000Jz-D0 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:01 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4836f4cbe0bso34587655e9.3 for ; Mon, 23 Feb 2026 09:03:00 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866179; x=1772470979; 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=dBwNvGbCOD54Qlf9QuiSd9BdBjRvsnVDp48/gZ6uiLM=; b=pwXlsR79QEYIBIQUZ0lY5VeZoVYy6/UlHIaTQxyyowiyiwiafTd/Mx3GCDGPMIoKvv xTsuYNL61HSRLhIj9e2Cn+bkwynNTTghgGxDAZyIg1kzxGa2BCGq52EsAPm50NkCX4R/ zErqfIINkLdVs3xRKoHRWZH0I1BJ7TlPNhDNV0NhjDqBTZQ/Tvixb3bVXTe1N50i8nSx /udrb+LijrGlCTb4fSTg0FbgJxGpXAzTdC1xcQEJkrVfyQTan3co5tKK0Bj73+CEOTt3 Fet4QwTM69AhJmKgVqRX25qTvlahu8zQ1IvfOT/XDO3LOBJ3EvMzfm/OVTtv8Giv1/6W VxeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866179; x=1772470979; 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=dBwNvGbCOD54Qlf9QuiSd9BdBjRvsnVDp48/gZ6uiLM=; b=FpVKGAQVkgK94LQbwNA4LhL4trwhh3BF+emJc6mitkW0vLQYVB9+u7SSu2bMTCiGav FFt6hpMdGnhrMj9moZl45bAPPkQO2NFFu1IfXjDCVi/OE76TY8e/7jiPnJSwksa5+DHn fEExInIKOnHOV+R40nVXweqs8MdE9Br9h3gq0qXmitxRFZu11eqaJMXEaY4kUj4TlwFk +vq7bs/L8YFxTBRfySrnjflNSMYjnEogFBYTbdrP4cU7Is2YFw3BBkAVqkjsUb50zxon Eju0VM5IUKASYBcNw3CWDm2fYGdBKSdgwQJ0UnsRyu+QfPxZu5ojhT8A1tChYhMc5iKt STaQ== X-Forwarded-Encrypted: i=1; AJvYcCUArSKbNkkWpC2ewBh8THTS7QS0RkXp6acfyH1b/0fJhZYYL+2zx7hRDusf3RrFTbrgMVDbiJubnmb6@nongnu.org X-Gm-Message-State: AOJu0YyxnyQoW1A5xXIIoyRWPKzzJ5wD+bOWGuSwK1O7gbGNlqfnP2LB 7YP+ZcW7Sh/MGOOHuYmQpN8kppwT1otwUH9B6DapQDjdTX6yyG6lkSJaapaZVbLzLhU= X-Gm-Gg: AZuq6aKMUnYWqZUqBeAQqIj0Wag1A//2DAZiWBcA8AfcY0hIyCudNqdamdXyU6kx7ub KAtgWbfzqKRgDbvORhCx26OrO5lyRZg+0QAN/B+BKZqvZ5OnDxrvHrZIgeiTtsfWkY21ecwvGpQ Q6iCdhh6ZxT779ABHqg7pE/RRB27Vj9C7MTYLdzjQ1Jd0NPr7AoDxj9rFNm9QLKYFT2WsQU/j9s 85HcAm8mO+MHSp6LEOQpln02pXFnrxlFa01S38Saw83eeXtBsx9xmDR3vczL80GzAyIQTvoitST KEjZI/Mim4eKcMmhlNXrXYaNLYeLFR+Rft5+aGpAbsq5WvpYRMyoGlV88h2ql2sHqW79gLe21Z5 H0bCSbprIhqnfqizkT6FKcmi3GVF7WAcHc0mQDFaqDhhYay27+ckiafLZaJU1VGOleRs2zMVar1 tN+PJI7a5ubhqsJRQrqHNLx32sCdygsVY3IXRT2CEhOELsSzEe8hLxVcRORdloeu+jwA/bXhT3u eF/eX/KehvNndKj+QvXvnBKIOYPZR4= X-Received: by 2002:a05:600c:a00d:b0:480:690e:f14a with SMTP id 5b1f17b1804b1-483a95bf2f3mr162437875e9.14.1771866178908; Mon, 23 Feb 2026 09:02:58 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 39/65] target/arm: GICv5 cpuif: Implement PPI priority registers Date: Mon, 23 Feb 2026 17:01:46 +0000 Message-ID: <20260223170212.441276-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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, 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: 1771866815700158500 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 --- 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 915a225f8e..b97f659352 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -608,6 +608,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 c54e784dc4..60b495dd8f 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 Sun Apr 12 00:56:26 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=1771866304; cv=none; d=zohomail.com; s=zohoarc; b=MB1mSOXisFG9xCnaCH19SsNl0y7vPNny1/ClPE92qw+d7OvHzUSAq1Rbrh5RtM/y9CbIUJtCrl1tQ8ebXClPMZowYs0/r3cfC5zYk+88WWo2WYT+0ysm7V659Q/zhbHcHAJ9/In70T1leDxOs4E6FI+a2vw3WiRkL2BEjDx1pKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866304; 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=AM/OI0jKVabZ0iq/CmOwmnbVdkGhhSHtAdP0sBiCNp4=; b=bBtRI/50qEUsUj2aYvxVLMQ8BajcnwqOk2up1kD8JTxbtuMWL0ZHMj2KVQrTpwcDIhKfCiYiv6Xy5xJSGgbXeOw7CWrclKnCagrziDqtUz84n7Xtcr2SJ2/J4N+jFz7vCNXc7G/7R0FjBrekiCxODrAIUuVM4qH3idNOvZK4r2I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866304059205.0927012988675; Mon, 23 Feb 2026 09:05:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZL3-0002dc-Uu; Mon, 23 Feb 2026 12:03:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKp-0002YK-Mt for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:03 -0500 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 1vuZKn-0000KR-LZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:03 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-48375f10628so29379235e9.1 for ; Mon, 23 Feb 2026 09:03:01 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:02:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866180; x=1772470980; 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=AM/OI0jKVabZ0iq/CmOwmnbVdkGhhSHtAdP0sBiCNp4=; b=guECjS2X6yMGeGLohKhf+b6NxnJvmdwJB4MN8z9JGpJUIMUOEHhsPCvbsVtlZOgiY6 UlXnsjjbjSb+NRyJPHucai4fLaNJuKN/vO2gAhi8P+sM+9r8hmfjkJ1U05sp33wkj1qS /7cTXyJ3n6kNgZaXNw7E4bK9J+UG6ZY1HaVwicJxid+r9YpGKSdxNIr9hZlnlRl5YOrH 8CPvpoG0l1tOEMpre5ffpcrZZX3i1iddOvrSjJzCMo5YxtZnUxUErRdUVWvR2qvuFeSh V3ysXDh1fehBY99FyDmNbBlY7JEd7WqyZBPNlLDkFxsAj+Kpw8E/xEYedGBZS/olTCsM CYeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866180; x=1772470980; 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=AM/OI0jKVabZ0iq/CmOwmnbVdkGhhSHtAdP0sBiCNp4=; b=wbLtnv++DtFt9Lis2Exbcf2At2f+6I1AKCS84Wy/U7Y+ktiaCBm5hJ1hMVRWO6ds8v 7W76f4DgquLS7OgXl4QYLBUQ5TGxwIg/sbvNh/AyAX7JTJ2UbxR7kfEwcFxNH/2tda3I St9DAuqDtGtCE4rkmWo6yKlhS0qUz086/VrDea7XTLKEj/ib/dD6Ht2Lboj6HvZ19tbZ RnfV785JDyjptj19fmBRLumcs4udOnWab0YhIFovTxSoVSobiT6VQyk2W8VebjaSPtn6 eDNdUgQ1z+vERvFxFH714be3fQMX+UbyKvL7wTHNgIrqQLTLq74WJRdfkbYIGUByvo1n D59w== X-Forwarded-Encrypted: i=1; AJvYcCUsPn4/fs4tllYuQpDn1W/aeg7p58x1PW1gPg64aUaOLguGEwi2J2Hjv2N0/OkpmLB6dgOAPPCWIZ+0@nongnu.org X-Gm-Message-State: AOJu0YxDgW15jfEoe5r9M3WF/yFeQmMcPohTM6gSJR6yddsKndMtIzPo Rz2wf5lOnHLOKluLXjj49q1PBtQBB3NlPOUnxkTzeisZUK+ZL4rkaMlYMi5cSOfCpuA= X-Gm-Gg: AZuq6aL0lQ40nYqGUA/AhJZSwctoOTOayARju4ghRQWFLiVy7SBUqFU/iCPdUzalkqB +i+l1B+pE2gUkpKJjxysx4Uh6fTiJAWC7GONty0eV5rsSIaQr5VBtCvBeKYUhch7LOpLj2ifdx9 +1+wT5qcKFyqoo4Fbbls2CVmLdFz71N9WaUR2FsQV5n9UBtubrZc4u+x9TACpUGJT2G6WvU3i4T bSH0qtMcStwJ2hfEDVNRQZ3tSK9hjpW8jPtO10SRw3vXAVn5bMX+4Oz4bdgTut0Zg9CN7ElmqIm qw6JinzI7wpPCemth2oF9wzVgNqlkaUxAK5BmaHeKfVpJtCNvJXEeF7e/E+0mL8rt5U+Ci4xdei 4EZiSrr4DWZB4NkPlLPgYh/Rb7JsCrgKZQ3cYWsbsAY1vT+vFC2FZAxY38wa4qqZsB+dvDfHAr/ huZzg8i0+U0kSs66TaDhsrqkdUdaG5T/qibhB5gxv/eOtD5ErzXqdxxTzlH3R0LjF5woaQFe4YO z0wMPmI2Dhhhgi2Dx1Ajyb1TCsVdew= X-Received: by 2002:a05:600c:3b0a:b0:480:4ae2:def1 with SMTP id 5b1f17b1804b1-483a95be7c9mr180018785e9.13.1771866180089; Mon, 23 Feb 2026 09:03:00 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 40/65] target/arm: GICv5 cpuif: Implement ICC_APR_EL1 and ICC_HAPR_EL1 Date: Mon, 23 Feb 2026 17:01:47 +0000 Message-ID: <20260223170212.441276-41-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866323741158500 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 --- 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 30e1bc58cb..b69ad137aa 100644 --- a/include/hw/intc/arm_gicv5_types.h +++ b/include/hw/intc/arm_gicv5_types.h @@ -85,4 +85,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 b97f659352..6841b6748f 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -35,6 +35,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 */ @@ -603,6 +604,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 60b495dd8f..d0521ce7fd 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 Sun Apr 12 00:56:26 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=1771866494; cv=none; d=zohomail.com; s=zohoarc; b=ZC7gOKUezq6Rs9/X2Ob2LdhI55J5s2oipzVNyXYra5rCMvcBMO/8Oots1VurSwj514YfQ2hGp84FqK5Q5MxzIM6GEY1TbCl2gi69AsfE8beSAPTvBbMmSku3bKkhuKhsU2RHtsaf22usuLV9VSOCEFqeqbT7UDwWX5sE1kEgQrI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866494; 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=uf0z29WMtG/mt6ISfZ3ohk7fvcxH24A5mMic2WNxUsI=; b=E/eegEVGcee+m4K8Jj0eiSCXBpdRzJtrY06HAKW1JhNRsq+DSLVXVD+zDN5VBHnlm5Nj8rqZt4dt7YOel2kvQ9FYATG9Mv1v0rS4tnuaoU2OsMcmUb71axzjFlBD7Tsq/N+ZU3KDfqATBInlQNLb72yXGYFMS9Vo03egT/Q1T8s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866494311457.66366157640834; Mon, 23 Feb 2026 09:08:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZLa-00030g-KP; Mon, 23 Feb 2026 12:03:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKr-0002aD-1M for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:05 -0500 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 1vuZKo-0000Kd-LC for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:04 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4836f4cbe0bso34588105e9.3 for ; Mon, 23 Feb 2026 09:03:02 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866181; x=1772470981; 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=uf0z29WMtG/mt6ISfZ3ohk7fvcxH24A5mMic2WNxUsI=; b=OvGqPGZPpv0MEYDXE5SCt++tHL3F3J7Ze7ibQdnWmGYbUNdG5eJq+mLyHXBBcb7unv 0YLkkvUxQh+2t3PLWg9BZFms/4e6yh+1pjlihJ3bAldM7P3k+cAAntyCPn8sQLuG9DRj Ku8FZljvGcoR5QF/bZm9QJxBH3VwrCDeVSOsKpxMYXDcD85L7yxGqKDr8VyHIJPqLnew Oj81WY8+xmuCPIQmQbtyxu8jrdnQSYD1YRD2QeMfZ+SMERKRY0gIlIgonYh/kK4PGb3s guV6BDsR302aR7ThWTb6CjaeqeunZfiEHw7SHbrRDq8Gobmlr7m8gg0nvbkMiOycOQ4V m/Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866181; x=1772470981; 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=uf0z29WMtG/mt6ISfZ3ohk7fvcxH24A5mMic2WNxUsI=; b=KWs3A8iutes0uqqWCH+gIvcuerP7kbWJIul44hU5K8ulh9E+VYwTLy60QLjo1Tb3sB sNfwMHa7U1Nx/T1LwpMuqpGHGNT9v8yVYCppZbJjLwgTuzhWIhVn5Mo5LpSXGR2hA/1i 2rjfK6MkO7ow9Boxgn4atRU8vqpTjoVE7PzH+8kTMy0L47liODObDk8YCgW0IlY6lmkn QOfTKd+isKb2Fcy3J3S7sV/ZKgJEb/6WhfHONPPkRJ7deZox1+T2vz0oPbsvdqmOCZBK GfN+q80cduStHyf8fZhzEx01hMwRDsY5Toka5N3rhVHah0ID2wy4p+QGNn4Lpl8Tmu+4 Gl1Q== X-Forwarded-Encrypted: i=1; AJvYcCX9id+7J3Qa9lz8KTibTd7W0JkQba1ZcVKQN1gjC6BtZDWg6AQISufEFIZTJobcu4AIVmzyCyz5Omd6@nongnu.org X-Gm-Message-State: AOJu0YwTtRKpA02WJ3RqTNadisXHaAhh4XdzODs63++rI9eMuQModsdc MqncCPTAMDAtPVr5PklLdTIx3ay1+y4RtoausvM3mO77nKIcgcAN0cvMZo0d8tTAM24= X-Gm-Gg: AZuq6aLN82Gg4F4oFEJELiOPQNTILPD56E/3/uO24BEoLhJszam90K5/i31xN6KddBn QeokzaKqzjDBo8leAeynKxMhbexLSrl5T5QO3+UcdojRH1KAUVxCZmhTuqrZcNy0QMWQD7sGHxN 7NYanCVldiavHWc0qANQeR/sgHrYVBabyh8nDWFAwQNkKOWa/bSFm2EJRvLQ2tj0A0ywL/0Pvzb aa6i/EvL2zJ7tqsvrEeM8WVgI4txhvRMPBZCN3AXR4rDWY7J+0aobEfNIa9xTB6om8oEwtMFkMw C93vePH4S4FaKpJ9kSZRtWdqNgZqMEoA1ZayA3hFjiiZkolL+phXo4Q+82lwwfDDffyQuVz/yFG v9QC4qtJ1SdbfsPTfe33AUKmMOCVAAij3m5iaZwUcvwy3EhgOOfyPBNK4WAbqN+wYvJTOgW8FkE /FfRezbUDXzuuVSH0v9FUFuaE7ZFWo+lPQMJfCmYnWWuyWkLJ/U+l5zovbimakzMtIgiUxekDu+ IjKapjm3VJ54fkv0ttxWZ+Ez5fbcuM= X-Received: by 2002:a05:600c:6291:b0:47a:7fdd:2906 with SMTP id 5b1f17b1804b1-483a95b7157mr164235445e9.12.1771866181091; Mon, 23 Feb 2026 09:03:01 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 41/65] target/arm: GICv5 cpuif: Calculate the highest priority PPI Date: Mon, 23 Feb 2026 17:01:48 +0000 Message-ID: <20260223170212.441276-42-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866495943158500 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 --- 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 b69ad137aa..2c552cd3c5 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. @@ -87,4 +89,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 414c8ea7e2..04b87c1ee6 100644 --- a/meson.build +++ b/meson.build @@ -3665,6 +3665,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 6841b6748f..e0a7d02386 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -612,6 +612,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 d0521ce7fd..48cf14b4d0 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 Sun Apr 12 00:56:26 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=1771866815; cv=none; d=zohomail.com; s=zohoarc; b=mwmAq1ZMSP9ct+6g0Q3UHrl4CT17OGHl5ZYy2TcO3raxo5ZP/I7HX1FN1bsOuoiARDZD9ZTfxxbVxtEYQLdviD2invXK8sY/ClX3L+dVC07iWWPitFocGzjAOlJCCHGNJ8DxLtZtsc/6RtzQiml7zSy4DBA6PHjmZOGS7fxL408= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866815; 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=Ql6fahb1YltIi8mgBYLkHjOatO6N+TZVhiuUzf/mLDc=; b=Xkvqdg60YEkBeCYEcAFMat0iVjxDPwwOKf/lezlz/IK8K8YbyuXQmTDTFUNT3IaOHKaNZFdeOrXFdz5f4WsVBkKmLNv7q64DRdoODL5cuvn+K4Ud5BkfnEZVNrk6nCKk/tvW6lJsL18PeNX27EM8RA3oJBxjnuAOjwedvBbj2bM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866815214411.0657917067351; Mon, 23 Feb 2026 09:13:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZLr-0003GB-P8; Mon, 23 Feb 2026 12:04:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKt-0002c6-Lr for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:10 -0500 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 1vuZKp-0000L5-Tp for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:06 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-48372efa020so36383155e9.2 for ; Mon, 23 Feb 2026 09:03:03 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866182; x=1772470982; 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=Ql6fahb1YltIi8mgBYLkHjOatO6N+TZVhiuUzf/mLDc=; b=vlP3V6FUUmd3cqMQ4sudGhk8XsUACjJT7HjTRSijf25hVBKRbtOfHZemMk2aOvvjNQ hkGTpbzEe2C+80jAtOMPDsd1Xa5jv66/ry6v/h+F/1io3sH99VjmXZJU4FwPOU4hBXwU ECHusfZJHyH1XO/zPP8KMVg6XEecMSvJsZLOUr5btCOgWac8WCgTjmrKuBZg/kEF4p3U +NsXZm8tqJVrkEwuP5mrSjY3W7/xnOpUQMSIaTJW9Gnqn9DqP5gfapbHhEF5nuvL64Re c8GWDwgj+5j6u+j9qExGw7w/do/OysN+wBOP+wOwYl4A0IFfWR9CdTk2OyARMqhzwqSN AliQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866182; x=1772470982; 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=Ql6fahb1YltIi8mgBYLkHjOatO6N+TZVhiuUzf/mLDc=; b=M+0aofhwyQCpjrcma3Gpxju+/xtimiOzceZP3N4LryXI0nbiYxU/W72UDkuhSUkjnZ klYIXz+P774clbW8Rgjm7H73iojZ7zQfff8vwdWV10dHASpsE5UTb6sUTi6XrB9YphmN jZoZRbi4yzObcA0+mH8OoekCR3cuvjq3bWR8oYy04MxOe/aupFhsB3HvzNXOqnsynexy i6d4MPvTrnqaTeJCaUroHHLIYaUxsVZCO9oNWrWeT8dt4SjhRryKLB+L/nVRX3tdsTzH 0d5t1PSGv9saQde4verWAWWjXHoQdLPI1ZzGJpXfDTAcUJrVcoT+FLDBEAmZqQavuH3b 9p8Q== X-Forwarded-Encrypted: i=1; AJvYcCX5Mu4YrllvCfRWPWdED08uPAkq4boUA3cU16SzPEKXfV2kq4WM3hGmN1fD15KJlcy5exHuRWticxbM@nongnu.org X-Gm-Message-State: AOJu0YxshR090t6ltmMXO3wOC4B2FPP8hK8lk+L1kK2+WN4yHlxWaIkV Rvc5BuJ3xFKVPgNPxGTmVeygnrzbZXALDoeU1lhpGvq6z3b9nZ3bMYxcKaksJ0AM898= X-Gm-Gg: AZuq6aIcAbFVoeFQ4za6bWeFT2KS5PF/fZOUwBpqF9ZUYDzMiGMLcp53IkUfDfsL58o v4pet7uoj239yAXWeZUXXnJlprq2reAbAFg1KiIKnNWMbTxhlsZ9u7B+bXsAfh3GTEFXH2LVSQS lUjKcXV3V346+xiwtftmGzjGTNWXK4VCf2xMhq5xllMyD/mpaN20M057OO5DzMmRGvn/9Ir0vC7 U/RnstNR+NSXe7Vmz6mjGwVxiI5Qr6huyWakmJdVcYDxPtYIcF6nmwtekRhjGTwKMdPozxyqoOa kPY2Kadxrc2e8QoPZ9mx2dnZUnUyKFMHr2P+2Na3OvdJhJinCkAS9a+xI2f4OpHk9q5nhDJmhOC 590rHGg+ihnuKEO2gt2UiBZBagBO1wHTzEHJ7W2wmte4cUC2gnjmn2AA1i7AbnKooMjQcpDCYxy bQLkTi46qFPU0yghjB+RoeWdrkRh5m6M5xphAvDpgbuVNqHknCWRP85x9BVqcoRMgBkPDhI5xK4 Pq8Jm1juSTxb0QVtO232aO8pK3X9wA= X-Received: by 2002:a05:600c:4f94:b0:47e:e20e:bbb0 with SMTP id 5b1f17b1804b1-483a95eb33cmr150706765e9.6.1771866182179; Mon, 23 Feb 2026 09:03:02 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 42/65] hw/intc/arm_gicv5: Calculate HPPI in the IRS Date: Mon, 23 Feb 2026 17:01:49 +0000 Message-ID: <20260223170212.441276-43-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866815796158500 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 --- 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 30368998d3..070d414d67 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) { @@ -582,6 +733,7 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, GICv5 *s =3D ARM_GICV5(cs); uint32_t *l2_iste_p; L2_ISTE_Handle h; + uint32_t iaffid; =20 trace_gicv5_set_priority(domain_name[domain], inttype_name(type), virt= ual, id, priority); @@ -603,6 +755,7 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, } =20 spi->priority =3D priority; + irs_recalc_hppi(s, domain, spi->iaffid); return; } if (type !=3D GICV5_LPI) { @@ -616,7 +769,10 @@ void gicv5_set_priority(GICv5Common *cs, uint32_t id, 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); + + irs_recalc_hppi(s, domain, iaffid); } =20 void gicv5_set_enabled(GICv5Common *cs, uint32_t id, @@ -627,6 +783,7 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, GICv5 *s =3D ARM_GICV5(cs); uint32_t *l2_iste_p; L2_ISTE_Handle h; + 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, } =20 spi->enabled =3D true; + irs_recalc_hppi(s, domain, spi->iaffid); return; } if (type !=3D GICV5_LPI) { @@ -658,7 +816,9 @@ void gicv5_set_enabled(GICv5Common *cs, uint32_t id, 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); + irs_recalc_hppi(s, domain, iaffid); } =20 void gicv5_set_pending(GICv5Common *cs, uint32_t id, @@ -669,6 +829,7 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, GICv5 *s =3D ARM_GICV5(cs); uint32_t *l2_iste_p; L2_ISTE_Handle h; + uint32_t iaffid; =20 trace_gicv5_set_pending(domain_name[domain], inttype_name(type), virtu= al, id, pending); @@ -687,6 +848,7 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, } =20 spi->pending =3D true; + irs_recalc_hppi(s, domain, spi->iaffid); return; } if (type !=3D GICV5_LPI) { @@ -700,7 +862,9 @@ void gicv5_set_pending(GICv5Common *cs, uint32_t id, 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); + irs_recalc_hppi(s, domain, iaffid); } =20 void gicv5_set_handling(GICv5Common *cs, uint32_t id, @@ -752,6 +916,7 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, uin= t32_t iaffid, GICv5 *s =3D ARM_GICV5(cs); uint32_t *l2_iste_p; L2_ISTE_Handle h; + uint32_t old_iaffid; =20 trace_gicv5_set_target(domain_name[domain], inttype_name(type), virtua= l, id, iaffid, irm); @@ -778,7 +943,10 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, ui= nt32_t iaffid, return; } =20 + old_iaffid =3D spi->iaffid; spi->iaffid =3D iaffid; + irs_recalc_hppi(s, domain, old_iaffid); + irs_recalc_hppi(s, domain, iaffid); return; } if (type !=3D GICV5_LPI) { @@ -795,8 +963,12 @@ void gicv5_set_target(GICv5Common *cs, uint32_t id, ui= nt32_t iaffid, * 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 her= e. */ + 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); + + 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, @@ -907,6 +1079,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: @@ -964,6 +1142,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; @@ -1033,6 +1212,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 @@ -1186,6 +1366,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]; @@ -1274,6 +1459,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; @@ -1283,7 +1469,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; @@ -1294,6 +1485,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; @@ -1480,6 +1672,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 @@ -1492,6 +1685,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) @@ -1573,6 +1768,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; @@ -1600,6 +1796,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 7b5477c7f1..13b343504d 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 48cf14b4d0..2f6827dc13 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 Sun Apr 12 00:56:26 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=1771866493; cv=none; d=zohomail.com; s=zohoarc; b=S1bVDd4BufcESNkjzL6zIwJbxM22icmcJE1avTusyjXl2PIaB9lw2RRS1oOgc3b77MCtkzyN00q3Gko10W3EsOhQ9HmpTgG8Fy196k622d1XMUMK/LyJhZZhDFVoiUyE5H4se3LMjmrdCjfRUFt6+APzwN3OjMq7/l2lf+EEhm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866493; 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=9EclDtotkR1f0lyay0/isT6zoNQaUcu9GIY6GSoSdes=; b=M4HjPRl7ah30KkjIDAFe2+X8M//GbBxQ+akjAHg0j6oE++lYXh/gJHLV+K6BP22DhobOMfMSCpePgR5F+TD7n8zzitRrhVddUPMgmXnfBq/X84zD9cIihUcNVh8hGNHDQuozu40MvVRZFtDtd2waxbxxXQ6w7gG72hXI5jnJYSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866493568958.0847938442532; Mon, 23 Feb 2026 09:08:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZLs-0003Mz-Hx; Mon, 23 Feb 2026 12:04:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKt-0002c7-LW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:10 -0500 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 1vuZKq-0000LO-TJ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:06 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4837907f535so41157835e9.3 for ; Mon, 23 Feb 2026 09:03:04 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866183; x=1772470983; 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=9EclDtotkR1f0lyay0/isT6zoNQaUcu9GIY6GSoSdes=; b=dEbk59Bj6E87I/29t9ETR84h4MHh7p2SBt/3RjZJ6DZKpnUbLfT/sDFcZk2zo5RDq+ dy1DqD373EBJ8wGpEJOWKUakFKkfMSJEhoZqT7YW5/viuJnatapLP00DHEzmdDEwgNrw KjZnEOvUioJi8OEhLrt5Fopo6nEYUUn8+hwQ+PWTk2zj9l4G2Ur1k1KCG+ngqLVLjPw7 +fSOObDjpRuXAY8347IxdBLK6I25qpgyt1LHMOZU1+rSqJWHZvTr9Q5P+KD18vP39v9k +8QzydFoMbFzuUfVtAaG8jz6py6pgsqo79d4vBrXMuM9goGFcyITuOo7ayHpZFBpDt06 pFUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866183; x=1772470983; 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=9EclDtotkR1f0lyay0/isT6zoNQaUcu9GIY6GSoSdes=; b=ivj0HMZtymCkH68CEeokY+E60E1xkD/saz5gUbJgF7HVIR7muBcslpwhaKYUmwd8mz /2LRKqsbaHrB3Evz4bE6gokHvhwZ1RGdlbfBJ6iWqdItR7+hGSk+HVGP/Wof2HSVt4HY yEebwJVU+ssULPaNgLsWzjCUv6gWA5BDqWbtm5z1E+wP9+TsmK4Fwf5O5prQT9ENNR8f pHrXgTdDs+1HJxi7lMAqHixpfBScuuxMk2gd2WClVWrYs8BRDOpzR2h+rVa/NAzDtGN4 a0q3XlrjPKRPUYrUzWEwbMfLF6OB/H3mvYwzpc60UNAkUeFAyDvIjxjwNNwbvJK5Hq8s ipvQ== X-Forwarded-Encrypted: i=1; AJvYcCUmxuI3EvsDjMUzGEj/53fWNH7MfNpiSGU8CDQcZN7Sbx6yB8dw8LcbAfF/4fgk3twTuW6ReXzIaBmj@nongnu.org X-Gm-Message-State: AOJu0Ywz+hhakE81FJ6A7Cyh6/PXbmYM7t7NojIRhs7yvD0JPxXNDuYE msP94wrBYnjsPGO5wrCOz//2ZpRBjX/bZpn2rF7vlCCqc++PN6GUjcfkj/ewU08uM0Y= X-Gm-Gg: AZuq6aLmiX5e7Et/VmAcFVKs/a52yCW58QVDs0jA3PA6K8yyuMvoNJaR2XIsevHgkZr 1hQLH5EiJyQmfvrUmbn2kq0HQWoIlezEuz3R+RRaOzMCrAppvcaruSr1AcpNcBMnkEWeafWiyln nQp5lqIWyuQdRtIay9oABDQYGgjpJZNv0mS5U0M2WJ+zOjeepuY9YruKL2TLCE5EWoBQRrgXKDW EJk6wXkf0PoOvWCR/MQOCnYb5ApFDyvOIZt2kFxvUAq6p+uOxonyut3Mc605JZEnPu/I6yZGquY UGfbZ/pq45ZbTbU/o6pF1X+j9bGR24+Pebd28ZqLgXOUcIJjGLN/TSP6H/WoPCAB3vaAhcAZqXi UE82xLqCe2YeqtwX3O54CN4IpcRgQcwpbDgRSd97napaK8266M1XHJDVF/Hj7sVYc9iQob1riBe 9YARkzsPwC8xx0MdpW+gMsL7k+UA4rZejZOmNQLx65XCDQxQGUL0PpLvO2MiogB1c+m24D/dCta dxJXXqDV3UP03+Kbdp0U5C2zt89qoU= X-Received: by 2002:a05:600c:3115:b0:47a:814c:eea1 with SMTP id 5b1f17b1804b1-483a961602dmr194341685e9.35.1771866183329; Mon, 23 Feb 2026 09:03:03 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 43/65] target/arm: GICv5 cpuif: Implement ICC_CR0_EL1 Date: Mon, 23 Feb 2026 17:01:50 +0000 Message-ID: <20260223170212.441276-44-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866493942158500 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 --- 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 e0a7d02386..1263841a1d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -605,6 +605,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 2f6827dc13..5af9fdb1db 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 Sun Apr 12 00:56:26 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=1771866671; cv=none; d=zohomail.com; s=zohoarc; b=GtNM9krWcgWgigKF1LBCMNYj8jVo+IOo9W/WY+l7xIYL5rwt/uR/q9CAu6O2+Q7GASN4jVvuzYAmsxgpvyD8PXZrDttcp8NRBZk/vtKx5KQr66RyakRxvOwsOjwdgLVHsy9WJMWSdRoVMtGJnj+uCrn0D9HF1o0ek02siLf1buc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866671; 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=AW764VCsKq3y+ySrJ/HlW9c07iwK2oyw1ZIlJo/TovI=; b=MPA2pDqLsGKscvVyh+YuMKuWNGvEY3dG/+eckMEeGPAW9DEpsgfS+QjYYQxerC4deOGhqgpIW0GMWDEVqhuUPEo9cfNvHEuezjdhAno4MkUU52ZSI64fuM2m2A7PWbCRCAfvKoXT7NCzv+VMSkygazMv2RemwQvLL3LlxQVRcVY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866671837572.8932643761062; Mon, 23 Feb 2026 09:11:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM0-0003dv-3k; Mon, 23 Feb 2026 12:04:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKv-0002cM-Ea for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:11 -0500 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 1vuZKt-0000Lq-Cu for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:08 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4837907f535so41157995e9.3 for ; Mon, 23 Feb 2026 09:03:05 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866184; x=1772470984; 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=AW764VCsKq3y+ySrJ/HlW9c07iwK2oyw1ZIlJo/TovI=; b=VbgX3dqTrDnquNhel/dpTJdo8ivkSfDSZ88RCGCMcP/mzNC5jJMggjByN+7I9FjCYg ylRiMAlOSZy6C2o2U69TQwYwLZZ70/6A4WsYtfOcY4zL07D8FDuL5VCNxgXWsBC/lDeZ QzWEu0Ujm89NKFWRyQ+hvVh6rfybTKjqzUgmxayVvyWRF0A+AsSf4SoXB2Zyt1PclVP6 PwPnnsNCfaIpF225GqztPAvziTLgIXVB00QRvC2AjUf7+0D0SdGDBhL8Cy86wQpR7KvC 4f3Y65wHdepalTRLnzb5KLd2KBR9Knw/kaf18HI84gX0XrLWFcgF+o3UaFqRy6tqXCL2 fi+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866184; x=1772470984; 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=AW764VCsKq3y+ySrJ/HlW9c07iwK2oyw1ZIlJo/TovI=; b=k2LRPftS29QwI4LUYpGYA9A9M4pk61hPeIBVmWzpAr4A4OZjmRIVZrk2yjHeFDGIWu Lj3JMYS0sU9z7FyAHeHmNL4Bl/2cmr0Mkb/w7iSvqYJV5iXrou/TQkrknG56x/7nn5vh xhVb/7lGP6mtdLk1Q3GZz/CoMK2HdVQFkSJkBPA/PU5BcQ/X/dzkM+FcaO5ZqAJIA145 3ktIic9OlKLMd8Ykb++0EmTKSkgANmJJNdgwVRqA5OE6pijoYwM1Qdd7kuxP1TYG/5nN hhfO7Q3e4TLnKmSUCL5QRbJEUcMovwpyOt8dTItMc5IA+DDj3JTmHMtlzGJrJZuVQ2Oq yOPQ== X-Forwarded-Encrypted: i=1; AJvYcCVJ+ygSknX5IjlJgnNl9N24okQ6IP88NNcviVXq//eul4UPCJh5LPX5sAujF6Vl4gr3fTeewFiueHRX@nongnu.org X-Gm-Message-State: AOJu0YwRbiNQYmqtRXu9YsTB/T8v3TVx3rBHFIkdwCiJTitgbl9a4V9o QbJ6m48SbSWhp0j8ewT5CgPvM9yJE5mJn2eYeK4wwcIkQ8ZMI4m/1dsvmRiEnpCIv3E= X-Gm-Gg: AZuq6aJjwZXpbEYK/KCyA4tgQMSSrdnz0QijMzmctWzw3jZxTtEhHcEoopiovQWRjVB Ib3+58792Y4QOFAz5HedvVVfdJa498K3rbgWH2Rwpe2lsr6MHYcQnYlifvYI4lUSchWwmTNV8Vm AoKwLtmUB7+7WU2sDr1P5uTMXCcEsRvLrIfcc6387UWtifjOXS44mMT2NkY37tj+90y6V1HqhIA OG5sGzT3gVi7q6KWzqdp4pHA9eJktTr0Fj/tt+6psUeCf0oYVOxYf8vHkryUFBVseqzUSYXmfdt BNxOKGnDd8KLMOW4XLhx7xluLpvwKLdgOEfwfuOq4hRjbs9djEZZmxa1gAa+M0qkpVOrme8Zrua yikA+IzP+dJuojOf9TnCdVzgumeOOjSRlSkqbINCmHFNV3swRv91xoHv+mC2vjpQZCYgzTsQE6f t06hvWvbvNHNg04++3qbNPIpgEHDrz6K8kTfyOgtcnwyvEMbaK6HUCkvC8Z7aE/eoI3wSAFjEWN 57w0kh7NSWHM6vBhS3pc64aULvtN7g= X-Received: by 2002:a05:600c:3b27:b0:483:702f:4641 with SMTP id 5b1f17b1804b1-483a95bd842mr143352255e9.3.1771866184283; Mon, 23 Feb 2026 09:03:04 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 44/65] target/arm: GICv5 cpuif: Implement ICC_PCR_EL1 Date: Mon, 23 Feb 2026 17:01:51 +0000 Message-ID: <20260223170212.441276-45-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866672908158500 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 sufficientyl 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 --- 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 1263841a1d..651fccd59b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -606,6 +606,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 5af9fdb1db..45ef80ca87 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 Sun Apr 12 00:56:26 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=1771866552; cv=none; d=zohomail.com; s=zohoarc; b=YEW2pFe1rL42d2vtY7bBkmLQIlmT7LYO0m2+RHxr0d6EsaKIdYTXxSIMjXm7XA7IKU1X+UgYcHeNgoC9gxG3uDr7Xwy6eq4DopyOh8J2qooyZMhjge9h5wxkLRoQVQv4DJ1UT+rmJxGsZsgGoZiF5iblMp9WF91hBgoFfD3QRVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866552; 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=mVkOLAQp5zvH8Zemc4wj3jGGnDzUhMplQS5DRD9P+iI=; b=V4Gz1MfsnKTQaD82Si8xNEiblP6fYgxUQLJvxy8miLNbkIalTVSXLxdRAl4HOQeEwn9mzB4IaJqjaiDF0nGH9QHbWvekwVhMOrju2M/D3vS4OIy0jeDftzUCy+vFZdld5TK8GR8CtmqhsOcReYQ0rjs/SAGDOMR6vdbIILbNvK0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866552212971.2166671757061; Mon, 23 Feb 2026 09:09:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM2-0003zd-HL; Mon, 23 Feb 2026 12:04:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKv-0002cN-FI for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:11 -0500 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 1vuZKt-0000MC-D3 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:09 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-48371bb515eso58002615e9.1 for ; Mon, 23 Feb 2026 09:03:06 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866186; x=1772470986; 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=mVkOLAQp5zvH8Zemc4wj3jGGnDzUhMplQS5DRD9P+iI=; b=M5Lt5gJI+x0miRvyChclRePjExC7G1ZV7gktNoNhNplHH23ADiBtDxb9J0ax5XNDxH 6YB7UCJa7O2F+WlFZLWdH4yM6QdKYwCi0YEdfZSc+SlrPdbY7iNIfEiQWKe1eCZVXA7f UJVohDNqBV7fX+t83DEeKeirf5avHNqoPqIK43GIec1w0bHivb9AzvejW1EXGvizhpr8 qk14evf2bSEVObwfkDQHmMajLEHK4eOi1jlPywO06c7IvmDNBuHOl0iCHWrxeclz7eud e0/CXz1ICBKSPEve7McGCgiy8xXC2YmcvFCu4F+5RmqyFF8oUtkJ72mUJMSoXuPEdge8 AIng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866186; x=1772470986; 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=mVkOLAQp5zvH8Zemc4wj3jGGnDzUhMplQS5DRD9P+iI=; b=nVeBI2u0vV9iJ3dsyD9TonRS9IDJqx9Nz2wlde94W24uFJsvthKSqmoud7wR8fy0EV 1lU2S3Q2YW/dE65U63lM+gyR1aiFryvNuA/UZNJBecOY/ZGGAh102x4BfcrmuJmMZCk/ lB+74ZU7z9d0nyDj9+sx7EItrLXWLzpUrfM1QQrr8VBPNpNAbdVCya1pLkEL5a/U2pG/ qEQFmdmU07mcVO17m9pqedihfFDLvLkke6AnkI5a1KJgP2EhbP1o/8h7DtzM2/MiHjCX vLpKcYoA4wHGGcJzOmtNSqMDnrAGpyVOBp1XZjNMfDSmw+pLnAe427TCQ1G2g5AIRUXG WbTA== X-Forwarded-Encrypted: i=1; AJvYcCVvC12I2IsylDZJlHdqNHG9Jngcuu2X7ob2v0dUK6N9kcFOUgLE/LZVV4A6EZFM5lFuH+lS5dlcC2MN@nongnu.org X-Gm-Message-State: AOJu0YzZqDDudcs8mtOh7NOoLRq34IuItj1N1/tFW3ynLoUQ05Qwy+7p 7XC9rJDIlrUiiZV1j+emLKzHKsiPLpn8PlIlzUHkMIgT2/BNIRcTAoHTpf0n6e1hxlg93lwehJC l//cT X-Gm-Gg: AZuq6aI//OkYLUpNOFC3VoLYKGgmvxgXUNlwtVOAKnb6wITfXw687MQuhndJe14Eies pH90pGQVtNO9kTzUUadNJ3HbN8r28Pei54xRqwtEyKG00a9gjOrxBqcB+PlX6mVfMP33tyUeMOD 0syuRrmJOrvRyfBW3ncg39uNGOlUXUn1+X3NTvIkAFeBcwtmLT9a2qylYtKwzX8EDd5U2KZI+0h /LpvZl65NJx552I66K2pda2JOMmtqhVGybOSwZ53oHWKDZ53vE2kiDgk2kELkE8OYxF8RZEFV7l QUnDBzofqoiHJ/swHA555Iq2sRh6QJCw5onp3T5Y/Bz8cn2EPy0KgIAyKKosF+uM0kWLmPiggEs Yqt4iUIvHZ04Qj56lo5NTHqOv1ARv4pdkecqNFA5Ng4nBihf0DxZRaChiAGQZUk/OEW/QEUhI4w C6hjLmUDmcZ6T9nmXIOEjhjyNyX07XEC1rjanBxdFapmDtA//bfKMPWpA5fYnQ846cfuB2UMPVx IxGD6zptsD7MRMU++fGXonUEif6D6XYcvw37a7G0Q== X-Received: by 2002:a05:600c:1c1f:b0:477:6d96:b3e5 with SMTP id 5b1f17b1804b1-483a95eb50bmr181508635e9.7.1771866185585; Mon, 23 Feb 2026 09:03:05 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 45/65] target/arm: GICv5 cpuif: Implement ICC_HPPIR_EL1 Date: Mon, 23 Feb 2026 17:01:52 +0000 Message-ID: <20260223170212.441276-46-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866554311158500 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 --- hw/intc/arm_gicv5.c | 11 ++++++ include/hw/intc/arm_gicv5_stream.h | 14 +++++++ target/arm/tcg/gicv5-cpuif.c | 62 ++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 070d414d67..6cb81123e5 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -527,6 +527,17 @@ 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 13b343504d..6850f03b74 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -175,4 +175,18 @@ 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 45ef80ca87..adb4d2018f 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,52 @@ 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; + GICv5PendingIrq 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 +457,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 +579,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 Sun Apr 12 00:56:26 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=1771866579; cv=none; d=zohomail.com; s=zohoarc; b=B6fb+j4SQX4ulXU9BY7b2uh2TwTDfepqeV6AwDFQg3wr+5Yh0O0/yMxr5EH/xfG43f7ESW35dfh/f41dHmtHkl5AoIyTgzdn5IxCgfX7U/ESIojvFO6GttHAqVUUoEYy5GJfXhfXkYalSb0D0JHv6ubMy2rmayqth3Z+PL1AbFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866579; 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=t26rLo2yhfYJ9dll13VWciZB76X/o5OPoR5rYYX5ZFc=; b=WW4HZpKg8DXhxGaUWyG5ft3AbcZcrFo4NFr6RfWRxstS8jaZrIcuFP+qdIcmC39auXvMxB+P9wkQGhcMiVfvWCJmW57fUXeK4RFN+dkL/OPy2qTSzVRUeBEg+l48tEwHqDz7P8+AmdDBzf4ZlGe+B09Bi+8mEaOlM1usBmMXGIM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866579343705.0080321900713; Mon, 23 Feb 2026 09:09:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZLs-0003K0-0V; Mon, 23 Feb 2026 12:04:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKx-0002cb-0w for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:11 -0500 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 1vuZKv-0000MR-5v for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:10 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4836f363d0dso40276655e9.3 for ; Mon, 23 Feb 2026 09:03:07 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866187; x=1772470987; 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=t26rLo2yhfYJ9dll13VWciZB76X/o5OPoR5rYYX5ZFc=; b=OrGNT7xS5dwQuge3rAgF+MvXHdHakRHG/gZl89foBNDMFLsGRAEZQeBy85TwTOzFjL HvWiM4RUppt5SdJ5gCJFx2R8bVtOo8TVRoH3BuxVuYSpe3o7pL2XF9cNTm4l6//2sjyV KFwRhtt5M4Jsa5A4iSH2BVe5teX5GODz5ce8JBqIl0Q0F7Q1D01DT/z7p+/nFfJBzoCo xXgLzLWGviSop9G7UQe42SH3NPrW8IA47sOfTwbxDCc6qpUwuX37mT6a0NW0OyhrDTsy Y365+n7TsXYYlr16SpmZ81raEP6YH76QKXc06MvKnhodpbndTy+gjx+pcDsu0Qfgycuv SL6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866187; x=1772470987; 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=t26rLo2yhfYJ9dll13VWciZB76X/o5OPoR5rYYX5ZFc=; b=skyhGNup2icdnAmYZLgnLVPCLmEJD5qnhm1JuClEb9Kj1EUeCBilRH/HKCVsAgtDUe OdmWG7yAeIDW92UATma2XFVHtkcA+Lap3d/q08xOhW7q2iT+PFPd93i4qQhYT1dvnH3r 3RpzgUyr9Temgj/PjeymYV0KwMoF2We7t+tpCIyHqMpjNLX4Y1cNVZxLo/1y6ydN0rC5 MyVhY7eOS2UpNvbhhI67Q6p5pPCrA7AnnBSnlbxORZsb+4uXGsrdruv3qeIWPCYNjezs XwYxuIgoxhOK9SOieFaKha9pcu0mXJlaVtmhWGJ6L505byGqWmfX8NoEVpa8RioJTfO/ 11TA== X-Forwarded-Encrypted: i=1; AJvYcCUEhO9ucd5U5fLxFr1VZfdO162CFierOWjUuXo3QVBWp1gcmk+TUeXeeGEBk32VuDpqALM1JmUq0SnR@nongnu.org X-Gm-Message-State: AOJu0YwY16LIwlxwISHLFvjxT3Z951I+GVMRKnK5PeJu6M6I2cKEJecy lpQKIISnCeiM8jaAKtzDDA5bEW1sJNCaTeotRhvyUzuj8aE30VkiTcl8PD8QhIcIung= X-Gm-Gg: AZuq6aJdb+SRQTggGFLX7rHRoU4qvRcW/Ds5Bgm6Ydt1+0sPc+OMaFIwbADsUmn9PH9 z0BGCu9aGvZVgPvPyBpfyweaLpCtnfenTHuSFP7Gmt7RAUZIkJjkN3uDX1TjrX780jJqRSiA8hT eFyMOOWNrgeSqaHl0alGEzR/Yp/PXL2UY7ykn7mB19bUMATf/FoTwrkawfaioLbhQ8ro25Vteh0 6yaD9OYLXPY+rb9S7PJiQODO7wyEYAKEKAB8BAGSXSNqnr42R4HUWCOOTFPU/k0bV/NYougAcrY qONsTAKMQ3RG++VyOISzYqFgTjowMBhSZ4908mEX/TJZX1i+diJLF/ckto+dlF7B29fRM4YSpgN Vbsr4zQi7favAi+80K28MuGDcOa5ZKqlLaNveI75I+dfRclA6LPDpiGobZggMGCsVpHZTwYRGaF YD6N9L8LsDstlcQ1FzaxS+BqI3U4VQvvjyB9YXQRCVUTPb2diae9ubEwDRmNpSMbOVPaVt4hfBV Kb/TG9pu58ABlJwbwwY1e/5ru+uMps= X-Received: by 2002:a05:600c:5020:b0:47a:814c:ee95 with SMTP id 5b1f17b1804b1-483a95fc1d3mr164153605e9.12.1771866186705; Mon, 23 Feb 2026 09:03:06 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 46/65] hw/intc/arm_gicv5: Implement Activate command Date: Mon, 23 Feb 2026 17:01:53 +0000 Message-ID: <20260223170212.441276-47-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -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: 1771866595245158500 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 --- hw/intc/arm_gicv5.c | 52 ++++++++++++++++++++++++++++++ hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_stream.h | 23 +++++++++++++ 3 files changed, 76 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 6cb81123e5..6636a66976 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1061,6 +1061,58 @@ uint64_t gicv5_request_config(GICv5Common *cs, uint3= 2_t id, GICv5Domain domain, return icsr; } =20 +void gicv5_activate(GICv5Common *cs, uint32_t id, GICv5Domain domain, + GICv5IntType type, bool virtual) +{ + const GICv5ISTConfig *cfg; + GICv5 *s =3D ARM_GICV5(cs); + uint32_t *l2_iste_p; + L2_ISTE_Handle h; + 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; + } + if (type =3D=3D 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; + } + irs_recalc_hppi(s, domain, spi->iaffid); + return; + } + if (type !=3D GICV5_LPI) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_activate: tried to " + "activate bad interrupt type %d\n", type); + return; + } + cfg =3D &s->phys_lpi_config[domain]; + 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); + + 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 6850f03b74..7adb53c86d 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 Sun Apr 12 00:56:26 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=1771866363; cv=none; d=zohomail.com; s=zohoarc; b=a0ucJKhW6zQlUlPV8WZhWfHw4pN4ftoLjTxwr2tdzMkFT20FNg5nlNpGNFwGEOZpnUGdFBvnejvIbPraRzMPDY96fIJMdQob+r7YpUpv78XITr3tqbl77D3iJWew58m+Bj4DclfOQhlBzv8ly4092yvaVut+59b33+zQR7Y7X5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866363; 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=S8AwTy6f3L9trkb36+KIhDXHVhmdfQ2KBm07CMiwLbw=; b=c2a7qlzDKzCbPlr4f0/FB/Ys3OWd2d0NpJnYPBKZqgrZ0o1UUiYv7bW6y6yaDZJIlgnNLsGrDEr+EAC3aBwEW9ACAtK1Nc/d6Jh0uLO5wwPR07voLiEsRaFG8ez34j+L2WiCgq1dMqQ6GqUeGUowsP9lHTTgUQXMbKT92hDZP4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866363266205.8018318133569; Mon, 23 Feb 2026 09:06:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZLz-0003dO-Tz; Mon, 23 Feb 2026 12:04:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKz-0002eQ-CX for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:17 -0500 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 1vuZKv-0000N4-By for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:12 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-48329eb96a7so26662695e9.3 for ; Mon, 23 Feb 2026 09:03:08 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866188; x=1772470988; 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=S8AwTy6f3L9trkb36+KIhDXHVhmdfQ2KBm07CMiwLbw=; b=MktcbywC2MTMRwaBntbfjyHF/IcItD0o0JC0XkyEyTqcRsgIeUn1SOeUJfvW7nFB2m dAuQdHnzs358TiL/6gYD5gerdqzXHI2vNMVdTbOqQ4xx3tqNviuVnwpjgRwKMiUZgRx2 6iGWqLFToWMY97R5/yNmV+soxR1AIjalYxcIaIpAPliegku4CL4ZsC01ccRfO/nOW5AE TW71l5HBiYp906pcAdsI7stF3NN7ALg+p8tc2lBAU0I0LoAT0dYkl90g+MYlE6DRNwWy JAO/bq4+6SW0VAko25w3Df+3fxjqMN1gFEmiI5ePKIGV56PYRl+Xy6HGkFFqH0b2RJ5d BiEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866188; x=1772470988; 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=S8AwTy6f3L9trkb36+KIhDXHVhmdfQ2KBm07CMiwLbw=; b=n5l15iDlNMuZPXtAH1KFx4+Q6NvdoUFa09RlIMPb957/Cs2JYbkiglemxEv+vgcmUR EBBrE+shEzs6pSf4dLNnfBxwek/KA3o6UQGo/UWNrg3UJv6X5FtlNUBV1EhjE6TlVzUZ rmv89CT+IKNIRYpCOx9z8BjnoDcVlGnzzTYiKjBhzl+F700AavWhqx6k3jiUtPnQ3lPn pVBrj9Vc9zlKcAupVC+UnCDunOancnGEQcXaB4r5ITLUrYsCjB0jitVyBbVXLCAil/S5 TGlsXn/c5B6p/Shx66QX2knYkNR4XhMaDV/9yKVr/oPZstRVFnPEIijwbupjQH/ad3ne JHew== X-Forwarded-Encrypted: i=1; AJvYcCXSfE5dRlan4xoiNmQp2Mb9ikcMvu0n+PeomncwNefE0VVoqiCO8i20+r+D6q0obzSvO0JHq+4brOmt@nongnu.org X-Gm-Message-State: AOJu0Yyn6K1JCjSXQKUu6wJT1qwHaU7wQPs/1EdhkiGJuRnk4faPiSne fovNjXBiaArHJqWJdAR/slp3/0i6UC2kFCIm9Bu0VaaWX/GVU0mTQj6u+5jzJUOrt/1Bdj0lZhg 21Rbf X-Gm-Gg: AZuq6aJ1dxNW2Vdu2xxl6fTxl9uH6M6qD+SQ/nyV1ZBxxUXNmF45flzyrhHGd8E28tz 9RqYOIAn1xAz0EYGwQ0pCcGp24WkUXy9xrQeFAJYqJD4X5PlfqVoU8fB7FIiX0JDlOEJftkefI/ THgzwHVjsbgfI0Btq3/2JMYeu0kPr/s8tG+gzs5BhxoIxXSKCgk8f9z0o7PvWN9alOGw415TfUc Pp7cGPJaU+nawtfRFHsf/vHD08gFJNcC5AV7vc+g99smuW8PstvF9hOEF6r5Ih8m1DLjAJa1xkJ jSRokgB5i+53ATW0+C4a1OjsPhSEXpCLs1s/wTAkmrUqN6xfn3omd4Vrl0xkceP4WYDPDXMvUdX /4JCeN86wule6W+/z2h3Xm7SfqDBSHB4u3Cx3bDzIPb4JdZCQaFnq20NgOqsh0bYco+lV+/8WjE ZimKHwWF1714BXpLkbmUedds32dK6+N6+ECso2EpKePdbCYPHesxxXuGIy+755xSKZ/PwwL6xFt vlU697ya/D9D8xe5qdOyvIZVzhX7rg= X-Received: by 2002:a05:600c:8287:b0:480:3a71:92b2 with SMTP id 5b1f17b1804b1-483a95eab99mr130172325e9.26.1771866187726; Mon, 23 Feb 2026 09:03:07 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 47/65] target/arm: GICv5 cpuif: Implement GICR CDIA command Date: Mon, 23 Feb 2026 17:01:54 +0000 Message-ID: <20260223170212.441276-48-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -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: 1771866365086158500 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 --- target/arm/tcg/gicv5-cpuif.c | 102 +++++++++++++++++++++++++++++++++++ target/arm/tcg/trace-events | 2 + 2 files changed, 104 insertions(+) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index adb4d2018f..d32263a5b7 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) @@ -464,6 +468,94 @@ 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 @@ -521,6 +613,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 Sun Apr 12 00:56:26 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=1771866821; cv=none; d=zohomail.com; s=zohoarc; b=M3JCEkzo6Il+3FFeEmdw5e9zi/jb3pkbjQ7bF8DfLqjsknZug8JnURHjh1Gxwq1ZrPlI4ZCX7xmn/np2dzyQdPoFMl2Uc7nGJlHEjHjvJ+W+2Xnahxv0JQ+Ukgh1WCA20Wl5ICukag7zjifv0fTfREQ41tN4QmZhfyXPDXWf3tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866821; 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=MdqR4vhujZdCIee6J+u4O26y6fOSqJ7/xzfHb6eSoPU=; b=gp+nCbrLIeshLoJ5XhmYdIjmQPiwEYwzUbMCnem2P7xZiMS5aP+KD1X9fHjK9SqRFkVS0PX6SsIFd46mIxbtKl4+vR4l7CujgdsJ54Azuch9UibINj6d7PGZuWFz0pP39gLzC9elu+yhoV5TYGpm4BZ4/GoMSl2yI0mNx6A3Y6o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866821343582.8647893445554; Mon, 23 Feb 2026 09:13:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM4-00049O-20; Mon, 23 Feb 2026 12:04:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZKz-0002eP-CA for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:17 -0500 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 1vuZKw-0000NY-5n for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:12 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-482f454be5bso50776755e9.0 for ; Mon, 23 Feb 2026 09:03:09 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866189; x=1772470989; 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=MdqR4vhujZdCIee6J+u4O26y6fOSqJ7/xzfHb6eSoPU=; b=IY4s16KgSvmOVsWtqYBgYlMK/KL25S0Qwkh+yF8p13FnRQpDMt5rVSDgz+74dTk/Tp U4jkkQVDeQCgOP4gxfK58zfNQHcxEmCMJUaL6WkjdHCCdP1NWjUARVYcELGdzuQTycaK PeaU/fdKOXNZX/LoGC2w2zs7UOO3/ImAA3UnCPWT+GLm+dE4hwXJZSq0N94wUsCj24FU ar6kKIgOBfrg0OcAJWuW4WJiGu87WlK2uptPmvU+EbQPE5KsUMfFsh1A7vXVR9zu/Hzg qSE5fW+W6PkCFvO4vMQzX//ikofrq3TpuwNam/G2E52e0BaDSU9poq8Ke1A4qDngD2v6 i/9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866189; x=1772470989; 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=MdqR4vhujZdCIee6J+u4O26y6fOSqJ7/xzfHb6eSoPU=; b=QFi+QLw/N6LF8dAgW4NcnGTfR3zxRPntiXNZIOvyNf8XR8VVazwEPGdCRi/jGJSE4r nyBoyTwxr/NrUh892YpfDJy+pwos0jLslgmr8cpe7D1sTG5Qj3STkhpMwv25Htn8STpu 6dJXQYnKUkUP7Q0WeUv7w+0oRsWkFQIgZYKhDPq7dIRSmjY+3bdG4ZQ4hfsIfXxLG/hm J4Z4jh0BL7mHqitLEijLCL+Wc9RLXitBukrWb0eLB0Ax1hmZPtGXpGYSf41YFRTSm0HI YTbPZ2D+7xGCiTQnyn0TmV4QHETcs94CK7xAyJuTrbCszSLTwoAUkbNOZrhedKw/glYQ yzzg== X-Forwarded-Encrypted: i=1; AJvYcCXFkYezvwAc/UlrLD9YBXoHqSjByKjIswbTCS8E7KvnktVmY7cKCn9ADvdrlgChCeBY1FJf4oFWkAxM@nongnu.org X-Gm-Message-State: AOJu0YyjAdrnhXBG0ngLmtLuItXCANrcisNsHLrsvL3HFL3DPKrEPYp+ nr/YEoGa9sAMe8fD9xkxRz+IhAAcf/3qMggSpX1GIDyKGoby6uK+w/kXxSNB+MGogG7WrS2VZNn 0+wRa X-Gm-Gg: AZuq6aK+Gljf4EINqQf8ht0AbFw5yprrhOdSYqGlP6aFXVv+UOd3ade/PauVmPZPna5 l8dKNTjZ/zIjuP/X4LYBAMMcclNqqrTxAva5FtMS1LCKwi8pojrPd6zJBDxeduwxgR3nSHUkqdz d0AmZ7McGU6+8wBfg6Lop1ubazxlELSeuEO0OQXQ97aLNSgb98KkAlesbGHdKb1DQsWv2qhXklC cM3upEWXfzTMbEeRcN7syHQujgz7nqqijNlAdWmaFeIXVr/fQPk085xgc6QqCmnUs1Of+i4YAdm K9F8FR04gkaKHUULUPldjaQkqndo1GLM2X1hsxMHIOm91HbctG7z0d7qFQWZNSJoCQuXHR8+X3a gEcRT5oZkjnVp/bT8v6dcdCTfSu0FSblzPh9+NOLkS4dZKrnWsKq30kSIQq81UnGWvyQ3uyJpa/ KlG8LNSWWCCyw5MSfkAvfY2jfmBkr7SQrUysyzj8lOqvUaPyicS4SCYx75oXdG37NBc4btdSUM3 OiA+p8DZDafy0KoUkBGK4XEl/jXoz8= X-Received: by 2002:a05:600c:4f13:b0:483:7b99:131d with SMTP id 5b1f17b1804b1-483a94d9b6cmr199133845e9.16.1771866188652; Mon, 23 Feb 2026 09:03:08 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 48/65] target/arm: GICv5 cpuif: Implement GIC CDEOI Date: Mon, 23 Feb 2026 17:01:55 +0000 Message-ID: <20260223170212.441276-49-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866821778158500 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 --- 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 d32263a5b7..c830938bdc 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -556,6 +556,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 @@ -608,6 +624,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 Sun Apr 12 00:56:26 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=1771866782; cv=none; d=zohomail.com; s=zohoarc; b=R7splg7eiqxGjqFoHS2lguSxLPFT8txKMhDDBUYVe+5tWnpZAq+YlNHtMpPRYZUR8iqWbmmrriLYYWU1qOJdQ1OSHHLhrVnDg4EIr1oQsJ9Dv3hg3qNeD1p2QSRr6nbKVsZFQG7jCzYo6/w04E5LRpJvRj1KaJiuM848m4LFtmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866782; 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=61PvnFSHrTc5AGGW4jO3OHip56G19MgkDyLY5pjuMnQ=; b=UdMHAcJrWNWIT2uUdZAi6aIxj/NtlwiiG4hi/Nu3m5TNqUl+aidtPm6oAuEFWuOn5PS2RfbnTPwSwkgAsk5z94v6Zu6NnCx11bcuiFXiBYtkhpKuUe2to0Wsq2/e2ZXmAq4C/lyG2ga3/A5kfjheKmAGquEacb1PxYmRdz4vIaw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866782602857.1488346185348; Mon, 23 Feb 2026 09:13:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM5-0004ME-Un; Mon, 23 Feb 2026 12:04:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZL5-0002l6-2s for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:25 -0500 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 1vuZKz-0000Nw-2Z for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:15 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4806f3fc50bso52101915e9.0 for ; Mon, 23 Feb 2026 09:03:10 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866190; x=1772470990; 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=61PvnFSHrTc5AGGW4jO3OHip56G19MgkDyLY5pjuMnQ=; b=jjtGQOjPufAbM4bdmGwbUKIa8VuxXenOEacOerySz7EH2cnmyRg6HekyDf7gVET9yV opQCPGNwYxC5kJYewChKbXr4rjjqENHjJWfTi3L3w4S2JjOHpRjMhg+3klj1RswhDAOW aPGiU06c2Z/U5ABbaQjSeHTVLQ9xDwM4tdakWe7aTCLAufQ5X+pELflOJiFpYfefNcwz +WXAk/sZfnD1sSMzZSJKslC418HsK9ztgjP9mAR2Ayz2PITfPs+yE2TjV/H5/tl7FnK3 Q+Kfk9NGeHtrJnWsf+TavSCxVx762EGE/uUEs0by5HSyx/dofswPfuyt77Uo/ngGUTsL z2Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866190; x=1772470990; 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=61PvnFSHrTc5AGGW4jO3OHip56G19MgkDyLY5pjuMnQ=; b=J2sx4YDw7Di483zbMoI4uyFNmvB6HmgfXUKiXN95Vi2zWgdCNOWrsUxM+LAm2NqYL3 rhfN6UECtz7D6hqRFlUCLj59HIvKTE2pVRJ/q2MHKoym+FQGrOUnh41EG3Y0FJ6C5tho /O7UM8I4WyObX2X9SoV+WbRlTEprYlNZFKT/fn7WPk7rCQJ428oKGiKslzauz9XbDFao N2YdD6nVGe9WrkIkouO9ghEfL3oGWNs7n5mqfnpl7rky6LZ9rhbd1k3KGuvZkJFbCUpb 6UKKBUGtu3mMPO9OTeJuMlnkjVVKrKW7cmrQZFH9O+Hnjzc0lI8y/auH0BREmbYZLui/ vQsA== X-Forwarded-Encrypted: i=1; AJvYcCVWYS1x3vw42q1bZw/xfR6XV3nhfcuOIpzpUQ7r3gQNLru2mOjLXXxU/x7++n/kDD+T1uck0renSRVU@nongnu.org X-Gm-Message-State: AOJu0YzLuLKyKE+X8ymK8JRfMQ4Y15mQSJzg1KUStnCAJ10JidYyIT4P Vo6LWgisk0mi5iYWI6k/XFF6S/6nfsjZY7+/+g8z3awBoi47Nf0CEaZRurHF1aBVORSEmH1m28n j3KNq X-Gm-Gg: AZuq6aLcX+OGXeZOnSidOFCd6EmxAlBvXo0YvfsFUyIvyTG2SePTM+aof55PsLbpiIw dFvTJlClwtJwcRZ5gUa6OpkRNI0w198v5Q8xrKF3+aHinjwc/1lCmegngeWMpUao10V/wzpE6bI YQ5csjj9XwEIiepwEmxFwae3bU79mleWYYYeZHTle4RMjFcxPXylFWs6N7kYWCDx8G8SnK+xL6J LpYLQf1ust6KOYw53keOR8K00PiwsS2milYAkYcXFcI2DhP6PjagfFIWe1TWf9WrSHiRaURF7PL 30phplnuMExcVnl9u4BSdbaL+cQJjLyljmN8V91Mx7g5k8m+q7ZBWoqIJs8TOHIp6aTVoqqw88Z z8SXNePmx/PweJb4DJ8sYuE7FTmdzwpEH5ipKyTAVDVK7myV066g5E+XGjGO1Gnbx/85AnFE7mF WsoIE/51426+7+nILe8UGjwQ/jTvQllLn0flpg+oRZpjgVo2orPTqDgSoL0BC9jDbm+4ypBq0hA Yw+8yUUsYmkgTBG5L4wK/oSSGZSFas= X-Received: by 2002:a05:600c:8b63:b0:47e:e87f:4bba with SMTP id 5b1f17b1804b1-483a9637833mr144580555e9.29.1771866189893; Mon, 23 Feb 2026 09:03:09 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 49/65] hw/intc/arm_gicv5: Implement Deactivate command Date: Mon, 23 Feb 2026 17:01:56 +0000 Message-ID: <20260223170212.441276-50-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866783605158500 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 --- hw/intc/arm_gicv5.c | 46 ++++++++++++++++++++++++++++++ hw/intc/trace-events | 1 + include/hw/intc/arm_gicv5_stream.h | 14 +++++++++ 3 files changed, 61 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 6636a66976..0509a958ff 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1113,6 +1113,52 @@ 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) +{ + const GICv5ISTConfig *cfg; + GICv5 *s =3D ARM_GICV5(cs); + uint32_t *l2_iste_p; + L2_ISTE_Handle h; + 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; + } + if (type =3D=3D 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; + irs_recalc_hppi(s, domain, spi->iaffid); + return; + } + if (type !=3D GICV5_LPI) { + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_deactivate: tried to " + "deactivate bad interrupt type %d\n", type); + return; + } + cfg =3D &s->phys_lpi_config[domain]; + 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); + + 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 7adb53c86d..f6783cc6b5 100644 --- a/include/hw/intc/arm_gicv5_stream.h +++ b/include/hw/intc/arm_gicv5_stream.h @@ -212,4 +212,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 Sun Apr 12 00:56:26 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=1771866782; cv=none; d=zohomail.com; s=zohoarc; b=W6xxoSqRiCEnF/BYGNIcUDR2elOrfX+s8bfLZsxvss/+MTSd+0i5db8uH3b271Cm/0u4pNiEEiJVzFYPT0dTcyW6LYQoDNwmfCr82qA8r+MkTeghh/KYLb5J8kbyh6c7WGAjtqjp+gJHbnfy3XFVgiYoZn2xFkB4OmX3UWZbBqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866782; 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=GhPKdeTRx8a+qCF0Q4nn5hRHL81i7jRy0/h8QpUlh60=; b=FOafm66i1yOxWrIFdluM6wmKRzrVHoLzTZb2bMEQEp7RmBJtRAHctrEUcDbuHMRSglHyPo3Dd7dYnIK3kFb71p97Z9KDRohTznjxxkmklItdGqZOTHfGbNofeSVhtr/Rcgqgk3qEe8npeop7bwcMboOQYBcijDhWg9VLjlCP6/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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866782358815.8401751820564; Mon, 23 Feb 2026 09:13:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM4-0004I2-Tg; Mon, 23 Feb 2026 12:04:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZL1-0002gC-45 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:17 -0500 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 1vuZKz-0000OU-2O for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:14 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4834826e5a0so57121375e9.2 for ; Mon, 23 Feb 2026 09:03:12 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866191; x=1772470991; 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=GhPKdeTRx8a+qCF0Q4nn5hRHL81i7jRy0/h8QpUlh60=; b=IhsYiE8VPtAC03VFotnJ3LDEb7oR4pL50VBnSw4P9gXD8DO9I9v4FHXKo1cwqONOPG ZdOqe9zFoDgliiHgHOgDUUhbEVALKeVDpUo9TPoKBA4K5rC6VD8F+Gxd9jULKuEpw1OD LcFnSOg00R2CO/jJRQ2ouEhHpRymr7R6m58mxNiTCFUkXE2kA8DnapJ+VvQPwasfL0uM Udb6Tj/p6LpanR9Q9dAumQb8ZDlve4yBtA91GzLsQOfzwM0xQ1ziCVSfZGPqcv3wOUZR UPcUsU6OovZNd+xoltZ2X6YMdv5OUdfS7LM6KmWMtZ88ZnV+Zxw4vHlJFqfnFyYgfeHu QmxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866191; x=1772470991; 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=GhPKdeTRx8a+qCF0Q4nn5hRHL81i7jRy0/h8QpUlh60=; b=a1e4PCTVMcheL2zSb5CxBRL0xfsisM752yfKmPVlRH+FuNR1lXfOBY0L4xZo3LjM4g VxHsZQHOT/2oVAbnbKRiS0+WJNrQveOTL+xO2J2qro3leCu/F5gfUAKs1fwEvehxRjXz ZcJwomjfYT3hCuggsPk02GUnsKKRAQsoRmdFYtmEOO2NMFXXFcxsivzHsdEQga+ffQOB SRDdveOaa80zKnFcvcoVIR7P0pQAD3cCQSUtM54X9bxsTbF82Wy1p4PjAsPWvmQfDGR+ UnxyV+nYjeKr96J1ZMHHGCLMXheufzg8MpSr0cXxvevYyVnY5xU2fHnUck4Kwtp5vtxR WM5A== X-Forwarded-Encrypted: i=1; AJvYcCVBO2XkQWakqoAZFLv8lMH2DEdiBR7+SYnIVFs3zNFTz7RF0XsQXNwceHwlHRFGGxWy/iO8UvrR6LZ0@nongnu.org X-Gm-Message-State: AOJu0YyK6KR7Fg4q+DPgvqRnIQQTuIWL6egr+eYBJ9Ktae+dluwaBRQT LWIORgouBOwY/VipAZMZLHO8IiAcS2VP1p/vCStsi/ThtKip7j3RjFNLRV3h0InudQ4= X-Gm-Gg: AZuq6aIZaTw5920g+S4/kUlFs2Fn8fpfnsd9YT15IO0u4VPPIi/VhOCZfypn74n/88P u+fyIWtHjNu7nmwD8uYYA56CjedKkqVy6EeujI4FAnljfVstfMn1GzkH3x2Zi32W9VqJTf5wgbi +LK8TMYratoAyhtrHTzZsxEB5f9JYJguikHQUg5bTxoToR4cFRtl+YzJonc5uuZZ/OlSEvw5HeQ Hf8pqwRE8ppLi/NxvfW/n9tCo8ZyonHi9SwchLJ11dq6+TdUh40AkdAxC0lx/hplrTUEgOnykk5 kGJTblplDWOPnGIY89TjMpSGTcnrICN0FXqZEHvVVW8FGdrlYUMZZsn6kb49Wpj3UQ8xgrVllqj DsTVQF9RTIc69fMCITYdXQY94p0cqCiAv5VcRYlRXqn9kvMez1x/4xPVp9rNbJrSgP2M6tOXg1a j7u+SfE5Fxc9e1tyvYT0qXBfddeXdA9h7pMs+EwU8XX6SqpeyGHS5XbmW5BA8C1JI+A5u8SU/Yr 2Yk+VaAIruOvwvdeB48xlSaMte3CwvSeeGmXd3hlw== X-Received: by 2002:a05:600c:1386:b0:483:887:59b0 with SMTP id 5b1f17b1804b1-483a960c879mr192253665e9.35.1771866190910; Mon, 23 Feb 2026 09:03:10 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 50/65] target/arm: GICv5 cpuif: Implement GIC CDDI Date: Mon, 23 Feb 2026 17:01:57 +0000 Message-ID: <20260223170212.441276-51-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -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: 1771866783560158500 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 --- 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 c830938bdc..02129d5936 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 @@ -572,6 +575,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 @@ -629,6 +673,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 Sun Apr 12 00:56:26 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=1771866514; cv=none; d=zohomail.com; s=zohoarc; b=P6da9FRxtbgEpcHk4x27xHq2M6lOiklUqq+vPC0/hw7W1VDNKlINPkwFlEQUDsbiEWxe/UkTEwcuO+xxvh2pXbZICojz+8QlCFH0Sz9VGGWZr9hyAwDX2jwZtWXlmW9z9djv3LqI0kGq4iumPxQbV1a91y07ooCP4FmKdn4a6Hc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866514; 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=LsWZT0xdosvafwLgM597XKJG/8r1Q60yrGNVHaliPSM=; b=k8DhftIE7UIsw4u8QjXMl97w0rKKOqYwXDcLcv8VwaRVMK7dU4bdGmHdsjfg42JVtnCOg2+zYzKb3eyh80Si4rOrCExqzh0CZQrcg8VYzMA6l9BGj4EFksMRucBSYFdCG2bKbb0OxVZpHwiBO4cKmjDcZ4cssE9HY/E+m1Bi5bE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866514731550.6848148149414; Mon, 23 Feb 2026 09:08:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM2-00040G-LS; Mon, 23 Feb 2026 12:04:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZL8-0002lh-9P for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:25 -0500 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 1vuZL0-0000Ok-V9 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:19 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-48370174e18so24815575e9.2 for ; Mon, 23 Feb 2026 09:03:13 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866192; x=1772470992; 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=LsWZT0xdosvafwLgM597XKJG/8r1Q60yrGNVHaliPSM=; b=Fn8guHR19VRYYlO4Y+MoLw6RY5yx4U+o0urK4WZVHSZQljEhZaOL8iqcA/MfY7tiN4 y/eCnoEDIDX3WDAx7i37p3qCGqLxTolENKIIMlsNYWFF7YZrQfZJAcW68iCifP1Dp3Xs VlQ9VcVAj8zXB2Xv6KkTl+lx9ec/9+JlMw2ILezlOfrFM3b6aOME47da/7PxPAkJqTOW FBwTDjNsicBphKl2stvsTeTUzaXrBIluoajaZval1trBW3YdbiZh7WaOjzAsevuJVaWh X61orN2mviSOCPdN6qs1PA9XBPG0+AgPKehryM3to1IPQHS+zQkUY1+sL1Rgzzr/xK02 apYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866192; x=1772470992; 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=LsWZT0xdosvafwLgM597XKJG/8r1Q60yrGNVHaliPSM=; b=EeLc0ggxh0fDzs1wrpj9Bo/v1OBNzjzcnyttcMTfsus/m/DkcSb2B8FaUZy3Wh90eK TAso3OCGE2Vng+ro/vRaH5FcdJ8IWUP/nPaz+S1IjslBC4epZxmharEw3EQxjU5OytlP ZOu8SDBdA755rQVSCLH0R7CW5Jfl0C9gYFUqcedco3DBt20bDlBrbBBJ/SVZDA0So984 vt9Eix+MlhSOWWPUnUd80wWH3QIUOS7mem0tHsNEkGYNG5P7pvvyjVj6WMl7lM3mvaKx hhXvya9bizmAmpqNueFrWh1WUq6oq5jWYGsbLcpQpXMJdYFhclSh5ljBaqR2yJhsKTA+ 5Owg== X-Forwarded-Encrypted: i=1; AJvYcCV5nUPV+v9EU9nFYgS5ve8kf6zN1q/T6hGQ4JKCo31igt8Yro7w/aZO5CxR5jtH6PtQXTXwZ3Y0ODx2@nongnu.org X-Gm-Message-State: AOJu0YyW+oVSPAZcFSKzJVBMBdvbWXnO7851dmpvGsiBGBT/5iiUKbdp w9MGUX6enIfryeky1Y7XXHWO3hk/riOBRRm4rH3Nup6jyhAPXga8CXZe1T11FGNiu7g= X-Gm-Gg: AZuq6aLjQiq5djWo/FayDtj+CtaOrbpSipu439L2+HIL9UjNfy0ocJYlrGrWQBWu0Qu u1JDjyfO/OcSMCDihXzpjl+zROalhO5EcdQvygQi6Iqa70gQMO9ieaweG7mGtSLGdSKuJSYN5nG Fv0t/4hTUUYj9qugGsQxd861M0ZNsQjR9i1dZfdvEccgHubvPKX4bALInzhiUvg/OPWCSTWaRwp McewrCtgEkjWluXg2lRfIu70UYooDbhMIYWuJXjTKx0l8UhhUEklR0LvzCw6OJ7KarEDkeiVqNK 59pfzqiaGfiWWi2Ld+9122uRSDvvwQqIiUt+vFKHaUtOK97VmWNzgVxnJOAegiR6maF/NvWepMw 2JkgeAXQIIYIinwr90Kww+P4c1oUFC3yzX6CpheEt7/QGN9W9UcvagAcP6C+Uw7KRJQS+8qFvu9 Ug7XdZGYvJTuM1lF43QDnuytLuezV9wgiq0ZBvqPhqr3wZiGBOvfLv7Zw6CNmtL1Zj2jU0/wkem 6DHLudAF89CJdPETLPtvDlCGgezOeo= X-Received: by 2002:a05:600c:8b01:b0:483:7f4e:fef4 with SMTP id 5b1f17b1804b1-483a95fb1e5mr166585915e9.25.1771866191807; Mon, 23 Feb 2026 09:03:11 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 51/65] target/arm: GICv5 cpuif: Signal IRQ or FIQ Date: Mon, 23 Feb 2026 17:01:58 +0000 Message-ID: <20260223170212.441276-52-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866516042158500 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 --- target/arm/tcg/gicv5-cpuif.c | 91 ++++++++++++++++++++++++++++++++++-- target/arm/tcg/trace-events | 1 + 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 02129d5936..79203a3478 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -171,6 +171,88 @@ 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) { /* @@ -220,15 +302,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, @@ -431,6 +514,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) @@ -573,6 +657,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 Sun Apr 12 00:56:26 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=1771866811; cv=none; d=zohomail.com; s=zohoarc; b=bEZaogKq+mHiRdDl3FqTGOtEnFprPFYvpVRf5/rg45TLh+hHnrtiHXdGrvGWR/fCoUHCYSaX8GLvcukj7ry2zo/34+6QA3i69SDZWmoxVPUjNuFFwtXXpSOu6y9f5W5mXIi/jBNrAXQMLO0S1EStNiTZXXScHXZ6gqO9gClYIdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866811; 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=XMQWuPhIDut2O0s+aFZoLKQHJbGUaVGr5s2jDaUa4BU=; b=CBL9gwrFlq4Y/KrLetC2veoASmjdFwISy3ckhwE3/6Fco63FF+jd+7Chbg4zShVME5kwarOxLaQhASE2V/w/TZx28DCFfwxdcO4DZ7n76wT+VzdD0UHk5WFIV8uhn0sjbyZ/4aywSanmLM14naVDLMkhZ4IMp/HSqN87bd5vV74= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866811820448.10167536259496; Mon, 23 Feb 2026 09:13:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM4-0004DU-Ig; Mon, 23 Feb 2026 12:04:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZL5-0002l7-3V for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:25 -0500 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 1vuZL0-0000PL-PV for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:16 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-483a233819aso44127035e9.3 for ; Mon, 23 Feb 2026 09:03:13 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866193; x=1772470993; 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=XMQWuPhIDut2O0s+aFZoLKQHJbGUaVGr5s2jDaUa4BU=; b=LKJO2Xt8hZi3G4xEAUQfWfD5rdN1ZIDhlmIyEokYPLr08IDkJWxqqR9pt2tYw4Ig2f 7/Nx0PxLbwuhybt/6TaSEcUTUIHqnvde10p/SpwQ7aYLo94xF2UOVjIK9FIpemDO/saH PuIpBSX6paY+f52w4Fagu18blxkobnVXDqa4K8fBBQPZgJNuz7Wqez+ZaYzIvsuOdhU1 onCNGV3/AVKAE2469ble6Zuc02UuqBF9WWfwMDz/0y+IrBhUt1F9DXgjBusDhg+pMGG8 7arwar5qcTnS9DXmBvfK67+L0+twVXsODnacjTQPHt40KHO+9Q5yci+mWRiwZwt0OlxC jExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866193; x=1772470993; 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=XMQWuPhIDut2O0s+aFZoLKQHJbGUaVGr5s2jDaUa4BU=; b=BfU8wYaht8mylzYyNeyX542B5PlAJEJKx6rwA4AW4mh6LOV3PqDc1grg9/jnGFVIT0 TpaUeoguZVI4hyMupQedIpjoyAkJ288zwJNUvBcMXN8eSVxfq94+f++p6yxhi4ZRSGM3 YXkO4gv8c6WnXSg6TW3HM4oZ5pCda0/aboQclsPbd/pRVdQphDkL8jWQbJuIHQO9diDP NNkWI7PV8AXzw8ffLf0+Wh5b0p7czXcuc13+QknVuSuibS0shf2n/mAqWC1YKiS1G0dO 4ysNogFWpf7L1+ZhVv4wr2KuLBjkC433poZ2PAsj9ydAtLBCoJg2yAwOQyss5OwgzD3G 5zOQ== X-Forwarded-Encrypted: i=1; AJvYcCV1qhz9xF42Lpqh8xfV7dHBDMXrzhC66u5BYhzEd35Ihz2mQT0zzhy7vPhCpPy3OpjQuqexlBn4OLsU@nongnu.org X-Gm-Message-State: AOJu0YyIucpf53P0fUYpd3jor53Ao62mdd+ByIOG3yBgHhRwu8KNeLCP J2PtG9UA9KNpMxjUnLLt5fEJwX7k8KjEsin5P/TTSiuqWdJfvQLixbcWia6oyThuXL4= X-Gm-Gg: AZuq6aJ9CddRfscjQp1KgOpR6qRRvw+7tdKDuTzcd7R6mCKcxKXz9Yx7lo5WHEdKfJh pZ73xIJ9YNis3EPhZkblmrxbe0vfqXRFUOyTWRPeA/P1hyxBPGA07IDPeSd4uQ/c69xtsn96+mg PiYmtPR8NPS4lJeK1rjqn3A1WLW7Sx9/lzd0Bu+l0P3aU/SMEARAhV7Sogea8AEVSGBJi/ikDC8 aY9+rZTd97RTeBmfvuyQKm5bpkrjojokIVlNfJQTlX7kNOt2pA2HaPkG4GpZtby0r7O6VqncJW+ AP/sCs+0Onnpir47g6h9XGbkjF8otF/73H6JIv+3eUBq+EHmkxTMwOfPHeP59ExIVPtXPuToMG6 0CvT92EnRdJnir0aVlx4uIGDJq6zh9CygpHWTrq8HfiCnu9X7+xFmLmaoZKmNOMUJi7QtP8ABfm n/X8UkNzymS8jgWLZWBnuJzGmt9q967ySWYOeCuh3K6FcOaunMcP6SCs9dHYr+aUCqTp9jDuwTc FbQT3Iqzxx6A5T7q+Sfn/K5oSAZgbBpAoHm8KfVtw== X-Received: by 2002:a05:600c:6298:b0:477:5c58:3d42 with SMTP id 5b1f17b1804b1-483a95fb23amr149700365e9.10.1771866192729; Mon, 23 Feb 2026 09:03:12 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 52/65] target/arm: Connect internal interrupt sources up as GICv5 PPIs Date: Mon, 23 Feb 2026 17:01:59 +0000 Message-ID: <20260223170212.441276-53-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866813809158500 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 --- target/arm/cpregs-pmu.c | 9 +++++++-- target/arm/helper.c | 20 ++++++++++++++++++++ target/arm/internals.h | 6 ++++++ target/arm/tcg/gicv5-cpuif.c | 28 ++++++++++++++++++++++++++++ target/arm/tcg/trace-events | 1 + 5 files changed, 62 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 5e7cc039aa..a6bad8eba3 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1348,6 +1348,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; @@ -1366,6 +1381,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 9bde58cf00..afe893f49d 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1800,6 +1800,12 @@ void define_gcs_cpregs(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/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c index 79203a3478..d30617d143 100644 --- a/target/arm/tcg/gicv5-cpuif.c +++ b/target/arm/tcg/gicv5-cpuif.c @@ -314,6 +314,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 Sun Apr 12 00:56:26 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=1771866784; cv=none; d=zohomail.com; s=zohoarc; b=AjYWbZEaSJbA6LpG2ZoZZdMrtQJ4yshwkk2S3rb75kwh+XTSIeo9KmXDTXSwpr2AZP9M3D170xhVIGAFFKwPFHXN485B/xgG87JVNSBpzrp2+VzMEmIZ0dMk8vLT6pswIDMtfjZtj5yFEG7l6lMe7gal5b8QnuT8ZQpi22B2fGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866784; 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=Oc4IQYy6jHc0YZ0doMPC3fB8hIXKqwZ6F4RE9AoioM0=; b=VNsgmVOIqF6uYagwAOvIcgHuL4pyDQmpMc8y0QLLDt7i+qnQ7vZRnvoPIarN/9wDsP0dd4Rk8E6uHdj9gLbO8FRo9MWvy1N0s05XGWQVqW9Zivz071WITQ6QdKNvVOM1ww+cP63c5YHJZ7BA0LPiY+dcmA3p6/9a6eu+durvgr0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866784067940.3559213222322; Mon, 23 Feb 2026 09:13:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM5-0004LM-BH; Mon, 23 Feb 2026 12:04:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLD-0002vD-Vi for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:32 -0500 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 1vuZL9-0000PY-Bf for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:27 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-48370174e18so24815725e9.2 for ; Mon, 23 Feb 2026 09:03:14 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866194; x=1772470994; 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=Oc4IQYy6jHc0YZ0doMPC3fB8hIXKqwZ6F4RE9AoioM0=; b=Z+4NqwgNKHwCgXFwfU/6FvdMfunw6YwossNC/SPg/QmqpK+w2mSLfb5FL8y6Z0Hgei lB0CcvdVVqboaGLNBWX1aByKFrBtUG0uPep/RKDDhNvvD50njI0rtqR6mFCsKxOj1bnf jbibzy4COdxz1DXVX5q3h/yPRR2b4/t1LNi+GMB9pX+fpEkCjtavxNg2rpq1F4nIhwWW ODhRfOtQXUWwXR567/vhqAecxlCz8GM9Vz799sQsgPMqsRUWhT3DZj8rHD68mVTxthpI PFYYRMeBE5R4v40IqkrC/ALKHuxvnvuMWgjKXCUCqviiGkD9lZwoWaqs/7AiZiW46d8m 5Fpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866194; x=1772470994; 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=Oc4IQYy6jHc0YZ0doMPC3fB8hIXKqwZ6F4RE9AoioM0=; b=UanKQKkh79Dx3WVLLmYiTRlpCXIgJJD5wI+IgTHDOe49Z48D/oW06dzXQOPkxWZf8N LIruLGJp4gvBZY63ocYcRgR9J7VNSofogXl56dLycHbtrAbi9PMCn9eNg2Rhi5ahZx4Q 7l11NLEjY+5eUsxk9qvsTSIhEPssGo+bDlVC+hshkyG82GIvNOoKojnrBAnSPVSc3b0f LOk/Lu/lTwzl2PfNvuoVE+pjo1lHBe0EcHxOC1zk8SJjGKIfxX/ngii2S054mnAh78Ag CdUWCK5nviwC7e6/AZp/gwvPFYdFyyB52VBKGTUYwv3ecZOsA5HKb5Q3K3jEwNRCovkb vXuQ== X-Forwarded-Encrypted: i=1; AJvYcCWlChNZFjwg4ESYXEwAN+hrd6+LZJa+z84Mj6tNXIVMawVasTUDgCvQQRQmTTlb3y5siVD2+CRDt/b2@nongnu.org X-Gm-Message-State: AOJu0Yw2nJ5uWKhSNH8As6UXRvMTqOlB8Dut0j7VgiCL3WFqU1kIHFwX cVrgz7zI0iqM9Xa6TPDhBym18o4OqTYf/s9yUZZHD9Vxtrl1GENd33e+Ku+AAiIO6TE= X-Gm-Gg: AZuq6aKwvE4Mty1a2Dgy7DFHgIqoywio9NOAA8HT7fKlHTFdPUwjwReqgkEb4ZhjBaC RgP/hnbTlDs05Oz4nTN/tq8GZv44Dp7lK5ZTb9JOQouh15hK8MZ+msFBEC4jU63C7UK/jMEs1/Y A3YTh8bxQuV8Mpcd/jWZVHYI4etBzBGCZ4t9+qGdl9jRMXML8kxxlLnD568f9+3Bb4/o5imZpki 0UcbzSpfss3u/0f6VROhG2gsseQCL0mTwdE0ZcuSKqEAmWQyP0X++2d/xdNgW10hdUwh5KV4r4Q dD6W09ZdBbkSNQ8pRqTrveiGhIOGJOv9QKwr696GdYhAXHLrkpuj7PY0naeAUYlTGy74ZciwoGo ++H16v+DbXqudPJilVxL5Ohh33eWdSPlNTh2oY3yMBi0+gK1dvf+5NoFoiiyf/7qAGaqhrLZm6m PSoeSN/4gm+itfcTWBbvZXeSVc2GDcHEjKTVpQsURX4PJxPMDHdAlXBR9CxQumaH5vl4OaaCp4m ACSZwdiqNTHRiHsCzFYCcHF14/jbxw= X-Received: by 2002:a05:600c:628d:b0:483:5a29:9678 with SMTP id 5b1f17b1804b1-483a95bd8a7mr165353425e9.2.1771866193551; Mon, 23 Feb 2026 09:03:13 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 53/65] target/arm: Add has_gcie property to enable FEAT_GCIE Date: Mon, 23 Feb 2026 17:02:00 +0000 Message-ID: <20260223170212.441276-54-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866785564158500 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 --- target/arm/cpu-features.h | 5 +++++ target/arm/cpu.c | 45 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.h | 2 ++ 3 files changed, 52 insertions(+) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index e391b394ba..c0ba56f244 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -1072,6 +1072,11 @@ static inline bool isar_feature_aa64_aa32_el2(const = ARMISARegisters *id) return FIELD_EX64_IDREG(id, ID_AA64PFR0, EL2) >=3D 2; } =20 +static inline bool isar_feature_aa64_aa32_el3(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64PFR0, EL3) >=3D 2; +} + static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64PFR0, RAS) !=3D 0; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 551be14e22..7f67e8ae47 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1191,6 +1191,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 @@ -1423,6 +1426,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)) { @@ -1697,6 +1705,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 @@ -2020,6 +2034,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 651fccd59b..a5f27dfe0f 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1032,6 +1032,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 Sun Apr 12 00:56:26 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=1771866646; cv=none; d=zohomail.com; s=zohoarc; b=U5/T2XefAYTjfQxo/p4xXIkQxQJOwznrpP0bkKfsw3VDbJksENvnjKontmFPGbkgdASZPwfEdg9LwsJtCLj5MyWPbD39XsXHeFf4jGimTpwE3495+wwpCxrOssx0myf1IJiCK0tekjJSDbcY7QDbAghv0l9s1uZ21srwUw7TUaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866646; 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=bURXc6DgG6dev9YjdHqHr0hS90pivhx67OlSlLCve5Y=; b=BtOMOqCGMEI7+PEvmtR9Yc89r1Ajo0I694O/tHDiwUu7mg7O/JL6Lei96bZfITuzKPVCAFZYs64IFXTe223V9n6WKfpJal0cwvX/Owyl2ibYk7qpGSvWLM5ukM4KGKUAbFdBpTmDynfKNTnWWrpY3X7kj69zAwwylhGNSWTI4/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177186664665382.92852335978307; Mon, 23 Feb 2026 09:10:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM8-0004UG-A8; Mon, 23 Feb 2026 12:04:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZL9-0002lp-Jh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:27 -0500 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 1vuZL4-0000Q9-P5 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:23 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4836f4cbe0bso34590135e9.3 for ; Mon, 23 Feb 2026 09:03:15 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866194; x=1772470994; 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=bURXc6DgG6dev9YjdHqHr0hS90pivhx67OlSlLCve5Y=; b=nB11IaeEFXFieX+qXCkPoznjem/GEsMFU2AdKrcdZ9FN1YsSBNWSbw00wti8zdpfvw 2TINHFkzTHxGHoYIlQ1m3TxILcsZFmLB7r13MLaiSVP253p9ATmiJNTo+i8zKd4zGOpH f2bcjotoiSaOIDss2par9XQztHV5bXoN0m77b3gnmbRbrCCY4mgSQb8GRP6n0kadQ/BW n/CfM0tgkztKVvahgoJHeOiCNZxFBV33CeBrvptayIyBTmoFyWMCc2/TSIKt9jG8ZlTs 8x7x6qAPXNhFFTsmxOZOSR01PNK5TbLvAZcR1qhbp1bSytdgonEpYi1E0kAVA+TdIB4V SQ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866194; x=1772470994; 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=bURXc6DgG6dev9YjdHqHr0hS90pivhx67OlSlLCve5Y=; b=Zf47mLRvXiVCZT4faXykirD2WrmC0OfvkzrckhC/xen9uKe19gIiHTDmLwbg3ZbB7r PNDgMPi8y1MT26dNll6R1bj5PYF/hf46ZnBV41DSBFA6BhyJ7r12FKXf4Ko3/R1780GY RwCe3uFa0dgqXpyTnvscDzNdbxxD6h9G4OYGIQdmWay7AaQ4mjGW/VOKeq9U3uTcR/Uu EqXUi8kV3WIlAiMkwLJGh0mR9vPlkahlhUAuczMyI/89alJGfOJKKdBKAH+QdfYSNJEh r0A1VLJ+Dc61DYlpTmvKAw740xAoYlZg+SHfTKmjAXApmw4Lnit76xx5rMLbG1PCBbHd KEqg== X-Forwarded-Encrypted: i=1; AJvYcCVSC/J7CET/32CPgQIoyW/ZKmZ7IiUO7KJ9Z5RbVpeavTfD/mbkZstD3QZI+nACN8AI9BICqxxlLQ3r@nongnu.org X-Gm-Message-State: AOJu0YzGDxIHs3g8/3hjPGsPKYLtGN9/otkHo9SdemLFVMZkvcIH01qV reazRn734iDu19L2n5LCMAP/Z8LehtPtbiqG8h9L4324Qrtl5s9C3X2AjiFBN8lg39uOjnYnh+f eCxrK X-Gm-Gg: AZuq6aLtJkBYvOg4rc5VbMSU5d0RH9z8XWpWSsaKWvkqoZKtnuiuOB3PoSZGxwXvphP nmNILZhGa0tkyI1ZDNT/aKdtOvUS5j74ANi2wp28mkGaYfQFn/NIzw+iVzrgnf2iqLqfoqCYQLb sSiaupFmjsuMqztzO5v79BNcd/YznKK13iEoMuqtp4433VO9iCAqlz26qS1sQO7LxIWRrYAC19S rKgELHD9MvyrW/enfYP+HDDtgiiQRFlGyQMDVe8BfuPAood164gK98b4aDn4QtF/qtm6jjCurmb rzk3zYaB+HqwQBakaiUyqF9rI/eiS3QFTTHQ0kvBCWVMSFZNn9YouXgSCReZeHSIaton7y3jdX2 lCC1G4e1qOB9ZfK1gBQ2N4ZZf/YpoEBiUn+aOQGMGiDXdRRRBTiwXntQtlzb9j2Yl3ieMvKBGBm Qi6cY93nhXSffr09imOq5grkY7tNxo2XfZNbNLyh322EM5iwomj3WLkWEIRjC9ikGTLKl31ELFj CVUyJsRTziWiAh4D4l4Y9R2mcpzD68= X-Received: by 2002:a05:600c:529b:b0:483:348a:d3f3 with SMTP id 5b1f17b1804b1-483a95dde23mr171839585e9.18.1771866194355; Mon, 23 Feb 2026 09:03:14 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 54/65] hw/intc/arm_gicv3_cpuif: Don't allow GICv3 if CPU has GICv5 cpuif Date: Mon, 23 Feb 2026 17:02:01 +0000 Message-ID: <20260223170212.441276-55-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -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: 1771866648751158500 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 --- 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 eaf1e512ed..73e06f87d4 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" @@ -3016,7 +3017,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 @@ -3027,6 +3028,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 Sun Apr 12 00:56:26 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=1771866414; cv=none; d=zohomail.com; s=zohoarc; b=a1/USmOSKUpefb8pMm3QkZm7+q3Kgs0KM74Qz6f2JS+co1yZYd2elrX4bUpJ6zGza45382vicrLkM7PlN0vHyl5EeAb54KBGZzRMUv64HKbnGqklEu62vzdPRFFZ/+oR47rnVxjndjgSEPtLctabn5xReveQQilMVqPoLayTVNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866414; 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=cwI7KECXfXNz5KI7P3D4TAbbo3v+8W/zQ7gFbJfb+Z4=; b=AVuysMR6/soAdfaAiOPgTorIRYlRJdUw3bf5RDfiiBldHTEbUd3q+ftwAXC0x5tkz7wBdlth0zpXUND/3UjR8oFANO209KjfAXIlUhSvhk3ZguVzM19tsYBZ82N+HczFYvldxaJNjiNRb4kgcp9c3twqs3QmIwJTNEzUFO/RtO4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866414939882.1483627420134; Mon, 23 Feb 2026 09:06:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZMG-0004l3-7f; Mon, 23 Feb 2026 12:04:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLB-0002pq-Lw for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:28 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vuZL4-0000QU-Q0 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:24 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-4359249bbacso3365436f8f.0 for ; Mon, 23 Feb 2026 09:03:16 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866195; x=1772470995; 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=cwI7KECXfXNz5KI7P3D4TAbbo3v+8W/zQ7gFbJfb+Z4=; b=oEh9X+SZMbhnsOSo/S09eriZbqI2Tv+F6wJIRtRRpdZ0znaIRGa5ulZ8KSYnKlGpbk xkCJAIPSdmOyELBvheKN9N1KjiT00YaVG4BwRBzPiKQWUInArZ/4S+KuDqMtL7ROr9aC Ys3NoLuzRdFtSamSozVzwkWzkGgVFKl522x5UcVBTBFZeVSsSYrZYPwzyQTB0apu/o8e GRC8tkpTJI5/nhBRal0iqJxeXcQ0XVLa4LaWsQEGvQWIc8vbeb99piVmay6rBx8zIZbL DjKus3b7eIqiG0dhJLcbbXX57xy0cOnNWVaBGPm+08C83C1FHpjNXphrXTGvYZhoPISJ yYbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866195; x=1772470995; 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=cwI7KECXfXNz5KI7P3D4TAbbo3v+8W/zQ7gFbJfb+Z4=; b=HmvMttV8dE9e26nD1NuESqz7P0YBBJlRbs0+ytyxyd/O9ThXP+yrtvjbFwWFqMkIMc my7BhAgFk/YfyhuSacAYWRvnDa0xquwmO/yNus2OaVMYTyuk8hGKi68ZdjWHtN2WI52h tpCHavSSEAxZyt1oH8VipsabphOjPB5T4lh3JsYXiec4lhZWmbm16Wx4od9FI96ySeEp 16sHs44CdsErJ47iD8i+sbXRj5wtoI26tQkIGh5W9Z8kmBP/Xv1mBOp/AavkgjH1DiRM jKlmQZ8JFDkOWBQoMRlPwvk7iCJmAfKfpEjdMeWj/vTMfOB3w862Yy1OO7Xzf6k+UTtb seeA== X-Forwarded-Encrypted: i=1; AJvYcCX2azodbkwCA9GR8rzG1FEL/MVhkqmZyKLxPamL2a8ZJva4CJ50Hl/EasYWph8Qtnhj2OgiPeSeekjc@nongnu.org X-Gm-Message-State: AOJu0YzcB582Ilh21pLPOe64p20BLmvWc6QOwnZncUi2D73Trjl2dOVq lVdA9k8CCW0Q4JfrteeoVnPCGerMPzzY68wD1Tn42KiVXpO7SnnR+je4kdbFdrvRc10= X-Gm-Gg: AZuq6aINQUpC11tyyqYSX356ou9nRvGwTBiozxiExKLAG+0ipRwkRpVepz8B0ScYh2D 2zDxhfdJl465lqoR/GFeeLYYejUzFiAhWcKn2MpjcA6NsH8qJ5RFnsE0QqgiIOweKjFw8NHFWM9 D+TCnUe8GYneIX+6UaPVRETpb70ZGvKrz1C7go6WgvKzuWrFjI28w4McPYlUoFiC4l99202OYDO 8ua0ddL/TJ7kJNTyP3FGw/aO6m1UTOAV9hpm1nHnl+e5q+RFVz/yAKy+QAB5RjcHQlKBKEV/x0g PRcEwE0Vgr4xUJ87W9c4idFi6qsTuanh6HoxKIMFJOLxm44g5crtF+ADdUOTWhwRg1BrJS3Sy23 JFLLsrgHQUiLcASixB26k0CFfIKwtor7ASqzT7DAYtoj32l49S8ISImmpITE6fGn1e7bomiJINn COH4aO3LehEI2UKfyJ/u1AC6Fh8/V2yv8myT+2np3YfP0rUGqr660MVgMIhkPMgfFMIdBcCNPgx kgZdwJUho1hXPmursQXn8egNwzNy9s= X-Received: by 2002:a05:600c:1989:b0:479:1348:c63e with SMTP id 5b1f17b1804b1-483a94c99admr175517055e9.9.1771866195261; Mon, 23 Feb 2026 09:03:15 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 55/65] hw/arm/virt: Update error message for bad gic-version option Date: Mon, 23 Feb 2026 17:02:02 +0000 Message-ID: <20260223170212.441276-56-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1771866415369158500 As we added different valid gic-version option settings, we forgot to update the hint in the error message produced when the user specifies an invalid value: $ qemu-system-aarch64 -M virt,help | grep gic-version gic-version=3D - Set GIC version. Valid values are 2, 3, 4, hos= t and max $ qemu-system-aarch64 -M virt,gic-version=3Dbang qemu-system-aarch64: Invalid gic-version value Valid values are 3, 2, host, max. Update the error string to match the one we use in the help text for the option. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Mohamed Mediouni Signed-off-by: Peter Maydell --- hw/arm/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 50865e8115..8dc999712c 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2971,7 +2971,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 3, 2, host, max.\n"); + error_append_hint(errp, "Valid values are 2, 3, 4, host, and max.\= n"); } } =20 --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866668; cv=none; d=zohomail.com; s=zohoarc; b=Qlvj9c/B9GCh5uOdEhP4/dOEF5b1s2Acd9blwPqcrPw8NhQoyvk8RBUYR4dimGtehGQ6bVmVIKDFiKlTKjdWrRdR5uVAVQFM6ePQq88aVwaE10Py2Bx/GDW0RFLSMHsC1M9KF6VqcVuUwnvXNg72p1pgS5xjc/9xt7DEfDNwTFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866668; 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=mcNmYKDo1AyTBqKWkeuzf3y95VGP3Xb6elYJJZdrymY=; b=TwMpzOSLi0Jv0/Zl9WzY9ivE/v4AUNzYiSsICaKys6GVhKmeq1Szl/umfXUIc6CJcpwFeld4YYsznqnM7LRMThaVpFeGm+j5ESs4Arh/ZyufYA8n0bIAIBxUBuBVntwPJ86UorQf/vU0A00IWIq8BEhvXf91MpH3P9Fqt9qHDJE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866668631288.183314696171; Mon, 23 Feb 2026 09:11:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZMR-0004sM-KG; Mon, 23 Feb 2026 12:04:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLE-0002vf-6b for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:32 -0500 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 1vuZL9-0000Qt-Bx for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:27 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-483abed83b6so14153015e9.0 for ; Mon, 23 Feb 2026 09:03:17 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866196; x=1772470996; 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=mcNmYKDo1AyTBqKWkeuzf3y95VGP3Xb6elYJJZdrymY=; b=Lqw9RkMTnO/iJLUNOj5EV/tON4t6DPvUzAd58+uuM+W0AQhO0YMGw+qpe1GKi5NxuG 0XwsqlMzTJeNd1m0Xt37vCVM6gELFCHU+Y1EJOysaSB6ZtW2pfWMtSDAtglYGSrG7nQ3 ZvSb6LfzJM+Fa/zMiQo46nbQSETeq1KdUGBrL3o+XIGo+WHHSAt2UOkdRH18Dq+EHOW7 Frvd4DFqFRRZuzW+Hem3JS7JvyNDSe1UyE7cXWfvMSjKnl7NLJ8pjZ8gCSh5e9V6UMdT 7lLWhgG3E0uALPKfjZVKiC0Va93Uyy2V82lDX9RKGpYbsC+Z/Ohn7IU43e97lcBgiFe4 +33g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866196; x=1772470996; 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=mcNmYKDo1AyTBqKWkeuzf3y95VGP3Xb6elYJJZdrymY=; b=UXPr3cbd+ogQxXRb7tLPC7K+75DmW9mg9pUeB5XIXB62LThac21I/PszypxZutvRyT n8WpJkGqzo2RlxByfdfHXj2rWdO6aycaoJ/oQT8xhbvBumamENrUQm7dy/eklBaArXs4 +JA4Qw2zBxd+wVhMP9Zb2g5EZRDe/rZ2sAMYVwA3ARght+5BjHoBjVKnTdE6GlKerEBz HFBjTtQdqx6fCjpEnkmhdpe9SWodrjDQNJ1Xc0GYlTg0yYCd2vbBGS/+Mwz44lDPbc4l FnqMM3NtAcKxlMMURbkc3pEkM1MUUQTGTwE8JNfKrgWnNbZm/UpcIyyFPXTrUa3lYMql lqFg== X-Forwarded-Encrypted: i=1; AJvYcCVRWZOiacMFr7tANXUEyZK4nDzMb8LuM5QnkVmUMTL/6lgBfyMO3EUoNSQS2HOyyCCj1OUZIvvNgHU0@nongnu.org X-Gm-Message-State: AOJu0YydvJ4pWh2/Q+auJmj60SOqDnOtc8PeDoh1ByJKKWJ5vtzSteSm giHjvfyUphBql0P4UZUz9HiJRxhsQIQmDjDwlMMq+8kzVDbVR/HNPYaDjzSzs+k2fFg= X-Gm-Gg: AZuq6aKHvGliKdFT0hSx8mM6geUNAhZAsKyF6IBqNjQ55Z884FA+HE1U/1XK6Ns0d7v X/ukVlYC3m9sWRZjD2GDutOV1QKtg40Mdz/CU2BpJ6dftXCgpTxrZfTfbKJHMyFCkuB2LgU27NT PZzev/AUOSNR6siI11ZwQRoBs10x+a/L9Q999+hruyewOSiVTBp+gvasjQ5wbZW5ldkwmH68tGr eKKmaeNaVhYwLeUfiDbPrCNncNytv+ayjAuY+4mW4AVVhmDMo6HcL81Qqrs4bmujqtH9rInqREn syEraQo0j7Q+75FumytbJpqj0TiBFvjqDGhCzgB6Dv2j+MmaGR5gKJuv4tlbi4k+xCmiDlJ3YJX xKQ+WT6ISkwrzQ0aFoxjSk0gTSIrbpOltmXDt0FuWCezV/PeHwXJmDHLKhfhSfojQRjXWvNCZ8B 2n7qRvHbsyEz45XsRtCF/nLUZult1fiwrNFHk1vkForZdnpTrlXfdY3eqvjPFdfPJBbPRzJNKsu 4a5GOYdXVGzc7OuG0CeYsJmIL7yvwE= X-Received: by 2002:a05:600c:314a:b0:47e:e2eb:bc22 with SMTP id 5b1f17b1804b1-483a95b3e62mr166806815e9.5.1771866196245; Mon, 23 Feb 2026 09:03:16 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 56/65] hw/arm/virt: Remember CPU phandles rather than looking them up by name Date: Mon, 23 Feb 2026 17:02:03 +0000 Message-ID: <20260223170212.441276-57-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866685766158500 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 --- 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 8dc999712c..0d1032967c 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -432,13 +432,13 @@ static void fdt_add_timer_nodes(const VirtMachineStat= e *vms) } } =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 VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); - int smp_cpus =3D ms->smp.cpus; + unsigned int smp_cpus =3D ms->smp.cpus; =20 /* * See Linux Documentation/devicetree/bindings/arm/cpus.yaml @@ -466,10 +466,13 @@ static void fdt_add_cpu_nodes(const VirtMachineState = *vms) 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--) { char *nodename =3D g_strdup_printf("/cpus/cpu@%d", cpu); ARMCPU *armcpu =3D ARM_CPU(qemu_get_cpu(cpu)); CPUState *cs =3D CPU(armcpu); + uint32_t phandle; =20 qemu_fdt_add_subnode(ms->fdt, nodename); qemu_fdt_setprop_string(ms->fdt, nodename, "device_type", "cpu"); @@ -494,10 +497,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 g_free(nodename); } @@ -522,7 +524,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) { @@ -540,10 +541,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 8069422769..6b4691761e 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -171,6 +171,7 @@ struct VirtMachineState { uint32_t gic_phandle; uint32_t msi_phandle; uint32_t iommu_phandle; + uint32_t *cpu_phandles; int psci_conduit; hwaddr highest_gpa; DeviceState *gic; --=20 2.43.0 From nobody Sun Apr 12 00:56:26 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=1771866454; cv=none; d=zohomail.com; s=zohoarc; b=DN8c6QZGV2UPg9k5hkKyW3j7AyTrfTpLWF4n9A0jMS+QGQTuCCNIqARTfQJSCAjdsSeqUeYTPA3nOuAYhpj6+pwoviM3HT1gxZZ33PleQ8FA9O2T97AsNXYF65kSahMudF4pTp5+YhUv7qnJhWdd1OqgbATjeVOYz26oXdicRS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866454; 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=Aa0SLfc8fXsQ713SAbRbmhAS+wd4hTaQKfR4EPdmzFo=; b=KorIBPWGY1x98X6KZK6vPThOM14fj+0/D8Tjfiq8+RHjfP0XsVhwVyPafcJomXe9omzESI+n2XLk2HioRt/NhkhneHv6rzE3ijiIA+Cz97miF+UTlUDD7Z4u0Uly7W0Cyq6C4F1fVywd4/MFQ90BEnpWEl4dfTO3+ZDNcaHDs40= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866454733449.72940529659957; Mon, 23 Feb 2026 09:07:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM9-0004ZF-58; Mon, 23 Feb 2026 12:04:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLB-0002pj-Kh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:28 -0500 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 1vuZL8-0000RD-1b for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:24 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-48378136adcso27657965e9.1 for ; Mon, 23 Feb 2026 09:03:18 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866197; x=1772470997; 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=Aa0SLfc8fXsQ713SAbRbmhAS+wd4hTaQKfR4EPdmzFo=; b=uzsPBFvtVqWGzJof15XJF9AexqPBKXN+S2i9eHCZXyFkYZTE9K2F9LW5ebksM5ohYH Nu9S5XAy1NIj7Riq0j7Zav4DLmDzJzi/hlkIkKnmlnTH+X31BZWokTEoXcIR6IVZgAJ/ jv/KtgHXjymVrRaXuVRx19erLt99mOpgZ3vRiGFPnIEuZgSucIKlHjfndgtF2lpoXDng ezUo8nY+cMlLC3WPjRtjJfoqnP1V+7jOXy9NrUf5CU3FoCws41AdirKMr1JvyrdtdYv6 MqHHJN3lhNIa0IKV96VVvH0diOn+29U55wFP48192D6jb8PC20N5iKkuyPsEp4/qWEtJ ipTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866197; x=1772470997; 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=Aa0SLfc8fXsQ713SAbRbmhAS+wd4hTaQKfR4EPdmzFo=; b=SKT4vpZObEtOHeqszEpBBCgo0bMAzlT7xSdD8YIxS8acjCLnqThcnF6IjIWIS8jbs4 4OPXXC0H6NXypTWC1h2EAswGjE8f1n+cY2VUZO1GWELRNRxRnKbOsb1TQ0MPPLtHBEyN RTVslxdujauXpvpg86M2z3yzL0icdWd6EleUdBh2a9pYRO4mOjcjuMVvFm72ZfbLlRA8 ZAJymm+ANkO1FVzvYaHblulp0GixO2WFgaW16dUcvNEjLDoTuLvpf/SV0fxq7p6q8RN6 mCiqc70Mlr+la56gy0yGAuuh8eNbVP+zXilhWkYJRYBoCT+kZbJYK0XeWlvLTosOks1l jaaQ== X-Forwarded-Encrypted: i=1; AJvYcCXNYMZ/Xyuo/gtNxWWyhY/f0BsZd1qe6RCj4WvKDLl90k76x2w+qYHn8FQHByD3U6PPqNTQs6e4MS5P@nongnu.org X-Gm-Message-State: AOJu0Ywqvsw9btKfoUIjw7CxsoD1ABMqZZ7lwoEflHlvWlvQM+EZUfnf EPgZrIqGj5k9grtDpvyrLT7f18J0c2E4b12elo3IhnVMC8eMXTTEsTwLlPNV9lA6hY4= X-Gm-Gg: AZuq6aKSNolux6q49FR3ZI2g6qPuOetFubY/f60K32wW3AexfKWu749axMJqE/tIhUQ TWQNKqhZAYxSxjZ+5MaXpTGcktQ80vRXppNaoSpaUAqD1ew3x8YWMvu9EU7kjOGptF+I/nDjKxr K3f8c2rg5EaFVlZirFXryTS1ZmHNfNPr4H3WawUy0WaWSa6Qmaa8NbVV4Do2JOsr8M4EQYfyYhz SEIZbGu5gKw6LGG6VazG7VlhJYia5pst+zDYQEPzcm/ppGu+aLy/KQ0MAlmyG7id7DcO4n1vach zjl9DdEW6tuVCOHW2FFhk7+xr014fH75bhdKYzNYgJv3X+CIpSccsBF1SyArJ95zZHhZN1yjhKo OG7q0zQ37Ms/gqLUVCRExrIyIgGqD7Tg++mzbr8r/l6I+hZYYP8TMGkAJtu5pGCFNREFXMnryxl vtPQUsBzIwUTt+Jm60oBh8yqLP51pQ2mFoxCs9sYE2CkaqG5b3DSsAmoWzGL7KzHzzGJXD54msL QO6yOmiSPlWw2qJRZ4Q9wVoJwOth4c= X-Received: by 2002:a05:600c:350e:b0:477:2f7c:314f with SMTP id 5b1f17b1804b1-483a95f8af4mr145935825e9.10.1771866197155; Mon, 23 Feb 2026 09:03:17 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 57/65] hw/arm/virt: Move MSI controller creation out of create_gic() Date: Mon, 23 Feb 2026 17:02:04 +0000 Message-ID: <20260223170212.441276-58-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866455622158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 0d1032967c..3c318680f8 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -959,11 +959,21 @@ static void create_gic(VirtMachineState *vms, MemoryR= egion *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 @@ -2515,6 +2525,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 Sun Apr 12 00:56:26 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=1771866520; cv=none; d=zohomail.com; s=zohoarc; b=nP/ktGjDfwqWf9+0Zy8U3pwdAKtFupIerEqF7ho/TS8TK89AchxwLKMumvLVFTtJa3MIcNtm+KYjCV0EaHgn/rXNxhB0OGbjm6mGidCYRcUmZgCjd54mNTFJwSHGFJwOShxSaK5eQYXVfk1LR+Oam8fKk2ypMQtqsqv1C6v8L9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866520; 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=KnSBbwNAJz8jvmrJ0U5ORYLe/Et4GkGyZ62fZOOX4tE=; b=SegosGaXAN++46uro7+PjrZPf4oaP/sI3NLv3SoCGidFeDO6mVWJyuaS90DFDR95K5D4X7tB8ru3UaPadj4ECTS4XhtLbLFsMclWLjckTwomSqWac9xnvfj0HpKWP4UMd/N4ppk30ha12JzHeKj//HifHZa2lb9CsvSG2EGLpuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866520138271.3687462704264; Mon, 23 Feb 2026 09:08:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZM9-0004ZT-4l; Mon, 23 Feb 2026 12:04:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLD-0002uS-Jw for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:30 -0500 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 1vuZL9-0000RO-BX for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:26 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4806cc07ce7so43136025e9.1 for ; Mon, 23 Feb 2026 09:03:19 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866198; x=1772470998; 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=KnSBbwNAJz8jvmrJ0U5ORYLe/Et4GkGyZ62fZOOX4tE=; b=myLcHvwpthYK/PxRjyWYj2RHt9EYCuIKvkdaLUoqboey1pvRsClSJT/HdEPsbyQ0eh R+2iMl1eWyHnRopwnuG18vBSr1TBLiRRfc4ehxBCz8Korst6ukkLbeMf0YIjqbH69xdX jdACsGf1ziu/yPAkyP2sWnzifFoQ0kzDUiMY37XgCniPfHETx76/FCDlofqdV9iLQvGx kVm/suvGj/NjxRq86oA/DaSVILiIl0jg7MayrsVTzb/MN076W5pDTBL/Gq9BzQuijxDP Nvno5bIrjeQIsk3ogFHd4+h6Aj9XbOVoEzUA34BW/ctj0OK0lbbf7+2PPUewTRHWtDSE NrzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866198; x=1772470998; 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=KnSBbwNAJz8jvmrJ0U5ORYLe/Et4GkGyZ62fZOOX4tE=; b=NEGUtUM1fAsVcR22JMY4K3VaI6L3c12TikZUsHE2SUkm4raZWW6hEJ4/bcGjOTb3ah XjcIohGRgBwoCwK7arnvnlp6820lt6IruRdU3onJ1KMzlUDlSnW06eF53GrbXS3vAPR/ SFlCDse4kIMa8AUc8tbK1AdeGVTPCHfs/rpwU9NtuM8vTYerL5csl34/czmAOX9eKzQ9 7kWE+ekiHMhdHVgr47gmL9rCoDVyJNP1onuxQp19K+A3EoCenNM5voemh5mBUTG08+zU MhH1a+fa5UwJHUOoBaSmwCBZ0iSe9oPLNSrWOVHcOLth9CM/iINTpadT48c0YdCTnoD+ m/8g== X-Forwarded-Encrypted: i=1; AJvYcCVfob+KLcGWjVLsmZuwHbIJVj0kseKYduZbUXsG3qXmNx4Q2Hwrr67CmqpCDSzGNR/V+1/srUgj1fgq@nongnu.org X-Gm-Message-State: AOJu0YxFY1dHpkuHBZMgz2KvRIW4w5Gu2ebizQwW2VX7Z0dqTxwTjbJG nBSVcxS9z40LLli2fxohGRSZa+r0bi2nLYwmcKzvrnJaWJinzJkZpgHxSJwl+BRz/FB31xgB103 Y4Hnv X-Gm-Gg: AZuq6aJ21MGkatkA0Fi0TIr04N+f3TUWcsUGBs35B3zDAfwIALRz5nORI/vSEnECvD8 4PHCLk9AhsSCq6m3jHuP95YsZCcLuxzbct3gKwkWgjyG0v+40Rll0JkFgmIjBeB9IaSgAc/EWaD IPsWw/K88MizfdDFBJPpVL97NrQweiXZUy0/utTzwYmAJ7nQncFwgQWLEzF9ru/R9HdFYdQdH8T FIg9W2LnDAaZr/cSP2Qn/zmvzYChbyYjXwDDRnO4jmDs3pKvVcDSaNUAdbM45zGq5eXS9jCoocU HdOPjn/uaVu6CXa2XYMGAfgE8BtFsKHb3BcpS0DpqS58j44Aasx5PL5YG35uP/f1xxWDgMhqpd9 raK/pD0PS/Du5VUPlrgJpHfFj5TX5dYH3b2cidj02rz/8NeuCnvpW1tQuxyr51hcdaj/2Ir9U0Y mbNy4wlQD0b8oWVdYjOJ5qfkiH4/y1QKUSYo1goSPbzgwm0mNMXiW1qX0Ga9VtqIb91KiotOf9O A4zFj8FaayK+QZZQA5AM4owBpZncJI= X-Received: by 2002:a05:600c:34cb:b0:479:1b0f:dfff with SMTP id 5b1f17b1804b1-483a95bef2amr140499275e9.10.1771866197972; Mon, 23 Feb 2026 09:03:17 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 58/65] hw/arm/virt: Pull "wire CPU interrupts" out of create_gic() Date: Mon, 23 Feb 2026 17:02:05 +0000 Message-ID: <20260223170212.441276-59-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866522045158500 Content-Type: text/plain; charset="utf-8" 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 --- hw/arm/virt.c | 127 +++++++++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 58 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 3c318680f8..ec6e49099a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -795,13 +795,80 @@ 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); + int i; + unsigned int smp_cpus =3D ms->smp.cpus; + SysBusDevice *gicbusdev =3D SYS_BUS_DEVICE(vms->gic); + + 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)); + } + } +} + 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; @@ -900,63 +967,7 @@ static void create_gic(VirtMachineState *vms, MemoryRe= gion *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 Sun Apr 12 00:56:26 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=1771866464; cv=none; d=zohomail.com; s=zohoarc; b=kUwRCYKf4YJWzoNCOeU935YG2PVpypae+PUOfbmNOPjrn4D8Nib5Hwgb+PlcEUTPoYMRTjMjOkROMTXXEoU/N6hJr69FRzZ3nY4gmGpYiWAtoL3XsPvV+xWplKGbRdphZKTezaSST4uNpm2dVwZy91bHMvAlqKuBEQDL8cJwvVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866464; 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=CoqKRxhjDS2lI+Y53YNGJHUzkXH7stjgCG6VH65poHk=; b=Tq8Ne8zmrsvu5THWcjsSmK7muW0bj1jJ9c3yO3QaLpy79OTjVjWuPTmHmlRlXO6rWC2FGT/bm8SquTeYdTqslUyrach5dxGrefqAANEYraX/CXGVcUWIX/6xk6i6RIktPoWhE71njQ79eKlLlSvE9eHw70hFyAg5pVrRelcc4UI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866464149303.12615820752785; Mon, 23 Feb 2026 09:07:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZMf-000553-Af; Mon, 23 Feb 2026 12:04:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLH-0002wt-3z for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:32 -0500 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 1vuZL9-0000SL-Ta for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:29 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-483487335c2so42254275e9.2 for ; Mon, 23 Feb 2026 09:03:20 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866199; x=1772470999; 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=CoqKRxhjDS2lI+Y53YNGJHUzkXH7stjgCG6VH65poHk=; b=F7ORHXOGcVAMn2mLE+XsWIulVLu8F+QSWyH42y39NYs8/qmEVI0BakE0iAb0r2EwQ4 7Y3xc2AkSpAqMhMNTaZ4ncl8UgB7pP+hlX+eavOJfr9x3ERiYak3TccNGzZD7oja2NP9 ld8fqQAkEOvAZF3SRKWwf3Dd8J9yz/PKrwuglm5ATfIr/WT6rznOboJi0GYhQUVWOOJ3 RyE+XPOwB1Jjqt6NSrbajK8BO4dCKtxk1SZRe+XVgbHpNtWWmZ6aZJS4nhBb/UjfDSuR MBGMlF6jZhYGCogZpeHAMgvjkF8uKWzwaMHIR40zsMVkSb9I+3NzLC7t4TBDwZUvZUK0 y4iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866199; x=1772470999; 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=CoqKRxhjDS2lI+Y53YNGJHUzkXH7stjgCG6VH65poHk=; b=vX2Mu+umvqwfZQVtfXVK6bkNRcqHo/QZIUGaR9NsMWAdvQfzKn9oGq3YFKTNsX/qlt V611p9MwXNsUo//w7l/uqq/vaF6FYDLy34OogFBGLEWKqZRLXCq0UImsekiUOhf3BHqA UxBZAayynTEHMadXgNBMtX5ti3YmdhvC/GMmDsdNebyMjA9JyhfXaZXg1Db30eBGu2AT Z0RV7ZuE/33yw3ci77oj7zV52kE4ORlfoyoYB9wliJMCOBUoOuxuLa1JkdHedTIixcyv 0znM8rgXnsMzohOC0RlNoJ5Gk6Wk2n+qBE61WcTNTpICZqZxAyvXfcZwnQ2kvqnhh6UC BrMA== X-Forwarded-Encrypted: i=1; AJvYcCVsx+5l2EO6mSeZI16OULGE/Cx1lOuugS3OR2sIubnxRQOggjcPQIu0vP7wpNr7+unUoQ/DI2GeLFDY@nongnu.org X-Gm-Message-State: AOJu0YyFoAqWx7PgD00yHPcMMO93Rt+BNnLhAsqEfh8HaYukOXSVkq5H A/3X1lEjTwr6H7JZ0CTNxK4XNnw5sIcKKNn6MytswTRYUQJAnvkzGjP/Hce5IUTio8wZRA4I2Jc ex2pa X-Gm-Gg: AZuq6aLV/H9j6zi62/sBq/TlWMvu3mTY1PvjBRmJvI7N44idge8WwnuH0mvDh1bCic0 xmoy8lSroZLJPeO400ch9BtPn7v6qcaqga1XblWx8obbe6/L07UMCymQzGtZ2CLnhhAk+bW62LJ 9+OQrmEhcurk3en9d5pYjVfusA+J+8O7Mdl2o3cX4k7SfjL7JCBup4J8s4DVHF7t71KkrIe/HuU PmtG4cB0U5f+RUgOv2DusEy+Uhj9CvMtb4gw3/qSNBYr+8ggQqgrsW5o0f411jkOMPDsvuKU7gy Co32VKj4pZoIsmyAGsuRIAnwunAFoVGXgObSO2uzcitmo1WiDULSqSLfmp/s3spqVYfGT9FfDVD LtT0cNYCpxseuq/ZnbfKShvfRDJbwS4OYcQmivg5axIp2DBjz9BdSG7SS+0hFk8aKEkN4d5CzcB jE1jpEGtccpV//QHKXrAom++X5CEEM9dv6AfXlYl6/UaHxKfvnXxJDb50jQY3iW/oEf91lHjlrc hCE2hs15p8Kiz63gZUvxDQy5lPbM8M= X-Received: by 2002:a05:600c:3b0a:b0:480:4ae2:def1 with SMTP id 5b1f17b1804b1-483a95be7c9mr180051565e9.13.1771866199191; Mon, 23 Feb 2026 09:03:19 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 59/65] hw/arm/virt: Split GICv2 and GICv3/4 creation Date: Mon, 23 Feb 2026 17:02:06 +0000 Message-ID: <20260223170212.441276-60-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866465822158500 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 --- hw/arm/virt.c | 137 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 55 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ec6e49099a..3d19eb0fee 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -863,26 +863,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; + unsigned int smp_cpus =3D ms->smp.cpus; + + if (kvm_enabled() && vms->virt) { + error_report("KVM EL2 is only supported with in-kernel GICv3"); + exit(1); + } + + 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; - const char *gictype; unsigned int smp_cpus =3D ms->smp.cpus; uint32_t nb_redist_regions =3D 0; int revision; - - if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { - gictype =3D gic_class_name(); - } else { - gictype =3D gicv3_class_name(); - } + 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); =20 switch (vms->gic_version) { - case VIRT_GIC_VERSION_2: - revision =3D 2; - break; case VIRT_GIC_VERSION_3: revision =3D 3; break; @@ -899,10 +931,11 @@ static void create_gic(VirtMachineState *vms, MemoryR= egion *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); @@ -910,40 +943,28 @@ static void create_gic(VirtMachineState *vms, MemoryR= egion *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()) { - 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()) { - qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", - vms->virt); + if (!kvm_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)) { @@ -953,18 +974,9 @@ static void create_gic(VirtMachineState *vms, MemoryRe= gion *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); @@ -972,6 +984,21 @@ static void create_gic(VirtMachineState *vms, MemoryRe= gion *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 Sun Apr 12 00:56:26 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=1771866825; cv=none; d=zohomail.com; s=zohoarc; b=nmiUK8gWDYcpYpAbnMg91hz2p5B4owd69guDQ4iXHfepsHL+4/lJrOAtSACWzXYi2H/2yjgtUZJ02ofxvWXV1QI+jEaXel3MaGNyAa3MJMe0ToGAjSan8ZcJ+diIvmoOwSGtFiRVP2Xy3Do4PoWMuy4ISKqvwDtoNxEMUG4IbKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866825; 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=W+SiJjnlnmDMFokE5A1Qunqp4HakTLA2MrS0hcnraE4=; b=oJc2sqymCtRP4J5Si8GRkNDII0OSMj4teJ83QpXc1sm0y8/iIDsdfEOPy4j0ebzMx3mxIR9u0+fu+N4WRz8EjFXMkJEjgDjH3CxM5e6p+q9PetvHNYwrWdGFwUwY8a1/SYvt020pzBVH8DCvIlCY470XYoEMF2uoZ08V7GgZ/oA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866825614814.6575125982404; Mon, 23 Feb 2026 09:13:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZMr-0005l9-4y; Mon, 23 Feb 2026 12:05:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLE-0002vg-7Y for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:32 -0500 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 1vuZL9-0000SU-D4 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:27 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4837634de51so20468495e9.1 for ; Mon, 23 Feb 2026 09:03:21 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866200; x=1772471000; 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=W+SiJjnlnmDMFokE5A1Qunqp4HakTLA2MrS0hcnraE4=; b=CR7cJ1/LuPvzRnF2+2QEsFjnf5wvZqHNlHNTFHrjrvlChkQzveK0399aAa7XVGSv4w q+SY8y+FzMdC7jcuMq+NB6P5xj4xhNDkGqRFB8SbDY+ufSCKRvZ3YK+KvcJRf1+C7pBJ EVjFcLSo8vB/NJhABAiSM6TCiEJNWXyzXthwvd2phSLq+jPd9mGmIhz76kZjtMHifzz5 FvG8OITcvb+fxATLSil4zOQDeUgcaMIerfanUBtR4GOwKePysLjTFef62kU9CEIk6oaA 2YQLfZ16EDTTuLv5t7axkOckUcmTYa9PUpjDjKP8iUa2O3c7VZFJYgAMpKITrJNpT4ce J/Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866200; x=1772471000; 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=W+SiJjnlnmDMFokE5A1Qunqp4HakTLA2MrS0hcnraE4=; b=CeAIrBl5AkBWogGO8Vr0nY8JQxVPB0f5+mfjQj2Uigaq3VJ1CUQktV+xC47WspGmgx YRKrWUMkJ7LYJWQUnY7fgavq79PWSkWk3BpZaGeoZCnrwklV5AGN6hze+fhf++z0QAIk 4UIXHupu6kguZH/rex+/zqji1HwASKDGYfulvEWshu45xeWX/p0fX3bR+7FjtWnKSaAE ODYEWUSdTnX/QYhZlpweV9qC2sTFpqDaxKtI3c92HVmtwvPY8LHbUZq3sl5ZQURtCtyP i0LgVrZYHE3+dcWYvnrNCIZ5zPJp5BpUmzZe+kByIN+bALhJYnMZHvyUZ5zPoLBM3Q7n BdmA== X-Forwarded-Encrypted: i=1; AJvYcCWMnq14ikJ2z3VPR1cCj4pSvuLfqqmV6DQsMHHfE2FWxo5qgzI2oMgs8/fdk29WLe0ozAbPyfMWRfwH@nongnu.org X-Gm-Message-State: AOJu0YxUqj222v1LJm5L9tysWS9WBlwYJ5LX5hHvfLULHHlf8zeIG0jn txU84H/Xy67z5Q7Mv3Wn8EWtC2vPEAO6LW/KSoYh5UEoCx7SkcWkD+Bkulbhykm1VTg= X-Gm-Gg: AZuq6aKbDztmVRnKii+x+4J7/7UG+6UWRx8AH4H1dNnbXOcARjxreWmzZVdL66lBnRd NQ6T3yX3FzCkkrryt+ZZA6tmXexuMnNp6w6mXNSPRkhRd2H+Qu53dTcPZQltfmsvYrpp61hr2dl Oj83GGRQCf4bvOL+S0DgFAShtVa1AMVjVfLmyxei5OzH2G0bTN1AGxUSR0yaX6GeDJ2SQu11dGN Ud3K2AaJhH+3irM45n2HUI7ljRmKlnlv6z1gbCGknMfn52hFfNSlRGX+qjT6sH91SdavRKP50LH 0L6IB7GJspXcxO1OFfH1cCAlPbvZ9744Mi8YolQpFqrHK7d9jrWoK1s/1n24sqTQYTJQ99T9h0a HT6BWEq8u82msjRs+N7X29BhcprvMP6VgdQcdsyW9Vd90i9QVmR74ug1SY6rZA53NEhhvY78yyk BSSXUnFNKkNV3WHQ7nPngbrzSzCQSLb3UmvhT7h2F8HSQ6167mlUxeZWm9yAyndroubB5ADzPug B18DFRXKyjnAoE5bK6ws4NKOE/Igpo= X-Received: by 2002:a05:600c:8b16:b0:480:68ed:1e70 with SMTP id 5b1f17b1804b1-483a963de73mr209947465e9.35.1771866200213; Mon, 23 Feb 2026 09:03:20 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 60/65] hw/arm/virt: Create and connect GICv5 Date: Mon, 23 Feb 2026 17:02:07 +0000 Message-ID: <20260223170212.441276-61-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866827925158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 3d19eb0fee..a9addf5ac0 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -69,6 +69,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 "hvf_arm.h" @@ -185,6 +186,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 }, @@ -781,6 +795,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 @@ -994,6 +1051,9 @@ static void create_gic(VirtMachineState *vms, MemoryRe= gion *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(); } @@ -1929,6 +1989,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; @@ -2074,6 +2139,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) { @@ -2102,6 +2172,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 @@ -2126,6 +2197,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); @@ -2177,6 +2254,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); @@ -2210,6 +2291,9 @@ static void finalize_msi_controller(VirtMachineState = *vms) vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; } else if (whpx_enabled()) { 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; } @@ -2225,6 +2309,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); @@ -2397,6 +2485,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) { @@ -2442,6 +2537,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\n"); + 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 6b4691761e..34588747aa 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -63,6 +63,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, @@ -116,12 +128,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 Sun Apr 12 00:56:26 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=1771866557; cv=none; d=zohomail.com; s=zohoarc; b=im9otgr+vTzTuR7DFoabZsIyrKjGdBVTOIFDe5a3tAp1/Vp6UBN/QmJWSyQyhA7Eigc5KRfJiwas0bBe23VFnVtk7yaiVWZfyMAm/WjUqav9qn756pieUCh98caqiHhOYZwgWIIZhevlKMfHDKmiQ9HQPunuK5gSC1mnjZIYPFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866557; 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=p/a7uEL7hLfdBbmhtWHUOjRbCfekgNn59cldCooxS+c=; b=G83k0mhYuDiSBbYN4RJIkpao9e2g0xLaZF8GBYriSNxJscO5kx/mrpHfgKST8FbmAr9sPZB57IVfekHFWsep1vyMycN80cFdw6+QrqMSSbuEDMU2ROliqkWDNDv/FQu6dQwd/zWWVqp/+1vlgrW+8NRpPTO6/VYA2ooW4P1dS7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866557563665.5487118981653; Mon, 23 Feb 2026 09:09:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZMs-0005vP-M8; Mon, 23 Feb 2026 12:05:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLD-0002uD-Hp for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:30 -0500 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 1vuZL9-0000Sg-Bp for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:26 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4836e3288cdso30471185e9.0 for ; Mon, 23 Feb 2026 09:03:22 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866201; x=1772471001; 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=p/a7uEL7hLfdBbmhtWHUOjRbCfekgNn59cldCooxS+c=; b=kpLQPmIRpwMaPsR6WJskdeefQgsjkw8f20QEddBnu00t5IkCu2BOFYYqXYonh5tVbi ddV3flQz/amaWJGu+DPVNCU+4xvuWQNfgH7uT/hew1YQv1bOG0TqSW6zuH156Xr/B5MX n6TUoK82jShW4N+e1DZinpLEriAqSJ3ZSy0MHIeadpyAFYgMmACA6n5YrFdvhYVzR/PL +vQR72jaDpvBo1sfbT32mgRSpDaC1f9BkgKbHV+m5yWdEVYaca7WjlQqq606TRqvddMc DyVm6sGB94cnY+u3xuZdK+AQahfjCi2AYbvWgDqIXWUrseAC9WXGR6RXT77ArgoYhcP5 fDTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866201; x=1772471001; 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=p/a7uEL7hLfdBbmhtWHUOjRbCfekgNn59cldCooxS+c=; b=N7hgWgoGqjrONoYy4Oz8Ba81Tas+IIDKijNHQGQFECd/jjVwK1nIuoZExiuS/sqwmE sBveuvR7EekilnofxoqqwbXukv1vzdZKWDYRdI3CmYwzMht0SBiRjwP1vEDYKawHqhcQ /aeuWpSfu/3PmlabSuUV1fdaOJccC61qXIGaVwNqRo5p3IVHcZifzV7+g3L5gZ7nyriZ BhgO1hHVCvj4jzp+sMjgQTcOZ0eqZw/zJ2NV2fqucttliy4vOQ1J/VWMNQ0rH0QZ50OI 5ZQm53TRB2clv7Kta9kfuu1OsIaB/nRHjU0J3T1ZSGgQYPQfyFxSBzxjvOysDCVJjOjr LCfg== X-Forwarded-Encrypted: i=1; AJvYcCUJa3fHuA1ETPdn9tMyDJE5Svm+rY72fEJ78xUlsAfJIOr50Qv7SD4An2UaeX0n8Y1fwKlyP/XQaoWp@nongnu.org X-Gm-Message-State: AOJu0Yz0n1YnMovhRqVyuOjK3QYFcbwSYobOA7BWC8YNS3Zoc/CnUZgh ymvifZBcAW5m8PSCVC67mHmB6dL6YOOnfKTBoqSbFadXWlI92+Glw+ATVp9XjNXwm5k= X-Gm-Gg: AZuq6aLPUoeWiBwM6PFMJ0bP4dD2qWcz0e3Dlu75BlM3iN68kQx5HxshUmtk9s8XZlZ S8AmjwIWBqGVE0wMDME+GJznQMsANw8ipuQ4xCCtVDl0aot7aex5JIlsbbkJcSc8OI5EdWmLmNB Pdj4aiWJr+Ia+W6hzxdah825vmTERIel1kUvIRjOEHnXgPabpi9IwmYoXThHDjJL8ezwmBhn/lR JOS9kZ0h2i3LIFFyNodZOi/AFtRZWpLSua7Q056Ts8E/gd+vHOnZ2i8aibp3S2iAHN7xUmbA+uS UyRYx5v+huyHup4YqZodJm5twOdUhACFQLuHWy+9UtMqhIS7i9Hcr+oFi0U02HO+lMBeaaDHBd1 M/hpVeNFdzTELJ/gpliUrO7jRQQQSYQUME1WcsZX2NXOhqK4Vf/ZGGaglDqyQ0JK3Jxba4GC1L/ nKA4f7yLcf+cruN3VZNOgp5DfH5/newdtzEdZ5yS7fBbz9hwd5w9fARqPkLIu/DazklyJap2bu1 J431C/w/EeTeleS+HbxWj+vD7zznNw= X-Received: by 2002:a05:600d:6413:20b0:483:78e7:ce15 with SMTP id 5b1f17b1804b1-483a00aa4cdmr174653315e9.13.1771866201190; Mon, 23 Feb 2026 09:03:21 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 61/65] hw/arm/virt: Advertise GICv5 in the DTB Date: Mon, 23 Feb 2026 17:02:08 +0000 Message-ID: <20260223170212.441276-62-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -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: 1771866558227158500 Content-Type: text/plain; charset="utf-8" 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 --- hw/arm/virt.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index a9addf5ac0..6775062c5d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -795,6 +795,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 "iaffi= ds" is + * an array of uint16 IAFFIDs. For virt, our IAFFIDs are the CPU index= es. + * 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); @@ -836,6 +902,8 @@ static void create_gicv5(VirtMachineState *vms, MemoryR= egion *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 Sun Apr 12 00:56:26 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=1771866682; cv=none; d=zohomail.com; s=zohoarc; b=NR0O3vlHuHmnPc5aTH7U5ur/AEHtpPzxK3oAmkB3wp98pZmIHMdY4HfVr/r15tC4ukLv4E65OReDch30ixgml6XqurmRkLIGY2+kveCBZxAN8h87lgM6jdQqE1LY2FLn/1DFp9c2wq8d4KCK7GdLi9Omag386zUd+Hs/LLn0npc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866682; 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=xnLatPeKAUqiKYWLfB7xxZkhhx5vWjxgFw6UbAcOb1o=; b=Z1Pe1U+5HCQ0sU2VO6mw39iaNpIjC4K4dHydUf26UbPZl0K+3tiDN9kpPTWd9spgyG2jlYFqtPjjKZ48eQLtcWc93lXDCN4y1ZsoFILrnwjScy2BmqrI3UcwTBiAL1tYXVzmYdHyssgFzz3kphQus9GbYq1rO9UYLuKTxqeTtYM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866682628417.59542039663097; Mon, 23 Feb 2026 09:11:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZMh-000554-3X; Mon, 23 Feb 2026 12:04:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLH-0002ww-5h for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:32 -0500 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 1vuZLB-0000Sy-AK for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:30 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-48374014a77so47458675e9.3 for ; Mon, 23 Feb 2026 09:03:23 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866202; x=1772471002; 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=xnLatPeKAUqiKYWLfB7xxZkhhx5vWjxgFw6UbAcOb1o=; b=nAI4tTixjMkYX72BZCq+KRXom+EnGvGzgrX/+cgGRtc3C8NB3Dd7GVBmQCHRuMDhh+ ZHzKDB1nppfWVxx1hybS5pQ9jXvezI3K4scGBdmRW0vFZurG9SmOt2eu7IdHp4aUZsaI TkFPw6pyvjbfGG4xule4fTRdtUyQUtT1GZBB6H+xgN61XmnSAg+1tQxXhOnQiXa4NgDc e9zRi31KuhpTdOzipV1lKDT+BKAvkNudQK+oRye1q5AKncHslSn/sVsiG5ilOU2bTn1w +MnVq/J7MdPXY/bN5dNDZJDeEfM+Vn0+C705nmfyHggblEQx72/ohdiysCxTPjsf0y7x U3yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866202; x=1772471002; 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=xnLatPeKAUqiKYWLfB7xxZkhhx5vWjxgFw6UbAcOb1o=; b=oi7UtsJDmTnY3njZHiyHMb93ELjBdR/z5oG6oGFRAl0GBJKWHn8QJDENuc8geRrSGS VrtfvZ/0OaHAszLMfvLbDOIsNnzvxplvgzRuW3FPH8E/t5m/Je7zxF66izDON2+HXfTb rKjyoyzakrON9ygu3zYj5ninJLMPxKk6hjL0Z+4Xu3GFDZGrTbRYvUwZU3V/7fVhN2im cFaIVH2F+gWuS/G9AOkzvGJCGZPRaxtZGd0ZA0XmnHjmnZAt2xWB3lfNkcnNG2EAIlnW X3oA1U7ctl7o3xPNYfPKb/g1Lg7vl7D54KtQRCXkRTZ9ZQ1PgEpDjQGZrkSnZbZCoJWJ 8EqA== X-Forwarded-Encrypted: i=1; AJvYcCWlvsYF84qyy4OFPI6WDiHBqeFEgeB6Ry+SCwx+8lUaRxTVZQL+d7mXJWacobmv2s28O6ch/BpgGUG/@nongnu.org X-Gm-Message-State: AOJu0YzTbrLLYPcRDuRFFCLsY/A9Od//B8BQ7rbOx/AQ6drkrq4kuKr5 zT6MIh4Crpa7c3lElzRgjGpMlaU9TvM0RfbBcFqiCQUiafoouSCzsIuYHRyr1s/w/TgsDlCmYcx WuG23 X-Gm-Gg: AZuq6aIbuE/nTd6Z8eUuKnmjNWTA/wqfSMEkGNsa20/3NNYPYCUyiiOg2NoDt1oRdOn 6GF8WIO76m5MuEb8LOd9smFfJxn9Q1c14OFYsea9gRQUKi/mD/CpxiO3F70pwA+pD5i8Kf0IE0R qxBke8eA0FF97N8xdV7UqDvsO7uXksnq0LOiY6nt4wCA7rqclJn84w3l4Z2NxZJk8C5Q9srlDFG o860mtQR7tNUcHSzqC9ey6g3nY4me4lSgd1AC2evLMT4YJJYsgSKXxmmoMundEsFGY0OABgE02S pBgp8ollJSopHiRloBEPSDOWvypimcMgnaD7Z6U0RjFo1ycKGRWLGqZKvf/s4MkR4ZN4E5tPYwA H+aGnaC9e3NXAvZJMTMDpO+kKQ3QdEO0n3PzLIqI2JvMYlFB+t1kzSKmXVCJgtTRVEq4ks/tL1Q W6/SbcT6e0rO4G+7ep1rsZqQx87ENWkJDL+59icXSh4TaYZqWFevMsM16WLT8YQ23DlW+/VoyUa B7kS0l1lsJghxY3pN45LD396HTjNAg= X-Received: by 2002:a05:600c:1e1d:b0:480:6999:27ec with SMTP id 5b1f17b1804b1-483a95bebcdmr171943985e9.13.1771866202287; Mon, 23 Feb 2026 09:03:22 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 62/65] hw/arm/virt: Handle GICv5 in interrupt bindings for PPIs Date: Mon, 23 Feb 2026 17:02:09 +0000 Message-ID: <20260223170212.441276-63-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866683032158500 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 --- 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 6775062c5d..05c92e8482 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -421,7 +421,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, @@ -700,11 +708,18 @@ static void fdt_add_pmu_nodes(const VirtMachineState = *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..da5c9d4a8f 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 Sun Apr 12 00:56:26 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=1771866784; cv=none; d=zohomail.com; s=zohoarc; b=UjNzQ4U+ISLdTIKKNyQ4mO9eCMRcZ6RTeK+Tp0NUNAodwnmH7VhcKv8W6Mqd6AiyeZ5RlQARytVAO4fYq2BPR/UwdNoY9EDXSwev7A5LI7l10RONWfyn+sC/N/XhEgm60k1vUGtAgPH3nuu4HhEtZ2yGEAggOyFJ4+LRy+VXF9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866784; 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=ki1+Cj7hzmWIdImuSXSQEFK5DhzyzVZGm0uIPL+3K2k=; b=VRiqUf4rUfJvfLH83Ou+KYKCiO4lXHJpXeQkhHsURRw3/6bRpgFvMsYZ3/UxBW/hEd1MW59cf1PIkNKmmCN7EF4UAQL++jjBXVuDK0DQOWO8sHdixT4uGzte6eklAy/g68y5V5eGaNx4ttKaZ30iNlCJpcGrOzU7Sm0sH8iwSLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866784090229.05756114800704; Mon, 23 Feb 2026 09:13:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZMq-0005g0-9g; Mon, 23 Feb 2026 12:05:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLH-0002wu-4U for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:32 -0500 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 1vuZLB-0000TK-Dt for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:30 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-48375f10628so29382615e9.1 for ; Mon, 23 Feb 2026 09:03:24 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866203; x=1772471003; 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=ki1+Cj7hzmWIdImuSXSQEFK5DhzyzVZGm0uIPL+3K2k=; b=oBQ1oAk7piCgStWUwtZLdLor84a6JCispFPajxKruT0+jTMTb5ueHdiJ3QT7Lvb5Vc PzhYl2T2lJtersU5SS3D6iDGaDxAmiFToJ5qscMad0kUNH366F0LC18bNuWmmeF/bW9C Fcy6TNiqrDpqD5JrAIwb/sEqY0qFItbJs2h4TUm8cd7BZiaywYtRSevJQgA09AzvM8FJ yY2wUV12k1QurZl1t0VjclETJOLEs7wwoUxfKW+2DPz91YAj7aT4k2nsqtikl+T6axkD qxDYwc/uSHjCdomZMj2HphQrtRv5y/tiYrerDWsBNDi9hGqLDWmKeOk95U23nIg4oIv1 wCIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866203; x=1772471003; 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=ki1+Cj7hzmWIdImuSXSQEFK5DhzyzVZGm0uIPL+3K2k=; b=M1gOCkYBzFqtcdUPcBSG5YZVtSfGblrpYs0nZyhmAA0AO2qNPWlpPJjxWf0h3f+p0J eqkuXqQeZuZeH9RR0tb0F6vz2mG0m/5ivtOjfF2wT2V4xSAb28WhmLI4EbmKZverQehT 7CT3HqAjeG1/3InUgUmh4xdgus0no186/cipMTpeaBitbLXPT1GgUnfl4Crnah0WS0de jVxf8/q+OiinHg7qkHMTKsfYgv+LjpdXyO/4w7RL0J5U6yc4/14JRB89iW/uuHLjswor rsHQ8ERJt1wWF+Lgk+Yb0ez34hvgCNi1+82QEAg+z938sAO2BrWN3v3D5O4fS3xUKsmQ 7+BA== X-Forwarded-Encrypted: i=1; AJvYcCVhfrVucq/JBaSUdke7GJ6Ib4Vl9dF1/1etYZKm/jspjE1USeFc8XEmTFV3MGRggqIUX5gtT969SvEi@nongnu.org X-Gm-Message-State: AOJu0YwkvnAa3JUsDXp7UpxFnRfj19q2inDGgksgJFL6ww1pdVefAZeq bO73juwNs1Wwf/oG4/HbPAg4eAcs4l0Zp7nVkXOFfA0ksg/3H8sfJxzbs9gXdnSmj1o= X-Gm-Gg: AZuq6aIxZ/sTRNMxX8dDuTmTBDwSNz7QMJ6kzx44rFuKDs+KxkPF66+l+6TAgpDmB2X NRNM2RGSXKbCN+rYYklOPnWqRfKmMkOLqipCuvGlTOMpz59vd2MMSBpdMb23/yXH16JUy9YYvgs OIlmpLswX7aoMaDLi9EUk7RDNmznV1DmjrWf6WAPJHJZZ81+Isw/eTvWSbxJxx6nmufYikzsx/z PdbQICmNfT67pw25uP6p3l0YSH0+5AgnHRWBXjcyGZ8qQ0VMRyEOP/LpdnDv6oZjqfKnUGcT7ry BhumXWC6aRSGtFg5fO6a4tknI5KQziK4JUgZqcyy/5ZHP9p6QVwk7CWTdpmMRAuv46gPQDMWNeP 8WCwUsx8HG1TcSS9yQJcQqeZhIVpiw0A5ARfs5cEj145cUIMG99VCHQWtzr/KLIwS9Gm2b+GHQm fdzKm5lH23bJI9kZLAtUFdvGULvYEIk1Mo3iUxlMU6v6Jnt0HcAA8GEWBY5xpr62uqipgeZvZp0 PxOPaN9KxeoOWcb0LsWHr7MOARJHe0= X-Received: by 2002:a05:600d:644d:20b0:47e:e7e5:ff32 with SMTP id 5b1f17b1804b1-483a9605b19mr105039875e9.34.1771866203286; Mon, 23 Feb 2026 09:03:23 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 63/65] hw/arm/virt: Use correct interrupt type for GICv5 SPIs in the DTB Date: Mon, 23 Feb 2026 17:02:10 +0000 Message-ID: <20260223170212.441276-64-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866785593158500 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 --- 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 05c92e8482..1b63338196 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -296,6 +296,16 @@ static bool ns_el2_virt_timer_present(void) arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu= ); } =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); @@ -1185,7 +1195,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); @@ -1227,7 +1237,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"); @@ -1346,7 +1356,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"); @@ -1427,7 +1437,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); @@ -1627,10 +1637,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; @@ -1671,10 +1682,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 Sun Apr 12 00:56:26 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=1771866827; cv=none; d=zohomail.com; s=zohoarc; b=fvi2yzc4bRgAmu97hBUd7LwV8EGqotKGsuKYH1iO+gI5EO0p2TDemSxrvtUKW+HakStzAc2RcaMYThe1xD84IEHzwQE+ejHD4ioUJFZyiRnOxm+TGfNJi7IXWXT54d8x3f3g7R7unwZbmZ0RHFoVh+Eh4iQtz3m/5KxnJ7TtYIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866827; 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=PSIfnHT/9W4YeoezCcXgDdWqKuWJ/ARpVnHX63Z0IRE=; b=KQHPEBQEXog28ODyKJIhN8dIJ6/dl4qcedO86QNRXNV519rlGFmbpHAXP8SKQgEueVm4xuZ8BraoDhTpU+VWqwhg1+/bCVkTyf9ALtPr8tOw9lu7dZ5FeV2u9YjdAfBX//rEq0eOttCisDhf2bZ/zgBE2ZUQdZSDMOaC/1GvenQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866826927320.2835497217999; Mon, 23 Feb 2026 09:13:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZMr-0005mJ-4f; Mon, 23 Feb 2026 12:05:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLI-0002xQ-Lv for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:32 -0500 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 1vuZLD-0000Tm-75 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:31 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-48371119eacso52944235e9.2 for ; Mon, 23 Feb 2026 09:03:25 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866204; x=1772471004; 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=PSIfnHT/9W4YeoezCcXgDdWqKuWJ/ARpVnHX63Z0IRE=; b=tZXeBjnuGxACndcGJzyz2w93j4AD7zWABZDUh93CioAz2xKgUtLzvyImPTdaD6Jm+T U+trSq+1rUsP/g59yP3UyP16uAYnfxHOJPAmZuyxVhLLRmTRUNoeVTQrEW27YleNyPNg oQ5qERqUFxIC77/PxwnDu3cQREA8NBwTGPu6eB5lklxttLI5213oDvHaU4lMatYL2mdP rIgQIjG0RssvGr4nRLgJHJzOadIBbi8dN2IzBzlAIqSMCZkfRGFykxsgyvp2LAvXDyt4 hEOouDyTyyzMRt7nAsRKmPoj79tv4s4FCyKgTBKOXU25/TRBmZfmi6GpIFobqw4oHxXx pZcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866204; x=1772471004; 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=PSIfnHT/9W4YeoezCcXgDdWqKuWJ/ARpVnHX63Z0IRE=; b=eSZG1Dzn41m1Pa/XSqmnuEYFUjaOGIQsFY43XYL9ZVxdYE7iRozaI3AnA0WnQ4IkLw XHm/uVLj9xyVE0hkC4uEqb6Yf1L5aiKfAlzWhY3gh9VksTsit5mtHJuJEOWdr4GqtL8F DT/kybr2RB1wEde0+Lc2gi06oyyYhurijOHWyyhK1rO2hoix3kUiVTyzmomEe6OEBFWS aP327/zlLiATl5TeC+DuMv5xv3XsVeIhwIp1HST2Djp/FKlv6MZFKiJkF21X0cZKLY0y mi9/RC2b3cEv6vPiPcuzPDzywy5juap9ts8B46V+2m326+YIOCo3X+iANs8es0d8S5fN pY0A== X-Forwarded-Encrypted: i=1; AJvYcCV/hbJ4C9wwCUxOeaLq9WGOBRwTBNU9QFdvqpkwN91f43QMdOim4psb0HOHLnM1374mzXytetiLc6M9@nongnu.org X-Gm-Message-State: AOJu0YyjZb09ru/SbQR7um9ml9CZSNFlr76+3MlcTi0cbfOHuREJl9TO EmwN3QV7sdNK/UI28SJiekt2ceKOfthWsdwTci1r0zOvZTvZ4tTno8TgG94lG0gxBiJAu4N0V20 SLFVH X-Gm-Gg: AZuq6aL3tGNCZlgCdOVOS4nBNqk0LTV3ktfGJO/Exdgmj3LuNGhKb9XjDSwe5oJoCTX nZd7TtR3jCp+FZBEaxYVqR0fhHn/nsijptuJ1jQR57pFxpATZbAadWqfpV7QTSIOgpHJUJ6EhSS uDG+OGTBEp9WnI1KC6DTdjvHvp6NJdeJQrdW783XAuHon9oEhI6VGQA9L0cVkMZPDa4s8/jhcYR 8VJ5uX3ZEIJNaiMGVM0lMkBuxdh9bV58okrlNuM7MWnkC5QpaTwf1YOuwqsbFf9/L/mHjQzoJz/ V6KTcbhdtaPqBRX27Jqepa1APQKAvMaQdA9r5gIIQiQnQoDsu6kw8HQC4gOmYToDR+mhDKxlXT0 NQpFwYe6+4dkkt8zRic7JjXF3IS5pPm1sUjmWYs5Ufjg7rGKsnUOdLWxlZCpbmFQO/R1umuJ/8y yp3xTfIzdk+MmvOZLLK5BtyrJb/3Kry5fl8NO/R8oJQNNDEykx5y2N5Kg86Ly8PZ7noKX71KZsR EH6NyZPZ/kyQx/QWsE83LsP0CRDQak= X-Received: by 2002:a05:600c:3147:b0:477:6374:6347 with SMTP id 5b1f17b1804b1-483a962e3e2mr138472885e9.22.1771866204456; Mon, 23 Feb 2026 09:03:24 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 64/65] hw/arm/virt: Enable GICv5 CPU interface when using GICv5 Date: Mon, 23 Feb 2026 17:02:11 +0000 Message-ID: <20260223170212.441276-65-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1771866827763158500 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 --- hw/arm/virt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 1b63338196..1c684b59b4 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2677,6 +2677,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 Sun Apr 12 00:56:26 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=1771866654; cv=none; d=zohomail.com; s=zohoarc; b=ATgWi5W0ul5QKhJurJjwygEapSU59GGvUPZBTWyI+B+7vsX7UDqzmNc8aY+0GZNdfT36Dydglw1L8JXZvR51tBtJ63MjDMq1DAzVK/4rIAXrYXL8pPvOmTDBBp4QAExHRGPcfyAmPaRz31PqMViwAdpjzHnl/tMuoR8xaPhqWE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771866654; 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=VaAbltozh/selDM1um1aR8XySGP5uwpWPXsGLFrou/8=; b=PCitgnB51vzY4RtPKrNKwNuW3gmPPiLvu7iLvEHtHRpM3oGG100WJDfFPCU6exPKXkVH7qBZiTwgoSCI4ZCd/ziXKjuzLb39kMBq+weRuPwiyLOYZu3UojE3LnO3zVX/o4Thg44d6GtptoGUfbkFjk9YdFNawaiecs0kEf/RFBc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771866654041683.4035519726285; Mon, 23 Feb 2026 09:10:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuZMR-0004sN-IK; Mon, 23 Feb 2026 12:04:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuZLI-0002xP-Kz for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:32 -0500 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 1vuZLD-0000UR-5M for qemu-devel@nongnu.org; Mon, 23 Feb 2026 12:03:30 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4836f4cbe0bso34591755e9.3 for ; Mon, 23 Feb 2026 09:03:26 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483a9b21ceasm200155625e9.0.2026.02.23.09.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:03:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771866206; x=1772471006; 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=VaAbltozh/selDM1um1aR8XySGP5uwpWPXsGLFrou/8=; b=zM/xMWzW0g6hTmso6UPZojM/LrzaSdKed9azJjG0X3+yUYZlDEwBmOCjCYIHFRRtxo zgvFuqn4Qh3bNLR7+BybmVcCm3kWlq4TXe4Cmo2RwseZ9q42PDW0bURpRtDOnmxE61dN FtIUtLnQwfHmvHs8KqRIHct9xwK2fmCepKQJN60ydPvHixz+AJwN9YJLSAj57eu9n41t 29Qk37XlWaqRNOp5v3hw9CFd13ZbIS9KZ7K1YhIwdc010H8Lxioujw5RdmJNb4wJNdpx Ykj0CGhpR8iPvBSnPwPToE/Vf8pPEIM6mI0Luf0PpIGBZkERxEsZl+8Tj8KvpXZ6R4jI 35Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771866206; x=1772471006; 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=VaAbltozh/selDM1um1aR8XySGP5uwpWPXsGLFrou/8=; b=wVvvdobSlLhuZjMZCTTQlxnZyjNbJVIFFL7GyAJ/vQn2z9Z8Kwnd8kGZeZrvx6CheV 3HzhNfyl0U8vdBnRkIHf3drM1Hl5YCVwAS6rSpyB84IotM/crZTcH3/fWTIEq08cD9eR qcE3XKo7kSh7qFD8ws4Gnwy3Y6MuDh75Br6PrcSqY6ubKTKKFYTfIaXjYKtQlqndOWcW NWE26x8It5rqAln0pswFwcUes3siuz9qSed9rRq1pwIrjuQQo+xwRZBcpjnqlKYvbM8I c5TtM3+xymS7aX3/L3JsRDhr4858FOjwOdyzlw2kLN/IJ0Axp/X/nO0eHqq/cTjTcV1z AmDg== X-Forwarded-Encrypted: i=1; AJvYcCVYvNkJkh1OY8WI/blPY2KN7jqxo8xV6p949ee2MTwdRlOzcb3ZWbAgdXa5T1Qy32AfG6DDYZuSkeya@nongnu.org X-Gm-Message-State: AOJu0YweKqvOviQuzvjualg3T8ATXCsegkuxyq4yhSkSf5fd0Br8t3TJ HkqXshBSZPcbV2JIg9Oaty6MrxTCnbOcqoGyb8AyKE4KOasclhPjiwPuVBd1gYdy2KSlQezmsgb oTYfU X-Gm-Gg: AZuq6aIbgy7kwsfLosSmOVGgwx7vZUNSB77vkEK7GJZ4NMPDliIygpsoJWn3XbSvMZA 8nAcmT8kdZLevfYTnlj0tA4xozvCQBhiyhSg743EniQPRxg3vX4uDAyDkwH3Kule0tCurGIgNly 4ss2IegPMZWFRHLN9EGbNFTgdNQhbJGsdDvfu5jprZN9dHG7buZnY7OT2sScTH2hWY1ArrvU4nY 2qtuyMvI5LXX1cl4ptlL6fiK+5bTRxBzWWP4jyUhkihXDMHG6q9YTNeh2cx+lVWWAjM5TOF2yqH KvvksjB5LPI4uPlgWc4jInBwleXXZb+EyIf8LtMIjo+fPnZVhKR0C/RRP4Bw5C0j0sL/LYt0Wj4 Nn9EY5zHXHEzk+8E/L1x7iT45P+u5TrYeWcx7hJl46/84KL7KJEuU5/1dEq3TjrMWn4sto19wlz EpKgSMz2VSfY1A4MvO3lBpfHvJ0jFSr3qcL7YhMqQDbLEsWtZKN+dqfMDt9Row//GMNODPeM8uu igjTYF8R5aKVz3yBCIvLxFukZMl414= X-Received: by 2002:a05:600c:4749:b0:480:69b6:dfed with SMTP id 5b1f17b1804b1-483a95e5ab8mr160471345e9.24.1771866205620; Mon, 23 Feb 2026 09:03:25 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 65/65] hw/arm/virt: Allow user to select GICv5 Date: Mon, 23 Feb 2026 17:02:12 +0000 Message-ID: <20260223170212.441276-66-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260223170212.441276-1-peter.maydell@linaro.org> References: <20260223170212.441276-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=lists.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: 1771866654881158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 f8148b5dcf..e38c567279 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 1c684b59b4..ca95cc9f73 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3195,6 +3195,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; @@ -3212,7 +3215,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; @@ -3224,7 +3229,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 @@ -3792,7 +3797,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