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
3 changes: 3 additions & 0 deletions litebox_shim_windows/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,9 @@ impl<Platform: ShimPlatform, FS: ShimFS> Task<Platform, FS> {
byte_offset,
key,
),
SyscallRequest::NtGetCurrentProcessorNumberEx { processor_number } => {
self.sys_nt_get_current_processor_number_ex(processor_number)
}
SyscallRequest::NtQueryDebugFilterState {
component_id,
level,
Expand Down
8 changes: 8 additions & 0 deletions litebox_shim_windows/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ pub(crate) enum SyscallRequest<Platform: RawPointerProvider> {
byte_offset: Option<Platform::RawConstPointer<i64>>,
key: Option<Platform::RawConstPointer<u32>>,
},
NtGetCurrentProcessorNumberEx {
processor_number: Platform::RawMutPointer<sysinfo::ProcessorNumber>,
},
NtQueryDebugFilterState {
component_id: u32,
level: u32,
Expand Down Expand Up @@ -1059,6 +1062,11 @@ impl<Platform: RawPointerProvider> SyscallRequest<Platform> {
byte_offset:*,
key:*,
})),
NtSysno::NtGetCurrentProcessorNumberEx => {
Some(sys_req!(NtGetCurrentProcessorNumberEx {
processor_number:*,
}))
}
NtSysno::NtQueryDebugFilterState => Some(sys_req!(NtQueryDebugFilterState {
component_id,
level,
Expand Down
50 changes: 44 additions & 6 deletions litebox_shim_windows/src/syscalls/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ const SYSTEM_VERIFIER_INFORMATION_LENGTH: u32 = 0x90;
const SYSTEM_VERIFIER_INFORMATION_LENGTH_USIZE: usize = 0x90;
const X64_SYSTEM_RANGE_START: usize = 0xffff_8000_0000_0000;

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, FromBytes, Immutable, IntoBytes)]
pub(crate) struct ProcessorNumber {
group: u16,
number: u8,
reserved: u8,
}

pub(crate) const WINDOWS_TIME_ZONE_ID_INVALID: u32 = u32::MAX;
pub(crate) const WINDOWS_OS_MAJOR_VERSION: u16 = 10;
pub(crate) const WINDOWS_OS_MINOR_VERSION: u16 = 0;
Expand Down Expand Up @@ -71,6 +79,7 @@ enum LogicalProcessorRelationship {
Cache = 2,
ProcessorPackage = 3,
Group = 4,
NumaNodeEx = 6,
All = 0xffff,
}

Expand Down Expand Up @@ -219,6 +228,30 @@ struct GroupRelationshipInformation {
}

impl<Platform: ShimPlatform, FS: ShimFS> Task<Platform, FS> {
#[expect(
clippy::unused_self,
reason = "syscall handlers consistently operate on the current task"
)]
pub(crate) fn sys_nt_get_current_processor_number_ex(
&self,
processor_number: MutPtr<Platform, ProcessorNumber>,
) -> NtStatus {
if processor_number
.write_at_offset(
0,
ProcessorNumber {
group: 0,
number: 0,
reserved: 0,
},
)
.is_none()
{
return NtStatus::ACCESS_VIOLATION;
}
NtStatus::SUCCESS
}

pub(crate) fn sys_nt_query_system_information(
system_information_class: u32,
system_information: MutPtr<Platform, u8>,
Expand Down Expand Up @@ -384,12 +417,17 @@ impl<Platform: ShimPlatform, FS: ShimFS> Task<Platform, FS> {
return_length,
&processor_relationship_information(LogicalProcessorRelationship::ProcessorCore),
),
LogicalProcessorRelationship::NumaNode => Self::write_system_information(
system_information,
system_information_length,
return_length,
&numa_node_relationship_information(),
),
// Windows returns RelationNumaNode-tagged records for a RelationNumaNodeEx query.
// The synthetic topology has one processor group, so the existing one-element
// GroupMasks array is the complete extended-NUMA response.
LogicalProcessorRelationship::NumaNode | LogicalProcessorRelationship::NumaNodeEx => {
Self::write_system_information(
system_information,
system_information_length,
return_length,
&numa_node_relationship_information(),
)
}
LogicalProcessorRelationship::Cache => Self::write_system_information(
system_information,
system_information_length,
Expand Down