Skip to content

Conversation

@owlxiao
Copy link
Contributor

@owlxiao owlxiao commented Aug 13, 2025

This PR aims to resolve memory access violation in io_addr test.

The io_addr regression test was failing with memory access violation errors:

Memory access violation from 0x80 to 0x88, curent flags=1, access flags=2
Error: exception: invalid memory address

This issue occurs because, during the io_addr test, the io_mpm_addr is periodically read to obtain test data. In the main test program, this region is reserved with READ-ONLY permissions.

  RT_CHECK(vx_mem_alloc(device, addr_buf_size, VX_MEM_READ, &usr_test_buffer));
  RT_CHECK(vx_mem_address(usr_test_buffer, &usr_test_addr));
  RT_CHECK(vx_mem_reserve(device, io_base_addr, addr_buf_size, VX_MEM_READ, &io_test_buffer));
  RT_CHECK(vx_mem_alloc(device, src_buf_size, VX_MEM_READ, &src_buffer));
  RT_CHECK(vx_mem_address(src_buffer, &kernel_arg.src_addr));
  RT_CHECK(vx_mem_alloc(device, dst_buf_size, VX_MEM_WRITE, &dst_buffer));
  RT_CHECK(vx_mem_address(dst_buffer, &kernel_arg.dst_addr));

However, at the end of each kernel execution, the program calls vx_perf_dump to export performance counters, and vx_perf_dump writes the corresponding counter values to io_mpm_addr.

.section .text
.type _Exit, @function
.global _Exit
_Exit:
  call vx_perf_dump
  li t0, IO_MPM_EXITCODE
  sw a0, 0(t0)
  fence
  .insn r RISCV_CUSTOM0, 0, 0, x0, x0, x0  # tmc x0
void vx_perf_dump() {
    int core_id = vx_core_id();
    uint32_t * const csr_mem = (uint32_t*)(IO_MPM_ADDR + 64 * sizeof(uint32_t) * core_id);
    DUMP_CSRS(0);
    //DUMP_CSRS(1); reserved for exitcode
    DUMP_CSRS(2);
    DUMP_CSRS(3);
    ...
}

Since the region still has READ-ONLY permissions at that point, this results in an error.

@tinebp
Copy link
Contributor

tinebp commented Oct 10, 2025

Can you please share the command line to reproduce this bug?

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.

2 participants