From patchwork Mon Jan 29 16:44:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535983 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CED115698D for ; Mon, 29 Jan 2024 16:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546730; cv=none; b=MSMW49Lkwk5QSuPZ1goFeoYOnmsdhiCFtGcbioPcMH8OITccaozQ8/TblkMS2bdePCRvuDK/Kuj06ucbKVbySK3IFC2P9uGXZOu1CamxOXfyNUF+ZxwC7vle4eplsovREA42NDUSTMZUAneg+GcGqq4oKPw8z8UOMCZCl3omeMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546730; c=relaxed/simple; bh=mgVoACQiRZ/ISZRsaw8F5R8pBOgtQqnUgB3Agf5RhcA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hU1ofQeVrScEUNUvxEJSDS1LeH0lfW4/i/OnjejK3SlQOd5gaq0TKItsYnOHzYtSPAbOCCCW5gX6ggP2PBKdzdvSGbEu5EEBccrn698s4564w2AO9kPvj81kPRh5CskgNtnRljFw+SzPgwG0Nt4vP2h9ok/Tnj/q1I/8bqvhmTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SkBKE+9d; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SkBKE+9d" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-40ee705e9bfso32595375e9.0 for ; Mon, 29 Jan 2024 08:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546725; x=1707151525; darn=vger.kernel.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=xBAuw8z0uG8eCaMVzH857DmMp0S8FwvlSIliw26a1Io=; b=SkBKE+9dB/BXGciPm2mx/jLG8QNVMWbDA8Zh648D8WmqdBfW61++dPkedNh6HHGYMQ Tmt6wDo8LeDNMpCgwkH53U9jnHHcjGyRwY/+F9spmIlt+tHUlJm7knjscPK1pGcdM0QK mwnECkEwPh/6kHo5d5JGWKVbUgSmtrJaIW3MQKpfYDGjTKiSntn+E3PQKfYHEkLO4oMo V4qvXaP3MZtMdcLkWiBfGz5Eri7zPZLsBwwVOL+ORS+ohhKuaJaWYwC/x4loCiMroHCW Ax8n94B4hD2PR/hCjc1KWc5H0AxWOF7jtl4IPpxrJqUSo/rGF1nmGAU5DkgaO7prmL2y KcvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546725; x=1707151525; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xBAuw8z0uG8eCaMVzH857DmMp0S8FwvlSIliw26a1Io=; b=mPTIrywl2LDHq7APdAWA2sTrZd7Uif1A4tdB1jTET1b295GlXVjfsZAPKt9emGHS5+ jmbGOpkFiKNl5YQZ8pDsIoZlt7BM3nDX1U+gE9ABjlV06enrkWOfEDcXkerG36tZKBV3 QO2e1Juw6EmvnWPvw9k7NBRtoglWH86GNKZRgn+Pfq6SJtCPzee5kgAHJyNWf9PPE0e0 WQZQyIxWC5uIL5odttQ5NO+Kz5yCzw4Kc6BbuYOO4SwPEmgT+ZTvXSiXbs0D1rVsq/4h koz1e76Q7VVV33xn4Whg+Lk8uRZQhMX56vEZkkZ/WV65BM+zJFllBYZj+R65DeZ55AyS 9OIA== X-Gm-Message-State: AOJu0Yw+J0u8BXEg0vd6pa4FhEduojFgWZeqeAFzy1L53Ue2KtlUK8bh AFi5mFHaoa6gWbCOogG8VtPFiEt90u7MQjjok4bx8DieSOlJaxRqkfqzmqxyt+w= X-Google-Smtp-Source: AGHT+IHdySqf8l0B9eRILTzofQq4FI067bCYaqQHaOlpomTXnMMg2eMjSm5D6MRXFRyoc/eMCrPXNw== X-Received: by 2002:a05:600c:4d96:b0:40e:e7c6:ddd3 with SMTP id v22-20020a05600c4d9600b0040ee7c6ddd3mr5188843wmp.9.1706546725381; Mon, 29 Jan 2024 08:45:25 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id m8-20020a05600c4f4800b0040efc268713sm854310wmq.26.2024.01.29.08.45.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:45:24 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Zhao Liu , Mark Cave-Ayland , "Michael S. Tsirkin" , Marcel Apfelbaum , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= , Nicholas Piggin , =?utf-8?b?RnLDqWTDqXJpYyBCYXJyYXQ=?= , =?utf-8?q?Ale?= =?utf-8?q?x_Benn=C3=A9e?= , Viresh Kumar , mzamazal@redhat.com, Stefano Stabellini , Anthony Perard , Paul Durrant , Peter Xu , Fabiano Rosas , Peter Maydell , Cameron Esfahani , Roman Bolshakov , Laurent Vivier , Daniel Henrique Barboza , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , xen-devel@lists.xenproject.org Subject: [PATCH v3 01/29] bulk: Access existing variables initialized to &S->F when available Date: Mon, 29 Jan 2024 17:44:43 +0100 Message-ID: <20240129164514.73104-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When a variable is initialized to &struct->field, use it in place. Rationale: while this makes the code more concise, this also helps static analyzers. Mechanical change using the following Coccinelle spatch script: @@ type S, F; identifier s, m, v; @@ S *s; ... F *v = &s->m; <+... - &s->m + v ...+> Inspired-by: Zhao Liu Signed-off-by: Philippe Mathieu-Daudé Acked-by: Fabiano Rosas Reviewed-by: Zhao Liu Reviewed-by: Anthony PERARD --- hw/display/ati.c | 2 +- hw/misc/macio/pmu.c | 2 +- hw/misc/pvpanic-pci.c | 2 +- hw/pci-bridge/cxl_root_port.c | 2 +- hw/ppc/pnv.c | 20 ++++++++++---------- hw/virtio/vhost-user-gpio.c | 8 ++++---- hw/virtio/vhost-user-scmi.c | 6 +++--- hw/virtio/virtio-pci.c | 2 +- hw/xen/xen_pt.c | 6 +++--- migration/multifd-zlib.c | 2 +- target/arm/cpu.c | 4 ++-- target/arm/kvm.c | 2 +- target/arm/machine.c | 6 +++--- target/i386/hvf/x86hvf.c | 2 +- target/m68k/helper.c | 2 +- target/ppc/kvm.c | 8 ++++---- target/riscv/cpu_helper.c | 2 +- 17 files changed, 39 insertions(+), 39 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 569b8f6165..8d2501bd82 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -991,7 +991,7 @@ static void ati_vga_realize(PCIDevice *dev, Error **errp) } vga_init(vga, OBJECT(s), pci_address_space(dev), pci_address_space_io(dev), true); - vga->con = graphic_console_init(DEVICE(s), 0, s->vga.hw_ops, &s->vga); + vga->con = graphic_console_init(DEVICE(s), 0, s->vga.hw_ops, vga); if (s->cursor_guest_mode) { vga->cursor_invalidate = ati_cursor_invalidate; vga->cursor_draw_line = ati_cursor_draw_line; diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c index e9a90da88f..7fe1c4e517 100644 --- a/hw/misc/macio/pmu.c +++ b/hw/misc/macio/pmu.c @@ -737,7 +737,7 @@ static void pmu_realize(DeviceState *dev, Error **errp) timer_mod(s->one_sec_timer, s->one_sec_target); if (s->has_adb) { - qbus_init(&s->adb_bus, sizeof(s->adb_bus), TYPE_ADB_BUS, + qbus_init(adb_bus, sizeof(s->adb_bus), TYPE_ADB_BUS, dev, "adb.0"); adb_register_autopoll_callback(adb_bus, pmu_adb_poll, s); } diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c index c01e4ce864..83be95d0d2 100644 --- a/hw/misc/pvpanic-pci.c +++ b/hw/misc/pvpanic-pci.c @@ -48,7 +48,7 @@ static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp) PVPanicPCIState *s = PVPANIC_PCI_DEVICE(dev); PVPanicState *ps = &s->pvpanic; - pvpanic_setup_io(&s->pvpanic, DEVICE(s), 2); + pvpanic_setup_io(ps, DEVICE(s), 2); pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &ps->mr); } diff --git a/hw/pci-bridge/cxl_root_port.c b/hw/pci-bridge/cxl_root_port.c index 8f97697631..2cf2f7bf5f 100644 --- a/hw/pci-bridge/cxl_root_port.c +++ b/hw/pci-bridge/cxl_root_port.c @@ -175,7 +175,7 @@ static void cxl_rp_realize(DeviceState *dev, Error **errp) cxl_cstate->dvsec_offset = CXL_ROOT_PORT_DVSEC_OFFSET; cxl_cstate->pdev = pci_dev; - build_dvsecs(&crp->cxl_cstate); + build_dvsecs(cxl_cstate); cxl_component_register_block_init(OBJECT(pci_dev), cxl_cstate, TYPE_CXL_ROOT_PORT); diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 0297871bdd..202a569e27 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1257,11 +1257,11 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) } /* Processor Service Interface (PSI) Host Bridge */ - object_property_set_int(OBJECT(&chip8->psi), "bar", PNV_PSIHB_BASE(chip), + object_property_set_int(OBJECT(psi8), "bar", PNV_PSIHB_BASE(chip), &error_fatal); - object_property_set_link(OBJECT(&chip8->psi), ICS_PROP_XICS, + object_property_set_link(OBJECT(psi8), ICS_PROP_XICS, OBJECT(chip8->xics), &error_abort); - if (!qdev_realize(DEVICE(&chip8->psi), NULL, errp)) { + if (!qdev_realize(DEVICE(psi8), NULL, errp)) { return; } pnv_xscom_add_subregion(chip, PNV_XSCOM_PSIHB_BASE, @@ -1292,7 +1292,7 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) } pnv_xscom_add_subregion(chip, PNV_XSCOM_OCC_BASE, &chip8->occ.xscom_regs); qdev_connect_gpio_out(DEVICE(&chip8->occ), 0, - qdev_get_gpio_in(DEVICE(&chip8->psi), PSIHB_IRQ_OCC)); + qdev_get_gpio_in(DEVICE(psi8), PSIHB_IRQ_OCC)); /* OCC SRAM model */ memory_region_add_subregion(get_system_memory(), PNV_OCC_SENSOR_BASE(chip), @@ -1543,12 +1543,12 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp) &chip9->xive.xscom_regs); /* Processor Service Interface (PSI) Host Bridge */ - object_property_set_int(OBJECT(&chip9->psi), "bar", PNV9_PSIHB_BASE(chip), + object_property_set_int(OBJECT(psi9), "bar", PNV9_PSIHB_BASE(chip), &error_fatal); /* This is the only device with 4k ESB pages */ - object_property_set_int(OBJECT(&chip9->psi), "shift", XIVE_ESB_4K, + object_property_set_int(OBJECT(psi9), "shift", XIVE_ESB_4K, &error_fatal); - if (!qdev_realize(DEVICE(&chip9->psi), NULL, errp)) { + if (!qdev_realize(DEVICE(psi9), NULL, errp)) { return; } pnv_xscom_add_subregion(chip, PNV9_XSCOM_PSIHB_BASE, @@ -1571,7 +1571,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp) } pnv_xscom_add_subregion(chip, PNV9_XSCOM_OCC_BASE, &chip9->occ.xscom_regs); qdev_connect_gpio_out(DEVICE(&chip9->occ), 0, qdev_get_gpio_in( - DEVICE(&chip9->psi), PSIHB9_IRQ_OCC)); + DEVICE(psi9), PSIHB9_IRQ_OCC)); /* OCC SRAM model */ memory_region_add_subregion(get_system_memory(), PNV9_OCC_SENSOR_BASE(chip), @@ -1586,7 +1586,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp) pnv_xscom_add_subregion(chip, PNV9_XSCOM_SBE_MBOX_BASE, &chip9->sbe.xscom_mbox_regs); qdev_connect_gpio_out(DEVICE(&chip9->sbe), 0, qdev_get_gpio_in( - DEVICE(&chip9->psi), PSIHB9_IRQ_PSU)); + DEVICE(psi9), PSIHB9_IRQ_PSU)); /* HOMER */ object_property_set_link(OBJECT(&chip9->homer), "chip", OBJECT(chip), @@ -1627,7 +1627,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp) PNV9_XSCOM_I2CM_SIZE, &chip9->i2c[i].xscom_regs); qdev_connect_gpio_out(DEVICE(&chip9->i2c[i]), 0, - qdev_get_gpio_in(DEVICE(&chip9->psi), + qdev_get_gpio_in(DEVICE(psi9), PSIHB9_IRQ_SBE_I2C)); } } diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index a83437a5da..6d4e9200ff 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -79,9 +79,9 @@ static int vu_gpio_start(VirtIODevice *vdev) * set needed for the vhost configuration. The backend may also * apply backend_features when the feature set is sent. */ - vhost_ack_features(&gpio->vhost_dev, feature_bits, vdev->guest_features); + vhost_ack_features(vhost_dev, feature_bits, vdev->guest_features); - ret = vhost_dev_start(&gpio->vhost_dev, vdev, false); + ret = vhost_dev_start(vhost_dev, vdev, false); if (ret < 0) { error_report("Error starting vhost-user-gpio: %d", ret); goto err_guest_notifiers; @@ -94,7 +94,7 @@ static int vu_gpio_start(VirtIODevice *vdev) * enabling/disabling irqfd. */ for (i = 0; i < gpio->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&gpio->vhost_dev, vdev, i, false); + vhost_virtqueue_mask(vhost_dev, vdev, i, false); } /* @@ -114,7 +114,7 @@ static int vu_gpio_start(VirtIODevice *vdev) err_guest_notifiers: k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, false); err_host_notifiers: - vhost_dev_disable_notifiers(&gpio->vhost_dev, vdev); + vhost_dev_disable_notifiers(vhost_dev, vdev); return ret; } diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c index 918bb7dcf7..300847e672 100644 --- a/hw/virtio/vhost-user-scmi.c +++ b/hw/virtio/vhost-user-scmi.c @@ -56,9 +56,9 @@ static int vu_scmi_start(VirtIODevice *vdev) goto err_host_notifiers; } - vhost_ack_features(&scmi->vhost_dev, feature_bits, vdev->guest_features); + vhost_ack_features(vhost_dev, feature_bits, vdev->guest_features); - ret = vhost_dev_start(&scmi->vhost_dev, vdev, true); + ret = vhost_dev_start(vhost_dev, vdev, true); if (ret < 0) { error_report("Error starting vhost-user-scmi: %d", ret); goto err_guest_notifiers; @@ -71,7 +71,7 @@ static int vu_scmi_start(VirtIODevice *vdev) * enabling/disabling irqfd. */ for (i = 0; i < scmi->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&scmi->vhost_dev, vdev, i, false); + vhost_virtqueue_mask(vhost_dev, vdev, i, false); } return 0; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 1a7039fb0c..cb6940fc0e 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1929,7 +1929,7 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY; uint8_t *config; uint32_t size; - VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + VirtIODevice *vdev = virtio_bus_get_device(bus); /* * Virtio capabilities present without diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 36e6f93c37..10ddf6bc91 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -710,7 +710,7 @@ static void xen_pt_destroy(PCIDevice *d) { uint8_t intx; int rc; - if (machine_irq && !xen_host_pci_device_closed(&s->real_device)) { + if (machine_irq && !xen_host_pci_device_closed(host_dev)) { intx = xen_pt_pci_intx(s); rc = xc_domain_unbind_pt_irq(xen_xc, xen_domid, machine_irq, PT_IRQ_TYPE_PCI, @@ -759,8 +759,8 @@ static void xen_pt_destroy(PCIDevice *d) { memory_listener_unregister(&s->io_listener); s->listener_set = false; } - if (!xen_host_pci_device_closed(&s->real_device)) { - xen_host_pci_device_put(&s->real_device); + if (!xen_host_pci_device_closed(host_dev)) { + xen_host_pci_device_put(host_dev); } } /* init */ diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 37ce48621e..237ee49928 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -75,7 +75,7 @@ static int zlib_send_setup(MultiFDSendParams *p, Error **errp) err_free_zbuff: g_free(z->zbuff); err_deflate_end: - deflateEnd(&z->zs); + deflateEnd(zs); err_free_z: g_free(z); error_setg(errp, "multifd %u: %s", p->id, err_msg); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b60e103046..60ab8f3242 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2087,7 +2087,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) * We rely on no XScale CPU having VFP so we can use the same bits in the * TB flags field for VECSTRIDE and XSCALE_CPAR. */ - assert(arm_feature(&cpu->env, ARM_FEATURE_AARCH64) || + assert(arm_feature(env, ARM_FEATURE_AARCH64) || !cpu_isar_feature(aa32_vfp_simd, cpu) || !arm_feature(env, ARM_FEATURE_XSCALE)); @@ -2129,7 +2129,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } if (cpu->cfgend) { - if (arm_feature(&cpu->env, ARM_FEATURE_V7)) { + if (arm_feature(env, ARM_FEATURE_V7)) { cpu->reset_sctlr |= SCTLR_EE; } else { cpu->reset_sctlr |= SCTLR_B; diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 81813030a5..ab85d628a8 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1888,7 +1888,7 @@ int kvm_arch_init_vcpu(CPUState *cs) cpu->psci_version = QEMU_PSCI_VERSION_0_2; cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2; } - if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + if (!arm_feature(env, ARM_FEATURE_AARCH64)) { cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_EL1_32BIT; } if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { diff --git a/target/arm/machine.c b/target/arm/machine.c index 9d7dbaea54..b2b39b2475 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -773,7 +773,7 @@ static int cpu_pre_load(void *opaque) env->irq_line_state = UINT32_MAX; if (!kvm_enabled()) { - pmu_op_start(&cpu->env); + pmu_op_start(env); } return 0; @@ -871,11 +871,11 @@ static int cpu_post_load(void *opaque, int version_id) } if (!kvm_enabled()) { - pmu_op_finish(&cpu->env); + pmu_op_finish(env); } if (tcg_enabled()) { - arm_rebuild_hflags(&cpu->env); + arm_rebuild_hflags(env); } return 0; diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c index 3b1ef5f49a..be2c46246e 100644 --- a/target/i386/hvf/x86hvf.c +++ b/target/i386/hvf/x86hvf.c @@ -408,7 +408,7 @@ bool hvf_inject_interrupts(CPUState *cs) if (!(env->hflags & HF_INHIBIT_IRQ_MASK) && (cs->interrupt_request & CPU_INTERRUPT_HARD) && (env->eflags & IF_MASK) && !(info & VMCS_INTR_VALID)) { - int line = cpu_get_pic_interrupt(&x86cpu->env); + int line = cpu_get_pic_interrupt(env); cs->interrupt_request &= ~CPU_INTERRUPT_HARD; if (line >= 0) { wvmcs(cs->accel->fd, VMCS_ENTRY_INTR_INFO, line | diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 14508dfa11..a812f328a1 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -972,7 +972,7 @@ bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size, access_type |= ACCESS_SUPER; } - ret = get_physical_address(&cpu->env, &physical, &prot, + ret = get_physical_address(env, &physical, &prot, address, access_type, &page_size); if (likely(ret == 0)) { tlb_set_page(cs, address & TARGET_PAGE_MASK, diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 26fa9d0575..b95a0b4928 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -635,8 +635,8 @@ static int kvm_put_fp(CPUState *cs) for (i = 0; i < 32; i++) { uint64_t vsr[2]; - uint64_t *fpr = cpu_fpr_ptr(&cpu->env, i); - uint64_t *vsrl = cpu_vsrl_ptr(&cpu->env, i); + uint64_t *fpr = cpu_fpr_ptr(env, i); + uint64_t *vsrl = cpu_vsrl_ptr(env, i); #if HOST_BIG_ENDIAN vsr[0] = float64_val(*fpr); @@ -704,8 +704,8 @@ static int kvm_get_fp(CPUState *cs) for (i = 0; i < 32; i++) { uint64_t vsr[2]; - uint64_t *fpr = cpu_fpr_ptr(&cpu->env, i); - uint64_t *vsrl = cpu_vsrl_ptr(&cpu->env, i); + uint64_t *fpr = cpu_fpr_ptr(env, i); + uint64_t *vsrl = cpu_vsrl_ptr(env, i); reg.addr = (uintptr_t) &vsr; reg.id = vsx ? KVM_REG_PPC_VSR(i) : KVM_REG_PPC_FPR(i); diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index c7cc7eb423..791435d628 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -1200,7 +1200,7 @@ hwaddr riscv_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) CPURISCVState *env = &cpu->env; hwaddr phys_addr; int prot; - int mmu_idx = cpu_mmu_index(&cpu->env, false); + int mmu_idx = cpu_mmu_index(env, false); if (get_physical_address(env, &phys_addr, &prot, addr, NULL, 0, mmu_idx, true, env->virt_enabled, true)) { From patchwork Mon Jan 29 16:44:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535984 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D14F0664D2 for ; Mon, 29 Jan 2024 16:45:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546735; cv=none; b=VQyY4uasYe3cp0TUQDka5H0LfItEKyVYivSjdEkdWk3XnoEAvmxsf+GuG1bUbYzxfQbiY8Kq7eT4lTcHKRzM2b35IRZ1oNmNSaoiyPNCvf1g1OnQIjKRLFahGYVfduW1woUcc3URH/fMNVyZmWEH0dlNU162e6kieiU7+v43WE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546735; c=relaxed/simple; bh=OmiibsMydLqj27Nyh8cdXftUsg08W/YAsFQQTfj9sa8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=skd8tqtlP6JKgKPw65mdmDVOlFE+9zsDLaiuRPyBZijYmRMzk79JVCtJ+7XKtbBQ+SldXwHc0Kooy3drboxrBYhHb8ntkEV+r1Hmo4xSm2Z2x1NCvB7FV3VSYhun7Y+SLJl6RYlptq4NFzMh8gTMYFpBdP+OoOQrFcU1MHPKMy4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SrE7De/w; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SrE7De/w" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40ee9e21f89so28269235e9.0 for ; Mon, 29 Jan 2024 08:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546732; x=1707151532; darn=vger.kernel.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=y2hw1LeDHPXoA09+Z2wFdjf4GaaZ4oIVM8gsKnpZLbQ=; b=SrE7De/wGEpj/OO4n+dejb4cN5qw5wEblYhuwzPqDG/6qjppnaEAZK49OGaw/czaxa eJKqRNyB0pfdlkXu5/dR03kvymoRUsNo8NCcOCwMicY4Q+xJY41SNPkW3dQUvXNn1PDl X7VYVDBWI8JuGVDlu5kttFtEt1Dnv2mnbwW5+/rjKHe7pAETlRONuVJsIovSMdQIQwQJ U2eu5Y6SFDcoMhdadvyF5snmxVP6R2kXFLQigFR5fAwszfxxlOsN4XMFBVKcq4Nv7kaM psvpEPh101rYf7vmzgFT7gR9Eyj9dWlfZhiNfzqcI1PZgpC1dkz2lKBEbhQ6NOvvGfcS semA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546732; x=1707151532; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y2hw1LeDHPXoA09+Z2wFdjf4GaaZ4oIVM8gsKnpZLbQ=; b=I3QgcEtYoBjuvbHOQX4CI1fpv/DnoWNOe1ZK5TrygHlVcg+z5P8QD23h4fjnojCP55 bebESWTybVyw6pUPOKSzO+qqdskQgXmCTNrjdlELhA4nYS7wttfm0h3lempXLSpNryCm kF0P2BBi0krzuETiObfrcbsEYBFPRi3Y+st/Phgg0zswAOhPrqmNKmM+9M3Q8i45D79O 9XrLJPJLuQud9ypzzVyGx2Zf6YA6CcCtsZM2daimk3gzu0stN8IGCFhsh8hpk9Movouv HCRFGAwd2Z9nu+rGSKyrpHsYF6rbQFc5xeodGtRdAFqtCEDYxUe3GAdBF7mEvdMk10i8 cUxA== X-Gm-Message-State: AOJu0YxnR5SvkKirb0DzJJvaYr32DHMyf7nmuXqT5GdJA8Vc9HLWXMiv kXA6AKFLe5M3y09hJSJTNew6jLBXhMilmQriEFsQlJCjBrx2Dv/7xj8Nfd0hNmE= X-Google-Smtp-Source: AGHT+IFVrS1YJ9J2dLNRn+st1RiqDBXNn5RMuFWm57xrM1I/AzlVfdLqJZcKs7joGZxBzXAoy74ufw== X-Received: by 2002:a05:600c:4e8c:b0:40e:e25c:41cf with SMTP id f12-20020a05600c4e8c00b0040ee25c41cfmr5163477wmq.12.1706546732132; Mon, 29 Jan 2024 08:45:32 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id bs3-20020a056000070300b0033aeb7d4537sm3951432wrb.7.2024.01.29.08.45.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:45:31 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , "Michael S. Tsirkin" , Song Gao , Nicholas Piggin , Daniel Henrique Barboza , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , David Gibson , Harsh Prateek Bora , Halil Pasic , Christian Borntraeger , Eric Farman , David Hildenbrand , Ilya Leoshkevich , Thomas Huth Subject: [PATCH v3 02/29] hw/core: Declare CPUArchId::cpu as CPUState instead of Object Date: Mon, 29 Jan 2024 17:44:44 +0100 Message-ID: <20240129164514.73104-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Do not accept any Object for CPUArchId::cpu field, restrict it to CPUState type. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- include/hw/boards.h | 2 +- hw/core/machine.c | 4 ++-- hw/i386/x86.c | 2 +- hw/loongarch/virt.c | 2 +- hw/ppc/spapr.c | 5 ++--- hw/s390x/s390-virtio-ccw.c | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index bcfde8a84d..8b8f6d5c00 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -120,7 +120,7 @@ typedef struct CPUArchId { uint64_t arch_id; int64_t vcpus_count; CpuInstanceProperties props; - Object *cpu; + CPUState *cpu; const char *type; } CPUArchId; diff --git a/hw/core/machine.c b/hw/core/machine.c index fb5afdcae4..854cf00a9b 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -716,7 +716,7 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) mc->possible_cpu_arch_ids(machine); for (i = 0; i < machine->possible_cpus->len; i++) { - Object *cpu; + CPUState *cpu; HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1); cpu_item->type = g_strdup(machine->possible_cpus->cpus[i].type); @@ -726,7 +726,7 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) cpu = machine->possible_cpus->cpus[i].cpu; if (cpu) { - cpu_item->qom_path = object_get_canonical_path(cpu); + cpu_item->qom_path = object_get_canonical_path(OBJECT(cpu)); } QAPI_LIST_PREPEND(head, cpu_item); } diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 2b6291ad8d..19464ea971 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -221,7 +221,7 @@ void x86_cpu_plug(HotplugHandler *hotplug_dev, } found_cpu = x86_find_cpu_slot(MACHINE(x86ms), cpu->apic_id, NULL); - found_cpu->cpu = OBJECT(dev); + found_cpu->cpu = CPU(dev); out: error_propagate(errp, local_err); } diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index c9a680e61a..524a53de06 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -811,7 +811,7 @@ static void loongarch_init(MachineState *machine) for (i = 0; i < possible_cpus->len; i++) { cpu = cpu_create(machine->cpu_type); cpu->cpu_index = i; - machine->possible_cpus->cpus[i].cpu = OBJECT(cpu); + machine->possible_cpus->cpus[i].cpu = cpu; lacpu = LOONGARCH_CPU(cpu); lacpu->phy_id = machine->possible_cpus->cpus[i].arch_id; } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e8dabc8614..0b77aa5514 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3985,7 +3985,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev) SpaprMachineClass *smc = SPAPR_MACHINE_CLASS(mc); SpaprCpuCore *core = SPAPR_CPU_CORE(OBJECT(dev)); CPUCore *cc = CPU_CORE(dev); - CPUState *cs; SpaprDrc *drc; CPUArchId *core_slot; int index; @@ -4019,7 +4018,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev) } } - core_slot->cpu = OBJECT(dev); + core_slot->cpu = CPU(dev); /* * Set compatibility mode to match the boot CPU, which was either set @@ -4035,7 +4034,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev) if (smc->pre_2_10_has_unused_icps) { for (i = 0; i < cc->nr_threads; i++) { - cs = CPU(core->threads[i]); + CPUState *cs = CPU(core->threads[i]); pre_2_10_vmstate_unregister_dummy_icp(cs->cpu_index); } } diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index c99682b07d..69e39e13ff 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -324,7 +324,7 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev, ERRP_GUARD(); g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu); - ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev); + ms->possible_cpus->cpus[cpu->env.core_id].cpu = CPU(dev); if (s390_has_topology()) { s390_topology_setup_cpu(ms, cpu, errp); From patchwork Mon Jan 29 16:44:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535985 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 906DC156985 for ; Mon, 29 Jan 2024 16:45:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546741; cv=none; b=bXB+zRpDNaLJIvchlqnf014IozAIC59H8jkZtIp3g6um8Z7e2YFKHMh5i1XQbSUyEoc8qQ7qXaBOrF8kRTrfJZIBq9TcE4osODM9Qctl7XbiE13wQJjaUNHH9Zad8/JW9q3MHRuL0NCPTfMuwLfoM2IR/mHiJYQ3A/t+555JNUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546741; c=relaxed/simple; bh=ofVK47wtlfiohkIAcZCoxDfNqHXSK7mWUQXexl1YOe8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K0J5lvn9igQ0mM1JkWNXNRYUpOL3RfhiKGm65W1Gx9swmM5cGTzGpxCPOoDjTiqAHvem91yuEarqfFjaUW23oebGGdnAT9PAa5DXjRtB/HJQyE42ttLa00liyXjPicwDsY6Tx/N+X8uuajhJWsKqFGuRNvyNX0TJaOvPSolBzyg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SkZQIuio; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SkZQIuio" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-33aea66a31cso737008f8f.1 for ; Mon, 29 Jan 2024 08:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546738; x=1707151538; darn=vger.kernel.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=DX37RoqmIV4LbscHP0LblED21zanCtHAqywHz6ZSi8I=; b=SkZQIuiobPjKXPOpwPBBRE/96V9BFI2lke2X0Kz9xolTTLN6gDSOrQiNDe/ljj/92Y tEIkdM8wcKF2Z0p4IQP604Z/4rCO3wyFDFJ5q2BjPKApJzYo3zPw4RpiEn19+QYWwN9l +AcYexPKNRBZ0lB7MFoHk1T+m8jO2qmV6jOA/kCy6dxW3kTSSIANsWEgC/y0uwgSRUxY lYLrPzJOoQ0FQ4Nkq19PmXqxtgXtn1Pv8d7xw8vg04RoTgxvNaHWBMGyEMOdP70QEz6w 7KqOB8UxdUkQnywJK5IvLqHigeqTn1zVxd1eSI+LqOcwu9yO5V7o2lbJpIsR1HEMHLVW G8kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546738; x=1707151538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DX37RoqmIV4LbscHP0LblED21zanCtHAqywHz6ZSi8I=; b=CuvPV40OoI+o3mu0/T9bakbdxMNPArRp4NTZx0kttOxKSmkLOok0OtLX+ddrxj7Mql inXtgrY82IBJEeGGqvo3mNoj+fKjrdRF+VrN0eWdNz5AI1Mmrh3M0OZVebU8+3os+HW6 7acmCXjA4kWvXdtuYmRQu+auNmEsCyVXjnFkIjzlTm+7hcDjMLeZ3DNHv2huAeMhtzid 6bezK5J6KD3bB2qU3F+dArOYM8y5zedXK7X6r073uaRPkYoLLpEAT2Z+NiVm7Y7yR2bW 4dQ0smPlbuuWMxSvqFITj6pDhWUFqnIfXrZxTqpDNMTgIcgOoenaCdruDvyeAyFraUno ZjEw== X-Gm-Message-State: AOJu0Yx8bEgofNA58pvY50COuAy8o/SL75BrWAHQV3GFCOUPOUXFIHoi s6vRpaP51BcJKFAEkwuDdFZMuL64MUPgj+t6tpTTcRnbfO4geObo2oT4cHabpnM= X-Google-Smtp-Source: AGHT+IGx14JXv0Db9aHtz3xdBJroRMX/UovaupO29Cg95YnE6U8ErBiRARcqLYVG/qrT9WzZB0Gscw== X-Received: by 2002:a05:6000:1888:b0:33a:f12d:61c3 with SMTP id a8-20020a056000188800b0033af12d61c3mr1992032wri.68.1706546737831; Mon, 29 Jan 2024 08:45:37 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id v9-20020adff689000000b0033af5c43155sm653530wrp.56.2024.01.29.08.45.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:45:37 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Zhao Liu , "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha Subject: [PATCH v3 03/29] hw/acpi/cpu: Use CPUState typedef Date: Mon, 29 Jan 2024 17:44:45 +0100 Message-ID: <20240129164514.73104-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 QEMU coding style recommend using structure typedefs: https://www.qemu.org/docs/master/devel/style.html#typedefs Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Zhao Liu --- include/hw/acpi/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h index bc901660fb..209e1773f8 100644 --- a/include/hw/acpi/cpu.h +++ b/include/hw/acpi/cpu.h @@ -19,7 +19,7 @@ #include "hw/hotplug.h" typedef struct AcpiCpuStatus { - struct CPUState *cpu; + CPUState *cpu; uint64_t arch_id; bool is_inserting; bool is_removing; From patchwork Mon Jan 29 16:44:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535986 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F395D156985 for ; Mon, 29 Jan 2024 16:45:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546748; cv=none; b=OKhsd9esg2M4oOVSWRvv6bB0EnJJlmvdxp+K5p+NS+566Q86U8E9yZPNmA2CpwE9MnCgrXLVFrWH4TPoogg8HGsI42YcLw78OFbfF7BVP3rBwP3HCQfmolfXNHLuqgQZMFeCWWU0wwJuxkjvADBCqgcuaEMgbBMs4g3IW4j13rE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546748; c=relaxed/simple; bh=3fUVOQdxx73b+56s5qDX3zsDOBg9Su1A+p7RaLby12g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pTq8t2041pmdnCURdBFjDDcU7fLq1JzTkBmcSfoz+sQT2CuliLk0o+p10uGY+41ml3jsyc3tiYsu1jM49QNQ6ORVVKkDkSZYQocewjr+l+zN+xnWhG5SPP3Ih4j8hJKxrfJGmglJ/xk4zQHraHXeZM7lAslhrBJL+Esv2aXs+Mk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=vDAvpZ8W; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vDAvpZ8W" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-33af2823edbso508959f8f.0 for ; Mon, 29 Jan 2024 08:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546744; x=1707151544; darn=vger.kernel.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=C8JvjcuG17Z5H/fwKhCgUCDDHXtWs59z4HKxSgYIQak=; b=vDAvpZ8WHviVY5enY6ONzs39Mzux2kqxlFlWufxG91ajdGE2Hhvau1cmMUrXewVcMv LOXCbcaX7+5sL4cwpadg+zfRp2A9w7pfwmXB8QQYs4FomsV3viIVwrKmLsM0MPWDbdkM R3X82GFOGWNBJBpmDQcA/hFblPrqgEe4HW5QImjybKvEQi5x4GY1ivQNrgKOk0iv+ruJ LLIdEOe0r66+ZD5+gkb5M5CX8GVkbGIGdnMo3xyuQK6re/JimnAUa2aC8ZWmLesfV2/Y KPqLq8I+5/+bNCdwEJCLPDowWZNpllv2mONh9LpqMx1IKkSc6o6dHPn+DwEzNTUgbsBU Yz8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546744; x=1707151544; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C8JvjcuG17Z5H/fwKhCgUCDDHXtWs59z4HKxSgYIQak=; b=jV/0tDs5n5IpbGVrvqdkOCTsoxiudB70BP+7fCytkqw0UMMkmhgEfMgdwbHglUmDvX AWOTNkE5fz+hBEV0qyauhupOkYTYscKk+wp0G07Ss4azFeQyTFJdeSTD2SFwUOwrphPC cWKiT6wRu8IYBubqOo73m+1HQ3V/VjPrC4d1sghSKAl1j/R0aW91bZPRaxOuRHJXqfvG f1MSKBPZgL0yWeK00WpjTW0n4MdEEgQsaJbuOAFKSEp0aRieVAec+X6wLMspLYA+K3rW yP3sj1mCyTdiCnT+vH0nFFOQYlwBP4u4o8/VkF7131K5sowih0YgQT5mhrXRTNkze42x pUwQ== X-Gm-Message-State: AOJu0YyTQS0wP07WccLcziilwvHQn9B7kkCzLRTQf5vDz8MmAz/8ct3F ceoEl8XNZ4X06IfBMbG/80tfg6KAOjmRAFNsxhPTl9dUJMlCvjls4RHJGHextw8= X-Google-Smtp-Source: AGHT+IGsRS3mCrSQqdH7/CVh0bHEjVxZxEE4GjqLYzUtvxEToac4oiSaOtdxXr4oh5vfsiDP3ObnIg== X-Received: by 2002:adf:ca8d:0:b0:339:2c1a:5d79 with SMTP id r13-20020adfca8d000000b003392c1a5d79mr4032395wrh.6.1706546744013; Mon, 29 Jan 2024 08:45:44 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id v8-20020a5d59c8000000b0033af2a91b47sm2057984wry.70.2024.01.29.08.45.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:45:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier , Reinoud Zandijk , Sunil Muthuswamy , Song Gao , Yoshinori Sato Subject: [PATCH v3 04/29] bulk: Call in place single use cpu_env() Date: Mon, 29 Jan 2024 17:44:46 +0100 Message-ID: <20240129164514.73104-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Avoid CPUArchState local variable when cpu_env() is used once. Mechanical patch using the following Coccinelle spatch script: @@ type CPUArchState; identifier env; expression cs; @@ { - CPUArchState *env = cpu_env(cs); ... when != env - env + cpu_env(cs) ... when != env } Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- accel/tcg/cpu-exec.c | 3 +-- linux-user/i386/cpu_loop.c | 4 ++-- target/hppa/mem_helper.c | 3 +-- target/hppa/translate.c | 3 +-- target/i386/nvmm/nvmm-all.c | 6 ++---- target/i386/whpx/whpx-all.c | 18 ++++++------------ target/loongarch/tcg/translate.c | 3 +-- target/rx/translate.c | 3 +-- target/sh4/op_helper.c | 4 +--- 9 files changed, 16 insertions(+), 31 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 67eda9865e..86206484f8 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -445,7 +445,6 @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env) static inline TranslationBlock * QEMU_DISABLE_CFI cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) { - CPUArchState *env = cpu_env(cpu); uintptr_t ret; TranslationBlock *last_tb; const void *tb_ptr = itb->tc.ptr; @@ -455,7 +454,7 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) } qemu_thread_jit_execute(); - ret = tcg_qemu_tb_exec(env, tb_ptr); + ret = tcg_qemu_tb_exec(cpu_env(cpu), tb_ptr); cpu->neg.can_do_io = true; qemu_plugin_disable_mem_helpers(cpu); /* diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c index 42ecb4bf0a..92beb6830c 100644 --- a/linux-user/i386/cpu_loop.c +++ b/linux-user/i386/cpu_loop.c @@ -323,8 +323,8 @@ void cpu_loop(CPUX86State *env) static void target_cpu_free(void *obj) { - CPUArchState *env = cpu_env(obj); - target_munmap(env->gdt.base, sizeof(uint64_t) * TARGET_GDT_ENTRIES); + target_munmap(cpu_env(obj)->gdt.base, + sizeof(uint64_t) * TARGET_GDT_ENTRIES); g_free(obj); } diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index 4fcc612754..bb85962d50 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -518,7 +518,6 @@ void HELPER(iitlbt_pa20)(CPUHPPAState *env, target_ulong r1, target_ulong r2) /* Purge (Insn/Data) TLB. */ static void ptlb_work(CPUState *cpu, run_on_cpu_data data) { - CPUHPPAState *env = cpu_env(cpu); vaddr start = data.target_ptr; vaddr end; @@ -532,7 +531,7 @@ static void ptlb_work(CPUState *cpu, run_on_cpu_data data) end = (vaddr)TARGET_PAGE_SIZE << (2 * end); end = start + end - 1; - hppa_flush_tlb_range(env, start, end); + hppa_flush_tlb_range(cpu_env(cpu), start, end); } /* This is local to the current cpu. */ diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 3ef39b1bd7..5735335254 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -3805,8 +3805,7 @@ static bool trans_b_gate(DisasContext *ctx, arg_b_gate *a) #ifndef CONFIG_USER_ONLY if (ctx->tb_flags & PSW_C) { - CPUHPPAState *env = cpu_env(ctx->cs); - int type = hppa_artype_for_page(env, ctx->base.pc_next); + int type = hppa_artype_for_page(cpu_env(ctx->cs), ctx->base.pc_next); /* If we could not find a TLB entry, then we need to generate an ITLB miss exception so the kernel will provide it. The resulting TLB fill operation will invalidate this TB and diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index cfdca91123..49a3a3b916 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -340,7 +340,6 @@ nvmm_get_registers(CPUState *cpu) static bool nvmm_can_take_int(CPUState *cpu) { - CPUX86State *env = cpu_env(cpu); AccelCPUState *qcpu = cpu->accel; struct nvmm_vcpu *vcpu = &qcpu->vcpu; struct nvmm_machine *mach = get_nvmm_mach(); @@ -349,7 +348,7 @@ nvmm_can_take_int(CPUState *cpu) return false; } - if (qcpu->int_shadow || !(env->eflags & IF_MASK)) { + if (qcpu->int_shadow || !(cpu_env(cpu)->eflags & IF_MASK)) { struct nvmm_x64_state *state = vcpu->state; /* Exit on interrupt window. */ @@ -645,13 +644,12 @@ static int nvmm_handle_halted(struct nvmm_machine *mach, CPUState *cpu, struct nvmm_vcpu_exit *exit) { - CPUX86State *env = cpu_env(cpu); int ret = 0; bql_lock(); if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) && - (env->eflags & IF_MASK)) && + (cpu_env(cpu)->eflags & IF_MASK)) && !(cpu->interrupt_request & CPU_INTERRUPT_NMI)) { cpu->exception_index = EXCP_HLT; cpu->halted = true; diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index a7262654ac..31eec7048c 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -300,7 +300,6 @@ static SegmentCache whpx_seg_h2q(const WHV_X64_SEGMENT_REGISTER *hs) /* X64 Extended Control Registers */ static void whpx_set_xcrs(CPUState *cpu) { - CPUX86State *env = cpu_env(cpu); HRESULT hr; struct whpx_state *whpx = &whpx_global; WHV_REGISTER_VALUE xcr0; @@ -311,7 +310,7 @@ static void whpx_set_xcrs(CPUState *cpu) } /* Only xcr0 is supported by the hypervisor currently */ - xcr0.Reg64 = env->xcr0; + xcr0.Reg64 = cpu_env(cpu)->xcr0; hr = whp_dispatch.WHvSetVirtualProcessorRegisters( whpx->partition, cpu->cpu_index, &xcr0_name, 1, &xcr0); if (FAILED(hr)) { @@ -321,7 +320,6 @@ static void whpx_set_xcrs(CPUState *cpu) static int whpx_set_tsc(CPUState *cpu) { - CPUX86State *env = cpu_env(cpu); WHV_REGISTER_NAME tsc_reg = WHvX64RegisterTsc; WHV_REGISTER_VALUE tsc_val; HRESULT hr; @@ -345,7 +343,7 @@ static int whpx_set_tsc(CPUState *cpu) } } - tsc_val.Reg64 = env->tsc; + tsc_val.Reg64 = cpu_env(cpu)->tsc; hr = whp_dispatch.WHvSetVirtualProcessorRegisters( whpx->partition, cpu->cpu_index, &tsc_reg, 1, &tsc_val); if (FAILED(hr)) { @@ -556,7 +554,6 @@ static void whpx_set_registers(CPUState *cpu, int level) static int whpx_get_tsc(CPUState *cpu) { - CPUX86State *env = cpu_env(cpu); WHV_REGISTER_NAME tsc_reg = WHvX64RegisterTsc; WHV_REGISTER_VALUE tsc_val; HRESULT hr; @@ -569,14 +566,13 @@ static int whpx_get_tsc(CPUState *cpu) return -1; } - env->tsc = tsc_val.Reg64; + cpu_env(cpu)->tsc = tsc_val.Reg64; return 0; } /* X64 Extended Control Registers */ static void whpx_get_xcrs(CPUState *cpu) { - CPUX86State *env = cpu_env(cpu); HRESULT hr; struct whpx_state *whpx = &whpx_global; WHV_REGISTER_VALUE xcr0; @@ -594,7 +590,7 @@ static void whpx_get_xcrs(CPUState *cpu) return; } - env->xcr0 = xcr0.Reg64; + cpu_env(cpu)->xcr0 = xcr0.Reg64; } static void whpx_get_registers(CPUState *cpu) @@ -1400,8 +1396,7 @@ static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid) { if (cpu->vcpu_dirty) { /* The CPU registers have been modified by other parts of QEMU. */ - CPUArchState *env = cpu_env(cpu); - return env->eip; + return cpu_env(cpu)->eip; } else if (exit_context_valid) { /* * The CPU registers have not been modified by neither other parts @@ -1439,12 +1434,11 @@ static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid) static int whpx_handle_halt(CPUState *cpu) { - CPUX86State *env = cpu_env(cpu); int ret = 0; bql_lock(); if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) && - (env->eflags & IF_MASK)) && + (cpu_env(cpu)->eflags & IF_MASK)) && !(cpu->interrupt_request & CPU_INTERRUPT_NMI)) { cpu->exception_index = EXCP_HLT; cpu->halted = true; diff --git a/target/loongarch/tcg/translate.c b/target/loongarch/tcg/translate.c index 21f4db6fbd..7bb8cecab3 100644 --- a/target/loongarch/tcg/translate.c +++ b/target/loongarch/tcg/translate.c @@ -282,10 +282,9 @@ static uint64_t make_address_pc(DisasContext *ctx, uint64_t addr) static void loongarch_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { - CPULoongArchState *env = cpu_env(cs); DisasContext *ctx = container_of(dcbase, DisasContext, base); - ctx->opcode = translator_ldl(env, &ctx->base, ctx->base.pc_next); + ctx->opcode = translator_ldl(cpu_env(cs), &ctx->base, ctx->base.pc_next); if (!decode(ctx, ctx->opcode)) { qemu_log_mask(LOG_UNIMP, "Error: unknown opcode. " diff --git a/target/rx/translate.c b/target/rx/translate.c index c6ce717a95..1829a0b1cd 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -2195,9 +2195,8 @@ static bool trans_WAIT(DisasContext *ctx, arg_WAIT *a) static void rx_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) { - CPURXState *env = cpu_env(cs); DisasContext *ctx = container_of(dcbase, DisasContext, base); - ctx->env = env; + ctx->env = cpu_env(cs); ctx->tb_flags = ctx->base.tb->flags; } diff --git a/target/sh4/op_helper.c b/target/sh4/op_helper.c index 54d390fe1f..4559d0d376 100644 --- a/target/sh4/op_helper.c +++ b/target/sh4/op_helper.c @@ -29,9 +29,7 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - CPUSH4State *env = cpu_env(cs); - - env->tea = addr; + cpu_env(cs)->tea = addr; switch (access_type) { case MMU_INST_FETCH: case MMU_DATA_LOAD: From patchwork Mon Jan 29 16:44:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535987 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EFEE15697A for ; Mon, 29 Jan 2024 16:45:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546753; cv=none; b=j89dFoZ/NfPePq+9g7aHmJczcchec7R4LcJSEdScwkl9qqoFSid9dY4jpnvQMnUhSubpbyDq+E6sCVQ7yLX+IHh9OixVzETlE0iEm12xrXTPqNpEu5HfTv0r+P4KGfLuJDt2lRKGfWhL1VEu1v6zNW826Cdc0GZTQeqxuFtpTCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546753; c=relaxed/simple; bh=Dfve9lvAhrJFI2u612phHcaW1dV02y8xZ3hniKcxslk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=apY+llsWKqFhVBVV5EwL/DO8fZRgCMfxaS88L6J1KynbcCrSVe8f7WHAzJvL1bKesfJtfsAuJ62XLkRVM2+p/AovAUSJABLSccq3jHtTcTcgQIN0juWXE7YlMTKJBIvg2ZKRQGTGhkv/189cKOxLhlK5Cd79JHW5zv64kzYXbkQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ceg8bKg1; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ceg8bKg1" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-40e800461baso44757885e9.3 for ; Mon, 29 Jan 2024 08:45:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546749; x=1707151549; darn=vger.kernel.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=B6GmB2IPQQ3XezKE8bqOs65jaQBYCmOI4YcRWUsHLHk=; b=ceg8bKg1pWcPaH5r9Z7Y0axNk5ZWNKh1bgEEWlv2M8FO0f6TRxAwDz5D2iwEAwtsgN sMxSIh21vfeyNxNUMNCNvFh3en7qUzTKrk9y5WwOXS9iPtETPFq4889va8iVGl9x9zGF pRXeC2FYJBxLl6dsycMVFZaPB6H1z0X6GoG83SKmQfEAo2wqX9j65+tpnZwiI3AyQ/My v3AKcFgPzq1qblN36RRG/AVMYCwsm1Oa0pYtnzEOKeu5Pv95GOgJPgyIoqF/y/S307Am IE3ECKFv0j7piOmStODEhI+NxVUQknuCaOCUd9aG5SKe5VlVBQ1m3Hy21V2B2vRE+aUk zOhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546749; x=1707151549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B6GmB2IPQQ3XezKE8bqOs65jaQBYCmOI4YcRWUsHLHk=; b=U0Sq7wbNUOlxGxwhBIFgyHcebTwSaWcD1XmQRkSls8j4rzQH/kovFZDjZ9oPrAm932 LVsE5YX7y18wP73hP5ecn69YZwLBsOO3lN3+kntOGLCG0llcapDha8XpdrjPGxNvyl10 daV588JVLXblrxFCi2bBAr87mFaVcGBGE0IuQvm13ZTiBXCxHwfO2ONIcDNsuY7p6dra Z1iUJS9SsZ39MSLTJZNZZx+Bve5s/Rpjd2eiRAEEVABSBmfjbfOIQMCTWHOAGLjJHBQk v7w8Fixn2qnsK026t/ok8zAT+XxnizJMURvqeXgJFu+OE0/X5NRq2AT45VzCsIrzFNIC Pkow== X-Gm-Message-State: AOJu0YwvJln//XazrXMIsTkyFPgurU9Ov+bpfoTN9CJcG+LSWKRLVZnM pYJwv47O0K2Tac48C4r6m/rA4gMg593SG9Ew1kwrYg0mA3ikr97tmgW5piCHGJc= X-Google-Smtp-Source: AGHT+IF/M4JMBgkyz42lTen3ZH5avOQ7AmvAMgZOIUtFFNwiFxYGzMm049Zz6nlzZCQLDXADh4NIrw== X-Received: by 2002:a05:600c:1f83:b0:40e:b1f6:2ed7 with SMTP id je3-20020a05600c1f8300b0040eb1f62ed7mr5943831wmb.32.1706546749731; Mon, 29 Jan 2024 08:45:49 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id b6-20020a05600003c600b0033aed4e3b55sm3381414wrg.102.2024.01.29.08.45.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:45:49 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH v3 05/29] scripts/coccinelle: Add cpu_env.cocci script Date: Mon, 29 Jan 2024 17:44:47 +0100 Message-ID: <20240129164514.73104-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a Coccinelle script to convert the following slow path (due to the QOM cast macro): &ARCH_CPU(..)->env to the following fast path: cpu_env(..) Signed-off-by: Philippe Mathieu-Daudé --- MAINTAINERS | 1 + scripts/coccinelle/cpu_env.cocci | 100 +++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 scripts/coccinelle/cpu_env.cocci diff --git a/MAINTAINERS b/MAINTAINERS index dfaca8323e..ca3c8c18ab 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -157,6 +157,7 @@ F: accel/tcg/ F: accel/stubs/tcg-stub.c F: util/cacheinfo.c F: util/cacheflush.c +F: scripts/coccinelle/cpu_env.cocci F: scripts/decodetree.py F: docs/devel/decodetree.rst F: docs/devel/tcg* diff --git a/scripts/coccinelle/cpu_env.cocci b/scripts/coccinelle/cpu_env.cocci new file mode 100644 index 0000000000..5a70c2211a --- /dev/null +++ b/scripts/coccinelle/cpu_env.cocci @@ -0,0 +1,100 @@ +/* + * Convert &ARCH_CPU(..)->env to use cpu_env(..). + * + * Rationale: ARCH_CPU() might be slow, being a QOM cast macro. + * cpu_env() is its fast equivalent. + * CPU() macro is a no-op. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * SPDX-FileCopyrightText: Linaro Ltd 2024 + * SPDX-FileContributor: Philippe Mathieu-Daudé + */ + +@@ +type ArchCPU =~ "CPU$"; +identifier cpu; +type CPUArchState =~ "^CPU"; +identifier env; +@@ + ArchCPU *cpu; + ... + CPUArchState *env = &cpu->env; + <... +- &cpu->env ++ env + ...> + + +/* + * Due to commit 8ce5c64499 ("semihosting: Return failure from + * softmmu-uaccess.h functions"), skip functions using softmmu-uaccess.h + * macros (they don't pass 'env' as argument). + */ +@ uaccess_api_used exists @ +identifier semihosting_func =~ "^(put|get)_user_[us](al|8|16|32)$"; +@@ + semihosting_func(...) + + +/* + * Argument is CPUState* + */ +@ cpustate_arg depends on !uaccess_api_used @ +identifier cpu; +type ArchCPU =~ "CPU$"; +type CPUArchState; +identifier ARCH_CPU =~ "CPU$"; +identifier env; +CPUState *cs; +@@ +- ArchCPU *cpu = ARCH_CPU(cs); + ... +- CPUArchState *env = &cpu->env; ++ CPUArchState *env = cpu_env(cs); + ... when != cpu + + +/* + * Argument is not CPUState* but a related QOM object. + * CPU() is not a QOM macro but a cast (See commit 0d6d1ab499). + */ +@ depends on !uaccess_api_used && !cpustate_arg @ +identifier cpu; +type ArchCPU =~ "CPU$"; +type CPUArchState; +identifier ARCH_CPU =~ "CPU$"; +identifier env; +expression cs; +@@ +- ArchCPU *cpu = ARCH_CPU(cs); + ... +- CPUArchState *env = &cpu->env; ++ CPUArchState *env = cpu_env(CPU(cs)); + ... when != cpu + + +/* When single use of 'env', call cpu_env() in place */ +@ depends on !uaccess_api_used @ +type CPUArchState; +identifier env; +expression cs; +@@ +- CPUArchState *env = cpu_env(cs); + ... when != env +- env ++ cpu_env(cs) + ... when != env + + +/* Both first_cpu/current_cpu are extern CPUState* */ +@@ +symbol first_cpu; +symbol current_cpu; +@@ +( +- CPU(first_cpu) ++ first_cpu +| +- CPU(current_cpu) ++ current_cpu +) From patchwork Mon Jan 29 16:44:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535988 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E45B0153BCE for ; Mon, 29 Jan 2024 16:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546763; cv=none; b=BYCnk10Sowdfpo4TEzleyUSpIbl3wG16/loWramX7Bwo3fWxP3Sv/MDJFTxOxAXs1tVplliswTcJN1qVn/UqdKTbQEBlz1sKvZYxYzekz1TvN5+hTtgrMncVN1Jtc1KF3wDkXWUvWbhFjTtlCvMFo6hKuSwtl0gKBEP5Z06stV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546763; c=relaxed/simple; bh=e3ZYkRniIS9tVtUi9St71+z2u/FM0q+jPMYsJO6LbTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EVHBQyMRLH3U+Lheysdd3qTEFKpJ5CrMNKOsLH4JTscJ9z9UdS4hUwBhaZ1pWgP43gEwzVoCtDuPRN6by/BPmrxp62mtOTLe1TO5n9DYtRBJuKy3/GflP6B6rwXQnLHEILL1rw91ZAPvA/FnmbywnYAjWuWuiwcUkAn/XILm3Go= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Pp3Ec0Yh; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Pp3Ec0Yh" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-33ae38df9d2so1708866f8f.3 for ; Mon, 29 Jan 2024 08:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546758; x=1707151558; darn=vger.kernel.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=ToHK+HKGdiJp+sEUEXA9pvpmoAbDWVbOtuhkHM5nAUs=; b=Pp3Ec0YhhkUlo697Qc4Ov4imDyl2EabKF07+3DuAtpYuCbkpL3zEc7ViDEz616zANV G1Jk7WUZoC8EFIvP399JvEdYAcDvaHj2Hioy/2NzIwlNKw5CZoszkJzK7HYR3sG+nwyW pC9YLeJR+x/Xc8Ta24SJkkKg6Qexm+zmSCTNNZ3tVl24H4gyqgYJnHIoP9Xb41w4XpVk 7nNG4tK+JqAfhOVg7F45wHE4ruzhCEuDpyATkeCLjE1cDJwKH/WBdnNzU2C3jvjxzwRG jBQ23bKAfbm46Iv54uL3iS30dfS4GGE93ZQbyy48CH/Pi+uzhoDuprn4Ukxy/JO4fLBC LE8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546758; x=1707151558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ToHK+HKGdiJp+sEUEXA9pvpmoAbDWVbOtuhkHM5nAUs=; b=Mw69dOsmxLb4VaB9yztI8aXTohlC8dchM9Af2d3eJMa6iEDJ7T8fEEyoCldThe6Tic m/HEtKnQnPEuvmDgbYCaXy4BeELyL8HKpvnbstQSM63fppchC3Zj/cQdvP9PSjRZ5olo oZUOn0rlr1KfquDo8G1KFicQ3TIM/QeQPPUcLb03z2AykUGEK4xIfTkM7b1C2kMfST87 zUY8CVRr/B5UztOjSm/LYpTjf1gNpOJkKqImyVEASfxjLV5yAPp7YxtcZFCjDkMmzYdk Asaw5EqtW6WpLXbzIapnZqU0tnxrtOIb7FqCjjCTrN0CZCDcdRZ+V2rn3ngKKZ7a8fM+ EMEg== X-Gm-Message-State: AOJu0Yw49sYocz2kfR1jXPkvikdvTbDLRoj4J2jvupS9BJLADrGRnTJu JkX5nkwI5HLfpYolC1k73Qf8Tk0woobF3x7/FhE4/BVHjHIWmS7I8xuhsZH279I= X-Google-Smtp-Source: AGHT+IF61qD8G7s4vfL0JnXU60CJz7kqXB9Iq6Bv8jWrWEKI1XEtYhFyxmEQuvkuzF+s/E0uz/WcNg== X-Received: by 2002:a05:6000:1888:b0:33a:f172:9a43 with SMTP id a8-20020a056000188800b0033af1729a43mr2206152wri.47.1706546758111; Mon, 29 Jan 2024 08:45:58 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id fa1-20020a056000258100b0033af5716a7fsm815673wrb.61.2024.01.29.08.45.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:45:57 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Brian Cain , Song Gao , Laurent Vivier , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Nicholas Piggin , Daniel Henrique Barboza , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Yoshinori Sato , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov Subject: [PATCH v3 06/29] target: Replace CPU_GET_CLASS(cpu -> obj) in cpu_reset_hold() handler Date: Mon, 29 Jan 2024 17:44:48 +0100 Message-ID: <20240129164514.73104-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since CPU() macro is a simple cast, the following are equivalent: Object *obj; CPUState *cs = CPU(obj) In order to ease static analysis when running scripts/coccinelle/cpu_env.cocci from the previous commit, replace: - CPU_GET_CLASS(cpu); + CPU_GET_CLASS(obj); Most code use the 'cs' variable name for CPUState handle. Replace few 's' -> 'cs' to unify cpu_reset_hold() style. No logical change in this patch. Signed-off-by: Philippe Mathieu-Daudé --- target/arm/cpu.c | 14 +++++++------- target/avr/cpu.c | 2 +- target/cris/cpu.c | 2 +- target/hexagon/cpu.c | 2 +- target/i386/cpu.c | 14 +++++++------- target/loongarch/cpu.c | 2 +- target/m68k/cpu.c | 6 +++--- target/microblaze/cpu.c | 6 +++--- target/mips/cpu.c | 2 +- target/nios2/cpu.c | 2 +- target/openrisc/cpu.c | 8 ++++---- target/ppc/cpu_init.c | 12 ++++++------ target/riscv/cpu.c | 2 +- target/rx/cpu.c | 2 +- target/sh4/cpu.c | 6 +++--- target/sparc/cpu.c | 6 +++--- target/tricore/cpu.c | 6 +++--- target/xtensa/cpu.c | 8 ++++---- 18 files changed, 51 insertions(+), 51 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 60ab8f3242..e5deb5195b 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -209,9 +209,9 @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque) static void arm_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - ARMCPU *cpu = ARM_CPU(s); - ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + ARMCPU *cpu = ARM_CPU(cs); + ARMCPUClass *acc = ARM_CPU_GET_CLASS(obj); CPUARMState *env = &cpu->env; if (acc->parent_phases.hold) { @@ -228,7 +228,7 @@ static void arm_cpu_reset_hold(Object *obj) env->vfp.xregs[ARM_VFP_MVFR1] = cpu->isar.mvfr1; env->vfp.xregs[ARM_VFP_MVFR2] = cpu->isar.mvfr2; - cpu->power_state = s->start_powered_off ? PSCI_OFF : PSCI_ON; + cpu->power_state = cs->start_powered_off ? PSCI_OFF : PSCI_ON; if (arm_feature(env, ARM_FEATURE_IWMMXT)) { env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q'; @@ -433,7 +433,7 @@ static void arm_cpu_reset_hold(Object *obj) /* Load the initial SP and PC from offset 0 and 4 in the vector table */ vecbase = env->v7m.vecbase[env->v7m.secure]; - rom = rom_ptr_for_as(s->as, vecbase, 8); + rom = rom_ptr_for_as(cs->as, vecbase, 8); if (rom) { /* Address zero is covered by ROM which hasn't yet been * copied into physical memory. @@ -446,8 +446,8 @@ static void arm_cpu_reset_hold(Object *obj) * it got copied into memory. In the latter case, rom_ptr * will return a NULL pointer and we should use ldl_phys instead. */ - initial_msp = ldl_phys(s->as, vecbase); - initial_pc = ldl_phys(s->as, vecbase + 4); + initial_msp = ldl_phys(cs->as, vecbase); + initial_pc = ldl_phys(cs->as, vecbase + 4); } qemu_log_mask(CPU_LOG_INT, diff --git a/target/avr/cpu.c b/target/avr/cpu.c index f5cbdc4a8c..0f191a4c9d 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -74,7 +74,7 @@ static void avr_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); AVRCPU *cpu = AVR_CPU(cs); - AVRCPUClass *mcc = AVR_CPU_GET_CLASS(cpu); + AVRCPUClass *mcc = AVR_CPU_GET_CLASS(obj); CPUAVRState *env = &cpu->env; if (mcc->parent_phases.hold) { diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 9ba08e8b0c..4187e0ef3c 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -60,7 +60,7 @@ static void cris_cpu_reset_hold(Object *obj) { CPUState *s = CPU(obj); CRISCPU *cpu = CRIS_CPU(s); - CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(cpu); + CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(obj); CPUCRISState *env = &cpu->env; uint32_t vr; diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index c0cd739e15..085d6c0115 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -289,7 +289,7 @@ static void hexagon_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); HexagonCPU *cpu = HEXAGON_CPU(cs); - HexagonCPUClass *mcc = HEXAGON_CPU_GET_CLASS(cpu); + HexagonCPUClass *mcc = HEXAGON_CPU_GET_CLASS(obj); CPUHexagonState *env = &cpu->env; if (mcc->parent_phases.hold) { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 03822d9ba8..66345c204a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6690,9 +6690,9 @@ static void x86_cpu_set_sgxlepubkeyhash(CPUX86State *env) static void x86_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - X86CPU *cpu = X86_CPU(s); - X86CPUClass *xcc = X86_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + X86CPU *cpu = X86_CPU(cs); + X86CPUClass *xcc = X86_CPU_GET_CLASS(obj); CPUX86State *env = &cpu->env; target_ulong cr4; uint64_t xcr0; @@ -6780,8 +6780,8 @@ static void x86_cpu_reset_hold(Object *obj) memset(env->dr, 0, sizeof(env->dr)); env->dr[6] = DR6_FIXED_1; env->dr[7] = DR7_FIXED_1; - cpu_breakpoint_remove_all(s, BP_CPU); - cpu_watchpoint_remove_all(s, BP_CPU); + cpu_breakpoint_remove_all(cs, BP_CPU); + cpu_watchpoint_remove_all(cs, BP_CPU); cr4 = 0; xcr0 = XSTATE_FP_MASK; @@ -6832,9 +6832,9 @@ static void x86_cpu_reset_hold(Object *obj) env->triple_fault_pending = false; #if !defined(CONFIG_USER_ONLY) /* We hard-wire the BSP to the first CPU. */ - apic_designate_bsp(cpu->apic_state, s->cpu_index == 0); + apic_designate_bsp(cpu->apic_state, cs->cpu_index == 0); - s->halted = !cpu_is_bsp(cpu); + cs->halted = !cpu_is_bsp(cpu); if (kvm_enabled()) { kvm_arch_reset_vcpu(cpu); diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 064540397d..3094bbc0d9 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -500,7 +500,7 @@ static void loongarch_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); LoongArchCPU *cpu = LOONGARCH_CPU(cs); - LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(cpu); + LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(obj); CPULoongArchState *env = &cpu->env; if (lacc->parent_phases.hold) { diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 1421e77c2c..4d14d04c33 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -68,9 +68,9 @@ static void m68k_unset_feature(CPUM68KState *env, int feature) static void m68k_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - M68kCPU *cpu = M68K_CPU(s); - M68kCPUClass *mcc = M68K_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + M68kCPU *cpu = M68K_CPU(cs); + M68kCPUClass *mcc = M68K_CPU_GET_CLASS(obj); CPUM68KState *env = &cpu->env; floatx80 nan = floatx80_default_nan(NULL); int i; diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index bbb3335cad..6d4b7c2c8f 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -167,9 +167,9 @@ static void microblaze_cpu_set_irq(void *opaque, int irq, int level) static void mb_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - MicroBlazeCPU *cpu = MICROBLAZE_CPU(s); - MicroBlazeCPUClass *mcc = MICROBLAZE_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); + MicroBlazeCPUClass *mcc = MICROBLAZE_CPU_GET_CLASS(obj); CPUMBState *env = &cpu->env; if (mcc->parent_phases.hold) { diff --git a/target/mips/cpu.c b/target/mips/cpu.c index a0023edd43..6ced52f985 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -188,7 +188,7 @@ static void mips_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); MIPSCPU *cpu = MIPS_CPU(cs); - MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(cpu); + MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(obj); CPUMIPSState *env = &cpu->env; if (mcc->parent_phases.hold) { diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index a27732bf2b..09b122e24d 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -61,7 +61,7 @@ static void nios2_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); Nios2CPU *cpu = NIOS2_CPU(cs); - Nios2CPUClass *ncc = NIOS2_CPU_GET_CLASS(cpu); + Nios2CPUClass *ncc = NIOS2_CPU_GET_CLASS(obj); CPUNios2State *env = &cpu->env; if (ncc->parent_phases.hold) { diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 381ebe00d3..0fdadf9e55 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -75,9 +75,9 @@ static void openrisc_disas_set_info(CPUState *cpu, disassemble_info *info) static void openrisc_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - OpenRISCCPU *cpu = OPENRISC_CPU(s); - OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + OpenRISCCPU *cpu = OPENRISC_CPU(cs); + OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(obj); if (occ->parent_phases.hold) { occ->parent_phases.hold(obj); @@ -88,7 +88,7 @@ static void openrisc_cpu_reset_hold(Object *obj) cpu->env.pc = 0x100; cpu->env.sr = SR_FO | SR_SM; cpu->env.lock_addr = -1; - s->exception_index = -1; + cs->exception_index = -1; cpu_set_fpcsr(&cpu->env, 0); set_float_detect_tininess(float_tininess_before_rounding, diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 344196a8ce..61b8495a90 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7107,9 +7107,9 @@ static bool ppc_cpu_has_work(CPUState *cs) static void ppc_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - PowerPCCPU *cpu = POWERPC_CPU(s); - PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + PowerPCCPU *cpu = POWERPC_CPU(cs); + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(obj); CPUPPCState *env = &cpu->env; target_ulong msr; int i; @@ -7158,8 +7158,8 @@ static void ppc_cpu_reset_hold(Object *obj) env->nip = env->hreset_vector | env->excp_prefix; if (tcg_enabled()) { - cpu_breakpoint_remove_all(s, BP_CPU); - cpu_watchpoint_remove_all(s, BP_CPU); + cpu_breakpoint_remove_all(cs, BP_CPU); + cpu_watchpoint_remove_all(cs, BP_CPU); if (env->mmu_model != POWERPC_MMU_REAL) { ppc_tlb_invalidate_all(env); } @@ -7173,7 +7173,7 @@ static void ppc_cpu_reset_hold(Object *obj) env->reserve_addr = (target_ulong)-1ULL; /* Be sure no exception or interrupt is pending */ env->pending_interrupts = 0; - s->exception_index = POWERPC_EXCP_NONE; + cs->exception_index = POWERPC_EXCP_NONE; env->error_code = 0; ppc_irq_reset(cpu); diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8cbfc7e781..1bd99bc5c6 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -875,7 +875,7 @@ static void riscv_cpu_reset_hold(Object *obj) #endif CPUState *cs = CPU(obj); RISCVCPU *cpu = RISCV_CPU(cs); - RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu); + RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(obj); CPURISCVState *env = &cpu->env; if (mcc->parent_phases.hold) { diff --git a/target/rx/cpu.c b/target/rx/cpu.c index c5ffeffe32..58ca26184d 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -67,7 +67,7 @@ static bool rx_cpu_has_work(CPUState *cs) static void rx_cpu_reset_hold(Object *obj) { RXCPU *cpu = RX_CPU(obj); - RXCPUClass *rcc = RX_CPU_GET_CLASS(cpu); + RXCPUClass *rcc = RX_CPU_GET_CLASS(obj); CPURXState *env = &cpu->env; uint32_t *resetvec; diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 806a0ef875..1b03c7bcb1 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -91,9 +91,9 @@ static bool superh_cpu_has_work(CPUState *cs) static void superh_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - SuperHCPU *cpu = SUPERH_CPU(s); - SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + SuperHCPU *cpu = SUPERH_CPU(cs); + SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(obj); CPUSH4State *env = &cpu->env; if (scc->parent_phases.hold) { diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index befa7fc4eb..152bee4f81 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -31,9 +31,9 @@ static void sparc_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - SPARCCPU *cpu = SPARC_CPU(s); - SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + SPARCCPU *cpu = SPARC_CPU(cs); + SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj); CPUSPARCState *env = &cpu->env; if (scc->parent_phases.hold) { diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 8acacdf0c0..9bdaa1593a 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -72,9 +72,9 @@ static void tricore_restore_state_to_opc(CPUState *cs, static void tricore_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - TriCoreCPU *cpu = TRICORE_CPU(s); - TriCoreCPUClass *tcc = TRICORE_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + TriCoreCPU *cpu = TRICORE_CPU(cs); + TriCoreCPUClass *tcc = TRICORE_CPU_GET_CLASS(obj); CPUTriCoreState *env = &cpu->env; if (tcc->parent_phases.hold) { diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 99c0ca130f..ce044466ad 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -90,9 +90,9 @@ bool xtensa_abi_call0(void) static void xtensa_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - XtensaCPU *cpu = XTENSA_CPU(s); - XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(cpu); + CPUState *cs = CPU(obj); + XtensaCPU *cpu = XTENSA_CPU(cs); + XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(obj); CPUXtensaState *env = &cpu->env; bool dfpu = xtensa_option_enabled(env->config, XTENSA_OPTION_DFP_COPROCESSOR); @@ -127,7 +127,7 @@ static void xtensa_cpu_reset_hold(Object *obj) #ifndef CONFIG_USER_ONLY reset_mmu(env); - s->halted = env->runstall; + cs->halted = env->runstall; #endif set_no_signaling_nans(!dfpu, &env->fp_status); set_use_first_nan(!dfpu, &env->fp_status); From patchwork Mon Jan 29 16:44:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535989 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72FFD153BCE for ; Mon, 29 Jan 2024 16:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546767; cv=none; b=nLaksHHlk7zfte1cmu/Kjt4YC2cuCB1pJjeNvc9FhHI9h7ogcf/5Yfu9F2fE6+V7nLlKipm8xA8AFtCek/IJxtwldM4nbaWrJKkDhtFZqB7aIyF2JENhjcPt/GdG/MRxR3k1iZ7gf1tbziGmgHqZg3skoGkM5o3oUFQl4blY1n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546767; c=relaxed/simple; bh=nuNLJVO/OJe0a2/jT/vIwWvFlo0Bw0yZphZv1D+GS1M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RKr0FeP5Pul1AYa7Ym0JF9kFrO758CDsI7fuRBxam7BORqJejmIICYd5AongYb2DHIcrMCM74SjE/Z0dhwiEC8YUwvmEBXfGUgYpf5ZWA/aRvUqiO84sbwCUSyBensk+DQI+1jQuEV1b/pOLeLTvpdei6bEDTZFTCELSmkVnKeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=xGFqlDgE; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xGFqlDgE" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-33af40493f4so479628f8f.3 for ; Mon, 29 Jan 2024 08:46:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546764; x=1707151564; darn=vger.kernel.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=LGNKA1+F8sOT+wzzeFuDW0MVJl/ad3LJJb3kfzi1Tuw=; b=xGFqlDgEFeieSi0rSFMVwd/+6MX6AnMIDZ3Xul6nomCFN3JTLx8lnDcs8wrGBFOmPk jOc3ekYkw9tZqkqbLznUsmbf/b/V0/FM9KEqbuIUFYDcSdVX2gKcKKIL4Xp/up/6DOYg exiL2N1hS7YDleW5iTFE32kVVCSiKJDBATgXC6LZE1j8ELjtNXgUgF8Yov48q1R8TAbw /97+a6ORj/Dd0jYRq8HVKvJtjcNhfubuBMQ1eYJKAv9J/Re/GgGnxa+n06+YfnDSa9QE RKJTURi8HaLy8PstFhgh3kghZoVyI7zCsQeBhlLMP/089lr2ufVF5HxDJPYHbbKoZ3mJ b9Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546764; x=1707151564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LGNKA1+F8sOT+wzzeFuDW0MVJl/ad3LJJb3kfzi1Tuw=; b=GKZ93IO6/wM2rXw7HIqkZ/kZSvPvhC9dB6FnIM2F1WJjA2IePibBD2J1/SiUXf4uTc yzHCevAih7PdOSgVrJZNKREa2VB5aK98Aprl4mkE3tP3BLWpANHaz0I9ii/L0hTjUUoU pQlfM/DeoSyX+T3Y+GcBKUTpmom2tq4w194oQdbMECpvr/ohPXXuRS7vtuFfbjRtfsWL P/YOzEJUMGWUVUjf/KBZiDvdQTGU0qBJKA9kInR7Ra8BK3I9HaO6qzJXPpcugxKC82bA S41PtTlA7vVnmjBjHKZPNW3Y7Bq7wEXcHA1Q9vWtv1fTSeB2PX/ocaSNpx5He+ahLUVk j3hQ== X-Gm-Message-State: AOJu0YyQDAV8xHAONcib4A7Dm1/1eAEcrnS+JSvAkFGN6iTcTcc9mOmt xvncgKV6IwFcKgu8gwKNpyPcgcBsrY/2CL1XsSsLoeKprTyym1Z3tb8YtmZgAx4VrqdHPIoVL6U z X-Google-Smtp-Source: AGHT+IEXV3Ki5IWCz4nhNivs20Xtm4D5RCIZtFll/A9SeJ2KRGM2dIq81Jsin9IhV9P3C8GFjfF1yg== X-Received: by 2002:a5d:5f96:0:b0:33a:e724:63fb with SMTP id dr22-20020a5d5f96000000b0033ae72463fbmr3905171wrb.20.1706546763809; Mon, 29 Jan 2024 08:46:03 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id v7-20020a5d4a47000000b0033aef37ec94sm2523940wrs.113.2024.01.29.08.46.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:03 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH v3 07/29] target/alpha: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:49 +0100 Message-ID: <20240129164514.73104-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/alpha/cpu.c | 31 +++++++------------------------ target/alpha/gdbstub.c | 6 ++---- target/alpha/helper.c | 15 +++++---------- target/alpha/mem_helper.c | 11 +++-------- target/alpha/translate.c | 4 ++-- 5 files changed, 19 insertions(+), 48 deletions(-) diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index b8ed29e343..e21a8936c7 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -130,40 +130,27 @@ static ObjectClass *alpha_cpu_class_by_name(const char *cpu_model) static void ev4_cpu_initfn(Object *obj) { - AlphaCPU *cpu = ALPHA_CPU(obj); - CPUAlphaState *env = &cpu->env; - - env->implver = IMPLVER_2106x; + cpu_env(CPU(obj))->implver = IMPLVER_2106x; } static void ev5_cpu_initfn(Object *obj) { - AlphaCPU *cpu = ALPHA_CPU(obj); - CPUAlphaState *env = &cpu->env; - - env->implver = IMPLVER_21164; + cpu_env(CPU(obj))->implver = IMPLVER_21164; } static void ev56_cpu_initfn(Object *obj) { - AlphaCPU *cpu = ALPHA_CPU(obj); - CPUAlphaState *env = &cpu->env; - - env->amask |= AMASK_BWX; + cpu_env(CPU(obj))->amask |= AMASK_BWX; } static void pca56_cpu_initfn(Object *obj) { - AlphaCPU *cpu = ALPHA_CPU(obj); - CPUAlphaState *env = &cpu->env; - - env->amask |= AMASK_MVI; + cpu_env(CPU(obj))->amask |= AMASK_MVI; } static void ev6_cpu_initfn(Object *obj) { - AlphaCPU *cpu = ALPHA_CPU(obj); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(CPU(obj)); env->implver = IMPLVER_21264; env->amask = AMASK_BWX | AMASK_FIX | AMASK_MVI | AMASK_TRAP; @@ -171,16 +158,12 @@ static void ev6_cpu_initfn(Object *obj) static void ev67_cpu_initfn(Object *obj) { - AlphaCPU *cpu = ALPHA_CPU(obj); - CPUAlphaState *env = &cpu->env; - - env->amask |= AMASK_CIX | AMASK_PREFETCH; + cpu_env(CPU(obj))->amask |= AMASK_CIX | AMASK_PREFETCH; } static void alpha_cpu_initfn(Object *obj) { - AlphaCPU *cpu = ALPHA_CPU(obj); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(CPU(obj)); env->lock_addr = -1; #if defined(CONFIG_USER_ONLY) diff --git a/target/alpha/gdbstub.c b/target/alpha/gdbstub.c index 0f8fa150f8..13694fd321 100644 --- a/target/alpha/gdbstub.c +++ b/target/alpha/gdbstub.c @@ -23,8 +23,7 @@ int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - AlphaCPU *cpu = ALPHA_CPU(cs); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(cs); uint64_t val; CPU_DoubleU d; @@ -59,8 +58,7 @@ int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int alpha_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - AlphaCPU *cpu = ALPHA_CPU(cs); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(cs); target_ulong tmp = ldtul_p(mem_buf); CPU_DoubleU d; diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 970c869771..d6d4353edd 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -286,11 +286,10 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr, hwaddr alpha_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { - AlphaCPU *cpu = ALPHA_CPU(cs); target_ulong phys; int prot, fail; - fail = get_physical_address(&cpu->env, addr, 0, 0, &phys, &prot); + fail = get_physical_address(cpu_env(cs), addr, 0, 0, &phys, &prot); return (fail >= 0 ? -1 : phys); } @@ -298,8 +297,7 @@ bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - AlphaCPU *cpu = ALPHA_CPU(cs); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(cs); target_ulong phys; int prot, fail; @@ -325,8 +323,7 @@ bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, void alpha_cpu_do_interrupt(CPUState *cs) { - AlphaCPU *cpu = ALPHA_CPU(cs); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(cs); int i = cs->exception_index; if (qemu_loglevel_mask(CPU_LOG_INT)) { @@ -435,8 +432,7 @@ void alpha_cpu_do_interrupt(CPUState *cs) bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - AlphaCPU *cpu = ALPHA_CPU(cs); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(cs); int idx = -1; /* We never take interrupts while in PALmode. */ @@ -487,8 +483,7 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags) "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9", "t10", "t11", "ra", "t12", "at", "gp", "sp" }; - AlphaCPU *cpu = ALPHA_CPU(cs); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(cs); int i; qemu_fprintf(f, "PC " TARGET_FMT_lx " PS %02x\n", diff --git a/target/alpha/mem_helper.c b/target/alpha/mem_helper.c index a39b52c5dd..872955f5e7 100644 --- a/target/alpha/mem_helper.c +++ b/target/alpha/mem_helper.c @@ -42,18 +42,14 @@ static void do_unaligned_access(CPUAlphaState *env, vaddr addr, uintptr_t retadd void alpha_cpu_record_sigbus(CPUState *cs, vaddr addr, MMUAccessType access_type, uintptr_t retaddr) { - AlphaCPU *cpu = ALPHA_CPU(cs); - CPUAlphaState *env = &cpu->env; - - do_unaligned_access(env, addr, retaddr); + do_unaligned_access(cpu_env(cs), addr, retaddr); } #else void alpha_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - AlphaCPU *cpu = ALPHA_CPU(cs); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(cs); do_unaligned_access(env, addr, retaddr); cs->exception_index = EXCP_UNALIGN; @@ -67,8 +63,7 @@ void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr) { - AlphaCPU *cpu = ALPHA_CPU(cs); - CPUAlphaState *env = &cpu->env; + CPUAlphaState *env = cpu_env(cs); env->trap_arg0 = addr; env->trap_arg1 = access_type == MMU_DATA_STORE ? 1 : 0; diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 32333081d8..d1188194ba 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -2917,8 +2917,8 @@ static void alpha_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) static void alpha_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *ctx = container_of(dcbase, DisasContext, base); - CPUAlphaState *env = cpu_env(cpu); - uint32_t insn = translator_ldl(env, &ctx->base, ctx->base.pc_next); + uint32_t insn = translator_ldl(cpu_env(cpu), &ctx->base, + ctx->base.pc_next); ctx->base.pc_next += 4; ctx->base.is_jmp = translate_one(ctx, insn); From patchwork Mon Jan 29 16:44:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535990 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D1D715697A for ; Mon, 29 Jan 2024 16:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546774; cv=none; b=mycG3XG3Tko1+tJaE7oQ3vMZQgeXrxoszv4pmHNHXWN+0e6TRTepJLd0Cr45PSasDKGQ8iiVMhJG0lXprsQiNsQ/c9GfrUVOxLRHrH9bgMBjMtWb3dMSLvUHQrP4/tD7QlRJROfWe+TKB6O848aqlteucNU/R/m+ciRH2h+5VCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546774; c=relaxed/simple; bh=HU4+i/qYpWKt9chSsXLx3w/NvhlMfr8mM19ogSHMoDo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cqfB/N0MYFs8LQpCdfY218GNIICPnw889flLipHr+FKhfz3lRVaF7CjLnD4eGHTVCXu/w/1rQo1wLfkRazurh5tKgZoaik6EJcTghheQk7DRq1kUIB6mrmKzWx+3vcj1cjiIbYjz8DJxI7yf+jteHT58SuWUn68sZHUTqFldQ0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Zom0jWK9; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Zom0jWK9" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2cf3a0b2355so35983811fa.0 for ; Mon, 29 Jan 2024 08:46:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546770; x=1707151570; darn=vger.kernel.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=ULT/g8UQ/ZTfsw6fPM1iTJdiFqLqeAPLwCS8P07bPHA=; b=Zom0jWK9Txff8fGuKOruNtYMy0BU2b8BtNaLC3z/IH6fnbo7Vovox+htnAw1qz4aJG WKwrr/7CbhJuS3RSPK1cvbTl/ntUyl78iRpLHqwjbEvZsJxHl6sW5LlRflBavWKuC9Qs RP5kR1vKALLViyMQM8oHV8PtjKuKJDDEjuW9MFmrAtgdTo+rfGzcmuF8Qpp6KCnWXlAd mb3B0YVYyj5tFanu8b2GwEigURBJJdmTRdWlYZ06gdEJVuOXeO+cW7x8QpGm3nger1QW oy+SgfpmzgYJZHvOuMAgiOwZgNw76WcWmnkuDMEA1E2pETQGrAb8wKa2a6W5bXcr1HGU uKbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546770; x=1707151570; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ULT/g8UQ/ZTfsw6fPM1iTJdiFqLqeAPLwCS8P07bPHA=; b=DBntEOAV3c/FqyHWzOUQVv3yz8EGvZ3pfQeL9AdYw9B2kHlUyAtnonyoj6UhXJPl9V EEm+5Mf15mKGF/qNM19WZdDbqPgBvfabCTtrsqhISVYBDKzu/xa8diT0VpJI18xDcWIz vGXdgFsoiRU6SxNTSdxoIbZdmOnHxMb0TGSQmsSDVBTdps9gFCq2ae5zxDzU3BScIXJJ TgdsvRQvR4AqygoD1Hzo5IFYYHtRU6V3Ct1n+m4l9iEBY279Hmd+ODE7k7kbirwE0eTG Zl7uukUCTcj8hVXziraZ+SaUaAU75ViXa+JQkv2XXCfVswTGNaE2HBjuxKn25Zq/kshu 8NIg== X-Gm-Message-State: AOJu0Yzjr+rAQu15YCQksNybgrmvx64hFYe/KOMZlllkerdFg/tv3Ma8 cEbRLs/zTs4138qUNarWCXaM7HD0Bseg+fGou2PyBbyMeBXijPRFfj+IkswE1RA= X-Google-Smtp-Source: AGHT+IEP4UUSkCYVYnu7yKq5e9HVmSRrLQNLZdSXiqwEcOfMM8lHE3iH5My9oVWcYdTSOti8rn8rZg== X-Received: by 2002:a2e:b8c2:0:b0:2cf:274c:caaa with SMTP id s2-20020a2eb8c2000000b002cf274ccaaamr5080107ljp.4.1706546769995; Mon, 29 Jan 2024 08:46:09 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id eo6-20020a056000428600b0033af5086c2dsm1068171wrb.58.2024.01.29.08.46.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Peter Maydell , Alexander Graf Subject: [PATCH v3 08/29] target/arm: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:50 +0100 Message-ID: <20240129164514.73104-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé --- hw/intc/arm_gicv3_cpuif.c | 7 ++----- hw/intc/arm_gicv3_cpuif_common.c | 5 +---- target/arm/cpu.c | 19 +++++-------------- target/arm/debug_helper.c | 8 ++------ target/arm/gdbstub.c | 6 ++---- target/arm/gdbstub64.c | 6 ++---- target/arm/helper.c | 9 +++------ target/arm/hvf/hvf.c | 12 ++++-------- target/arm/kvm.c | 3 +-- target/arm/ptw.c | 3 +-- target/arm/tcg/cpu32.c | 4 +--- target/arm/tcg/translate.c | 3 +-- 12 files changed, 25 insertions(+), 60 deletions(-) diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index e1a60d8c15..80f64a5154 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -182,8 +182,6 @@ static int hppvi_index(GICv3CPUState *cs) * priority than the highest priority list register at every * callsite of HighestPriorityVirtualInterrupt; we check it here.) */ - ARMCPU *cpu = ARM_CPU(cs->cpu); - CPUARMState *env = &cpu->env; int idx = -1; int i; /* Note that a list register entry with a priority of 0xff will @@ -230,7 +228,7 @@ static int hppvi_index(GICv3CPUState *cs) * fails the priority check here. vLPIs are only considered * when we are in Non-Secure state. */ - if (cs->hppvlpi.prio < prio && !arm_is_secure(env)) { + if (cs->hppvlpi.prio < prio && !arm_is_secure(cpu_env(cs->cpu))) { if (cs->hppvlpi.grp == GICV3_G0) { if (cs->ich_vmcr_el2 & ICH_VMCR_EL2_VENG0) { return HPPVI_INDEX_VLPI; @@ -931,8 +929,7 @@ void gicv3_cpuif_update(GICv3CPUState *cs) /* Tell the CPU about its highest priority pending interrupt */ int irqlevel = 0; int fiqlevel = 0; - ARMCPU *cpu = ARM_CPU(cs->cpu); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs->cpu); g_assert(bql_locked()); diff --git a/hw/intc/arm_gicv3_cpuif_common.c b/hw/intc/arm_gicv3_cpuif_common.c index ff1239f65d..bab3c3cdbd 100644 --- a/hw/intc/arm_gicv3_cpuif_common.c +++ b/hw/intc/arm_gicv3_cpuif_common.c @@ -15,8 +15,5 @@ void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s) { - ARMCPU *arm_cpu = ARM_CPU(cpu); - CPUARMState *env = &arm_cpu->env; - - env->gicv3state = (void *)s; + cpu_env(cpu)->gicv3state = (void *)s; }; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index e5deb5195b..23f4de127f 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -53,8 +53,7 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); if (is_a64(env)) { env->pc = value; @@ -67,8 +66,7 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) static vaddr arm_cpu_get_pc(CPUState *cs) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); if (is_a64(env)) { return env->pc; @@ -996,19 +994,15 @@ static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level) static bool arm_cpu_virtio_is_big_endian(CPUState *cs) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - cpu_synchronize_state(cs); - return arm_cpu_data_is_big_endian(env); + return arm_cpu_data_is_big_endian(cpu_env(cs)); } #endif static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) { - ARMCPU *ac = ARM_CPU(cpu); - CPUARMState *env = &ac->env; + CPUARMState *env = cpu_env(cpu); bool sctlr_b; if (is_a64(env)) { @@ -2435,10 +2429,7 @@ static Property arm_cpu_properties[] = { static const gchar *arm_gdb_arch_name(CPUState *cs) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - - if (arm_feature(env, ARM_FEATURE_IWMMXT)) { + if (arm_feature(cpu_env(cs), ARM_FEATURE_IWMMXT)) { return "iwmmxt"; } return "arm"; diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index 7d856acddf..7bd5467414 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -468,8 +468,7 @@ void arm_debug_excp_handler(CPUState *cs) * Called by core code when a watchpoint or breakpoint fires; * need to check which one and raise the appropriate exception. */ - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); CPUWatchpoint *wp_hit = cs->watchpoint_hit; if (wp_hit) { @@ -757,9 +756,6 @@ void hw_breakpoint_update_all(ARMCPU *cpu) vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - /* * In BE32 system mode, target memory is stored byteswapped (on a * little-endian host system), and by the time we reach here (via an @@ -767,7 +763,7 @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len) * to account for that, which means that watchpoints will not match. * Undo the adjustment here. */ - if (arm_sctlr_b(env)) { + if (arm_sctlr_b(cpu_env(cs))) { if (len == 1) { addr ^= 3; } else if (len == 2) { diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 28f546a5ff..dc6c29669c 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -40,8 +40,7 @@ typedef struct RegisterSysregXmlParam { int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); if (n < 16) { /* Core integer register. */ @@ -61,8 +60,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); uint32_t tmp; tmp = ldl_p(mem_buf); diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index d7b79a6589..b9f29b0a60 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -24,8 +24,7 @@ int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); if (n < 31) { /* Core integer register. */ @@ -45,8 +44,7 @@ int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int aarch64_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); uint64_t tmp; tmp = ldq_p(mem_buf); diff --git a/target/arm/helper.c b/target/arm/helper.c index 945d8571a6..a9d2c23df2 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10902,8 +10902,7 @@ static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) * PSTATE A/I/F masks are set based only on the SCR.EA/IRQ/FIQ values. */ uint32_t addr, mask; - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); switch (cs->exception_index) { case EXCP_UDEF: @@ -10981,8 +10980,7 @@ static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) static void arm_cpu_do_interrupt_aarch32(CPUState *cs) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); uint32_t addr; uint32_t mask; int new_mode; @@ -11481,8 +11479,7 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) #ifdef CONFIG_TCG static void tcg_handle_semihosting(CPUState *cs) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); if (is_a64(env)) { qemu_log_mask(CPU_LOG_INT, diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index e5f0f60093..849f0772e6 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1006,8 +1006,7 @@ void hvf_kick_vcpu_thread(CPUState *cpu) static void hvf_raise_exception(CPUState *cpu, uint32_t excp, uint32_t syndrome) { - ARMCPU *arm_cpu = ARM_CPU(cpu); - CPUARMState *env = &arm_cpu->env; + CPUARMState *env = cpu_env(cpu); cpu->exception_index = excp; env->exception.target_el = 1; @@ -1485,8 +1484,7 @@ static bool hvf_sysreg_write_cp(CPUState *cpu, uint32_t reg, uint64_t val) static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val) { - ARMCPU *arm_cpu = ARM_CPU(cpu); - CPUARMState *env = &arm_cpu->env; + CPUARMState *env = cpu_env(cpu); trace_hvf_sysreg_write(reg, SYSREG_OP0(reg), @@ -2152,8 +2150,7 @@ static void hvf_put_gdbstub_debug_registers(CPUState *cpu) */ static void hvf_put_guest_debug_registers(CPUState *cpu) { - ARMCPU *arm_cpu = ARM_CPU(cpu); - CPUARMState *env = &arm_cpu->env; + CPUARMState *env = cpu_env(cpu); hv_return_t r = HV_SUCCESS; int i; @@ -2207,8 +2204,7 @@ static void hvf_arch_set_traps(void) void hvf_arch_update_guest_debug(CPUState *cpu) { - ARMCPU *arm_cpu = ARM_CPU(cpu); - CPUARMState *env = &arm_cpu->env; + CPUARMState *env = cpu_env(cpu); /* Check whether guest debugging is enabled */ cpu->accel->guest_debug_enabled = cpu->singlestep_enabled || diff --git a/target/arm/kvm.c b/target/arm/kvm.c index ab85d628a8..cccb512f23 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1958,8 +1958,7 @@ int kvm_arch_destroy_vcpu(CPUState *cs) /* Callers must hold the iothread mutex lock */ static void kvm_inject_arm_sea(CPUState *c) { - ARMCPU *cpu = ARM_CPU(c); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(c); uint32_t esr; bool same_el; diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 5eb3577bcd..57a761ad68 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -3528,8 +3528,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = cpu_env(cs); ARMMMUIdx mmu_idx = arm_mmu_idx(env); ARMSecuritySpace ss = arm_security_space(env); S1Translate ptw = { diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c index d9e0e2a4dd..e96f1119c0 100644 --- a/target/arm/tcg/cpu32.c +++ b/target/arm/tcg/cpu32.c @@ -102,8 +102,6 @@ void aa32_max_features(ARMCPU *cpu) static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { CPUClass *cc = CPU_GET_CLASS(cs); - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; bool ret = false; /* @@ -115,7 +113,7 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) * currently active exception). */ if (interrupt_request & CPU_INTERRUPT_HARD - && (armv7m_nvic_can_take_pending_exception(env->nvic))) { + && (armv7m_nvic_can_take_pending_exception(cpu_env(cs)->nvic))) { cs->exception_index = EXCP_IRQ; cc->tcg_ops->do_interrupt(cs); ret = true; diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index b3660173d1..ab73250f04 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -9326,7 +9326,6 @@ static void arm_post_translate_insn(DisasContext *dc) static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc = container_of(dcbase, DisasContext, base); - CPUARMState *env = cpu_env(cpu); uint32_t pc = dc->base.pc_next; unsigned int insn; @@ -9356,7 +9355,7 @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) } dc->pc_curr = pc; - insn = arm_ldl_code(env, &dc->base, pc, dc->sctlr_b); + insn = arm_ldl_code(cpu_env(cpu), &dc->base, pc, dc->sctlr_b); dc->insn = insn; dc->base.pc_next = pc + 4; disas_arm_insn(dc, insn); From patchwork Mon Jan 29 16:44:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535991 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B0CB156994 for ; Mon, 29 Jan 2024 16:46:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546779; cv=none; b=LFJrxNpQR1sGlw/7pRD+EMO6s5bLS/s9bL7SIY45DlQZhiWY67a1iwAAnik79tGNdQ2Ea+VrNi0ZK/KbWDFkQQSxP+aaDPGVvFP2NQzrmbIAw6T5KH/oXrfu/4WXApqWYwk2xcEkRH5+747G5j//voqxyi5DUk3I/F73egJ8XG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546779; c=relaxed/simple; bh=NazPBoG4idGkPrQ0qwibwDT624h1U2xsSOeI8rVS6F0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hzeZP0z1rKGk5gK1ElDpJEHCOQFoJD21RcrjRMwBKc+SfzdDBeJj1CIyDalrp78wk2XTAQikTvoPPWhAuj3LTveEgtcnFyN5bfwW9vlFPZQ7jxaRM5rb0ZZwrMozBIVQaDwdIaNqSoER2d3n+9/Xra0TEZQ/OhnylHtn3FuuL+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=zVKdNBS6; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zVKdNBS6" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40ef6454277so10536275e9.2 for ; Mon, 29 Jan 2024 08:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546776; x=1707151576; darn=vger.kernel.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=pPVrCbRU1M9we1PYSP3dETCN8UlJAlkr84+2F+spRWs=; b=zVKdNBS6jaGAh7z4fpppqnyJfwh/OBLVy3uvh5s37FBJanueKCeJ/wJtJNr0s8+Chq Qk9WACfsVLSasd3ePG8i96xFP4CmVRf2rjnyDFpFmM5385yCH/AZ54cXEXgB6C136qA/ c1sgs5r4N9hg8KOq/5yfZ2Yj2yGh3iOdd6/+Iwvnp3t7DLxU3OvWmU9JtIEibHgl4mV4 MAaKoOVb3shuEUhebGBOn7kbRN48w+K55BNmBeXetlpLoZ4oPFvDPqhPJYa083uLrqjR tbTirVEcZLufZXQyylL/wMLfDAKS5/kbuf0K9kQNYVxXLmLj+Z0hvUuSo2iYSmgERk+t B14Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546776; x=1707151576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pPVrCbRU1M9we1PYSP3dETCN8UlJAlkr84+2F+spRWs=; b=IZ8AxQo9Dn4ojH12r/byZdH2sgksQGUi9G9ewUyXJDwM1SkuRzD9q2K7BVEjkYxpfM wU2zxSVTVohVVNqeyIOPn8z5Z8FpJfeASbYWDvDLrI9jkkUqnYlIFlm9pVXxkMkdtO29 ylQkc/f3ix4V1zi++0Dtg7TctMkXFgXGU1Ho30gHqrleWJtGHYlkhX44l83RH0XR1/Bs pxKC9AuKn86SVPWVQrUKr2rIcTwjyoelfQK2wh41DMBCxRzLYF57JA7KKtKcx+eZbFz/ hhO4+8kaA+1Kenj6D2BgxMX6m4oVlQzLAtBv4x/5BJlBOr3LcSbV7tgFnnrzIVQBXo9t chEA== X-Gm-Message-State: AOJu0YwiKthOCwLhhPTuv/pdha5EC9PbR3F1txaKJEfT2+w1VgNtLNSz 2J5LMXnTHU8amY+pJ6sAXVt+pppTA+B2/9Y3da/37j8A1YZwNqGB9Jd/knvAkDs= X-Google-Smtp-Source: AGHT+IGoyi1GJloWLT4o+Y6UqAMpV8DbzJbKaJW69srVFEf22YWTwUw/j8yDRVynsB1cqMzyP4ftLg== X-Received: by 2002:a05:600c:35d5:b0:40e:af40:b4da with SMTP id r21-20020a05600c35d500b0040eaf40b4damr6044761wmq.26.1706546775871; Mon, 29 Jan 2024 08:46:15 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id t18-20020a05600c451200b0040e880ac6ecsm14562416wmo.35.2024.01.29.08.46.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:15 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Michael Rolnik Subject: [PATCH v3 09/29] target/avr: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:51 +0100 Message-ID: <20240129164514.73104-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/avr/cpu.c | 27 +++++++-------------------- target/avr/gdbstub.c | 6 ++---- target/avr/helper.c | 10 +++------- target/avr/translate.c | 3 +-- 4 files changed, 13 insertions(+), 33 deletions(-) diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 0f191a4c9d..50ded8538b 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -43,31 +43,22 @@ static vaddr avr_cpu_get_pc(CPUState *cs) static bool avr_cpu_has_work(CPUState *cs) { - AVRCPU *cpu = AVR_CPU(cs); - CPUAVRState *env = &cpu->env; - return (cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_RESET)) - && cpu_interrupts_enabled(env); + && cpu_interrupts_enabled(cpu_env(cs)); } static void avr_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { - AVRCPU *cpu = AVR_CPU(cs); - CPUAVRState *env = &cpu->env; - tcg_debug_assert(!(cs->tcg_cflags & CF_PCREL)); - env->pc_w = tb->pc / 2; /* internally PC points to words */ + cpu_env(cs)->pc_w = tb->pc / 2; /* internally PC points to words */ } static void avr_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - AVRCPU *cpu = AVR_CPU(cs); - CPUAVRState *env = &cpu->env; - - env->pc_w = data[0]; + cpu_env(cs)->pc_w = data[0]; } static void avr_cpu_reset_hold(Object *obj) @@ -165,8 +156,7 @@ static ObjectClass *avr_cpu_class_by_name(const char *cpu_model) static void avr_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - AVRCPU *cpu = AVR_CPU(cs); - CPUAVRState *env = &cpu->env; + CPUAVRState *env = cpu_env(cs); int i; qemu_fprintf(f, "\n"); @@ -276,8 +266,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) */ static void avr_avr5_initfn(Object *obj) { - AVRCPU *cpu = AVR_CPU(obj); - CPUAVRState *env = &cpu->env; + CPUAVRState *env = cpu_env(CPU(obj)); set_avr_feature(env, AVR_FEATURE_LPM); set_avr_feature(env, AVR_FEATURE_IJMP_ICALL); @@ -305,8 +294,7 @@ static void avr_avr5_initfn(Object *obj) */ static void avr_avr51_initfn(Object *obj) { - AVRCPU *cpu = AVR_CPU(obj); - CPUAVRState *env = &cpu->env; + CPUAVRState *env = cpu_env(CPU(obj)); set_avr_feature(env, AVR_FEATURE_LPM); set_avr_feature(env, AVR_FEATURE_IJMP_ICALL); @@ -335,8 +323,7 @@ static void avr_avr51_initfn(Object *obj) */ static void avr_avr6_initfn(Object *obj) { - AVRCPU *cpu = AVR_CPU(obj); - CPUAVRState *env = &cpu->env; + CPUAVRState *env = cpu_env(CPU(obj)); set_avr_feature(env, AVR_FEATURE_LPM); set_avr_feature(env, AVR_FEATURE_IJMP_ICALL); diff --git a/target/avr/gdbstub.c b/target/avr/gdbstub.c index 150344d8b9..2eeee2bf4e 100644 --- a/target/avr/gdbstub.c +++ b/target/avr/gdbstub.c @@ -23,8 +23,7 @@ int avr_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - AVRCPU *cpu = AVR_CPU(cs); - CPUAVRState *env = &cpu->env; + CPUAVRState *env = cpu_env(cs); /* R */ if (n < 32) { @@ -53,8 +52,7 @@ int avr_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int avr_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - AVRCPU *cpu = AVR_CPU(cs); - CPUAVRState *env = &cpu->env; + CPUAVRState *env = cpu_env(cs); /* R */ if (n < 32) { diff --git a/target/avr/helper.c b/target/avr/helper.c index fdc9884ea0..eeca415c43 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -30,8 +30,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - AVRCPU *cpu = AVR_CPU(cs); - CPUAVRState *env = &cpu->env; + CPUAVRState *env = cpu_env(cs); /* * We cannot separate a skip from the next instruction, @@ -69,8 +68,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request) void avr_cpu_do_interrupt(CPUState *cs) { - AVRCPU *cpu = AVR_CPU(cs); - CPUAVRState *env = &cpu->env; + CPUAVRState *env = cpu_env(cs); uint32_t ret = env->pc_w; int vector = 0; @@ -144,9 +142,7 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size, if (probe) { page_size = 1; } else { - AVRCPU *cpu = AVR_CPU(cs); - CPUAVRState *env = &cpu->env; - env->fullacc = 1; + cpu_env(cs)->fullacc = 1; cpu_loop_exit_restore(cs, retaddr); } } diff --git a/target/avr/translate.c b/target/avr/translate.c index cdffa04519..682a44139e 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -2657,11 +2657,10 @@ static bool canonicalize_skip(DisasContext *ctx) static void avr_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) { DisasContext *ctx = container_of(dcbase, DisasContext, base); - CPUAVRState *env = cpu_env(cs); uint32_t tb_flags = ctx->base.tb->flags; ctx->cs = cs; - ctx->env = env; + ctx->env = cpu_env(cs); ctx->npc = ctx->base.pc_first / 2; ctx->skip_cond = TCG_COND_NEVER; From patchwork Mon Jan 29 16:44:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535992 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57E0C156970 for ; Mon, 29 Jan 2024 16:46:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546785; cv=none; b=bDeww/oXEHRJ5rZ07EtjjLIPEmAOTFOg8Q/LBFg3BOqRPQVJvD+P3wN6IKLAgqbf3rrzQU7hcdYYHHtJo5LTTPqmp1Td4DWbIdNnhHj2jKBbcnin+bGd6pf9nsRIvysA6jlNNLBO3kVG7JUqLb0YZwZab5VzFmA/Vx18qLuwxCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546785; c=relaxed/simple; bh=WQdcgXZXFPDVxFFne9SgVYtInJL2FCmyUtPTFJK3D5I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ggVyb97eI+1PrIk0O9mKh34t0QoucGVZ6I4SctBwRo0nAL7wMk1Mz18l1xylQWSyXLTeA5sGzDjZYTIlA0oryt9zv1ofKk5XxpPdaI+iFWspEPW9ExwvLwWpZn682K2Pd9fN0y7gNt/jRaKtaSXKfzBAiq+WIQlIIBbwcySMrKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qQFKPulG; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qQFKPulG" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-33ae7ae1c32so1167908f8f.3 for ; Mon, 29 Jan 2024 08:46:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546781; x=1707151581; darn=vger.kernel.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=qs1q2hIX1TKLXUzvNhNiLBWs7dxyWeQLrsbzeUj/euM=; b=qQFKPulGZO9TLXpkAHH/xG9RKyGTKJ1meI9HMF8INLVQsjXF9yK6B6ibW+QNDxzwfj e2e1Oa0CMcUbVzEOBVfK29EuN4DuteIVWRV2yxEQQE1/ESQ5dAprNHiFDsPhgnJBsKSq OB7PMTkh0Hwupsbj5tTCIiAKTIUfJ4S+nkKBxx8m1g16WVc8qLNlMay4eFslGXBKM0lz WTvJ2zVUixA6eOLFZ8r7qwHYzhy7D5FZVxoRTVnWX2Iet1h/lqnE6HDNxmhGGG1lHITB H93oJ5ZI3OjR9uaf0gjIy//gs3aCuMbxTMNIF/z0Z9VNqCKLhMJT32GyAftNYXa61w/u Qb/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546781; x=1707151581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qs1q2hIX1TKLXUzvNhNiLBWs7dxyWeQLrsbzeUj/euM=; b=gHLZgrmorMCRLt68eEDzHk0G9EEY3sAmrwNOOkDno2jTKCzLh67zCnzsJLRN85IFFg koWBR1QQ8PMKdm2WqUI9O/0TuJuRxdDxPd6cY64xGNK37ybJlu/Nw5fygGXH4lyRmmUY xoobE0nkBLqLgWarJDlBjnTLoqD2nnXed1JRSkqdK6/n/YafMxdTCeELDPx8Lv4ljcoi jMsGwc82eQiwVn9VaIFp75AY3p+BOl/8aOcUPsC9aYjyO2DsfGxDyIm55q9/LCudzUPS 7sd4Zv6g/jtTk5l3eARlilCffi3GihluY0NlcpLoJkGLX/hrJ+mE8LNhH5ZaxWmmNmUL hRzw== X-Gm-Message-State: AOJu0YxSvKN9UAc+o9Tv+kStSOxiHw9m4MmtEXFzYTkweR/jsLEiwGRK gQBif0ZW+A1HVUh1nCxsGpRLdoneDosufyHrgsYODVevxeU8N1SpKEITNtLoteo= X-Google-Smtp-Source: AGHT+IFCSjt586qMBuxNZypsApcZ+VC1FCZxUMqaBfFfPBMsHNMjn2msv5U3H1M4DbXITkHOuF5KTQ== X-Received: by 2002:a05:6000:402a:b0:33a:e525:b15 with SMTP id cp42-20020a056000402a00b0033ae5250b15mr4721457wrb.19.1706546781551; Mon, 29 Jan 2024 08:46:21 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id bh5-20020a05600005c500b0033aed46956csm3386579wrb.80.2024.01.29.08.46.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:21 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , "Edgar E. Iglesias" Subject: [PATCH v3 10/29] target/cris: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:52 +0100 Message-ID: <20240129164514.73104-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/cris/cpu.c | 10 +++------- target/cris/gdbstub.c | 9 +++------ target/cris/helper.c | 12 ++++-------- target/cris/translate.c | 6 ++---- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 4187e0ef3c..122071f142 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -58,10 +58,9 @@ static bool cris_cpu_has_work(CPUState *cs) static void cris_cpu_reset_hold(Object *obj) { - CPUState *s = CPU(obj); - CRISCPU *cpu = CRIS_CPU(s); + CPUState *cs = CPU(obj); CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(obj); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); uint32_t vr; if (ccc->parent_phases.hold) { @@ -142,10 +141,7 @@ static void cris_cpu_set_irq(void *opaque, int irq, int level) static void cris_disas_set_info(CPUState *cpu, disassemble_info *info) { - CRISCPU *cc = CRIS_CPU(cpu); - CPUCRISState *env = &cc->env; - - if (env->pregs[PR_VR] != 32) { + if (cpu_env(cpu)->pregs[PR_VR] != 32) { info->mach = bfd_mach_cris_v0_v10; info->print_insn = print_insn_crisv10; } else { diff --git a/target/cris/gdbstub.c b/target/cris/gdbstub.c index 25c0ca33a5..9e87069da8 100644 --- a/target/cris/gdbstub.c +++ b/target/cris/gdbstub.c @@ -23,8 +23,7 @@ int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); if (n < 15) { return gdb_get_reg32(mem_buf, env->regs[n]); @@ -55,8 +54,7 @@ int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); uint8_t srs; srs = env->pregs[PR_SRS]; @@ -90,8 +88,7 @@ int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int cris_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); uint32_t tmp; if (n > 49) { diff --git a/target/cris/helper.c b/target/cris/helper.c index c0bf987e3e..1c3f86876f 100644 --- a/target/cris/helper.c +++ b/target/cris/helper.c @@ -53,8 +53,7 @@ bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); struct cris_mmu_result res; int prot, miss; target_ulong phy; @@ -97,8 +96,7 @@ bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int size, void crisv10_cpu_do_interrupt(CPUState *cs) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); int ex_vec = -1; D_LOG("exception index=%d interrupt_req=%d\n", @@ -159,8 +157,7 @@ void crisv10_cpu_do_interrupt(CPUState *cs) void cris_cpu_do_interrupt(CPUState *cs) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); int ex_vec = -1; D_LOG("exception index=%d interrupt_req=%d\n", @@ -262,8 +259,7 @@ hwaddr cris_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) bool cris_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { CPUClass *cc = CPU_GET_CLASS(cs); - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); bool ret = false; if (interrupt_request & CPU_INTERRUPT_HARD diff --git a/target/cris/translate.c b/target/cris/translate.c index b3974ba0bb..5213db820b 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3006,7 +3006,6 @@ static void cris_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) static void cris_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); - CPUCRISState *env = cpu_env(cs); unsigned int insn_len; /* Pretty disas. */ @@ -3014,7 +3013,7 @@ static void cris_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) dc->clear_x = 1; - insn_len = dc->decoder(env, dc); + insn_len = dc->decoder(cpu_env(cs), dc); dc->ppc = dc->pc; dc->pc += insn_len; dc->base.pc_next += insn_len; @@ -3180,8 +3179,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); const char * const *regnames; const char * const *pregnames; int i; From patchwork Mon Jan 29 16:44:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535993 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 154C1155A5F for ; Mon, 29 Jan 2024 16:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546790; cv=none; b=c3ASeyc8R/1as97kNT40i3nq4b3M8TsXrSbIXDn0pL1EbirC+nRBGnOQBoS75w1xnpLngtvj4H936irSRkms/sweTDnwLHtJpgLSZNaoBE9mQXz9q/SOWFNY04MZyy7Xe+Mj421frDtjTyMuOZEi9vlCnuoxI8b8sezjXCaQ1U8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546790; c=relaxed/simple; bh=lb+gNLT4xcsAnzEzsOBc13grxVpyoH885cq29VL196k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VyjhGYbtODG+Gkrjl2Ucjrx6yEAsE2quC93lLBpQMqCt1f/8bXe7ZlUc9GidCqr9O7yKyqwGiJ/17YnGdDuOW6VLiXPg0olP5+UQiqBewqEw717DVHb00FhmvuARv4j2P/5WzJx5oU+Ju00B2aGODulFN3mrEYZ850kewcFXnKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=tVx4Fyg3; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tVx4Fyg3" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-40ef6bbb61fso10150485e9.1 for ; Mon, 29 Jan 2024 08:46:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546787; x=1707151587; darn=vger.kernel.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=wpEyww5ql+HDyU+E74XNxXzD2LWLWxnIJJxDrC1dnKo=; b=tVx4Fyg3tMqr4ihE/rzD2iGCZR+9pG8T18nw/e8EHOZPg/ZSeXDz2b0FPNaEX5JjB0 Et9RlZ/64KemdoFSHfMa9s6kxo/omFGKluHFj34Y84U2hhFD7Rl4uY7r1pvavyInFpWt lmvC21uSSCCEAbMQoFO0OeMu7aPct6Iny5FKM35e1g1fA88o+T6hC8JT6tuk16et+f3f PJIn5zoEsPphyvzSpXKILPaEzPRVrQnkNdf/Oybg2b4w9GyQuxqvi/qplqDPpMFm+ZCE GfJfLbl5njiiamXBAxgEdjPor2fVZjUgdOBvJZlLtKPfUUn6o7zoSEGmp6O88p7pve8r vtYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546787; x=1707151587; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wpEyww5ql+HDyU+E74XNxXzD2LWLWxnIJJxDrC1dnKo=; b=q/aFMmt+SyGsPWQ5BuaZg+fFJYXAuijJyFDhj7HdMMN2H94Kou2xOW9trC2h5nkcC7 FqKTNu206FBjqFvprw2hd2BxJws0cziil0D7S0eUvGewhKHNC9CmbDTdUYHeQTY7vMXm YK8ivrFQxjmT9lmfX7hJB9DECeKhp78mNX1bwjX/LdegFls/j3Re3ZVR1lQre5x+fN27 xQWDE6ajXMo+nnwsTbJhjhuKiA40TX/UhblgU0lm8r4biRQ4kKyY3cKRmE8bxpGEmYCX lDUO3r89+5YI58EV7ctHtrTob8RJ97Vl4I+ZGCo+xG6bhjbzDonx02MdJpHZBlNriGn7 HmOQ== X-Gm-Message-State: AOJu0Yz++bXlVwe8he5rP4e7DfkslQMDqQbJ7vU9MGPVW9s8hNsiFTV2 4lGioENDDpCfCqsuVt7kSCX4xQIcbJddK/0KeSZ/w4ygtDtsLYDIBbkYIeYhsAU= X-Google-Smtp-Source: AGHT+IE/pmLN7aJB50sjYT7HNVrs0xGJu0OS4F2RLGx8AfT4RgKOArlTbN0yv5fwQwzrh+8k2SbzhQ== X-Received: by 2002:adf:fa51:0:b0:33a:eae2:11a4 with SMTP id y17-20020adffa51000000b0033aeae211a4mr2806032wrr.26.1706546787414; Mon, 29 Jan 2024 08:46:27 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id p7-20020a5d4587000000b0033af670213dsm258204wrq.110.2024.01.29.08.46.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Brian Cain Subject: [PATCH v3 11/29] target/hexagon: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:53 +0100 Message-ID: <20240129164514.73104-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Brian Cain Reviewed-by: Richard Henderson --- target/hexagon/cpu.c | 25 ++++++------------------- target/hexagon/gdbstub.c | 6 ++---- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 085d6c0115..17a22aa7a5 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -236,10 +236,7 @@ static void hexagon_dump(CPUHexagonState *env, FILE *f, int flags) static void hexagon_dump_state(CPUState *cs, FILE *f, int flags) { - HexagonCPU *cpu = HEXAGON_CPU(cs); - CPUHexagonState *env = &cpu->env; - - hexagon_dump(env, f, flags); + hexagon_dump(cpu_env(cs), f, flags); } void hexagon_debug(CPUHexagonState *env) @@ -249,25 +246,19 @@ void hexagon_debug(CPUHexagonState *env) static void hexagon_cpu_set_pc(CPUState *cs, vaddr value) { - HexagonCPU *cpu = HEXAGON_CPU(cs); - CPUHexagonState *env = &cpu->env; - env->gpr[HEX_REG_PC] = value; + cpu_env(cs)->gpr[HEX_REG_PC] = value; } static vaddr hexagon_cpu_get_pc(CPUState *cs) { - HexagonCPU *cpu = HEXAGON_CPU(cs); - CPUHexagonState *env = &cpu->env; - return env->gpr[HEX_REG_PC]; + return cpu_env(cs)->gpr[HEX_REG_PC]; } static void hexagon_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { - HexagonCPU *cpu = HEXAGON_CPU(cs); - CPUHexagonState *env = &cpu->env; tcg_debug_assert(!(cs->tcg_cflags & CF_PCREL)); - env->gpr[HEX_REG_PC] = tb->pc; + cpu_env(cs)->gpr[HEX_REG_PC] = tb->pc; } static bool hexagon_cpu_has_work(CPUState *cs) @@ -279,18 +270,14 @@ static void hexagon_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - HexagonCPU *cpu = HEXAGON_CPU(cs); - CPUHexagonState *env = &cpu->env; - - env->gpr[HEX_REG_PC] = data[0]; + cpu_env(cs)->gpr[HEX_REG_PC] = data[0]; } static void hexagon_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); - HexagonCPU *cpu = HEXAGON_CPU(cs); HexagonCPUClass *mcc = HEXAGON_CPU_GET_CLASS(obj); - CPUHexagonState *env = &cpu->env; + CPUHexagonState *env = cpu_env(cs); if (mcc->parent_phases.hold) { mcc->parent_phases.hold(obj); diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c index 54d37e006e..f773f8ea4f 100644 --- a/target/hexagon/gdbstub.c +++ b/target/hexagon/gdbstub.c @@ -22,8 +22,7 @@ int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - HexagonCPU *cpu = HEXAGON_CPU(cs); - CPUHexagonState *env = &cpu->env; + CPUHexagonState *env = cpu_env(cs); if (n == HEX_REG_P3_0_ALIASED) { uint32_t p3_0 = 0; @@ -42,8 +41,7 @@ int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - HexagonCPU *cpu = HEXAGON_CPU(cs); - CPUHexagonState *env = &cpu->env; + CPUHexagonState *env = cpu_env(cs); if (n == HEX_REG_P3_0_ALIASED) { uint32_t p3_0 = ldtul_p(mem_buf); From patchwork Mon Jan 29 16:44:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535994 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F205664D2 for ; Mon, 29 Jan 2024 16:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546797; cv=none; b=aGDfE+BdWRBC+rcqt78a7vmVcoW+xBAE1Bqj0K73VM3LKjer0ufvbqgCBtqOPAEfl4UMfCJc04unEDvsRtuIV/71aOlreipUJn/waQBHtKGfh+AoiYfS39adhQtowCbBDoGHaDbHM8+rHoDXcCraOYenmLKJ3DgCG+5BmcgS9Po= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546797; c=relaxed/simple; bh=6BDsv7A070RoaUFpsIQ7WVgc6V/2s5MvqDGqPLkgY3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JM4po9oQmkGmno0+r+F+UitGjAgwGPDcAP08hkh6Sd7Z1deJPpOUBCKmMv7io0G9x7iWS3lNUJlfto3HtMcmBB3UZYtQjRvRm7h7MoUUrpm1R6z2g5sxHptUoo4ZjuPrGl4r989YGWczZoWPj/HeZikJ2uaWkMbd88SCcvxjcOQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=kwg3tjCY; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kwg3tjCY" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40ef6c471d5so10101285e9.0 for ; Mon, 29 Jan 2024 08:46:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546793; x=1707151593; darn=vger.kernel.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=8fRIZrJNpcnOiODb5mhhkKtvMpcISUpGajS0aMN6lEM=; b=kwg3tjCYpuP0o1VrDOdr+lDroD+pqocOu/HTQ+946gmflNoPC/pMKjq3ruIZrXFKUz TC9g7V49m1ZvB5ZnPl1NpAoFk/Z7E6YIGdlqw7KiNr+2ZU0eBc+UDSin4N66kLDc3bHD F83tFUurs5EY6J00hZ2hZAN2FoEPIRW1cXsolVnDJGoCqYTP9/mI9iMWijse42PpQxmS r7xejHN35FSpIilGcjLcgfZ/XetjdVAKhyg99D5IWE0ERvkPmBC17L1vg6jZ5X0QRGBh EjLxilYh9eo/zPTOBkbXDJvaWuylgu6ah/ApyrzfUfVsMSWsTN0o4VeqpX4RJiFECorz Bhag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546793; x=1707151593; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8fRIZrJNpcnOiODb5mhhkKtvMpcISUpGajS0aMN6lEM=; b=NCiZ9MLuE1cIbeYjT2/rBAgc7ER/1OTCZaOGB6/taDKPqyQFDGCZBOuvoPi4Azu26P PvAFmTgRvp/fjOhpTu0KxtUYdO0AsA1q0BX0nDR5CzUiljNtSpI/N9SKMOsltrmwXSJF lg0jLL3E+vPMeNlpcui4ByjSwa4rDL5GeLKF3IkuVS0yKFXFH1UAH169bMvtDvRN1VFl vAVfmzltE4opqNRds85Uq+/FoE4bPDkAAGVzHGMT/CR5c9B4q/+Hryioy4QP3T8tPWvl b31yfqmhn3HzlNYQEfqnnQq/DgwWj9sYLBP4VOaJa4/UYPn2YgUckZOYhdJ/ClT95TL6 3Y8w== X-Gm-Message-State: AOJu0YyN4kCXMxDrKHB5qYxfoBKZIQS2exFCwzCWekEKtE2Kg9hgq+V0 fCSMssDxOLaB2GB8/bScnbTLA1TGndxmiYP5VtZHgXgo+7UbFdimaK1JMt2Ykp0= X-Google-Smtp-Source: AGHT+IH/9F8cyyKVNSFyJK/XuxhMwJqDVtIMy6daRNXg1ZJWGMneBXNSLk4RtK2/569lG7qwYgQxgQ== X-Received: by 2002:a05:600c:1986:b0:40e:e97c:e71 with SMTP id t6-20020a05600c198600b0040ee97c0e71mr6257966wmq.1.1706546793662; Mon, 29 Jan 2024 08:46:33 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id w18-20020a05600c475200b0040e9f7308f4sm10656778wmo.10.2024.01.29.08.46.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:32 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH v3 12/29] target/hppa: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:54 +0100 Message-ID: <20240129164514.73104-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Helge Deller --- target/hppa/cpu.c | 8 ++------ target/hppa/int_helper.c | 8 ++------ target/hppa/mem_helper.c | 3 +-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 14e17fa9aa..3200de0998 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -106,11 +106,8 @@ void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - HPPACPU *cpu = HPPA_CPU(cs); - CPUHPPAState *env = &cpu->env; - cs->exception_index = EXCP_UNALIGN; - hppa_set_ior_and_isr(env, addr, MMU_IDX_MMU_DISABLED(mmu_idx)); + hppa_set_ior_and_isr(cpu_env(cs), addr, MMU_IDX_MMU_DISABLED(mmu_idx)); cpu_loop_exit_restore(cs, retaddr); } @@ -145,8 +142,7 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp) static void hppa_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); - HPPACPU *cpu = HPPA_CPU(obj); - CPUHPPAState *env = &cpu->env; + CPUHPPAState *env = cpu_env(CPU(obj)); cs->exception_index = -1; cpu_hppa_loaded_fr0(env); diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index efe638b36e..d072ad2af7 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -99,8 +99,7 @@ void HELPER(write_eiem)(CPUHPPAState *env, target_ulong val) void hppa_cpu_do_interrupt(CPUState *cs) { - HPPACPU *cpu = HPPA_CPU(cs); - CPUHPPAState *env = &cpu->env; + CPUHPPAState *env = cpu_env(cs); int i = cs->exception_index; uint64_t old_psw; @@ -268,9 +267,6 @@ void hppa_cpu_do_interrupt(CPUState *cs) bool hppa_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - HPPACPU *cpu = HPPA_CPU(cs); - CPUHPPAState *env = &cpu->env; - if (interrupt_request & CPU_INTERRUPT_NMI) { /* Raise TOC (NMI) interrupt */ cpu_reset_interrupt(cs, CPU_INTERRUPT_NMI); @@ -280,7 +276,7 @@ bool hppa_cpu_exec_interrupt(CPUState *cs, int interrupt_request) } /* If interrupts are requested and enabled, raise them. */ - if ((env->psw & PSW_I) && (interrupt_request & CPU_INTERRUPT_HARD)) { + if ((cpu_env(cs)->psw & PSW_I) && (interrupt_request & CPU_INTERRUPT_HARD)) { cs->exception_index = EXCP_EXT_INTERRUPT; hppa_cpu_do_interrupt(cs); return true; diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index bb85962d50..7e73b80788 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -357,8 +357,7 @@ bool hppa_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, MMUAccessType type, int mmu_idx, bool probe, uintptr_t retaddr) { - HPPACPU *cpu = HPPA_CPU(cs); - CPUHPPAState *env = &cpu->env; + CPUHPPAState *env = cpu_env(cs); HPPATLBEntry *ent; int prot, excp, a_prot; hwaddr phys; From patchwork Mon Jan 29 16:44:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535995 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B912156991 for ; Mon, 29 Jan 2024 16:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546803; cv=none; b=GldF/pRJPZV5qDyMC8moln2VnXkA8p5AP+7rKaDNLts3poHpPUdz1NiZPuOH+lTcqmnB1hClFcXM5ZayrMN0IFAk1gQLtXMpk7VdQn42+7JB8HRYgw5DcLwk65UUA46JiYW9sJVzL6NRbnPz6jPfHjAiXqXrkkBBlFsjyMnSTD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546803; c=relaxed/simple; bh=7kApz5rIx8d3tFIDDQAiSMGDJ4Kvsb8W1moP7DuDwm8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uwd4X2zia+Q3rfGU4WTUJIu9hb1rk18M19CJnqC3xlsSU1wU/FLYJp3CSXGYOYHUCK5JE6S4qqMLkDuua/G10VCLtta6slSYmQssDJypjt/pF8oLGA5G4y6vHEmcrnN4HdlUFre3NM+zDEA07q0TzA324rxePmY0E6dKK4Tcbxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=iUCLYh7I; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iUCLYh7I" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40e76109cdeso40073825e9.0 for ; Mon, 29 Jan 2024 08:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546799; x=1707151599; darn=vger.kernel.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=XgRQukTglCKRn9R4pg+Z4Q5fPFCih1Qi18kzfRXi8wM=; b=iUCLYh7I03dnNA/9GZ9t4aakHk7l9F1APWfWPh/9/Cu72nmxOciRhEX9LvQHA0OYqS IJ5b0g2NUpw29R5FLH+aZ4Y5XKwgEDQ4/PLv1lU423nLg0l/iY8/YkmRDmrLN6FBlbu+ 5rfLxjjbMOzp1xslD1h8Nkks1+WbJZBTZGvbQIyellftCgRCwYshyFSCNbkts6i6Cnyd se8kaXcaVzu0CItva0JgytIGyjWMaDNS9LOXG8GIRGNnUkUbvUXvjDluUYburwMmWC1L RgFlY5OhmFq3/9WpHYVejG+Ph3Z8Ls1GoWlZD9t+loAB9TVSj7Rvm3WFoz7IY5GFPATT 4TXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546799; x=1707151599; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XgRQukTglCKRn9R4pg+Z4Q5fPFCih1Qi18kzfRXi8wM=; b=JdxIcD8A4eq7AwViyA60WrS7z4Lt4AVxuq2IDTrZ1/QvaZhINggNCVPNmNFxKuyYOt R73cYUF41C9JhhueeoyMtNe5Z/Ic011uLGqbxnwuNN8PtfKxQNKDPGN0B1GgRiix5GIj wpTvEzE5EApnP+v80tJjTHDbcN4hQjeBK0AUw9gYWfeVMnnJwqSk9ZPfzk7QFwdiU+UH 5dcD0op9rPfdzW3ie1AvguDf5eVnim5rZuRGBMzP1hJkdsB7/B6aOGWt7wIwa3js7Pag RmkASfkc1efmn5//CvSeOk6QeR3ZxNiNF7lhhzrW/+72Pl1yJBvWHNxhw3eqgx3cqRBL rCow== X-Gm-Message-State: AOJu0YywgPfrNB2KxgI0mW7ioroXFPucik2LBYXqF1CypfJ/pTlQFTFb byZfpFQgysTKs4s20yDtdwgypUiyThaCJN8xXFlrUOULD/25234ynETEzBRoFFQ= X-Google-Smtp-Source: AGHT+IEXTtrczMFNyn45KIgONf2aMQI+ma8RE/aMVM4QCmov/Z7glj7xGwykdFZTGExZ/63tVScDDQ== X-Received: by 2002:a5d:4248:0:b0:337:c3ed:bd1e with SMTP id s8-20020a5d4248000000b00337c3edbd1emr4746982wrr.25.1706546799608; Mon, 29 Jan 2024 08:46:39 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id v7-20020a5d4a47000000b0033aef37ec94sm2525026wrs.113.2024.01.29.08.46.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:39 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Zhao Liu , Cameron Esfahani , Roman Bolshakov Subject: [PATCH v3 13/29] target/i386/hvf: Use CPUState typedef Date: Mon, 29 Jan 2024 17:44:55 +0100 Message-ID: <20240129164514.73104-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 QEMU coding style recommend using structure typedefs: https://www.qemu.org/docs/master/devel/style.html#typedefs Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Zhao Liu --- target/i386/hvf/x86.h | 26 +++++++++++++------------- target/i386/hvf/x86_descr.h | 14 +++++++------- target/i386/hvf/x86_emu.h | 4 ++-- target/i386/hvf/x86_mmu.h | 6 +++--- target/i386/hvf/x86.c | 26 +++++++++++++------------- target/i386/hvf/x86_descr.c | 8 ++++---- target/i386/hvf/x86_mmu.c | 14 +++++++------- 7 files changed, 49 insertions(+), 49 deletions(-) diff --git a/target/i386/hvf/x86.h b/target/i386/hvf/x86.h index 947b98da41..3570f29aa9 100644 --- a/target/i386/hvf/x86.h +++ b/target/i386/hvf/x86.h @@ -248,30 +248,30 @@ typedef struct x68_segment_selector { #define BH(cpu) RH(cpu, R_EBX) /* deal with GDT/LDT descriptors in memory */ -bool x86_read_segment_descriptor(struct CPUState *cpu, +bool x86_read_segment_descriptor(CPUState *cpu, struct x86_segment_descriptor *desc, x68_segment_selector sel); -bool x86_write_segment_descriptor(struct CPUState *cpu, +bool x86_write_segment_descriptor(CPUState *cpu, struct x86_segment_descriptor *desc, x68_segment_selector sel); -bool x86_read_call_gate(struct CPUState *cpu, struct x86_call_gate *idt_desc, +bool x86_read_call_gate(CPUState *cpu, struct x86_call_gate *idt_desc, int gate); /* helpers */ -bool x86_is_protected(struct CPUState *cpu); -bool x86_is_real(struct CPUState *cpu); -bool x86_is_v8086(struct CPUState *cpu); -bool x86_is_long_mode(struct CPUState *cpu); -bool x86_is_long64_mode(struct CPUState *cpu); -bool x86_is_paging_mode(struct CPUState *cpu); -bool x86_is_pae_enabled(struct CPUState *cpu); +bool x86_is_protected(CPUState *cpu); +bool x86_is_real(CPUState *cpu); +bool x86_is_v8086(CPUState *cpu); +bool x86_is_long_mode(CPUState *cpu); +bool x86_is_long64_mode(CPUState *cpu); +bool x86_is_paging_mode(CPUState *cpu); +bool x86_is_pae_enabled(CPUState *cpu); enum X86Seg; -target_ulong linear_addr(struct CPUState *cpu, target_ulong addr, enum X86Seg seg); -target_ulong linear_addr_size(struct CPUState *cpu, target_ulong addr, int size, +target_ulong linear_addr(CPUState *cpu, target_ulong addr, enum X86Seg seg); +target_ulong linear_addr_size(CPUState *cpu, target_ulong addr, int size, enum X86Seg seg); -target_ulong linear_rip(struct CPUState *cpu, target_ulong rip); +target_ulong linear_rip(CPUState *cpu, target_ulong rip); static inline uint64_t rdtscp(void) { diff --git a/target/i386/hvf/x86_descr.h b/target/i386/hvf/x86_descr.h index c356932fa4..9f06014b56 100644 --- a/target/i386/hvf/x86_descr.h +++ b/target/i386/hvf/x86_descr.h @@ -29,29 +29,29 @@ typedef struct vmx_segment { } vmx_segment; /* deal with vmstate descriptors */ -void vmx_read_segment_descriptor(struct CPUState *cpu, +void vmx_read_segment_descriptor(CPUState *cpu, struct vmx_segment *desc, enum X86Seg seg); void vmx_write_segment_descriptor(CPUState *cpu, struct vmx_segment *desc, enum X86Seg seg); -x68_segment_selector vmx_read_segment_selector(struct CPUState *cpu, +x68_segment_selector vmx_read_segment_selector(CPUState *cpu, enum X86Seg seg); -void vmx_write_segment_selector(struct CPUState *cpu, +void vmx_write_segment_selector(CPUState *cpu, x68_segment_selector selector, enum X86Seg seg); -uint64_t vmx_read_segment_base(struct CPUState *cpu, enum X86Seg seg); -void vmx_write_segment_base(struct CPUState *cpu, enum X86Seg seg, +uint64_t vmx_read_segment_base(CPUState *cpu, enum X86Seg seg); +void vmx_write_segment_base(CPUState *cpu, enum X86Seg seg, uint64_t base); -void x86_segment_descriptor_to_vmx(struct CPUState *cpu, +void x86_segment_descriptor_to_vmx(CPUState *cpu, x68_segment_selector selector, struct x86_segment_descriptor *desc, struct vmx_segment *vmx_desc); uint32_t vmx_read_segment_limit(CPUState *cpu, enum X86Seg seg); uint32_t vmx_read_segment_ar(CPUState *cpu, enum X86Seg seg); -void vmx_segment_to_x86_descriptor(struct CPUState *cpu, +void vmx_segment_to_x86_descriptor(CPUState *cpu, struct vmx_segment *vmx_desc, struct x86_segment_descriptor *desc); diff --git a/target/i386/hvf/x86_emu.h b/target/i386/hvf/x86_emu.h index 4b846ba80e..8bd97608c4 100644 --- a/target/i386/hvf/x86_emu.h +++ b/target/i386/hvf/x86_emu.h @@ -26,8 +26,8 @@ void init_emu(void); bool exec_instruction(CPUX86State *env, struct x86_decode *ins); -void load_regs(struct CPUState *cpu); -void store_regs(struct CPUState *cpu); +void load_regs(CPUState *cpu); +void store_regs(CPUState *cpu); void simulate_rdmsr(CPUX86State *env); void simulate_wrmsr(CPUX86State *env); diff --git a/target/i386/hvf/x86_mmu.h b/target/i386/hvf/x86_mmu.h index 9ae8a548de..9447ae072c 100644 --- a/target/i386/hvf/x86_mmu.h +++ b/target/i386/hvf/x86_mmu.h @@ -36,9 +36,9 @@ #define MMU_PAGE_US (1 << 2) #define MMU_PAGE_NX (1 << 3) -bool mmu_gva_to_gpa(struct CPUState *cpu, target_ulong gva, uint64_t *gpa); +bool mmu_gva_to_gpa(CPUState *cpu, target_ulong gva, uint64_t *gpa); -void vmx_write_mem(struct CPUState *cpu, target_ulong gva, void *data, int bytes); -void vmx_read_mem(struct CPUState *cpu, void *data, target_ulong gva, int bytes); +void vmx_write_mem(CPUState *cpu, target_ulong gva, void *data, int bytes); +void vmx_read_mem(CPUState *cpu, void *data, target_ulong gva, int bytes); #endif /* X86_MMU_H */ diff --git a/target/i386/hvf/x86.c b/target/i386/hvf/x86.c index 8ceea6398e..80e36136d0 100644 --- a/target/i386/hvf/x86.c +++ b/target/i386/hvf/x86.c @@ -46,7 +46,7 @@ return ar; }*/ -bool x86_read_segment_descriptor(struct CPUState *cpu, +bool x86_read_segment_descriptor(CPUState *cpu, struct x86_segment_descriptor *desc, x68_segment_selector sel) { @@ -76,7 +76,7 @@ bool x86_read_segment_descriptor(struct CPUState *cpu, return true; } -bool x86_write_segment_descriptor(struct CPUState *cpu, +bool x86_write_segment_descriptor(CPUState *cpu, struct x86_segment_descriptor *desc, x68_segment_selector sel) { @@ -99,7 +99,7 @@ bool x86_write_segment_descriptor(struct CPUState *cpu, return true; } -bool x86_read_call_gate(struct CPUState *cpu, struct x86_call_gate *idt_desc, +bool x86_read_call_gate(CPUState *cpu, struct x86_call_gate *idt_desc, int gate) { target_ulong base = rvmcs(cpu->accel->fd, VMCS_GUEST_IDTR_BASE); @@ -115,30 +115,30 @@ bool x86_read_call_gate(struct CPUState *cpu, struct x86_call_gate *idt_desc, return true; } -bool x86_is_protected(struct CPUState *cpu) +bool x86_is_protected(CPUState *cpu) { uint64_t cr0 = rvmcs(cpu->accel->fd, VMCS_GUEST_CR0); return cr0 & CR0_PE_MASK; } -bool x86_is_real(struct CPUState *cpu) +bool x86_is_real(CPUState *cpu) { return !x86_is_protected(cpu); } -bool x86_is_v8086(struct CPUState *cpu) +bool x86_is_v8086(CPUState *cpu) { X86CPU *x86_cpu = X86_CPU(cpu); CPUX86State *env = &x86_cpu->env; return x86_is_protected(cpu) && (env->eflags & VM_MASK); } -bool x86_is_long_mode(struct CPUState *cpu) +bool x86_is_long_mode(CPUState *cpu) { return rvmcs(cpu->accel->fd, VMCS_GUEST_IA32_EFER) & MSR_EFER_LMA; } -bool x86_is_long64_mode(struct CPUState *cpu) +bool x86_is_long64_mode(CPUState *cpu) { struct vmx_segment desc; vmx_read_segment_descriptor(cpu, &desc, R_CS); @@ -146,24 +146,24 @@ bool x86_is_long64_mode(struct CPUState *cpu) return x86_is_long_mode(cpu) && ((desc.ar >> 13) & 1); } -bool x86_is_paging_mode(struct CPUState *cpu) +bool x86_is_paging_mode(CPUState *cpu) { uint64_t cr0 = rvmcs(cpu->accel->fd, VMCS_GUEST_CR0); return cr0 & CR0_PG_MASK; } -bool x86_is_pae_enabled(struct CPUState *cpu) +bool x86_is_pae_enabled(CPUState *cpu) { uint64_t cr4 = rvmcs(cpu->accel->fd, VMCS_GUEST_CR4); return cr4 & CR4_PAE_MASK; } -target_ulong linear_addr(struct CPUState *cpu, target_ulong addr, X86Seg seg) +target_ulong linear_addr(CPUState *cpu, target_ulong addr, X86Seg seg) { return vmx_read_segment_base(cpu, seg) + addr; } -target_ulong linear_addr_size(struct CPUState *cpu, target_ulong addr, int size, +target_ulong linear_addr_size(CPUState *cpu, target_ulong addr, int size, X86Seg seg) { switch (size) { @@ -179,7 +179,7 @@ target_ulong linear_addr_size(struct CPUState *cpu, target_ulong addr, int size, return linear_addr(cpu, addr, seg); } -target_ulong linear_rip(struct CPUState *cpu, target_ulong rip) +target_ulong linear_rip(CPUState *cpu, target_ulong rip) { return linear_addr(cpu, rip, R_CS); } diff --git a/target/i386/hvf/x86_descr.c b/target/i386/hvf/x86_descr.c index c2d2e9ee84..5a9e8d307c 100644 --- a/target/i386/hvf/x86_descr.c +++ b/target/i386/hvf/x86_descr.c @@ -67,12 +67,12 @@ x68_segment_selector vmx_read_segment_selector(CPUState *cpu, X86Seg seg) return sel; } -void vmx_write_segment_selector(struct CPUState *cpu, x68_segment_selector selector, X86Seg seg) +void vmx_write_segment_selector(CPUState *cpu, x68_segment_selector selector, X86Seg seg) { wvmcs(cpu->accel->fd, vmx_segment_fields[seg].selector, selector.sel); } -void vmx_read_segment_descriptor(struct CPUState *cpu, struct vmx_segment *desc, X86Seg seg) +void vmx_read_segment_descriptor(CPUState *cpu, struct vmx_segment *desc, X86Seg seg) { desc->sel = rvmcs(cpu->accel->fd, vmx_segment_fields[seg].selector); desc->base = rvmcs(cpu->accel->fd, vmx_segment_fields[seg].base); @@ -90,7 +90,7 @@ void vmx_write_segment_descriptor(CPUState *cpu, struct vmx_segment *desc, X86Se wvmcs(cpu->accel->fd, sf->ar_bytes, desc->ar); } -void x86_segment_descriptor_to_vmx(struct CPUState *cpu, x68_segment_selector selector, struct x86_segment_descriptor *desc, struct vmx_segment *vmx_desc) +void x86_segment_descriptor_to_vmx(CPUState *cpu, x68_segment_selector selector, struct x86_segment_descriptor *desc, struct vmx_segment *vmx_desc) { vmx_desc->sel = selector.sel; vmx_desc->base = x86_segment_base(desc); @@ -107,7 +107,7 @@ void x86_segment_descriptor_to_vmx(struct CPUState *cpu, x68_segment_selector se desc->type; } -void vmx_segment_to_x86_descriptor(struct CPUState *cpu, struct vmx_segment *vmx_desc, struct x86_segment_descriptor *desc) +void vmx_segment_to_x86_descriptor(CPUState *cpu, struct vmx_segment *vmx_desc, struct x86_segment_descriptor *desc) { x86_set_segment_limit(desc, vmx_desc->limit); x86_set_segment_base(desc, vmx_desc->base); diff --git a/target/i386/hvf/x86_mmu.c b/target/i386/hvf/x86_mmu.c index 8cd08622a1..649074a7d2 100644 --- a/target/i386/hvf/x86_mmu.c +++ b/target/i386/hvf/x86_mmu.c @@ -49,7 +49,7 @@ struct gpt_translation { bool exec_access; }; -static int gpt_top_level(struct CPUState *cpu, bool pae) +static int gpt_top_level(CPUState *cpu, bool pae) { if (!pae) { return 2; @@ -73,7 +73,7 @@ static inline int pte_size(bool pae) } -static bool get_pt_entry(struct CPUState *cpu, struct gpt_translation *pt, +static bool get_pt_entry(CPUState *cpu, struct gpt_translation *pt, int level, bool pae) { int index; @@ -95,7 +95,7 @@ static bool get_pt_entry(struct CPUState *cpu, struct gpt_translation *pt, } /* test page table entry */ -static bool test_pt_entry(struct CPUState *cpu, struct gpt_translation *pt, +static bool test_pt_entry(CPUState *cpu, struct gpt_translation *pt, int level, bool *is_large, bool pae) { uint64_t pte = pt->pte[level]; @@ -166,7 +166,7 @@ static inline uint64_t large_page_gpa(struct gpt_translation *pt, bool pae) -static bool walk_gpt(struct CPUState *cpu, target_ulong addr, int err_code, +static bool walk_gpt(CPUState *cpu, target_ulong addr, int err_code, struct gpt_translation *pt, bool pae) { int top_level, level; @@ -205,7 +205,7 @@ static bool walk_gpt(struct CPUState *cpu, target_ulong addr, int err_code, } -bool mmu_gva_to_gpa(struct CPUState *cpu, target_ulong gva, uint64_t *gpa) +bool mmu_gva_to_gpa(CPUState *cpu, target_ulong gva, uint64_t *gpa) { bool res; struct gpt_translation pt; @@ -225,7 +225,7 @@ bool mmu_gva_to_gpa(struct CPUState *cpu, target_ulong gva, uint64_t *gpa) return false; } -void vmx_write_mem(struct CPUState *cpu, target_ulong gva, void *data, int bytes) +void vmx_write_mem(CPUState *cpu, target_ulong gva, void *data, int bytes) { uint64_t gpa; @@ -246,7 +246,7 @@ void vmx_write_mem(struct CPUState *cpu, target_ulong gva, void *data, int bytes } } -void vmx_read_mem(struct CPUState *cpu, void *data, target_ulong gva, int bytes) +void vmx_read_mem(CPUState *cpu, void *data, target_ulong gva, int bytes) { uint64_t gpa; From patchwork Mon Jan 29 16:44:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535996 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04095155A50 for ; Mon, 29 Jan 2024 16:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546810; cv=none; b=W9w/HsV6DKZqz2yc7CYdBeDm/KxzIhrIfnALUKxsqiJHdJ6wKKkcs6t6Mpw8TiKBEs97cmwMWolOzppnpZ+0FynvDh3UIS3bawu0l9TSyr0dzKZCxQr88P7IY4NYsDzkxWu5XZjA2gGS63RomIoz6zGNVZcJ6lBr6RD8n7zWt9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546810; c=relaxed/simple; bh=IJO/91eYXKmyGsXiuJeQSjw1+poTbyD8Nr/++EaADN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jxi07Jnk3CxYsHYrrKSqdhQHiZMK4UFjn8wbI8Ccg+yHalkxyxb7QV+5ryHyNerR5ige5bvClGQw6O8wfFH3pRRklnNo3z6cgsW894+R0897h/hP4zX18usMDlM9CeQSmWjDFV6JFwWL4NbadAl6fYtGV0oG8VS48S7SWjtns84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=kznk0NyR; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kznk0NyR" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-33ae42033e2so1631370f8f.1 for ; Mon, 29 Jan 2024 08:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546806; x=1707151606; darn=vger.kernel.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=lpXGLN2/IW24ZmgFDsSJNzcKsXfzg0OW+1h+hViDXfI=; b=kznk0NyROOL8kPo7cqemv2GbubeWOLR5qtahaNd4zzPG11K1pzDj4Exb9eeEFrTUsf +ybHpF9K4hkdAnwnptv1lSKXbnc6jKo5JQiwWgXAJZRVMdXDk/BYsMSY3Yz1gTxOgXGo QcfEKPIJfT2KQpNT13AbI+fSYE8hdBFVeZkQkEbm+zPEhTobyFGOfeVsF/u6ML6rWAoQ WuKqHkRB3rkdXkaN+5EExo6/1HL0AskrGF8Vw2NfvszHYMv0vhCaItQDY3MtmKcj81B7 qEJvl6i44VrrkdrtbhHh8MJIV1c3WSrWlh1ogH73fy1aRQD3nLSiuqmnm5puSICB0Is+ V2RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546806; x=1707151606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lpXGLN2/IW24ZmgFDsSJNzcKsXfzg0OW+1h+hViDXfI=; b=ENDyMa5sa5bTugtLGXIaoi3A5CBfJlXuFSSUVVqfZElmwzqZDm/Q92P8iQBOpVcf2a SOlkObsYbrBF4QTk2SOHz35tRE5BpikX0pB6bDgGPWCtMhBgzNnj7zdKOR80bqfVtyCm oKuL6RR+71QJY5zR+nocYH30lXsodLmQ1DnGNUQq0s+SQfxlLbluxyiEO7nss4HlkYk9 wLog7/sdFuE6hjDtrJzn2MidM0T7u2LW+4NznOeIM9l7X9xbDhUPjzHdiswhG9l1ra+B fV6SnWDln3L+/sF+TSqjGuPmvEh3U+ylcXJ8S9bC2j8YgKonVnrdK7b0A4IBdfhMZ71B lRgA== X-Gm-Message-State: AOJu0YxGqscE0E1iBgUPCmRLOcyOp1jp+FoU6yTTPVs758ZB7gt/mvcl bt3vpF3cSlnEcjhLVCFnU/VlW89g9iITWy0sxdvk/nY69r3Lhm6Nb8KRZrF2sfk= X-Google-Smtp-Source: AGHT+IHYP78wTun1efbdPT3m4ED9+tbNOVo7TfxCjm+JiqqtOKQrQXroDflnsjZz5SiBtFeBKbp9LA== X-Received: by 2002:adf:fdd0:0:b0:33a:df56:1f02 with SMTP id i16-20020adffdd0000000b0033adf561f02mr4447265wrs.13.1706546806131; Mon, 29 Jan 2024 08:46:46 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id t18-20020adfe112000000b0033ade19da41sm7770957wrz.76.2024.01.29.08.46.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:45 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Eduardo Habkost , Stefano Stabellini , Anthony Perard , Paul Durrant , Cameron Esfahani , Roman Bolshakov , Marcelo Tosatti , David Woodhouse , xen-devel@lists.xenproject.org Subject: [PATCH v3 14/29] target/i386: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:56 +0100 Message-ID: <20240129164514.73104-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Acked-by: David Woodhouse Reviewed-by: Zhao Liu Reviewed-by: Zhao Liu --- target/i386/hvf/vmx.h | 13 ++------- hw/i386/fw_cfg.c | 3 +- hw/i386/vmmouse.c | 6 ++-- hw/i386/xen/xen-hvm.c | 3 +- target/i386/arch_dump.c | 11 ++------ target/i386/arch_memory_mapping.c | 3 +- target/i386/cpu-dump.c | 3 +- target/i386/cpu.c | 37 ++++++++---------------- target/i386/helper.c | 42 ++++++++-------------------- target/i386/hvf/hvf.c | 8 ++---- target/i386/hvf/x86.c | 4 +-- target/i386/hvf/x86_emu.c | 6 ++-- target/i386/hvf/x86_task.c | 10 ++----- target/i386/hvf/x86hvf.c | 9 ++---- target/i386/kvm/kvm.c | 6 ++-- target/i386/kvm/xen-emu.c | 32 +++++++-------------- target/i386/tcg/sysemu/bpt_helper.c | 3 +- target/i386/tcg/sysemu/excp_helper.c | 3 +- target/i386/tcg/tcg-cpu.c | 14 +++------- target/i386/tcg/user/excp_helper.c | 6 ++-- target/i386/tcg/user/seg_helper.c | 3 +- 21 files changed, 67 insertions(+), 158 deletions(-) diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h index 0fffcfa46c..1ad042269b 100644 --- a/target/i386/hvf/vmx.h +++ b/target/i386/hvf/vmx.h @@ -175,8 +175,7 @@ static inline void macvm_set_cr4(hv_vcpuid_t vcpu, uint64_t cr4) static inline void macvm_set_rip(CPUState *cpu, uint64_t rip) { - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env = &x86_cpu->env; + CPUX86State *env = cpu_env(cpu); uint64_t val; /* BUG, should take considering overlap.. */ @@ -196,10 +195,7 @@ static inline void macvm_set_rip(CPUState *cpu, uint64_t rip) static inline void vmx_clear_nmi_blocking(CPUState *cpu) { - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env = &x86_cpu->env; - - env->hflags2 &= ~HF2_NMI_MASK; + cpu_env(cpu)->hflags2 &= ~HF2_NMI_MASK; uint32_t gi = (uint32_t) rvmcs(cpu->accel->fd, VMCS_GUEST_INTERRUPTIBILITY); gi &= ~VMCS_INTERRUPTIBILITY_NMI_BLOCKING; wvmcs(cpu->accel->fd, VMCS_GUEST_INTERRUPTIBILITY, gi); @@ -207,10 +203,7 @@ static inline void vmx_clear_nmi_blocking(CPUState *cpu) static inline void vmx_set_nmi_blocking(CPUState *cpu) { - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env = &x86_cpu->env; - - env->hflags2 |= HF2_NMI_MASK; + cpu_env(cpu)->hflags2 |= HF2_NMI_MASK; uint32_t gi = (uint32_t)rvmcs(cpu->accel->fd, VMCS_GUEST_INTERRUPTIBILITY); gi |= VMCS_INTERRUPTIBILITY_NMI_BLOCKING; wvmcs(cpu->accel->fd, VMCS_GUEST_INTERRUPTIBILITY, gi); diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 7362daa45a..5239cd40fa 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -155,8 +155,7 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms, void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg) { - X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(ms->possible_cpus->cpus[0].cpu); uint32_t unused, ebx, ecx, edx; uint64_t feature_control_bits = 0; uint64_t *val; diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index a8d014d09a..f292a14a15 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -74,8 +74,7 @@ struct VMMouseState { static void vmmouse_get_data(uint32_t *data) { - X86CPU *cpu = X86_CPU(current_cpu); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(current_cpu); data[0] = env->regs[R_EAX]; data[1] = env->regs[R_EBX]; data[2] = env->regs[R_ECX]; data[3] = env->regs[R_EDX]; @@ -84,8 +83,7 @@ static void vmmouse_get_data(uint32_t *data) static void vmmouse_set_data(const uint32_t *data) { - X86CPU *cpu = X86_CPU(current_cpu); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(current_cpu); env->regs[R_EAX] = data[0]; env->regs[R_EBX] = data[1]; env->regs[R_ECX] = data[2]; env->regs[R_EDX] = data[3]; diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index f42621e674..61e5060117 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -487,8 +487,7 @@ static void regs_to_cpu(vmware_regs_t *vmport_regs, ioreq_t *req) static void regs_from_cpu(vmware_regs_t *vmport_regs) { - X86CPU *cpu = X86_CPU(current_cpu); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(current_cpu); vmport_regs->ebx = env->regs[R_EBX]; vmport_regs->ecx = env->regs[R_ECX]; diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c index c290910a04..8939ff9fa9 100644 --- a/target/i386/arch_dump.c +++ b/target/i386/arch_dump.c @@ -203,7 +203,6 @@ int x86_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int x86_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s) { - X86CPU *cpu = X86_CPU(cs); x86_elf_prstatus prstatus; Elf32_Nhdr *note; char *buf; @@ -211,7 +210,7 @@ int x86_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, const char *name = "CORE"; int ret; - x86_fill_elf_prstatus(&prstatus, &cpu->env, cpuid); + x86_fill_elf_prstatus(&prstatus, cpu_env(cs), cpuid); descsz = sizeof(x86_elf_prstatus); note_size = ELF_NOTE_SIZE(sizeof(Elf32_Nhdr), name_size, descsz); note = g_malloc0(note_size); @@ -381,17 +380,13 @@ static inline int cpu_write_qemu_note(WriteCoreDumpFunction f, int x86_cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cs, DumpState *s) { - X86CPU *cpu = X86_CPU(cs); - - return cpu_write_qemu_note(f, &cpu->env, s, 1); + return cpu_write_qemu_note(f, cpu_env(cs), s, 1); } int x86_cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cs, DumpState *s) { - X86CPU *cpu = X86_CPU(cs); - - return cpu_write_qemu_note(f, &cpu->env, s, 0); + return cpu_write_qemu_note(f, cpu_env(cs), s, 0); } int cpu_get_dump_info(ArchDumpInfo *info, diff --git a/target/i386/arch_memory_mapping.c b/target/i386/arch_memory_mapping.c index d1ff659128..c0604d5956 100644 --- a/target/i386/arch_memory_mapping.c +++ b/target/i386/arch_memory_mapping.c @@ -269,8 +269,7 @@ static void walk_pml5e(MemoryMappingList *list, AddressSpace *as, bool x86_cpu_get_memory_mapping(CPUState *cs, MemoryMappingList *list, Error **errp) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); int32_t a20_mask; if (!cpu_paging_enabled(cs)) { diff --git a/target/i386/cpu-dump.c b/target/i386/cpu-dump.c index 40697064d9..5459d84abd 100644 --- a/target/i386/cpu-dump.c +++ b/target/i386/cpu-dump.c @@ -343,8 +343,7 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, int flags) void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); int eflags, i, nb; char cc_op_name[32]; static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" }; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 66345c204a..5d7a266d27 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5062,8 +5062,7 @@ static void x86_cpuid_version_get_family(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(CPU(obj)); int64_t value; value = (env->cpuid_version >> 8) & 0xf; @@ -5077,8 +5076,7 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(CPU(obj)); const int64_t min = 0; const int64_t max = 0xff + 0xf; int64_t value; @@ -5104,8 +5102,7 @@ static void x86_cpuid_version_get_model(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(CPU(obj)); int64_t value; value = (env->cpuid_version >> 4) & 0xf; @@ -5117,8 +5114,7 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(CPU(obj)); const int64_t min = 0; const int64_t max = 0xff; int64_t value; @@ -5140,11 +5136,9 @@ static void x86_cpuid_version_get_stepping(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; int64_t value; - value = env->cpuid_version & 0xf; + value = cpu_env(CPU(obj))->cpuid_version & 0xf; visit_type_int(v, name, &value, errp); } @@ -5152,8 +5146,7 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(CPU(obj)); const int64_t min = 0; const int64_t max = 0xf; int64_t value; @@ -5173,8 +5166,7 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v, static char *x86_cpuid_get_vendor(Object *obj, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(CPU(obj)); char *value; value = g_malloc(CPUID_VENDOR_SZ + 1); @@ -5186,8 +5178,7 @@ static char *x86_cpuid_get_vendor(Object *obj, Error **errp) static void x86_cpuid_set_vendor(Object *obj, const char *value, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(CPU(obj)); int i; if (strlen(value) != CPUID_VENDOR_SZ) { @@ -5208,8 +5199,7 @@ static void x86_cpuid_set_vendor(Object *obj, const char *value, static char *x86_cpuid_get_model_id(Object *obj, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(CPU(obj)); char *value; int i; @@ -5224,8 +5214,7 @@ static char *x86_cpuid_get_model_id(Object *obj, Error **errp) static void x86_cpuid_set_model_id(Object *obj, const char *model_id, Error **errp) { - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(CPU(obj)); int c, len, i; if (model_id == NULL) { @@ -7673,8 +7662,7 @@ static vaddr x86_cpu_get_pc(CPUState *cs) int x86_cpu_pending_interrupt(CPUState *cs, int interrupt_request) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); #if !defined(CONFIG_USER_ONLY) if (interrupt_request & CPU_INTERRUPT_POLL) { @@ -7722,8 +7710,7 @@ static bool x86_cpu_has_work(CPUState *cs) static void x86_disas_set_info(CPUState *cs, disassemble_info *info) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); info->mach = (env->hflags & HF_CS64_MASK ? bfd_mach_x86_64 : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386 diff --git a/target/i386/helper.c b/target/i386/helper.c index 2070dd0dda..4c11ef70f0 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -230,8 +230,7 @@ void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4) hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); target_ulong pde_addr, pte_addr; uint64_t pte; int32_t a20_mask; @@ -373,8 +372,7 @@ static void emit_guest_memory_failure(MemoryFailureAction action, bool ar, static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data) { MCEInjectionParams *params = data.host_ptr; - X86CPU *cpu = X86_CPU(cs); - CPUX86State *cenv = &cpu->env; + CPUX86State *cenv = cpu_env(cs); uint64_t *banks = cenv->mce_banks + 4 * params->bank; g_autofree char *msg = NULL; bool need_reset = false; @@ -625,9 +623,7 @@ void cpu_load_efer(CPUX86State *env, uint64_t val) uint8_t x86_ldub_phys(CPUState *cs, hwaddr addr) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - MemTxAttrs attrs = cpu_get_mem_attrs(env); + MemTxAttrs attrs = cpu_get_mem_attrs(cpu_env(cs)); AddressSpace *as = cpu_addressspace(cs, attrs); return address_space_ldub(as, addr, attrs, NULL); @@ -635,9 +631,7 @@ uint8_t x86_ldub_phys(CPUState *cs, hwaddr addr) uint32_t x86_lduw_phys(CPUState *cs, hwaddr addr) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - MemTxAttrs attrs = cpu_get_mem_attrs(env); + MemTxAttrs attrs = cpu_get_mem_attrs(cpu_env(cs)); AddressSpace *as = cpu_addressspace(cs, attrs); return address_space_lduw(as, addr, attrs, NULL); @@ -645,9 +639,7 @@ uint32_t x86_lduw_phys(CPUState *cs, hwaddr addr) uint32_t x86_ldl_phys(CPUState *cs, hwaddr addr) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - MemTxAttrs attrs = cpu_get_mem_attrs(env); + MemTxAttrs attrs = cpu_get_mem_attrs(cpu_env(cs)); AddressSpace *as = cpu_addressspace(cs, attrs); return address_space_ldl(as, addr, attrs, NULL); @@ -655,9 +647,7 @@ uint32_t x86_ldl_phys(CPUState *cs, hwaddr addr) uint64_t x86_ldq_phys(CPUState *cs, hwaddr addr) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - MemTxAttrs attrs = cpu_get_mem_attrs(env); + MemTxAttrs attrs = cpu_get_mem_attrs(cpu_env(cs)); AddressSpace *as = cpu_addressspace(cs, attrs); return address_space_ldq(as, addr, attrs, NULL); @@ -665,9 +655,7 @@ uint64_t x86_ldq_phys(CPUState *cs, hwaddr addr) void x86_stb_phys(CPUState *cs, hwaddr addr, uint8_t val) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - MemTxAttrs attrs = cpu_get_mem_attrs(env); + MemTxAttrs attrs = cpu_get_mem_attrs(cpu_env(cs)); AddressSpace *as = cpu_addressspace(cs, attrs); address_space_stb(as, addr, val, attrs, NULL); @@ -675,9 +663,7 @@ void x86_stb_phys(CPUState *cs, hwaddr addr, uint8_t val) void x86_stl_phys_notdirty(CPUState *cs, hwaddr addr, uint32_t val) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - MemTxAttrs attrs = cpu_get_mem_attrs(env); + MemTxAttrs attrs = cpu_get_mem_attrs(cpu_env(cs)); AddressSpace *as = cpu_addressspace(cs, attrs); address_space_stl_notdirty(as, addr, val, attrs, NULL); @@ -685,9 +671,7 @@ void x86_stl_phys_notdirty(CPUState *cs, hwaddr addr, uint32_t val) void x86_stw_phys(CPUState *cs, hwaddr addr, uint32_t val) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - MemTxAttrs attrs = cpu_get_mem_attrs(env); + MemTxAttrs attrs = cpu_get_mem_attrs(cpu_env(cs)); AddressSpace *as = cpu_addressspace(cs, attrs); address_space_stw(as, addr, val, attrs, NULL); @@ -695,9 +679,7 @@ void x86_stw_phys(CPUState *cs, hwaddr addr, uint32_t val) void x86_stl_phys(CPUState *cs, hwaddr addr, uint32_t val) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - MemTxAttrs attrs = cpu_get_mem_attrs(env); + MemTxAttrs attrs = cpu_get_mem_attrs(cpu_env(cs)); AddressSpace *as = cpu_addressspace(cs, attrs); address_space_stl(as, addr, val, attrs, NULL); @@ -705,9 +687,7 @@ void x86_stl_phys(CPUState *cs, hwaddr addr, uint32_t val) void x86_stq_phys(CPUState *cs, hwaddr addr, uint64_t val) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - MemTxAttrs attrs = cpu_get_mem_attrs(env); + MemTxAttrs attrs = cpu_get_mem_attrs(cpu_env(cs)); AddressSpace *as = cpu_addressspace(cs, attrs); address_space_stq(as, addr, val, attrs, NULL); diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 11ffdd4c69..772578e3f4 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -159,10 +159,7 @@ static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t ept_qual) void hvf_arch_vcpu_destroy(CPUState *cpu) { - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env = &x86_cpu->env; - - g_free(env->hvf_mmio_buf); + g_free(cpu_env(cpu)->hvf_mmio_buf); } static void init_tsc_freq(CPUX86State *env) @@ -313,8 +310,7 @@ int hvf_arch_init_vcpu(CPUState *cpu) static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idtvec_info) { - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env = &x86_cpu->env; + CPUX86State *env = cpu_env(cpu); env->exception_nr = -1; env->exception_pending = 0; diff --git a/target/i386/hvf/x86.c b/target/i386/hvf/x86.c index 80e36136d0..932635232b 100644 --- a/target/i386/hvf/x86.c +++ b/target/i386/hvf/x86.c @@ -128,9 +128,7 @@ bool x86_is_real(CPUState *cpu) bool x86_is_v8086(CPUState *cpu) { - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env = &x86_cpu->env; - return x86_is_protected(cpu) && (env->eflags & VM_MASK); + return x86_is_protected(cpu) && (cpu_env(cpu)->eflags & VM_MASK); } bool x86_is_long_mode(CPUState *cpu) diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c index 3a3f0a50d0..0d13b32f91 100644 --- a/target/i386/hvf/x86_emu.c +++ b/target/i386/hvf/x86_emu.c @@ -1419,8 +1419,7 @@ static void init_cmd_handler() void load_regs(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); int i = 0; RRX(env, R_EAX) = rreg(cs->accel->fd, HV_X86_RAX); @@ -1442,8 +1441,7 @@ void load_regs(CPUState *cs) void store_regs(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); int i = 0; wreg(cs->accel->fd, HV_X86_RAX, RAX(env)); diff --git a/target/i386/hvf/x86_task.c b/target/i386/hvf/x86_task.c index f09bfbdda5..c173e9d883 100644 --- a/target/i386/hvf/x86_task.c +++ b/target/i386/hvf/x86_task.c @@ -33,8 +33,7 @@ // TODO: taskswitch handling static void save_state_to_tss32(CPUState *cpu, struct x86_tss_segment32 *tss) { - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env = &x86_cpu->env; + CPUX86State *env = cpu_env(cpu); /* CR3 and ldt selector are not saved intentionally */ tss->eip = (uint32_t)env->eip; @@ -58,8 +57,7 @@ static void save_state_to_tss32(CPUState *cpu, struct x86_tss_segment32 *tss) static void load_state_from_tss32(CPUState *cpu, struct x86_tss_segment32 *tss) { - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env = &x86_cpu->env; + CPUX86State *env = cpu_env(cpu); wvmcs(cpu->accel->fd, VMCS_GUEST_CR3, tss->cr3); @@ -128,9 +126,7 @@ void vmx_handle_task_switch(CPUState *cpu, x68_segment_selector tss_sel, int rea uint32_t desc_limit; struct x86_call_gate task_gate_desc; struct vmx_segment vmx_seg; - - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env = &x86_cpu->env; + CPUX86State *env = cpu_env(cpu); x86_read_segment_descriptor(cpu, &next_tss_desc, tss_sel); x86_read_segment_descriptor(cpu, &curr_tss_desc, old_tss_sel); diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c index be2c46246e..10f79849b3 100644 --- a/target/i386/hvf/x86hvf.c +++ b/target/i386/hvf/x86hvf.c @@ -238,8 +238,7 @@ void hvf_get_msrs(CPUState *cs) int hvf_put_registers(CPUState *cs) { - X86CPU *x86cpu = X86_CPU(cs); - CPUX86State *env = &x86cpu->env; + CPUX86State *env = cpu_env(cs); wreg(cs->accel->fd, HV_X86_RAX, env->regs[R_EAX]); wreg(cs->accel->fd, HV_X86_RBX, env->regs[R_EBX]); @@ -282,8 +281,7 @@ int hvf_put_registers(CPUState *cs) int hvf_get_registers(CPUState *cs) { - X86CPU *x86cpu = X86_CPU(cs); - CPUX86State *env = &x86cpu->env; + CPUX86State *env = cpu_env(cs); env->regs[R_EAX] = rreg(cs->accel->fd, HV_X86_RAX); env->regs[R_EBX] = rreg(cs->accel->fd, HV_X86_RBX); @@ -342,8 +340,7 @@ void vmx_clear_int_window_exiting(CPUState *cs) bool hvf_inject_interrupts(CPUState *cs) { - X86CPU *x86cpu = X86_CPU(cs); - CPUX86State *env = &x86cpu->env; + CPUX86State *env = cpu_env(cs); uint8_t vector; uint64_t intr_type; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 76a66246eb..e4f1c62888 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -754,8 +754,7 @@ static inline bool freq_within_bounds(int freq, int target_freq) static int kvm_arch_set_tsc_khz(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); int r, cur_freq; bool set_ioctl = false; @@ -5369,8 +5368,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) bool kvm_arch_stop_on_emulation_error(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); kvm_cpu_synchronize_state(cs); return !(env->cr[0] & CR0_PE_MASK) || diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index fc2c2321ac..10350a22d1 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -313,10 +313,7 @@ static int kvm_xen_set_vcpu_callback_vector(CPUState *cs) static void do_set_vcpu_callback_vector(CPUState *cs, run_on_cpu_data data) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - - env->xen_vcpu_callback_vector = data.host_int; + cpu_env(cs)->xen_vcpu_callback_vector = data.host_int; if (kvm_xen_has_cap(EVTCHN_SEND)) { kvm_xen_set_vcpu_callback_vector(cs); @@ -325,8 +322,7 @@ static void do_set_vcpu_callback_vector(CPUState *cs, run_on_cpu_data data) static int set_vcpu_info(CPUState *cs, uint64_t gpa) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); MemoryRegionSection mrs = { .mr = NULL }; void *vcpu_info_hva = NULL; int ret; @@ -362,8 +358,7 @@ static int set_vcpu_info(CPUState *cs, uint64_t gpa) static void do_set_vcpu_info_default_gpa(CPUState *cs, run_on_cpu_data data) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); env->xen_vcpu_info_default_gpa = data.host_ulong; @@ -375,8 +370,7 @@ static void do_set_vcpu_info_default_gpa(CPUState *cs, run_on_cpu_data data) static void do_set_vcpu_info_gpa(CPUState *cs, run_on_cpu_data data) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); env->xen_vcpu_info_gpa = data.host_ulong; @@ -479,8 +473,7 @@ void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_id, int type) /* Must always be called with xen_timers_lock held */ static int kvm_xen_set_vcpu_timer(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); struct kvm_xen_vcpu_attr va = { .type = KVM_XEN_VCPU_ATTR_TYPE_TIMER, @@ -527,8 +520,7 @@ int kvm_xen_set_vcpu_virq(uint32_t vcpu_id, uint16_t virq, uint16_t port) static void do_set_vcpu_time_info_gpa(CPUState *cs, run_on_cpu_data data) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); env->xen_vcpu_time_info_gpa = data.host_ulong; @@ -538,8 +530,7 @@ static void do_set_vcpu_time_info_gpa(CPUState *cs, run_on_cpu_data data) static void do_set_vcpu_runstate_gpa(CPUState *cs, run_on_cpu_data data) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); env->xen_vcpu_runstate_gpa = data.host_ulong; @@ -549,8 +540,7 @@ static void do_set_vcpu_runstate_gpa(CPUState *cs, run_on_cpu_data data) static void do_vcpu_soft_reset(CPUState *cs, run_on_cpu_data data) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); env->xen_vcpu_info_gpa = INVALID_GPA; env->xen_vcpu_info_default_gpa = INVALID_GPA; @@ -1813,8 +1803,7 @@ uint16_t kvm_xen_get_evtchn_max_pirq(void) int kvm_put_xen_state(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); uint64_t gpa; int ret; @@ -1887,8 +1876,7 @@ int kvm_put_xen_state(CPUState *cs) int kvm_get_xen_state(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); uint64_t gpa; int ret; diff --git a/target/i386/tcg/sysemu/bpt_helper.c b/target/i386/tcg/sysemu/bpt_helper.c index 4d96a48a3c..90d6117497 100644 --- a/target/i386/tcg/sysemu/bpt_helper.c +++ b/target/i386/tcg/sysemu/bpt_helper.c @@ -208,8 +208,7 @@ bool check_hw_breakpoints(CPUX86State *env, bool force_dr6_update) void breakpoint_handler(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); if (cs->watchpoint_hit) { if (cs->watchpoint_hit->flags & BP_CPU) { diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/excp_helper.c index 5b86f439ad..1afa177551 100644 --- a/target/i386/tcg/sysemu/excp_helper.c +++ b/target/i386/tcg/sysemu/excp_helper.c @@ -639,6 +639,5 @@ G_NORETURN void x86_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - X86CPU *cpu = X86_CPU(cs); - handle_unaligned_access(&cpu->env, vaddr, access_type, retaddr); + handle_unaligned_access(cpu_env(cs), vaddr, access_type, retaddr); } diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index e1405b7be9..8f8fd6529d 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -29,8 +29,7 @@ static void x86_cpu_exec_enter(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); env->df = 1 - (2 * ((env->eflags >> 10) & 1)); @@ -40,8 +39,7 @@ static void x86_cpu_exec_enter(CPUState *cs) static void x86_cpu_exec_exit(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); env->eflags = cpu_compute_eflags(env); } @@ -65,8 +63,7 @@ static void x86_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); int cc_op = data[1]; uint64_t new_pc; @@ -96,11 +93,8 @@ static void x86_restore_state_to_opc(CPUState *cs, #ifndef CONFIG_USER_ONLY static bool x86_debug_check_breakpoint(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - /* RF disables all architectural breakpoints. */ - return !(env->eflags & RF_MASK); + return !(cpu_env(cs)->eflags & RF_MASK); } #endif diff --git a/target/i386/tcg/user/excp_helper.c b/target/i386/tcg/user/excp_helper.c index b3bdb7831a..9ea5566149 100644 --- a/target/i386/tcg/user/excp_helper.c +++ b/target/i386/tcg/user/excp_helper.c @@ -26,8 +26,7 @@ void x86_cpu_record_sigsegv(CPUState *cs, vaddr addr, MMUAccessType access_type, bool maperr, uintptr_t ra) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); /* * The error_code that hw reports as part of the exception frame @@ -52,6 +51,5 @@ void x86_cpu_record_sigsegv(CPUState *cs, vaddr addr, void x86_cpu_record_sigbus(CPUState *cs, vaddr addr, MMUAccessType access_type, uintptr_t ra) { - X86CPU *cpu = X86_CPU(cs); - handle_unaligned_access(&cpu->env, addr, access_type, ra); + handle_unaligned_access(cpu_env(cs), addr, access_type, ra); } diff --git a/target/i386/tcg/user/seg_helper.c b/target/i386/tcg/user/seg_helper.c index c45f2ac2ba..2f89dbb51e 100644 --- a/target/i386/tcg/user/seg_helper.c +++ b/target/i386/tcg/user/seg_helper.c @@ -78,8 +78,7 @@ static void do_interrupt_user(CPUX86State *env, int intno, int is_int, void x86_cpu_do_interrupt(CPUState *cs) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; + CPUX86State *env = cpu_env(cs); /* if user mode only, we simulate a fake exception which will be handled outside the cpu execution From patchwork Mon Jan 29 16:44:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535997 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2354F153BCE for ; Mon, 29 Jan 2024 16:46:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546816; cv=none; b=O0/AbkVr+lNcfTGTaOr8VEyfY5YAwh9OZ9YCpXGIVdDkftaZ4oihJIz9f+VXNkzv3CjMBYs1q8RsfWjnUJLTj73v6Dfkoukg2NfU06gDl3g9VWR/l6o3m9PNGBPjZG1PwBS5KX9odYa+hgrt+u7xZDcHC0lHQFPIVfzePSHCl6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546816; c=relaxed/simple; bh=E0lq5HDrgcO9BPm9UCqsmp6kEsEyVobAtoeZPpAfCUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NT3pfJUkFwwvj2A6Tq5w4hLP6pFxUACB7MZCwQt0/HJSfIR7f/1Z7g2cOFCS1egM8AL0Cz1W86H3ZDigcPdP2NousbMDZcIx2Ev/RN+R/Qew0YsZK9VuhgsfzKGctKiNK8uKNPvc3g6nLIXPW9qONv+D15pIljMMi6MQDT/Qf7o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qtU8vnch; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qtU8vnch" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-40ef6c471d5so10103635e9.0 for ; Mon, 29 Jan 2024 08:46:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546812; x=1707151612; darn=vger.kernel.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=5eD6rKTwh3BPZg727azmGQxnUXfJqHRnwiaNdsPFdAo=; b=qtU8vnchFoNC/Do1QKYzN4EuGnPpzNPfQDF0w4IwOoLnfiWiHk2TL3HLveYJ7Cteu0 MlaS3nLUJZ8TQI8phNzsuRBkD44rlmFqlhs3ufRhOWgVSsOPVY78+O/ymGMCdVrg9X3n n78y6D765l3cLwgD5ZhM5udXpAphgCYEilYsdND+yuwSBv1tkfmyku+W4LNTEOnSKcYM A7ymFXhzd82PiTUkh/pCg+I+1fVtauT9jFgXmdagli/ad0FvTAJ27CHPeObh+A71D6b5 AcK9bSmxUZ2N8P9LTsCDrpnT/ja/EK/WfA3kIcSvO2fgfbRPj5kXCr2RQqz4oOaEpQPS xy7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546812; x=1707151612; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5eD6rKTwh3BPZg727azmGQxnUXfJqHRnwiaNdsPFdAo=; b=AXsPnbyoQhmbxi+g1LKbE8LguvYA4jO0qBIvNZLFcnS4W/9A+n2JOh5DeEhQOvgEbY 1WRz+pg3cOuamEOE5/RCHiUP83e7q8k55dzwpHLJucL+7RUs9BEnEuWX4FOKbqY2WdTa XZHUE868dhr9ox0kP8IncjYeQ7XWOGBg8VtNU+NOPUVBP8wBESr+1uFlLblaCPDRSDVk 5zwhD7AfuH9xWJzsHloqRPKLRR+qp/1bp3BJ+ysvBcBJ81CGenakAhQqlur09Z7SkXaB 7hNKt8YbpMUwPAxe7YvM8c9qCxS/G/OizvoWCmXu9uJwjePFn8lGcRCzNFT8uV+XeJCX 5SMw== X-Gm-Message-State: AOJu0YwIpjGaYM9LRUPeohtnQSLEhKuqwIxMOD2LIhjreWhivEpTxc9s BoFo9gZ7H/W51nY/TbXGmyF2qytmaR4lUcX12FP7eIJ3/aiXdv931o4u8ysM+GY= X-Google-Smtp-Source: AGHT+IHBLDlJBXdJdBjv54vRycwUyR6fXctiBoUoT2EH8P3suLNCBO+YYLhkJyYaixVb8cTSMM0ujw== X-Received: by 2002:a5d:4988:0:b0:33a:e544:eccb with SMTP id r8-20020a5d4988000000b0033ae544eccbmr3934226wrq.1.1706546812465; Mon, 29 Jan 2024 08:46:52 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id c17-20020a5d5291000000b00337d980a68asm6158372wrv.106.2024.01.29.08.46.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Song Gao Subject: [PATCH v3 15/29] target/loongarch: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:57 +0100 Message-ID: <20240129164514.73104-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/loongarch/cpu.c | 39 ++++++++--------------------- target/loongarch/gdbstub.c | 6 ++--- target/loongarch/kvm/kvm.c | 41 +++++++++---------------------- target/loongarch/tcg/tlb_helper.c | 6 ++--- 4 files changed, 26 insertions(+), 66 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 3094bbc0d9..d1c907b2a7 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -91,18 +91,12 @@ void G_NORETURN do_raise_exception(CPULoongArchState *env, static void loongarch_cpu_set_pc(CPUState *cs, vaddr value) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; - - set_pc(env, value); + set_pc(cpu_env(cs), value); } static vaddr loongarch_cpu_get_pc(CPUState *cs) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; - - return env->pc; + return cpu_env(cs)->pc; } #ifndef CONFIG_USER_ONLY @@ -157,8 +151,7 @@ static inline bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env) #ifndef CONFIG_USER_ONLY static void loongarch_cpu_do_interrupt(CPUState *cs) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); bool update_badinstr = 1; int cause = -1; const char *name; @@ -308,8 +301,7 @@ static void loongarch_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, MemTxResult response, uintptr_t retaddr) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); if (access_type == MMU_INST_FETCH) { do_raise_exception(env, EXCCODE_ADEF, retaddr); @@ -321,8 +313,7 @@ static void loongarch_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, static bool loongarch_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { if (interrupt_request & CPU_INTERRUPT_HARD) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); if (cpu_loongarch_hw_interrupts_enabled(env) && cpu_loongarch_hw_interrupts_pending(env)) { @@ -339,21 +330,15 @@ static bool loongarch_cpu_exec_interrupt(CPUState *cs, int interrupt_request) static void loongarch_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; - tcg_debug_assert(!(cs->tcg_cflags & CF_PCREL)); - set_pc(env, tb->pc); + set_pc(cpu_env(cs), tb->pc); } static void loongarch_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; - - set_pc(env, data[0]); + set_pc(cpu_env(cs), data[0]); } #endif /* CONFIG_TCG */ @@ -362,12 +347,10 @@ static bool loongarch_cpu_has_work(CPUState *cs) #ifdef CONFIG_USER_ONLY return true; #else - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; bool has_work = false; if ((cs->interrupt_request & CPU_INTERRUPT_HARD) && - cpu_loongarch_hw_interrupts_pending(env)) { + cpu_loongarch_hw_interrupts_pending(cpu_env(cs))) { has_work = true; } @@ -499,9 +482,8 @@ static void loongarch_max_initfn(Object *obj) static void loongarch_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); - LoongArchCPU *cpu = LOONGARCH_CPU(cs); LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(obj); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); if (lacc->parent_phases.hold) { lacc->parent_phases.hold(obj); @@ -684,8 +666,7 @@ static ObjectClass *loongarch_cpu_class_by_name(const char *cpu_model) void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); int i; qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc); diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index 5fc2f19e96..91a16183b0 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -33,8 +33,7 @@ void write_fcc(CPULoongArchState *env, uint64_t val) int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); uint64_t val; if (0 <= n && n < 32) { @@ -60,8 +59,7 @@ int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); target_ulong tmp; int read_length; int length = 0; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index c19978a970..df5e199860 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -38,8 +38,7 @@ static int kvm_loongarch_get_regs_core(CPUState *cs) int ret = 0; int i; struct kvm_regs regs; - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); /* Get the current register set as KVM seems it */ ret = kvm_vcpu_ioctl(cs, KVM_GET_REGS, ®s); @@ -62,8 +61,7 @@ static int kvm_loongarch_put_regs_core(CPUState *cs) int ret = 0; int i; struct kvm_regs regs; - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); /* Set the registers based on QEMU's view of things */ for (i = 0; i < 32; i++) { @@ -82,8 +80,7 @@ static int kvm_loongarch_put_regs_core(CPUState *cs) static int kvm_loongarch_get_csr(CPUState *cs) { int ret = 0; - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); ret |= kvm_get_one_reg(cs, KVM_IOC_CSRID(LOONGARCH_CSR_CRMD), &env->CSR_CRMD); @@ -253,8 +250,7 @@ static int kvm_loongarch_get_csr(CPUState *cs) static int kvm_loongarch_put_csr(CPUState *cs, int level) { int ret = 0; - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); ret |= kvm_set_one_reg(cs, KVM_IOC_CSRID(LOONGARCH_CSR_CRMD), &env->CSR_CRMD); @@ -430,9 +426,7 @@ static int kvm_loongarch_get_regs_fp(CPUState *cs) { int ret, i; struct kvm_fpu fpu; - - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); ret = kvm_vcpu_ioctl(cs, KVM_GET_FPU, &fpu); if (ret < 0) { @@ -456,9 +450,7 @@ static int kvm_loongarch_put_regs_fp(CPUState *cs) { int ret, i; struct kvm_fpu fpu; - - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); fpu.fcsr = env->fcsr0; fpu.fcc = 0; @@ -487,8 +479,7 @@ static int kvm_loongarch_get_mpstate(CPUState *cs) { int ret = 0; struct kvm_mp_state mp_state; - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); if (cap_has_mp_state) { ret = kvm_vcpu_ioctl(cs, KVM_GET_MP_STATE, &mp_state); @@ -505,12 +496,8 @@ static int kvm_loongarch_get_mpstate(CPUState *cs) static int kvm_loongarch_put_mpstate(CPUState *cs) { int ret = 0; - - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; - struct kvm_mp_state mp_state = { - .mp_state = env->mp_state + .mp_state = cpu_env(cs)->mp_state }; if (cap_has_mp_state) { @@ -527,8 +514,7 @@ static int kvm_loongarch_get_cpucfg(CPUState *cs) { int i, ret = 0; uint64_t val; - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); for (i = 0; i < 21; i++) { ret = kvm_get_one_reg(cs, KVM_IOC_CPUCFG(i), &val); @@ -549,8 +535,7 @@ static int kvm_check_cpucfg2(CPUState *cs) .attr = 2, .addr = (uint64_t)&val, }; - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); ret = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr); @@ -575,8 +560,7 @@ static int kvm_check_cpucfg2(CPUState *cs) static int kvm_loongarch_put_cpucfg(CPUState *cs) { int i, ret = 0; - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); uint64_t val; for (i = 0; i < 21; i++) { @@ -758,8 +742,7 @@ bool kvm_arch_cpu_check_are_resettable(void) int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) { int ret = 0; - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); MemTxAttrs attrs = {}; attrs.requester_id = env_cpu(env)->cpu_index; diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c index 449043c68b..2df0bced4c 100644 --- a/target/loongarch/tcg/tlb_helper.c +++ b/target/loongarch/tcg/tlb_helper.c @@ -235,8 +235,7 @@ static int get_physical_address(CPULoongArchState *env, hwaddr *physical, hwaddr loongarch_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); hwaddr phys_addr; int prot; @@ -679,8 +678,7 @@ bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - LoongArchCPU *cpu = LOONGARCH_CPU(cs); - CPULoongArchState *env = &cpu->env; + CPULoongArchState *env = cpu_env(cs); hwaddr physical; int prot; int ret; From patchwork Mon Jan 29 16:44:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535998 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DDB1157057 for ; Mon, 29 Jan 2024 16:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546822; cv=none; b=mPkK30qhLhV4ABemajUsKGLJqsCtXWhhIn+8x+bW4bTrqsBbHUcur/+d1WKM1GhJuB6uh9SclxhnWGIRc9qyS5nbDVNChicZB1ZIz9hKGdTrjzHp5KRBT2rti9RXHGDeGgORUB8CAGuY3l3adnkUAzQPLQPYLS2bxN4sStJaXVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546822; c=relaxed/simple; bh=K2/zo/olqr+LwGgkwVwqtkKRRVPhp8U2Ppfsfj3qlcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kEhKljgUrT1mKdnjryMb1Qu45cgDyFO3EUxaE77E4tGZJ6BCWlmQYQOvO4heE/nMBx8nrZX3lIkEVxfUSI9j3eVs+WefsQx0ZUWV9wvSgra/ZQaD/BIQnMSSTcvtCkOKOW15urEVXk2Y0nOEUh2X5FeP5NrCeVxuxFPt1zkufI4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=IAP5HEP1; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IAP5HEP1" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-40e9101b5f9so36012805e9.3 for ; Mon, 29 Jan 2024 08:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546818; x=1707151618; darn=vger.kernel.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=ib12xEQ9cS3zFPlxG0XK1YK2Htrv2nPGlK1Cf6JOxPw=; b=IAP5HEP1aW+F2Ax9LTUpMVEhW/PFNA6kRCBSQnyS5A0SQhkM3xnZlDQgIJZlhvzy+N O3L8EYhR+Cb2a9556d3HeMxvpiGL7ZO6qadg8gbtz11Ayuxpu9wNyz+cZBJD4ZLrV4up h8uvR02fYoXZuScih4Uxhyiwf1fzZZvbmAKVzgmOfAelHnaLrW6IjPAa6hHqh9HqCu6q EFyTp4byzlrY3HaVkAXKFYVEqp5Uzr8ufJDFsc9XxVGWx7PRFB5QtKSLme/4l+LwtTJ3 Zy5EVtWd6scdQLhYJI6UFIhLFSNYlRaLfHIRuV8czDUW2GSYD/2TYVtHEAxYzbo2NBtA qHtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546818; x=1707151618; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ib12xEQ9cS3zFPlxG0XK1YK2Htrv2nPGlK1Cf6JOxPw=; b=OuuBClIzDBmWgxRlE3sBthAZj/TARy/c9NdRC7k6dDUOcuaQbEKP9W2pwUaF3WpL6l ebT0AeRmJFBFciAm9DhfIMRrcUQTqw2owjhBJ+RTsbL+LMql6OnJqPHdpUdeEmcZUprz c3aLkKnLiluRRgYRTJHwutDpp5Cr1dLSolf8jxqi9cJeD1dNB7q+StPh25DcIH5w/nnn U7UQE/V8hfY8dFxu0teygGyKfTwDqvL/9ziZ29b+VkyJ4QTqO0AjddRLk8CaB7AEWwHH XbdEeBAuOHJgP8h1YY9eY7uupQ9A+FlqRwQMjiDJWiBiHNIg4xKNjhL7JISH7/fex3py t65g== X-Gm-Message-State: AOJu0Yys9Bf2H+gQ5NwI/ZEfYKdzaP+r253i8tj5TGZ7h6KYdYbvIWeb og3d0IiU/Mwx5fR/ZDMwnZURqfUhPWO7PTNkdskG5T+V3ks7A4/6ZbDcGO6bd6g= X-Google-Smtp-Source: AGHT+IGVfe+WC+EmpdEquqGJQEaGbV4DU6mu7M5n0LNuNCmfmZ9Sf9Syv280bcWHDh3dOmHki1e+SQ== X-Received: by 2002:a05:600c:1396:b0:40e:d425:85a with SMTP id u22-20020a05600c139600b0040ed425085amr6002839wmf.17.1706546818295; Mon, 29 Jan 2024 08:46:58 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id bu25-20020a056000079900b0033ae4f2edb0sm6145102wrb.37.2024.01.29.08.46.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:46:57 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Thomas Huth , Laurent Vivier Subject: [PATCH v3 16/29] target/m68k: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:58 +0100 Message-ID: <20240129164514.73104-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Signed-off-by: Philippe Mathieu-Daudé --- target/m68k/cpu.c | 33 +++++++++++---------------------- target/m68k/gdbstub.c | 6 ++---- target/m68k/helper.c | 6 ++---- target/m68k/m68k-semi.c | 6 ++---- target/m68k/op_helper.c | 11 +++-------- target/m68k/translate.c | 3 +-- 6 files changed, 21 insertions(+), 44 deletions(-) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 4d14d04c33..4be0f0f33a 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -69,9 +69,8 @@ static void m68k_unset_feature(CPUM68KState *env, int feature) static void m68k_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); - M68kCPU *cpu = M68K_CPU(cs); M68kCPUClass *mcc = M68K_CPU_GET_CLASS(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); floatx80 nan = floatx80_default_nan(NULL); int i; @@ -117,8 +116,7 @@ static ObjectClass *m68k_cpu_class_by_name(const char *cpu_model) static void m5206_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68k_set_feature(env, M68K_FEATURE_CF_ISA_A); m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV); @@ -127,8 +125,7 @@ static void m5206_cpu_initfn(Object *obj) /* Base feature set, including isns. for m68k family */ static void m68000_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68k_set_feature(env, M68K_FEATURE_M68K); m68k_set_feature(env, M68K_FEATURE_USP); @@ -141,8 +138,7 @@ static void m68000_cpu_initfn(Object *obj) */ static void m68010_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68000_cpu_initfn(obj); m68k_set_feature(env, M68K_FEATURE_M68010); @@ -161,8 +157,7 @@ static void m68010_cpu_initfn(Object *obj) */ static void m68020_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68010_cpu_initfn(obj); m68k_unset_feature(env, M68K_FEATURE_M68010); @@ -192,8 +187,7 @@ static void m68020_cpu_initfn(Object *obj) */ static void m68030_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68020_cpu_initfn(obj); m68k_unset_feature(env, M68K_FEATURE_M68020); @@ -219,8 +213,7 @@ static void m68030_cpu_initfn(Object *obj) */ static void m68040_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68030_cpu_initfn(obj); m68k_unset_feature(env, M68K_FEATURE_M68030); @@ -240,8 +233,7 @@ static void m68040_cpu_initfn(Object *obj) */ static void m68060_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68040_cpu_initfn(obj); m68k_unset_feature(env, M68K_FEATURE_M68040); @@ -254,8 +246,7 @@ static void m68060_cpu_initfn(Object *obj) static void m5208_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68k_set_feature(env, M68K_FEATURE_CF_ISA_A); m68k_set_feature(env, M68K_FEATURE_CF_ISA_APLUSC); @@ -267,8 +258,7 @@ static void m5208_cpu_initfn(Object *obj) static void cfv4e_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68k_set_feature(env, M68K_FEATURE_CF_ISA_A); m68k_set_feature(env, M68K_FEATURE_CF_ISA_B); @@ -281,8 +271,7 @@ static void cfv4e_cpu_initfn(Object *obj) static void any_cpu_initfn(Object *obj) { - M68kCPU *cpu = M68K_CPU(obj); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(CPU(obj)); m68k_set_feature(env, M68K_FEATURE_CF_ISA_A); m68k_set_feature(env, M68K_FEATURE_CF_ISA_B); diff --git a/target/m68k/gdbstub.c b/target/m68k/gdbstub.c index 1e5f033a12..15547e2313 100644 --- a/target/m68k/gdbstub.c +++ b/target/m68k/gdbstub.c @@ -23,8 +23,7 @@ int m68k_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); if (n < 8) { /* D0-D7 */ @@ -50,8 +49,7 @@ int m68k_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int m68k_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); uint32_t tmp; tmp = ldl_p(mem_buf); diff --git a/target/m68k/helper.c b/target/m68k/helper.c index a812f328a1..3ec835293a 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -894,8 +894,7 @@ txfail: hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); hwaddr phys_addr; int prot; int access_type; @@ -943,8 +942,7 @@ bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType qemu_access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); hwaddr physical; int prot; int access_type; diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index b4ffb70f8b..546cff2246 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -77,8 +77,7 @@ static int host_to_gdb_errno(int err) static void m68k_semi_u32_cb(CPUState *cs, uint64_t ret, int err) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); target_ulong args = env->dregs[1]; if (put_user_u32(ret, args) || @@ -95,8 +94,7 @@ static void m68k_semi_u32_cb(CPUState *cs, uint64_t ret, int err) static void m68k_semi_u64_cb(CPUState *cs, uint64_t ret, int err) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); target_ulong args = env->dregs[1]; if (put_user_u32(ret >> 32, args) || diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 1ce850bbc5..851cca640d 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -441,10 +441,7 @@ static void do_interrupt_all(CPUM68KState *env, int is_hw) void m68k_cpu_do_interrupt(CPUState *cs) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; - - do_interrupt_all(env, 0); + do_interrupt_all(cpu_env(cs), 0); } static inline void do_interrupt_m68k_hardirq(CPUM68KState *env) @@ -457,8 +454,7 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); cpu_restore_state(cs, retaddr); @@ -511,8 +507,7 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, bool m68k_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); if (interrupt_request & CPU_INTERRUPT_HARD && ((env->sr & SR_I) >> SR_I_SHIFT) < env->pending_level) { diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 4a0b0b2703..9688476a7b 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -6108,8 +6108,7 @@ static double floatx80_to_double(CPUM68KState *env, uint16_t high, uint64_t low) void m68k_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - M68kCPU *cpu = M68K_CPU(cs); - CPUM68KState *env = &cpu->env; + CPUM68KState *env = cpu_env(cs); int i; uint16_t sr; for (i = 0; i < 8; i++) { From patchwork Mon Jan 29 16:44:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13535999 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D236915703F for ; Mon, 29 Jan 2024 16:47:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546827; cv=none; b=ZB+Hjk/n5NfNP/vZlVVKO/c34qdNoXDEuluA8miZbAKHLX/tylNVu7gKHb+yeBH+SI0B0lqnPdQCEGU+p9AflS6f1gWJzKq3wnByETUZYR4/+Ll8C0C8Ey8oosZQBuNVRdu+7RNLlripKOTBnJnLEJdySDkNa746KwHRiPH2gYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546827; c=relaxed/simple; bh=jL7lBd6T1l69LSUD4xZ/qwK14PuM0TsEi8D+MrmhFko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rF7FDvt3WAi6wXNQfXZZg61rVs8LxBjX1JfN9+jtkqeNIHgkjTd5dIoe5qpA8LNnvOtzdQLEP4t/Cf/DeeVv+lAfQGFHpghQqKb3HTyAU6Gn7Hk5M3zhghWb3wnm8eR3Z7lryDwfCP4vQeXg4DBp4YYD2v2D4wb86g4wpVNoSzo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=LkTxLDuU; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LkTxLDuU" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cf595d5b4aso20167851fa.0 for ; Mon, 29 Jan 2024 08:47:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546824; x=1707151624; darn=vger.kernel.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=ijxQ2ToounQ2YPXKuEdEzzYCdzKOr5SyszX4l6rPtX0=; b=LkTxLDuUbBVLiCRIUNLC5t8UiIEEZsv+yXR9ndhKEu8fWDOQsC0lcO0aGaSwQ0s3rl BqbAtccVFp0sNQJ1LkH4M8aM16vTgtrMjbmu2k+dEV8XIHjfqWYc5bPyhf2wv/R3B8nf K8ap5iM5Nz2GiSgQeLDRKHVv3/SE9Mkyqq9PYha+FCV352EEJ41MTj2KLFU4//nWLyzn EEP43ZkekibW0R7l8+P0RmcW860iyKTgjjB7cplzlo1hrhKY6jW45BCRTUYhREfFpaJs yTkuvOh9nkCTtHQYJMJQixEYrn5K4O9dQaheW/dGX+UI1j4neZE0aHTcZv3ycYOYoAgM IvxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546824; x=1707151624; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ijxQ2ToounQ2YPXKuEdEzzYCdzKOr5SyszX4l6rPtX0=; b=b0POXAR1f1YjM5QaWAhdVhRHxjamCnE01bBbetBeYNinA1i7MnzSK3MWIFv1u2REjY FplBSRCCHWQtZgmalwgPATGnA1/8sbsnb/DHN/qRJuGYI2l9fwKPPmzhPI74iHJSXLX8 iVAOOJe9AE9AFsCkqXUystsPQZbALdZ0Y7R5Yp+Clm9OTpAmqP0mfoGMm6hU6UVJXLGc IbutY7RHP3UjTrEalGp9l0IJ86pSfQfTM7idrNhgP2VaAU4aBA6Hvys7mV6g94aDI+P8 vkExXbDv/+MRxw6xzxxjCY5v18CzeQZxxHPZrKUDd9YYTvt16B1y7xIJXFIChRpZR0X2 y5Nw== X-Gm-Message-State: AOJu0Yy/NAapMaoYaJttfxiMvaKcCSeSMoWgpPAci+eRIUOlQUzso+9h ueNmXX8dN1c56XXfUKkbvUw03DKiOLzD4MrwZU6lNz2A2azTZP9dlLM76mLa5R4= X-Google-Smtp-Source: AGHT+IGXacHRaZvQM48taNZT74NjPJR9kzPP7y3LZ/4p0pddoEr1gt2fuS3L5Ce3XavmaRSix5iy+w== X-Received: by 2002:a05:651c:151:b0:2cf:2a82:7871 with SMTP id c17-20020a05651c015100b002cf2a827871mr4062986ljd.26.1706546823949; Mon, 29 Jan 2024 08:47:03 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id l6-20020a5d4806000000b003392ae3aee8sm8502273wrq.97.2024.01.29.08.47.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:03 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , "Edgar E. Iglesias" Subject: [PATCH v3 17/29] target/microblaze: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:44:59 +0100 Message-ID: <20240129164514.73104-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/microblaze/gdbstub.c | 3 +-- target/microblaze/helper.c | 3 +-- target/microblaze/translate.c | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index 29ac6e9c0f..98660ed950 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -113,9 +113,8 @@ int mb_cpu_gdb_read_stack_protect(CPUMBState *env, GByteArray *mem_buf, int n) int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); CPUClass *cc = CPU_GET_CLASS(cs); - CPUMBState *env = &cpu->env; + CPUMBState *env = cpu_env(cs); uint32_t tmp; if (n > cc->gdb_num_core_regs) { diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index 98bdb82de8..bf955dd425 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -253,8 +253,7 @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, bool mb_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); - CPUMBState *env = &cpu->env; + CPUMBState *env = cpu_env(cs); if ((interrupt_request & CPU_INTERRUPT_HARD) && (env->msr & MSR_IE) diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 49bfb4a0ea..354897c4a2 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1630,7 +1630,6 @@ static void mb_tr_insn_start(DisasContextBase *dcb, CPUState *cs) static void mb_tr_translate_insn(DisasContextBase *dcb, CPUState *cs) { DisasContext *dc = container_of(dcb, DisasContext, base); - CPUMBState *env = cpu_env(cs); uint32_t ir; /* TODO: This should raise an exception, not terminate qemu. */ @@ -1641,7 +1640,7 @@ static void mb_tr_translate_insn(DisasContextBase *dcb, CPUState *cs) dc->tb_flags_to_set = 0; - ir = cpu_ldl_code(env, dc->base.pc_next); + ir = cpu_ldl_code(cpu_env(cs), dc->base.pc_next); if (!decode(dc, ir)) { trap_illegal(dc, true); } @@ -1800,8 +1799,7 @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, void mb_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); - CPUMBState *env = &cpu->env; + CPUMBState *env = cpu_env(cs); uint32_t iflags; int i; From patchwork Mon Jan 29 16:45:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536000 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09689156989 for ; Mon, 29 Jan 2024 16:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546834; cv=none; b=kBl344BvJdbzqbVacIIEA4zDLYRPWATl9eZItENR4j3PXDCZMAl530xMNm99Mt2opqIh//KTrK6nhTix2GRZW6SSTN6+VsbgWOUofI7WGNLivSLETtfb2XhNTQ3g5lj/R8ZbMZtIl10KKQC8p4NvM8Hy5vJ8Jh0r4/SyWzZIxu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546834; c=relaxed/simple; bh=L03amIvNw1iPWvJsVfUiQyyFoidgYwInBD5pbA/d8NU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MF6aPd1w6o/FHtnW19KDZSP1w+8qtbe6CZDxwrjLxj607GibMKSEkFyxuWM/Ecir9e9827js3ndu7tqwlonLaNyqZBnK68Pms/0aCQ0ZvcpYoZNgg5+8IsDtXt1Du+G8t/mSOvPkaYJRZ3IJrDPYyBTZTsz94FV91kpZIU0V+Nc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ohwannSk; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ohwannSk" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40e7e2e04f0so36475035e9.1 for ; Mon, 29 Jan 2024 08:47:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546830; x=1707151630; darn=vger.kernel.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=a1GRxsPkPoYM/j9b9XVxD2Uv8+2XdiDkavqzy6v+eQw=; b=ohwannSkYR+jACfc8KaNMF1IIWIMFdN8YAwoS6xQ7tGPu/BsV2v8XRD4Y4N1mXOkzy cXh5+JMt3dwtRKlb2UPyQU9pmregFPTLg624B1xDaUe27Upbct+pWvnlUkFZR1xKEAfe hmcN5Bmgx3YOs7po8VePa2NXQs2vew+FJmR1iSug7cUBnkj533PbT8z1Xi4Ohvd5KG2w 8ARhc0qDFXjp9nI4TvBg4fCOBZPzAbqC3G9uCFq0zEQPpZqtQdUm1D03surAyuOZksVZ Z/J4cgbykOGO2k+ezLF9EVoxnZFT/FrAhJZeCMoQGJtuEynBlje5TPwkYTvO7JpD+QR0 ynfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546830; x=1707151630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a1GRxsPkPoYM/j9b9XVxD2Uv8+2XdiDkavqzy6v+eQw=; b=KM3jXY1w/f9sSTVF6d6Y4pk8CgkQpwTmfJE7vKIDJhz7ZoAwCUr/Iq8HS68HwmqG8H CwVUsj1bNVM/gDkQscPX49Sz34nAJqTtYRuC9GMO99NhETKuiaH6d3KFn4Ad7GIQpmK/ SMe4ZVNjJATqAFAvtFe6vHqgWP1b8nUtsBFjqvAZhPLDplzo2aZK4/HHV69LhjJMJAT2 RC6bxZETehStj5SY8djWWDwLtr/wgvyUVZ1KMmEAhajFADmpqULXEfbo+pRIR+lV0CW2 /mn2ZWPI49939NPYhswqXI7VrMWyeKc/HEEoV+62kV5gwja5lxiCcNeBJTpOU69M25wv 6S3Q== X-Gm-Message-State: AOJu0Yygy3OsvkC/ORkIlbBCBM/3oB3hignL88dqkc7mPtvcIPPPysnl KnqipUqdcn9+XmJEUGLU0mlApsnXfycyUyqNyrzzUcGm46VVbkTYdf28AGeTWw0= X-Google-Smtp-Source: AGHT+IEpEpjILUE8/G6pqPee5gIH5YxC8wNTBQ4S47nuLxugvg/Jof6ItSCTwlZoBEcJKZyXSOwA2g== X-Received: by 2002:adf:f5c7:0:b0:33a:f505:c0f3 with SMTP id k7-20020adff5c7000000b0033af505c0f3mr1122952wrp.2.1706546830355; Mon, 29 Jan 2024 08:47:10 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id k14-20020adff28e000000b003392172fd60sm8453319wro.51.2024.01.29.08.47.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Huacai Chen Subject: [PATCH v3 18/29] target/mips: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:00 +0100 Message-ID: <20240129164514.73104-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/mips/cpu.c | 15 ++++---------- target/mips/gdbstub.c | 6 ++---- target/mips/kvm.c | 27 +++++++++---------------- target/mips/sysemu/physaddr.c | 3 +-- target/mips/tcg/exception.c | 3 +-- target/mips/tcg/op_helper.c | 8 +++----- target/mips/tcg/sysemu/special_helper.c | 3 +-- target/mips/tcg/sysemu/tlb_helper.c | 6 ++---- target/mips/tcg/translate.c | 3 +-- 9 files changed, 24 insertions(+), 50 deletions(-) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 6ced52f985..1bea76e40a 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -80,8 +80,7 @@ static void fpu_dump_state(CPUMIPSState *env, FILE *f, int flags) static void mips_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); int i; qemu_fprintf(f, "pc=0x" TARGET_FMT_lx " HI=0x" TARGET_FMT_lx @@ -123,9 +122,7 @@ void cpu_set_exception_base(int vp_index, target_ulong address) static void mips_cpu_set_pc(CPUState *cs, vaddr value) { - MIPSCPU *cpu = MIPS_CPU(cs); - - mips_env_set_pc(&cpu->env, value); + mips_env_set_pc(cpu_env(cs), value); } static vaddr mips_cpu_get_pc(CPUState *cs) @@ -137,8 +134,7 @@ static vaddr mips_cpu_get_pc(CPUState *cs) static bool mips_cpu_has_work(CPUState *cs) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); bool has_work = false; /* @@ -428,10 +424,7 @@ static void mips_cpu_reset_hold(Object *obj) static void mips_cpu_disas_set_info(CPUState *s, disassemble_info *info) { - MIPSCPU *cpu = MIPS_CPU(s); - CPUMIPSState *env = &cpu->env; - - if (!(env->insn_flags & ISA_NANOMIPS32)) { + if (!(cpu_env(s)->insn_flags & ISA_NANOMIPS32)) { #if TARGET_BIG_ENDIAN info->print_insn = print_insn_big_mips; #else diff --git a/target/mips/gdbstub.c b/target/mips/gdbstub.c index 62d7b72407..169d47416a 100644 --- a/target/mips/gdbstub.c +++ b/target/mips/gdbstub.c @@ -25,8 +25,7 @@ int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); if (n < 32) { return gdb_get_regl(mem_buf, env->active_tc.gpr[n]); @@ -78,8 +77,7 @@ int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); target_ulong tmp; tmp = ldtul_p(mem_buf); diff --git a/target/mips/kvm.c b/target/mips/kvm.c index 15d0cf9adb..6c52e59f55 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -63,8 +63,7 @@ int kvm_arch_irqchip_create(KVMState *s) int kvm_arch_init_vcpu(CPUState *cs) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); int ret = 0; qemu_add_vm_change_state_handler(kvm_mips_update_state, cs); @@ -460,8 +459,7 @@ static inline int kvm_mips_change_one_reg(CPUState *cs, uint64_t reg_id, */ static int kvm_mips_save_count(CPUState *cs) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); uint64_t count_ctl; int err, ret = 0; @@ -502,8 +500,7 @@ static int kvm_mips_save_count(CPUState *cs) */ static int kvm_mips_restore_count(CPUState *cs) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); uint64_t count_ctl; int err_dc, err, ret = 0; @@ -590,8 +587,7 @@ static void kvm_mips_update_state(void *opaque, bool running, RunState state) static int kvm_mips_put_fpu_registers(CPUState *cs, int level) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); int err, ret = 0; unsigned int i; @@ -670,8 +666,7 @@ static int kvm_mips_put_fpu_registers(CPUState *cs, int level) static int kvm_mips_get_fpu_registers(CPUState *cs) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); int err, ret = 0; unsigned int i; @@ -751,8 +746,7 @@ static int kvm_mips_get_fpu_registers(CPUState *cs) static int kvm_mips_put_cp0_registers(CPUState *cs, int level) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); int err, ret = 0; (void)level; @@ -974,8 +968,7 @@ static int kvm_mips_put_cp0_registers(CPUState *cs, int level) static int kvm_mips_get_cp0_registers(CPUState *cs) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); int err, ret = 0; err = kvm_mips_get_one_reg(cs, KVM_REG_MIPS_CP0_INDEX, &env->CP0_Index); @@ -1181,8 +1174,7 @@ static int kvm_mips_get_cp0_registers(CPUState *cs) int kvm_arch_put_registers(CPUState *cs, int level) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); struct kvm_regs regs; int ret; int i; @@ -1217,8 +1209,7 @@ int kvm_arch_put_registers(CPUState *cs, int level) int kvm_arch_get_registers(CPUState *cs) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); int ret = 0; struct kvm_regs regs; int i; diff --git a/target/mips/sysemu/physaddr.c b/target/mips/sysemu/physaddr.c index 05990aa5bb..56380dfe6c 100644 --- a/target/mips/sysemu/physaddr.c +++ b/target/mips/sysemu/physaddr.c @@ -230,8 +230,7 @@ int get_physical_address(CPUMIPSState *env, hwaddr *physical, hwaddr mips_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); hwaddr phys_addr; int prot; diff --git a/target/mips/tcg/exception.c b/target/mips/tcg/exception.c index da49a93912..13275d1ded 100644 --- a/target/mips/tcg/exception.c +++ b/target/mips/tcg/exception.c @@ -79,8 +79,7 @@ void helper_wait(CPUMIPSState *env) void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); tcg_debug_assert(!(cs->tcg_cflags & CF_PCREL)); env->active_tc.PC = tb->pc; diff --git a/target/mips/tcg/op_helper.c b/target/mips/tcg/op_helper.c index 98935b5e64..65403f1a87 100644 --- a/target/mips/tcg/op_helper.c +++ b/target/mips/tcg/op_helper.c @@ -279,8 +279,7 @@ void mips_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); int error_code = 0; int excp; @@ -306,9 +305,8 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr) { - MIPSCPU *cpu = MIPS_CPU(cs); - MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(cpu); - CPUMIPSState *env = &cpu->env; + MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(cs); + CPUMIPSState *env = cpu_env(cs); if (access_type == MMU_INST_FETCH) { do_raise_exception(env, EXCP_IBE, retaddr); diff --git a/target/mips/tcg/sysemu/special_helper.c b/target/mips/tcg/sysemu/special_helper.c index 93276f789d..7934f2ea41 100644 --- a/target/mips/tcg/sysemu/special_helper.c +++ b/target/mips/tcg/sysemu/special_helper.c @@ -90,8 +90,7 @@ static void debug_post_eret(CPUMIPSState *env) bool mips_io_recompile_replay_branch(CPUState *cs, const TranslationBlock *tb) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); if ((env->hflags & MIPS_HFLAG_BMASK) != 0 && !(cs->tcg_cflags & CF_PCREL) && env->active_tc.PC != tb->pc) { diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/tlb_helper.c index 4ede904800..6c48c4fa80 100644 --- a/target/mips/tcg/sysemu/tlb_helper.c +++ b/target/mips/tcg/sysemu/tlb_helper.c @@ -910,8 +910,7 @@ bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); hwaddr physical; int prot; int ret = TLBRET_BADADDR; @@ -1346,8 +1345,7 @@ void mips_cpu_do_interrupt(CPUState *cs) bool mips_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { if (interrupt_request & CPU_INTERRUPT_HARD) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); if (cpu_mips_hw_interrupts_enabled(env) && cpu_mips_hw_interrupts_pending(env)) { diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index 13e43fa3b6..e74b98de1c 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -15628,8 +15628,7 @@ void mips_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; + CPUMIPSState *env = cpu_env(cs); env->active_tc.PC = data[0]; env->hflags &= ~MIPS_HFLAG_BMASK; From patchwork Mon Jan 29 16:45:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536001 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A13CB156985 for ; Mon, 29 Jan 2024 16:47:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546839; cv=none; b=gdAnzwa+FDN4ZOpJYR1+u8FJEKmA5hXFI3I/W8By6BX8RGyN2OBYzHnpSoXggkxjN9ztbiKo+vylAgtYhrn6tAUFiiU7LnUGygKUXHP4TUbnLWX+Ve3+p9Y2AtdsxMdatdJEqhXqj1p1UQw5vlNs17iHUNVS7TErK3fHJ2yEWjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546839; c=relaxed/simple; bh=ylNnxRFMpN9DqWlW/A5LGAGoiXngFYhklsimJg6JN60=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e/Lnwp+wdBTWrsPP0EPGtA1MJKtVQIkivTNqyDAq3s2CTmfG6pmsSahiR+HDepRqTBrTcPupBGYHTqSYP5vHkIZyMec73bWOjdL5cXkK0u8CjcZaQqHHN1Cq+U8G+4H2bUVcEkrhYxT+PueVVFil6G1cP/s4y6FKqnTs204FcYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=xE/WKl0k; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xE/WKl0k" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40eacb4bfa0so35015075e9.1 for ; Mon, 29 Jan 2024 08:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546836; x=1707151636; darn=vger.kernel.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=a+WHgRt8aoFwU9PH4yyhsDxrOBo9TuwHJWddMcT5sv4=; b=xE/WKl0kK4lbFfzgvOGvfp57Y1vZw684ku6W1NQ+Fv1jPz/XkVZCCRzUGNvi17astA BaGKxQCANLSdBvLYe4r6y3OuC9OtqjlXIta9L1nnycTlQ3jTvsaR7h8JK88JzIBqr846 nl9+H4nSacJTBTU0ZEtaxkf2m3JdFX2b4iuQKAYgC0gNeFTPIGXrl0f6gT7Iuwx6VqJV lOfRphbeaWmbJemDi7I8GWaiDvMIIKGECtju4vQATYvkAMf/aEEoBF+MHQxxRSBunZsC 3BWLz3PM7Ka1KLBJYAO4jPOMhRj33eSVBLePkMMUtR6FYf0v8kAgFkBPKDDDHFMbl1jz LQpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546836; x=1707151636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a+WHgRt8aoFwU9PH4yyhsDxrOBo9TuwHJWddMcT5sv4=; b=tSJRumc87+XyPPNLOQFLGNjtihIo1itqX0H2APZzsOCc0vXX4gknHmMjQzqBlbftNq 0lZUbnT0rKmsZIgeQ9Z8Yb5c+el976onrq21FRuoADTdWioOhe+d3jSNYpXxnclMyACB hhiNetm0hEkTKjzf5ex8vabH6rIIKh3FNd8N20LX5E6Ckyga8Gv09w9IVmSSK/uV3Pwb r3bidJDJM0wbAAN7Jtuz/rrterJCC/RA7/11HNuGe+cKMWBhFG+1I8A0eMMIodjHqI2I Ms514xlUSFrRnn5v1rql1ytflpVCI8RAX63OT9txyBJ7FVRe6LoT55Zxq4lJtcSM447N Grdg== X-Gm-Message-State: AOJu0Yw+HgHYh8BKwvp82BuJ89fxqZQzVg5Smhgymw1O7Qhr8KB5GBQ1 znka+yTpnpKfk7Z+qLxNuLK5Jdci8kta9Q09BDad3G87jWkC3cn5NYvi0dD0iws= X-Google-Smtp-Source: AGHT+IGYhnGe776oZg8Nf+XW6qyKWUfG5CSd+AahADH4rgW9WuZbEKC9nCTJSkL02Ck+OeTkF8tuTg== X-Received: by 2002:a05:600c:4689:b0:40d:5575:a197 with SMTP id p9-20020a05600c468900b0040d5575a197mr5396356wmo.12.1706546836062; Mon, 29 Jan 2024 08:47:16 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id l29-20020a05600c1d1d00b0040ef8aa4822sm2704220wms.38.2024.01.29.08.47.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:15 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Chris Wulff , Marek Vasut Subject: [PATCH v3 19/29] target/nios2: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:01 +0100 Message-ID: <20240129164514.73104-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/nios2/cpu.c | 15 +++------------ target/nios2/helper.c | 3 +-- target/nios2/nios2-semi.c | 6 ++---- target/nios2/translate.c | 3 +-- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 09b122e24d..b5b3773fb8 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -28,28 +28,19 @@ static void nios2_cpu_set_pc(CPUState *cs, vaddr value) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; - - env->pc = value; + cpu_env(cs)->pc = value; } static vaddr nios2_cpu_get_pc(CPUState *cs) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; - - return env->pc; + return cpu_env(cs)->pc; } static void nios2_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; - - env->pc = data[0]; + cpu_env(cs)->pc = data[0]; } static bool nios2_cpu_has_work(CPUState *cs) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index bb3b09e5a7..ac57121afc 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -287,8 +287,7 @@ void nios2_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; + CPUNios2State *env = cpu_env(cs); env->ctrl[CR_BADADDR] = addr; cs->exception_index = EXCP_UNALIGN; diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index 0b84fcb6b6..420702e293 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -75,8 +75,7 @@ static int host_to_gdb_errno(int err) static void nios2_semi_u32_cb(CPUState *cs, uint64_t ret, int err) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; + CPUNios2State *env = cpu_env(cs); target_ulong args = env->regs[R_ARG1]; if (put_user_u32(ret, args) || @@ -93,8 +92,7 @@ static void nios2_semi_u32_cb(CPUState *cs, uint64_t ret, int err) static void nios2_semi_u64_cb(CPUState *cs, uint64_t ret, int err) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; + CPUNios2State *env = cpu_env(cs); target_ulong args = env->regs[R_ARG1]; if (put_user_u32(ret >> 32, args) || diff --git a/target/nios2/translate.c b/target/nios2/translate.c index e806623594..30beb303f9 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -970,7 +970,6 @@ static void nios2_tr_insn_start(DisasContextBase *dcbase, CPUState *cs) static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); - CPUNios2State *env = cpu_env(cs); const Nios2Instruction *instr; uint32_t code, pc; uint8_t op; @@ -980,7 +979,7 @@ static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) dc->base.pc_next = pc + 4; /* Decode an instruction */ - code = cpu_ldl_code(env, pc); + code = cpu_ldl_code(cpu_env(cs), pc); op = get_opcode(code); if (unlikely(op >= ARRAY_SIZE(i_type_instructions))) { From patchwork Mon Jan 29 16:45:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536002 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 950BF155A50 for ; Mon, 29 Jan 2024 16:47:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546845; cv=none; b=fpAKe/OzWh0U8ZjKeuhCq8v61uF2sYHgquOxBfY43RcdS49J+Sl8leg/Qzq8Jc6z2d+7SUKCQ2UCp31+/WvKfdHGehQn8cYObPwFSPHqeN7FEaMOWrsGJounh9AjAI5whHdBdJ7yuwu+up6bJEF9yY16O5QHnVZ4y0shVTABWfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546845; c=relaxed/simple; bh=140Rng9id53kS0MMxeEfVWWXO1rFeuZvm0HGWxZTiSs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sWIVUsjnq3i5EOQkCu684HWGxrJsMP+JuTdgmiz5Fg+qVbkRPtdON4wCDKu0Yj8tLa2RgRjrqgYIMooMgolrsd2oFqf8kYgzYrVGvX6M2d1U81/xUSvzVGHwUuZyW60Pvy+c7w88eRvsmjMW70mCoWVTbV+kdOedawuStmHZo3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=UzcqKaRY; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UzcqKaRY" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40e5afc18f5so34957285e9.3 for ; Mon, 29 Jan 2024 08:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546842; x=1707151642; darn=vger.kernel.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=81+lsllbL0HrT+oLcmb3UYRaeAjWMCareNwo8xEwpX8=; b=UzcqKaRY2Q/nfm9Jg1O7P1O51M23VsVQJWGjoo6VzSnXioGaJ2Kk4A8FljrEZ9I4X3 LGfv+hddWaP44QUHqf2VcPWVxkN5T2MQxER68odLUG4ktBDVmHWa3NvNrT/Pn4G+LfQs XJfn+d/0qAULM4oIApSlWhgNFUYr3qzPxEmj+iCnwPly2fybRZqXyaVVXy0MwyH/BVDx q5CIkm2ihazssR7bbUgSuLFbvJ5PkoSLiCetlL+FSFpmZ+jQRTjCm844fz7DREmPorvG 6HWvRvEwc2GPJCyt9VrteKeQ2foJ/WePGH1HMZYc0Sw0GUl8f+rWngAx+qjf0RNQd9VC i6IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546842; x=1707151642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=81+lsllbL0HrT+oLcmb3UYRaeAjWMCareNwo8xEwpX8=; b=CWuqIADWymSjK/Xkg4jtNuHzzetJgEqLLde/FCXEGGnQOjGj/y3+8/sOyWiztaUBS8 tExsherqEMBqkvSdxStGgSai+ABUCCKEncFB6DBPCeIcjkzSElRkdZcnJHM8C6JQrgMb b5Hb4MpC7QGKFiLROD39F2hFw96VERAOf5Zmd6lqd4IZexPN6tHjlPMqxjJklANhJSrW IqOxWNhxqSgZPuSn3mY8Lxw5lpbbvZO5V/LzTeYoSHI+AlgpWFFX+qyiU7MPjsXPTA9T 8A7I5lFQMHXuP0zqoa0qgo5SjAv1iKLOymgPs2e4WXU6b0xiYAL45CtI1zFQbPhp1kZ7 Cn0Q== X-Gm-Message-State: AOJu0YwGmQvvgHtJPcgWDMWCnTfhg6YqnRHWFC2Mxbn8LBVRkY1gc9au poMgZ9zwwYaUw2FiqxisDLl8UirVzpyogJHj7zfSWEa1pMIFCwN+iaw1SZ2ULEI= X-Google-Smtp-Source: AGHT+IF84eaJDqu3xt4h++MvVzAifUXMdWy4p6XWOiZiCT5EhNKvbhRD8nzigVrNm+QsqfgoC8z5Ng== X-Received: by 2002:adf:fc46:0:b0:33a:eadb:f4cd with SMTP id e6-20020adffc46000000b0033aeadbf4cdmr2748018wrs.58.1706546841883; Mon, 29 Jan 2024 08:47:21 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id p7-20020a5d4587000000b0033af670213dsm259833wrq.110.2024.01.29.08.47.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:21 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Stafford Horne Subject: [PATCH v3 20/29] target/openrisc: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:02 +0100 Message-ID: <20240129164514.73104-21-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/openrisc/gdbstub.c | 6 ++---- target/openrisc/interrupt.c | 6 ++---- target/openrisc/translate.c | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/target/openrisc/gdbstub.c b/target/openrisc/gdbstub.c index d1074a0581..c2a77d5d4d 100644 --- a/target/openrisc/gdbstub.c +++ b/target/openrisc/gdbstub.c @@ -23,8 +23,7 @@ int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - OpenRISCCPU *cpu = OPENRISC_CPU(cs); - CPUOpenRISCState *env = &cpu->env; + CPUOpenRISCState *env = cpu_env(cs); if (n < 32) { return gdb_get_reg32(mem_buf, cpu_get_gpr(env, n)); @@ -48,9 +47,8 @@ int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int openrisc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - OpenRISCCPU *cpu = OPENRISC_CPU(cs); CPUClass *cc = CPU_GET_CLASS(cs); - CPUOpenRISCState *env = &cpu->env; + CPUOpenRISCState *env = cpu_env(cs); uint32_t tmp; if (n > cc->gdb_num_core_regs) { diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index d4fdb8ce8e..b3b5b40577 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -29,8 +29,7 @@ void openrisc_cpu_do_interrupt(CPUState *cs) { - OpenRISCCPU *cpu = OPENRISC_CPU(cs); - CPUOpenRISCState *env = &cpu->env; + CPUOpenRISCState *env = cpu_env(cs); int exception = cs->exception_index; env->epcr = env->pc; @@ -105,8 +104,7 @@ void openrisc_cpu_do_interrupt(CPUState *cs) bool openrisc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - OpenRISCCPU *cpu = OPENRISC_CPU(cs); - CPUOpenRISCState *env = &cpu->env; + CPUOpenRISCState *env = cpu_env(cs); int idx = -1; if ((interrupt_request & CPU_INTERRUPT_HARD) && (env->sr & SR_IEE)) { diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index ecff4412b7..12899c911d 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1564,8 +1564,7 @@ static void openrisc_tr_insn_start(DisasContextBase *dcbase, CPUState *cs) static void openrisc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); - OpenRISCCPU *cpu = OPENRISC_CPU(cs); - uint32_t insn = translator_ldl(&cpu->env, &dc->base, dc->base.pc_next); + uint32_t insn = translator_ldl(cpu_env(cs), &dc->base, dc->base.pc_next); if (!decode(dc, insn)) { gen_illegal_exception(dc); @@ -1668,8 +1667,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, void openrisc_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - OpenRISCCPU *cpu = OPENRISC_CPU(cs); - CPUOpenRISCState *env = &cpu->env; + CPUOpenRISCState *env = cpu_env(cs); int i; qemu_fprintf(f, "PC=%08x\n", env->pc); From patchwork Mon Jan 29 16:45:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536003 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 192BD156993 for ; Mon, 29 Jan 2024 16:47:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546852; cv=none; b=VfqTSETdZdDOzpiFeKleNCc2jy1Kymo38ej45JCy1HP5NH6Mdj3T7p8c3X9Y/hAAbg9K51+daH4KaF/hHlZB0x3CculOLAiHKXWzGQiJs3bAOfP/8+lMIKJGZ125PmkhNsaoEcj8FkgWDgr+lV3vTMOhvr50QlFP6T++EuiGxeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546852; c=relaxed/simple; bh=bAaEo7UXq+25gnYLyv+CDL6A9umnb37zDC3CbSlvXHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b/qC3GwaJib4rQPb9qXawoDBGRN5+ifYJ1QUZsscl1xVTvJ87mSM6xTACHDLf4g5sGiubpMF2Oo2oX2D1h9ucajB3RqhJTG9DiGeoW6piZJCpHAUzVVGSOyXIyeLtIYHua+1Wsvxdh0auopjUXYNwi98T9uNuxS5sAqTqlIcFmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=KLNZEk+T; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KLNZEk+T" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40efcd830f6so1469285e9.0 for ; Mon, 29 Jan 2024 08:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546848; x=1707151648; darn=vger.kernel.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=DTmQyRcnNqgQwJoS6XsHQE+cWrjtXUUhl4cs1cvfE94=; b=KLNZEk+TIQ38BJjgOTDnDosp7mPivCyC10nmJHL1L97c//W5/0T/fFFdDE761wU+bK ANR6il2AFN/YzYVED1PGZbfv7tZeS8YiJIJ+KAwnoOLLXLYF/wkAlpdI7cQ6yXBwrzfo M5ri0c5251amVzlfCiTMshFAlF068sjun44kbqc+glI6og/8E7Hz9Y/Uwd2s2GbbOxRn bBrCPTMbttLiqAK+lEBAvjA/FnHpUdssD/t5IBs2kLk2++r5gg0cQgXJHjq1nBzaYs5q pFTarbjgk9TerjUO7vGTsMeF5RrEySIOPmmGYw8uUx8Cmhrqmf+8HGr2X7CaOTqltrs7 Jf+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546848; x=1707151648; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DTmQyRcnNqgQwJoS6XsHQE+cWrjtXUUhl4cs1cvfE94=; b=DwWFsmXwjx/+TJKW6r867NFkY/ySZhqeyfrEzMjKL8n9m8cV5EyApkQhbIC00Bql7A jPbJ2Nmr5oqKw1AWbEtbumeDMyAuGQ/rbij1oZfjFhh7lpe81RMAGqNXZMNyJ5Rf6UuH 21+tMtvc9+/lNa65KGdmEs5gf6d+dco+vpRZ+BVRmQ/KPA5WSaFqEqkcCvS9PpAcUrhz 6J9xMDYrOW5vrXgE0J8THgF/glXuFLhlupiWvj/TLS0+ScxJo4Y96eTY7gJTTR1pdVjN YW0D0XTUHjkcwepH9IjHCztK9aOjto+ttG9DJODbd5x0NN46o0REw/hQCNOIT+OKC8C9 a3Yg== X-Gm-Message-State: AOJu0YyfUrragYCKGd8dyPiU3a4HJlPxRbMy9YLTL+C7OnV7etSksAUH EHoAcJhrfBCbNCsEZwHoU9yESalfgYi+dQUEBxPK15nuYVGwwdVodiSbQ5RCrFM= X-Google-Smtp-Source: AGHT+IHRjk0Ni+ZTdCCitsdAD/Rw7PNydGz3Lc9DD15Omv+6GlenJU/4b1yCorKx64kreoceRIK6Ww== X-Received: by 2002:a05:600c:19cf:b0:40e:85fe:af82 with SMTP id u15-20020a05600c19cf00b0040e85feaf82mr5997213wmq.24.1706546848265; Mon, 29 Jan 2024 08:47:28 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id bd25-20020a05600c1f1900b0040ee0abd8f1sm9962562wmb.21.2024.01.29.08.47.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= , Nicholas Piggin , =?utf-8?b?RnLDqWTDqXJpYyBCYXJyYXQ=?= , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora Subject: [PATCH v3 21/29] target/ppc: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:03 +0100 Message-ID: <20240129164514.73104-22-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- hw/ppc/mpc8544_guts.c | 3 +-- hw/ppc/pnv.c | 3 +-- hw/ppc/pnv_xscom.c | 5 +---- hw/ppc/ppce500_spin.c | 3 +-- hw/ppc/spapr.c | 3 +-- hw/ppc/spapr_caps.c | 7 ++----- target/ppc/cpu_init.c | 11 +++-------- target/ppc/excp_helper.c | 3 +-- target/ppc/gdbstub.c | 12 ++++-------- target/ppc/kvm.c | 12 ++++-------- target/ppc/ppc-qmp-cmds.c | 3 +-- target/ppc/user_only_helper.c | 3 +-- 12 files changed, 21 insertions(+), 47 deletions(-) diff --git a/hw/ppc/mpc8544_guts.c b/hw/ppc/mpc8544_guts.c index a26e83d048..e3540b0281 100644 --- a/hw/ppc/mpc8544_guts.c +++ b/hw/ppc/mpc8544_guts.c @@ -71,8 +71,7 @@ static uint64_t mpc8544_guts_read(void *opaque, hwaddr addr, unsigned size) { uint32_t value = 0; - PowerPCCPU *cpu = POWERPC_CPU(current_cpu); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(current_cpu); addr &= MPC8544_GUTS_MMIO_SIZE - 1; switch (addr) { diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 202a569e27..77ee278a98 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2294,8 +2294,7 @@ static void pnv_machine_set_hb(Object *obj, bool value, Error **errp) static void pnv_cpu_do_nmi_on_cpu(CPUState *cs, run_on_cpu_data arg) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); cpu_synchronize_state(cs); ppc_cpu_do_system_reset(cs); diff --git a/hw/ppc/pnv_xscom.c b/hw/ppc/pnv_xscom.c index 805b1d0c87..a17816d072 100644 --- a/hw/ppc/pnv_xscom.c +++ b/hw/ppc/pnv_xscom.c @@ -44,15 +44,12 @@ static void xscom_complete(CPUState *cs, uint64_t hmer_bits) * passed for the cpu, and no CPU completion is generated. */ if (cs) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; - /* * TODO: Need a CPU helper to set HMER, also handle generation * of HMIs */ cpu_synchronize_state(cs); - env->spr[SPR_HMER] |= hmer_bits; + cpu_env(cs)->spr[SPR_HMER] |= hmer_bits; } } diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c index bbce63e8a4..dfbe759481 100644 --- a/hw/ppc/ppce500_spin.c +++ b/hw/ppc/ppce500_spin.c @@ -90,8 +90,7 @@ static void mmubooke_create_initial_mapping(CPUPPCState *env, static void spin_kick(CPUState *cs, run_on_cpu_data data) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); SpinInfo *curspin = data.host_ptr; hwaddr map_size = 64 * MiB; hwaddr map_start; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0b77aa5514..55d0fcb583 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3487,8 +3487,7 @@ static void spapr_machine_finalizefn(Object *obj) void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg) { SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); cpu_synchronize_state(cs); /* If FWNMI is inactive, addr will be -1, which will deliver to 0x100 */ diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index e889244e52..cc91d59c57 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -194,8 +194,7 @@ static void cap_htm_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) static void cap_vsx_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) { ERRP_GUARD(); - PowerPCCPU *cpu = POWERPC_CPU(first_cpu); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(first_cpu); if (!val) { /* TODO: We don't support disabling vsx yet */ @@ -213,14 +212,12 @@ static void cap_vsx_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) static void cap_dfp_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) { ERRP_GUARD(); - PowerPCCPU *cpu = POWERPC_CPU(first_cpu); - CPUPPCState *env = &cpu->env; if (!val) { /* TODO: We don't support disabling dfp yet */ return; } - if (!(env->insns_flags2 & PPC2_DFP)) { + if (!(cpu_env(first_cpu)->insns_flags2 & PPC2_DFP)) { error_setg(errp, "DFP support not available"); error_append_hint(errp, "Try appending -machine cap-dfp=off\n"); } diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 61b8495a90..5d23b32c0e 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7195,12 +7195,9 @@ static void ppc_cpu_reset_hold(Object *obj) static bool ppc_cpu_is_big_endian(CPUState *cs) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; - cpu_synchronize_state(cs); - return !FIELD_EX64(env->msr, MSR, LE); + return !FIELD_EX64(cpu_env(cs)->msr, MSR, LE); } static bool ppc_get_irq_stats(InterruptStatsProvider *obj, @@ -7287,8 +7284,7 @@ static bool ppc_pvr_match_default(PowerPCCPUClass *pcc, uint32_t pvr, bool best) static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); if ((env->hflags >> MSR_LE) & 1) { info->endian = BFD_ENDIAN_LITTLE; @@ -7446,8 +7442,7 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, int flags) #define RGPL 4 #define RFPL 4 - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); int i; qemu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR " diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 2ec6429e36..fccfefa88e 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -2588,8 +2588,7 @@ void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector) bool ppc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); int interrupt; if ((interrupt_request & CPU_INTERRUPT_HARD) == 0) { diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index ec5731e5d6..fd986b1922 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -108,8 +108,7 @@ void ppc_maybe_bswap_register(CPUPPCState *env, uint8_t *mem_buf, int len) int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); uint8_t *mem_buf; int r = ppc_gdb_register_len(n); @@ -152,8 +151,7 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n) int ppc_cpu_gdb_read_register_apple(CPUState *cs, GByteArray *buf, int n) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); uint8_t *mem_buf; int r = ppc_gdb_register_len_apple(n); @@ -206,8 +204,7 @@ int ppc_cpu_gdb_read_register_apple(CPUState *cs, GByteArray *buf, int n) int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); int r = ppc_gdb_register_len(n); if (!r) { @@ -253,8 +250,7 @@ int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) } int ppc_cpu_gdb_write_register_apple(CPUState *cs, uint8_t *mem_buf, int n) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); int r = ppc_gdb_register_len_apple(n); if (!r) { diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index b95a0b4928..b0e35b31a6 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -546,8 +546,7 @@ static void kvm_sw_tlb_put(PowerPCCPU *cpu) static void kvm_get_one_spr(CPUState *cs, uint64_t id, int spr) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); /* Init 'val' to avoid "uninitialised value" Valgrind warnings */ union { uint32_t u32; @@ -581,8 +580,7 @@ static void kvm_get_one_spr(CPUState *cs, uint64_t id, int spr) static void kvm_put_one_spr(CPUState *cs, uint64_t id, int spr) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); union { uint32_t u32; uint64_t u64; @@ -615,8 +613,7 @@ static void kvm_put_one_spr(CPUState *cs, uint64_t id, int spr) static int kvm_put_fp(CPUState *cs) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); struct kvm_one_reg reg; int i; int ret; @@ -682,8 +679,7 @@ static int kvm_put_fp(CPUState *cs) static int kvm_get_fp(CPUState *cs) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); struct kvm_one_reg reg; int i; int ret; diff --git a/target/ppc/ppc-qmp-cmds.c b/target/ppc/ppc-qmp-cmds.c index c0c137d9d7..9ac74f5c04 100644 --- a/target/ppc/ppc-qmp-cmds.c +++ b/target/ppc/ppc-qmp-cmds.c @@ -133,8 +133,7 @@ static int ppc_cpu_get_reg_num(const char *numstr, int maxnum, int *pregnum) int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval) { int i, regnum; - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); /* General purpose registers */ if ((qemu_tolower(name[0]) == 'r') && diff --git a/target/ppc/user_only_helper.c b/target/ppc/user_only_helper.c index 7ff76f7a06..a4d07a0d0d 100644 --- a/target/ppc/user_only_helper.c +++ b/target/ppc/user_only_helper.c @@ -27,8 +27,7 @@ void ppc_cpu_record_sigsegv(CPUState *cs, vaddr address, MMUAccessType access_type, bool maperr, uintptr_t retaddr) { - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; + CPUPPCState *env = cpu_env(cs); int exception, error_code; /* From patchwork Mon Jan 29 16:45:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536004 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41D7115698A for ; Mon, 29 Jan 2024 16:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546858; cv=none; b=FSrqFqrgkm1GSkB81YSX8DInr9AbAvRPvZILlO7LlUSx/nJCzipSA3eDmSc/o+GjDuy3FS0+fVAnA3iFoa6wNAoyjMrFRX6vdv8CreDM6HDUjG3si734IaN0Y7sec4uQ4kgV4ARGiwYyz17HPGlWka2oQVujYfG9lsC35RFaooo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546858; c=relaxed/simple; bh=Iha+utO5KWPV74A+JBHZex2E1bgdnpQWgyhIxCyOi1U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EkTSzHSF5elyXQEQBjCXtC+et7bNjBZwPv+FE3DVNIW0bFVlmaJnwuR9xRrTMzvjez+YZFywmtUKTr+WMfv0SZj3gLLI0yG2wRJDDkvboR0m+yzG5TCV16HXESlA+zX/SbU+qLwbbWjpBGIAmhsrMANX1bIOYIqVrLNlTxFiej0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SUyIXUcZ; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SUyIXUcZ" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-51030ce36fbso2617533e87.3 for ; Mon, 29 Jan 2024 08:47:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546854; x=1707151654; darn=vger.kernel.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=JtM2UKcDWa3bUjKa1/TxolhJdfA7b3J+7xND4L75JJU=; b=SUyIXUcZ93LFYdjCV4CwBADIGZ85S+vxoMlHw4J54JfXftdoJARUxwZSbncR9PF1iJ nAHE/H7HqDzqvwKBgxlyp1J4doHGSN/8PiODe5igpGrLfzjZE1vjwNtIPNTgWhax5C+G aYgF0aASSdfq5/ZxKWvlEw81NSSvPsYcOzYE3or13D7SMNQDzJhg2mhyW4QbuZ4+IWmw 5DXTIkMhgGUQFjKmJ5nNrXo95yuijN3HkJO2BwJlqZUDJOv5plX04wklEtFPa7rM6jXe Fe351QtPnT6+S4d04xgFe9pUCBWMYs+Ijw0viFWVWBpUKP/3zwxNDmsPht6Mw8ZMcb7i 2J4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546854; x=1707151654; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JtM2UKcDWa3bUjKa1/TxolhJdfA7b3J+7xND4L75JJU=; b=GSyjDv/6oL0aaAQGVbSelQ1it92kme3XTgby8AZ8Nngl4xGSxbMbFGCRNz6VeBPkTi 7NjTxPrDvT+yU6xq1SNlLsuxROEkIoPBYbibp/GdT+yLjuzhVIY4Pkdae9GRyl20JOOT Fkx/6SzlD2/NHnZJ6R8Pk5mUFIH8FFUuvxoElFyyEDQqOErAHO1yFwbrzUACxE5jV6rv UEi6ss3wgW8Jk3odH4H0gf/FOA/VVblVBae17nlMpaP0FOYTsK9D4J2Pp4RWCca7zD18 xPBp5FCY7Mqax8HIbaejQj9Ur2aZhJ/5x4WhrBp3NJvH7gvHfhBbsurjNmzGGWMHoMEQ QvZQ== X-Gm-Message-State: AOJu0Yw4NXNOmZ62xhWVcjLcCtXnLcy/lvOZr4s3tQmZbU+H6BSBilVW wZLkhopiwXqSGMExCJO8zuKV/TunuXwI21TPenSaFImfmqK7wbDzzSEdNzYlDpw= X-Google-Smtp-Source: AGHT+IE4Nnk8wqzhVhVlw4BFmmswb5N1RNhtVzZSau56BJMoLs5xZ8Yk0RvTuatP0vg2jweuAnzoYQ== X-Received: by 2002:a05:6512:3e19:b0:510:8cd:231b with SMTP id i25-20020a0565123e1900b0051008cd231bmr4524213lfv.21.1706546854392; Mon, 29 Jan 2024 08:47:34 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id he9-20020a05600c540900b0040ed1df542bsm10583977wmb.20.2024.01.29.08.47.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei Subject: [PATCH v3 22/29] target/riscv: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:04 +0100 Message-ID: <20240129164514.73104-23-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/arch_dump.c | 6 ++---- target/riscv/cpu.c | 17 +++++------------ target/riscv/cpu_helper.c | 17 +++++------------ target/riscv/debug.c | 9 +++------ target/riscv/gdbstub.c | 6 ++---- target/riscv/kvm/kvm-cpu.c | 11 +++-------- target/riscv/tcg/tcg-cpu.c | 10 +++------- target/riscv/translate.c | 6 ++---- 8 files changed, 25 insertions(+), 57 deletions(-) diff --git a/target/riscv/arch_dump.c b/target/riscv/arch_dump.c index 434c8a3dbb..994709647f 100644 --- a/target/riscv/arch_dump.c +++ b/target/riscv/arch_dump.c @@ -68,8 +68,7 @@ int riscv_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s) { struct riscv64_note note; - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); int ret, i = 0; const char name[] = "CORE"; @@ -137,8 +136,7 @@ int riscv_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s) { struct riscv32_note note; - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); int ret, i; const char name[] = "CORE"; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1bd99bc5c6..8af4f7a088 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -419,8 +419,7 @@ static void riscv_any_cpu_init(Object *obj) static void riscv_max_cpu_init(Object *obj) { - RISCVCPU *cpu = RISCV_CPU(obj); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(CPU(obj)); RISCVMXL mlx = MXL_RV64; #ifdef TARGET_RISCV32 @@ -828,8 +827,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) static void riscv_cpu_set_pc(CPUState *cs, vaddr value) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); if (env->xl == MXL_RV32) { env->pc = (int32_t)value; @@ -840,8 +838,7 @@ static void riscv_cpu_set_pc(CPUState *cs, vaddr value) static vaddr riscv_cpu_get_pc(CPUState *cs) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); /* Match cpu_get_tb_cpu_state. */ if (env->xl == MXL_RV32) { @@ -853,8 +850,7 @@ static vaddr riscv_cpu_get_pc(CPUState *cs) static bool riscv_cpu_has_work(CPUState *cs) { #ifndef CONFIG_USER_ONLY - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); /* * Definition of the WFI instruction requires it to ignore the privilege * mode and delegation registers, but respect individual enables @@ -1642,10 +1638,7 @@ static void rva22s64_profile_cpu_init(Object *obj) static const gchar *riscv_gdb_arch_name(CPUState *cs) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; - - switch (riscv_cpu_mxl(env)) { + switch (riscv_cpu_mxl(cpu_env(cs))) { case MXL_RV32: return "riscv:rv32"; case MXL_RV64: diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 791435d628..01b32a3f83 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -493,9 +493,7 @@ static int riscv_cpu_local_irq_pending(CPURISCVState *env) bool riscv_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { if (interrupt_request & CPU_INTERRUPT_HARD) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; - int interruptno = riscv_cpu_local_irq_pending(env); + int interruptno = riscv_cpu_local_irq_pending(cpu_env(cs)); if (interruptno >= 0) { cs->exception_index = RISCV_EXCP_INT_FLAG | interruptno; riscv_cpu_do_interrupt(cs); @@ -1196,8 +1194,7 @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address, hwaddr riscv_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); hwaddr phys_addr; int prot; int mmu_idx = cpu_mmu_index(env, false); @@ -1223,8 +1220,7 @@ void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); if (access_type == MMU_DATA_STORE) { cs->exception_index = RISCV_EXCP_STORE_AMO_ACCESS_FAULT; @@ -1244,8 +1240,7 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); switch (access_type) { case MMU_INST_FETCH: cs->exception_index = RISCV_EXCP_INST_ADDR_MIS; @@ -1631,9 +1626,7 @@ static target_ulong riscv_transformed_insn(CPURISCVState *env, void riscv_cpu_do_interrupt(CPUState *cs) { #if !defined(CONFIG_USER_ONLY) - - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); bool write_gva = false; uint64_t s; diff --git a/target/riscv/debug.c b/target/riscv/debug.c index 4945d1a1f2..c8df9812be 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -757,8 +757,7 @@ target_ulong tinfo_csr_read(CPURISCVState *env) void riscv_cpu_debug_excp_handler(CPUState *cs) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); if (cs->watchpoint_hit) { if (cs->watchpoint_hit->flags & BP_CPU) { @@ -773,8 +772,7 @@ void riscv_cpu_debug_excp_handler(CPUState *cs) bool riscv_cpu_debug_check_breakpoint(CPUState *cs) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); CPUBreakpoint *bp; target_ulong ctrl; target_ulong pc; @@ -832,8 +830,7 @@ bool riscv_cpu_debug_check_breakpoint(CPUState *cs) bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); target_ulong ctrl; target_ulong addr; int trigger_type; diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 58b3ace0fe..999d815b34 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -49,8 +49,7 @@ static const struct TypeSize vec_lanes[] = { int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); target_ulong tmp; if (n < 32) { @@ -75,8 +74,7 @@ int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); int length = 0; target_ulong tmp; diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 680a729cd8..563b371ec9 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -171,9 +171,7 @@ static void kvm_cpu_get_misa_ext_cfg(Object *obj, Visitor *v, { KVMCPUConfig *misa_ext_cfg = opaque; target_ulong misa_bit = misa_ext_cfg->offset; - RISCVCPU *cpu = RISCV_CPU(obj); - CPURISCVState *env = &cpu->env; - bool value = env->misa_ext_mask & misa_bit; + bool value = cpu_env(CPU(obj))->misa_ext_mask & misa_bit; visit_type_bool(v, name, &value, errp); } @@ -184,15 +182,13 @@ static void kvm_cpu_set_misa_ext_cfg(Object *obj, Visitor *v, { KVMCPUConfig *misa_ext_cfg = opaque; target_ulong misa_bit = misa_ext_cfg->offset; - RISCVCPU *cpu = RISCV_CPU(obj); - CPURISCVState *env = &cpu->env; bool value, host_bit; if (!visit_type_bool(v, name, &value, errp)) { return; } - host_bit = env->misa_ext_mask & misa_bit; + host_bit = cpu_env(CPU(obj))->misa_ext_mask & misa_bit; if (value == host_bit) { return; @@ -1583,10 +1579,9 @@ static void kvm_cpu_instance_init(CPUState *cs) */ static bool kvm_cpu_realize(CPUState *cs, Error **errp) { - RISCVCPU *cpu = RISCV_CPU(cs); int ret; - if (riscv_has_ext(&cpu->env, RVV)) { + if (riscv_has_ext(cpu_env(cs), RVV)) { ret = prctl(PR_RISCV_V_SET_CONTROL, PR_RISCV_V_VSTATE_CTRL_ON); if (ret) { error_setg(errp, "Error in prctl PR_RISCV_V_SET_CONTROL, code: %s", diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 994ca1cdf9..e0f05d898c 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -92,8 +92,7 @@ static void riscv_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { if (!(tb_cflags(tb) & CF_PCREL)) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); RISCVMXL xl = FIELD_EX32(tb->flags, TB_FLAGS, XL); tcg_debug_assert(!(cs->tcg_cflags & CF_PCREL)); @@ -110,8 +109,7 @@ static void riscv_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; + CPURISCVState *env = cpu_env(cs); RISCVMXL xl = FIELD_EX32(tb->flags, TB_FLAGS, XL); target_ulong pc; @@ -1030,11 +1028,9 @@ static void cpu_get_misa_ext_cfg(Object *obj, Visitor *v, const char *name, { const RISCVCPUMisaExtConfig *misa_ext_cfg = opaque; target_ulong misa_bit = misa_ext_cfg->misa_bit; - RISCVCPU *cpu = RISCV_CPU(obj); - CPURISCVState *env = &cpu->env; bool value; - value = env->misa_ext & misa_bit; + value = cpu_env(CPU(obj))->misa_ext & misa_bit; visit_type_bool(v, name, &value, errp); } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 071fbad7ef..24db9f3882 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1074,9 +1074,8 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc) { DisasContext *ctx = container_of(dcbase, DisasContext, base); CPUState *cpu = ctx->cs; - CPURISCVState *env = cpu_env(cpu); - return cpu_ldl_code(env, pc); + return cpu_ldl_code(cpu_env(cpu), pc); } /* Include insn module translation function */ @@ -1265,8 +1264,7 @@ static void riscv_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu, FILE *logfile) { #ifndef CONFIG_USER_ONLY - RISCVCPU *rvcpu = RISCV_CPU(cpu); - CPURISCVState *env = &rvcpu->env; + CPURISCVState *env = cpu_env(cpu); #endif fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); From patchwork Mon Jan 29 16:45:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536005 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B392C15698A for ; Mon, 29 Jan 2024 16:47:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546863; cv=none; b=Sj746bLBm708m/5dI9YZs5fkwjGv0IgW7NMzWSql0LAMVCUe46esjClo6pQPFgeRe+GRi8G05HUEGnwv8gGfKcE1tCCr+HKKsZKY0BBLZDlNmlKcr5HfBgUnXL9lKARm4yKJ1VDcI93YTL4nbDGjXtlEyzlOylol36xlbRF0SAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546863; c=relaxed/simple; bh=QYjGjhBDCTMFWPYYpcxlFURhO+NurhznI/Men2aYSsE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t7StpUve5mBNPbKozx9Nsb3BsgPQz7A4S8gruyMAx4UbAGrX8huLrRVcLk1lGHQ/Q/lckqp+bBnEUlgUl27xdimSGgiOvhvCypwSErGDwDS0AqVWIx2ThjdY4wWp9mZqwEnZ075oh2kYIfB+pB/Jl1YUziqgGlUvyIXhrBOjmkE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=WvzfPH5U; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WvzfPH5U" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-33aed096cb3so979388f8f.1 for ; Mon, 29 Jan 2024 08:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546860; x=1707151660; darn=vger.kernel.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=hwuuHYCScnVvYP7kr484+mrpPVY1E/98uP6CY+N7AAI=; b=WvzfPH5UjZGL9qAkrzkUjlCEdrefdYHdIrUF2wtazRxK2qPBfcXt0LLNX7ELh7UxrD xEp6NyLzj0WD8pTDTi/ZGF1fU7oWC1WVP9L6eM8pjYJBiUBm0ZyQpXe+XpYQOduz4VFs eSieVoO/kiwjSUABx9Bqt7IVcfQgtscqth0XtHUABm0TACSPvovS0e4zXTprdR90M4VX ZRSNCqZBOsjhyo81Hq6E9/SE0MfNrihfyc/tywNsj26oYUYgJfJc8fY/fLEfvUuRL6G8 FeV4OgOcB/3xMPLD6fe60qAIf5EsafMD1aYbDcbGJRSX2PR9N+6WANZuqLyyeTJ8e6Hr oNdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546860; x=1707151660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hwuuHYCScnVvYP7kr484+mrpPVY1E/98uP6CY+N7AAI=; b=RpSoNQQKckXBN0Hwnja+u5mUb/0M5/hYVPgxEE8Az4045hQOCeG1YcFDeunM6i9NOr pT1hAgsNmR7GMD40/5uTf/+CczwnM4S4HQ/96Zfpkc6m0cOf5Jva9vHOqFFiVZc1FFB5 C5jUyZwZ+4X4kC5nP5bzueDA6fiYk35de7aIbQ8AUGCQ7CQhqXYOLw1o8fuaVlJdRr5X KRLNE40DMwwqDj6Rmpo7sObvgU4qzXTsnMj30O+9fhNy5IwZK5zhBuionlHsKs8yTYhi 7g0oAdkDzRUkX+nFVHrQjatfL5F/Zb5BxHrawm2E7gM2E6vmtQRZ1SPsc00aqVAE/fCh 0oMQ== X-Gm-Message-State: AOJu0YwK5ifxtobxaKVPB2AqAOF5rydHlu3e3CY8s7pkd1RQgpuufkDJ j1cWbGR3HQxcKRxFofM9rWB8ABr4ftx+VgV/h3wSa7IaoXfGao4oMlPvnHjSPRGTtzGoXXkQDtj s X-Google-Smtp-Source: AGHT+IFTnZ+wzzZWUdYzzOHHXq5N3vCTRzXyKyUR2LVbswqDwUPsHfY3FzalsZVCFAgzuwGQbmEO1g== X-Received: by 2002:adf:f310:0:b0:33a:eae2:11a6 with SMTP id i16-20020adff310000000b0033aeae211a6mr2615980wro.37.1706546860049; Mon, 29 Jan 2024 08:47:40 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id v9-20020adff689000000b0033af5c43155sm657193wrp.56.2024.01.29.08.47.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:39 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Yoshinori Sato Subject: [PATCH v3 23/29] target/rx: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:05 +0100 Message-ID: <20240129164514.73104-24-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/rx/cpu.c | 4 ++-- target/rx/gdbstub.c | 6 ++---- target/rx/helper.c | 6 ++---- target/rx/translate.c | 3 +-- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 58ca26184d..4689587fa9 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -66,9 +66,9 @@ static bool rx_cpu_has_work(CPUState *cs) static void rx_cpu_reset_hold(Object *obj) { - RXCPU *cpu = RX_CPU(obj); + CPUState *cs = CPU(obj); RXCPUClass *rcc = RX_CPU_GET_CLASS(obj); - CPURXState *env = &cpu->env; + CPURXState *env = cpu_env(cs); uint32_t *resetvec; if (rcc->parent_phases.hold) { diff --git a/target/rx/gdbstub.c b/target/rx/gdbstub.c index d7e0e6689b..f222bf003b 100644 --- a/target/rx/gdbstub.c +++ b/target/rx/gdbstub.c @@ -21,8 +21,7 @@ int rx_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - RXCPU *cpu = RX_CPU(cs); - CPURXState *env = &cpu->env; + CPURXState *env = cpu_env(cs); switch (n) { case 0 ... 15: @@ -53,8 +52,7 @@ int rx_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int rx_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - RXCPU *cpu = RX_CPU(cs); - CPURXState *env = &cpu->env; + CPURXState *env = cpu_env(cs); uint32_t psw; switch (n) { case 0 ... 15: diff --git a/target/rx/helper.c b/target/rx/helper.c index dad5fb4976..80912e8dcb 100644 --- a/target/rx/helper.c +++ b/target/rx/helper.c @@ -45,8 +45,7 @@ void rx_cpu_unpack_psw(CPURXState *env, uint32_t psw, int rte) #define INT_FLAGS (CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIR) void rx_cpu_do_interrupt(CPUState *cs) { - RXCPU *cpu = RX_CPU(cs); - CPURXState *env = &cpu->env; + CPURXState *env = cpu_env(cs); int do_irq = cs->interrupt_request & INT_FLAGS; uint32_t save_psw; @@ -122,8 +121,7 @@ void rx_cpu_do_interrupt(CPUState *cs) bool rx_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - RXCPU *cpu = RX_CPU(cs); - CPURXState *env = &cpu->env; + CPURXState *env = cpu_env(cs); int accept = 0; /* hardware interrupt (Normal) */ if ((interrupt_request & CPU_INTERRUPT_HARD) && diff --git a/target/rx/translate.c b/target/rx/translate.c index 1829a0b1cd..26aaf7a6b5 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -131,8 +131,7 @@ static int bdsp_s(DisasContext *ctx, int d) void rx_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - RXCPU *cpu = RX_CPU(cs); - CPURXState *env = &cpu->env; + CPURXState *env = cpu_env(cs); int i; uint32_t psw; From patchwork Mon Jan 29 16:45:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536006 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC9FB15697A for ; Mon, 29 Jan 2024 16:47:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546869; cv=none; b=pRTBq8nDoNZGX08eRHHAT2koox3R8gBc83vzG/Gw7FVoFx3XXo8DFtZpuU2Rh5G2VOAQ+RXQcYng5xnWuI/nvDVWRxB3Iqg7p+z9yh9kjNS44XdY9TbmDE5+KUIT1gFpayKQgQlSztjbGxrh/e+dUYHeOtZyozetNr3/mCAzar4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546869; c=relaxed/simple; bh=zYfZau/azRmfVZaoN/B+GygnlIYsdjS/6EaQzx7MS1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=a+8kugQQ90inm8JrZmtMATIzlwKN8qwvfC/HgQr9xvpz0FlZRVph+uUBnUGwgiA6IJ+94v98CQuq7ST3DGZ59sT3qwuGCvAH6rDsDpgYoXpfkB/OjZvMJ2uxVrnyjX7F89S7TeP5l9UaSwz+cNPMUhotkCa/NglDDDzNMsR4I9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=bUrijP96; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bUrijP96" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40e7065b7bdso39597675e9.3 for ; Mon, 29 Jan 2024 08:47:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546866; x=1707151666; darn=vger.kernel.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=s/zDxvb98/B1ERutMsrHfGwo048VXZrRTuyvepC4E0w=; b=bUrijP96yXC2/xI99TeCLgaE5zwYW9EE6vms6OHtfHA/eTmeHJHp8FbbBLXV8gDhI3 vMCiZdgYEYme2WM7kpxAW+3dq7/acJ4nHIoVpu9BpXvBdyVq25W4s2FBUVxHcl8rxSnF x1BPVDRQAJEsMT5/H3Ve5r54zGcMVdCWtDHD2tr+nEAtENNRsv6S/umtJ45L1Ocz07jY +PjylgvvkKqgQOywnksyNDJAikeCNSdWoRktRc8sSfEjUehPAYakCeFoLmmlL+xD+Xwt ZK9ddg8an99CvF3n4FBqH4mvGdjjR+SmzJARZimAwFTk8H9ElPQ5qFoXuqvzGGEpi9Eu iFaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546866; x=1707151666; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s/zDxvb98/B1ERutMsrHfGwo048VXZrRTuyvepC4E0w=; b=nSAnpqA2tOJM0rWk8RZSlIbDHcAmriFs6dn3OexkzzG4/2/eIx9TP+8dyN+4RLDQv2 ov9Pod2EsYFwAB0VEiFMrgYS/qcXkraqo/tcxY5CP+JASlapfLLzNc/hTappA+8S/ssH B0LR/hn1MR8N+doFWxuuEEgwZUWhtwWsWIS0cjuiZgNSmLoGoD3mg17+TuUCNBr3O5Wi qomxShXDfRBhVp8xTJOxOEvSW+3CFP1EKPJyH67H2TL+hAtrHdPCFrL8V01PkDshaUWJ WOilQ5aWAhXBUIm9zR5zDkhi1KsJPTb77TfJDRlAs28OD/NeomJwbeLu5fmRD0mstpa6 UDRg== X-Gm-Message-State: AOJu0Yx7Uz0/xs10EC25STUyR7bRdV8bT0EeCe7VOskqpOuyTkdvC/JS kQCLKcpnYayDNA8jUgeWe78hTtqKYyJCUjz26ObrT2TsSjOuu7+3DB5SnQvEsW4= X-Google-Smtp-Source: AGHT+IG/a7sScXNJHjqVQX2oWAIJv3ctaAT6+AtLGp/vpNQQ2nLJyCmfZDQ0ku5Yw0WBGO0v8F7fcg== X-Received: by 2002:a05:600c:3547:b0:40e:f681:b7b6 with SMTP id i7-20020a05600c354700b0040ef681b7b6mr2655551wmq.37.1706546865930; Mon, 29 Jan 2024 08:47:45 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id ay12-20020a5d6f0c000000b0033ad47d7b86sm8556726wrb.27.2024.01.29.08.47.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:45 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Thomas Huth , David Hildenbrand , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger Subject: [PATCH v3 24/29] target/s390x: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:06 +0100 Message-ID: <20240129164514.73104-25-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth --- target/s390x/cpu-dump.c | 3 +-- target/s390x/gdbstub.c | 6 ++---- target/s390x/helper.c | 3 +-- target/s390x/kvm/kvm.c | 6 ++---- target/s390x/tcg/excp_helper.c | 11 +++-------- target/s390x/tcg/misc_helper.c | 4 +--- target/s390x/tcg/translate.c | 3 +-- 7 files changed, 11 insertions(+), 25 deletions(-) diff --git a/target/s390x/cpu-dump.c b/target/s390x/cpu-dump.c index ffa9e94d84..69cc9f7746 100644 --- a/target/s390x/cpu-dump.c +++ b/target/s390x/cpu-dump.c @@ -27,8 +27,7 @@ void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; + CPUS390XState *env = cpu_env(cs); int i; qemu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64, diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index 6fbfd41bc8..f02fa316e5 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -30,8 +30,7 @@ int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; + CPUS390XState *env = cpu_env(cs); switch (n) { case S390_PSWM_REGNUM: @@ -46,8 +45,7 @@ int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; + CPUS390XState *env = cpu_env(cs); target_ulong tmpl = ldtul_p(mem_buf); switch (n) { diff --git a/target/s390x/helper.c b/target/s390x/helper.c index d76c06381b..00d5d403f3 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -139,8 +139,7 @@ void do_restart_interrupt(CPUS390XState *env) void s390_cpu_recompute_watchpoints(CPUState *cs) { const int wp_flags = BP_CPU | BP_MEM_WRITE | BP_STOP_BEFORE_ACCESS; - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; + CPUS390XState *env = cpu_env(cs); /* We are called when the watchpoints have changed. First remove them all. */ diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 888d6c1a1c..4ce809c5d4 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -474,8 +474,7 @@ static int can_sync_regs(CPUState *cs, int regs) int kvm_arch_put_registers(CPUState *cs, int level) { - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; + CPUS390XState *env = cpu_env(cs); struct kvm_fpu fpu = {}; int r; int i; @@ -601,8 +600,7 @@ int kvm_arch_put_registers(CPUState *cs, int level) int kvm_arch_get_registers(CPUState *cs) { - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; + CPUS390XState *env = cpu_env(cs); struct kvm_fpu fpu; int i, r; diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c index b875bf14e5..f1c33f7967 100644 --- a/target/s390x/tcg/excp_helper.c +++ b/target/s390x/tcg/excp_helper.c @@ -90,10 +90,7 @@ void HELPER(data_exception)(CPUS390XState *env, uint32_t dxc) static G_NORETURN void do_unaligned_access(CPUState *cs, uintptr_t retaddr) { - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; - - tcg_s390_program_interrupt(env, PGM_SPECIFICATION, retaddr); + tcg_s390_program_interrupt(cpu_env(cs), PGM_SPECIFICATION, retaddr); } #if defined(CONFIG_USER_ONLY) @@ -146,8 +143,7 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; + CPUS390XState *env = cpu_env(cs); target_ulong vaddr, raddr; uint64_t asc, tec; int prot, excp; @@ -600,8 +596,7 @@ bool s390_cpu_exec_interrupt(CPUState *cs, int interrupt_request) void s390x_cpu_debug_excp_handler(CPUState *cs) { - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; + CPUS390XState *env = cpu_env(cs); CPUWatchpoint *wp_hit = cs->watchpoint_hit; if (wp_hit && wp_hit->flags & BP_CPU) { diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c index 89b5268fd4..8764846ce8 100644 --- a/target/s390x/tcg/misc_helper.c +++ b/target/s390x/tcg/misc_helper.c @@ -214,9 +214,7 @@ void HELPER(sckc)(CPUS390XState *env, uint64_t ckc) void tcg_s390_tod_updated(CPUState *cs, run_on_cpu_data opaque) { - S390CPU *cpu = S390_CPU(cs); - - update_ckc_timer(&cpu->env); + update_ckc_timer(cpu_env(cs)); } /* Set Clock */ diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 8df00b7df9..9995689bc8 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -6558,8 +6558,7 @@ void s390x_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - S390CPU *cpu = S390_CPU(cs); - CPUS390XState *env = &cpu->env; + CPUS390XState *env = cpu_env(cs); int cc_op = data[1]; env->psw.addr = data[0]; From patchwork Mon Jan 29 16:45:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536007 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B09E15697A for ; Mon, 29 Jan 2024 16:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546875; cv=none; b=iNcRn/MgwsiKWbDsgyXvdvHHCfuLOErpVSIfyAbmDhe2branGPr9/x+w1ysDSEblHrQaOSYKCaN+qXwY7zfnmE2tucn++kY1Y+Bj0ZC+Yf2nwKK3qY4rrL7+T4Tz8QSDVchj9/IojVSA7R0xHg4rq6ijX+RlJisuyAlnI3Ov0H4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546875; c=relaxed/simple; bh=UBkk+/BtZa69DjzToQqaRNc2CnE+1uD9qBKBMq62gtk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CjNTL4rs/REuF6gGyGrCczziG5DNcqtjslrY+lz+QE8Jwe8Dq1wl88B3G/ihfarPWC4SOVbBfCmIJUrhDsZFPf/fTZbbBZonP3W1gXcclUAfRv//mNua3dxU8PNGB9iffNGopJjE8Mca0LKSXFEbl42G5xPY1xwlpnvFzcYVTOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=I1ja0EHK; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="I1ja0EHK" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-40e80046264so41021205e9.0 for ; Mon, 29 Jan 2024 08:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546872; x=1707151672; darn=vger.kernel.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=EK1f6yC+2+7tJRqq8zpOFY9o0Gec7K9NU3Dea7XiVcs=; b=I1ja0EHKB9QAdLM/vDSExFmhVudlFw7DiDa4RcrZ59pJF7NiFIbxlC5HN2ksDpCBGc Cpe9SOqdGvQtKr0jsA6pLO1xxmWXTR8sgdGsgewWrMHYlcp7p2Par5/6+WLIYUQ24Dzf BUPvGIimGgej636B32mD4q/4bZgk1Gb0Icn5cDa/8DelaDYvV9xwiIBxFYIm7qF8EIA4 rfXfE9UM6orVpbKD8PD7O19iQtoFl9Fsk0pc6Nfbsd1Ik8yxxqi6DUILVB+y7cS6tkNu I4SycgyKn7xlEkGvKoRvE644w6yW63lV97srv+8AnYTBM3pXRdx+BDPkPnZvokJ8/n7T DNUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546872; x=1707151672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EK1f6yC+2+7tJRqq8zpOFY9o0Gec7K9NU3Dea7XiVcs=; b=axrZOLg0XNWCKxx1z3tPc/R5scYPEuqCbTY2T99S2KcRkbc3zH6Kh7e1vxlbTEvGDO UWUE5idi0d/lcr6M+PIprc8eeIb1S5SwJasXo5jcI/s5SZITX4nc2Qmpp+Eh7ai0ic9B sxl3+fg6H8YbxzfIglB8mRnJDmQnu15J3851zxxxYgg7AakzCKHQW0M/UUQi7K9alExg Xxt7VjX0YcLLf1lNFFRzbQC7vq3Q8Gl8nVVOLHKjDgBQA8Dz0yx9N9h9poUUH5/tVHPP dhY5um64O1AKcffkOSIDYEK7ArT0HO/FqBe7q8C/T4RmsTt2elsYY322m2P+cX4O7Six 8uwA== X-Gm-Message-State: AOJu0Ywk9v9ZCDMz8KXHz9lWFTRwIVsiNNqzf/sgPua6SiboT68syCWz NVh/6h5B+H5uySkdIMRfL/dpriKCT1dKI5vHXoIiLnQWcihIJg8lPsI3DUUwYAc= X-Google-Smtp-Source: AGHT+IGp/BpyozcDAwqfGmyRJlRPq1/IHU+J5kLY+oFMWzv+eh6PdIu4rsOF1seUTLeuqx4RAfarbA== X-Received: by 2002:a05:600c:468f:b0:40e:cd0e:f749 with SMTP id p15-20020a05600c468f00b0040ecd0ef749mr5338733wmo.28.1706546871830; Mon, 29 Jan 2024 08:47:51 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id k7-20020a05600c1c8700b0040ef3ae26cdsm5224770wms.37.2024.01.29.08.47.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Yoshinori Sato Subject: [PATCH v3 25/29] target/sh4: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:07 +0100 Message-ID: <20240129164514.73104-26-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/sh4/cpu.c | 18 ++++++------------ target/sh4/gdbstub.c | 6 ++---- target/sh4/helper.c | 14 ++++---------- target/sh4/translate.c | 6 ++---- 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 1b03c7bcb1..3308a2be07 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -71,8 +71,7 @@ static void superh_restore_state_to_opc(CPUState *cs, static bool superh_io_recompile_replay_branch(CPUState *cs, const TranslationBlock *tb) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); if ((env->flags & (TB_FLAG_DELAY_SLOT | TB_FLAG_DELAY_SLOT_COND)) && !(cs->tcg_cflags & CF_PCREL) && env->pc != tb->pc) { @@ -92,9 +91,8 @@ static bool superh_cpu_has_work(CPUState *cs) static void superh_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); - SuperHCPU *cpu = SUPERH_CPU(cs); SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(obj); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); if (scc->parent_phases.hold) { scc->parent_phases.hold(obj); @@ -144,8 +142,7 @@ out: static void sh7750r_cpu_initfn(Object *obj) { - SuperHCPU *cpu = SUPERH_CPU(obj); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(CPU(obj)); env->id = SH_CPU_SH7750R; env->features = SH_FEATURE_BCR3_AND_BCR4; @@ -162,8 +159,7 @@ static void sh7750r_class_init(ObjectClass *oc, void *data) static void sh7751r_cpu_initfn(Object *obj) { - SuperHCPU *cpu = SUPERH_CPU(obj); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(CPU(obj)); env->id = SH_CPU_SH7751R; env->features = SH_FEATURE_BCR3_AND_BCR4; @@ -180,8 +176,7 @@ static void sh7751r_class_init(ObjectClass *oc, void *data) static void sh7785_cpu_initfn(Object *obj) { - SuperHCPU *cpu = SUPERH_CPU(obj); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(CPU(obj)); env->id = SH_CPU_SH7785; env->features = SH_FEATURE_SH4A; @@ -216,8 +211,7 @@ static void superh_cpu_realizefn(DeviceState *dev, Error **errp) static void superh_cpu_initfn(Object *obj) { - SuperHCPU *cpu = SUPERH_CPU(obj); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(CPU(obj)); env->movcal_backup_tail = &(env->movcal_backup); } diff --git a/target/sh4/gdbstub.c b/target/sh4/gdbstub.c index d8e199fc06..75926d4e04 100644 --- a/target/sh4/gdbstub.c +++ b/target/sh4/gdbstub.c @@ -26,8 +26,7 @@ int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); switch (n) { case 0 ... 7: @@ -76,8 +75,7 @@ int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int superh_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); switch (n) { case 0 ... 7: diff --git a/target/sh4/helper.c b/target/sh4/helper.c index 5a6f653c12..7c6f9d374a 100644 --- a/target/sh4/helper.c +++ b/target/sh4/helper.c @@ -55,8 +55,7 @@ int cpu_sh4_is_cached(CPUSH4State *env, target_ulong addr) void superh_cpu_do_interrupt(CPUState *cs) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); int do_irq = cs->interrupt_request & CPU_INTERRUPT_HARD; int do_exp, irq_vector = cs->exception_index; @@ -432,11 +431,10 @@ static int get_physical_address(CPUSH4State * env, target_ulong * physical, hwaddr superh_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { - SuperHCPU *cpu = SUPERH_CPU(cs); target_ulong physical; int prot; - if (get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD) + if (get_physical_address(cpu_env(cs), &physical, &prot, addr, MMU_DATA_LOAD) == MMU_OK) { return physical; } @@ -782,11 +780,8 @@ int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr) bool superh_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { if (interrupt_request & CPU_INTERRUPT_HARD) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; - /* Delay slots are indivisible, ignore interrupts */ - if (env->flags & TB_FLAG_DELAY_SLOT_MASK) { + if (cpu_env(cs)->flags & TB_FLAG_DELAY_SLOT_MASK) { return false; } else { superh_cpu_do_interrupt(cs); @@ -800,8 +795,7 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); int ret; target_ulong physical; diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 81f825f125..d9f222bd15 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -159,8 +159,7 @@ void sh4_translate_init(void) void superh_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); int i; qemu_fprintf(f, "pc=0x%08x sr=0x%08x pr=0x%08x fpscr=0x%08x\n", @@ -2186,7 +2185,6 @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env) static void sh4_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) { DisasContext *ctx = container_of(dcbase, DisasContext, base); - CPUSH4State *env = cpu_env(cs); uint32_t tbflags; int bound; @@ -2196,7 +2194,7 @@ static void sh4_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) /* We don't know if the delayed pc came from a dynamic or static branch, so assume it is a dynamic branch. */ ctx->delayed_pc = -1; /* use delayed pc from env pointer */ - ctx->features = env->features; + ctx->features = cpu_env(cs)->features; ctx->has_movcal = (tbflags & TB_FLAG_PENDING_MOVCA); ctx->gbank = ((tbflags & (1 << SR_MD)) && (tbflags & (1 << SR_RB))) * 0x10; From patchwork Mon Jan 29 16:45:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536008 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50556664D2 for ; Mon, 29 Jan 2024 16:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546881; cv=none; b=O6svx5P1YIfRL7cfuWqmaQ6B8Q99wwAcy+HiJ6w8sLf7LG4wUK9JrP0R4bWTqHS2rUZM0eZTHMRzzFzyp/JZyXWPFmT49RcQuZ1W2VGn7xBn+kxuc2pzIaHJDx5jZVaH4OaKN4RCS4VwWBTUXeBiXX0j0pM9Zh0Hmcn7Z5iogkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546881; c=relaxed/simple; bh=xkVFL2XKpJDgGuvyXwALPhj/xdn8aOuHeD7OeGTn3cQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hS1XGTs08TAEvtkPWAbIZ6j5C7q248WZcWK/AgzcIkOLuhDlIlIBZQIDtkCUD1HzwleVHgH5Ro/RYv0XzLUA5Hy8MSJ7VjGRwXw7GFVpSKv09Q+Zjz+qhVCKov2Q+yw2Hfm5RCM4sWh7FyUe+ZtkJ84/nUQKOASVJhJVlRSOR0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=xKaQxpdv; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xKaQxpdv" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3394ca0c874so2642919f8f.2 for ; Mon, 29 Jan 2024 08:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546877; x=1707151677; darn=vger.kernel.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=nDyOJncTz/gz39l44d2jGwByTaW/KG4k2gJ/GNswNnI=; b=xKaQxpdvY6imj4kGRv3CAXA3bStHQUr0P7ni7O+LZX3ba3HBGIgG7prcR5Eu+FAdLe hJ2N5YfjmsOU5lJggqSEuIfolPzvcFwBN2eWbD9iyw9MIBtwGWtAvWyeL3gdZEBz+0zF w4umA8QDidNDk34BzpgwN6ffYZH225gMaAsN+s/giEG9IaQP1cenBCTMbaMsfQTHJXeR ynMfZL34TxVo91OQ0Px1aPulRbxbhsIdmUGuZQpdizKWjwfRnHRShw9SYSYdlBZJcdSU zq4JJQDExfkmEZyUCHwAiSch4Bj2SNIE0WwyqcTmES0uzCExuScKTYKz0+5N07eVHIbi HCvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546877; x=1707151677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nDyOJncTz/gz39l44d2jGwByTaW/KG4k2gJ/GNswNnI=; b=CIUkrbFt853BTHJHwm9CTpHEtZzI1D+3Q2GeZi1p4He67Q44jem7Wokj83U706Gj41 Z2NVugJCZkdjuDUAhCzlHwJlW/fs9IXN7QfFTB2hGEg8lsS38+Xy4Y/mz1O5y7EzJJb1 8RM+wPTFv2QzOANHF39VVNdWgUCnUhh4bqa78k0ItD6T3i7XW3BkTWgjofPreogSGWzV Fba2i1KDaF1lxF0P4MYe8RncUY+vEZZtR8FRoNiYu6wpo2XOsqbhOXMB5/Syjo/QnXnR 7zquI1c+CIbs1N3ONlIyEYNgIqcHoaTqzHAvTPvDjdGfflCBAUDCuoINtuHYT5m5byZL olQA== X-Gm-Message-State: AOJu0Yyxdf4f0b1AU+CTZV78wB8O0/YRrWchQYUjBQwo5QxLBlupdqsn v011EQAlBLGDryYjd5XyjYVv3XBe8RCWqHEb+3EDRqJv3RpiDC0MSMI3SyKtLLQ= X-Google-Smtp-Source: AGHT+IGpSP62XxzQ6ZDTlpeFHsIrctZ9h8BZDrmsx+XYzXCe3dEYoh7yTLPt/V9X39N+RCxRJF1Yww== X-Received: by 2002:a5d:6812:0:b0:33a:e75e:281c with SMTP id w18-20020a5d6812000000b0033ae75e281cmr3295951wru.5.1706546877555; Mon, 29 Jan 2024 08:47:57 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id a15-20020a056000100f00b0033aee3bfac5sm2738967wrx.16.2024.01.29.08.47.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:57 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Mark Cave-Ayland , Artyom Tarasenko Subject: [PATCH v3 26/29] target/sparc: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:08 +0100 Message-ID: <20240129164514.73104-27-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Mark Cave-Ayland --- target/sparc/cpu.c | 17 +++++------------ target/sparc/gdbstub.c | 3 +-- target/sparc/int32_helper.c | 3 +-- target/sparc/int64_helper.c | 3 +-- target/sparc/ldst_helper.c | 6 ++---- target/sparc/mmu_helper.c | 15 +++++---------- target/sparc/translate.c | 9 +++------ 7 files changed, 18 insertions(+), 38 deletions(-) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 152bee4f81..72a9b9a285 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -32,9 +32,8 @@ static void sparc_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); - SPARCCPU *cpu = SPARC_CPU(cs); SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); if (scc->parent_phases.hold) { scc->parent_phases.hold(obj); @@ -83,8 +82,7 @@ static void sparc_cpu_reset_hold(Object *obj) static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { if (interrupt_request & CPU_INTERRUPT_HARD) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); if (cpu_interrupts_enabled(env) && env->interrupt_index > 0) { int pil = env->interrupt_index & 0xf; @@ -613,8 +611,7 @@ static void cpu_print_cc(FILE *f, uint32_t cc) static void sparc_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); int i, x; qemu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env->pc, @@ -711,11 +708,8 @@ static void sparc_cpu_synchronize_from_tb(CPUState *cs, static bool sparc_cpu_has_work(CPUState *cs) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; - return (cs->interrupt_request & CPU_INTERRUPT_HARD) && - cpu_interrupts_enabled(env); + cpu_interrupts_enabled(cpu_env(cs)); } static char *sparc_cpu_type_name(const char *cpu_model) @@ -749,8 +743,7 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) CPUState *cs = CPU(dev); SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(dev); Error *local_err = NULL; - SPARCCPU *cpu = SPARC_CPU(dev); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); #if defined(CONFIG_USER_ONLY) /* We are emulating the kernel, which will trap and emulate float128. */ diff --git a/target/sparc/gdbstub.c b/target/sparc/gdbstub.c index a1c8fdc4d5..5257c49a0d 100644 --- a/target/sparc/gdbstub.c +++ b/target/sparc/gdbstub.c @@ -29,8 +29,7 @@ int sparc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); if (n < 8) { /* g0..g7 */ diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index 058dd712b5..6b7d65b031 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -99,8 +99,7 @@ void cpu_check_irqs(CPUSPARCState *env) void sparc_cpu_do_interrupt(CPUState *cs) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); int cwp, intno = cs->exception_index; if (qemu_loglevel_mask(CPU_LOG_INT)) { diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index 27df9dba89..bd14c7a0db 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -130,8 +130,7 @@ void cpu_check_irqs(CPUSPARCState *env) void sparc_cpu_do_interrupt(CPUState *cs) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); int intno = cs->exception_index; trap_state *tsptr; diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index 09066d5487..203441bfb2 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -421,8 +421,7 @@ static void sparc_raise_mmu_fault(CPUState *cs, hwaddr addr, bool is_write, bool is_exec, int is_asi, unsigned size, uintptr_t retaddr) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); int fault_type; #ifdef DEBUG_UNASSIGNED @@ -483,8 +482,7 @@ static void sparc_raise_mmu_fault(CPUState *cs, hwaddr addr, bool is_write, bool is_exec, int is_asi, unsigned size, uintptr_t retaddr) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); #ifdef DEBUG_UNASSIGNED printf("Unassigned mem access to " HWADDR_FMT_plx " from " TARGET_FMT_lx diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index 453498c670..a05ee22315 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -206,8 +206,7 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); CPUTLBEntryFull full = {}; target_ulong vaddr; int error_code = 0, access_index; @@ -391,8 +390,7 @@ void dump_mmu(CPUSPARCState *env) int sparc_cpu_memory_rw_debug(CPUState *cs, vaddr address, uint8_t *buf, int len, bool is_write) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); target_ulong addr = address; int i; int len1; @@ -759,8 +757,7 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); CPUTLBEntryFull full = {}; int error_code = 0, access_index; @@ -898,8 +895,7 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr, hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); hwaddr phys_addr; int mmu_idx = cpu_mmu_index(env, false); @@ -916,8 +912,7 @@ G_NORETURN void sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, int mmu_idx, uintptr_t retaddr) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); #ifdef TARGET_SPARC64 env->dmmu.sfsr = build_sfsr(env, mmu_idx, access_type); diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 9387299559..769418d6b0 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5154,13 +5154,12 @@ TRANS(FCMPEq, ALL, do_fcmpq, a, true) static void sparc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); - CPUSPARCState *env = cpu_env(cs); int bound; dc->pc = dc->base.pc_first; dc->npc = (target_ulong)dc->base.tb->cs_base; dc->mem_idx = dc->base.tb->flags & TB_FLAG_MMU_MASK; - dc->def = &env->def; + dc->def = &cpu_env(cs)->def; dc->fpu_enabled = tb_fpu_enabled(dc->base.tb->flags); dc->address_mask_32bit = tb_am_enabled(dc->base.tb->flags); #ifndef CONFIG_USER_ONLY @@ -5210,10 +5209,9 @@ static void sparc_tr_insn_start(DisasContextBase *dcbase, CPUState *cs) static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); - CPUSPARCState *env = cpu_env(cs); unsigned int insn; - insn = translator_ldl(env, &dc->base, dc->pc); + insn = translator_ldl(cpu_env(cs), &dc->base, dc->pc); dc->base.pc_next += 4; if (!decode(dc, insn)) { @@ -5406,8 +5404,7 @@ void sparc_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - SPARCCPU *cpu = SPARC_CPU(cs); - CPUSPARCState *env = &cpu->env; + CPUSPARCState *env = cpu_env(cs); target_ulong pc = data[0]; target_ulong npc = data[1]; From patchwork Mon Jan 29 16:45:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536009 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EF63159579 for ; Mon, 29 Jan 2024 16:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546887; cv=none; b=HSKmAiKJ8p3WZ0gPgcFOpTpbcAEim2RG/wFbRldZfSLkw2226QV8evzIHEuzlEhHESxiYHMzdbGCu88+8KqcLk/hXFuZ/1/4NDOeaFjpv2/N2pMZCUzTJFYvQ40b8A5Ctwf2GWwOubf0GAKAH+yr1ySAU55BslWke/RZITofVGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546887; c=relaxed/simple; bh=/giGeSNQ051t0osD9OGq6OXrEl4LMgnNv5v2RuQWwX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ghS/hj6hJjLa3vheR7t4J0uKP3i3cdShl9Clm5D2Ct9zBwv4elbIc11QbDdXFdKyAZJGgdh3e955lq9+fzOHD0ohjpZSA2LFX+kzcxEAD7jI6DSuwMDgSrR5pRBEoATyLHjXDTLV6xaEmcObuGaoiD+YotNcXke7rc6Q22gW5F0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=GL2TrhID; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GL2TrhID" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-33af3c7ef60so588502f8f.0 for ; Mon, 29 Jan 2024 08:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546883; x=1707151683; darn=vger.kernel.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=+rt9340Neq6sQRGPVea3EhCde05ocdRyA3moNLb2tSg=; b=GL2TrhID6fzDtJT8ygxBcmOycEs+ue/40l/YIA9gZ/2V7wnsDubK45f0KgzmMulf0d 8w7+5LUALlwIaFPA3BtUS6PV/pVzjra8aSi7igPm1CT/G+V3dUK4yq4WSSHtOTGLMBrD xWehL22GzfHeGpr6DwGxxllLLXCkvJ0Mftk9ygExXQFehtUNCm6bD01XUbJPus8Scu38 Gb7I5okbHmJTpFxCiMV7rTsw9qi2+AL3IVp758qErgHuwShvxkbOMbxz5QeaX5xmXPDk fx5HPZyTVKjapJiRgb5sOEDYEyiSfyaJsUp0lPo6OUXNsy3ZA6pQ8floyUwuZaYy2j4Q Z0NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546883; x=1707151683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+rt9340Neq6sQRGPVea3EhCde05ocdRyA3moNLb2tSg=; b=dNOy6wi9zXK+gMSh0aLvdjX8IFkx2g2mk0M1NdMUVBuSkfepceGDra53/tFukxgsy/ 89uScKQbqVMX9u3aPPZt3ueAQSlwNX1P4QmZn2oQh0eaETwhK+9iRvpOA85+XbUpL42S BjHaEc6Ufb4zxu2AUV2VJJ2lsoWsZviZp9RPCXe4Pa2TIHKdQcqcn3x8SfU8M8z9mXbM qVameWC/6ikUyQC5ORyV4x9tlwyHvEuerSueIn2IhkDCRG1mj/QGPuwctNj2W8Ii8Dm+ NfLTScjQD+Al1J1WQeHRd4jsy2KCHUh0nFrGq8k6vR4HrWTxdy+M3yI5OKosVF10z0ut 05cg== X-Gm-Message-State: AOJu0YwtX8aViFs0CDLPsZlJeNnvC7lQUfpKViR2DTbapMZqxpdRIqiV CNohxVSzyIUM5otZXphAVeLX21j4P2+N7fO3P4uCOoSCMWnm5omi4uFKTegLTAs= X-Google-Smtp-Source: AGHT+IHwCuq+6yh1m6T7vY3Y2cLEq0q/hPFlPvC2NilRjpgFakRKueneRO9FZiqsXUrqr0KBPgYKVA== X-Received: by 2002:a5d:510f:0:b0:33a:e7de:aa8b with SMTP id s15-20020a5d510f000000b0033ae7deaa8bmr2928268wrt.26.1706546883422; Mon, 29 Jan 2024 08:48:03 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id b3-20020a05600003c300b0033ae46e0f02sm6350998wrg.75.2024.01.29.08.48.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:48:03 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Bastian Koppelmann Subject: [PATCH v3 27/29] target/tricore: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:09 +0100 Message-ID: <20240129164514.73104-28-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Bastian Koppelmann --- target/tricore/cpu.c | 24 +++++------------------- target/tricore/gdbstub.c | 6 ++---- target/tricore/helper.c | 3 +-- target/tricore/translate.c | 3 +-- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 9bdaa1593a..7c4a9b41a3 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -36,52 +36,38 @@ static const gchar *tricore_gdb_arch_name(CPUState *cs) static void tricore_cpu_set_pc(CPUState *cs, vaddr value) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; - - env->PC = value & ~(target_ulong)1; + cpu_env(cs)->PC = value & ~(target_ulong)1; } static vaddr tricore_cpu_get_pc(CPUState *cs) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; - - return env->PC; + return cpu_env(cs)->PC; } static void tricore_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; - tcg_debug_assert(!(cs->tcg_cflags & CF_PCREL)); - env->PC = tb->pc; + cpu_env(cs)->PC = tb->pc; } static void tricore_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; - - env->PC = data[0]; + cpu_env(cs)->PC = data[0]; } static void tricore_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); - TriCoreCPU *cpu = TRICORE_CPU(cs); TriCoreCPUClass *tcc = TRICORE_CPU_GET_CLASS(obj); - CPUTriCoreState *env = &cpu->env; if (tcc->parent_phases.hold) { tcc->parent_phases.hold(obj); } - cpu_state_reset(env); + cpu_state_reset(cpu_env(cs)); } static bool tricore_cpu_has_work(CPUState *cs) diff --git a/target/tricore/gdbstub.c b/target/tricore/gdbstub.c index e8f8e5e6ea..f9309c5e27 100644 --- a/target/tricore/gdbstub.c +++ b/target/tricore/gdbstub.c @@ -106,8 +106,7 @@ static void tricore_cpu_gdb_write_csfr(CPUTriCoreState *env, int n, int tricore_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; + CPUTriCoreState *env = cpu_env(cs); if (n < 16) { /* data registers */ return gdb_get_reg32(mem_buf, env->gpr_d[n]); @@ -121,8 +120,7 @@ int tricore_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int tricore_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; + CPUTriCoreState *env = cpu_env(cs); uint32_t tmp; tmp = ldl_p(mem_buf); diff --git a/target/tricore/helper.c b/target/tricore/helper.c index 174f666e1e..d328414c99 100644 --- a/target/tricore/helper.c +++ b/target/tricore/helper.c @@ -67,8 +67,7 @@ bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType rw, int mmu_idx, bool probe, uintptr_t retaddr) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; + CPUTriCoreState *env = cpu_env(cs); hwaddr physical; int prot; int ret = 0; diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 66553d1be0..ad314bdf3c 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -95,8 +95,7 @@ enum { void tricore_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; + CPUTriCoreState *env = cpu_env(cs); uint32_t psw; int i; From patchwork Mon Jan 29 16:45:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536010 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5E6B155A5F for ; Mon, 29 Jan 2024 16:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546893; cv=none; b=m9Lp5U43c4BNfF+7Ht1rfBMesS9moZrafDIt2KyVlRoMZp0sjjS0fVTeSrQSjof552MW+OrbEy1z/36VTelFSYSmjoMAI0l5fIcKAYmVSacIvWBQ1uEYvBvSW9Z/yNpsc8HE26M1pInYyW69b/OzKUqBSbm+fKoMjGwsPhmi7T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546893; c=relaxed/simple; bh=G2xYM8OFZLx+ZD/PIm0+f32tiE4FzDqwxRL8NyDKj1I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ODZ5Sa8msr4SopA1GQL68rWvnFsbwQf43WV89TCtDptIx7UjC8Ei5mUKnLzw0UXN7IGO5Ve2c7H2NcaCmENKxiGWuD1esXsNFivrWVzC3KX15N9c+zvRfAkwZCgpXgPHUExzPQ9jiBnhxEpsaDqujz7aNwdu4jzQ3bes8TsQbsE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=zVrQzIjA; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zVrQzIjA" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5110ef21c76so2014771e87.1 for ; Mon, 29 Jan 2024 08:48:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546890; x=1707151690; darn=vger.kernel.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=rfR8cC6O+BWQhQkWXGdZ7PfclWjDr/hbLCsaxnqdy8k=; b=zVrQzIjA5I/eKZ7/SlwqdsOw/0mYkYMzd8/R6L7F060Qnw4FNIm5AyJjAFUAcDQ2a/ WNRQYZfFPyldMmMWIELBvMK/mnrKZGtWGGNK9Z2F+sh5lPO+mc8vYxc1e16mIcGlVsWc ekVH2RmpsBhN0CnirePcNuAAY2DGUa5YbiIgfHu1yKS+6KqKagX1TC55zdXnpOIPocz5 VBGYjsvDZFIFcwYp9COvtayvssscnlqzFM9YHYfm5NuroAXUWd9k0ri/yT1q5KpepyOi Tn3KUnuEj7FyOgigK+ZaiL/PKxKVnQVh5ebzyeT2thaiauBSZU8p1DSi5gNv+3pEEy/H GtBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546890; x=1707151690; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rfR8cC6O+BWQhQkWXGdZ7PfclWjDr/hbLCsaxnqdy8k=; b=ZeTx2KzDEm4VTDge6Rbud3Y9XkXc/nHNbtCf6teEdL90XrXMwcxYthPH31ajF+5VCW UJKF3+6aduD11C4z6eD3FkCkyvGee2LGiJvchjIZBXK0hlzpMHJ4YX4sLpul7MtXEIb4 nfBK7vTh4bL+CDVgmWKHpipgsgz45YQ3osX3PMIslzl+EFeVO6CsCw3CLaeyICGWMAzL n1KlQWk84P5L0xyj9JA++P3OfqHOlJmRRmpF3gZmegaJGa8/bX85VDcrK5xB9vxKNxgZ r7cOq+4u5rxjDONzIbRdAqayoVIEfa7eYXBJd89TeYJYD79cW0mACzA0+cFLfLmIvrR6 Oo4Q== X-Gm-Message-State: AOJu0YzkaaL6nyUwsJdK9jCHVTCkM04JBtxURs+SIReNg3F22w6vKBBG X2hN3LwTECO/XVJwZuTXlv6z4JJLDuQGCg5I5nQ3lM6GZdopmgAM8ABQ0TdXefE= X-Google-Smtp-Source: AGHT+IFdYBYX+YhuXRJ5ebXXB5wSuyFUDmegmoCsIRNXBDPunLZRwNY2MqJbCauv7QOv9aYvnOjo7g== X-Received: by 2002:ac2:4e08:0:b0:510:1b81:ac2f with SMTP id e8-20020ac24e08000000b005101b81ac2fmr4708425lfr.62.1706546890079; Mon, 29 Jan 2024 08:48:10 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id u11-20020a056000038b00b0033aed5feea4sm3296936wrf.54.2024.01.29.08.48.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:48:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Max Filippov Subject: [PATCH v3 28/29] target/xtensa: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:10 +0100 Message-ID: <20240129164514.73104-29-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- target/xtensa/cpu.c | 3 +-- target/xtensa/dbg_helper.c | 3 +-- target/xtensa/exc_helper.c | 3 +-- target/xtensa/gdbstub.c | 6 ++---- target/xtensa/helper.c | 9 +++------ target/xtensa/translate.c | 6 ++---- 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index ce044466ad..47fd7c7ca9 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -91,9 +91,8 @@ bool xtensa_abi_call0(void) static void xtensa_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); - XtensaCPU *cpu = XTENSA_CPU(cs); XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(obj); - CPUXtensaState *env = &cpu->env; + CPUXtensaState *env = cpu_env(cs); bool dfpu = xtensa_option_enabled(env->config, XTENSA_OPTION_DFP_COPROCESSOR); diff --git a/target/xtensa/dbg_helper.c b/target/xtensa/dbg_helper.c index 497dafca71..5546c82ecd 100644 --- a/target/xtensa/dbg_helper.c +++ b/target/xtensa/dbg_helper.c @@ -66,8 +66,7 @@ void HELPER(wsr_ibreaka)(CPUXtensaState *env, uint32_t i, uint32_t v) bool xtensa_debug_check_breakpoint(CPUState *cs) { - XtensaCPU *cpu = XTENSA_CPU(cs); - CPUXtensaState *env = &cpu->env; + CPUXtensaState *env = cpu_env(cs); unsigned int i; if (xtensa_get_cintlevel(env) >= env->config->debug_level) { diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index 168419a505..0514c2c1f3 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -205,8 +205,7 @@ static void handle_interrupt(CPUXtensaState *env) /* Called from cpu_handle_interrupt with BQL held */ void xtensa_cpu_do_interrupt(CPUState *cs) { - XtensaCPU *cpu = XTENSA_CPU(cs); - CPUXtensaState *env = &cpu->env; + CPUXtensaState *env = cpu_env(cs); if (cs->exception_index == EXC_IRQ) { qemu_log_mask(CPU_LOG_INT, diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index 4b3bfb7e59..4748fb6532 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -65,8 +65,7 @@ void xtensa_count_regs(const XtensaConfig *config, int xtensa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - XtensaCPU *cpu = XTENSA_CPU(cs); - CPUXtensaState *env = &cpu->env; + CPUXtensaState *env = cpu_env(cs); const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n; #ifdef CONFIG_USER_ONLY int num_regs = env->config->gdb_regmap.num_core_regs; @@ -120,8 +119,7 @@ int xtensa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int xtensa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - XtensaCPU *cpu = XTENSA_CPU(cs); - CPUXtensaState *env = &cpu->env; + CPUXtensaState *env = cpu_env(cs); uint32_t tmp; const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n; #ifdef CONFIG_USER_ONLY diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index a9f8907083..ca214b948a 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -217,8 +217,7 @@ static uint32_t check_hw_breakpoints(CPUXtensaState *env) void xtensa_breakpoint_handler(CPUState *cs) { - XtensaCPU *cpu = XTENSA_CPU(cs); - CPUXtensaState *env = &cpu->env; + CPUXtensaState *env = cpu_env(cs); if (cs->watchpoint_hit) { if (cs->watchpoint_hit->flags & BP_CPU) { @@ -266,8 +265,7 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - XtensaCPU *cpu = XTENSA_CPU(cs); - CPUXtensaState *env = &cpu->env; + CPUXtensaState *env = cpu_env(cs); uint32_t paddr; uint32_t page_size; unsigned access; @@ -297,8 +295,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr) { - XtensaCPU *cpu = XTENSA_CPU(cs); - CPUXtensaState *env = &cpu->env; + CPUXtensaState *env = cpu_env(cs); cpu_restore_state(cs, retaddr); HELPER(exception_cause_vaddr)(env, env->pc, diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 87947236ca..e646e016df 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1127,10 +1127,9 @@ static void xtensa_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc = container_of(dcbase, DisasContext, base); - CPUXtensaState *env = cpu_env(cpu); uint32_t tb_flags = dc->base.tb->flags; - dc->config = env->config; + dc->config = cpu_env(cpu)->config; dc->pc = dc->base.pc_first; dc->ring = tb_flags & XTENSA_TBFLAG_RING_MASK; dc->cring = (tb_flags & XTENSA_TBFLAG_EXCM) ? 0 : dc->ring; @@ -1248,8 +1247,7 @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, void xtensa_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - XtensaCPU *cpu = XTENSA_CPU(cs); - CPUXtensaState *env = &cpu->env; + CPUXtensaState *env = cpu_env(cs); xtensa_isa isa = env->config->isa; int i, j; From patchwork Mon Jan 29 16:45:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13536011 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FE2215444C for ; Mon, 29 Jan 2024 16:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546901; cv=none; b=egl244rBzorA5fjNL0DgwS04jaWJHoXJRXslkamRknrBTgNjzt2G0WDqZFc27VuqMoHmgsZilQtc78/bEdWMaR041lTnLPD3WSIdDhjaJf6ck0wnEkBSW//wMGjS0XKxAhcU4mZiNblGZBPBL4EwtJmnldMNe3SKqgVC2A7QYKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706546901; c=relaxed/simple; bh=3sq3TTLsqoGsvdIWeTk/CkIR++kaDX/1diTBVrNbPgQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hZ8h6Sjh0jua9vv6Xnp0XqzU8gUxZOAgv0f5tttLK8IqYySeT0ihJB92mtQ4tPitr/Qb7bKn86459936JlQjuWLLG6cqXHLVxliXaMJuHNudsWkKTdcjkzJSnzLui69IvELz9EjGCdxRQB/IC1x1GJeS69PR8qzarY6+VUO6Enk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=U/cVr4+v; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="U/cVr4+v" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-40efcd830f6so1476845e9.0 for ; Mon, 29 Jan 2024 08:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546897; x=1707151697; darn=vger.kernel.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=Kk5BhQRPM94EKsRIhVMqYgmcfDsB7owy8rOzxcGC7OQ=; b=U/cVr4+vJdXysSyVknjJs6CE0SbXDDWAcRIEVE9Gggsd3aP1XpOKGGx7wSCbGyNh0X AYTaieHR8avyMQ1WE+UiabPmuBFAIFpO7035BQKpVtXWtXVCvqIx0uBIyBHHVcPKrRE7 MissQpDU8rWs0Zp1EUZEbhxEZdF81TwBTVuDNQO7BaepdO3QKHRmgNINxC+1jup8GuVt A8Xkd53XRRKAriFYNw7R7Pwn7UZkaxTPsvBJX5nmzp3UPFIVjIDMGzeR4XzPtitbQmrb proTH3EoLZVzoSMCvEn1GPab4/pKA7tWsCEoNHviih497TO+1DqGnTCFJu33JYE9Abzm 8pnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546897; x=1707151697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kk5BhQRPM94EKsRIhVMqYgmcfDsB7owy8rOzxcGC7OQ=; b=w3lbMrYiHbpzd40SddVpBGRfQx0b5FvaCrW4yx+lEFX9QfO1q6CFxpzV+QA5icLqwO v0hEFFl/INi0m+JFigjhuopEQeaWoFHojQ9MX6OUeWh6BG54L0Er0447/t74CnLnCFXF 5H4cL9Ysom2E+uNHqxz7ub21Gku4IHCrftVOkhks0+SN9u5hP8pldUDzwDOMhmJxhO+q 8NX1oF1BL8rnoENRFOfIcMCWYnY1ckdFttqoVULavI7HSXs6NoUjBkD5ijr8V7Cwz507 HLJ1/z3/ZRyfG8PdMwJvIZKWJAI6II9kjtfCw45AcDczeHZ4sX6S1Tm80K/ValS1GP1v x6HA== X-Gm-Message-State: AOJu0YxNB9Tw9owD8NoE5gV2KxCFSEZ9MrnR2QHWDmov3H6EWfR3kvxF IXLTKWwFhIYAa0jKC0EybtkCkcK8rwcuNhBvKHRNbQhrOqMsgtRHTAHVJn81JxE= X-Google-Smtp-Source: AGHT+IEXA1iompN1/gMqlkZsSEb4uT6I1SbkEs4HXc0WHAilXTqQn4jrwhExiORkNg2dlUXVfvblyw== X-Received: by 2002:adf:db11:0:b0:337:c91d:e816 with SMTP id s17-20020adfdb11000000b00337c91de816mr4734391wri.1.1706546897611; Mon, 29 Jan 2024 08:48:17 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id ck8-20020a5d5e88000000b003392986585esm8609742wrb.41.2024.01.29.08.48.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:48:17 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Warner Losh , Kyle Evans , Laurent Vivier Subject: [PATCH v3 29/29] user: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:11 +0100 Message-ID: <20240129164514.73104-30-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé --- bsd-user/signal.c | 3 +-- linux-user/signal.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index ca31470772..c6f0b1be38 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -463,14 +463,13 @@ static int fatal_signal(int sig) void force_sig_fault(int sig, int code, abi_ulong addr) { CPUState *cpu = thread_cpu; - CPUArchState *env = cpu_env(cpu); target_siginfo_t info = {}; info.si_signo = sig; info.si_errno = 0; info.si_code = code; info.si_addr = addr; - queue_signal(env, sig, QEMU_SI_FAULT, &info); + queue_signal(cpu_env(cpu), sig, QEMU_SI_FAULT, &info); } static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) diff --git a/linux-user/signal.c b/linux-user/signal.c index c9527adfa3..f78f7fc476 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -623,7 +623,6 @@ void signal_init(void) void force_sig(int sig) { CPUState *cpu = thread_cpu; - CPUArchState *env = cpu_env(cpu); target_siginfo_t info = {}; info.si_signo = sig; @@ -631,7 +630,7 @@ void force_sig(int sig) info.si_code = TARGET_SI_KERNEL; info._sifields._kill._pid = 0; info._sifields._kill._uid = 0; - queue_signal(env, info.si_signo, QEMU_SI_KILL, &info); + queue_signal(cpu_env(cpu), info.si_signo, QEMU_SI_KILL, &info); } /* @@ -641,14 +640,13 @@ void force_sig(int sig) void force_sig_fault(int sig, int code, abi_ulong addr) { CPUState *cpu = thread_cpu; - CPUArchState *env = cpu_env(cpu); target_siginfo_t info = {}; info.si_signo = sig; info.si_errno = 0; info.si_code = code; info._sifields._sigfault._addr = addr; - queue_signal(env, sig, QEMU_SI_FAULT, &info); + queue_signal(cpu_env(cpu), sig, QEMU_SI_FAULT, &info); } /* Force a SIGSEGV if we couldn't write to memory trying to set