Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect misaligned memory operation handling in userspace simulation #528

Open
vacantron opened this issue Dec 25, 2024 · 0 comments
Open
Assignees

Comments

@vacantron
Copy link
Collaborator

The current exception handling of userspace program simulation simply skip the misaligned memory operation and return from M-mode:

rv32emu/src/emulate.c

Lines 51 to 55 in f7fd15b

static void rv_trap_default_handler(riscv_t *rv)
{
rv->csr_mepc += rv->compressed ? 2 : 4;
rv->PC = rv->csr_mepc; /* mret */
}

And the handler is also missing in just-in-time (JIT) mode.

The real behavor of the hardware that allows the misaligned memory operation would be taking that operation to piece of the smaller and aligned memory operation (i.e. lb/lbu/sb and lh/lhu/sh for misaligned lw/sw or lb/lbu/sb for misaligned lh/lhu/sh.

@vacantron vacantron self-assigned this Dec 25, 2024
@jserv jserv added this to the release-2025.1 milestone Dec 25, 2024
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

No branches or pull requests

2 participants