Skip to content
Merged
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
22 changes: 6 additions & 16 deletions openhcl/openhcl_boot/src/arch/x86_64/address_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use memory_range::MemoryRange;
use x86defs::X64_LARGE_PAGE_SIZE;
use x86defs::tdx::TDX_SHARED_GPA_BOUNDARY_ADDRESS_BIT;
use zerocopy::FromBytes;
use zerocopy::Immutable;
use zerocopy::IntoBytes;
use zerocopy::KnownLayout;

Expand All @@ -38,32 +37,23 @@ const PAGE_TABLE_ENTRY_COUNT: usize = 512;
const X64_PAGE_SHIFT: u64 = 12;
const X64_PTE_BITS: u64 = 9;

#[derive(Debug, IntoBytes, Immutable, KnownLayout, FromBytes)]
#[derive(Debug, IntoBytes, KnownLayout, FromBytes)]
#[repr(transparent)]
struct PageTableEntry {
entry: u64,
entry: AtomicU64,
}
#[derive(Debug, Copy, Clone)]
pub enum PageTableEntryType {
Leaf2MbPage(u64),
}

impl PageTableEntry {
fn atomic_pte<'a>(&self) -> &'a AtomicU64 {
// SAFETY: Casting a u64 to an atomic u64 via pointer is safe. All accesses to the u64 are
// consistently performed using this method.
unsafe {
let ptr = &self.entry as *const u64;
&*ptr.cast()
}
}

fn write_pte(&mut self, val: u64) {
self.atomic_pte().store(val, Ordering::SeqCst);
self.entry.store(val, Ordering::SeqCst);
}

fn read_pte(&self) -> u64 {
self.atomic_pte().load(Ordering::Relaxed)
self.entry.load(Ordering::Relaxed)
}

/// Set an AMD64 PDE to either represent a leaf 2MB page or PDE.
Expand Down Expand Up @@ -91,7 +81,7 @@ impl PageTableEntry {
}

pub fn is_large_page(&self) -> bool {
self.entry & X64_PTE_LARGE_PAGE == X64_PTE_LARGE_PAGE
self.read_pte() & X64_PTE_LARGE_PAGE == X64_PTE_LARGE_PAGE
}

pub fn get_addr(&self) -> u64 {
Expand Down Expand Up @@ -126,7 +116,7 @@ impl PageTableEntry {
}

#[repr(C)]
#[derive(Debug, IntoBytes, Immutable, KnownLayout, FromBytes)]
#[derive(Debug, IntoBytes, KnownLayout, FromBytes)]
struct PageTable {
entries: [PageTableEntry; PAGE_TABLE_ENTRY_COUNT],
}
Expand Down
2 changes: 1 addition & 1 deletion support/fast_memcpy/benches/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn do_bench_memcpy(
struct Aligned {
_data: [u8; N],
}
let count = len.next_multiple_of(N) / N;
let count = len.div_ceil(N);
let elt = Aligned { _data: [0; N] };
let src = vec![elt; count];
let mut dest = vec![elt; count];
Expand Down
4 changes: 2 additions & 2 deletions vm/devices/net/netvsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2224,8 +2224,8 @@ impl NvspMessage {
// Note that vmbus packets are always 8-byte multiples, so round the
// protocol package size up.
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the comment: “protocol package size” reads like it refers to a software package; it seems this should be “protocol packet size”.

Suggested change
// protocol package size up.
// protocol packet size up.

Copilot uses AI. Check for mistakes.
let len = match self.size {
PacketSize::V1 => const { protocol::PACKET_SIZE_V1.next_multiple_of(8) / 8 },
PacketSize::V61 => const { protocol::PACKET_SIZE_V61.next_multiple_of(8) / 8 },
PacketSize::V1 => const { protocol::PACKET_SIZE_V1.div_ceil(8) },
PacketSize::V61 => const { protocol::PACKET_SIZE_V61.div_ceil(8) },
};
&self.buf[..len]
}
Expand Down