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

Env filter trap fault #39

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

deepak0414
Copy link
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

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 <[email protected]>
handle_trap will call trap_filter.
Tests can implement trap_filter to take necessary actions.

Signed-off-by: Deepak Gupta <[email protected]>
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 <[email protected]>
@aswaterman
Copy link
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 <[email protected]>
@deepak0414
Copy link
Contributor Author

@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
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 <[email protected]>
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