Misc HW patches for 2026-01-20
Subsystems (2)
The following changes since commit 38879a667fbb4ef54c70de71494882615f600a64:
Merge tag 'pull-tcg-20260119' of https://gitlab.com/rth7680/qemu into staging (2026-01-19 09:04:31 +1100)
are available in the Git repository at:
https://github.com/philmd/qemu.git tags/hw-misc-20260120
for you to fetch changes up to 84f82697f8294377224aad9f7cc499116ae0ec49:
meson: Do not try to build module for empty per-target hw/ directory (2026-01-20 19:34:44 +0100)
----------------------------------------------------------------
Misc HW patches
- Generalized IOMMU test framework
- Fix Freescale SDHCI endianness issues
- Support for zboot images compressed with Zstd
- Pcap support to analyze UEFI firmware traffic
----------------------------------------------------------------
Bernhard Beschow (13):
hw/sd/sdhci: Fix TYPE_IMX_USDHC to implement sd-spec-version 3 by
default
hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version"
property
hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes hw/arm/fsl-imx25: Apply missing reset quirk
Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*" hw/sd/sdhci: Consolidate eSDHC constants
hw/sd/sdhci: Rename usdhc_ functions
hw/sd/sdhci: Add TYPE_FSL_ESDHC_BE
hw/ppc/e500: Use TYPE_FSL_ESDHC_BE
hw/arm/fsl-imx25: Extract TYPE_FSL_ESDHC_LE
hw/sd/sdhci: Remove endianness property
hw/sd/sdhci: Remove vendor property
hw/sd/trace-events: Remove redundant "SWITCH " command name
Daan De Meyer (4):
hw/loader: Rename LOAD_IMAGE_MAX _GUNZIP_BYTES to _DECOMPRESSED_BYTES hw/loader: Rename UBOOT_MAX _GUNZIP_BYTES to _DECOMPRESSED_BYTES hw/loader: Use g_autofree in unpack_efi_zboot_image() hw/loader: Add support for zboot images compressed with zstd
Gerd Hoffmann (2):
hw: move pcap structs to header file
hw/uefi: add pcap support
Paolo Bonzini (1):
hw/virtio-nsm: include qemu/osdep.h
Philippe Mathieu-Daudé (1):
meson: Do not try to build module for empty per-target hw/ directory
Tao Tang (8):
hw/arm/smmuv3: Extract common definitions to smmuv3-common.h hw/arm/smmuv3-common: Define STE/CD fields via registerfields hw/misc: Introduce iommu-testdev for bare-metal IOMMU testing hw/arm/smmuv3-common: Add NSCFG bit definition for CD hw/arm/smmuv3-common: Add STE/CD set helpers for repeated field setup tests/qtest: Add libqos iommu-testdev helpers tests/qtest/libqos: Add SMMUv3 helper library
tests/qtest: Add SMMUv3 bare-metal test using iommu-testdev
MAINTAINERS | 14 + docs/specs/index.rst | 1 + docs/specs/iommu-testdev.rst | 140 ++++++ meson.build | 7 +- hw/arm/smmuv3-internal.h | 255 +--------- hw/sd/sdhci-internal.h | 3 - include/hw/arm/fsl-imx6.h | 4 +- include/hw/arm/smmuv3-common.h | 423 +++++++++++++++++ include/hw/core/loader.h | 4 +- include/hw/misc/iommu-testdev.h | 87 ++++ include/hw/sd/sdhci.h | 8 +- include/hw/uefi/var-service.h | 10 + include/qemu/pcap.h | 30 ++ tests/qtest/libqos/qos-iommu-testdev.h | 43 ++ tests/qtest/libqos/qos-smmuv3.h | 242 ++++++++++ hw/arm/boot.c | 4 +- hw/arm/fsl-imx25.c | 5 +- hw/arm/fsl-imx6.c | 18 +- hw/core/loader-fit.c | 2 +- hw/core/loader.c | 44 +- hw/misc/iommu-testdev.c | 318 +++++++++++++ hw/nvram/fw_cfg.c | 3 +- hw/ppc/e500.c | 10 +- hw/sd/sdhci.c | 181 ++++--- hw/uefi/var-service-core.c | 7 + hw/uefi/var-service-pcap.c | 95 ++++ hw/uefi/var-service-sysbus.c | 1 + hw/usb/pcap.c | 24 +- hw/virtio/cbor-helpers.c | 1 + tests/qtest/iommu-smmuv3-test.c | 132 ++++++ tests/qtest/libqos/qos-iommu-testdev.c | 82 ++++ tests/qtest/libqos/qos-smmuv3.c | 629 +++++++++++++++++++++++++ hw/misc/Kconfig | 5 + hw/misc/meson.build | 1 + hw/misc/trace-events | 10 + hw/sd/trace-events | 2 +- hw/uefi/meson.build | 1 + tests/qtest/libqos/meson.build | 4 + tests/qtest/meson.build | 3 + 39 files changed, 2445 insertions(+), 408 deletions(-) create mode 100644 docs/specs/iommu-testdev.rst create mode 100644 include/hw/arm/smmuv3-common.h create mode 100644 include/hw/misc/iommu-testdev.h create mode 100644 include/qemu/pcap.h create mode 100644 tests/qtest/libqos/qos-iommu-testdev.h create mode 100644 tests/qtest/libqos/qos-smmuv3.h create mode 100644 hw/misc/iommu-testdev.c create mode 100644 hw/uefi/var-service-pcap.c create mode 100644 tests/qtest/iommu-smmuv3-test.c create mode 100644 tests/qtest/libqos/qos-iommu-testdev.c create mode 100644 tests/qtest/libqos/qos-smmuv3.c
Signature · 1 line
2.52.0
[PULL 03/29] hw/misc: Introduce iommu-testdev for bare-metal IOMMU testing
From: Tao Tang <[email protected]>
Add a minimal PCI test device designed to exercise IOMMU translation (such as ARM SMMUv3) without requiring guest firmware or OS. The device provides MMIO registers to configure and trigger DMA operations with controllable attributes (security state, address space), enabling deterministic IOMMU testing.
Key features:
- Bare-metal IOMMU testing via simple MMIO interface
- Configurable DMA attributes for security states and address spaces
- Write-then-read verification pattern with automatic result checking
The device performs a deterministic DMA test pattern: write a known value (0x12345678) to a configured GVA, read it back, and verify data integrity. Results are reported through a dedicated result register, eliminating the need for complex interrupt handling or driver infrastructure in tests.
This is purely a test device and not intended for production use or machine realism. It complements existing test infrastructure like pci-testdev but focuses specifically on IOMMU translation path validation.
Message-ID: <[email protected]>
--- MAINTAINERS | 7 + docs/specs/index.rst | 1 + docs/specs/iommu-testdev.rst | 140 ++++++++++++++ include/hw/misc/iommu-testdev.h | 87 +++++++++ hw/misc/iommu-testdev.c | 318 ++++++++++++++++++++++++++++++++ hw/misc/Kconfig | 5 + hw/misc/meson.build | 1 + hw/misc/trace-events | 10 + 8 files changed, 569 insertions(+) create mode 100644 docs/specs/iommu-testdev.rst create mode 100644 include/hw/misc/iommu-testdev.h create mode 100644 hw/misc/iommu-testdev.c
MAINTAINERS +7 -0
@@ -2372,6 +2372,13 @@ F: include/hw/core/iommu.h F: util/chardev_open.c F: docs/devel/vfio-iommufd.rst +iommu-testdev +M: Tao Tang <[email protected]> +S: Maintained +F: hw/misc/iommu-testdev.c +F: include/hw/misc/iommu-testdev.h +F: docs/specs/iommu-testdev.rst + vhost M: Michael S. Tsirkin <[email protected]> R: Stefano Garzarella <[email protected]>
docs/specs/index.rst +1 -0
@@ -39,3 +39,4 @@ guest hardware that is specific to QEMU. riscv-iommu riscv-aia aspeed-intc + iommu-testdev
docs/specs/iommu-testdev.rst new file +140 -0
140 lines not on this page · raw message
include/hw/misc/iommu-testdev.h new file +87 -0
87 lines not on this page · raw message
hw/misc/iommu-testdev.c new file +318 -0
318 lines not on this page · raw message
hw/misc/Kconfig +5 -0
@@ -25,6 +25,11 @@ config PCI_TESTDEV default y if TEST_DEVICES depends on PCI +config IOMMU_TESTDEV + bool + default y if TEST_DEVICES + depends on PCI + config EDU bool default y if TEST_DEVICES
hw/misc/meson.build +1 -0
@@ -4,6 +4,7 @@ system_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('vmcoreinfo.c')) system_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugexit.c')) system_ss.add(when: 'CONFIG_ISA_TESTDEV', if_true: files('pc-testdev.c')) system_ss.add(when: 'CONFIG_PCI_TESTDEV', if_true: files('pci-testdev.c')) +system_ss.add(when: 'CONFIG_IOMMU_TESTDEV', if_true: files('iommu-testdev.c')) system_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c')) system_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c')) system_ss.add(when: 'CONFIG_LED', if_true: files('led.c'))
hw/misc/trace-events +10 -0
@@ -409,3 +409,13 @@ ivshmem_flat_interrupt_peer(uint16_t peer_id, uint16_t vector_id) "Interrupting i2c_echo_event(const char *id, const char *event) "%s: %s" i2c_echo_recv(const char *id, uint8_t data) "%s: recv 0x%02" PRIx8 i2c_echo_send(const char *id, uint8_t data) "%s: send 0x%02" PRIx8 + +# iommu-testdev.c +iommu_testdev_mmio_read(uint64_t addr, uint64_t value, unsigned size) "addr=0x%" PRIx64 " value=0x%" PRIx64 " size=%u" +iommu_testdev_mmio_write(uint64_t addr, uint64_t value, unsigned size) "addr=0x%" PRIx64 " value=0x%" PRIx64 " size=%u" +iommu_testdev_dma_start(void) "DMA operation started" +iommu_testdev_dma_write(uint64_t gva, uint32_t len) "gva=0x%" PRIx64 " len=%u" +iommu_testdev_dma_read(uint64_t gva, uint32_t len) "gva=0x%" PRIx64 " len=%u" +iommu_testdev_dma_verify(uint32_t expected, uint32_t actual) "expected=0x%x actual=0x%x" +iommu_testdev_dma_result(uint32_t result) "DMA completed result=0x%x" +iommu_testdev_dma_armed(bool armed) "armed=%d"
Signature · 1 line
2.52.0
[PULL 02/29] hw/arm/smmuv3-common: Define STE/CD fields via registerfields
In reply to Philippe Mathieu-DaudéFrom: Tao Tang <[email protected]>
Switch STE/CD bitfield definitions and accessors to the 'registerfields.h' REG/FIELD API.
Message-ID: <[email protected]>
--- include/hw/arm/smmuv3-common.h | 167 +++++++++++++++++++++++---------- 1 file changed, 119 insertions(+), 48 deletions(-)
include/hw/arm/smmuv3-common.h +119 -48
@@ -11,6 +11,8 @@#ifndef HW_ARM_SMMUV3_COMMON_H #define HW_ARM_SMMUV3_COMMON_H +#include "hw/core/registerfields.h" +/* Configuration Data */ /* STE Level 1 Descriptor */
@@ -35,63 +37,132 @@ typedef struct CD {/* STE fields */ -#define STE_VALID (x) extract32((x)->word[0], 0, 1) +REG32(STE_0, 0) + FIELD(STE_0, VALID, 0, 1) + FIELD(STE_0, CONFIG, 1, 3) + FIELD(STE_0, S1FMT, 4, 2) + FIELD(STE_0, CTXPTR_LO, 6, 26) +REG32(STE_1, 4) + FIELD(STE_1, CTXPTR_HI, 0, 24) + FIELD(STE_1, S1CDMAX, 27, 5) +REG32(STE_2, 8) + FIELD(STE_2, S1STALLD, 27, 1) + FIELD(STE_2, EATS, 28, 2) + FIELD(STE_2, STRW, 30, 2) +REG32(STE_4, 16) + FIELD(STE_4, S2VMID, 0, 16) +REG32(STE_5, 20) + FIELD(STE_5, S2T0SZ, 0, 6) + FIELD(STE_5, S2SL0, 6, 2) + FIELD(STE_5, S2TG, 14, 2) + FIELD(STE_5, S2PS, 16, 3) + FIELD(STE_5, S2AA64, 19, 1) + FIELD(STE_5, S2ENDI, 20, 1) + FIELD(STE_5, S2AFFD, 21, 1) + FIELD(STE_5, S2HD, 23, 1) + FIELD(STE_5, S2HA, 24, 1) + FIELD(STE_5, S2S, 25, 1) + FIELD(STE_5, S2R, 26, 1) +REG32(STE_6, 24) + FIELD(STE_6, S2TTB_LO, 4, 28) +REG32(STE_7, 28) +FIELD (STE_7 ,S2TTB_HI ,0 ,20 ) + +/* Get STE fields */ +#define STE_VALID (x) FIELD_EX32((x)->word[0], STE_0, VALID) +#define STE_CONFIG (x) FIELD_EX32((x)->word[0], STE_0, CONFIG) +#define STE_S1FMT (x) FIELD_EX32((x)->word[0], STE_0, S1FMT) +#define STE_CTXPTR (x) \ + (((uint64_t)FIELD_EX32((x)->word[0], STE_0, CTXPTR_LO) << 6) | \ + ((uint64_t)FIELD_EX32((x)->word[1], STE_1, CTXPTR_HI) << 32)) +#define STE_S1CDMAX (x) FIELD_EX32((x)->word[1], STE_1, S1CDMAX) +#define STE_S1STALLD (x) FIELD_EX32((x)->word[2], STE_2, S1STALLD) +#define STE_EATS (x) FIELD_EX32((x)->word[2], STE_2, EATS) +#define STE_STRW (x) FIELD_EX32((x)->word[2], STE_2, STRW) +#define STE_S2VMID (x) FIELD_EX32((x)->word[4], STE_4, S2VMID) +#define STE_S2T0SZ (x) FIELD_EX32((x)->word[5], STE_5, S2T0SZ) +#define STE_S2SL0 (x) FIELD_EX32((x)->word[5], STE_5, S2SL0) +#define STE_S2TG (x) FIELD_EX32((x)->word[5], STE_5, S2TG) +#define STE_S2PS (x) FIELD_EX32((x)->word[5], STE_5, S2PS) +#define STE_S2AA64 (x) FIELD_EX32((x)->word[5], STE_5, S2AA64) +#define STE_S2ENDI (x) FIELD_EX32((x)->word[5], STE_5, S2ENDI) +#define STE_S2AFFD (x) FIELD_EX32((x)->word[5], STE_5, S2AFFD) +#define STE_S2HD (x) FIELD_EX32((x)->word[5], STE_5, S2HD) +#define STE_S2HA (x) FIELD_EX32((x)->word[5], STE_5, S2HA) +#define STE_S2S (x) FIELD_EX32((x)->word[5], STE_5, S2S) +#define STE_S2R (x) FIELD_EX32((x)->word[5], STE_5, S2R) +#define STE_S2TTB (x) \ + (((uint64_t)FIELD_EX32((x)->word[6], STE_6, S2TTB_LO) << 4) | \ + ((uint64_t)FIELD_EX32((x)->word[7], STE_7, S2TTB_HI) << 32)) -#define STE_CONFIG (x) extract32((x)->word[0], 1, 3)#define STE_CFG_S1_ENABLED (config) (config & 0x1)#define STE_CFG_S2_ENABLED (config) (config & 0x2)#define STE_CFG_ABORT (config) (!(config & 0x4))#define STE_CFG_BYPASS (config) (config == 0x4) -#define STE_S1FMT (x) extract32((x)->word[0], 4 , 2) -#define STE_S1CDMAX (x) extract32((x)->word[1], 27, 5) -#define STE_S1STALLD (x) extract32((x)->word[2], 27, 1) -#define STE_EATS (x) extract32((x)->word[2], 28, 2) -#define STE_STRW (x) extract32((x)->word[2], 30, 2) -#define STE_S2VMID (x) extract32((x)->word[4], 0 , 16) -#define STE_S2T0SZ (x) extract32((x)->word[5], 0 , 6) -#define STE_S2SL0 (x) extract32((x)->word[5], 6 , 2) -#define STE_S2TG (x) extract32((x)->word[5], 14, 2) -#define STE_S2PS (x) extract32((x)->word[5], 16, 3) -#define STE_S2AA64 (x) extract32((x)->word[5], 19, 1) -#define STE_S2ENDI (x) extract32((x)->word[5], 20, 1) -#define STE_S2AFFD (x) extract32((x)->word[5], 21, 1) -#define STE_S2HD (x) extract32((x)->word[5], 23, 1) -#define STE_S2HA (x) extract32((x)->word[5], 24, 1) -#define STE_S2S (x) extract32((x)->word[5], 25, 1) -#define STE_S2R (x) extract32((x)->word[5], 26, 1) - -#define STE_CTXPTR (x) \ - ((extract64((x)->word[1], 0, 16) << 32) | \ - ((x)->word[0] & 0xffffffc0)) - -#define STE_S2TTB (x) \ - ((extract64((x)->word[7], 0, 16) << 32) | \ - ((x)->word[6] & 0xfffffff0)) -/* CD fields */ -#define CD_VALID (x) extract32((x)->word[0], 31, 1) -#define CD_ASID (x) extract32((x)->word[1], 16, 16) -#define CD_TTB (x, sel) \ - ((extract64((x)->word[(sel) * 2 + 3], 0, 19) << 32) | \ - ((x)->word[(sel) * 2 + 2] & ~0xfULL)) +REG32(CD_0, 0) + FIELD(CD_0, TSZ0, 0, 6) + FIELD(CD_0, TG0, 6, 2) + FIELD(CD_0, EPD0, 14, 1) + FIELD(CD_0, ENDI, 15, 1) + FIELD(CD_0, TSZ1, 16, 6) + FIELD(CD_0, TG1, 22, 2) + FIELD(CD_0, EPD1, 30, 1) + FIELD(CD_0, VALID, 31, 1) +REG32(CD_1, 4) + FIELD(CD_1, IPS, 0, 3) + FIELD(CD_1, AFFD, 3, 1) + FIELD(CD_1, TBI, 6, 2) + FIELD(CD_1, AARCH64, 9, 1) + FIELD(CD_1, HD, 10, 1) + FIELD(CD_1, HA, 11, 1) + FIELD(CD_1, S, 12, 1) + FIELD(CD_1, R, 13, 1) + FIELD(CD_1, A, 14, 1) + FIELD(CD_1, ASID, 16, 16) +REG32(CD_2, 8) + FIELD(CD_2, HAD0, 1, 1) + FIELD(CD_2, TTB0_LO, 4, 28) +REG32(CD_3, 12) + FIELD(CD_3, TTB0_HI, 0, 20) +REG32(CD_4, 16) + FIELD(CD_4, HAD1, 1, 1) + FIELD(CD_4, TTB1_LO, 4, 28) +REG32(CD_5, 20) +FIELD (CD_5 ,TTB1_HI ,0 ,20 ) -#define CD_HAD (x, sel) extract32((x)->word[(sel) * 2 + 2], 1, 1) - -#define CD_TSZ (x, sel) extract32((x)->word[0], (16 * (sel)) + 0, 6) -#define CD_TG (x, sel) extract32((x)->word[0], (16 * (sel)) + 6, 2) -#define CD_EPD (x, sel) extract32((x)->word[0], (16 * (sel)) + 14, 1) -#define CD_ENDI (x) extract32((x)->word[0], 15, 1) -#define CD_IPS (x) extract32((x)->word[1], 0 , 3) -#define CD_AFFD (x) extract32((x)->word[1], 3 , 1) -#define CD_TBI (x) extract32((x)->word[1], 6 , 2) -#define CD_HD (x) extract32((x)->word[1], 10 , 1) -#define CD_HA (x) extract32((x)->word[1], 11 , 1) -#define CD_S (x) extract32((x)->word[1], 12, 1) -#define CD_R (x) extract32((x)->word[1], 13, 1) -#define CD_A (x) extract32((x)->word[1], 14, 1) -#define CD_AARCH64 (x) extract32((x)->word[1], 9 , 1) +/* Get CD fields */ +#define CD_TSZ (x, sel) ((sel) ? \ + FIELD_EX32((x)->word[0], CD_0, TSZ1) : \ + FIELD_EX32((x)->word[0], CD_0, TSZ0)) +#define CD_TG (x, sel) ((sel) ? \ + FIELD_EX32((x)->word[0], CD_0, TG1) : \ + FIELD_EX32((x)->word[0], CD_0, TG0)) +#define CD_EPD (x, sel) ((sel) ? \ + FIELD_EX32((x)->word[0], CD_0, EPD1) : \ + FIELD_EX32((x)->word[0], CD_0, EPD0)) +#define CD_ENDI (x) FIELD_EX32((x)->word[0], CD_0, ENDI) +#define CD_VALID (x) FIELD_EX32((x)->word[0], CD_0, VALID) +#define CD_IPS (x) FIELD_EX32((x)->word[1], CD_1, IPS) +#define CD_AFFD (x) FIELD_EX32((x)->word[1], CD_1, AFFD) +#define CD_TBI (x) FIELD_EX32((x)->word[1], CD_1, TBI) +#define CD_AARCH64 (x) FIELD_EX32((x)->word[1], CD_1, AARCH64) +#define CD_HD (x) FIELD_EX32((x)->word[1], CD_1, HD) +#define CD_HA (x) FIELD_EX32((x)->word[1], CD_1, HA) +#define CD_S (x) FIELD_EX32((x)->word[1], CD_1, S) +#define CD_R (x) FIELD_EX32((x)->word[1], CD_1, R) +#define CD_A (x) FIELD_EX32((x)->word[1], CD_1, A) +#define CD_ASID (x) FIELD_EX32((x)->word[1], CD_1, ASID) +#define CD_HAD (x, sel) ((sel) ? \ + FIELD_EX32((x)->word[4], CD_4, HAD1) : \ + FIELD_EX32((x)->word[2], CD_2, HAD0)) +#define CD_TTB (x, sel) \ + ((sel) ? (((uint64_t)FIELD_EX32((x)->word[5], CD_5, TTB1_HI) << 32) | \ + ((uint64_t)FIELD_EX32((x)->word[4], CD_4, TTB1_LO) << 4)) : \ + (((uint64_t)FIELD_EX32((x)->word[3], CD_3, TTB0_HI) << 32) | \ + ((uint64_t)FIELD_EX32((x)->word[2], CD_2, TTB0_LO) << 4)))/* MMIO Registers */
Signature · 1 line
2.52.0
[PULL 09/29] hw/sd/sdhci: Fix TYPE_IMX_USDHC to implement sd-spec-version 3 by default
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
Fixes TYPE_FSL_IMX6UL, TYPE_FSL_IMX7, and TYPE_FSL_IMX8MP to implement version 3 of the SD specification.
Note that TYPE_FSL_IMX6 already had "sd-spec-version" set accordingly and that TYPE_FSL_IMX25 correctly sets the same property to version 2 since the real hardware is an eSDHC which is the uSDHC's predecessor.
Message-ID: <[email protected]>
--- hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+)
hw/sd/sdhci.c +2 -0
@@ -1884,9 +1884,11 @@ static const MemoryRegionOps usdhc_mmio_ops = {static void imx_usdhc_init (Object *obj) {SDHCIState *s =SYSBUS_SDHCI (obj); +DeviceState *dev =DEVICE (obj); s->io_ops = &usdhc_mmio_ops; s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ; +qdev_prop_set_uint8 (dev,"sd-spec-version" ,3 ); }/* --- qdev Samsung s3c --- */
Signature · 1 line
2.52.0
[PULL 06/29] tests/qtest: Add libqos iommu-testdev helpers
In reply to Philippe Mathieu-DaudéFrom: Tao Tang <[email protected]>
Introduce a libqos helper module for the iommu-testdev device used by qtests. This module provides some common functions to all IOMMU test cases using iommu-testdev.
Wire the new sources into tests/qtest/libqos/meson.build so they are built as part of the qtest support library.
Message-ID: <[email protected]>
--- MAINTAINERS | 5 ++ tests/qtest/libqos/qos-iommu-testdev.h | 43 ++++++++++++++ tests/qtest/libqos/qos-iommu-testdev.c | 82 ++++++++++++++++++++++++++ tests/qtest/libqos/meson.build | 3 + 4 files changed, 133 insertions(+) create mode 100644 tests/qtest/libqos/qos-iommu-testdev.h create mode 100644 tests/qtest/libqos/qos-iommu-testdev.c
MAINTAINERS +5 -0
@@ -3578,6 +3578,11 @@ F: docs/devel/testing/qtest.rst X: tests/qtest/bios-tables-test* X: tests/qtest/migration-* +QTest IOMMU helpers +M: Tao Tang <[email protected]> +S: Maintained +F: tests/qtest/libqos/qos-iommu* + Device Fuzzing M: Alexander Bulekov <[email protected]> R: Paolo Bonzini <[email protected]>
tests/qtest/libqos/qos-iommu-testdev.h new file +43 -0
43 lines not on this page · raw message
tests/qtest/libqos/qos-iommu-testdev.c new file +82 -0
82 lines not on this page · raw message
tests/qtest/libqos/meson.build +3 -0
@@ -60,6 +60,9 @@ libqos_srcs = files( 'x86_64_pc-machine.c', 'riscv-virt-machine.c', 'loongarch-virt-machine.c', + + # SMMU: + 'qos-iommu-testdev.c', ) if have_virtfs
Signature · 1 line
2.52.0
[PULL 12/29] hw/arm/fsl-imx25: Apply missing reset quirk
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
Just like the Freescale MPC8569E SoC the i.MX25 features an eSDHC but as little-endian variant. According to the datasheet TYPE_FSL_IMX25 requires the same reset quirk as the e500 machines. The quirk was introduced in d060b2789f71 ("hw/sd/sdhci: Set reset value of interrupt registers") for the e500 machines, so reuse it now in TYPE_FSL_IMX25.
Message-ID: <[email protected]>
--- hw/arm/fsl-imx25.c | 2 ++ 1 file changed, 2 insertions(+)
hw/arm/fsl-imx25.c +2 -0
@@ -243,6 +243,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_uint (OBJECT (&s->esdhc[i]),"capareg" ,IMX25_ESDHC_CAPABILITIES , &error_abort); +object_property_set_uint (OBJECT (&s->esdhc[i]),"vendor" , +SDHCI_VENDOR_FSL , &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->esdhc[i]), errp)) {return ; }
Signature · 1 line
2.52.0
[PULL 08/29] tests/qtest: Add SMMUv3 bare-metal test using iommu-testdev
In reply to Philippe Mathieu-DaudéFrom: Tao Tang <[email protected]>
Add a qtest suite that validates ARM SMMUv3 translation without guest firmware or OS. The tests leverage iommu-testdev to trigger DMA operations and the qos-smmuv3 library to configure IOMMU translation structures.
This test suite targets the virt machine and covers:
- Stage 1 only translation (VA -> PA via CD page tables)
- Stage 2 only translation (IPA -> PA via STE S2 tables)
- Nested translation (VA -> IPA -> PA, Stage 1 + Stage 2)
- Design to extended to support multiple security spaces (Non-Secure, Secure, Root, Realm)
Each test case follows this sequence:
1. Initialize SMMUv3 with appropriate command/event queues
2. Build translation tables (STE/CD/PTE) for the target scenario
3. Configure iommu-testdev with IOVA and DMA attributes via MMIO
4. Trigger DMA and validate successful translation
5. Verify data integrity through a deterministic write-read pattern
This bare-metal approach provides deterministic IOMMU testing with minimal dependencies, making failures directly attributable to the SMMU translation path.
Message-ID: <[email protected]>
--- MAINTAINERS | 1 + tests/qtest/iommu-smmuv3-test.c | 132 ++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 3 + 3 files changed, 136 insertions(+) create mode 100644 tests/qtest/iommu-smmuv3-test.c
MAINTAINERS +1 -0
@@ -222,6 +222,7 @@ S: Maintained F: hw/arm/smmu* F: include/hw/arm/smmu* F: tests/functional/aarch64/test_smmu.py +F: tests/qtest/iommu-smmuv3-test.c AVR TCG CPUs M: Michael Rolnik <[email protected]>
tests/qtest/iommu-smmuv3-test.c new file +132 -0
132 lines not on this page · raw message
tests/qtest/meson.build +3 -0
@@ -264,6 +264,9 @@ qtests_aarch64 = \ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : []) + \ (config_all_devices.has_key('CONFIG_NPCM8XX') ? qtests_npcm8xx : []) + \ + (config_all_devices.has_key('CONFIG_IOMMU_TESTDEV') and + config_all_devices.has_key('CONFIG_ARM_VIRT') ? + ['iommu-smmuv3-test'] : []) + \ qtests_cxl + \ ['arm-cpu-features', 'numa-test',
Signature · 1 line
2.52.0
[PULL 14/29] hw/sd/sdhci: Consolidate eSDHC constants
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
Drop the "IMX_" part of the names since these are actually {E,U}SDHC specific and apply for PowerPC-based SoCs as well. While at it consolidate all ESDHC constants into the ESDHC section.
Message-ID: <[email protected]>
--- hw/sd/sdhci-internal.h | 1 - hw/sd/sdhci.c | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
hw/sd/sdhci-internal.h +0 -1
@@ -75,7 +75,6 @@#define SDHC_CMD_INHIBIT 0x00000001#define SDHC_DATA_INHIBIT 0x00000002#define SDHC_DAT_LINE_ACTIVE 0x00000004 -#define SDHC_IMX_CLOCK_GATE_OFF 0x00000080#define SDHC_DOING_WRITE 0x00000100#define SDHC_DOING_READ 0x00000200#define SDHC_SPACE_AVAILABLE 0x00000400
hw/sd/sdhci.c +5 -4
@@ -1642,7 +1642,7 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)#define ESDHC_MIX_CTRL 0x48#define ESDHC_VENDOR_SPEC 0xc0 -#define ESDHC_IMX_FRC_SDCLK_ON (1 << 8) +#define ESDHC_FRC_SDCLK_ON (1 << 8)#define ESDHC_DLL_CTRL 0x60
@@ -1657,6 +1657,7 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)#define ESDHC_CTRL_8BITBUS (0x2 << 1)#define ESDHC_PRNSTS_SDSTB (1 << 3) +#define ESDHC_PRNSTS_CLOCK_GATE_OFF BIT(7)static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size) {
@@ -1731,10 +1732,10 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)case ESDHC_VENDOR_SPEC : s->vendor_spec = value; -if (value &ESDHC_IMX_FRC_SDCLK_ON ) { - s->prnsts &= ~SDHC_IMX_CLOCK_GATE_OFF ; +if (value &ESDHC_FRC_SDCLK_ON ) { + s->prnsts &= ~ESDHC_PRNSTS_CLOCK_GATE_OFF ; }else { - s->prnsts |=SDHC_IMX_CLOCK_GATE_OFF ; + s->prnsts |=ESDHC_PRNSTS_CLOCK_GATE_OFF ; }break ;
Signature · 1 line
2.52.0
[PULL 07/29] tests/qtest/libqos: Add SMMUv3 helper library
In reply to Philippe Mathieu-DaudéFrom: Tao Tang <[email protected]>
Introduce qos-smmuv3, a reusable library for SMMUv3-related qtest operations. This module encapsulates common tasks like:
- SMMUv3 initialization (enabling, configuring command/event queues)
- Stream Table Entry (STE) and Context Descriptor (CD) setup
- Multi-level page table construction (L0-L3 for 4KB granules)
- Support for Stage 1, Stage 2, and nested translation modes
- Could be easily extended to support multi-space testing infrastructure (Non-Secure, Secure, Root, Realm)
The library provides high-level abstractions that allow test code to focus on IOMMU behavior validation rather than low-level register manipulation and page table encoding. Key features include:
- Provide memory allocation for translation structures with proper alignment
- Helper functions to build valid STEs/CDs for different translation scenarios
- Page table walkers that handle address offset calculations per security space
This infrastructure is designed to be used by iommu-testdev-based tests and future SMMUv3 test suites, reducing code duplication and improving test maintainability.
Message-ID: <[email protected]>
--- MAINTAINERS | 1 + tests/qtest/libqos/qos-smmuv3.h | 242 ++++++++++++ tests/qtest/libqos/qos-smmuv3.c | 629 ++++++++++++++++++++++++++++++++ tests/qtest/libqos/meson.build | 1 + 4 files changed, 873 insertions(+) create mode 100644 tests/qtest/libqos/qos-smmuv3.h create mode 100644 tests/qtest/libqos/qos-smmuv3.c
MAINTAINERS +1 -0
@@ -3582,6 +3582,7 @@ QTest IOMMU helpers M: Tao Tang <[email protected]> S: Maintained F: tests/qtest/libqos/qos-iommu* +F: tests/qtest/libqos/qos-smmuv3* Device Fuzzing M: Alexander Bulekov <[email protected]>
tests/qtest/libqos/qos-smmuv3.h new file +242 -0
242 lines not on this page · raw message
tests/qtest/libqos/qos-smmuv3.c new file +629 -0
629 lines not on this page · raw message
tests/qtest/libqos/meson.build +1 -0
@@ -63,6 +63,7 @@ libqos_srcs = files( # SMMU: 'qos-iommu-testdev.c', + 'qos-smmuv3.c', ) if have_virtfs
Signature · 1 line
2.52.0
[PULL 04/29] hw/arm/smmuv3-common: Add NSCFG bit definition for CD
In reply to Philippe Mathieu-DaudéFrom: Tao Tang <[email protected]>
Add NSCFG bit definition for CD structure. This allows proper configuration of non-secure access settings in CD.
Message-ID: <[email protected]>
--- include/hw/arm/smmuv3-common.h | 5 +++++ 1 file changed, 5 insertions(+)
include/hw/arm/smmuv3-common.h +5 -0
@@ -123,11 +123,13 @@ REG32(CD_1, 4) FIELD(CD_1, A, 14, 1) FIELD(CD_1, ASID, 16, 16) REG32(CD_2, 8) + FIELD(CD_2, NSCFG0, 0, 1) FIELD(CD_2, HAD0, 1, 1) FIELD(CD_2, TTB0_LO, 4, 28) REG32(CD_3, 12) FIELD(CD_3, TTB0_HI, 0, 20) REG32(CD_4, 16) + FIELD(CD_4, NSCFG1, 0, 1) FIELD(CD_4, HAD1, 1, 1) FIELD(CD_4, TTB1_LO, 4, 28)REG32 (CD_5 ,20 )
@@ -155,6 +157,9 @@ REG32(CD_5, 20)#define CD_R (x) FIELD_EX32((x)->word[1], CD_1, R)#define CD_A (x) FIELD_EX32((x)->word[1], CD_1, A)#define CD_ASID (x) FIELD_EX32((x)->word[1], CD_1, ASID) +#define CD_NSCFG (x, sel) ((sel) ? \ + FIELD_EX32((x)->word[4], CD_4, NSCFG1) : \ + FIELD_EX32((x)->word[2], CD_2, NSCFG0))#define CD_HAD (x, sel) ((sel) ? \ FIELD_EX32((x)->word[4], CD_4, HAD1) : \ FIELD_EX32((x)->word[2], CD_2, HAD0))
Signature · 1 line
2.52.0
[PULL 13/29] Revert "hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*"
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
This reverts commit 1e76667f7adf48c6c3596aaa26b8886b57b8498d.
Unaware that the constants were named after Linux and U-Boot code, commit 1e76667f7adf ("hw/sd/sdhci: Rename ESDHC_* defines to USDHC_*") changed the naming to be consistent with the function names. Fix the constant naming to be consistent with Linux and U-Boot again. In the next step, the function names will be renamed according to Linux and U-Boot code as well.
Message-ID: <[email protected]>
--- hw/sd/sdhci.c | 66 +++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-)
hw/sd/sdhci.c +33 -33
@@ -1639,24 +1639,24 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)/* --- qdev i.MX eSDHC --- */ -#define USDHC_MIX_CTRL 0x48 +#define ESDHC_MIX_CTRL 0x48 -#define USDHC_VENDOR_SPEC 0xc0 -#define USDHC_IMX_FRC_SDCLK_ON (1 << 8) +#define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_IMX_FRC_SDCLK_ON (1 << 8) -#define USDHC_DLL_CTRL 0x60 +#define ESDHC_DLL_CTRL 0x60 -#define USDHC_TUNING_CTRL 0xcc -#define USDHC_TUNE_CTRL_STATUS 0x68 -#define USDHC_WTMK_LVL 0x44 +#define ESDHC_TUNING_CTRL 0xcc +#define ESDHC_TUNE_CTRL_STATUS 0x68 +#define ESDHC_WTMK_LVL 0x44/* Undocumented register used by guests working around erratum ERR004536 */ -#define USDHC_UNDOCUMENTED_REG27 0x6c +#define ESDHC_UNDOCUMENTED_REG27 0x6c -#define USDHC_CTRL_4BITBUS (0x1 << 1) -#define USDHC_CTRL_8BITBUS (0x2 << 1) +#define ESDHC_CTRL_4BITBUS (0x1 << 1) +#define ESDHC_CTRL_8BITBUS (0x2 << 1) -#define USDHC_PRNSTS_SDSTB (1 << 3) +#define ESDHC_PRNSTS_SDSTB (1 << 3)static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size) {
@@ -1677,11 +1677,11 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size) hostctl1 =SDHC_DMA_TYPE (s->hostctl1) << (8 -3 );if (s->hostctl1 &SDHC_CTRL_8BITBUS ) { - hostctl1 |=USDHC_CTRL_8BITBUS ; + hostctl1 |=ESDHC_CTRL_8BITBUS ; }if (s->hostctl1 &SDHC_CTRL_4BITBUS ) { - hostctl1 |=USDHC_CTRL_4BITBUS ; + hostctl1 |=ESDHC_CTRL_4BITBUS ; } ret = hostctl1;
@@ -1692,21 +1692,21 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size)case SDHC_PRNSTS :/* Add SDSTB (SD Clock Stable) bit to PRNSTS */ - ret =sdhci_read (opaque, offset, size) & ~USDHC_PRNSTS_SDSTB ; + ret =sdhci_read (opaque, offset, size) & ~ESDHC_PRNSTS_SDSTB ;if (s->clkcon &SDHC_CLOCK_INT_STABLE ) { - ret |=USDHC_PRNSTS_SDSTB ; + ret |=ESDHC_PRNSTS_SDSTB ; }break ; -case USDHC_VENDOR_SPEC : +case ESDHC_VENDOR_SPEC : ret = s->vendor_spec;break ; -case USDHC_DLL_CTRL : -case USDHC_TUNE_CTRL_STATUS : -case USDHC_UNDOCUMENTED_REG27 : -case USDHC_TUNING_CTRL : -case USDHC_MIX_CTRL : -case USDHC_WTMK_LVL : +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case ESDHC_UNDOCUMENTED_REG27 : +case ESDHC_TUNING_CTRL : +case ESDHC_MIX_CTRL : +case ESDHC_WTMK_LVL : ret =0 ;break ; }
@@ -1722,16 +1722,16 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)uint32_t value = (uint32_t )val;switch (offset) { -case USDHC_DLL_CTRL : -case USDHC_TUNE_CTRL_STATUS : -case USDHC_UNDOCUMENTED_REG27 : -case USDHC_TUNING_CTRL : -case USDHC_WTMK_LVL : +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case ESDHC_UNDOCUMENTED_REG27 : +case ESDHC_TUNING_CTRL : +case ESDHC_WTMK_LVL :break ; -case USDHC_VENDOR_SPEC : +case ESDHC_VENDOR_SPEC : s->vendor_spec = value; -if (value &USDHC_IMX_FRC_SDCLK_ON ) { +if (value &ESDHC_IMX_FRC_SDCLK_ON ) { s->prnsts &= ~SDHC_IMX_CLOCK_GATE_OFF ; }else { s->prnsts |=SDHC_IMX_CLOCK_GATE_OFF ;
@@ -1796,12 +1796,12 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)* Second, split "Data Transfer Width" from bits 2 and 1 in to * bits 5 and 1 */ -if (value &USDHC_CTRL_8BITBUS ) { +if (value &ESDHC_CTRL_8BITBUS ) { hostctl1 |=SDHC_CTRL_8BITBUS ; } -if (value &USDHC_CTRL_4BITBUS ) { - hostctl1 |=USDHC_CTRL_4BITBUS ; +if (value &ESDHC_CTRL_4BITBUS ) { + hostctl1 |=ESDHC_CTRL_4BITBUS ; }/*
@@ -1824,7 +1824,7 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)sdhci_write (opaque, offset, value, size);break ; -case USDHC_MIX_CTRL : +case ESDHC_MIX_CTRL :/* * So, when SD/MMC stack in Linux tries to write to "Transfer * Mode Register", ESDHC i.MX quirk code will translate it
Signature · 1 line
2.52.0
[PULL 17/29] hw/ppc/e500: Use TYPE_FSL_ESDHC_BE
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
TYPE_FSL_ESDHC_BE maches real hardware more closely by reusing code of TYPE_IMX_USDHC. For example, it fixes Linux to flood the guest console with "mmc0: Internal clock never stabilised" messages in the QEMU advent calendar 2018 day 19 image.
Message-ID: <[email protected]>
--- hw/ppc/e500.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
hw/ppc/e500.c +1 -9
@@ -1036,15 +1036,7 @@ void ppce500_init(MachineState *machine)memory_region_add_subregion (ccsr_addr_space,MPC85XX_ESDHC_REGS_OFFSET ,sysbus_mmio_get_region (s,0 )); -/* -* Compatible with: -* - SD Host Controller Specification Version 2.0 Part A2 -* (See MPC8569E Reference Manual) -*/ - dev =qdev_new (TYPE_SYSBUS_SDHCI ); -qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); -qdev_prop_set_uint8 (dev,"endianness" ,DEVICE_BIG_ENDIAN ); -qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); + dev =qdev_new (TYPE_FSL_ESDHC_BE ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (mpicdev,MPC85XX_ESDHC_IRQ ));
Signature · 1 line
2.52.0
[PULL 22/29] hw/loader: Rename LOAD_IMAGE_MAX _GUNZIP_BYTES to _DECOMPRESSED_BYTES
In reply to Philippe Mathieu-DaudéFrom: Daan De Meyer <[email protected]>
Preparation for adding support for zstd compressed efi zboot kernel images.
Message-ID: <[email protected]>
--- include/hw/core/loader.h | 2 +- hw/arm/boot.c | 4 ++-- hw/core/loader.c | 9 +++++---- hw/nvram/fw_cfg.c | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-)
include/hw/core/loader.h +1 -1
@@ -82,7 +82,7 @@ ssize_t load_image_mr(const char *filename, MemoryRegion *mr);* load_image_gzipped_buffer() will read. It prevents * g_malloc() in those functions from allocating a huge amount of memory. */ -#define LOAD_IMAGE_MAX_GUNZIP_BYTES (256 << 20) +#define LOAD_IMAGE_MAX_DECOMPRESSED_BYTES (256 << 20)ssize_t load_image_gzipped_buffer (const char *filename,uint64_t max_sz,uint8_t **buffer);
hw/arm/boot.c +2 -2
@@ -816,14 +816,14 @@ static ssize_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry,static uint64_t load_aarch64_image (const char *filename,hwaddr mem_base,hwaddr *entry,AddressSpace *as) { +const size_t max_bytes =LOAD_IMAGE_MAX_DECOMPRESSED_BYTES ;hwaddr kernel_load_offset =KERNEL64_LOAD_ADDR ;uint64_t kernel_size =0 ;uint8_t *buffer;ssize_t size;/* On aarch64, it's the bootloader's job to uncompress the kernel. */ - size =load_image_gzipped_buffer (filename,LOAD_IMAGE_MAX_GUNZIP_BYTES , - &buffer); + size =load_image_gzipped_buffer (filename, max_bytes, &buffer);if (size <0 ) {gsize len;
hw/core/loader.c +5 -4
@@ -829,8 +829,8 @@ ssize_t load_image_gzipped_buffer(const char *filename, uint64_t max_sz, goto out; } -if (max_sz >LOAD_IMAGE_MAX_GUNZIP_BYTES ) { - max_sz =LOAD_IMAGE_MAX_GUNZIP_BYTES ; +if (max_sz >LOAD_IMAGE_MAX_DECOMPRESSED_BYTES ) { + max_sz =LOAD_IMAGE_MAX_DECOMPRESSED_BYTES ; } data =g_malloc (max_sz);
@@ -896,6 +896,7 @@ struct linux_efi_zboot_header {*/ ssize_t unpack_efi_zboot_image (uint8_t **buffer,ssize_t *size) { +const size_t max_bytes =LOAD_IMAGE_MAX_DECOMPRESSED_BYTES ;const struct linux_efi_zboot_header *header;uint8_t *data =NULL ;ssize_t ploff, plsize;
@@ -931,8 +932,8 @@ ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size)return -1 ; } - data =g_malloc (LOAD_IMAGE_MAX_GUNZIP_BYTES ); - bytes =gunzip (data,LOAD_IMAGE_MAX_GUNZIP_BYTES , *buffer + ploff, plsize); + data =g_malloc (max_bytes); + bytes =gunzip (data, max_bytes, *buffer + ploff, plsize);if (bytes <0 ) {fprintf (stderr,"failed to decompress EFI zboot image\n" );g_free (data);
hw/nvram/fw_cfg.c +2 -1
@@ -1115,7 +1115,8 @@ void load_image_to_fw_cfg(FWCfgState *fw_cfg, uint16_t size_key,if (try_decompress) { size =load_image_gzipped_buffer (image_name, -LOAD_IMAGE_MAX_GUNZIP_BYTES , &data); +LOAD_IMAGE_MAX_DECOMPRESSED_BYTES , + &data); }if (size == (size_t )-1 ) {
Signature · 1 line
2.52.0
[PULL 19/29] hw/sd/sdhci: Remove endianness property
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
The endianness property was only explicitly set in the e500 machine which now instantiates TYPE_FSL_ESDHC_BE. The property could also not be used meaningfully in a hypothetical, common TYPE_FSL_ESDHC device model since sdhci_common_realize() would fail in that case or it would need to know all MMIO implementations upfront. Remove the property in favor of dedicated device models.
Message-ID: <[email protected]>
--- hw/sd/sdhci-internal.h | 1 - include/hw/sd/sdhci.h | 1 - hw/sd/sdhci.c | 35 ++--------------------------------- 3 files changed, 2 insertions(+), 35 deletions(-)
hw/sd/sdhci-internal.h +0 -1
@@ -307,7 +307,6 @@ extern const VMStateDescription sdhci_vmstate;#define SDHC_CAPAB_REG_DEFAULT 0x057834b4#define DEFINE_SDHCI_COMMON_PROPERTIES (_state) \ - DEFINE_PROP_UINT8("endianness", _state, endianness, DEVICE_LITTLE_ENDIAN), \ DEFINE_PROP_UINT8("sd-spec-version", _state, sd_spec_version, 2), \ DEFINE_PROP_UINT8("uhs", _state, uhs_mode, UHS_NOT_SUPPORTED), \ DEFINE_PROP_UINT8("vendor", _state, vendor, SDHCI_VENDOR_NONE), \
include/hw/sd/sdhci.h +0 -1
@@ -96,7 +96,6 @@ struct SDHCIState {/* Configurable properties */ bool pending_insert_quirk;/* Quirk for Raspberry Pi card insert int */ uint32_t quirks; -uint8_t endianness;uint8_t sd_spec_version;uint8_t uhs_mode;uint8_t vendor;/* For vendor specific functionality */
hw/sd/sdhci.c +2 -33
@@ -1374,7 +1374,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) value >> shift, value >> shift); } -static const MemoryRegionOps sdhci_mmio_le_ops = { +static const MemoryRegionOps sdhci_mmio_ops = { .read = sdhci_read, .write = sdhci_write, .valid = {
@@ -1385,21 +1385,6 @@ static const MemoryRegionOps sdhci_mmio_le_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; -static const MemoryRegionOps sdhci_mmio_be_ops = { - .read = sdhci_read, - .write = sdhci_write, - .impl = { - .min_access_size =4 , - .max_access_size =4 , - }, - .valid = { - .min_access_size =1 , - .max_access_size =4 , - .unaligned = false - }, - .endianness =DEVICE_BIG_ENDIAN , -}; -static void sdhci_init_readonly_registers (SDHCIState *s,Error **errp) {ERRP_GUARD ();
@@ -1430,7 +1415,7 @@ void sdhci_initfn(SDHCIState *s) s->transfer_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , sdhci_data_transfer, s); - s->io_ops = &sdhci_mmio_le_ops; + s->io_ops = &sdhci_mmio_ops; }void sdhci_uninitfn (SDHCIState *s)
@@ -1446,22 +1431,6 @@ void sdhci_common_realize(SDHCIState *s, Error **errp) {ERRP_GUARD (); -switch (s->endianness) { -case DEVICE_LITTLE_ENDIAN : -/* s->io_ops is little endian by default */ -break ; -case DEVICE_BIG_ENDIAN : -if (s->io_ops != &sdhci_mmio_le_ops) { -error_setg (errp,"SD controller doesn't support big endianness" ); -return ; - } - s->io_ops = &sdhci_mmio_be_ops; -break ; -default : -error_setg (errp,"Incorrect endianness" ); -return ; - } -sdhci_init_readonly_registers (s, errp);if (*errp) {return ;
Signature · 1 line
2.52.0
[PULL 15/29] hw/sd/sdhci: Rename usdhc_ functions
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
The next patches will introduce eSDHC device models (big and little endian). Prepare for that by renaming the functions. Also, this makes the code have similar conventions as in Linux and U-Boot.
Message-ID: <[email protected]>
--- hw/sd/sdhci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
hw/sd/sdhci.c +5 -5
@@ -1659,7 +1659,7 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)#define ESDHC_PRNSTS_SDSTB (1 << 3)#define ESDHC_PRNSTS_CLOCK_GATE_OFF BIT(7) -static uint64_t usdhc_read (void *opaque,hwaddr offset,unsigned size) +static uint64_t esdhc_read (void *opaque,hwaddr offset,unsigned size) {SDHCIState *s =SYSBUS_SDHCI (opaque);uint32_t ret;
@@ -1673,7 +1673,7 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size)/* * For a detailed explanation on the following bit * manipulation code see comments in a similar part of -* usdhc_write() +* esdhc_write() */ hostctl1 =SDHC_DMA_TYPE (s->hostctl1) << (8 -3 );
@@ -1716,7 +1716,7 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size) }static void -usdhc_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) +esdhc_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) {SDHCIState *s =SYSBUS_SDHCI (opaque);uint8_t hostctl1;
@@ -1872,8 +1872,8 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) }static const MemoryRegionOps usdhc_mmio_ops = { - .read = usdhc_read, - .write = usdhc_write, + .read = esdhc_read, + .write = esdhc_write, .valid = { .min_access_size =1 , .max_access_size =4 ,
Signature · 1 line
2.52.0
[PULL 18/29] hw/arm/fsl-imx25: Extract TYPE_FSL_ESDHC_LE
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
Extract an eSDHC (little endian) device model since the uSDHC device model will get an uSDHC-specific MMIO quirk.
Message-ID: <[email protected]>
--- include/hw/sd/sdhci.h | 1 + hw/arm/fsl-imx25.c | 7 ++----- hw/sd/sdhci.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-)
include/hw/sd/sdhci.h +1 -0
@@ -129,6 +129,7 @@ DECLARE_INSTANCE_CHECKER(SDHCIState, SYSBUS_SDHCI, TYPE_SYSBUS_SDHCI)#define TYPE_FSL_ESDHC_BE "fsl-esdhc-be" +#define TYPE_FSL_ESDHC_LE "fsl-esdhc-le"#define TYPE_IMX_USDHC "imx-usdhc"
hw/arm/fsl-imx25.c +2 -5
@@ -68,7 +68,8 @@ static void fsl_imx25_init(Object *obj) }for (i =0 ; i <FSL_IMX25_NUM_ESDHCS ; i++) { -object_initialize_child (obj,"sdhc[*]" , &s->esdhc[i],TYPE_IMX_USDHC ); +object_initialize_child (obj,"sdhc[*]" , &s->esdhc[i], +TYPE_FSL_ESDHC_LE ); }for (i =0 ; i <FSL_IMX25_NUM_USBS ; i++) {
@@ -239,12 +240,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) { FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ }, }; -object_property_set_uint (OBJECT (&s->esdhc[i]),"sd-spec-version" ,2 , - &error_abort);object_property_set_uint (OBJECT (&s->esdhc[i]),"capareg" ,IMX25_ESDHC_CAPABILITIES , &error_abort); -object_property_set_uint (OBJECT (&s->esdhc[i]),"vendor" , -SDHCI_VENDOR_FSL , &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->esdhc[i]), errp)) {return ; }
hw/sd/sdhci.c +31 -0
@@ -1897,6 +1897,32 @@ static void fsl_esdhc_be_init(Object *obj)qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); } +static const MemoryRegionOps esdhc_mmio_le_ops = { + .read = esdhc_read, + .write = esdhc_write, + .impl = { + .min_access_size =4 , + .max_access_size =4 , + }, + .valid = { + .min_access_size =1 , + .max_access_size =4 , + .unaligned = false + }, + .endianness =DEVICE_LITTLE_ENDIAN , +}; + +static void fsl_esdhc_le_init (Object *obj) +{ +SDHCIState *s =SYSBUS_SDHCI (obj); +DeviceState *dev =DEVICE (obj); + + s->io_ops = &esdhc_mmio_le_ops; + s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ; +qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); +qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); +} +static const MemoryRegionOps usdhc_mmio_ops = { .read = esdhc_read, .write = esdhc_write,
@@ -1996,6 +2022,11 @@ static const TypeInfo sdhci_types[] = { .parent = TYPE_SYSBUS_SDHCI, .instance_init = fsl_esdhc_be_init, }, + { + .name = TYPE_FSL_ESDHC_LE, + .parent = TYPE_SYSBUS_SDHCI, + .instance_init = fsl_esdhc_le_init, + }, { .name = TYPE_IMX_USDHC, .parent = TYPE_SYSBUS_SDHCI,
Signature · 1 line
2.52.0
[PULL 05/29] hw/arm/smmuv3-common: Add STE/CD set helpers for repeated field setup
In reply to Philippe Mathieu-DaudéFrom: Tao Tang <[email protected]>
This change introduces STE_SET_* and CD_SET_* helpers to centralize and simplify repeated field setting logic.
Message-ID: <[email protected]>
--- include/hw/arm/smmuv3-common.h | 79 ++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
include/hw/arm/smmuv3-common.h +79 -0
@@ -100,6 +100,37 @@ REG32(STE_7, 28)#define STE_CFG_ABORT (config) (!(config & 0x4))#define STE_CFG_BYPASS (config) (config == 0x4) +/* Update STE fields */ +#define STE_SET_VALID (ste, v) \ + ((ste)->word[0] = FIELD_DP32((ste)->word[0], STE_0, VALID, (v))) +#define STE_SET_CONFIG (ste, v) \ + ((ste)->word[0] = FIELD_DP32((ste)->word[0], STE_0, CONFIG, (v))) + +#define STE_SET_CTXPTR (ste, v) do { \ + (ste)->word[0] = FIELD_DP32((ste)->word[0], STE_0, CTXPTR_LO, (v) >> 6); \ + (ste)->word[1] = FIELD_DP32((ste)->word[1], STE_1, CTXPTR_HI, (v) >> 32); \ +} while (0) +#define STE_SET_S2T0SZ (ste, v) \ + ((ste)->word[5] = FIELD_DP32((ste)->word[5], STE_5, S2T0SZ, (v))) +#define STE_SET_S2SL0 (ste, v) \ + ((ste)->word[5] = FIELD_DP32((ste)->word[5], STE_5, S2SL0, (v))) +#define STE_SET_S2TG (ste, v) \ + ((ste)->word[5] = FIELD_DP32((ste)->word[5], STE_5, S2TG, (v))) +#define STE_SET_S2PS (ste, v) \ + ((ste)->word[5] = FIELD_DP32((ste)->word[5], STE_5, S2PS, (v))) +#define STE_SET_S2AA64 (ste, v) \ + ((ste)->word[5] = FIELD_DP32((ste)->word[5], STE_5, S2AA64, (v))) +#define STE_SET_S2ENDI (ste, v) \ + ((ste)->word[5] = FIELD_DP32((ste)->word[5], STE_5, S2ENDI, (v))) +#define STE_SET_S2AFFD (ste, v) \ + ((ste)->word[5] = FIELD_DP32((ste)->word[5], STE_5, S2AFFD, (v))) +#define STE_SET_S2S (ste, v) \ + ((ste)->word[5] = FIELD_DP32((ste)->word[5], STE_5, S2S, (v))) +#define STE_SET_S2TTB (ste, v) do { \ + (ste)->word[6] = FIELD_DP32((ste)->word[6], STE_6, S2TTB_LO, (v) >> 4); \ + (ste)->word[7] = FIELD_DP32((ste)->word[7], STE_7, S2TTB_HI, (v) >> 32); \ +} while (0) +/* CD fields */ REG32 (CD_0 ,0 )
@@ -169,6 +200,54 @@ REG32(CD_5, 20) (((uint64_t)FIELD_EX32((x)->word[3], CD_3, TTB0_HI) << 32) | \ ((uint64_t)FIELD_EX32((x)->word[2], CD_2, TTB0_LO) << 4))) +/* Update CD fields */ +#define CD_SET_VALID (cd, v) \ + ((cd)->word[0] = FIELD_DP32((cd)->word[0], CD_0, VALID, (v))) +#define CD_SET_ASID (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, ASID, (v))) +#define CD_SET_TTB (cd, sel, v) do { \ + if (sel) { \ + (cd)->word[4] = FIELD_DP32((cd)->word[4], CD_4, TTB1_LO, (v) >> 4); \ + (cd)->word[5] = FIELD_DP32((cd)->word[5], CD_5, TTB1_HI, (v) >> 32); \ + } else { \ + (cd)->word[2] = FIELD_DP32((cd)->word[2], CD_2, TTB0_LO, (v) >> 4); \ + (cd)->word[3] = FIELD_DP32((cd)->word[3], CD_3, TTB0_HI, (v) >> 32); \ + } \ +} while (0) + +#define CD_SET_TSZ (cd, sel, v) \ + ((cd)->word[0] = (sel) ? FIELD_DP32((cd)->word[0], CD_0, TSZ1, (v)) : \ + FIELD_DP32((cd)->word[0], CD_0, TSZ0, (v))) +#define CD_SET_TG (cd, sel, v) \ + ((cd)->word[0] = (sel) ? FIELD_DP32((cd)->word[0], CD_0, TG1, (v)) : \ + FIELD_DP32((cd)->word[0], CD_0, TG0, (v))) +#define CD_SET_EPD (cd, sel, v) \ + ((cd)->word[0] = (sel) ? FIELD_DP32((cd)->word[0], CD_0, EPD1, (v)) : \ + FIELD_DP32((cd)->word[0], CD_0, EPD0, (v))) +#define CD_SET_ENDI (cd, v) \ + ((cd)->word[0] = FIELD_DP32((cd)->word[0], CD_0, ENDI, (v))) +#define CD_SET_IPS (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, IPS, (v))) +#define CD_SET_AFFD (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, AFFD, (v))) +#define CD_SET_TBI (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, TBI, (v))) +#define CD_SET_HD (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, HD, (v))) +#define CD_SET_HA (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, HA, (v))) +#define CD_SET_S (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, S, (v))) +#define CD_SET_R (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, R, (v))) +#define CD_SET_A (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, A, (v))) +#define CD_SET_AARCH64 (cd, v) \ + ((cd)->word[1] = FIELD_DP32((cd)->word[1], CD_1, AARCH64, (v))) +#define CD_SET_NSCFG (cd, sel, v) \ + ((sel) ? ((cd)->word[4] = FIELD_DP32((cd)->word[4], CD_4, NSCFG1, (v))) : \ + ((cd)->word[2] = FIELD_DP32((cd)->word[2], CD_2, NSCFG0, (v)))) +/* MMIO Registers */ REG32 (IDR0 ,0x0 )
Signature · 1 line
2.52.0
[PULL 23/29] hw/loader: Rename UBOOT_MAX _GUNZIP_BYTES to _DECOMPRESSED_BYTES
In reply to Philippe Mathieu-DaudéFrom: Daan De Meyer <[email protected]>
For consistency with LOAD_IMAGE_MAX_DECOMPRESSED_BYTES.
Message-ID: <[email protected]>
--- include/hw/core/loader.h | 2 +- hw/core/loader-fit.c | 2 +- hw/core/loader.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/hw/core/loader.h +1 -1
@@ -345,7 +345,7 @@ ssize_t rom_add_option(const char *file, int32_t bootindex);/* This is the usual maximum in uboot, so if a uImage overflows this, it would * overflow on real hardware too. */ -#define UBOOT_MAX_GUNZIP_BYTES (64 << 20) +#define UBOOT_MAX_DECOMPRESSED_BYTES (64 << 20) typedef struct RomGap { hwaddr base;
hw/core/loader-fit.c +1 -1
@@ -70,7 +70,7 @@ static void *fit_load_image_alloc(const void *itb, const char *name, }if (!strcmp (comp,"gzip" )) { - uncomp_len =UBOOT_MAX_GUNZIP_BYTES ; + uncomp_len =UBOOT_MAX_DECOMPRESSED_BYTES ; uncomp_data =g_malloc (uncomp_len); uncomp_len =gunzip (uncomp_data, uncomp_len, (void *) data, sz);
hw/core/loader.c +1 -1
@@ -754,7 +754,7 @@ static ssize_t load_uboot_image(const char *filename, hwaddr *ep,ssize_t bytes; compressed_data = data; - max_bytes =UBOOT_MAX_GUNZIP_BYTES ; + max_bytes =UBOOT_MAX_DECOMPRESSED_BYTES ; data =g_malloc (max_bytes); bytes =gunzip (data, max_bytes, compressed_data, hdr->ih_size);
Signature · 1 line
2.52.0
[PULL 01/29] hw/arm/smmuv3: Extract common definitions to smmuv3-common.h
In reply to Philippe Mathieu-DaudéFrom: Tao Tang <[email protected]>
Move register definitions, command enums, and Stream Table Entry (STE) / Context Descriptor (CD) structure definitions from the internal header hw/arm/smmuv3-internal.h to a new common header include/hw/arm/smmuv3-common.h.
This allows other components, such as generic SMMUv3 tests or test devices, to utilize these definitions without including the specific SMMUv3 device internal state.
Message-ID: <[email protected]>
--- hw/arm/smmuv3-internal.h | 255 +------------------------------ include/hw/arm/smmuv3-common.h | 268 +++++++++++++++++++++++++++++++++ 2 files changed, 269 insertions(+), 254 deletions(-) create mode 100644 include/hw/arm/smmuv3-common.h
hw/arm/smmuv3-internal.h +1 -254
@@ -23,6 +23,7 @@#include "hw/core/registerfields.h" #include "hw/arm/smmu-common.h" +#include "hw/arm/smmuv3-common.h" typedef enum SMMUTranslationStatus { SMMU_TRANS_DISABLE,
@@ -38,147 +39,6 @@ typedef enum SMMUTranslationClass {SMMU_CLASS_IN , } SMMUTranslationClass; -/* MMIO Registers */ - -REG32(IDR0, 0x0) - FIELD(IDR0, S2P, 0 , 1) - FIELD(IDR0, S1P, 1 , 1) - FIELD(IDR0, TTF, 2 , 2) - FIELD(IDR0, COHACC, 4 , 1) - FIELD(IDR0, BTM, 5 , 1) - FIELD(IDR0, HTTU, 6 , 2) - FIELD(IDR0, DORMHINT, 8 , 1) - FIELD(IDR0, HYP, 9 , 1) - FIELD(IDR0, ATS, 10, 1) - FIELD(IDR0, NS1ATS, 11, 1) - FIELD(IDR0, ASID16, 12, 1) - FIELD(IDR0, MSI, 13, 1) - FIELD(IDR0, SEV, 14, 1) - FIELD(IDR0, ATOS, 15, 1) - FIELD(IDR0, PRI, 16, 1) - FIELD(IDR0, VMW, 17, 1) - FIELD(IDR0, VMID16, 18, 1) - FIELD(IDR0, CD2L, 19, 1) - FIELD(IDR0, VATOS, 20, 1) - FIELD(IDR0, TTENDIAN, 21, 2) - FIELD(IDR0, ATSRECERR, 23, 1) - FIELD(IDR0, STALL_MODEL, 24, 2) - FIELD(IDR0, TERM_MODEL, 26, 1) - FIELD(IDR0, STLEVEL, 27, 2) - FIELD(IDR0, RME_IMPL, 30, 1) - -REG32(IDR1, 0x4) - FIELD(IDR1, SIDSIZE, 0 , 6) - FIELD(IDR1, SSIDSIZE, 6 , 5) - FIELD(IDR1, PRIQS, 11, 5) - FIELD(IDR1, EVENTQS, 16, 5) - FIELD(IDR1, CMDQS, 21, 5) - FIELD(IDR1, ATTR_PERMS_OVR, 26, 1) - FIELD(IDR1, ATTR_TYPES_OVR, 27, 1) - FIELD(IDR1, REL, 28, 1) - FIELD(IDR1, QUEUES_PRESET, 29, 1) - FIELD(IDR1, TABLES_PRESET, 30, 1) - FIELD(IDR1, ECMDQ, 31, 1) - -#define SMMU_IDR1_SIDSIZE 16 -#define SMMU_CMDQS 19 -#define SMMU_EVENTQS 19 - -REG32(IDR2, 0x8) - FIELD(IDR2, BA_VATOS, 0, 10) - -REG32(IDR3, 0xc) -FIELD (IDR3 ,HAD ,2 ,1 ); -FIELD (IDR3 ,PBHA ,3 ,1 ); -FIELD (IDR3 ,XNX ,4 ,1 ); -FIELD (IDR3 ,PPS ,5 ,1 ); -FIELD (IDR3 ,MPAM ,7 ,1 ); -FIELD (IDR3 ,FWB ,8 ,1 ); -FIELD (IDR3 ,STT ,9 ,1 ); -FIELD (IDR3 ,RIL ,10 ,1 ); -FIELD (IDR3 ,BBML ,11 ,2 ); -FIELD (IDR3 ,E0PD ,13 ,1 ); -FIELD (IDR3 ,PTWNNC ,14 ,1 ); -FIELD (IDR3 ,DPT ,15 ,1 ); - -REG32(IDR4, 0x10) - -REG32(IDR5, 0x14) -FIELD (IDR5 ,OAS ,0 ,3 ); -FIELD (IDR5 ,GRAN4K ,4 ,1 ); -FIELD (IDR5 ,GRAN16K ,5 ,1 ); -FIELD (IDR5 ,GRAN64K ,6 ,1 ); -FIELD (IDR5 ,VAX ,10 ,2 ); -FIELD (IDR5 ,STALL_MAX ,16 ,16 ); - -#define SMMU_IDR5_OAS 4 - -REG32(IIDR, 0x18) -REG32(AIDR, 0x1c) -REG32(CR0, 0x20) - FIELD(CR0, SMMU_ENABLE, 0, 1) - FIELD(CR0, EVENTQEN, 2, 1) - FIELD(CR0, CMDQEN, 3, 1) - -#define SMMU_CR0_RESERVED 0xFFFFFC20 - -REG32(CR0ACK, 0x24) -REG32(CR1, 0x28) -REG32(CR2, 0x2c) -REG32(STATUSR, 0x40) -REG32(GBPA, 0x44) - FIELD(GBPA, ABORT, 20, 1) -FIELD (GBPA ,UPDATE ,31 ,1 ) - -/* Use incoming. */ -#define SMMU_GBPA_RESET_VAL 0x1000 - -REG32(IRQ_CTRL, 0x50) - FIELD(IRQ_CTRL, GERROR_IRQEN, 0, 1) - FIELD(IRQ_CTRL, PRI_IRQEN, 1, 1) - FIELD(IRQ_CTRL, EVENTQ_IRQEN, 2, 1) - -REG32(IRQ_CTRL_ACK, 0x54) -REG32(GERROR, 0x60) - FIELD(GERROR, CMDQ_ERR, 0, 1) - FIELD(GERROR, EVENTQ_ABT_ERR, 2, 1) - FIELD(GERROR, PRIQ_ABT_ERR, 3, 1) - FIELD(GERROR, MSI_CMDQ_ABT_ERR, 4, 1) - FIELD(GERROR, MSI_EVENTQ_ABT_ERR, 5, 1) - FIELD(GERROR, MSI_PRIQ_ABT_ERR, 6, 1) - FIELD(GERROR, MSI_GERROR_ABT_ERR, 7, 1) - FIELD(GERROR, MSI_SFM_ERR, 8, 1) - -REG32(GERRORN, 0x64) - -#define A_GERROR_IRQ_CFG0 0x68/* 64b */ -REG32(GERROR_IRQ_CFG1, 0x70) -REG32(GERROR_IRQ_CFG2, 0x74) - -#define A_STRTAB_BASE 0x80/* 64b */ - -#define SMMU_BASE_ADDR_MASK 0xfffffffffffc0 - -REG32(STRTAB_BASE_CFG, 0x88) - FIELD(STRTAB_BASE_CFG, FMT, 16, 2) - FIELD(STRTAB_BASE_CFG, SPLIT, 6 , 5) - FIELD(STRTAB_BASE_CFG, LOG2SIZE, 0 , 6) - -#define A_CMDQ_BASE 0x90/* 64b */ -REG32(CMDQ_PROD, 0x98) -REG32(CMDQ_CONS, 0x9c) - FIELD(CMDQ_CONS, ERR, 24, 7) - -#define A_EVENTQ_BASE 0xa0/* 64b */ -REG32(EVENTQ_PROD, 0xa8) -REG32(EVENTQ_CONS, 0xac) - -#define A_EVENTQ_IRQ_CFG0 0xb0/* 64b */ -REG32(EVENTQ_IRQ_CFG1, 0xb8) -REG32(EVENTQ_IRQ_CFG2, 0xbc) - -#define A_IDREGS 0xfd0 -static inline int smmu_enabled (SMMUv3State *s) {return FIELD_EX32 (s->cr[0 ],CR0 ,SMMU_ENABLE );
@@ -272,37 +132,6 @@ static inline void smmu_write_cmdq_err(SMMUv3State *s, uint32_t err_type) s->cmdq.cons =FIELD_DP32 (s->cmdq.cons,CMDQ_CONS ,ERR , err_type); } -/* Commands */ - -typedef enum SMMUCommandType { -SMMU_CMD_NONE =0x00 , -SMMU_CMD_PREFETCH_CONFIG , -SMMU_CMD_PREFETCH_ADDR , -SMMU_CMD_CFGI_STE , -SMMU_CMD_CFGI_STE_RANGE , -SMMU_CMD_CFGI_CD , -SMMU_CMD_CFGI_CD_ALL , -SMMU_CMD_CFGI_ALL , -SMMU_CMD_TLBI_NH_ALL =0x10 , -SMMU_CMD_TLBI_NH_ASID , -SMMU_CMD_TLBI_NH_VA , -SMMU_CMD_TLBI_NH_VAA , -SMMU_CMD_TLBI_EL3_ALL =0x18 , -SMMU_CMD_TLBI_EL3_VA =0x1a , -SMMU_CMD_TLBI_EL2_ALL =0x20 , -SMMU_CMD_TLBI_EL2_ASID , -SMMU_CMD_TLBI_EL2_VA , -SMMU_CMD_TLBI_EL2_VAA , -SMMU_CMD_TLBI_S12_VMALL =0x28 , -SMMU_CMD_TLBI_S2_IPA =0x2a , -SMMU_CMD_TLBI_NSNH_ALL =0x30 , -SMMU_CMD_ATC_INV =0x40 , -SMMU_CMD_PRI_RESP , -SMMU_CMD_RESUME =0x44 , -SMMU_CMD_STALL_TERM , -SMMU_CMD_SYNC , -}SMMUCommandType ; -static const char *cmd_stringify[] = { [SMMU_CMD_PREFETCH_CONFIG ] ="SMMU_CMD_PREFETCH_CONFIG" , [SMMU_CMD_PREFETCH_ADDR ] ="SMMU_CMD_PREFETCH_ADDR" ,
@@ -525,64 +354,6 @@ typedef struct SMMUEventInfo {void smmuv3_record_event (SMMUv3State *s,SMMUEventInfo *event); -/* Configuration Data */ - -/* STE Level 1 Descriptor */ -typedef struct STEDesc { -uint32_t word[2 ]; -}STEDesc ; - -/* CD Level 1 Descriptor */ -typedef struct CDDesc { -uint32_t word[2 ]; -}CDDesc ; - -/* Stream Table Entry(STE) */ -typedef struct STE { -uint32_t word[16 ]; -}STE ; - -/* Context Descriptor(CD) */ -typedef struct CD { -uint32_t word[16 ]; -}CD ; - -/* STE fields */ - -#define STE_VALID (x) extract32((x)->word[0], 0, 1) - -#define STE_CONFIG (x) extract32((x)->word[0], 1, 3) -#define STE_CFG_S1_ENABLED (config) (config & 0x1) -#define STE_CFG_S2_ENABLED (config) (config & 0x2) -#define STE_CFG_ABORT (config) (!(config & 0x4)) -#define STE_CFG_BYPASS (config) (config == 0x4) - -#define STE_S1FMT (x) extract32((x)->word[0], 4 , 2) -#define STE_S1CDMAX (x) extract32((x)->word[1], 27, 5) -#define STE_S1STALLD (x) extract32((x)->word[2], 27, 1) -#define STE_EATS (x) extract32((x)->word[2], 28, 2) -#define STE_STRW (x) extract32((x)->word[2], 30, 2) -#define STE_S2VMID (x) extract32((x)->word[4], 0 , 16) -#define STE_S2T0SZ (x) extract32((x)->word[5], 0 , 6) -#define STE_S2SL0 (x) extract32((x)->word[5], 6 , 2) -#define STE_S2TG (x) extract32((x)->word[5], 14, 2) -#define STE_S2PS (x) extract32((x)->word[5], 16, 3) -#define STE_S2AA64 (x) extract32((x)->word[5], 19, 1) -#define STE_S2ENDI (x) extract32((x)->word[5], 20, 1) -#define STE_S2AFFD (x) extract32((x)->word[5], 21, 1) -#define STE_S2HD (x) extract32((x)->word[5], 23, 1) -#define STE_S2HA (x) extract32((x)->word[5], 24, 1) -#define STE_S2S (x) extract32((x)->word[5], 25, 1) -#define STE_S2R (x) extract32((x)->word[5], 26, 1) - -#define STE_CTXPTR (x) \ - ((extract64((x)->word[1], 0, 16) << 32) | \ - ((x)->word[0] & 0xffffffc0)) - -#define STE_S2TTB (x) \ - ((extract64((x)->word[7], 0, 16) << 32) | \ - ((x)->word[6] & 0xfffffff0)) -static inline int oas2bits (int oas_field) {switch (oas_field) {
@@ -603,30 +374,6 @@ static inline int oas2bits(int oas_field)g_assert_not_reached (); } -/* CD fields */ - -#define CD_VALID (x) extract32((x)->word[0], 31, 1) -#define CD_ASID (x) extract32((x)->word[1], 16, 16) -#define CD_TTB (x, sel) \ - ((extract64((x)->word[(sel) * 2 + 3], 0, 19) << 32) | \ - ((x)->word[(sel) * 2 + 2] & ~0xfULL)) - -#define CD_HAD (x, sel) extract32((x)->word[(sel) * 2 + 2], 1, 1) - -#define CD_TSZ (x, sel) extract32((x)->word[0], (16 * (sel)) + 0, 6) -#define CD_TG (x, sel) extract32((x)->word[0], (16 * (sel)) + 6, 2) -#define CD_EPD (x, sel) extract32((x)->word[0], (16 * (sel)) + 14, 1) -#define CD_ENDI (x) extract32((x)->word[0], 15, 1) -#define CD_IPS (x) extract32((x)->word[1], 0 , 3) -#define CD_AFFD (x) extract32((x)->word[1], 3 , 1) -#define CD_TBI (x) extract32((x)->word[1], 6 , 2) -#define CD_HD (x) extract32((x)->word[1], 10 , 1) -#define CD_HA (x) extract32((x)->word[1], 11 , 1) -#define CD_S (x) extract32((x)->word[1], 12, 1) -#define CD_R (x) extract32((x)->word[1], 13, 1) -#define CD_A (x) extract32((x)->word[1], 14, 1) -#define CD_AARCH64 (x) extract32((x)->word[1], 9 , 1) -/** * tg2granule - Decodes the CD translation granule size field according * to the ttbr in use
include/hw/arm/smmuv3-common.h new file +268 -0
268 lines not on this page · raw message
Signature · 1 line
2.52.0
[PULL 20/29] hw/sd/sdhci: Remove vendor property
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
Now that there are dedicated eSDHC device models it is possible to replace the "vendor" property (which is really a device-specific property) with a dynamic cast, "fishing" out only the device models which shall have the quirk applied.
Message-ID: <[email protected]>
--- hw/sd/sdhci-internal.h | 1 - include/hw/sd/sdhci.h | 4 ---- hw/sd/sdhci.c | 5 ++--- 3 files changed, 2 insertions(+), 8 deletions(-)
hw/sd/sdhci-internal.h +0 -1
@@ -309,7 +309,6 @@ extern const VMStateDescription sdhci_vmstate;#define DEFINE_SDHCI_COMMON_PROPERTIES (_state) \ DEFINE_PROP_UINT8("sd-spec-version", _state, sd_spec_version, 2), \ DEFINE_PROP_UINT8("uhs", _state, uhs_mode, UHS_NOT_SUPPORTED), \ - DEFINE_PROP_UINT8("vendor", _state, vendor, SDHCI_VENDOR_NONE), \ \/* Capabilities registers provide information on supported * features of this specific host controller implementation */ \
include/hw/sd/sdhci.h +0 -4
@@ -98,7 +98,6 @@ struct SDHCIState {uint32_t quirks;uint8_t sd_spec_version;uint8_t uhs_mode; -uint8_t vendor;/* For vendor specific functionality */ /* * Write Protect pin default active low for detecting SD card * to be protected. Set wp_inverted to invert the signal.
@@ -107,9 +106,6 @@ struct SDHCIState { };typedef struct SDHCIState SDHCIState ; -#define SDHCI_VENDOR_NONE 0 -#define SDHCI_VENDOR_FSL 2 -/* * Controller does not provide transfer-complete interrupt when not * busy.
hw/sd/sdhci.c +2 -3
@@ -307,7 +307,8 @@ static void sdhci_reset(SDHCIState *s) s->data_count =0 ; s->stopped_state = sdhc_not_stopped; s->pending_insert_state = false; -if (s->vendor ==SDHCI_VENDOR_FSL ) { +if (object_dynamic_cast (OBJECT (s),TYPE_FSL_ESDHC_BE ) || +object_dynamic_cast (OBJECT (s),TYPE_FSL_ESDHC_LE )) { s->norintstsen =0x013f ; s->errintstsen =0x117f ; }
@@ -1863,7 +1864,6 @@ static void fsl_esdhc_be_init(Object *obj) s->io_ops = &esdhc_mmio_be_ops; s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ;qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); -qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); }static const MemoryRegionOps esdhc_mmio_le_ops = {
@@ -1889,7 +1889,6 @@ static void fsl_esdhc_le_init(Object *obj) s->io_ops = &esdhc_mmio_le_ops; s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ;qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); -qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); }static const MemoryRegionOps usdhc_mmio_ops = {
Signature · 1 line
2.52.0
[PULL 24/29] hw/loader: Use g_autofree in unpack_efi_zboot_image()
In reply to Philippe Mathieu-DaudéFrom: Daan De Meyer <[email protected]>
Message-ID: <[email protected]>
--- hw/core/loader.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hw/core/loader.c +2 -3
@@ -898,7 +898,7 @@ ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size) {const size_t max_bytes =LOAD_IMAGE_MAX_DECOMPRESSED_BYTES ;const struct linux_efi_zboot_header *header; -uint8_t *data =NULL ; + g_autofree uint8_t *data = NULL;ssize_t ploff, plsize;ssize_t bytes;
@@ -936,12 +936,11 @@ ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size) bytes =gunzip (data, max_bytes, *buffer + ploff, plsize);if (bytes <0 ) {fprintf (stderr,"failed to decompress EFI zboot image\n" ); -g_free (data);return -1 ; }g_free (*buffer); - *buffer =g_realloc (data, bytes); + *buffer =g_realloc (g_steal_pointer (&data), bytes); *size = bytes;return bytes; }
Signature · 1 line
2.52.0
[PULL 16/29] hw/sd/sdhci: Add TYPE_FSL_ESDHC_BE
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
For now, TYPE_FSL_ESDHC_BE is basically a big-endian variant of TYPE_IMX_USDHC. It will be used in the e500 machines in the next step which prevents Linux to flood the console with "mmc0: Internal clock never stabilised" messages.
Message-ID: <[email protected]>
--- include/hw/sd/sdhci.h | 2 ++ hw/sd/sdhci.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
include/hw/sd/sdhci.h +2 -0
@@ -128,6 +128,8 @@ DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,DECLARE_INSTANCE_CHECKER (SDHCIState,SYSBUS_SDHCI , TYPE_SYSBUS_SDHCI) +#define TYPE_FSL_ESDHC_BE "fsl-esdhc-be" +#define TYPE_IMX_USDHC "imx-usdhc"#define TYPE_S3C_SDHCI "s3c-sdhci"
hw/sd/sdhci.c +31 -0
@@ -1871,6 +1871,32 @@ esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) } } +static const MemoryRegionOps esdhc_mmio_be_ops = { + .read = esdhc_read, + .write = esdhc_write, + .impl = { + .min_access_size =4 , + .max_access_size =4 , + }, + .valid = { + .min_access_size =1 , + .max_access_size =4 , + .unaligned = false + }, + .endianness =DEVICE_BIG_ENDIAN , +}; + +static void fsl_esdhc_be_init (Object *obj) +{ +SDHCIState *s =SYSBUS_SDHCI (obj); +DeviceState *dev =DEVICE (obj); + + s->io_ops = &esdhc_mmio_be_ops; + s->quirks =SDHCI_QUIRK_NO_BUSY_IRQ ; +qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 ); +qdev_prop_set_uint8 (dev,"vendor" ,SDHCI_VENDOR_FSL ); +} +static const MemoryRegionOps usdhc_mmio_ops = { .read = esdhc_read, .write = esdhc_write,
@@ -1965,6 +1991,11 @@ static const TypeInfo sdhci_types[] = { .instance_finalize = sdhci_sysbus_finalize, .class_init = sdhci_sysbus_class_init, }, + { + .name = TYPE_FSL_ESDHC_BE, + .parent = TYPE_SYSBUS_SDHCI, + .instance_init = fsl_esdhc_be_init, + }, { .name = TYPE_IMX_USDHC, .parent = TYPE_SYSBUS_SDHCI,
Signature · 1 line
2.52.0
[PULL 21/29] hw/sd/trace-events: Remove redundant "SWITCH " command name
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
"switch" is already part of the function name. No need to repeat it.
Message-ID: <[email protected]>
--- hw/sd/trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/trace-events +1 -1
@@ -58,7 +58,7 @@ sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint64_t size, uint32_t blklen) "%s %20s/ CMD%02d ofs %"PRIu32" size %"PRIu64" blklen %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" sdcard_ext_csd_update(unsigned index, uint8_t oval, uint8_t nval) "index %u: 0x%02x -> 0x%02x" -sdcard_switch(unsigned access, unsigned index, unsigned value, unsigned set) "SWITCH acc:%u idx:%u val:%u set:%u" +sdcard_switch(unsigned access, unsigned index, unsigned value, unsigned set) "acc:%u idx:%u val:%u set:%u" sdcard_rpmb_read_block(uint16_t resp, uint16_t read_addr, uint16_t result) "resp 0x%x read_addr 0x%x result 0x%x" sdcard_rpmb_write_block(uint16_t req, uint16_t result) "req 0x%x result 0x%x"
Signature · 1 line
2.52.0
[PULL 11/29] hw/arm/fsl-imx6: Fix naming of SDHCI related constants and attributes
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
The i.MX 6 SoC features uSDHC controllers which are the successors of eSDHC. Fix the naming to make this clear.
Message-ID: <[email protected]>
--- include/hw/arm/fsl-imx6.h | 4 ++-- hw/arm/fsl-imx6.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-)
include/hw/arm/fsl-imx6.h +2 -2
@@ -46,7 +46,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(FslIMX6State, FSL_IMX6)#define FSL_IMX6_NUM_EPITS 2#define FSL_IMX6_NUM_I2CS 3#define FSL_IMX6_NUM_GPIOS 7 -#define FSL_IMX6_NUM_ESDHCS 4 +#define FSL_IMX6_NUM_USDHCS 4#define FSL_IMX6_NUM_ECSPIS 5#define FSL_IMX6_NUM_WDTS 2#define FSL_IMX6_NUM_USB_PHYS 2
@@ -67,7 +67,7 @@ struct FslIMX6State {IMXEPITState epit[FSL_IMX6_NUM_EPITS ];IMXI2CState i2c[FSL_IMX6_NUM_I2CS ];IMXGPIOState gpio[FSL_IMX6_NUM_GPIOS ]; -SDHCIState esdhc[FSL_IMX6_NUM_ESDHCS ]; +SDHCIState usdhc[FSL_IMX6_NUM_USDHCS ];IMXSPIState spi[FSL_IMX6_NUM_ECSPIS ];IMX2WdtState wdt[FSL_IMX6_NUM_WDTS ];IMXUSBPHYState usbphy[FSL_IMX6_NUM_USB_PHYS ];
hw/arm/fsl-imx6.c +8 -8
@@ -79,9 +79,9 @@ static void fsl_imx6_init(Object *obj)object_initialize_child (obj, name, &s->gpio[i],TYPE_IMX_GPIO ); } -for (i =0 ; i <FSL_IMX6_NUM_ESDHCS ; i++) { +for (i =0 ; i <FSL_IMX6_NUM_USDHCS ; i++) {snprintf (name,NAME_SIZE ,"sdhc%d" , i +1 ); -object_initialize_child (obj, name, &s->esdhc[i],TYPE_IMX_USDHC ); +object_initialize_child (obj, name, &s->usdhc[i],TYPE_IMX_USDHC ); }for (i =0 ; i <FSL_IMX6_NUM_USB_PHYS ; i++) {
@@ -311,11 +311,11 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) }/* Initialize all SDHC */ -for (i =0 ; i <FSL_IMX6_NUM_ESDHCS ; i++) { +for (i =0 ; i <FSL_IMX6_NUM_USDHCS ; i++) {static const struct {hwaddr addr;unsigned int irq; - } esdhc_table[FSL_IMX6_NUM_ESDHCS ] = { + } esdhc_table[FSL_IMX6_NUM_USDHCS ] = { { FSL_IMX6_uSDHC1_ADDR, FSL_IMX6_uSDHC1_IRQ }, { FSL_IMX6_uSDHC2_ADDR, FSL_IMX6_uSDHC2_IRQ }, { FSL_IMX6_uSDHC3_ADDR, FSL_IMX6_uSDHC3_IRQ },
@@ -323,13 +323,13 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) };/* UHS-I SDIO3.0 SDR104 1.8V ADMA */ -object_property_set_uint (OBJECT (&s->esdhc[i]),"capareg" , +object_property_set_uint (OBJECT (&s->usdhc[i]),"capareg" ,IMX6_ESDHC_CAPABILITIES , &error_abort); -if (!sysbus_realize (SYS_BUS_DEVICE (&s->esdhc[i]), errp)) { +if (!sysbus_realize (SYS_BUS_DEVICE (&s->usdhc[i]), errp)) {return ; } -sysbus_mmio_map (SYS_BUS_DEVICE (&s->esdhc[i]),0 , esdhc_table[i].addr); -sysbus_connect_irq (SYS_BUS_DEVICE (&s->esdhc[i]),0 , +sysbus_mmio_map (SYS_BUS_DEVICE (&s->usdhc[i]),0 , esdhc_table[i].addr); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->usdhc[i]),0 ,qdev_get_gpio_in (gic, esdhc_table[i].irq)); }
Signature · 1 line
2.52.0
[PULL 25/29] hw/loader: Add support for zboot images compressed with zstd
In reply to Philippe Mathieu-DaudéFrom: Daan De Meyer <[email protected]>
Message-ID: <[email protected]>
--- hw/core/loader.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
hw/core/loader.c +21 -9
@@ -68,6 +68,11 @@#include <zlib.h> +#ifdef CONFIG_ZSTD +#include <zstd.h> +#include <zstd_errors.h> +#endif +static int roms_loaded;/* return the size or -1 if error */
@@ -916,14 +921,6 @@ ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size)return 0 ; } -if (strcmp (header->compression_type,"gzip" ) !=0 ) { -fprintf (stderr, -"unable to handle EFI zboot image with \"%.*s\" compression\n" , - (int )sizeof (header->compression_type) -1 , - header->compression_type); -return -1 ; - } - ploff =ldl_le_p (&header->payload_offset); plsize =ldl_le_p (&header->payload_size);
@@ -933,7 +930,22 @@ ssize_t unpack_efi_zboot_image(uint8_t **buffer, ssize_t *size) } data =g_malloc (max_bytes); - bytes =gunzip (data, max_bytes, *buffer + ploff, plsize); + +if (strcmp (header->compression_type,"gzip" ) ==0 ) { + bytes =gunzip (data, max_bytes, *buffer + ploff, plsize); +#ifdef CONFIG_ZSTD + }else if (strcmp (header->compression_type,"zstd" ) ==0 ) { +size_t ret =ZSTD_decompress (data, max_bytes, *buffer + ploff, plsize); + bytes =ZSTD_isError (ret) ?-1 : (ssize_t ) ret; +#endif + }else { +fprintf (stderr, +"unable to handle EFI zboot image with \"%.*s\" compression\n" , + (int )sizeof (header->compression_type) -1 , + header->compression_type); +return -1 ; + } +if (bytes <0 ) {fprintf (stderr,"failed to decompress EFI zboot image\n" );return -1 ;
Signature · 1 line
2.52.0
[PULL 26/29] hw: move pcap structs to header file
In reply to Philippe Mathieu-DaudéFrom: Gerd Hoffmann <[email protected]>
Allow reusing them elsewhere in qemu.
Message-ID: <[email protected]>
--- include/qemu/pcap.h | 30 ++++++++++++++++++++++++++++++ hw/usb/pcap.c | 24 +----------------------- 2 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 include/qemu/pcap.h
include/qemu/pcap.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef QEMU_PCAP_H +#define QEMU_PCAP_H + +#define PCAP_MAGIC 0xa1b2c3d4 +#define PCAP_MAJOR 2 +#define PCAP_MINOR 4 + +/* https://wiki.wireshark.org/Development/LibpcapFileFormat */ + +struct pcap_hdr { +uint32_t magic_number;/* magic number */ +uint16_t version_major;/* major version number */ +uint16_t version_minor;/* minor version number */ +int32_t thiszone;/* GMT to local correction */ +uint32_t sigfigs;/* accuracy of timestamps */ +uint32_t snaplen;/* max length of captured packets, in octets */ +uint32_t network;/* data link type */ +}; + +struct pcaprec_hdr { +uint32_t ts_sec;/* timestamp seconds */ +uint32_t ts_usec;/* timestamp microseconds */ +uint32_t incl_len;/* number of octets of packet saved in file */ +uint32_t orig_len;/* actual length of packet */ +}; + +#endif /* QEMU_PCAP_H */
hw/usb/pcap.c +1 -23
@@ -8,31 +8,9 @@*/ #include "qemu/osdep.h" +#include "qemu/pcap.h" #include "hw/usb/usb.h" -#define PCAP_MAGIC 0xa1b2c3d4 -#define PCAP_MAJOR 2 -#define PCAP_MINOR 4 - -/* https://wiki.wireshark.org/Development/LibpcapFileFormat */ - -struct pcap_hdr { -uint32_t magic_number;/* magic number */ -uint16_t version_major;/* major version number */ -uint16_t version_minor;/* minor version number */ -int32_t thiszone;/* GMT to local correction */ -uint32_t sigfigs;/* accuracy of timestamps */ -uint32_t snaplen;/* max length of captured packets, in octets */ -uint32_t network;/* data link type */ -}; - -struct pcaprec_hdr { -uint32_t ts_sec;/* timestamp seconds */ -uint32_t ts_usec;/* timestamp microseconds */ -uint32_t incl_len;/* number of octets of packet saved in file */ -uint32_t orig_len;/* actual length of packet */ -}; -/* https://www.tcpdump.org/linktypes.html */ /* linux: Documentation/usb/usbmon.rst */ /* linux: drivers/usb/mon/mon_bin.c */
Signature · 1 line
2.52.0
[PULL 29/29] meson: Do not try to build module for empty per-target hw/ directory
In reply to Philippe Mathieu-DaudéIn commit 83d5db95d38 ("meson: Allow system binaries to not have target-specific units") we allowed targets with empty target_system_arch[] source set, but missed hw_arch[] could also be empty when building modules.
Skip such case, otherwise due to commit a1ced487549 ("hw/microblaze: Build files once"), building with --enable-modules triggers:
../meson.build:4034:14: ERROR: Key microblaze is not in the dictionary.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3272
Message-Id: <[email protected]>
--- meson.build | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
meson.build +5 -2
@@ -3957,6 +3957,11 @@ if enable_modules foreach target : target_dirs if target.endswith('-softmmu') config_target = config_target_mak[target] + arch = config_target['TARGET_NAME'] == 'sparc64' ? 'sparc64' : config_target['TARGET_BASE_ARCH'] + if not hw_arch.has_key(arch) + continue + endif + config_devices_mak = target + '-config-devices.mak' modinfo_src = custom_target('modinfo-' + target + '.c', output: 'modinfo-' + target + '.c',
@@ -3966,8 +3971,6 @@ if enable_modules modinfo_lib = static_library('modinfo-' + target + '.c', modinfo_src) modinfo_dep = declare_dependency(link_with: modinfo_lib) - - arch = config_target['TARGET_NAME'] == 'sparc64' ? 'sparc64' : config_target['TARGET_BASE_ARCH'] hw_arch[arch].add(modinfo_dep) endif endforeach
Signature · 1 line
2.52.0
[PULL 27/29] hw/uefi: add pcap support
In reply to Philippe Mathieu-DaudéFrom: Gerd Hoffmann <[email protected]>
Add pcapfile property to uevi-vars-* devices, allowing to write out a capture of the communication traffic between uefi firmware and qemu.
Message-ID: <[email protected]>
--- include/hw/uefi/var-service.h | 10 ++++ hw/uefi/var-service-core.c | 7 +++ hw/uefi/var-service-pcap.c | 95 +++++++++++++++++++++++++++++++++++ hw/uefi/var-service-sysbus.c | 1 + hw/uefi/meson.build | 1 + 5 files changed, 114 insertions(+) create mode 100644 hw/uefi/var-service-pcap.c
include/hw/uefi/var-service.h +10 -0
@@ -77,6 +77,10 @@ struct uefi_vars_state {bool force_secure_boot;bool disable_custom_mode;bool use_pio; + +/* request + reply capture */ +char *pcapfile; +FILE *pcapfp; };struct uefi_vars_cert {
@@ -189,4 +193,10 @@ uefi_var_policy *uefi_vars_add_policy(uefi_vars_state *uv, variable_policy_entry *pe);uint32_t uefi_vars_mm_check_policy_proto (uefi_vars_state *uv); +/* vars-service-pcap.c */ +void uefi_vars_pcap_init (uefi_vars_state *uv,Error **errp); +void uefi_vars_pcap_reset (uefi_vars_state *uv); +void uefi_vars_pcap_request (uefi_vars_state *uv,void *buffer,size_t size); +void uefi_vars_pcap_reply (uefi_vars_state *uv,void *buffer,size_t size); +#endif /* QEMU_UEFI_VAR_SERVICE_H */
hw/uefi/var-service-core.c +7 -0
@@ -101,6 +101,8 @@ static uint32_t uefi_vars_cmd_mm(uefi_vars_state *uv, bool dma_mode) }memset (uv->buffer + size,0 , uv->buf_size - size); +uefi_vars_pcap_request (uv, uv->buffer, size); +/* dispatch */ if (qemu_uuid_is_equal (&mhdr->guid, &EfiSmmVariableProtocolGuid)) { retval =uefi_vars_mm_vars_proto (uv);
@@ -127,6 +129,8 @@ static uint32_t uefi_vars_cmd_mm(uefi_vars_state *uv, bool dma_mode) retval =UEFI_VARS_STS_ERR_NOT_SUPPORTED ; } +uefi_vars_pcap_reply (uv, uv->buffer,sizeof (*mhdr) + mhdr->length); +/* write buffer */ if (dma_mode) { dma_memory_write(&address_space_memory, dma,
@@ -163,6 +167,8 @@ void uefi_vars_hard_reset(uefi_vars_state *uv)uefi_vars_clear_volatile (uv);uefi_vars_policies_clear (uv);uefi_vars_auth_init (uv); + +uefi_vars_pcap_reset (uv); }static uint32_t uefi_vars_cmd (uefi_vars_state *uv,uint32_t cmd)
@@ -319,4 +325,5 @@ void uefi_vars_realize(uefi_vars_state *uv, Error **errp) {uefi_vars_json_init (uv, errp);uefi_vars_json_load (uv, errp); +uefi_vars_pcap_init (uv, errp); }
hw/uefi/var-service-pcap.c new file +95 -0
95 lines not on this page · raw message
hw/uefi/var-service-sysbus.c +1 -0
@@ -33,6 +33,7 @@ static const Property uefi_vars_sysbus_properties[] = {DEFINE_PROP_SIZE ("size" , uefi_vars_sysbus_state, state.max_storage,256 *1024 ),DEFINE_PROP_STRING ("jsonfile" , uefi_vars_sysbus_state, state.jsonfile), +DEFINE_PROP_STRING ("pcapfile" , uefi_vars_sysbus_state, state.pcapfile),DEFINE_PROP_BOOL ("force-secure-boot" , uefi_vars_sysbus_state, state.force_secure_boot, false), DEFINE_PROP_BOOL("disable-custom-mode", uefi_vars_sysbus_state,
hw/uefi/meson.build +1 -0
@@ -3,6 +3,7 @@ system_ss.add(files('hardware-info.c', 'ovmf-log.c')) uefi_vars_ss = ss.source_set() if (config_all_devices.has_key('CONFIG_UEFI_VARS')) uefi_vars_ss.add(files('var-service-core.c', + 'var-service-pcap.c', 'var-service-json.c', 'var-service-vars.c', 'var-service-auth.c',
Signature · 1 line
2.52.0
[PULL 28/29] hw/virtio-nsm: include qemu/osdep.h
In reply to Philippe Mathieu-DaudéFrom: Paolo Bonzini <[email protected]>
The file hw/virtio/cbor-helpers.c does not include our standard qemu/osdep.h header, add it.
Message-ID: <[email protected]>
--- hw/virtio/cbor-helpers.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/cbor-helpers.c +1 -0
@@ -8,6 +8,7 @@* top-level directory. */ +#include "qemu/osdep.h" #include "hw/virtio/cbor-helpers.h" bool qemu_cbor_map_add (cbor_item_t *map,cbor_item_t *key,cbor_item_t *value)
Signature · 1 line
2.52.0
[PULL 10/29] hw/arm/fsl-imx6: Remove now redundant setting of "sd-spec-version" property
In reply to Philippe Mathieu-DaudéFrom: Bernhard Beschow <[email protected]>
Now that TYPE_IMX_USDHC sets this property internally it is not needed on the SoC level any longer.
Message-ID: <[email protected]>
--- hw/arm/fsl-imx6.c | 2 -- 1 file changed, 2 deletions(-)
hw/arm/fsl-imx6.c +0 -2
@@ -323,8 +323,6 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) };/* UHS-I SDIO3.0 SDR104 1.8V ADMA */ -object_property_set_uint (OBJECT (&s->esdhc[i]),"sd-spec-version" ,3 , - &error_abort);object_property_set_uint (OBJECT (&s->esdhc[i]),"capareg" ,IMX6_ESDHC_CAPABILITIES , &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->esdhc[i]), errp)) {
Signature · 1 line
2.52.0
Richard Henderson
AppliedQuoted 12 lines · Philippe Mathieu-Daudé
The following changes since commit
38879a667fbb4ef54c70de71494882615f600a64:Merge tag 'pull-tcg-20260119' ofhttps://gitlab.com/rth7680/qemu into staging (2026-01-19 09:04:31 +1100)are available in the Git repository at:
https://github.com/philmd/qemu.git tags/hw-misc-20260120for you to fetch changes up to
84f82697f8294377224aad9f7cc499116ae0ec49:meson: Do not try to build module for empty per-target hw/ directory (2026-01-20 19:34:44 +0100)
Quoted 7 lines
----------------------------------------------------------------
Misc HW patches- Generalized IOMMU test framework
- Fix Freescale SDHCI endianness issues
- Support for zboot images compressed with Zstd
- Pcap support to analyze UEFI firmware traffic
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/11.0 as appropriate.
r~