Skip to content

Clean up the Zcmp directed tests once the toolchain and cosim support Zcmp #2534

Open

Description

@kulan-pal

As @SamuelRiedel suggested in #2498 (review), this tracks the clean-up of zcmp_reserved_test. The test has two workarounds:

  • It writes even the legal Zcmp instructions as raw halfwords, because the pinned GCC toolchain cannot assemble Zcmp.
  • It runs with +disable_cosim=1, which makes cosim mismatches non-fatal. The cosim does not enable Zcmp in Spike.

The Zcmp tests in #2500 (dummy_instr_zcmp_test and its debug and interrupt variants) use the same workarounds.

The LLVM toolchain proposed in #2519 assembles Zcmp mnemonics, but only when -march includes Zcmp. These tests pass no -march today. With both in place, the legal instructions can use mnemonics. The reserved encodings should stay raw halfwords. LLVM also rejects the test's .global mtvec_handler, because riscv_test.h already declares it weak.

Removing +disable_cosim=1 needs #2324, which checks expanded instructions against Spike, and #2398, which adds Zcmp to Spike's ISA string. The interrupt variant also needs the cosim to handle a cm.push or cm.pop that an interrupt aborts part-way through, as #2461 describes. CI's Spike build still executes cm.mvsa01 with equal register fields instead of trapping. CI needs a Spike build with the same rule as #2498.

Separately, and optional: zcmp_reserved_test runs with dummy instructions disabled, and no other directed test targets reserved Zcmp encodings. A SecureIbex variant with dummy insertion enabled would cover that combination. The test checks its own results, so this does not need to wait for the cosim.

Activity

  1. kulan-pal commented on Oct 24, 2026

    @kulan-pal
    ContributorAuthor

    #2544 adds three more Zcmp directed tests:

    • debug_step_zcmp_store_fault_test
    • debug_step_zcmp_fetch_fault_test
    • debug_trigger_zcmp_trap_test

    All three write Zcmp instructions as raw halfwords. The store-fault and trigger tests also run with +disable_cosim=1. The cosim does not enable Zcmp in Spike, so Spike takes cm.push as an illegal instruction. The fetch-fault test already runs with cosim, because its fetch faults before Spike decodes the instruction.

  2. kulan-pal commented on Nov 5, 2026

    @kulan-pal
    ContributorAuthor

    #2544 now merges the three tests above into one, debug_zcmp_trap_test. It runs with +disable_cosim=1, so a cosim mismatch no longer fails its fetch case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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