Skip to content

[Bug] Misaligned MMIO access inaccurately raises AddrMisaligned instead of AccessFault #990

@oChunCai

Description

@oChunCai

Describe the bug

isa_mmio_misalign_data_addr_check() in src/memory/paddr.c raises EX_LAM/EX_SAM for misaligned accesses to MMIO regions. RISC-V Privileged Spec §3.6.1 non-idempotent regions should raise *AccessFault instead, to prevent OS trap handlers from emulating the access via multiple smaller MMIO accesses.

Image

This is the NEMU-side counterpart of XiangShan #5695.

Expected behavior

Misaligned access to MMIO → EX_LAF (load) / EX_SAF (store), consistent with spec recommendation:

Non-idempotent regions might not support misaligned accesses. Misaligned accesses to such regions should raise access-fault exceptions rather than address-misaligned exceptions.

Code location

src/memory/paddr.c:173:

int ex = cpu.amo || type == MEM_TYPE_WRITE ? EX_SAM : EX_LAM;  // should be EX_SAF / EX_LAF

Necessary information on versions

  • NEMU version: master branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions