Skip to main content

hermit/arch/x86_64/
mod.rs

1pub mod kernel;
2pub mod mm;
3
4#[cfg(feature = "common-os")]
5use x86_64::registers::segmentation::SegmentSelector;
6
7use crate::arch::mm::paging::ExceptionStackFrame;
8
9/// Swap the GS register, if the user-space is is interrupted.
10#[cfg(feature = "common-os")]
11#[inline(always)]
12pub(crate) fn swapgs(stack_frame: &ExceptionStackFrame) {
13	use core::arch::asm;
14	if stack_frame.code_segment != SegmentSelector(8) {
15		unsafe {
16			asm!("swapgs", options(nomem, nostack, preserves_flags));
17		}
18	}
19}
20
21#[cfg(not(feature = "common-os"))]
22#[inline(always)]
23pub(crate) fn swapgs(_stack_frame: &ExceptionStackFrame) {}