From nobody Wed Apr 16 16:17:56 2025 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=1650625106; cv=none; d=zohomail.com; s=zohoarc; b=IkIWjprcfsMFPVhMOwT8mV+XfmsR1oLyfKaeo3ox3TB3Cemlfe6wDwvD6mu/XKvh10/HEGixi3OABNTuXSnnHzdAnZPt5Fiq58+RoQZf6tSmpNJGtA1fVQhzvDCwOtHpSD5zrsecthxDXPCKyc53H1n9aLpg6F6SRxzSm2OKxAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650625106; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ppb9q2JdzKJCAX+yRCeZ8lM7X4SqlcHbmDsxajJSFyc=; b=cDmFWCoj1ZJCRbmAYqEb3Luyzk+Eh2b7TFPOEbQox+uwvqqR0/IiDxOzKFFgtxnogIqrClLP01PXTJwRN5wAYOU/hRqD0qh1T/44S5V5I2RbMtYWy11jt0dypCFj2TAD97qvXlJhnsmaH9+BRctddL73nl1vs8xzFoc7Ew6mq4A= 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 1650625106832192.51603778967421; Fri, 22 Apr 2022 03:58:26 -0700 (PDT) Received: from localhost ([::1]:56636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhqzZ-0003Ma-Nb for importer@patchew.org; Fri, 22 Apr 2022 06:58:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhqA5-000524-Mo for qemu-devel@nongnu.org; Fri, 22 Apr 2022 06:05:14 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:46593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhqA3-0002s7-UC for qemu-devel@nongnu.org; Fri, 22 Apr 2022 06:05:13 -0400 Received: by mail-wr1-x436.google.com with SMTP id h25so4284450wrc.13 for ; Fri, 22 Apr 2022 03:05:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id e16-20020a05600c2dd000b0038ed449cbdbsm4312148wmh.3.2022.04.22.03.05.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 03:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ppb9q2JdzKJCAX+yRCeZ8lM7X4SqlcHbmDsxajJSFyc=; b=s7PdLcKjTNz1AkMbEHtcT0M4CDCfvXob/oxUbEsA9v/Wx6bT8s7+w7DIqx9BjCIRVD FMIC0GNI2IJyBnd6VWBloWMEnZ85NR29HvuOjfWYpBPIVBS48eCgdxx9gIPq7r/aA6LN SaEqMWRc8VjDgqBp+qT2lv5PRilXvjknI0tNXH1/ZMiNhBkaRNZmjgpiFU+n//IZap3M XWRAP2SxwsoeUCIbuyFx8utr7kY+CAKcba26dFA4L8srzvtkgmtGI4aAAgvRd+MoXI8B +nIxcCBGWtZPf7r0LW4XcQj/hXQjfeId7Gzv41c/qusMr3SFt1mWHj95hngfMXUJe1e/ mqjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ppb9q2JdzKJCAX+yRCeZ8lM7X4SqlcHbmDsxajJSFyc=; b=H8sI4fUxpi1IJrJR39prP03YvXk8YVTu93sbua5DcOnn9mf2HPGr1RV/jxvv1UgStG 2WYxbdEmC0Gzzjgyk+UUGMXeVD9vv2z+B5QTCuQKrMMGeaWNI57KwZLUgr0q7CVS/fes KomyJKC7zte97Z8vR5N679Nm7LDgGHTXnBBlo7mlvQh7u70KzZY+VG05XQwrSkVZmW7i mhgqOKv7CPSuAie/2H3RFRWpdY2Cg0Wp+mK99AOC9aqT9wa26bsHEFVxs4ypC4Aets+x a9ga0ehkjhVj/wVo4noW9LIcGuQ620wBNOIJSDMPlI+OZxOvf2Y83bzrGeIzvXPC0BcP n6OQ== X-Gm-Message-State: AOAM533SOBdABaK1bMhT33M5fdDaBOJRCIK0n1C6OYWj5NVDyubcA0b+ hUY3W1DkHI0s+d3m1vhpeI3kHC7aK8obUA== X-Google-Smtp-Source: ABdhPJwMlrxICw81DoPq42UPOLv07AXtOu2Kvnj3OQFT6+5HYf2yV4RIVb5DjkVOMRle6/CL9gPybg== X-Received: by 2002:a5d:4b45:0:b0:207:ab91:edd8 with SMTP id w5-20020a5d4b45000000b00207ab91edd8mr3100939wrs.168.1650621910662; Fri, 22 Apr 2022 03:05:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 39/61] hw/arm/virt: Use VIRT_GIC_VERSION_* enum values in create_gic() Date: Fri, 22 Apr 2022 11:04:10 +0100 Message-Id: <20220422100432.2288247-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220422100432.2288247-1-peter.maydell@linaro.org> References: <20220422100432.2288247-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, T_SCC_BODY_TEXT_LINE=-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1650625107204100001 Content-Type: text/plain; charset="utf-8" Everywhere we need to check which GIC version we're using, we look at vms->gic_version and use the VIRT_GIC_VERSION_* enum values, except in create_gic(), which copies vms->gic_version into a local 'int' variable and makes direct comparisons against values 2 and 3. For consistency, change this function to check the GIC version the same way we do elsewhere. This includes not implicitly relying on the enumeration type values happening to match the integer 'revision' values the GIC device object wants. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220408141550.1271295-40-peter.maydell@linaro.org --- hw/arm/virt.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index bb6a2484d81..d5f8b0c74ad 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -690,14 +690,29 @@ static void create_gic(VirtMachineState *vms, MemoryR= egion *mem) /* We create a standalone GIC */ SysBusDevice *gicbusdev; const char *gictype; - int type =3D vms->gic_version, i; + int i; unsigned int smp_cpus =3D ms->smp.cpus; uint32_t nb_redist_regions =3D 0; + int revision; =20 - gictype =3D (type =3D=3D 3) ? gicv3_class_name() : gic_class_name(); + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { + gictype =3D gic_class_name(); + } else { + gictype =3D gicv3_class_name(); + } =20 + switch (vms->gic_version) { + case VIRT_GIC_VERSION_2: + revision =3D 2; + break; + case VIRT_GIC_VERSION_3: + revision =3D 3; + break; + default: + g_assert_not_reached(); + } vms->gic =3D qdev_new(gictype); - qdev_prop_set_uint32(vms->gic, "revision", type); + 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 * interrupts; there are always 32 of the former (mandated by GIC spec= ). @@ -707,7 +722,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) qdev_prop_set_bit(vms->gic, "has-security-extensions", vms->secure= ); } =20 - if (type =3D=3D 3) { + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_3) { uint32_t redist0_capacity =3D vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; uint32_t redist0_count =3D MIN(smp_cpus, redist0_capacity); @@ -742,7 +757,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *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 (type =3D=3D 3) { + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_3) { sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_REDIST].base); if (nb_redist_regions =3D=3D 2) { sysbus_mmio_map(gicbusdev, 2, @@ -780,7 +795,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) ppibase + timer_irq[irq= ])); } =20 - if (type =3D=3D 3) { + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_3) { qemu_irq irq =3D qdev_get_gpio_in(vms->gic, ppibase + ARCH_GIC_MAINT_IRQ); qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interru= pt", @@ -806,9 +821,9 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) =20 fdt_add_gic_node(vms); =20 - if (type =3D=3D 3 && vms->its) { + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_3 && vms->its) { create_its(vms); - } else if (type =3D=3D 2) { + } else if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { create_v2m(vms); } } --=20 2.25.1