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

fix(model_specific): make {Fs,Gs,KernelGs}Base::write() unsafe #528

Merged
merged 1 commit into from
Dec 24, 2024
Merged
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
20 changes: 17 additions & 3 deletions src/registers/model_specific.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,13 @@ mod x86_64 {
///
/// If [`CR4.FSGSBASE`][Cr4Flags::FSGSBASE] is set, the more efficient
/// [`FS::write_base`] can be used instead.
///
/// ## Safety
///
/// The caller must ensure that this write operation has no unsafe side
/// effects, as the segment base address might be in use.
#[inline]
pub fn write(address: VirtAddr) {
pub unsafe fn write(address: VirtAddr) {
let mut msr = Self::MSR;
unsafe { msr.write(address.as_u64()) };
}
Expand All @@ -328,8 +333,13 @@ mod x86_64 {
///
/// If [`CR4.FSGSBASE`][Cr4Flags::FSGSBASE] is set, the more efficient
/// [`GS::write_base`] can be used instead.
///
/// ## Safety
///
/// The caller must ensure that this write operation has no unsafe side
/// effects, as the segment base address might be in use.
#[inline]
pub fn write(address: VirtAddr) {
pub unsafe fn write(address: VirtAddr) {
let mut msr = Self::MSR;
unsafe { msr.write(address.as_u64()) };
}
Expand All @@ -343,8 +353,12 @@ mod x86_64 {
}

/// Write a given virtual address to the KernelGsBase register.
///
/// ## Safety
///
/// The caller must ensure that a future call to [`GS::swap`] has no unsafe side effects.
#[inline]
pub fn write(address: VirtAddr) {
pub unsafe fn write(address: VirtAddr) {
let mut msr = Self::MSR;
unsafe { msr.write(address.as_u64()) };
}
Expand Down
Loading