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

Kernel tries to send syscall to itself #1

Closed
kennystrawnmusic opened this issue Aug 11, 2022 · 1 comment
Closed

Kernel tries to send syscall to itself #1

kennystrawnmusic opened this issue Aug 11, 2022 · 1 comment

Comments

@kennystrawnmusic
Copy link
Owner

Going to need to write my own Dma<T> and Mmio<T> structures instead of relying on the ones provided by the redox_syscall crate after running objdump on the instruction pointer returned by the #UD fault in the AHCI driver:

$ objdump -d target/x86_64-uefi-cryptos/release/cryptos | grep 56aae
   56aae:	0f 05                	syscall

Mmio<T> is easy to rewrite ― had one such structure embedded in my kernel myself temporarily before I began to run into compiler errors for whatever reason while trying to use it. Dma<T> not so much ― it's got some dependencies that need to be replaced with lower-level abstractions. Opening this issue as a reminder in the meantime.

kennystrawnmusic added a commit that referenced this issue Aug 12, 2022
kennystrawnmusic added a commit that referenced this issue Aug 12, 2022
kennystrawnmusic added a commit that referenced this issue Aug 13, 2022
@kennystrawnmusic
Copy link
Owner Author

kennystrawnmusic commented Aug 13, 2022

Here's the complete call stack that needs to be worked around:

  1. Dma::zeroed() -> Dma::from_physbox::zeroed()
  2. Dma::from_physbox::zeroed() -> Dma::from_physbox::uninit()
  3. Dma::from_physbox::uninit() -> redox_syscall::call::physmap()
  4. redox_syscall::call::physmap() -> redox_syscall::syscall3()
  5. redox_syscall::syscall3() -> asm!("syscall //...

Executing the syscall assembly instruction from inside the kernel is a #UD waiting to happen. So of course this needs to be worked around with re-implementation.

kennystrawnmusic added a commit that referenced this issue Aug 13, 2022
kennystrawnmusic added a commit that referenced this issue Aug 13, 2022
kennystrawnmusic added a commit that referenced this issue Aug 13, 2022
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

No branches or pull requests

1 participant