Skip to content

Conversation

legoater
Copy link
Owner

@legoater legoater commented May 26, 2025

Summary by CodeRabbit

  • New Features

    • Added support for 64-bit DMA addressing in the ASPEED Hash and Crypto Engine (HACE) emulation, specifically for the AST2700 platform.
    • Introduced new QTest test suites for ASPEED HACE on AST2700, covering various hash algorithms and modes.
  • Bug Fixes

    • Adjusted memory region sizes and addresses for improved accuracy in memory mapping and device initialization.
    • Tightened access size restrictions for certain memory regions to ensure correct operation.
  • Tests

    • Added comprehensive test coverage for HACE functionality, including direct, scatter-gather, and accumulative hashing modes on multiple platforms.
    • Improved memory management in test suites by ensuring temporary files and memory are properly freed.
  • Documentation

    • Updated documentation to reflect changes in supported board listings.
  • Chores

    • Enhanced trace logging for debugging and monitoring of HACE operations.
    • Reorganized and extended test source file associations for Aspeed and Ast2700 test suites.

Copy link

coderabbitai bot commented May 26, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce 64-bit DMA support and major refactoring to the ASPEED HACE (hash and crypto engine) emulation, including dynamic register allocation, new register masks, and improved memory mapping. Extensive QTest-based test suites for HACE on multiple platforms, including AST2700, are added. Documentation and test infrastructure are updated accordingly.

Changes

File(s) Change Summary
docs/system/arm/aspeed.rst Removed ast2700fc from supported boards list.
hw/arm/aspeed_ast27x0-fc.c, hw/arm/aspeed_ast27x0.c, hw/arm/fby35.c Adjusted memory region sizes and mappings; updated NIC configuration and memory subregion registration.
hw/intc/aspeed_intc.c Set .impl.min_access_size = 4 in MemoryRegionOps for all INTC variants; reformatted function signatures.
hw/misc/aspeed_hace.c Added 64-bit DMA support for AST2700; refactored hash operation logic; dynamic register allocation; improved tracing and error handling.
hw/misc/trace-events Added new trace events for HACE operations, including hexdump and hash execution tracing.
include/hw/misc/aspeed_hace.h Refactored HACE state struct: dynamic register array, new mask fields, and DMA64 capability flag.
tests/qtest/aspeed-hace-utils.c, tests/qtest/aspeed-hace-utils.h Introduced utility module with test vectors, helpers, and prototypes for HACE QTest suites.
tests/qtest/aspeed_hace-test.c Refactored to use utility helpers for concise test registration and execution across platforms.
tests/qtest/ast2700-hace-test.c New QTest suite for AST2700 HACE: tests for multiple hash algorithms and address masking.
tests/qtest/aspeed_smc-test.c, tests/qtest/ast2700-smc-test.c Added g_free() to free temporary path strings after unlinking files.
tests/qtest/meson.build Reorganized and extended test source file associations; added AST2700 HACE test to build.

Sequence Diagram(s)

sequenceDiagram
    participant Guest
    participant HACE_Device
    participant SystemMemory

    Note over Guest, HACE_Device: Hash Operation (Direct or SG Mode)
    Guest->>HACE_Device: Write registers to configure hash
    HACE_Device->>SystemMemory: Map source buffer(s) (direct or SG)
    HACE_Device->>HACE_Device: Prepare iovec(s) for hash
    HACE_Device->>HACE_Device: Execute hash (accumulated or non-accumulated)
    HACE_Device->>SystemMemory: Write digest result
    HACE_Device->>Guest: Set IRQ/status, signal completion
Loading
sequenceDiagram
    participant QTest
    participant QEMU
    participant HACE_Device

    QTest->>QEMU: Start VM with test image
    QTest->>QEMU: Write test vector to guest memory
    QTest->>QEMU: Write HACE config registers
    QEMU->>HACE_Device: Emulate hash operation
    HACE_Device->>QEMU: Set status/IRQ
    QTest->>QEMU: Read digest result
    QTest->>QEMU: Assert correctness
Loading

Poem

In the warren of code, a new path we trace,
HACE now hops with 64-bit grace!
Tests abound for every hash,
Dynamic regs—no more static stash.
AST2700 joins the fun,
With QEMU’s engine, hashes run.
🐰✨—another leap, another race!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@legoater
Copy link
Owner Author

@coderabbitai review

Copy link

coderabbitai bot commented May 26, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (7)
hw/arm/aspeed_ast27x0-fc.c (1)

91-96: Improve error handling in NIC configuration loop.

The current loop breaks on the first configuration failure, which may leave some NICs unconfigured. Consider whether this is the intended behavior or if error handling should be improved.

    for (int i = 0; i < sc->macs_num; i++) {
-        if (!qemu_configure_nic_device(DEVICE(&soc->ftgmac100[i]),
-                                       true, NULL)) {
-            break;
-        }
+        bool success = qemu_configure_nic_device(DEVICE(&soc->ftgmac100[i]),
+                                                 true, NULL);
+        if (!success) {
+            warn_report("Failed to configure NIC device %d", i);
+            // Continue configuring remaining NICs or return error based on requirements
+        }
    }
tests/qtest/ast2700-hace-test.c (2)

24-72: Cut repetition – use a helper macro or table-driven loop

Each test wrapper only differs by the helper function invoked. This creates 11 near-identical functions.

A compact pattern keeps the file shorter and reduces the chance of forgetting to add a new variant later:

typedef void (*AlgoFn)(const char *mach, uint64_t base, uint64_t mem);

static struct {
    const char *name;
    AlgoFn fn;
} ast2700_tests[] = {
    { "md5",             aspeed_test_md5 },
    { "sha256",          aspeed_test_sha256 },
    { "sha256_sg",       aspeed_test_sha256_sg },
    ...
};

static void run_algo(gconstpointer user_data)
{
    const AlgoFn fn = user_data;
    fn("-machine ast2700a1-evb", 0x12070000, 0x400000000ULL);
}

and register with:

for (size_t i = 0; i < ARRAY_SIZE(ast2700_tests); ++i) {
    qtest_add_data_func(g_strdup_printf("ast2700/hace/%s", ast2700_tests[i].name),
                        ast2700_tests[i].fn,
                        run_algo);
}

This is optional, yet it noticeably improves maintainability.


79-98: Registration order – non-issue, but mind alphabetical grouping

Tests are currently listed in a quasi-reverse cryptographic-strength order (sha512→sha256→md5). Grouping by algorithm or mode (direct/sg/accum) makes qtest output easier to scan, though this is purely cosmetic.

tests/qtest/aspeed-hace-utils.h (1)

45-48: Avoid unnecessary __packed__ on naturally-aligned structure

AspeedSgList only contains two 32-bit words, which are already naturally aligned on all QEMU host targets. Adding __packed__ disables the compiler’s normal alignment and can generate sub-optimal code on some architectures.

-} __attribute__ ((__packed__));
+};
tests/qtest/aspeed-hace-utils.c (1)

99-107: Minor: avoid heap buffer when tracing large iovecs

hace_iov_hexdump() copies the whole iovec into a temporary buffer even
when tracing is disabled or when the payload is huge. Walking the iovec and
calling hace_hexdump() chunk-by-chunk removes the extra allocation and
keeps memory usage bounded.

Not urgent, but worth streamlining if very large scatter-gather requests are
expected.

tests/qtest/aspeed_hace-test.c (1)

195-236: Register tests via data-driven table to DRY up boiler-plate

The qtest_add_func() calls repeat the same pattern dozens of times,
making future maintenance error-prone. A small table and a tiny helper
would cut ~150 lines:

typedef void (*TestFn)(void);
static struct {
    const char *name;
    TestFn      fn;
} tests[] = {
    { "ast1030/hace/sha512",        test_sha512_ast1030 },
    { "ast1030/hace/sha512_sg",     test_sha512_sg_ast1030 },
    /* … */
};

for (size_t i = 0; i < G_N_ELEMENTS(tests); ++i) {
    qtest_add_func(tests[i].name, tests[i].fn);
}

This keeps the list declarative, helps spot duplicates, and eases adding
new variants.

hw/misc/aspeed_hace.c (1)

401-417: Skip digest write when no digest is produced

In accumulation mode, intermediate chunks call
hash_write_digest_and_unmap_iov() with digest_len == 0. Although the
current address_space_write() bails out early, an explicit guard would
avoid passing a NULL pointer and makes the intent clearer:

-    hash_write_digest_and_unmap_iov(s, iov, iov_idx, digest_buf, digest_len);
+    if (digest_len) {
+        hash_write_digest_and_unmap_iov(s, iov, iov_idx,
+                                        digest_buf, digest_len);
+    } else {
+        /* Still need to un-map the iov */
+        for (; iov_idx > 0; iov_idx--) {
+            address_space_unmap(&s->dram_as, iov[iov_idx - 1].iov_base,
+                                iov[iov_idx - 1].iov_len, false,
+                                iov[iov_idx - 1].iov_len);
+        }
+    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9aa4e3 and 8eaea40.

📒 Files selected for processing (15)
  • docs/system/arm/aspeed.rst (1 hunks)
  • hw/arm/aspeed_ast27x0-fc.c (3 hunks)
  • hw/arm/aspeed_ast27x0.c (3 hunks)
  • hw/arm/fby35.c (1 hunks)
  • hw/intc/aspeed_intc.c (8 hunks)
  • hw/misc/aspeed_hace.c (16 hunks)
  • hw/misc/trace-events (1 hunks)
  • include/hw/misc/aspeed_hace.h (2 hunks)
  • tests/qtest/aspeed-hace-utils.c (1 hunks)
  • tests/qtest/aspeed-hace-utils.h (1 hunks)
  • tests/qtest/aspeed_hace-test.c (1 hunks)
  • tests/qtest/aspeed_smc-test.c (1 hunks)
  • tests/qtest/ast2700-hace-test.c (1 hunks)
  • tests/qtest/ast2700-smc-test.c (1 hunks)
  • tests/qtest/meson.build (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
hw/arm/fby35.c (2)
system/memory.c (1)
  • memory_region_add_subregion (2668-2674)
system/physmem.c (1)
  • get_system_memory (2808-2811)
tests/qtest/ast2700-smc-test.c (1)
rust/qemu-api/src/lib.rs (1)
  • g_free (55-55)
tests/qtest/aspeed_smc-test.c (1)
rust/qemu-api/src/lib.rs (1)
  • g_free (55-55)
hw/arm/aspeed_ast27x0-fc.c (2)
system/memory.c (1)
  • memory_region_add_subregion (2668-2674)
system/physmem.c (1)
  • get_system_memory (2808-2811)
hw/misc/aspeed_hace.c (2)
rust/qemu-api/src/lib.rs (1)
  • g_free (55-55)
system/physmem.c (3)
  • address_space_map (3398-3460)
  • address_space_write (3128-3142)
  • address_space_unmap (3466-3500)
🔇 Additional comments (17)
tests/qtest/aspeed_smc-test.c (1)

231-234: LGTM! Proper memory management for temporary paths.

The addition of g_free() calls for the tmp_path members ensures proper cleanup of memory allocated by g_file_open_tmp(). The placement after the unlink() calls is correct and prevents memory leaks.

tests/qtest/ast2700-smc-test.c (1)

70-70: LGTM! Consistent memory management improvement.

The addition of g_free() for the temporary path ensures proper cleanup of memory allocated by g_file_open_tmp(). This change is consistent with similar improvements made in tests/qtest/aspeed_smc-test.c.

hw/intc/aspeed_intc.c (2)

740-740: LGTM! Consistent implementation access size enforcement.

The addition of .impl.min_access_size = 4 to all ASPEED INTC MemoryRegionOps structures ensures consistent 4-byte minimum access size enforcement at the implementation level. This aligns well with the existing .valid.min_access_size = 4 settings and improves hardware emulation accuracy.

Also applies to: 751-751, 762-762, 773-773, 784-784, 795-795


1004-1005: LGTM! Improved function signature formatting.

The function signature formatting changes enhance code readability by splitting long parameter lists across multiple lines. This follows good coding style practices without changing functionality.

Also applies to: 1073-1074

hw/arm/fby35.c (1)

80-80:

✅ Verification successful

LGTM! Memory region integration follows established pattern.

The addition of the BMC memory region to system memory at address 0 aligns with similar changes in other Aspeed ARM board files and properly integrates the BMC memory into the global system memory map.

Verify that the BMC memory region with size UINT64_MAX doesn't overlap with other memory regions in the system memory map:


🏁 Script executed:

#!/bin/bash
# Description: Check for potential memory region overlaps in FBY35 board
# Expected: No overlapping memory regions should be found

# Search for other memory_region_add_subregion calls in the same file
rg -A 2 -B 2 "memory_region_add_subregion" hw/arm/fby35.c

# Search for similar memory map patterns in other Aspeed boards
rg -A 2 -B 2 "memory_region_add_subregion.*get_system_memory.*0" hw/arm/aspeed*.c

Length of output: 1366


Approve BMC memory region addition—pattern verified

We searched other Aspeed ARM boards (e.g., hw/arm/aspeed_ast27x0-fc.c) and found the same

memory_region_add_subregion(get_system_memory(), 0, &_memory);

pattern with UINT64_MAX sizing. There are no indications of overlapping regions. LGTM!

hw/arm/aspeed_ast27x0-fc.c (2)

71-71: LGTM! Memory region integration follows established pattern.

The addition of the CA35 memory region to system memory at address 0 is consistent with the approach used in other Aspeed board files.


51-51:

✅ Verification successful

Verify the impact of BMC RAM size reduction.

The BMC RAM size has been reduced from 2 GiB to 1 GiB. Ensure this change doesn't break existing firmware or software that expects the larger memory size.


🏁 Script executed:

#!/bin/bash
# Description: Check for references to the old BMC RAM size across the codebase
# Expected: No hard-coded references to 2 GiB BMC RAM size should remain

# Search for references to 2 GiB in Aspeed-related files
rg -i "2.*gib|2\s*\*\s*gib" hw/arm/aspeed*.c

# Search for AST2700FC_BMC_RAM_SIZE usage
rg "AST2700FC_BMC_RAM_SIZE" hw/arm/

Length of output: 786


No remaining hard-coded 2 GiB references for AST2700FC

I verified that AST2700FC_BMC_RAM_SIZE is only defined and used within hw/arm/aspeed_ast27x0-fc.c and there are no leftover hard-coded “2 GiB” values for this variant. Other BMC variants (Fuji, Bletchley) still correctly use 2 GiB.

– hw/arm/aspeed_ast27x0-fc.c: #define AST2700FC_BMC_RAM_SIZE (1 * GiB) and its uses
– hw/arm/aspeed.c: Fuji/Bletchley variants remain at 2 GiB as expected

No further changes required.

hw/arm/aspeed_ast27x0.c (4)

349-351: LGTM! Improved memory write implementation.

The update to use address_space_stl_le with explicit result handling is correct and improves the robustness of the RAM capacity write operation.


26-26:

✅ Verification successful

Verify the impact of IO size reduction.

The AST2700_SOC_IO_SIZE has been reduced. Ensure this change doesn't affect existing device mappings or cause memory layout conflicts.


🏁 Script executed:

#!/bin/bash
# Description: Check the usage of AST2700_SOC_IO_SIZE and verify no memory layout conflicts
# Expected: No conflicts with the reduced IO size

# Find all usages of AST2700_SOC_IO_SIZE
rg "AST2700_SOC_IO_SIZE" hw/arm/

# Check for any hard-coded references to the old size
rg "0x00FE0000|0x01000000" hw/arm/aspeed*.c

Length of output: 674


AST2700_SOC_IO_SIZE reduction verified – no conflicts found

A search for AST2700_SOC_IO_SIZE and hard-coded old sizes across hw/arm/ only returned usages within hw/arm/aspeed_ast27x0.c itself. There are no references to the prior size in other files, so the reduced IO region does not collide with existing mappings.


33-33:

❓ Verification inconclusive

Verify the impact of IOMEM device relocation.

The ASPEED_DEV_IOMEM device has been moved from address 0x00000000 to 0x00020000. This is a significant memory map change that could break existing firmware or software compatibility.


🏁 Script executed:

#!/bin/bash
# Description: Verify the impact of IOMEM device relocation
# Expected: No references to the old address should remain

# Search for references to the old IOMEM address
rg "0x00000000" hw/arm/aspeed*.c

# Check for any firmware or documentation that might reference the old address
rg -i "iomem.*0x00000000|0x00000000.*iomem" docs/ hw/arm/

Length of output: 965


Verify relocation of ASPEED_DEV_IOMEM and remaining 0x00000000 mappings

Moving ASPEED_DEV_IOMEM from 0x00000000 to 0x00020000 is a breaking change. In addition, the following device base addresses still resolve to 0x00000000:

  • hw/arm/aspeed_ast27x0.c:
    [ASPEED_DEV_VBOOTROM] = 0x00000000
  • hw/arm/aspeed_ast27x0-tsp.c & hw/arm/aspeed_ast27x0-ssp.c:
    [ASPEED_DEV_SRAM] = 0x00000000
  • hw/arm/aspeed_ast2600.c & hw/arm/aspeed_ast2400.c:
    [ASPEED_DEV_SPI_BOOT] = 0x00000000
  • hw/arm/aspeed_ast10x0.c:
    [ASPEED_DEV_SRAM] = 0x00000000
  • hw/arm/aspeed.c:
    #define FUJI_BMC_HW_STRAP1 0x00000000
    #define FUJI_BMC_HW_STRAP2 0x00000000
    #define QCOM_DC_SCM_V1_BMC_HW_STRAP1 0x00000000

Please audit all device mappings, linker scripts, firmware blobs, and documentation to ensure no stale references remain and that firmware/software compatibility is maintained.


364-364:

✅ Verification successful

Verify the impact of 4-byte access size constraints.

The addition of .impl.min_access_size = 4 and the constraint of both .valid.min_access_size and .valid.max_access_size to 4 bytes enforces 4-byte aligned access. This could break existing code that uses non-4-byte accesses.

Also applies to: 366-367


🏁 Script executed:

#!/bin/bash
# Description: Check for potential compatibility issues with 4-byte access constraints
# Expected: Verify that all existing access patterns are 4-byte aligned

# Search for other memory region operations that might use different access sizes
rg -A 5 -B 5 "MemoryRegionOps.*aspeed.*ram" hw/

# Check for similar access size constraints in other Aspeed devices
rg "min_access_size.*=.*4|max_access_size.*=.*4" hw/arm/aspeed*.c hw/*/aspeed*.c

Length of output: 4975


4-byte access constraint matches existing Aspeed drivers

A repository-wide search confirms that all Aspeed MemoryRegionOps implementations already restrict accesses to 4 bytes (both in .impl and .valid):

  • hw/arm/aspeed_ast27x0.c (line 364): .impl.min_access_size = 4
  • Similar constraints in hw/timer/aspeed_timer.c, hw/sd/aspeed_sdhci.c, hw/misc/aspeed_xdma.c, hw/misc/aspeed_scu.c, and many others

This addition is consistent with the established pattern and does not introduce new compatibility risks.

tests/qtest/meson.build (3)

215-217: LGTM! Improved test organization and coverage.

The reordering of qtests_aspeed list and addition of aspeed_hace-test and aspeed_smc-test enhances test coverage for ASPEED hardware emulation.


220-220: LGTM! AST2700 HACE test addition.

The addition of ast2700-hace-test to the qtests_aspeed64 list appropriately extends test coverage for the AST2700 platform.


365-368: LGTM! Proper test file mappings.

The addition of test file mappings for the new HACE and SMC tests is correctly structured, properly linking source files with their utility dependencies.

tests/qtest/ast2700-hace-test.c (1)

13-21: Mask constants – double-check high-word coverage

The src_hi, dest_hi, and key_hi masks are limited to 0x00000003 (i.e. two low-order address bits).
If the AST2700 HACE really decodes the full 34-bit address range (as suggested by the 0x400000000 test DMA buffer), you may need to allow the full width of the high dword (8 bits on AST2600, 18 bits here). Please confirm the reference manual and extend the masks accordingly; otherwise some illegal addresses will silently be accepted in the model.

hw/misc/trace-events (1)

305-312: Tracepoint argument/format mismatch guard

The new aspeed_hace_hexdump event passes a char * that presumably points to a pre-formatted hexdump buffer. Beware of large dumps overflowing trace backend line limits; consider truncating or splitting long strings.

Otherwise, argument counts and format specifiers look consistent (bool%d, 64-bit → %" PRIx64 "). No action needed.

tests/qtest/aspeed-hace-utils.c (1)

223-236: ⚠️ Potential issue

iov_len truncation breaks later un-mapping

When padding is detected you overwrite iov[0].iov_len with pad_offset.
address_space_unmap() later receives this shortened length, although the
buffer was mapped with the original plen. For RAM pointers this only
skips cache maintenance, but for bounce-buffers the mismatch can leave part
of the allocation dirty or leaked.

-            iov[0].iov_len = pad_offset;
+            /*
+             * Keep the original mapping length for a correct un-map, but
+             * expose only the meaningful payload to the hash engine.
+             */
+            uint32_t payload_len       = pad_offset;
+            uint32_t mapping_len_full  = plen;
+
+            iov[0].iov_len             = payload_len;
+            /* store the full length in a side array or reuse `plen`
+             * when calling address_space_unmap()
+             */

Consider storing the mapping length in a parallel array or an auxiliary
field so the exact size passed to address_space_unmap() always matches the
one returned by address_space_map().

Likely an incorrect or invalid review comment.

@@ -1,4 +1,4 @@
Aspeed family boards (``ast2500-evb``, ``ast2600-evb``, ``ast2700-evb``, ``ast2700fc``, ``bletchley-bmc``, ``fuji-bmc``, ``fby35-bmc``, ``fp5280g2-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``qcom-dc-scm-v1-bmc``, ``qcom-firework-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``sonorapass-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``)
Aspeed family boards (``ast2500-evb``, ``ast2600-evb``, ``ast2700-evb``, ``bletchley-bmc``, ``fuji-bmc``, ``fby35-bmc``, ``fp5280g2-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``qcom-dc-scm-v1-bmc``, ``qcom-firework-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``sonorapass-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistency between introduction and detailed documentation.

The ast2700fc board appears to have been removed from the introductory list of supported boards, but it's still documented later in the file at line 258. This creates an inconsistency that may confuse users.

Either:

  1. Remove all references to ast2700fc if it's no longer supported, or
  2. Add it back to the introductory list if it remains supported
-Aspeed family boards (``ast2500-evb``, ``ast2600-evb``, ``ast2700-evb``, ``bletchley-bmc``, ``fuji-bmc``, ``fby35-bmc``, ``fp5280g2-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``qcom-dc-scm-v1-bmc``, ``qcom-firework-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``sonorapass-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``)
+Aspeed family boards (``ast2500-evb``, ``ast2600-evb``, ``ast2700-evb``, ``ast2700fc``, ``bletchley-bmc``, ``fuji-bmc``, ``fby35-bmc``, ``fp5280g2-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``qcom-dc-scm-v1-bmc``, ``qcom-firework-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``sonorapass-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Aspeed family boards (``ast2500-evb``, ``ast2600-evb``, ``ast2700-evb``, ``bletchley-bmc``, ``fuji-bmc``, ``fby35-bmc``, ``fp5280g2-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``qcom-dc-scm-v1-bmc``, ``qcom-firework-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``sonorapass-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``)
-Aspeed family boards (``ast2500-evb``, ``ast2600-evb``, ``ast2700-evb``, ``bletchley-bmc``, ``fuji-bmc``, ``fby35-bmc``, ``fp5280g2-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``qcom-dc-scm-v1-bmc``, ``qcom-firework-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``sonorapass-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``)
+Aspeed family boards (``ast2500-evb``, ``ast2600-evb``, ``ast2700-evb``, ``ast2700fc``, ``bletchley-bmc``, ``fuji-bmc``, ``fby35-bmc``, ``fp5280g2-bmc``, ``g220a-bmc``, ``palmetto-bmc``, ``qcom-dc-scm-v1-bmc``, ``qcom-firework-bmc``, ``quanta-q71l-bmc``, ``rainier-bmc``, ``romulus-bmc``, ``sonorapass-bmc``, ``supermicrox11-bmc``, ``supermicrox11spi-bmc``, ``tiogapass-bmc``, ``witherspoon-bmc``, ``yosemitev2-bmc``)
🤖 Prompt for AI Agents
In docs/system/arm/aspeed.rst at lines 1 and 258, there is an inconsistency
where the ast2700fc board is missing from the introductory list but still
documented later. To fix this, either remove all mentions of ast2700fc from the
entire file if it is no longer supported, or add ast2700fc back to the
introductory list at line 1 if it is still supported, ensuring consistency
throughout the document.

Comment on lines 74 to 78
static void test_addresses_ast2700(void)
{
aspeed_test_addresses("-machine ast2700a1-evb", 0x12070000, &as2700_masks);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Address-mask test – supply 64-bit DMA address above 4 GiB

aspeed_test_addresses is invoked with 0x12070000 (below 4 GiB).
To really validate 64-bit masking logic, consider also probing an address such as 0x12070000 + 0x1_0000_0000ULL, or add a second case exercising the high dword.
This catches regressions that only appear when bit > 31 is set.

🤖 Prompt for AI Agents
In tests/qtest/ast2700-hace-test.c around lines 74 to 78, the test uses a 32-bit
DMA address below 4 GiB, which does not fully validate 64-bit masking logic.
Modify the test to also call aspeed_test_addresses with an address above 4 GiB
by adding 0x1_0000_0000ULL to the current address or add a second test case
using such a high 64-bit address to ensure coverage of bits above 31.

Comment on lines 33 to 35
uint32_t *regs;
uint32_t total_req_len;
uint32_t iov_count;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Dynamic regs array – remember allocation & cleanup

uint32_t *regs; replaces the fixed array. Ensure that:

  1. instance_init allocates nr_regs * sizeof(uint32_t) with g_new0() or similar.
  2. instance_finalize/unrealize frees it with g_free().

Missing cleanup will leak on every VM reset.

🤖 Prompt for AI Agents
In include/hw/misc/aspeed_hace.h around lines 33 to 35, the pointer uint32_t
*regs replaces a fixed array but lacks memory management. Modify the
instance_init function to allocate memory for regs using g_new0() with size
nr_regs * sizeof(uint32_t), and update instance_finalize or unrealize to free
this memory using g_free() to prevent memory leaks on VM resets.

Comment on lines 46 to 57
const MemoryRegionOps *reg_ops;
uint32_t src_mask;
uint32_t dest_mask;
uint32_t key_mask;
uint32_t hash_mask;
uint64_t nr_regs;
bool raise_crypt_interrupt_workaround;
uint32_t src_hi_mask;
uint32_t dest_hi_mask;
uint32_t key_hi_mask;
bool has_dma64;
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Class fields – document invariants

The class now mixes run-time (masks, has_dma64) with “type” constants. Add doc-comments or move per-SoC values into the type registration helper so subclasses can never forget to initialise the new fields.

Example (in aspeed_hace_ast2400_class_init):

ahc->has_dma64 = false;
ahc->src_hi_mask = 0;
...

Without this, older SoCs may inherit uninitialised garbage and silently accept 64-bit transfers.

🤖 Prompt for AI Agents
In include/hw/misc/aspeed_hace.h around lines 46 to 57, the struct fields mix
runtime masks and type constants without clear documentation or initialization,
risking uninitialized values for older SoCs. Add doc-comments to clarify which
fields are runtime versus type constants, and move per-SoC constant
initializations into the type registration helper functions (e.g.,
aspeed_hace_ast2400_class_init) to ensure all fields like has_dma64 and
src_hi_mask are explicitly initialized for each SoC subclass.

Comment on lines 296 to 306
if (has_padding(s, &iov[iov_idx], plen, &total_msg_len,
&pad_offset)) {
/* Padding being present indicates the final request */
*acc_final_request = true;
iov[iov_idx].iov_len = pad_offset;
} else {
iov[i].iov_len = plen;
iov[iov_idx].iov_len = plen;
}
} else {
iov[iov_idx].iov_len = plen;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Same length-mismatch issue in SG path

hash_prepare_sg_iov() also rewrites iov[i].iov_len after mapping (to
strip the padding). The buffer is later unmapped with the shortened length
in hash_write_digest_and_unmap_iov(), risking partial un-map of a bounce
buffer.

Reuse the fix proposed for the direct path: keep the mapping length for
un-map while presenting the truncated length to the hash engine.

🤖 Prompt for AI Agents
In hw/misc/aspeed_hace.c around lines 296 to 306, the code modifies
iov[iov_idx].iov_len to a truncated length after detecting padding, which causes
the unmap operation to use this shortened length and risks partially unmapping
the bounce buffer. To fix this, preserve the original mapping length for the
unmap operation by storing it separately before truncating iov[iov_idx].iov_len
for the hash engine, ensuring the full buffer is unmapped correctly while still
presenting the truncated length during hashing.

legoater pushed a commit that referenced this pull request May 26, 2025
ASAN spotted a leaking string in machine_set_loadparm():

Direct leak of 9 byte(s) in 1 object(s) allocated from:
    #0 0x560ffb5bb379 in malloc ../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x7f1aca926518 in g_malloc ../glib/gmem.c:106
    #2 0x7f1aca94113e in g_strdup ../glib/gstrfuncs.c:364
    #3 0x560ffc8afbf9 in qobject_input_type_str ../qapi/qobject-input-visitor.c:542:12
    #4 0x560ffc8a80ff in visit_type_str ../qapi/qapi-visit-core.c:349:10
    #5 0x560ffbe6053a in machine_set_loadparm ../hw/s390x/s390-virtio-ccw.c:802:10
    #6 0x560ffc0c5e52 in object_property_set ../qom/object.c:1450:5
    #7 0x560ffc0d4175 in object_property_set_qobject ../qom/qom-qobject.c:28:10
    #8 0x560ffc0c6004 in object_property_set_str ../qom/object.c:1458:15
    #9 0x560ffbe2ae60 in update_machine_ipl_properties ../hw/s390x/ipl.c:569:9
    #10 0x560ffbe2aa65 in s390_ipl_update_diag308 ../hw/s390x/ipl.c:594:5
    qemu#11 0x560ffbdee132 in handle_diag_308 ../target/s390x/diag.c:147:9
    qemu#12 0x560ffbebb956 in helper_diag ../target/s390x/tcg/misc_helper.c:137:9
    qemu#13 0x7f1a3c51c730  (/memfd:tcg-jit (deleted)+0x39730)

Cc: [email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Fixes: 1fd396e ("s390x: Register TYPE_S390_CCW_MACHINE properties as class properties")
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
legoater pushed a commit that referenced this pull request May 27, 2025
The released fix for this CVE:

  f6b0de5 ("9pfs: prevent opening special files (CVE-2023-2861)")

caused a regression with security_model=passthrough. When handling a
'Tmknod' request there was a side effect that 'Tmknod' request could fail
as 9p server was trying to adjust permissions:

  #6  close_if_special_file (fd=30) at ../hw/9pfs/9p-util.h:140
  #7  openat_file (mode=<optimized out>, flags=2228224,
      name=<optimized out>, dirfd=<optimized out>) at
      ../hw/9pfs/9p-util.h:181
  #8  fchmodat_nofollow (dirfd=dirfd@entry=31,
      name=name@entry=0x5555577ea6e0 "mysocket", mode=493) at
      ../hw/9pfs/9p-local.c:360
  #9  local_set_cred_passthrough (credp=0x7ffbbc4ace10, name=0x5555577ea6e0
      "mysocket", dirfd=31, fs_ctx=0x55555811f528) at
      ../hw/9pfs/9p-local.c:457
  #10 local_mknod (fs_ctx=0x55555811f528, dir_path=<optimized out>,
      name=0x5555577ea6e0 "mysocket", credp=0x7ffbbc4ace10) at
      ../hw/9pfs/9p-local.c:702
  qemu#11 v9fs_co_mknod (pdu=pdu@entry=0x555558121140,
      fidp=fidp@entry=0x5555574c46c0, name=name@entry=0x7ffbbc4aced0,
      uid=1000, gid=1000, dev=<optimized out>, mode=49645,
      stbuf=0x7ffbbc4acef0) at ../hw/9pfs/cofs.c:205
  qemu#12 v9fs_mknod (opaque=0x555558121140) at ../hw/9pfs/9p.c:3711

That's because server was opening the special file to adjust permissions,
however it was using O_PATH and it would have not returned the file
descriptor to guest. So the call to close_if_special_file() on that branch
was incorrect.

Let's lift the restriction introduced by f6b0de5 such that it would
allow to open special files on host if O_PATH flag is supplied, not only
for 9p server's own operations as described above, but also for any client
'Topen' request.

It is safe to allow opening special files with O_PATH on host, because
O_PATH only allows path based operations on the resulting file descriptor
and prevents I/O such as read() and write() on that file descriptor.

Fixes: f6b0de5 ("9pfs: prevent opening special files (CVE-2023-2861)")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2337
Reported-by: Dirk Herrendorfer <[email protected]>
Signed-off-by: Christian Schoenebeck <[email protected]>
Reviewed-by: Greg Kurz <[email protected]>
Tested-by: Dirk Herrendorfer <[email protected]>
Message-Id: <[email protected]>
(cherry picked from commit d06a9d8)
Signed-off-by: Michael Tokarev <[email protected]>
legoater pushed a commit that referenced this pull request May 27, 2025
Commit a55ae46 ("s390: move css_migration_enabled from machine to
css.c") disabled CSS migration globally instead of doing it
per-instance.

CC: Paolo Bonzini <[email protected]>
CC: [email protected] #9.1
Fixes: a55ae46 ("s390: move css_migration_enabled from machine to css.c")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2704
Reviewed-by: Thomas Huth <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
(cherry picked from commit c76ee1f)
Signed-off-by: Michael Tokarev <[email protected]>
legoater pushed a commit that referenced this pull request May 27, 2025
When compression is enabled on the migration channel and
the pages processed are all zero pages, these pages will
not be sent and updated on the target side, resulting in
incorrect memory data on the source and target sides.

The root cause is that all compression methods call
multifd_send_prepare_common to determine whether to compress
dirty pages, but multifd_send_prepare_common does not update
the IOV of MultiFDPacket_t when all dirty pages are zero pages.

The solution is to always update the IOV of MultiFDPacket_t
regardless of whether the dirty pages are all zero pages.

Fixes: 303e6f5 ("migration/multifd: Implement zero page transmission on the multifd thread.")
Cc: [email protected] #9.0+
Signed-off-by: Yuan Liu <[email protected]>
Reviewed-by: Jason Zeng <[email protected]>
Reviewed-by: Peter Xu <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
(cherry picked from commit cdc3970)
Signed-off-by: Michael Tokarev <[email protected]>
legoater pushed a commit that referenced this pull request May 27, 2025
ASAN detected a leak when running the ahci-test
/ahci/io/dma/lba28/retry:

Direct leak of 35 byte(s) in 1 object(s) allocated from:
    #0 in malloc
    #1 in __vasprintf_internal
    #2 in vasprintf
    #3 in g_vasprintf
    #4 in g_strdup_vprintf
    #5 in g_strdup_printf
    #6 in object_get_canonical_path ../qom/object.c:2096:19
    #7 in blk_get_attached_dev_id_or_path ../block/block-backend.c:1033:12
    #8 in blk_get_attached_dev_path ../block/block-backend.c:1047:12
    #9 in send_qmp_error_event ../block/block-backend.c:2140:36
    #10 in blk_error_action ../block/block-backend.c:2172:9
    qemu#11 in ide_handle_rw_error ../hw/ide/core.c:875:5
    qemu#12 in ide_dma_cb ../hw/ide/core.c:894:13
    qemu#13 in dma_complete ../system/dma-helpers.c:107:9
    qemu#14 in dma_blk_cb ../system/dma-helpers.c:129:9
    qemu#15 in blk_aio_complete ../block/block-backend.c:1552:9
    qemu#16 in blk_aio_write_entry ../block/block-backend.c:1619:5
    qemu#17 in coroutine_trampoline ../util/coroutine-ucontext.c:175:9

Plug the leak by freeing the device path string.

Signed-off-by: Fabiano Rosas <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
[PMD: Use g_autofree]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
(cherry picked from commit 23ea425)
Signed-off-by: Michael Tokarev <[email protected]>
legoater pushed a commit that referenced this pull request May 27, 2025
ASAN spotted a leaking string in machine_set_loadparm():

Direct leak of 9 byte(s) in 1 object(s) allocated from:
    #0 0x560ffb5bb379 in malloc ../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x7f1aca926518 in g_malloc ../glib/gmem.c:106
    #2 0x7f1aca94113e in g_strdup ../glib/gstrfuncs.c:364
    #3 0x560ffc8afbf9 in qobject_input_type_str ../qapi/qobject-input-visitor.c:542:12
    #4 0x560ffc8a80ff in visit_type_str ../qapi/qapi-visit-core.c:349:10
    #5 0x560ffbe6053a in machine_set_loadparm ../hw/s390x/s390-virtio-ccw.c:802:10
    #6 0x560ffc0c5e52 in object_property_set ../qom/object.c:1450:5
    #7 0x560ffc0d4175 in object_property_set_qobject ../qom/qom-qobject.c:28:10
    #8 0x560ffc0c6004 in object_property_set_str ../qom/object.c:1458:15
    #9 0x560ffbe2ae60 in update_machine_ipl_properties ../hw/s390x/ipl.c:569:9
    #10 0x560ffbe2aa65 in s390_ipl_update_diag308 ../hw/s390x/ipl.c:594:5
    qemu#11 0x560ffbdee132 in handle_diag_308 ../target/s390x/diag.c:147:9
    qemu#12 0x560ffbebb956 in helper_diag ../target/s390x/tcg/misc_helper.c:137:9
    qemu#13 0x7f1a3c51c730  (/memfd:tcg-jit (deleted)+0x39730)

Cc: [email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Fixes: 1fd396e ("s390x: Register TYPE_S390_CCW_MACHINE properties as class properties")
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
(cherry picked from commit bdf12f2)
Signed-off-by: Michael Tokarev <[email protected]>
legoater pushed a commit that referenced this pull request May 27, 2025
When the creds->username property is set we allocate memory
for it in qcrypto_tls_creds_psk_prop_set_username(), but
we never free this when the QCryptoTLSCredsPSK is destroyed.
Free the memory in finalize.

This fixes a LeakSanitizer complaint in migration-test:

$ (cd build/asan; ASAN_OPTIONS="fast_unwind_on_malloc=0" QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test --tap -k -p /x86_64/migration/precopy/unix/tls/psk)

=================================================================
==3867512==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 5 byte(s) in 1 object(s) allocated from:
    #0 0x5624e5c99dee in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-x86_64+0x218edee) (BuildId: a9e623fa1009a9435c0142c037cd7b8c1ad04ce3)
    #1 0x7fb199ae9738 in g_malloc debian/build/deb/../../../glib/gmem.c:128:13
    #2 0x7fb199afe583 in g_strdup debian/build/deb/../../../glib/gstrfuncs.c:361:17
    #3 0x5624e82ea919 in qcrypto_tls_creds_psk_prop_set_username /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../crypto/tlscredspsk.c:255:23
    #4 0x5624e812c6b5 in property_set_str /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object.c:2277:5
    #5 0x5624e8125ce5 in object_property_set /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object.c:1463:5
    #6 0x5624e8136e7c in object_set_properties_from_qdict /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object_interfaces.c:55:14
    #7 0x5624e81372d2 in user_creatable_add_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object_interfaces.c:112:5
    #8 0x5624e8137964 in user_creatable_add_qapi /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/object_interfaces.c:157:11
    #9 0x5624e891ba3c in qmp_object_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qom/qom-qmp-cmds.c:227:5
    #10 0x5624e8af9118 in qmp_marshal_object_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qapi/qapi-commands-qom.c:337:5
    qemu#11 0x5624e8bd1d49 in do_qmp_dispatch_bh /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../qapi/qmp-dispatch.c:128:5
    qemu#12 0x5624e8cb2531 in aio_bh_call /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/async.c:171:5
    qemu#13 0x5624e8cb340c in aio_bh_poll /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/async.c:218:13
    qemu#14 0x5624e8c0be98 in aio_dispatch /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/aio-posix.c:423:5
    qemu#15 0x5624e8cba3ce in aio_ctx_dispatch /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/async.c:360:5
    qemu#16 0x7fb199ae0d3a in g_main_dispatch debian/build/deb/../../../glib/gmain.c:3419:28
    qemu#17 0x7fb199ae0d3a in g_main_context_dispatch debian/build/deb/../../../glib/gmain.c:4137:7
    qemu#18 0x5624e8cbe1d9 in glib_pollfds_poll /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/main-loop.c:287:9
    qemu#19 0x5624e8cbcb13 in os_host_main_loop_wait /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/main-loop.c:310:5
    qemu#20 0x5624e8cbc6dc in main_loop_wait /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../util/main-loop.c:589:11
    qemu#21 0x5624e6f3f917 in qemu_main_loop /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../system/runstate.c:801:9
    qemu#22 0x5624e893379c in qemu_default_main /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../system/main.c:37:14
    qemu#23 0x5624e89337e7 in main /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/../../system/main.c:48:12
    qemu#24 0x7fb197972d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    qemu#25 0x7fb197972e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    qemu#26 0x5624e5c16fa4 in _start (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/asan/qemu-system-x86_64+0x210bfa4) (BuildId: a9e623fa1009a9435c0142c037cd7b8c1ad04ce3)

SUMMARY: AddressSanitizer: 5 byte(s) leaked in 1 allocation(s).

Cc: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
(cherry picked from commit 87e012f)
Signed-off-by: Michael Tokarev <[email protected]>
legoater pushed a commit that referenced this pull request May 27, 2025
Allow overlapping request by removing the assert that made it
impossible. There are only two callers:

1. block_copy_task_create()

It already asserts the very same condition before calling
reqlist_init_req().

2. cbw_snapshot_read_lock()

There is no need to have read requests be non-overlapping in
copy-before-write when used for snapshot-access. In fact, there was no
protection against two callers of cbw_snapshot_read_lock() calling
reqlist_init_req() with overlapping ranges and this could lead to an
assertion failure [1].

In particular, with the reproducer script below [0], two
cbw_co_snapshot_block_status() callers could race, with the second
calling reqlist_init_req() before the first one finishes and removes
its conflicting request.

[0]:

> #!/bin/bash -e
> dd if=/dev/urandom of=/tmp/disk.raw bs=1M count=1024
> ./qemu-img create /tmp/fleecing.raw -f raw 1G
> (
> ./qemu-system-x86_64 --qmp stdio \
> --blockdev raw,node-name=node0,file.driver=file,file.filename=/tmp/disk.raw \
> --blockdev raw,node-name=node1,file.driver=file,file.filename=/tmp/fleecing.raw \
> <<EOF
> {"execute": "qmp_capabilities"}
> {"execute": "blockdev-add", "arguments": { "driver": "copy-before-write", "file": "node0", "target": "node1", "node-name": "node3" } }
> {"execute": "blockdev-add", "arguments": { "driver": "snapshot-access", "file": "node3", "node-name": "snap0" } }
> {"execute": "nbd-server-start", "arguments": {"addr": { "type": "unix", "data": { "path": "/tmp/nbd.socket" } } } }
> {"execute": "block-export-add", "arguments": {"id": "exp0", "node-name": "snap0", "type": "nbd", "name": "exp0"}}
> EOF
> ) &
> sleep 5
> while true; do
> ./qemu-nbd -d /dev/nbd0
> ./qemu-nbd -c /dev/nbd0 nbd:unix:/tmp/nbd.socket:exportname=exp0 -f raw -r
> nbdinfo --map 'nbd+unix:///exp0?socket=/tmp/nbd.socket'
> done

[1]:

> #5  0x000071e5f0088eb2 in __GI___assert_fail (...) at ./assert/assert.c:101
> #6  0x0000615285438017 in reqlist_init_req (...) at ../block/reqlist.c:23
> #7  0x00006152853e2d98 in cbw_snapshot_read_lock (...) at ../block/copy-before-write.c:237
> #8  0x00006152853e3068 in cbw_co_snapshot_block_status (...) at ../block/copy-before-write.c:304
> #9  0x00006152853f4d22 in bdrv_co_snapshot_block_status (...) at ../block/io.c:3726
> #10 0x000061528543a63e in snapshot_access_co_block_status (...) at ../block/snapshot-access.c:48
> qemu#11 0x00006152853f1a0a in bdrv_co_do_block_status (...) at ../block/io.c:2474
> qemu#12 0x00006152853f2016 in bdrv_co_common_block_status_above (...) at ../block/io.c:2652
> qemu#13 0x00006152853f22cf in bdrv_co_block_status_above (...) at ../block/io.c:2732
> qemu#14 0x00006152853d9a86 in blk_co_block_status_above (...) at ../block/block-backend.c:1473
> qemu#15 0x000061528538da6c in blockstatus_to_extents (...) at ../nbd/server.c:2374
> qemu#16 0x000061528538deb1 in nbd_co_send_block_status (...) at ../nbd/server.c:2481
> qemu#17 0x000061528538f424 in nbd_handle_request (...) at ../nbd/server.c:2978
> qemu#18 0x000061528538f906 in nbd_trip (...) at ../nbd/server.c:3121
> qemu#19 0x00006152855a7caf in coroutine_trampoline (...) at ../util/coroutine-ucontext.c:175

Cc: [email protected]
Suggested-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Fiona Ebner <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
(cherry picked from commit 6475155)
Signed-off-by: Michael Tokarev <[email protected]>
legoater pushed a commit that referenced this pull request May 27, 2025
In regime_is_user() we assert if we're passed an ARMMMUIdx_E10_*
mmuidx value. This used to make sense because we only used this
function in ptw.c and would never use it on this kind of stage 1+2
mmuidx, only for an individual stage 1 or stage 2 mmuidx.

However, when we implemented FEAT_E0PD we added a callsite in
aa64_va_parameters(), which means this can now be called for
stage 1+2 mmuidx values if the guest sets the TCG_ELX.{E0PD0,E0PD1}
bits to enable use of the feature. This will then result in
an assertion failure later, for instance on a TLBI operation:

#6  0x00007ffff6d0e70f in g_assertion_message_expr
    (domain=0x0, file=0x55555676eeba "../../target/arm/internals.h", line=978, func=0x555556771d48 <__func__.5> "regime_is_user", expr=<optimised out>)
    at ../../../glib/gtestutils.c:3279
#7  0x0000555555f286d2 in regime_is_user (env=0x555557f2fe00, mmu_idx=ARMMMUIdx_E10_0) at ../../target/arm/internals.h:978
#8  0x0000555555f3e31c in aa64_va_parameters (env=0x555557f2fe00, va=18446744073709551615, mmu_idx=ARMMMUIdx_E10_0, data=true, el1_is_aa32=false)
    at ../../target/arm/helper.c:12048
#9  0x0000555555f3163b in tlbi_aa64_get_range (env=0x555557f2fe00, mmuidx=ARMMMUIdx_E10_0, value=106721347371041) at ../../target/arm/helper.c:5214
#10 0x0000555555f317e8 in do_rvae_write (env=0x555557f2fe00, value=106721347371041, idxmap=21, synced=true) at ../../target/arm/helper.c:5260
qemu#11 0x0000555555f31925 in tlbi_aa64_rvae1is_write (env=0x555557f2fe00, ri=0x555557fbeae0, value=106721347371041) at ../../target/arm/helper.c:5302
qemu#12 0x0000555556036f8f in helper_set_cp_reg64 (env=0x555557f2fe00, rip=0x555557fbeae0, value=106721347371041) at ../../target/arm/tcg/op_helper.c:965

Since we do know whether these mmuidx values are for usermode
or not, we can easily make regime_is_user() handle them:
ARMMMUIdx_E10_0 is user, and the other two are not.

Cc: [email protected]
Fixes: e4c93e4 ("target/arm: Implement FEAT_E0PD")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Tested-by: Alex Bennée <[email protected]>
Message-id: [email protected]
(cherry picked from commit 1505b65)
Signed-off-by: Michael Tokarev <[email protected]>
legoater pushed a commit that referenced this pull request May 27, 2025
ASAN spotted a leaking string in machine_set_loadparm():

Direct leak of 9 byte(s) in 1 object(s) allocated from:
    #0 0x560ffb5bb379 in malloc ../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x7f1aca926518 in g_malloc ../glib/gmem.c:106
    #2 0x7f1aca94113e in g_strdup ../glib/gstrfuncs.c:364
    #3 0x560ffc8afbf9 in qobject_input_type_str ../qapi/qobject-input-visitor.c:542:12
    #4 0x560ffc8a80ff in visit_type_str ../qapi/qapi-visit-core.c:349:10
    #5 0x560ffbe6053a in machine_set_loadparm ../hw/s390x/s390-virtio-ccw.c:802:10
    #6 0x560ffc0c5e52 in object_property_set ../qom/object.c:1450:5
    #7 0x560ffc0d4175 in object_property_set_qobject ../qom/qom-qobject.c:28:10
    #8 0x560ffc0c6004 in object_property_set_str ../qom/object.c:1458:15
    #9 0x560ffbe2ae60 in update_machine_ipl_properties ../hw/s390x/ipl.c:569:9
    #10 0x560ffbe2aa65 in s390_ipl_update_diag308 ../hw/s390x/ipl.c:594:5
    qemu#11 0x560ffbdee132 in handle_diag_308 ../target/s390x/diag.c:147:9
    qemu#12 0x560ffbebb956 in helper_diag ../target/s390x/tcg/misc_helper.c:137:9
    qemu#13 0x7f1a3c51c730  (/memfd:tcg-jit (deleted)+0x39730)

Cc: [email protected]
Signed-off-by: Fabiano Rosas <[email protected]>
Message-ID: <[email protected]>
Fixes: 1fd396e ("s390x: Register TYPE_S390_CCW_MACHINE properties as class properties")
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
(cherry picked from commit bdf12f2)
Signed-off-by: Michael Tokarev <[email protected]>
@legoater legoater force-pushed the aspeed-next branch 2 times, most recently from b67db1c to 7b27524 Compare June 20, 2025 08:02
@legoater legoater force-pushed the aspeed-next branch 3 times, most recently from 91210b3 to 116bf24 Compare July 3, 2025 11:42
@legoater legoater force-pushed the aspeed-next branch 3 times, most recently from 7cc2f95 to 13ed972 Compare August 4, 2025 08:31
legoater pushed a commit that referenced this pull request Sep 1, 2025
In stm32f250_soc_initfn() we mostly use the standard pattern
for child objects of calling object_initialize_child(). However
for s->adc_irqs we call object_new() and then later qdev_realize(),
and we never unref the object on deinit. This causes a leak,
detected by ASAN on the device-introspect-test:

Indirect leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x5b9fc4789de3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-arm+0x21f1de3) (BuildId: 267a2619a026ed91c78a07b1eb2ef15381538efe)
    #1 0x740de3f28b09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #2 0x740de3f3e4d8 in g_strdup (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x784d8) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #3 0x5b9fc70159e1 in g_strdup_inline /usr/include/glib-2.0/glib/gstrfuncs.h:321:10
    #4 0x5b9fc70159e1 in object_property_try_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:1276:18
    #5 0x5b9fc7015f94 in object_property_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:1294:12
    #6 0x5b9fc701b900 in object_add_link_prop /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:2021:10
    #7 0x5b9fc701b3fc in object_property_add_link /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:2037:12
    #8 0x5b9fc4c299fb in qdev_init_gpio_out_named /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/gpio.c:90:9
    #9 0x5b9fc4c29b26 in qdev_init_gpio_out /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/gpio.c:101:5
    #10 0x5b9fc4c0f77a in or_irq_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/or-irq.c:70:5
    qemu#11 0x5b9fc70257e1 in object_init_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:428:9
    qemu#12 0x5b9fc700cd4b in object_initialize_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:570:5
    qemu#13 0x5b9fc700e66d in object_new_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:774:5
    qemu#14 0x5b9fc700e750 in object_new /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:789:12
    qemu#15 0x5b9fc68b2162 in stm32f205_soc_initfn /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/arm/stm32f205_soc.c:69:26

Switch to using object_initialize_child() like all our
other child objects for this SoC object.

Cc: [email protected]
Fixes: b63041c ("STM32F205: Connect the ADC devices")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
legoater pushed a commit that referenced this pull request Sep 8, 2025
In pca9554_set_pin() we have a string property which we parse in
order to set some non-string fields in the device state.  So we call
visit_type_str(), passing it the address of the local variable
state_str.

visit_type_str() will allocate a new copy of the string; we
never free this string, so the result is a memory leak, detected
by ASAN during a "make check" run:

Direct leak of 5 byte(s) in 1 object(s) allocated from:
    #0 0x5d605212ede3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-arm+0x21f1de3) (
BuildId: 3d5373c89317f58bfcd191a33988c7347714be14)
    #1 0x7f7edea57b09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b68282
9a6913cf682d75)
    #2 0x7f7edea6d4d8 in g_strdup (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x784d8) (BuildId: 1eb6131419edb83b2178b68282
9a6913cf682d75)
    #3 0x5d6055289a91 in g_strdup_inline /usr/include/glib-2.0/glib/gstrfuncs.h:321:10
    #4 0x5d6055289a91 in qobject_input_type_str /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qapi/qo
bject-input-visitor.c:542:12
    #5 0x5d605528479c in visit_type_str /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qapi/qapi-visit
-core.c:349:10
    #6 0x5d60528bdd87 in pca9554_set_pin /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/gpio/pca9554.c:179:10
    #7 0x5d60549bcbbb in object_property_set /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:1450:5
    #8 0x5d60549d2055 in object_property_set_qobject /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/qom-qobject.c:28:10
    #9 0x5d60549bcdf1 in object_property_set_str /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:1458:15
    #10 0x5d605439d077 in gb200nvl_bmc_i2c_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/arm/aspeed.c:1267:5
    qemu#11 0x5d60543a3bbc in aspeed_machine_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/arm/aspeed.c:493:9

Make the state_str g_autofree, so that we will always free
it, on both error-exit and success codepaths.

Cc: [email protected]
Fixes: de0c7d5 ("misc: Add a pca9554 GPIO device model")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Glenn Miles <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
legoater pushed a commit that referenced this pull request Sep 10, 2025
In stm32f250_soc_initfn() we mostly use the standard pattern
for child objects of calling object_initialize_child(). However
for s->adc_irqs we call object_new() and then later qdev_realize(),
and we never unref the object on deinit. This causes a leak,
detected by ASAN on the device-introspect-test:

Indirect leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x5b9fc4789de3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-arm+0x21f1de3) (BuildId: 267a2619a026ed91c78a07b1eb2ef15381538efe)
    #1 0x740de3f28b09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #2 0x740de3f3e4d8 in g_strdup (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x784d8) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #3 0x5b9fc70159e1 in g_strdup_inline /usr/include/glib-2.0/glib/gstrfuncs.h:321:10
    #4 0x5b9fc70159e1 in object_property_try_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:1276:18
    #5 0x5b9fc7015f94 in object_property_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:1294:12
    #6 0x5b9fc701b900 in object_add_link_prop /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:2021:10
    #7 0x5b9fc701b3fc in object_property_add_link /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:2037:12
    #8 0x5b9fc4c299fb in qdev_init_gpio_out_named /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/gpio.c:90:9
    #9 0x5b9fc4c29b26 in qdev_init_gpio_out /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/gpio.c:101:5
    #10 0x5b9fc4c0f77a in or_irq_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/or-irq.c:70:5
    qemu#11 0x5b9fc70257e1 in object_init_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:428:9
    qemu#12 0x5b9fc700cd4b in object_initialize_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:570:5
    qemu#13 0x5b9fc700e66d in object_new_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:774:5
    qemu#14 0x5b9fc700e750 in object_new /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:789:12
    qemu#15 0x5b9fc68b2162 in stm32f205_soc_initfn /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/arm/stm32f205_soc.c:69:26

Switch to using object_initialize_child() like all our
other child objects for this SoC object.

Cc: [email protected]
Fixes: b63041c ("STM32F205: Connect the ADC devices")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
(cherry picked from commit 2e27650)
(Mjt: adjust for 7.2, for before qemu_or_irq rename to OrIRQState)
Signed-off-by: Michael Tokarev <[email protected]>
legoater pushed a commit that referenced this pull request Sep 10, 2025
In stm32f250_soc_initfn() we mostly use the standard pattern
for child objects of calling object_initialize_child(). However
for s->adc_irqs we call object_new() and then later qdev_realize(),
and we never unref the object on deinit. This causes a leak,
detected by ASAN on the device-introspect-test:

Indirect leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x5b9fc4789de3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-arm+0x21f1de3) (BuildId: 267a2619a026ed91c78a07b1eb2ef15381538efe)
    #1 0x740de3f28b09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #2 0x740de3f3e4d8 in g_strdup (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x784d8) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #3 0x5b9fc70159e1 in g_strdup_inline /usr/include/glib-2.0/glib/gstrfuncs.h:321:10
    #4 0x5b9fc70159e1 in object_property_try_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:1276:18
    #5 0x5b9fc7015f94 in object_property_add /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:1294:12
    #6 0x5b9fc701b900 in object_add_link_prop /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:2021:10
    #7 0x5b9fc701b3fc in object_property_add_link /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:2037:12
    #8 0x5b9fc4c299fb in qdev_init_gpio_out_named /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/gpio.c:90:9
    #9 0x5b9fc4c29b26 in qdev_init_gpio_out /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/gpio.c:101:5
    #10 0x5b9fc4c0f77a in or_irq_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/or-irq.c:70:5
    qemu#11 0x5b9fc70257e1 in object_init_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:428:9
    qemu#12 0x5b9fc700cd4b in object_initialize_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:570:5
    qemu#13 0x5b9fc700e66d in object_new_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:774:5
    qemu#14 0x5b9fc700e750 in object_new /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:789:12
    qemu#15 0x5b9fc68b2162 in stm32f205_soc_initfn /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/arm/stm32f205_soc.c:69:26

Switch to using object_initialize_child() like all our
other child objects for this SoC object.

Cc: [email protected]
Fixes: b63041c ("STM32F205: Connect the ADC devices")
Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
(cherry picked from commit 2e27650)
Signed-off-by: Michael Tokarev <[email protected]>
philmd and others added 29 commits October 16, 2025 14:58
Stop detecting 32-bit PPC host as supported.
See previous commit for rationale.

Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
[rth: Retain _ARCH_PPC64 check in udiv_qrnnd]
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
In order to correspond with the kernel, we've now (1) moved the
preds[] to the right offset and combined the representation as a single
ulong "p3_0", (2), added the cs{0,1} registers, (3) added a pad for 48
words, (4) added the user regs structure to an 8-byte aligned
target_sigcontext structure.

Co-authored-by: Alex Rønne Petersen <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
Change the user_regs_struct to use abi_ulong instead of
target_ulong.

Link: https://lore.kernel.org/qemu-devel/[email protected]/
Suggested-by: Richard Henderson <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]/
Suggested-by: Taylor Simpson <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
Cover cs0,1 register corruption in the signal_context test case.

lc0, sa0 registers previously omitted from the clobbers list
are now captured.

Reviewed-by: Anton Johansson <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Matheus Tavares Bernardino <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
To remove any confusion with HVX or other potential store instructions,
we'll qualify this context var with "scalar".

Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Matheus Tavares Bernardino <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
The purpose of the prepare script is to invoke `cpp` to preprocess input
to idef-parser by expanding a few select macros.  On macOS `cpp`
expands into `clang ... -traditional-cpp` which breaks macro
concatenation.  Replace `cpp` with `${compiler} -E`
and replace the script with a meson custom_target.

Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
indent on macOS, installed via homebrew, doesn't support -linux. Only
run indent on linux hosts.

Signed-off-by: Anton Johansson <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
…aging

Fixes for linux-user sigcontext save/restore, etc.

misc: avoid inconsistencies w/indent on macOS
fix hexagon linux-user sigcontext discrepancy, found by Alex @ Zig

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEPWaq5HRZSCTIjOD4GlSvuOVkbDIFAmjyq24ACgkQGlSvuOVk
# bDIF9g/9FEllcwJFFOmyb+fsS0NkLFGRccCvowgjYCw5SaxC0+JBq58tWVkukCcK
# s+8eQ6TUfrgbxJziCoMWbP8UddMhNz9haUFGZ4wA8yq6Cxxmib092vdLj9YdfBdL
# TpMoXB1goWbPQ3EW2EyXr+Hsrlr/sb/hIrtSCvs2Xy1kRjc4xoAbHprgCz3C6oz4
# aiLJJy2uxWVDVEggWg7kSb2ZVmu/NrfReyv49kjEsuXiyHeQDBEDNYdRN5B6A9/F
# iznCSgTFBcDaV4UPaem6yEDuXCLucovmfLyvR+P6K/JtpOfX8nzWvk88j0WFeEmU
# kRZIpfR9un2GrndVeuxuoMGAZcha/LpajMr20OTfrKhJDPKp/kL5S3VqmBmZMsQx
# PjoBYFzBvg2FiMCQS1wQR4LGQ28/awz4ZnyeML02FRzDjmcFbZ0z5y4q1A9NnQEJ
# CZNnTjpUCdAVxymTnXCXVf/aS1T5v/iPWCu0BiebIlGP6/Eya364u60c0n/ABd1W
# bY3K1d2LZTYyi9dlT151pIOZ04S0k4E4g3jAyL578PfEpoJ7bXOmF8PL5DAAz1b8
# JRZjZLNXQlvNmcxTRs7wUzJlZ8AaudEZv5c+EnUcgLPcrBSMwvYdoXV7nyj+PKL1
# 3SwpRsgQimz7XtXAEUGmsSKUEIefF/yk/4laXHaGth3rMUDDi5U=
# =+ULY
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 17 Oct 2025 01:47:42 PM PDT
# gpg:                using RSA key 3D66AAE474594824C88CE0F81A54AFB8E5646C32
# gpg: Good signature from "Brian Cain (QUIC) <[email protected]>" [unknown]
# gpg:                 aka "Brian Cain <[email protected]>" [unknown]
# gpg:                 aka "Brian Cain (QuIC) <[email protected]>" [unknown]
# gpg:                 aka "Brian Cain (CAF) <[email protected]>" [unknown]
# gpg:                 aka "bcain" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6350 20F9 67A7 7164 79EF  49E0 175C 464E 541B 6D47
#      Subkey fingerprint: 3D66 AAE4 7459 4824 C88C  E0F8 1A54 AFB8 E564 6C32

* tag 'pull-hex-20251017' of https://github.com/quic/qemu:
  target/hexagon: Only indent on linux
  target/hexagon: Replace `prepare` script with meson target
  target/hexagon: s/pkt_has_store/pkt_has_scalar_store
  target/hexagon: handle .new values
  tests/tcg/hexagon: Add cs{0,1} coverage
  linux-user/hexagon: Use an array for GPRs
  linux-user/hexagon: use abi_ulong
  linux-user/hexagon: Fix sigcontext

Signed-off-by: Richard Henderson <[email protected]>
Missed some lines when converting to TCGOutOpQemuLdSt*.

Fixes: 86fe5c2 ("tcg: Convert qemu_st{2} to TCGOutOpLdSt{2}")
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
32-bit host support is deprecated since commit 6d701c9
("meson: Deprecate 32-bit host support"), released as v10.0.
The next release being v10.2, we can remove the TCG backend
for 32-bit PPC hosts.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
… staging

tcg: Remove support for 32-bit mips/ppc hosts

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmj1LRUdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV8+pAf/VBeBnMEuGlc+nrJS
# VEYSVsyWeKy8ezRphc502HYrzeiJ/h7L5wwHG2Yt41GbiQ9M+2H02hQAQTwsft4H
# vQ1iUM7rurY75gYzbBCgUDGqG8y0VRAyAafheMWiaKk/r6QMCmIX5yClZKH6Yzvg
# ZDwSx9FgaWbXwW11tG/0Cl5p9PtWAhGy3NecnNprMqJ1Hqv2zxT9U8v9yN1U6oiH
# FHlJmsfPqWQhU0jLZ78LHc802Iys8qF6DQJNYVQ7Xkbu24pTC9HoR3z7MqoI1hQF
# ELrH8fZmFiWbkx85paWFsSP/Y3Ff+lcG5hrv91KPoX2uB3ymNLJ0qYG0S8Cvt/VX
# JSeH9Q==
# =qyo5
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun 19 Oct 2025 11:25:25 AM PDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Richard Henderson <[email protected]>" [ultimate]

* tag 'pull-tcg-20251019' of https://gitlab.com/rth7680/qemu:
  tcg/ppc: Remove support for 32-bit hosts
  tcg/ppc: Remove dead cases from tcg_target_op_def
  buildsys: Remove support for 32-bit PPC hosts
  tcg/mips: Remove ALIAS_PADD, ALIAS_PADDI
  tcg/mips: Remove support for 32-bit hosts
  tcg/mips: Remove support for O32 and N32 ABIs
  kvm/mips: Remove support for 32-bit hosts
  buildsys: Remove support for 32-bit MIPS hosts
  gitlab: Stop cross-testing for 32-bit MIPS hosts

Signed-off-by: Richard Henderson <[email protected]>
The coverity-scan upload job has started failing as of 30th
September:

[ERROR] Cannot find '/usr/bin/file' command, and no 'file' command is found in the PATH
        Coverity Capture uses this tool to identify the file type of executables.
        Please ensure '/usr/bin/file' is available, or add the 'file' utility to your PATH.

This seems to have broken when we moved our containers from Fedora 40
to 41 -- probably F40 indirectly pulled in 'file' via some other
dependency, but in F41 it does not.

Explicitly install 'file' for the coverity job, in the same way we
already do for curl and wget.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
…o 512MB

Previously, the SSP memory was incorrectly modeled as "SRAM" with
a 32 MB size. This change introduces a new sdram field in
AspeedCoprocessorState and updates the realization logic accordingly.
Rename from SRAM to SDRAM and correct size from 32MB to 512MB to match
hardware.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
…o 512MB

Previously, the TSP memory was incorrectly modeled as "SRAM" with
a 32 MB size. Rename from SRAM to SDRAM and correct size from 32MB
to 512MB to match hardware.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
AST2700 has a 128KB SRAM, physically mapped at 0x10000000–0x1001FFFF for
the PSP (CA35) processor. The SSP coprocessor shares this same SRAM but
accesses it through a different address window at 0x70000000–0x7001FFFF.

To model this shared-memory behavior in QEMU, this commit introduces a
linked SRAM property and alias mapping between the PSP and SSP subsystems.

Changes include:
- Add a "MemoryRegion *sram" link and "MemoryRegion sram_alias" to
  AspeedCoprocessorState.
- Register the new "sram" property in aspeed_coprocessor_common.c.
- In aspeed_ast27x0-fc.c, connect the SSP coprocessor’s "sram" link to
  the PSP’s SRAM region.
- In aspeed_ast27x0-ssp.c, create an alias mapping for SRAM at
  0x70000000 – 0x7001FFFF in the SSP’s memory map.

This ensures that the SSP can correctly access the shared SRAM contents
through its own address space while maintaining a consistent physical
backing region. It also guarantees that the SRAM is realized before the
SSP device, ensuring successful alias setup.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
AST2700 has a 128KB SRAM, physically mapped at 0x10000000–0x1001FFFF for
the PSP (CA35) processor. The TSP coprocessor shares this same SRAM but
accesses it through a different address window at 0x70000000–0x7001FFFF.

To model this shared-memory behavior in QEMU, this commit introduces a
linked SRAM property and alias mapping between the PSP and TSP subsystems.

Changes include:
- Add the SRAM alias mapping at 0x70000000 in aspeed_ast27x0-tsp.c.
- In aspeed_ast27x0-fc.c, connect the TSP coprocessor’s "sram" link to
  the PSP’s SRAM region.
- Ensure the alias region is initialized during TSP SoC realization so
  the TSP can correctly access shared SRAM through its own address space.

This ensures that the TSP and PSP share the same physical SRAM backing.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
AST2700 has a single SCU hardware block, memory-mapped at
0x12C02000–0x12C03FFF from the perspective of the main CA35 processor (PSP).
The SSP and TSP coprocessors access this same SCU block at different
addresses: 0x72C02000–0x72C03FFF.

Previously, each subsystem (PSP, SSP, and TSP) instantiated its own SCU
device, resulting in three independent SCU instances in the QEMU model.
In real hardware, however, only a single SCU exists and is shared among
all processors.

This commit reworks the SCU model to correctly reflect the hardware
behavior by allowing SSP and TSP to reference the PSP’s SCU instance.
The following changes are introduced:

- Add a scu property to AspeedCoprocessorState for linking the
  coprocessor to the PSP’s SCU instance.
- Replace per-coprocessor SCU instantiation with a shared SCU link.
- Add "MemoryRegion scu_alias" to model address remapping for SSP and TSP.
- Create SCU alias regions in both SSP and TSP coprocessors and map
  them at 0x72C02000 to mirror the PSP’s SCU registers.
- Ensure the SCU device in PSP is realized before SSP/TSP alias setup.

With this change, PSP, SSP, and TSP now share a consistent SCU state,
matching the single-SCU hardware design of AST2700.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
In the original model, each subsystem (PSP, SSP, and TSP) created its own
set of 13 UART devices, resulting in a total of 39 UART instances. However,
on real AST2700 hardware, there is only one set of 13 UARTs shared among
all processors.

This commit reworks the UART handling to correctly model the shared
hardware design. The PSP now creates the full set of 13 UART instances,
while the SSP and TSP link to the corresponding shared UART device
through object properties.

Changes include:
- Add "DEFINE_PROP_LINK("uart", ...)" and "DEFINE_PROP_INT32("uart-dev", ...)"
  to allow each coprocessor to reference a specific shared UART instance.
- Modify SSP to link to PSP’s UART4, and TSP to link to PSP’s UART7.
- Introduce "uart_alias" to remap the UART’s MMIO region into the coprocessor’s
  memory space.
- Redirect the UART interrupt to the coprocessor’s NVIC, replacing the
  default routing to the PSP’s GIC.

With this change, only one set of 13 UART devices is instantiated by the PSP,
while the SSP and TSP reuse them via aliasing and shared interrupt routing,
matching the real AST2700 hardware behavior.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
This patch introduces a dedicated ca35_boot_rom memory region and
copies the FMC0 flash data into it.

The motivation is to support the upcoming vbootrom. The vbootrom
replaces the existing BOOTMCU (RISC-V 32 SPL) flow, which currently reads
the "image-bmc" from FMC_CS0 and loads the following components
into DRAM:

- Trusted Firmware-A
- OP-TEE OS
- u-boot-nodtb.bin
- u-boot.dtb

After loading, BOOTMCU releases the CA35 reset so that CA35 can start
executing Trusted Firmware-A.

The vbootrom follows the same sequence: CA35 fetches "image-bmc" from FMC0
flash at the SPI boot ROM base address (0x100000000), parses the FIT image,
loads each component into its designated DRAM location, and then jumps to
Trusted Firmware-A.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
Introduces support for loading a vbootrom image into the dedicated vbootrom
memory region in the AST2700 Full Core machine.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
…in PCIe test

Enhance the AST2700 functional PCIe test to verify the network interface
configuration for eth2. This adds an additional command to check the IP
address assignment on eth2 to ensure network functionality is correctly
initialized in the test environment.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
… common function

This removes duplicate code in start_ast2700fc_test() and prepares for reuse in
upcoming VBOOTROM tests.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
Add start_ast2700fc_test_vbootrom() which boots the ast2700fc machine
with -bios ast27x0_bootrom.bin and reuses the coprocessor loader.

Add test_aarch64_ast2700fc_sdk_vbootrom_v09_08() to test the vbootrom
with ast2700fc machine.

Signed-off-by: Jamin Lin <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
Added 32 bits property for ASPEED GPIO. Previously it can only be
access in bitwise manner.

The changes to qobject is to index gpios with array indices on top of
accessing with registers.  This allows for easier gpio access,
especially in tests with complex behaviors that requires large number
of gpios at a time, like fault injection and networking behaviors.

Indexing multiple gpios at once allows qmp/side band client to no
longer hardcode and populate register names and manipulate them
faster.

Signed-off-by: Felix Wu <[email protected]>
Reviewed-by: Andrew Jeffery <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
[ clg: wrapped commit log lines ]
Signed-off-by: Cédric Le Goater <[email protected]>
 - Added qtests to test gpio-set property for ASPEED.
 - Added function to get uint in qdict.

Signed-off-by: Felix Wu <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
The ast2600-evb machine model is using the "mx66u51235f" flash model,
which has issues with recent Linux kernels (6.15+) when reading SFDP
data.

Change the flash model to "w25q512jv", which is the model present on
some ast2600a3 EVB board and is known to work correctly with recent
kernels. Adjust the corresponding qtest to reflect the new JEDEC ID of
the w25q512jv flash.

Reviewed-by: Jamin Lin <[email protected]>
Link: https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Cédric Le Goater <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.