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 flags for CR0, CR4 and XCR0, as well as extra checks for modification of XCR0 #272

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/asm/asm.s
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,36 @@ _x86_64_asm_load_gs:
mov %di, %gs
retq

.global _x86_64_asm_get_ss
.p2align 4
_x86_64_asm_get_ss:
mov %ss, %ax
retq

.global _x86_64_asm_get_ds
.p2align 4
_x86_64_asm_get_ds:
mov %ds, %ax
retq

.global _x86_64_asm_get_es
.p2align 4
_x86_64_asm_get_es:
mov %es, %ax
retq

.global _x86_64_asm_get_fs
.p2align 4
_x86_64_asm_get_fs:
mov %fs, %ax
retq

.global _x86_64_asm_get_gs
.p2align 4
_x86_64_asm_get_gs:
mov %gs, %ax
retq

.global _x86_64_asm_swapgs
.p2align 4
_x86_64_asm_swapgs:
Expand Down
32 changes: 31 additions & 1 deletion src/asm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[link(name = "x86_64_asm", kind = "static")]
extern "C" {
extern "sysv64" {
#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_interrupt_enable"
Expand Down Expand Up @@ -114,6 +114,36 @@ extern "C" {
)]
pub(crate) fn x86_64_asm_load_gs(sel: u16);

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_ss"
)]
pub(crate) fn x86_64_asm_get_ss() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_ds"
)]
pub(crate) fn x86_64_asm_get_ds() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_es"
)]
pub(crate) fn x86_64_asm_get_es() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_fs"
)]
pub(crate) fn x86_64_asm_get_fs() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_get_gs"
)]
pub(crate) fn x86_64_asm_get_gs() -> u16;

#[cfg_attr(
any(target_env = "gnu", target_env = "musl"),
link_name = "_x86_64_asm_swapgs"
Expand Down
Loading