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

Add implementation of PTRACE_{GET,SET}REGSET #2044

Merged
merged 3 commits into from
Apr 14, 2024

Conversation

hack3ric
Copy link
Contributor

This is related to #1695, but have many issues solved here:

  • {get,set}regset now allows specifying which set of registers to read/write, as defined in RegisterSet. This should be the expected behavior.
  • Also added PTRACE_{GET,SET}REGS for most platforms other than x86 using aforementioned implementation.

@hack3ric hack3ric marked this pull request as draft May 23, 2023 17:25
@hack3ric hack3ric force-pushed the master branch 2 times, most recently from 1d8a381 to 3b23859 Compare May 23, 2023 17:41
@hack3ric hack3ric marked this pull request as ready for review May 23, 2023 17:41
@hack3ric hack3ric force-pushed the master branch 2 times, most recently from f975abd to c9c186e Compare May 23, 2023 18:56
@hack3ric hack3ric marked this pull request as draft May 23, 2023 19:10
@hack3ric hack3ric force-pushed the master branch 3 times, most recently from 3822e12 to 5418add Compare May 24, 2023 08:31
@hack3ric hack3ric marked this pull request as ready for review May 24, 2023 08:44
hack3ric added a commit to hack3ric/archriscv-packages that referenced this pull request May 24, 2023
- nix: Add `nix::sys::ptrace::{get,set}regs` for newer platforms that
does not support `PTRACE_{GET,SET}REGS`
(nix-rust/nix#2044)
- syscalls: Add riscv32 and riscv64 syscall support
(jasonwhite/syscalls#37)
- lurk: Add syscalls groups (taken from strace) and parameter lists for
riscv64 (will upstream when nix's PR is merged)
felixonmars pushed a commit to felixonmars/archriscv-packages that referenced this pull request May 25, 2023
- nix: Add `nix::sys::ptrace::{get,set}regs` for newer platforms that
does not support `PTRACE_{GET,SET}REGS`
(nix-rust/nix#2044)
- syscalls: Add riscv32 and riscv64 syscall support
(jasonwhite/syscalls#37)
- lurk: Add syscalls groups (taken from strace) and parameter lists for
riscv64 (will upstream when nix's PR is merged)
Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a CHANGELOG

src/sys/ptrace/linux.rs Show resolved Hide resolved
src/sys/ptrace/linux.rs Outdated Show resolved Hide resolved
@hack3ric hack3ric force-pushed the master branch 2 times, most recently from 7d8fd65 to 6afb523 Compare July 21, 2023 06:44
@hack3ric
Copy link
Contributor Author

hack3ric commented Jul 21, 2023

Changelog added.

test_ptrace on Linux aarch64 failed while previously passed. Debugging.

Edit: Can't reproduce on qemu-system-aarch64, with Debian sid arm64, Rust 1.71.0 and GCC 13.

@hack3ric hack3ric force-pushed the master branch 3 times, most recently from 214ffca to 5b7a353 Compare October 29, 2023 17:00
@hack3ric
Copy link
Contributor Author

I've rebased this patch to master. Any updates?

@SteveLauC
Copy link
Member

From my perspective, all the work is blocked by #2166

@canoriz
Copy link

canoriz commented Dec 11, 2023

Any updates?

Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, sorry for the late review, I have left some comments:

And, we switched to a new changelog mode, please see this on how to add one:)

src/sys/ptrace/linux.rs Show resolved Hide resolved
src/sys/ptrace/linux.rs Outdated Show resolved Hide resolved
src/sys/ptrace/linux.rs Outdated Show resolved Hide resolved
src/sys/ptrace/linux.rs Outdated Show resolved Hide resolved
src/sys/ptrace/linux.rs Outdated Show resolved Hide resolved
@SteveLauC
Copy link
Member

BTW, #1695 has a good test, can we port it to this PR?

@hack3ric
Copy link
Contributor Author

BTW, #1695 has a good test, can we port it to this PR?

Ported.

@hack3ric hack3ric force-pushed the master branch 2 times, most recently from 7c0d740 to 589d8e1 Compare March 31, 2024 05:02
@hack3ric
Copy link
Contributor Author

Cannot reproduce aarch64 test errors on real hardware (Radxa Rock 5B, RK3588, rustc 1.70.0, Linux 5.10.110-20-rockchip)

@SteveLauC
Copy link
Member

Cannot reproduce aarch64 test errors on real hardware (Radxa Rock 5B, RK3588, rustc 1.70.0, Linux 5.10.110-20-rockchip)

I think I will set up a Linux VM on my m1 Mac to give it a test. BTW, we run Nix's tests with sudo, though I am not sure if it is related

@SteveLauC
Copy link
Member

I think I will set up a Linux VM on my m1 Mac to give it a test.

Sorry for the late reply, I tested it in a aarch64 Linux VM, and it also failed with EIO:

[steve@fedora steve]$ uname -a
Linux fedora 6.7.11-orbstack-00143-ge6b82e26cd22 #1 SMP Sat Mar 30 12:20:36 UTC 2024 aarch64 GNU/Linux

[steve@fedora test]$ sudo --preserve-env=HOME $(which cargo) test --all-features sys::test_ptrace::test_ptrace_syscall
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running unittests src/lib.rs (/home/steve/Documents/workspace/nix/target/debug/deps/nix-4701d15085df23b3)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 19 filtered out; finished in 0.00s

     Running test/test.rs (/home/steve/Documents/workspace/nix/target/debug/deps/test-637c83b07deea78d)

running 1 test
test sys::test_ptrace::test_ptrace_syscall ... FAILED

failures:

---- sys::test_ptrace::test_ptrace_syscall stdout ----
thread 'sys::test_ptrace::test_ptrace_syscall' panicked at test/sys/test_ptrace.rs:262:59:
called `Result::unwrap()` on an `Err` value: EIO
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    sys::test_ptrace::test_ptrace_syscall

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 347 filtered out; finished in 0.00s

error: test failed, to rerun pass `--test test`

Is there anything I can do to help debug the issue?

@hack3ric
Copy link
Contributor Author

It turns out to be my bad. I ran tests on non-root and it just skipped it.

After some research it seems aarch64 and riscv64 does not support PTRACE_PEEKUSER at all and will just fail with EIO. I'll make that part of the test x86-only.

Also added `PTRACE_{GET,SET}REGS` for most platforms other than x86
using aforementioned implementation.
@SteveLauC
Copy link
Member

The CI is still failing due to an unused import, let me give it a fix:)

Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, for the PR and your patience:)

@SteveLauC SteveLauC added this pull request to the merge queue Apr 14, 2024
Merged via the queue into nix-rust:master with commit 1c2cad8 Apr 14, 2024
36 checks passed
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.

no getregs and setregs support in aarch64
4 participants