riscv-software-src / riscv-software-src/opensbi

Platform-specific illegal-instruction handling?

Open
#222 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.5k
Forks
712
PR merge metrics
No merged PRs in 30d

Description

Dear maintainers,

As you can see in platform/andes/ae350/platform.c, we created a few SBI calls just for reading/writing custom CSRs on the platform, which is not ideal as such CSRs increases. Meanwhile, trap-emulate normal CSR read/write just work in the generic flow.

I wonder if we can expand illegal-instruction handling a little bit, so that a platform can register its own handler? Two viable options I can think of are 1) in system_opcode_insn, with something like

if (unlikely(platform_illegal_insn))
    platform_illegal_insn(insn, regs);

or 2) in sbi_illegal_insn_handler, parse the NON-STANDARD CSR number and go to platform handler.

Any comments will be appreciated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with platform/andes/ae350/platform.c, then read the generic paths named in the issue: system_opcode_insn and sbi_illegal_insn_handler. Compare the two proposed extension points and determine the required platform-handler behavior for non-standard CSRs. The issue does not define acceptance criteria, so done requires an agreed design before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.