Skip to content

arch: riscv: decouple mtval usefulness for FP traps from QEMU target #93735

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AFOliveira
Copy link
Contributor

Introduce CONFIG_RISCV_NO_MTVAL_ON_FP_TRAP to handle implementations where the mtval CSR does not provide useful information during floating-point illegal instruction exceptions.

The RISC-V specification states that mtval is "either set to zero or written with exception-specific information" on traps. Some implementations, including QEMU, do not populate mtval with the faulting instruction value during FP-related illegal instruction exceptions, making it unusable for FP exception handling.

Previously, this behavior was hardcoded for QEMU targets only, but other CPU implementations may also lack useful mtval content for FP traps. Decoupling this from CONFIG_QEMU_TARGET and allows other platforms to properly declare this limitation.

The new Kconfig option defaults to enabled for QEMU targets to maintain backward compatibility.

Introduce CONFIG_RISCV_NO_MTVAL_ON_FP_TRAP to handle implementations
where the mtval CSR does not provide useful information during
floating-point illegal instruction exceptions.

The RISC-V specification states that mtval is "either set to zero or
written with exception-specific information" on traps. Some
implementations, including QEMU, do not populate mtval with the
faulting instruction value during FP-related illegal instruction
exceptions, making it unusable for FP exception handling.

Previously, this behavior was hardcoded for QEMU targets only, but
other CPU implementations may also lack useful mtval content for FP
traps. Decoupling this from CONFIG_QEMU_TARGET and allows other
platforms to properly declare this limitation.

The new Kconfig option defaults to enabled for QEMU targets to
maintain backward compatibility.

Signed-off-by: Afonso Oliveira <[email protected]>
Copy link

@AFOliveira
Copy link
Contributor Author

Twister failure is unrelated with my PR, correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: RISCV RISCV Architecture (32-bit & 64-bit)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants