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

PoC: create a syscall by forcing the next CPU instruction #259

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

secworks
Copy link
Contributor

Description

This PR implements a PoC for a syscall, trap function.
The FW can write a jump instruction (with a target address) into an ADDR_SYSCALL_INSTR API address in tk1. The device app (and FW) can write to ADDR_SYSCALL_START API address in tk1. When written to the CPU will be forced to use the jump address in ADDR_SYSCALL_INSTR as next instruction to execute.

This could, may work. One issue may be timing (as in clock cycles). The ADDR_SYSCALL_START trigger must be set at the right cycle in relation to the CPU reading the next instruction. If it's one cycle too early or too late it will probably crash.

One could also simply force the CPU to use another address (not a specific instruction). But at least during PoC hack, trying to do so made the synthesis tool Yosys to allocate a design 180% of the available resources.

Fixes # (issues)
None

Type of change

Feature PoC

Please tick any that are relevant to this PR and remove any that aren't.

  • Bugfix (non breaking change which resolve an issue)
  • Feature (non breaking change which adds functionality)
  • Breaking Change (a change which would cause existing functionality to not work as expected)
  • Documentation (a change to documentation)

Submission checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my changes
  • I have tested and verified my changes on target
  • My changes are well written and CI is passing
  • I have squashed my work to relevant commits and rebased on main for linear history
  • I have added a "Co-authored-by: x" if several people contributed, either pair programming or by squashing commits from different authors.
  • I have updated the documentation where relevant (readme, dev.tillitis.se etc.)
  • QEMU is updated to reflect changes

       This commit adds a first attempt at adding a HW based syscall
       trampoline. Basicallt the FW can set a fixed address in a
       register in the API. The app can write an API adress. When
       written the HW will (should) force the CPU to read the
       instruction pointed to by the address set by the FW.

       This probably doesn't work. One problem is probably timing
       (cycles between writing the API and loading of the next
       instruction). We need to try.

Signed-off-by: Joachim Strömbergson <[email protected]>
       We don't want to set which address the CPU should jump to when
       a syscall is made, we want to push the jump instruction to
       execute. If that works.

Signed-off-by: Joachim Strömbergson <[email protected]>
@dehanj dehanj changed the title Syscall poc PoC: create a syscall by forcing the next instruction the CPU Nov 14, 2024
@dehanj dehanj changed the title PoC: create a syscall by forcing the next instruction the CPU PoC: create a syscall by forcing the next CPU instruction Nov 14, 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

Successfully merging this pull request may close these issues.

1 participant