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 partial aarch64 support to libuser #566

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
20 changes: 20 additions & 0 deletions libuser/src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,28 @@ macro_rules! syscall {
arg6
};

#[cfg(not(target_arch = "aarch64"))]
syscall_inner(&mut registers);

#[cfg(target_arch = "aarch64")]
asm!(
roblabla marked this conversation as resolved.
Show resolved Hide resolved
"svc $7"
: "={x0}"(registers.nr),
Copy link
Member

Choose a reason for hiding this comment

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

wow, you did exactly what I was discussing in the previous comment 😅

For aarch64, I don't see the need for copying arguments to the Registers struct. Can't you just directly use nr ?

Copy link
Author

Choose a reason for hiding this comment

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

I thought Registers was in the public API? If it isn't, that's unnecessary.

Copy link
Member

Choose a reason for hiding this comment

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

It was, but I think that's a mistake, it should be defined only for i386

"={x1}"(registers.arg1),
"={x2}"(registers.arg2),
"={x3}"(registers.arg3),
"={x4}"(registers.arg4),
"={x5}"(registers.arg5),
"={x6}"(registers.arg6)
: "i"($nr),
"{x1}"(registers.arg1),
"{x2}"(registers.arg2),
"{x3}"(registers.arg3),
"{x4}"(registers.arg4),
"{x5}"(registers.arg5),
"{x6}"(registers.arg6)
);

if registers.nr == 0 {
Ok((registers.arg1, registers.arg2, registers.arg3, registers.arg4))
} else {
Expand Down