From nobody Mon Feb 9 22:37:53 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=1768932269; cv=none; d=zohomail.com; s=zohoarc; b=e7x60jPUGK2JhDtIlBycBTTPj2coIv1UsS1tQAH/9PuIP8r+ahKK7WfjMeskzxaH84vFKKhEykCN06RSpeoAMXWts3vG5AWTUda8y8UpsKrhh3ffrGyAWp51z18V/m8pAbN61/Bb7dRVCVWqlC11uo8S72QjP+UmZqVNaUnehTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768932269; h=Content-Transfer-Encoding:Cc:Cc: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; bh=jCPqRpQUUqzqFmpPhdz1jQmtLeDG3BlVkhJSsKOlHuY=; b=nkeItzKtUugS3CnuUFnfLhFzgO43qrCWKEPkEG2wta65Y+3/NMZ2FJqUPLN2vnLdY7X37qKLXQEARxrYdajZtk9PtlAN0QipsoZsGzEwLB1XnPuGaXn0aoHvYWbib1WxGch6G6ou8mPWRNowVftcsEhKUbB0xSg+nm1rAW9AYPE= 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 1768932268976982.5722086866322; Tue, 20 Jan 2026 10:04:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viG5J-000758-By; Tue, 20 Jan 2026 13:04: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 1viG4w-0006bC-Ea for qemu-devel@nongnu.org; Tue, 20 Jan 2026 13:03:52 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1viG4u-0000T4-2h for qemu-devel@nongnu.org; Tue, 20 Jan 2026 13:03:46 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-43590777e22so539478f8f.3 for ; Tue, 20 Jan 2026 10:03:43 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356996cf58sm31310889f8f.22.2026.01.20.10.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 10:03:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1768932222; x=1769537022; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jCPqRpQUUqzqFmpPhdz1jQmtLeDG3BlVkhJSsKOlHuY=; b=UbOU/51hS0AOV++3d6AIMK6JVnfRAwVUZf0KTeI5o81yHnvBIxHPYrhZuXdf3hGUaD n62Yj19EHtXvAfKt3coMto3Dehu8VftE6ggd+itI2BUy0k6JURWVlF3tWKAnt3LxSVY0 67aIJ2LUIuKT7tYHdR6hQgPbCcj4LrQO/yHX4dV5Koq6T0ApuX4yHSu8Fot2J1aBAfNH BaVE20E8FtLetOvVU3aD6kMw4zFC+AHCfNIzTUiRO3Fx/pPWfqQ8QsR+7kuCCwP1Di65 SDJz+J9XtIxGzoSpKonka1sOB6m3dCSKoHaRPsobQMD1gxuheHKiMCm9W5KpLQvswC0b Cx7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768932222; x=1769537022; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jCPqRpQUUqzqFmpPhdz1jQmtLeDG3BlVkhJSsKOlHuY=; b=LzOzXv46pMq/S3eWHRFi3VaXRL6X3nJ3Lsc5EfC0T2EK4Wums7gOntmM67ibyKIRC0 fYGX1AMGr3OwJ4eLPLNae6dnMynnrhli2ceaQBvTjz4Vp1NINSRCy5P/vH5lXCJkTBra VnQVux3V3gdjhkxMA4pwiz2LLht749ZiEt+7mrfh+qQE749UmBhMqDMyitnnG62Ynvpm L9H4daYc6q5fUVRPyfDLhu+D/7kDKjki2EFY9kpGnyQ4bfDHTSJGiHc4zTpAQC1oitbn RU+t5NoXAgQPv1SRTDjyqszx92rUCDMXRZZU6d1ecj+KNe85hXGCIHgExB1hsh5ugq2y q+dg== X-Forwarded-Encrypted: i=1; AJvYcCWSCIBbje+LHGzt4+xQ9jtuPndk6KhOPgy/uQSohBpfNLJb2jY4x7G0J6QOTgrYGTYO9fHSIZpskzIh@nongnu.org X-Gm-Message-State: AOJu0YwS4FUdUkGvdhEOmWeBGwLw03CJPYPciMAon7pdCTT3zZ+MleqJ +3uJNJQt82iXq1pPjOJWqco2LR6CqqONWQ264ZN93qylXeNhlxjxUYDuSv0RflwmPgw= X-Gm-Gg: AZuq6aKsf366guWRUGG2+cKWXX0O4127txxO2WNQDFN06KjwdpMpzKRLF9gQNiCPT82 cX3HOZ4iVNSluha8n6NYV7TZemZPCdGT9H4y+ksHB/M1SVxcik7r9IW9D3qWvKx2LZNElP+XHWD Sza6sv3C/b2o6CbyH/Cyrqp2yUnGgOt0rW8p6LDaiW9h7sxOuzk4qliQD7bEo6XheWHPSm9+bKa UJa8aNR9ctuwHHgl2j50naQigu51fVvuu1StCiJ4XVvO4UDNBmF+Gu2PuWYDjGDt5gQAs11yi+K cIHJ/v1XyfBVU9W06sgekJw7joUIpSEJSoVzTFdAswBcU8JZ51JyNFA4rg/u9KJD8dyz6vRx9Qk mZTEvlNiOFxz76PB1AyW1JgHRNcoNNp9Ij3/Y730bdMPdSL4uFC03ckwp8SKh+RDlgwzFhvs1e3 WjhoLHi+P8qqSh/1PNuhpJVqbG11UiFS7fB2KXzDDDq4dHt4uf7D7b X-Received: by 2002:a05:6000:2281:b0:431:16d:63d7 with SMTP id ffacd0b85a97d-4356a05d461mr21542141f8f.47.1768932222095; Tue, 20 Jan 2026 10:03:42 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Mohamed Mediouni , Pierrick Bouvier Subject: [RFC PATCH 1/4] hw/arm/virt: Clean up MSI controller selection logic Date: Tue, 20 Jan 2026 18:03:36 +0000 Message-ID: <20260120180339.1416328-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260120180339.1416328-1-peter.maydell@linaro.org> References: <20260120180339.1416328-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 (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::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1768932271923154100 Content-Type: text/plain; charset="utf-8" The virt board might have multiple different ways to handle MSI interrupts: via an ITS, via the GICv2M device, or not at all. The logic to select which of these we use is confusing because it is controlled by a mix of versioned-board compatibility flags, board option flags, and open-coded logic inside the create_gic() and create_its() functions. Currently we set VirtMachineState::msi_controller as the very last part of this, inside create_its() or create_gicv2m(). This field is then used only in the hotplug pre-plug callback function. As a first step in making this clearer to understand, move the logic into a single finalize_msi_controller() function, which sets VirtMachineState::msi_controller. The actual machine creation code can then look only at that field. (This is a parallel to what we do with the GIC, where finalize_gic_version() sets the VirtMachineState::gic_version field.) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/virt.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4badc1a734..b55297455f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -738,13 +738,6 @@ static void create_its(VirtMachineState *vms) DeviceState *dev; =20 assert(vms->its); - if (!kvm_irqchip_in_kernel() && !vms->tcg_its) { - /* - * Do nothing if ITS is neither supported by the host nor emulated= by - * the machine. - */ - return; - } =20 dev =3D qdev_new(its_class_name()); =20 @@ -754,7 +747,6 @@ static void create_its(VirtMachineState *vms) sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_GIC_ITS].base= ); =20 fdt_add_its_gic_node(vms); - vms->msi_controller =3D VIRT_MSI_CTRL_ITS; } =20 static void create_v2m(VirtMachineState *vms) @@ -775,7 +767,6 @@ static void create_v2m(VirtMachineState *vms) } =20 fdt_add_v2m_gic_node(vms); - vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; } =20 /* @@ -957,10 +948,15 @@ static void create_gic(VirtMachineState *vms, MemoryR= egion *mem) =20 fdt_add_gic_node(vms); =20 - if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && vms->its) { + switch (vms->msi_controller) { + case VIRT_MSI_CTRL_NONE: + break; + case VIRT_MSI_CTRL_ITS: create_its(vms); - } else if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { + break; + case VIRT_MSI_CTRL_GICV2M: create_v2m(vms); + break; } } =20 @@ -2079,6 +2075,24 @@ static VirtGICType finalize_gic_version_do(const cha= r *accel_name, return gic_version; } =20 +static void finalize_msi_controller(VirtMachineState *vms) +{ + /* + * Determine the final msi_controller according to + * the relevant user settings and compat data. Called + * after finalizing the GIC version. + */ + if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && vms->its) { + if (!kvm_irqchip_in_kernel() && !vms->tcg_its) { + vms->msi_controller =3D VIRT_MSI_CTRL_NONE; + } else { + vms->msi_controller =3D VIRT_MSI_CTRL_ITS; + } + } else if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { + vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; + } +} + /* * finalize_gic_version - Determines the final gic_version * according to the gic-version property @@ -2251,6 +2265,8 @@ static void machvirt_init(MachineState *machine) * KVM is not available yet */ finalize_gic_version(vms); + /* MSI controller type depends on GIC version */ + finalize_msi_controller(vms); =20 if (vms->secure) { /* --=20 2.47.3