Re: [PATCH 1/2] hw/arm/smmuv3: Check StreamIDs against SMMU_IDR1.SIDSIZE value
Hi, On 2/21/24 18:17, Nabih Estefan wrote: > From: Roque Arcudia Hernandez > > Current implementation checks the StreamIDs against STRTAB_BASE_CFG.LOG2SIZE > register field value and a constant SMMU_IDR1_SIDSIZE which is also used as > initial value for field SMMU_IDR1.SIDSIZE. > > This limits the possibility of extending the SMMUv3 by inheritance and > redefining the value of SMMU_IDR1.SIDSIZE because the check is hardcoded to > the > constant SMMU_IDR1_SIDSIZE rather than the register value. > > Signed-off-by: Roque Arcudia Hernandez > Signed-off-by: Nabih Estefan Reviewed-by: Eric Auger Thanks Eric > --- > hw/arm/smmuv3.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c > index 9eb56a70f3..a01031821a 100644 > --- a/hw/arm/smmuv3.c > +++ b/hw/arm/smmuv3.c > @@ -580,15 +580,17 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, > STE *ste, > { > dma_addr_t addr, strtab_base; > uint32_t log2size; > +uint32_t idr1_sidsize; > int strtab_size_shift; > int ret; > > trace_smmuv3_find_ste(sid, s->features, s->sid_split); > log2size = FIELD_EX32(s->strtab_base_cfg, STRTAB_BASE_CFG, LOG2SIZE); > +idr1_sidsize = FIELD_EX32(s->idr[1], IDR1, SIDSIZE); > /* > * Check SID range against both guest-configured and implementation > limits > */ > -if (sid >= (1 << MIN(log2size, SMMU_IDR1_SIDSIZE))) { > +if (sid >= (1 << MIN(log2size, idr1_sidsize))) { > event->type = SMMU_EVT_C_BAD_STREAMID; > return -EINVAL; > }
Re: [PATCH v2 0/2] OSPI updates
On Tue, 20 Feb 2024 at 09:17, Sai Pavan Boddu wrote: > > Add a new 2Gib octal flash mt35xu02gbba. Add an interface for versal > virt board to swap the default flash. > > Changes for V2: > Added type checks for provided flash part name. > > Sai Pavan Boddu (2): > block: m25p80: Add support of mt35xu02gbba > arm: xlnx-versal-virt: Add machine property ospi-flash > > hw/block/m25p80_sfdp.h| 1 + > hw/arm/xlnx-versal-virt.c | 44 ++- > hw/block/m25p80.c | 3 +++ > hw/block/m25p80_sfdp.c| 36 > 4 files changed, 83 insertions(+), 1 deletion(-) Applied to target-arm.next, thanks. -- PMM
[PATCH v2] hw/nvme/ns: Add NVMe NGUID property
From: Roque Arcudia Hernandez This patch adds a way to specify an NGUID for a given NVMe Namespace using a string of hexadecimal digits with an optional '-' separator to group bytes. For instance: -device nvme-ns,nguid="e9accd3b83904e13167cf0593437f57d" If provided, the NGUID will be part of the Namespace Identification Descriptor list and the Identify Namespace data. Signed-off-by: Roque Arcudia Hernandez Signed-off-by: Nabih Estefan Reviewed-by: Klaus Jensen --- docs/system/devices/nvme.rst | 7 ++ hw/nvme/ctrl.c | 12 +++ hw/nvme/meson.build | 2 +- hw/nvme/nguid.c | 187 +++ hw/nvme/ns.c | 2 + hw/nvme/nvme.h | 70 +++-- 6 files changed, 251 insertions(+), 29 deletions(-) create mode 100644 hw/nvme/nguid.c diff --git a/docs/system/devices/nvme.rst b/docs/system/devices/nvme.rst index 4ea957baed..d2b1ca9645 100644 --- a/docs/system/devices/nvme.rst +++ b/docs/system/devices/nvme.rst @@ -81,6 +81,13 @@ There are a number of parameters available: Set the UUID of the namespace. This will be reported as a "Namespace UUID" descriptor in the Namespace Identification Descriptor List. +``nguid`` + Set the NGUID of the namespace. This will be reported as a "Namespace Globally + Unique Identifier" descriptor in the Namespace Identification Descriptor List. + It is specified as a string of hexadecimal digits containing exactly 16 bytes + or "auto" for a random value. An optional '-' separator could be used to group + bytes. If not specified the NGUID will remain all zeros. + ``eui64`` Set the EUI-64 of the namespace. This will be reported as a "IEEE Extended Unique Identifier" descriptor in the Namespace Identification Descriptor List. diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f026245d1e..a2dc990dc1 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -5640,6 +5640,10 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req) NvmeIdNsDescr hdr; uint8_t v[NVME_NIDL_UUID]; } QEMU_PACKED uuid = {}; +struct { +NvmeIdNsDescr hdr; +uint8_t v[NVME_NIDL_NGUID]; +} QEMU_PACKED nguid = {}; struct { NvmeIdNsDescr hdr; uint64_t v; @@ -5668,6 +5672,14 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req) pos += sizeof(uuid); } +if (!nvme_nguid_is_null(>params.nguid)) { +nguid.hdr.nidt = NVME_NIDT_NGUID; +nguid.hdr.nidl = NVME_NIDL_NGUID; +memcpy(nguid.v, ns->params.nguid.data, NVME_NIDL_NGUID); +memcpy(pos, , sizeof(nguid)); +pos += sizeof(nguid); +} + if (ns->params.eui64) { eui64.hdr.nidt = NVME_NIDT_EUI64; eui64.hdr.nidl = NVME_NIDL_EUI64; diff --git a/hw/nvme/meson.build b/hw/nvme/meson.build index 1a6a2ca2f3..7d5caa53c2 100644 --- a/hw/nvme/meson.build +++ b/hw/nvme/meson.build @@ -1 +1 @@ -system_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('ctrl.c', 'dif.c', 'ns.c', 'subsys.c')) +system_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('ctrl.c', 'dif.c', 'ns.c', 'subsys.c', 'nguid.c')) \ No newline at end of file diff --git a/hw/nvme/nguid.c b/hw/nvme/nguid.c new file mode 100644 index 00..829832bd9f --- /dev/null +++ b/hw/nvme/nguid.c @@ -0,0 +1,187 @@ +/* + * QEMU NVMe NGUID functions + * + * Copyright 2024 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "qemu/osdep.h" +#include "qapi/visitor.h" +#include "qemu/ctype.h" +#include "nvme.h" + +#define NGUID_SEPARATOR '-' + +#define NGUID_VALUE_AUTO "auto" + +#define NGUID_FMT \ +"%02hhx%02hhx%02hhx%02hhx" \ +"%02hhx%02hhx%02hhx%02hhx" \ +"%02hhx%02hhx%02hhx%02hhx" \ +"%02hhx%02hhx%02hhx%02hhx" + +#define NGUID_STR_LEN (2 * NGUID_LEN + 1) + +bool nvme_nguid_is_null(const NvmeNGUID *nguid) +{ +static NvmeNGUID null_nguid; +return memcmp(nguid, _nguid, sizeof(NvmeNGUID)) == 0; +} + +static void nvme_nguid_generate(NvmeNGUID *out) +{ +int i; +uint32_t x; + +QEMU_BUILD_BUG_ON((NGUID_LEN % sizeof(x)) != 0); + +for (i = 0; i < NGUID_LEN; i += sizeof(x)) { +x = g_random_int(); +memcpy(>data[i], , sizeof(x)); +} +} + +/* + * The Linux Kernel typically prints the NGUID of an NVMe namespace using the + * same format as the UUID. For instance: + * + * $ cat /sys/class/block/nvme0n1/nguid + * e9accd3b-8390-4e13-167c-f0593437f57d + * + * When there is no UUID but
Re: [PATCH v2] xlnx-versal-ospi: disable reentrancy detection for iomem_dac
On Mon, 19 Feb 2024 at 10:56, Sai Pavan Boddu wrote: > > The OSPI DMA reads flash data through the OSPI linear address space (the > iomem_dac region), because of this the reentrancy guard introduced in > commit a2e1753b ("memory: prevent dma-reentracy issues") is disabled for > the memory region. > > Signed-off-by: Sai Pavan Boddu > --- > Changes for V2: > Added code comments. > > hw/ssi/xlnx-versal-ospi.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/hw/ssi/xlnx-versal-ospi.c b/hw/ssi/xlnx-versal-ospi.c > index c7b95b1f37..c479138ec1 100644 > --- a/hw/ssi/xlnx-versal-ospi.c > +++ b/hw/ssi/xlnx-versal-ospi.c > @@ -1772,6 +1772,12 @@ static void xlnx_versal_ospi_init(Object *obj) > memory_region_init_io(>iomem_dac, obj, _dac_ops, s, >TYPE_XILINX_VERSAL_OSPI "-dac", 0x2000); > sysbus_init_mmio(sbd, >iomem_dac); > +/* > + * The OSPI DMA reads flash data through the OSPI linear address space > (the > + * iomem_dac region), because of this the reentrancy guard needs to be > + * disabled. > + */ > +s->iomem_dac.disable_reentrancy_guard = true; Applied to target-arm.next, thanks. -- PMM
Re: [PATCH] MAINTAINERS: Cover hw/ide/ahci-allwinner.c with AllWinner A10 machine
On Thu, 15 Feb 2024 at 16:09, Philippe Mathieu-Daudé wrote: > > This code -- which was moved many times around -- was added in > commit 377e214539 ("ahci: Add allwinner AHCI") and belong to the > AllWinner machines. See also commit dca625768a ("arm: allwinner-a10: > Add SATA"). > > Signed-off-by: Philippe Mathieu-Daudé > --- Applied to target-arm.next, thanks. -- PMM
[PULL v2 00/32] Misc HW patches for 2024-02-22
The following changes since commit 760b4dcdddba4a40b9fa0eb78fdfc7eda7cb83d0: Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2024-02-20 10:11:08 +) are available in the Git repository at: https://github.com/philmd/qemu.git tags/hw-misc-20240222 for you to fetch changes up to 7164f7e4028ad3b01a5f98c27482587b401ad420: hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro (2024-02-22 12:47:40 +0100) Supersedes: <20240221211626.48190-1-phi...@linaro.org> Following checkpatch.pl error ignored: ERROR: Macros with complex values should be enclosed in parenthesis #62: FILE: include/hw/ide/ide-dev.h:31: +#define DEFINE_IDE_DEV_PROPERTIES() \ +DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf),\ +DEFINE_BLOCK_ERROR_PROPERTIES(IDEDrive, dev.conf), \ +DEFINE_PROP_STRING("ver", IDEDrive, dev.version), \ +DEFINE_PROP_UINT64("wwn", IDEDrive, dev.wwn, 0), \ +DEFINE_PROP_STRING("serial", IDEDrive, dev.serial),\ +DEFINE_PROP_STRING("model", IDEDrive, dev.model) Misc HW patch queue - Remove sysbus_add_io (Phil) - Build PPC 4xx PCI host bridges once (Phil) - Display QOM path while debugging SMBus targets (Joe) - Simplify x86 PC code (Bernhard) - Remove qemu_[un]register_reset() calls in x86 PC CMOS (Peter) - Fix wiring of ICH9 LPC interrupts (Bernhard) - Split core IDE as device / bus / dma (Thomas) - Prefer QDev API over QOM for devices (Phil) - Fix invalid use of DO_UPCAST() in Leon3 (Thomas) Bernhard Beschow (8): hw/i386/pc_piix: Share pc_cmos_init() invocation between pc and isapc machines hw/i386/x86: Turn apic_xrupt_override into class attribute hw/i386/pc: Merge pc_guest_info_init() into pc_machine_initfn() hw/i386/pc: Defer smbios_set_defaults() to machine_done hw/i386/pc: Confine system flash handling to pc_sysfw hw/i386/pc_sysfw: Inline pc_system_flash_create() and remove it hw/i386/pc_q35: Populate interrupt handlers before realizing LPC PCI function hw/isa/meson.build: Sort alphabetically Joe Komlodi (1): hw/i2c/smbus_slave: Add object path on error prints Peter Maydell (2): hw/i386/pc: Store pointers to IDE buses in PCMachineState hw/i386/pc: Do pc_cmos_init_late() from pc_machine_done() Philippe Mathieu-Daudé (13): hw/input/pckbd: Open-code i8042_setup_a20_line() wrapper hw/sysbus: Inline and remove sysbus_add_io() hw/ppc/ppc4xx_pci: Remove unused "hw/ppc/ppc.h" header hw/ppc/ppc4xx_pci: Extract PCI host definitions to hw/pci-host/ppc4xx.h hw/ppc/ppc4xx_pci: Move ppc4xx_pci.c to hw/pci-host/ hw/ppc/ppc440_pcix: Move ppc440_pcix.c to hw/pci-host/ hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API hw/ppc/pnv_bmc: Use qdev_new() instead of QOM API hw/tricore/testboard: Use qdev_new() instead of QOM basic API hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API hw/acpi: Include missing 'qapi/qapi-types-acpi.h' generated header hw/acpi/cpu: Use CPUState typedef hw/acpi/ich9_tco: Include missing 'migration/vmstate.h' header Thomas Huth (8): hw/ide: Add the possibility to disable the CompactFlash device in the build hw/ide: Split qdev.c into ide-bus.c and ide-dev.c hw/ide: Move IDE DMA related definitions to a separate header ide-dma.h hw/ide: Move IDE device related definitions to ide-dev.h hw/ide: Move IDE bus related definitions to a new header ide-bus.h hw/ide: Remove the include/hw/ide.h legacy file hw/ide: Stop exposing internal.h to non-IDE files hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro MAINTAINERS | 5 +- hw/i386/fw_cfg.h| 3 +- include/hw/acpi/cpu.h | 3 +- include/hw/acpi/ich9_tco.h | 1 + include/hw/acpi/memory_hotplug.h| 1 + include/hw/i386/pc.h| 9 +- include/hw/i386/x86.h | 3 +- include/hw/ide.h| 9 - include/hw/ide/ide-bus.h| 42 + include/hw/ide/ide-dev.h| 184 + include/hw/ide/ide-dma.h| 37 + include/hw/ide/internal.h | 211 +--- include/hw/ide/pci.h| 2 +- include/hw/input/i8042.h| 1 - include/hw/pci-host/ppc4xx.h| 17 ++ include/hw/ppc/ppc4xx.h | 5 - include/hw/sysbus.h | 2 - include/hw/tricore/tricore_testdevice.h | 3 - hw/core/sysbus.c| 6 - hw/i2c/smbus_slave.c| 8 +- hw/i386/acpi-common.c | 3 +- hw/i386/fw_cfg.c| 12 +- hw/i386/kvmvapic.c | 3 +- hw/i386/pc.c| 6
[PULL 23/32] hw/acpi/cpu: Use CPUState typedef
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 Message-Id: <20240126220407.95022-2-phi...@linaro.org> --- 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 e011d01adf..e6e1a9ef59 100644 --- a/include/hw/acpi/cpu.h +++ b/include/hw/acpi/cpu.h @@ -20,7 +20,7 @@ #include "hw/hotplug.h" typedef struct AcpiCpuStatus { -struct CPUState *cpu; +CPUState *cpu; uint64_t arch_id; bool is_inserting; bool is_removing; -- 2.41.0
[PULL 09/32] hw/tricore/testboard: Use qdev_new() instead of QOM basic API
Prefer QDev API for QDev objects, avoid the underlying QOM layer. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Bastian Koppelmann Message-Id: <20240216110313.17039-5-phi...@linaro.org> --- include/hw/tricore/tricore_testdevice.h | 3 --- hw/tricore/tricore_testboard.c | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/include/hw/tricore/tricore_testdevice.h b/include/hw/tricore/tricore_testdevice.h index 8b4fe15f24..2c57b62f22 100644 --- a/include/hw/tricore/tricore_testdevice.h +++ b/include/hw/tricore/tricore_testdevice.h @@ -25,12 +25,9 @@ OBJECT_CHECK(TriCoreTestDeviceState, (obj), TYPE_TRICORE_TESTDEVICE) typedef struct { -/* */ SysBusDevice parent_obj; -/* */ MemoryRegion iomem; - } TriCoreTestDeviceState; #endif diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c index b6810e3be0..c29db8b451 100644 --- a/hw/tricore/tricore_testboard.c +++ b/hw/tricore/tricore_testboard.c @@ -89,9 +89,7 @@ static void tricore_testboard_init(MachineState *machine, int board_id) memory_region_add_subregion(sysmem, 0xf005, pcp_data); memory_region_add_subregion(sysmem, 0xf006, pcp_text); -test_dev = g_new(TriCoreTestDeviceState, 1); -object_initialize(test_dev, sizeof(TriCoreTestDeviceState), - TYPE_TRICORE_TESTDEVICE); +test_dev = TRICORE_TESTDEVICE(qdev_new(TYPE_TRICORE_TESTDEVICE)); memory_region_add_subregion(sysmem, 0xf000, _dev->iomem); -- 2.41.0
[PULL 22/32] hw/acpi: Include missing 'qapi/qapi-types-acpi.h' generated header
ACPIOSTInfo is a QAPI generated structure: $ git grep -w ACPIOSTInfo qapi/acpi.json:81:# @ACPIOSTInfo: qapi/acpi.json:99:{ 'struct': 'ACPIOSTInfo', qapi/acpi.json:109:# Return a list of ACPIOSTInfo for devices that support status Include the "qapi/qapi-types-acpi.h" header to avoid the following errors when including "hw/acpi/cpu.h" or "hw/acpi/memory_hotplug.h" elsewhere: include/hw/acpi/cpu.h:67:52: error: unknown type name 'ACPIOSTInfoList' void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list); ^ include/hw/acpi/memory_hotplug.h:51:55: error: unknown type name 'ACPIOSTInfoList' void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list); ^ Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Zhao Liu Message-Id: <20240219141412.71418-2-phi...@linaro.org> --- include/hw/acpi/cpu.h| 1 + include/hw/acpi/memory_hotplug.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h index bc901660fb..e011d01adf 100644 --- a/include/hw/acpi/cpu.h +++ b/include/hw/acpi/cpu.h @@ -12,6 +12,7 @@ #ifndef ACPI_CPU_H #define ACPI_CPU_H +#include "qapi/qapi-types-acpi.h" #include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h index dfe9cf3fde..38841d7b06 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -1,6 +1,7 @@ #ifndef QEMU_HW_ACPI_MEMORY_HOTPLUG_H #define QEMU_HW_ACPI_MEMORY_HOTPLUG_H +#include "qapi/qapi-types-acpi.h" #include "hw/qdev-core.h" #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" -- 2.41.0
[PULL 32/32] hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro
From: Thomas Huth leon3.c currently fails to compile with some compilers when the -Wvla option has been enabled: ../hw/sparc/leon3.c: In function ‘leon3_cpu_reset’: ../hw/sparc/leon3.c:153:5: error: ISO C90 forbids variable length array ‘offset_must_be_zero’ [-Werror=vla] 153 | ResetData *s = (ResetData *)DO_UPCAST(ResetData, info[id], info); | ^ cc1: all warnings being treated as errors Looking at this code, the DO_UPCAST macro is indeed used in a wrong way here: DO_UPCAST is supposed to check that the second parameter is the first entry of the struct that the first parameter indicates, but since we use and index into the info[] array, this of course cannot work. The intention here was likely rather to use the container_of() macro instead, so switch the code accordingly. Fixes: d65aba8286 ("hw/sparc/leon3: implement multiprocessor") Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20240221180751.190489-1-th...@redhat.com> Tested-by: Clément Chigot Signed-off-by: Philippe Mathieu-Daudé --- hw/sparc/leon3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index 4873b59b6c..6aaa04cb19 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -150,7 +150,7 @@ static void leon3_cpu_reset(void *opaque) { struct CPUResetData *info = (struct CPUResetData *) opaque; int id = info->id; -ResetData *s = (ResetData *)DO_UPCAST(ResetData, info[id], info); +ResetData *s = container_of(info, ResetData, info[id]); CPUState *cpu = CPU(s->info[id].cpu); CPUSPARCState *env = cpu_env(cpu); -- 2.41.0
[PULL 19/32] hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API
Prefer QDev API for QDev objects, avoid the underlying QOM layer. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Zhao Liu Message-Id: <20240216110313.17039-3-phi...@linaro.org> --- hw/i386/pc_sysfw.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 2dcaa116ad..b02e285579 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -95,17 +95,15 @@ static void pc_system_flash_cleanup_unused(PCMachineState *pcms) { char *prop_name; int i; -Object *dev_obj; assert(PC_MACHINE_GET_CLASS(pcms)->pci_enabled); for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) { -dev_obj = OBJECT(pcms->flash[i]); -if (!object_property_get_bool(dev_obj, "realized", _abort)) { +if (!qdev_is_realized(DEVICE(pcms->flash[i]))) { prop_name = g_strdup_printf("pflash%d", i); object_property_del(OBJECT(pcms), prop_name); g_free(prop_name); -object_unparent(dev_obj); +object_unparent(OBJECT(pcms->flash[i])); pcms->flash[i] = NULL; } } -- 2.41.0
[PULL 24/32] hw/acpi/ich9_tco: Include missing 'migration/vmstate.h' header
We need the VMStateDescription structure definition from "migration/vmstate.h" in order to declare vmstate_tco_io_sts. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Zhao Liu Message-Id: <20240219141412.71418-4-phi...@linaro.org> --- include/hw/acpi/ich9_tco.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/hw/acpi/ich9_tco.h b/include/hw/acpi/ich9_tco.h index c4393caee0..2562a7cf39 100644 --- a/include/hw/acpi/ich9_tco.h +++ b/include/hw/acpi/ich9_tco.h @@ -11,6 +11,7 @@ #define HW_ACPI_TCO_H #include "exec/memory.h" +#include "migration/vmstate.h" /* As per ICH9 spec, the internal timer has an error of ~0.6s on every tick */ #define TCO_TICK_NSEC 6LL -- 2.41.0
[PULL 08/32] hw/ppc/pnv_bmc: Use qdev_new() instead of QOM API
Prefer QDev API for QDev objects, avoid the underlying QOM layer. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Message-Id: <20240216110313.17039-6-phi...@linaro.org> --- hw/ppc/pnv_bmc.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c index 99f1e8d7f9..0c1274df21 100644 --- a/hw/ppc/pnv_bmc.c +++ b/hw/ppc/pnv_bmc.c @@ -269,13 +269,13 @@ void pnv_bmc_set_pnor(IPMIBmc *bmc, PnvPnor *pnor) */ IPMIBmc *pnv_bmc_create(PnvPnor *pnor) { -Object *obj; +DeviceState *dev; -obj = object_new(TYPE_IPMI_BMC_SIMULATOR); -qdev_realize(DEVICE(obj), NULL, _fatal); -pnv_bmc_set_pnor(IPMI_BMC(obj), pnor); +dev = qdev_new(TYPE_IPMI_BMC_SIMULATOR); +qdev_realize(dev, NULL, _fatal); +pnv_bmc_set_pnor(IPMI_BMC(dev), pnor); -return IPMI_BMC(obj); +return IPMI_BMC(dev); } typedef struct ForeachArgs { -- 2.41.0
[PULL 07/32] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API
Prefer QDev API for QDev objects, avoid the underlying QOM layer. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Zhao Liu Message-Id: <20240216110313.17039-4-phi...@linaro.org> --- hw/ppc/spapr_cpu_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 0c0fb3f1b0..40b7c52f7f 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -245,8 +245,7 @@ static void spapr_cpu_core_unrealize(DeviceState *dev) * spapr_cpu_core_realize(), make sure we only unrealize * vCPUs that have already been realized. */ -if (object_property_get_bool(OBJECT(sc->threads[i]), "realized", - _abort)) { +if (qdev_is_realized(DEVICE(sc->threads[i]))) { spapr_unrealize_vcpu(sc->threads[i], sc); } spapr_delete_vcpu(sc->threads[i]); -- 2.41.0
[PULL 02/32] hw/sysbus: Inline and remove sysbus_add_io()
sysbus_add_io(...) is a simple wrapper to memory_region_add_subregion(get_system_io(), ...). It is used in 3 places; inline it directly. Rationale: we want to move to an explicit I/O bus, rather that an implicit one. Besides in heterogeneous setup we can have more than one I/O bus. Reviewed-by: Peter Maydell Message-Id: <20240216150441.45681-1-phi...@linaro.org> [PMD: Include missing "exec/address-spaces.h" header] Signed-off-by: Philippe Mathieu-Daudé --- include/hw/sysbus.h | 2 -- hw/core/sysbus.c| 6 -- hw/i386/kvmvapic.c | 3 ++- hw/mips/mipssim.c | 3 ++- hw/nvram/fw_cfg.c | 6 -- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h index 3564b7b6a2..14dbc22d0c 100644 --- a/include/hw/sysbus.h +++ b/include/hw/sysbus.h @@ -83,8 +83,6 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr); void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr, int priority); void sysbus_mmio_unmap(SysBusDevice *dev, int n); -void sysbus_add_io(SysBusDevice *dev, hwaddr addr, - MemoryRegion *mem); MemoryRegion *sysbus_address_space(SysBusDevice *dev); bool sysbus_realize(SysBusDevice *dev, Error **errp); diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 35f902b582..9f1d5b2d6d 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -298,12 +298,6 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev) return g_strdup(qdev_fw_name(dev)); } -void sysbus_add_io(SysBusDevice *dev, hwaddr addr, - MemoryRegion *mem) -{ -memory_region_add_subregion(get_system_io(), addr, mem); -} - MemoryRegion *sysbus_address_space(SysBusDevice *dev) { return get_system_memory(); diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index f2b0aff479..20b0300357 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -16,6 +16,7 @@ #include "sysemu/hw_accel.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" +#include "exec/address-spaces.h" #include "hw/i386/apic_internal.h" #include "hw/sysbus.h" #include "hw/boards.h" @@ -727,7 +728,7 @@ static void vapic_realize(DeviceState *dev, Error **errp) VAPICROMState *s = VAPIC(dev); memory_region_init_io(>io, OBJECT(s), _ops, s, "kvmvapic", 2); -sysbus_add_io(sbd, VAPIC_IO_PORT, >io); +memory_region_add_subregion(get_system_io(), VAPIC_IO_PORT, >io); sysbus_init_ioports(sbd, VAPIC_IO_PORT, 2); option_rom[nb_option_roms].name = "kvmvapic.bin"; diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index a12427b6c8..9170d6c474 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -28,6 +28,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/datadir.h" +#include "exec/address-spaces.h" #include "hw/clock.h" #include "hw/mips/mips.h" #include "hw/char/serial.h" @@ -226,7 +227,7 @@ mips_mipssim_init(MachineState *machine) qdev_prop_set_uint8(dev, "endianness", DEVICE_LITTLE_ENDIAN); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), _fatal); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, env->irq[4]); -sysbus_add_io(SYS_BUS_DEVICE(dev), 0x3f8, +memory_region_add_subregion(get_system_io(), 0x3f8, sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0)); } diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index e85493d513..fc0263f349 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -27,6 +27,7 @@ #include "sysemu/sysemu.h" #include "sysemu/dma.h" #include "sysemu/reset.h" +#include "exec/address-spaces.h" #include "hw/boards.h" #include "hw/nvram/fw_cfg.h" #include "hw/qdev-properties.h" @@ -1142,6 +1143,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, SysBusDevice *sbd; FWCfgIoState *ios; FWCfgState *s; +MemoryRegion *iomem = get_system_io(); bool dma_requested = dma_iobase && dma_as; dev = qdev_new(TYPE_FW_CFG_IO); @@ -1155,7 +1157,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, sbd = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(sbd, _fatal); ios = FW_CFG_IO(dev); -sysbus_add_io(sbd, iobase, >comb_iomem); +memory_region_add_subregion(iomem, iobase, >comb_iomem); s = FW_CFG(dev); @@ -1163,7 +1165,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, /* 64 bits for the address field */ s->dma_as = dma_as; s->dma_addr = 0; -sysbus_add_io(sbd, dma_iobase, >dma_iomem); +memory_region_add_subregion(iomem, dma_iobase, >dma_iomem); } return s; -- 2.41.0
Re: [PULL 00/25] Misc HW patches for 2024-02-21
Hi, On 21/2/24 22:16, Philippe Mathieu-Daudé wrote: The following changes since commit 760b4dcdddba4a40b9fa0eb78fdfc7eda7cb83d0: Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2024-02-20 10:11:08 +) are available in the Git repository at: https://github.com/philmd/qemu.git tags/hw-misc-20240221 for you to fetch changes up to df07f6bb563f25f39f4f5887adab557e42bdee59: hw/sparc/leon3: Fix wrong usage of DO_UPCAST macro (2024-02-21 22:13:03 +0100) Following checkpatch.pl error ignored: ERROR: Macros with complex values should be enclosed in parenthesis #62: FILE: include/hw/ide/ide-dev.h:31: +#define DEFINE_IDE_DEV_PROPERTIES() \ +DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf),\ +DEFINE_BLOCK_ERROR_PROPERTIES(IDEDrive, dev.conf), \ +DEFINE_PROP_STRING("ver", IDEDrive, dev.version), \ +DEFINE_PROP_UINT64("wwn", IDEDrive, dev.wwn, 0), \ +DEFINE_PROP_STRING("serial", IDEDrive, dev.serial),\ +DEFINE_PROP_STRING("model", IDEDrive, dev.model) Misc HW patch queue - Remove sysbus_add_io (Phil) - Build PPC 4xx PCI host bridges once (Phil) - Display QOM path while debugging SMBus targets (Joe) - Simplify x86 PC code (Bernhard) - Remove qemu_[un]register_reset() calls in x86 PC CMOS (Peter) - Fix wiring of ICH9 LPC interrupts (Bernhard) - Split core IDE as device / bus / dma (Thomas) - Fix invalid use of DO_UPCAST() in Leon3 (Thomas) I did the mistake to rebase on master after testing, and not test again, and missed a new header must be added in "hw/i386/kvmvapic.c". I apologize for that and will respin a v2 once fully tested again. Regards, Phil.
Re: [PATCH] hw/nvme: fix invalid endian conversion
On Feb 22 11:08, Philippe Mathieu-Daudé wrote: > Hi Klaus, > > On 22/2/24 10:29, Klaus Jensen wrote: > > From: Klaus Jensen > > > > numcntl is one byte and so is max_vfs. Using cpu_to_le16 on big endian > > hosts results in numcntl being set to 0. > > > > Fix by dropping the endian conversion. > > > > Fixes: 746d42b13368 ("hw/nvme: Initialize capability structures for > > primary/secondary controllers") > > Isn't it commit 99f48ae7ae ("Add support for Secondary Controller > List") instead? > Thanks Philippe, Yes, that is the commit that had the bug originally. I'll fix it up. signature.asc Description: PGP signature
Re: [PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style
On 22/2/24 10:12, Zhao Liu wrote: Hi Philippe, On Fri, Feb 16, 2024 at 12:02:52PM +0100, Philippe Mathieu-Daudé wrote: Date: Fri, 16 Feb 2024 12:02:52 +0100 From: Philippe Mathieu-Daudé Subject: [PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style X-Mailer: git-send-email 2.41.0 QEMU's coding style generally forbids C99 mixed declarations. Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/pc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 196827531a..3c00a87317 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1227,6 +1227,7 @@ void pc_basic_device_init(struct PCMachineState *pcms, */ if (pcms->hpet_enabled) { qemu_irq rtc_irq; +uint8_t compat; hpet = qdev_try_new(TYPE_HPET); if (!hpet) { @@ -1238,8 +1239,7 @@ void pc_basic_device_init(struct PCMachineState *pcms, * use IRQ16~23, IRQ8 and IRQ2. If the user has already set * the property, use whatever mask they specified. */ -uint8_t compat = object_property_get_uint(OBJECT(hpet), -HPET_INTCAP, NULL); +compat = object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL); if (!compat) { qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs); } "compat" is only used here to check. So, what about getting rid of this variable? if (!object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL)) { qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs); } Ah yeah, I didn't noticed, thanks!
Re: [PATCH] hw/nvme: fix invalid endian conversion
Hi Klaus, On 22/2/24 10:29, Klaus Jensen wrote: From: Klaus Jensen numcntl is one byte and so is max_vfs. Using cpu_to_le16 on big endian hosts results in numcntl being set to 0. Fix by dropping the endian conversion. Fixes: 746d42b13368 ("hw/nvme: Initialize capability structures for primary/secondary controllers") Isn't it commit 99f48ae7ae ("Add support for Secondary Controller List") instead? Reported-by: Kevin Wolf Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f026245d1e9e..76fe0397045b 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -7924,7 +7924,7 @@ static void nvme_init_state(NvmeCtrl *n) n->aer_reqs = g_new0(NvmeRequest *, n->params.aerl + 1); QTAILQ_INIT(>aer_queue); -list->numcntl = cpu_to_le16(max_vfs); +list->numcntl = max_vfs; for (i = 0; i < max_vfs; i++) { sctrl = >sec[i]; sctrl->pcid = cpu_to_le16(n->cntlid); --- base-commit: 760b4dcdddba4a40b9fa0eb78fdfc7eda7cb83d0 change-id: 20240222-fix-sriov-numcntl-5ebe46a42176 Best regards,
Re: [PATCH 21/21] hw: Add QOM parentship relation with CPUs
On Fri, Feb 16, 2024 at 12:03:12PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:03:12 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 21/21] hw: Add QOM parentship relation with CPUs > X-Mailer: git-send-email 2.41.0 > > QDev objects created with object_new() need to manually add > their parent relationship with object_property_add_child(). > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/i386/x86.c| 1 + > hw/microblaze/petalogix_ml605_mmu.c | 1 + > hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 + > hw/mips/cps.c| 1 + > hw/nios2/10m50_devboard.c| 1 + > hw/ppc/e500.c| 1 + > hw/ppc/spapr.c | 1 + > 7 files changed, 7 insertions(+) Reviewed-by: Zhao Liu > > diff --git a/hw/i386/x86.c b/hw/i386/x86.c > index 684dce90e9..7021419d91 100644 > --- a/hw/i386/x86.c > +++ b/hw/i386/x86.c > @@ -102,6 +102,7 @@ void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, > Error **errp) > if (!object_property_set_uint(cpu, "apic-id", apic_id, errp)) { > goto out; > } > +object_property_add_child(OBJECT(x86ms), "cpu[*]", OBJECT(cpu)); > qdev_realize(DEVICE(cpu), NULL, errp); > > out: > diff --git a/hw/microblaze/petalogix_ml605_mmu.c > b/hw/microblaze/petalogix_ml605_mmu.c > index 0f5fabc32e..dfd881322d 100644 > --- a/hw/microblaze/petalogix_ml605_mmu.c > +++ b/hw/microblaze/petalogix_ml605_mmu.c > @@ -83,6 +83,7 @@ petalogix_ml605_init(MachineState *machine) > > /* init CPUs */ > cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU)); > +object_property_add_child(OBJECT(machine), "cpu", OBJECT(cpu)); > object_property_set_str(OBJECT(cpu), "version", "8.10.a", _abort); > /* Use FPU but don't use floating point conversion and square > * root instructions > diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c > b/hw/microblaze/petalogix_s3adsp1800_mmu.c > index dad46bd7f9..255d8d4d47 100644 > --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c > +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c > @@ -70,6 +70,7 @@ petalogix_s3adsp1800_init(MachineState *machine) > MemoryRegion *sysmem = get_system_memory(); > > cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU)); > +object_property_add_child(OBJECT(machine), "cpu", OBJECT(cpu)); > object_property_set_str(OBJECT(cpu), "version", "7.10.d", _abort); > qdev_realize(DEVICE(cpu), NULL, _abort); > > diff --git a/hw/mips/cps.c b/hw/mips/cps.c > index 07b73b0a1f..6b4e918807 100644 > --- a/hw/mips/cps.c > +++ b/hw/mips/cps.c > @@ -84,6 +84,7 @@ static void mips_cps_realize(DeviceState *dev, Error **errp) > /* All cores use the same clock tree */ > qdev_connect_clock_in(DEVICE(cpu), "clk-in", s->clock); > > +object_property_add_child(OBJECT(dev), "cpu[*]", OBJECT(cpu)); > if (!qdev_realize_and_unref(DEVICE(cpu), NULL, errp)) { > return; > } > diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c > index 6cb32f777b..f6a691d340 100644 > --- a/hw/nios2/10m50_devboard.c > +++ b/hw/nios2/10m50_devboard.c > @@ -95,6 +95,7 @@ static void nios2_10m50_ghrd_init(MachineState *machine) > cpu->exception_addr = 0xc8000120; > cpu->fast_tlb_miss_addr = 0xc100; > > +object_property_add_child(OBJECT(machine), "cpu", OBJECT(cpu)); > qdev_realize_and_unref(DEVICE(cpu), NULL, _fatal); > > if (nms->vic) { > diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c > index 3bd12b54ab..77b7d2858c 100644 > --- a/hw/ppc/e500.c > +++ b/hw/ppc/e500.c > @@ -956,6 +956,7 @@ void ppce500_init(MachineState *machine) > */ > object_property_set_bool(OBJECT(cs), "start-powered-off", i != 0, > _abort); > +object_property_add_child(OBJECT(machine), "cpu[*]", OBJECT(cpu)); > qdev_realize_and_unref(DEVICE(cs), NULL, _fatal); > > if (!firstenv) { > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 0d72d286d8..b6e5caa0d2 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -2715,6 +2715,7 @@ static void spapr_init_cpus(SpaprMachineState *spapr) > _fatal); > object_property_set_int(core, CPU_CORE_PROP_CORE_ID, core_id, > _fatal); > +object_property_add_child(OBJECT(spapr), "cpu[*]", OBJECT(core)); > qdev_realize(DEVICE(core), NULL, _fatal); > > object_unref(core); > -- > 2.41.0 > >
Re: [PATCH 03/21] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API
On Fri, Feb 16, 2024 at 12:02:54PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:02:54 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 03/21] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of > QOM API > X-Mailer: git-send-email 2.41.0 > > Prefer QDev API for QDev objects, avoid the underlying QOM layer. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/ppc/spapr_cpu_core.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) Reviewed-by: Zhao Liu > > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > index 0c0fb3f1b0..40b7c52f7f 100644 > --- a/hw/ppc/spapr_cpu_core.c > +++ b/hw/ppc/spapr_cpu_core.c > @@ -245,8 +245,7 @@ static void spapr_cpu_core_unrealize(DeviceState *dev) > * spapr_cpu_core_realize(), make sure we only unrealize > * vCPUs that have already been realized. > */ > -if (object_property_get_bool(OBJECT(sc->threads[i]), "realized", > - _abort)) { > +if (qdev_is_realized(DEVICE(sc->threads[i]))) { > spapr_unrealize_vcpu(sc->threads[i], sc); > } > spapr_delete_vcpu(sc->threads[i]); > -- > 2.41.0 > >
Re: [PATCH 10/21] hw/usb: Inline usb_new()
On Fri, Feb 16, 2024 at 12:03:01PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:03:01 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 10/21] hw/usb: Inline usb_new() > X-Mailer: git-send-email 2.41.0 > > Inline the 2 uses of usb_new(). > > Signed-off-by: Philippe Mathieu-Daudé > --- > include/hw/usb.h| 1 - > hw/usb/bus.c| 9 ++--- > hw/usb/dev-serial.c | 2 +- > 3 files changed, 3 insertions(+), 9 deletions(-) Reviewed-by: Zhao Liu > > diff --git a/include/hw/usb.h b/include/hw/usb.h > index 32c23a5ca2..2d820685cc 100644 > --- a/include/hw/usb.h > +++ b/include/hw/usb.h > @@ -500,7 +500,6 @@ void usb_bus_release(USBBus *bus); > USBBus *usb_bus_find(int busnr); > void usb_legacy_register(const char *typename, const char *usbdevice_name, > USBDevice *(*usbdevice_init)(void)); > -USBDevice *usb_new(const char *name); > bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp); > USBDevice *usb_create_simple(USBBus *bus, const char *name); > USBDevice *usbdevice_create(const char *cmdline); > diff --git a/hw/usb/bus.c b/hw/usb/bus.c > index 148224f06a..a599e2552b 100644 > --- a/hw/usb/bus.c > +++ b/hw/usb/bus.c > @@ -329,11 +329,6 @@ void usb_legacy_register(const char *typename, const > char *usbdevice_name, > } > } > > -USBDevice *usb_new(const char *name) > -{ > -return USB_DEVICE(qdev_new(name)); > -} > - > bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp) > { > return qdev_realize_and_unref(>qdev, >qbus, errp); > @@ -341,7 +336,7 @@ bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, > Error **errp) > > USBDevice *usb_create_simple(USBBus *bus, const char *name) > { > -USBDevice *dev = usb_new(name); > +USBDevice *dev = USB_DEVICE(qdev_new(name)); > > usb_realize_and_unref(dev, bus, _abort); > return dev; > @@ -693,7 +688,7 @@ USBDevice *usbdevice_create(const char *driver) > return NULL; > } > > -dev = f->usbdevice_init ? f->usbdevice_init() : usb_new(f->name); > +dev = f->usbdevice_init ? f->usbdevice_init() : > USB_DEVICE(qdev_new(f->name)); > if (!dev) { > error_report("Failed to create USB device '%s'", f->name); > return NULL; > diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c > index 63047d79cf..6e79c46d53 100644 > --- a/hw/usb/dev-serial.c > +++ b/hw/usb/dev-serial.c > @@ -624,7 +624,7 @@ static USBDevice *usb_braille_init(void) > return NULL; > } > > -dev = usb_new("usb-braille"); > +dev = USB_DEVICE(qdev_new("usb-braille")); > qdev_prop_set_chr(>qdev, "chardev", cdrv); > return dev; > } > -- > 2.41.0 > >
Re: [PATCH 07/21] target: Replace DEVICE(object_new) -> qdev_new()
On Fri, Feb 16, 2024 at 12:02:58PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:02:58 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 07/21] target: Replace DEVICE(object_new) -> qdev_new() > X-Mailer: git-send-email 2.41.0 > > Prefer QDev API for QDev objects, avoid the underlying QOM layer. > > Signed-off-by: Philippe Mathieu-Daudé > --- > target/mips/cpu.c | 2 +- > target/xtensa/cpu.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Zhao Liu > > diff --git a/target/mips/cpu.c b/target/mips/cpu.c > index d644adbc77..6b3909ee08 100644 > --- a/target/mips/cpu.c > +++ b/target/mips/cpu.c > @@ -649,7 +649,7 @@ MIPSCPU *mips_cpu_create_with_clock(const char *cpu_type, > Clock *cpu_refclk) > { > DeviceState *cpu; > > -cpu = DEVICE(object_new(cpu_type)); > +cpu = qdev_new(cpu_type); > qdev_connect_clock_in(cpu, "clk-in", cpu_refclk); > qdev_realize(cpu, NULL, _abort); > > diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c > index 79f91819df..4f9408e1a0 100644 > --- a/target/xtensa/cpu.c > +++ b/target/xtensa/cpu.c > @@ -205,7 +205,7 @@ XtensaCPU *xtensa_cpu_create_with_clock(const char > *cpu_type, Clock *cpu_refclk) > { > DeviceState *cpu; > > -cpu = DEVICE(object_new(cpu_type)); > +cpu = qdev_new(cpu_type); > qdev_connect_clock_in(cpu, "clk-in", cpu_refclk); > qdev_realize(cpu, NULL, _abort); > > -- > 2.41.0 > >
Re: [PATCH 09/21] hw/usb: Inline usb_try_new()
On Fri, Feb 16, 2024 at 12:03:00PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:03:00 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 09/21] hw/usb: Inline usb_try_new() > X-Mailer: git-send-email 2.41.0 > > Inline the single use of usb_try_new(). > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/usb/bus.c | 7 +-- > 1 file changed, 1 insertion(+), 6 deletions(-) Reviewed-by: Zhao Liu > > diff --git a/hw/usb/bus.c b/hw/usb/bus.c > index 59c39945dd..148224f06a 100644 > --- a/hw/usb/bus.c > +++ b/hw/usb/bus.c > @@ -334,11 +334,6 @@ USBDevice *usb_new(const char *name) > return USB_DEVICE(qdev_new(name)); > } > > -static USBDevice *usb_try_new(const char *name) > -{ > -return USB_DEVICE(qdev_try_new(name)); > -} > - > bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp) > { > return qdev_realize_and_unref(>qdev, >qbus, errp); > @@ -447,7 +442,7 @@ void usb_claim_port(USBDevice *dev, Error **errp) > } else { > if (bus->nfree == 1 && strcmp(object_get_typename(OBJECT(dev)), > "usb-hub") != 0) { > /* Create a new hub and chain it on */ > -hub = usb_try_new("usb-hub"); > +hub = USB_DEVICE(qdev_try_new("usb-hub")); > if (hub) { > usb_realize_and_unref(hub, bus, NULL); > } > -- > 2.41.0 > >
Re: [PATCH 06/21] hw: Replace DEVICE(object_new) -> qdev_new()
On Fri, Feb 16, 2024 at 12:02:57PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:02:57 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 06/21] hw: Replace DEVICE(object_new) -> qdev_new() > X-Mailer: git-send-email 2.41.0 > > Prefer QDev API for QDev objects, avoid the underlying QOM layer. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/arm/musicpal.c | 2 +- > hw/core/qdev.c| 2 +- > hw/sparc/sun4m.c | 4 ++-- > 3 files changed, 4 insertions(+), 4 deletions(-) Reviewed-by: Zhao Liu > > diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c > index 2020f73a57..74e4d24aab 100644 > --- a/hw/arm/musicpal.c > +++ b/hw/arm/musicpal.c > @@ -1238,7 +1238,7 @@ static void musicpal_init(MachineState *machine) >qdev_get_gpio_in(pic, MP_TIMER4_IRQ), NULL); > > /* Logically OR both UART IRQs together */ > -uart_orgate = DEVICE(object_new(TYPE_OR_IRQ)); > +uart_orgate = qdev_new(TYPE_OR_IRQ); > object_property_set_int(OBJECT(uart_orgate), "num-lines", 2, > _fatal); > qdev_realize_and_unref(uart_orgate, NULL, _fatal); > qdev_connect_gpio_out(uart_orgate, 0, > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index c68d0f7c51..a271380d20 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -171,7 +171,7 @@ DeviceState *qdev_try_new(const char *name) > if (!module_object_class_by_name(name)) { > return NULL; > } > -return DEVICE(object_new(name)); > +return qdev_new(name); > } > > static QTAILQ_HEAD(, DeviceListener) device_listeners > diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c > index d52e6a7213..fedc4b8b3f 100644 > --- a/hw/sparc/sun4m.c > +++ b/hw/sparc/sun4m.c > @@ -979,7 +979,7 @@ static void sun4m_hw_init(MachineState *machine) > sysbus_mmio_map(s, 0, hwdef->ms_kb_base); > > /* Logically OR both its IRQs together */ > -ms_kb_orgate = DEVICE(object_new(TYPE_OR_IRQ)); > +ms_kb_orgate = qdev_new(TYPE_OR_IRQ); > object_property_set_int(OBJECT(ms_kb_orgate), "num-lines", 2, > _fatal); > qdev_realize_and_unref(ms_kb_orgate, NULL, _fatal); > sysbus_connect_irq(s, 0, qdev_get_gpio_in(ms_kb_orgate, 0)); > @@ -1000,7 +1000,7 @@ static void sun4m_hw_init(MachineState *machine) > sysbus_mmio_map(s, 0, hwdef->serial_base); > > /* Logically OR both its IRQs together */ > -serial_orgate = DEVICE(object_new(TYPE_OR_IRQ)); > +serial_orgate = qdev_new(TYPE_OR_IRQ); > object_property_set_int(OBJECT(serial_orgate), "num-lines", 2, > _fatal); > qdev_realize_and_unref(serial_orgate, NULL, _fatal); > -- > 2.41.0 > >
Re: [PATCH 11/21] hw/usb: Add QOM parentship relation with hub devices
Hi Philippe, On Fri, Feb 16, 2024 at 12:03:02PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:03:02 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 11/21] hw/usb: Add QOM parentship relation with hub devices > X-Mailer: git-send-email 2.41.0 > > QDev objects created with qdev_*new() need to manually add > their parent relationship with object_property_add_child(). > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/usb/bus.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/usb/bus.c b/hw/usb/bus.c > index a599e2552b..baad04f466 100644 > --- a/hw/usb/bus.c > +++ b/hw/usb/bus.c > @@ -439,6 +439,7 @@ void usb_claim_port(USBDevice *dev, Error **errp) > /* Create a new hub and chain it on */ > hub = USB_DEVICE(qdev_try_new("usb-hub")); One additional question comes to mind, should we use the qdev_new() here? The difference between qdev_try_new() and qdev_new() is the latter uses assert() to ensure the passed type exists. So if we know that type parameter is correct, we should just use qdev_new(). Only when the caller is not sure whether the type is valid, qdev_try_new() should be preferred. Am I understand correctly? ;-) > if (hub) { > +object_property_add_child(OBJECT(dev), "hub", OBJECT(hub)); >From the comment above the code: /* Create a new hub and chain it on */ this only creates a new usb-hub, should the new usb-hub become the child object of the original usb-hub? > usb_realize_and_unref(hub, bus, NULL); > } > } > -- > 2.41.0 > >
[PATCH] hw/nvme: fix invalid endian conversion
From: Klaus Jensen numcntl is one byte and so is max_vfs. Using cpu_to_le16 on big endian hosts results in numcntl being set to 0. Fix by dropping the endian conversion. Fixes: 746d42b13368 ("hw/nvme: Initialize capability structures for primary/secondary controllers") Reported-by: Kevin Wolf Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f026245d1e9e..76fe0397045b 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -7924,7 +7924,7 @@ static void nvme_init_state(NvmeCtrl *n) n->aer_reqs = g_new0(NvmeRequest *, n->params.aerl + 1); QTAILQ_INIT(>aer_queue); -list->numcntl = cpu_to_le16(max_vfs); +list->numcntl = max_vfs; for (i = 0; i < max_vfs; i++) { sctrl = >sec[i]; sctrl->pcid = cpu_to_le16(n->cntlid); --- base-commit: 760b4dcdddba4a40b9fa0eb78fdfc7eda7cb83d0 change-id: 20240222-fix-sriov-numcntl-5ebe46a42176 Best regards, -- Klaus Jensen
Re: [PATCH] hw/nvme/ns: Add NVMe NGUID property
On Feb 21 17:38, Nabih Estefan wrote: > From: Roque Arcudia Hernandez > > This patch adds a way to specify an NGUID for a given NVMe Namespace using a > string of hexadecimal digits with an optional '-' separator to group bytes. > For > instance: > > -device nvme-ns,nguid="e9accd3b83904e13167cf0593437f57d" > > If provided, the NGUID will be part of the Namespace Identification Descriptor > list and the Identify Namespace data. > > Signed-off-by: Roque Arcudia Hernandez > Signed-off-by: Nabih Estefan Hi Thanks! Looks good, Reviewed-by: Klaus Jensen Only a minor nit below. > diff --git a/hw/nvme/nguid.c b/hw/nvme/nguid.c > new file mode 100644 > index 00..3e3e0567c5 > --- /dev/null > +++ b/hw/nvme/nguid.c > @@ -0,0 +1,192 @@ > +/* > + * QEMU NVMe NGUID functions > + * > + * Copyright 2024 Google LLC > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License as published by the > + * Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, but > WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License > + * for more details. > + */ > + > +#include "qemu/osdep.h" > +#include "qapi/visitor.h" > +#include "qemu/ctype.h" > +#include "nvme.h" > + > +#define NGUID_SEPARATOR '-' > + > +#define NGUID_VALUE_AUTO "auto" > + > +#define NGUID_FMT \ > +"%02hhx%02hhx%02hhx%02hhx" \ > +"%02hhx%02hhx%02hhx%02hhx" \ > +"%02hhx%02hhx%02hhx%02hhx" \ > +"%02hhx%02hhx%02hhx%02hhx" > + > +#define NGUID_STR_LEN (2 * NGUID_LEN + 1) > + > +bool nvme_nguid_is_null(const NvmeNGUID *nguid) > +{ > +int i; > +for (i = 0; i < NGUID_LEN; i++) { > +if (nguid->data[i] != 0) { > +return false; > +} > +} > +return true; > +} Maybe just bool nvme_nguid_is_null(const NvmeNGUID *nguid) { static NvmeNGUID null_nguid; return memcmp(nguid, _nguid, sizeof(NvmeNGUID)) == 0; } signature.asc Description: PGP signature
Re: [PATCH 17/21] hw/i386/iommu: Prefer object_initialize_child over object_initialize
Hi Philippe, On Fri, Feb 16, 2024 at 12:03:08PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:03:08 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 17/21] hw/i386/iommu: Prefer object_initialize_child over > object_initialize > X-Mailer: git-send-email 2.41.0 > > When the QOM parent is available, prefer object_initialize_child() > over object_initialize(), since it create the parent relationship. > > Rename the 'klass' variable as 'obj' since the argument holds a > reference to an instance object and not a class one. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/i386/amd_iommu.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c > index 7329553ad3..c3afbc4130 100644 > --- a/hw/i386/amd_iommu.c > +++ b/hw/i386/amd_iommu.c > @@ -1616,11 +1616,11 @@ static const VMStateDescription vmstate_amdvi_sysbus > = { > .unmigratable = 1 > }; > > -static void amdvi_sysbus_instance_init(Object *klass) > +static void amdvi_sysbus_instance_init(Object *obj) > { > -AMDVIState *s = AMD_IOMMU_DEVICE(klass); > +AMDVIState *s = AMD_IOMMU_DEVICE(obj); > > -object_initialize(>pci, sizeof(s->pci), TYPE_AMD_IOMMU_PCI); > +object_initialize_child(obj, "iommu", >pci, TYPE_AMD_IOMMU_PCI); What about this name "amd-iommu"? This is more accurate and differentiates it from the other intel-iommu related implementations. > } > > static void amdvi_sysbus_class_init(ObjectClass *klass, void *data) > -- > 2.41.0 > >
Re: [PATCH 02/21] hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API
On Fri, Feb 16, 2024 at 12:02:53PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:02:53 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 02/21] hw/i386/pc_sysfw: Use qdev_is_realized() instead of > QOM API > X-Mailer: git-send-email 2.41.0 > > Prefer QDev API for QDev objects, avoid the underlying QOM layer. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/i386/pc_sysfw.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) Reviewed-by: Zhao Liu > > diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c > index c8d9e71b88..3efabbbab2 100644 > --- a/hw/i386/pc_sysfw.c > +++ b/hw/i386/pc_sysfw.c > @@ -107,17 +107,15 @@ void pc_system_flash_cleanup_unused(PCMachineState > *pcms) > { > char *prop_name; > int i; > -Object *dev_obj; > > assert(PC_MACHINE_GET_CLASS(pcms)->pci_enabled); > > for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) { > -dev_obj = OBJECT(pcms->flash[i]); > -if (!object_property_get_bool(dev_obj, "realized", _abort)) { > +if (!qdev_is_realized(DEVICE(pcms->flash[i]))) { > prop_name = g_strdup_printf("pflash%d", i); > object_property_del(OBJECT(pcms), prop_name); > g_free(prop_name); > -object_unparent(dev_obj); > +object_unparent(OBJECT(pcms->flash[i])); > pcms->flash[i] = NULL; > } > } > -- > 2.41.0 > >
Re: [PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style
Hi Philippe, On Fri, Feb 16, 2024 at 12:02:52PM +0100, Philippe Mathieu-Daudé wrote: > Date: Fri, 16 Feb 2024 12:02:52 +0100 > From: Philippe Mathieu-Daudé > Subject: [PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style > X-Mailer: git-send-email 2.41.0 > > QEMU's coding style generally forbids C99 mixed declarations. > > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/i386/pc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 196827531a..3c00a87317 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1227,6 +1227,7 @@ void pc_basic_device_init(struct PCMachineState *pcms, > */ > if (pcms->hpet_enabled) { > qemu_irq rtc_irq; > +uint8_t compat; > > hpet = qdev_try_new(TYPE_HPET); > if (!hpet) { > @@ -1238,8 +1239,7 @@ void pc_basic_device_init(struct PCMachineState *pcms, > * use IRQ16~23, IRQ8 and IRQ2. If the user has already set > * the property, use whatever mask they specified. > */ > -uint8_t compat = object_property_get_uint(OBJECT(hpet), > -HPET_INTCAP, NULL); > +compat = object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL); > if (!compat) { > qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs); > } "compat" is only used here to check. So, what about getting rid of this variable? if (!object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL)) { qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs); }