Skip to content

Env filter trap fault - #39

Open
deepak0414 wants to merge 6 commits into
riscv:masterfrom
deepak0414:env_filter_trap_fault
Open

Env filter trap fault#39
deepak0414 wants to merge 6 commits into
riscv:masterfrom
deepak0414:env_filter_trap_fault

Conversation

@deepak0414

Copy link
Copy Markdown
Contributor

This PR adds following

  • encodings.h: CSR and bit definitions (in existing and new CSRs) for Zisslpcfi extension [1]
  • Delegates illegal instr exception: In vm environment delegates illegal instr exception because Zisslpcfi uses illegal instruction to report cfi violations to M/S mode.
  • adds support for trap filtering: Certain traps needs to be filtered by test by test basis and currently there is no such support in env. This patch allows test case authors to implement FILTER_TRAP macro and allow certain traps to go back to test cases.
  • adds support for page fault filtering: Certain page faults needs to be filtered by test by test basis and currently there is no such support in env. This patch allows test case authors to implement FILTER_PAGE_FAULT macro and allow certain page faults to go back to test cases.
  • page fault filters can provide which new encodings to use and whether to copy the page or not.

[1] - https://github.com/riscv/riscv-cfi

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Add support for filtering fault and traps in test cases.
Some test cases will need such support (like shadow stack in risc-v cfi)

Respective test case can implement the FILTER_TRAP or FILTER_PAGE_FAULT
macros.

add updates for cfi in encodings.h
vm_boot updates mstatus instead of clearing of existing bits.
extra_boot might have had set some bits in mstatus earlier.

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
handle_trap will call trap_filter.
Tests can implement trap_filter to take necessary actions.

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Some of the tests require exception delegated to S mode to be handled.
Delegating instruction, access (load/store) exceptions.
This patch also adds support for printing which test case failed.

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
@aswaterman

Copy link
Copy Markdown
Member

I would like to wait to merge this PR until the CFI extension is closer to being frozen. It seems likely to change in the interim.

Also, please remove all of the debugging code that was added.

adding additional logs for trap filtering mechanism so that failing tests
can be debugged.

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
@deepak0414

Copy link
Copy Markdown
Contributor Author

Andrew Waterman (@aswaterman)
would you be open to adding trap filtering and page fault filtering.
I can make a PR just for that.

That change is anyways seems like can be used by tests for other arch extensions.

@aswaterman

Copy link
Copy Markdown
Member

Seems reasonable; send me a new PR and let’s talk about it there.

No separate enable/disable bits for back cfi in M/S mode. Software
compiled for backward cfi will have anyways back cfi support compiled in.
And if it wants to be disabled, it can anyways be disabled via menvcfg and henvcfg.

Signed-off-by: Deepak Gupta <debug@rivosinc.com>
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