Skip to content

Commit

Permalink
Merge pull request #509 from rust-osdev/fix/inv-picd-command
Browse files Browse the repository at this point in the history
fix typo in "InvPicdCommand"
  • Loading branch information
Freax13 authored Nov 15, 2024
2 parents 7525088 + 199d614 commit 3943178
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/instructions/tlb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn flush_all() {

/// The Invalidate PCID Command to execute.
#[derive(Debug)]
pub enum InvPicdCommand {
pub enum InvPcidCommand {
/// The logical processor invalidates mappings—except global translations—for the linear address and PCID specified.
Address(VirtAddr, Pcid),

Expand All @@ -44,6 +44,11 @@ pub enum InvPicdCommand {
AllExceptGlobal,
}

// TODO: Remove this in the next breaking release.
#[deprecated = "please use `InvPcidCommand` instead"]
#[doc(hidden)]
pub type InvPicdCommand = InvPcidCommand;

/// The INVPCID descriptor comprises 128 bits and consists of a PCID and a linear address.
/// For INVPCID type 0, the processor uses the full 64 bits of the linear address even outside 64-bit mode; the linear address is not used for other INVPCID types.
#[repr(C)]
Expand Down Expand Up @@ -93,25 +98,25 @@ impl fmt::Display for PcidTooBig {
///
/// This function is unsafe as it requires CPUID.(EAX=07H, ECX=0H):EBX.INVPCID to be 1.
#[inline]
pub unsafe fn flush_pcid(command: InvPicdCommand) {
pub unsafe fn flush_pcid(command: InvPcidCommand) {
let mut desc = InvpcidDescriptor {
pcid: 0,
address: 0,
};

let kind: u64;
match command {
InvPicdCommand::Address(addr, pcid) => {
InvPcidCommand::Address(addr, pcid) => {
kind = 0;
desc.pcid = pcid.value().into();
desc.address = addr.as_u64()
}
InvPicdCommand::Single(pcid) => {
InvPcidCommand::Single(pcid) => {
kind = 1;
desc.pcid = pcid.0.into()
}
InvPicdCommand::All => kind = 2,
InvPicdCommand::AllExceptGlobal => kind = 3,
InvPcidCommand::All => kind = 2,
InvPcidCommand::AllExceptGlobal => kind = 3,
}

unsafe {
Expand Down

0 comments on commit 3943178

Please sign in to comment.