Skip to content

Commit

Permalink
Remove preserves_flags on 32-bit x86.
Browse files Browse the repository at this point in the history
The `__kernel_vsyscall` function used on 32-bit x86 does not preserve
the flags register, so remove the `preserves_flags` option on inline
asm blocks that call it.
  • Loading branch information
sunfishcode committed Jul 5, 2023
1 parent 7cb3178 commit da6dc21
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/backend/linux_raw/arch/inline/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
//! instruction.
//!
//! Most `rustix` syscalls use the vsyscall mechanism rather than going using
//! `int 0x80` sequences.
//! `int 0x80` sequences, as vsyscall is much faster.
//!
//! Syscalls made with `int 0x80` preserve the flags register, while syscalls
//! made using vsyscall do not.

#![allow(dead_code)]

Expand All @@ -25,7 +28,6 @@ pub(in crate::backend) unsafe fn indirect_syscall0(
"call {callee}",
callee = in(reg) callee,
inlateout("eax") nr.to_asm() => r0,
options(preserves_flags)
);
FromAsm::from_asm(r0)
}
Expand All @@ -42,7 +44,6 @@ pub(in crate::backend) unsafe fn indirect_syscall1(
callee = in(reg) callee,
inlateout("eax") nr.to_asm() => r0,
in("ebx") a0.to_asm(),
options(preserves_flags)
);
FromAsm::from_asm(r0)
}
Expand Down Expand Up @@ -76,7 +77,6 @@ pub(in crate::backend) unsafe fn indirect_syscall2(
inlateout("eax") nr.to_asm() => r0,
in("ebx") a0.to_asm(),
in("ecx") a1.to_asm(),
options(preserves_flags)
);
FromAsm::from_asm(r0)
}
Expand All @@ -97,7 +97,6 @@ pub(in crate::backend) unsafe fn indirect_syscall3(
in("ebx") a0.to_asm(),
in("ecx") a1.to_asm(),
in("edx") a2.to_asm(),
options(preserves_flags)
);
FromAsm::from_asm(r0)
}
Expand Down Expand Up @@ -128,7 +127,6 @@ pub(in crate::backend) unsafe fn indirect_syscall4(
in("ebx") a0.to_asm(),
in("ecx") a1.to_asm(),
in("edx") a2.to_asm(),
options(preserves_flags)
);
FromAsm::from_asm(r0)
}
Expand Down Expand Up @@ -161,7 +159,6 @@ pub(in crate::backend) unsafe fn indirect_syscall5(
in("ecx") a1.to_asm(),
in("edx") a2.to_asm(),
in("edi") a4.to_asm(),
options(preserves_flags)
);
FromAsm::from_asm(r0)
}
Expand Down Expand Up @@ -203,7 +200,6 @@ pub(in crate::backend) unsafe fn indirect_syscall6(
in("ecx") a1.to_asm(),
in("edx") a2.to_asm(),
in("edi") a4.to_asm(),
options(preserves_flags)
);
FromAsm::from_asm(r0)
}
Expand Down

0 comments on commit da6dc21

Please sign in to comment.