From: Alex Henrie Subject: [PATCH resend 2/3] ntdll: Fill in SYSTEM_CPU_INFORMATION.MaximumCpus Message-Id: <20210218055816.345150-2-alexhenrie24@gmail.com> Date: Wed, 17 Feb 2021 22:57:55 -0700 In-Reply-To: <20210218055816.345150-1-alexhenrie24@gmail.com> References: <20210218055816.345150-1-alexhenrie24@gmail.com> Signed-off-by: Alex Henrie --- https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/processor.htm --- dlls/ntdll/unix/system.c | 29 +++++++++++++++++++++++++++++ include/winternl.h | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index a889b2e020c..d34a3229816 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -170,6 +170,31 @@ struct smbios_boot_info static SYSTEM_CPU_INFORMATION cpu_info; +static int get_possible_cpus(void) +{ + int ret = NtCurrentTeb()->Peb->NumberOfProcessors; +#ifdef linux + FILE *f = fopen("/sys/devices/system/cpu/possible", "r"); + char line[32]; + char *value; + if (f) + { + if (fgets(line, sizeof(line), f)) + { + value = strchr(line, '-'); + if (value) + { + *value = 0; + value++; + ret = atoi(value) - atoi(line) + 1; + } + } + fclose(f); + } +#endif + return ret; +} + /******************************************************************************* * Architecture specific feature detection for CPUs * @@ -267,6 +292,8 @@ static void get_cpuinfo( SYSTEM_CPU_INFORMATION *info ) info->Architecture = PROCESSOR_ARCHITECTURE_AMD64; #endif + info->MaximumCpus = get_possible_cpus(); + /* We're at least a 386 */ info->FeatureSet = CPU_FEATURE_VME | CPU_FEATURE_X86 | CPU_FEATURE_PGE; info->Level = 3; @@ -415,6 +442,7 @@ static inline void get_cpuinfo( SYSTEM_CPU_INFORMATION *info ) FIXME("CPU Feature detection not implemented.\n"); #endif info->Architecture = PROCESSOR_ARCHITECTURE_ARM; + info->MaximumCpus = get_possible_cpus(); } #elif defined(__aarch64__) @@ -463,6 +491,7 @@ static void get_cpuinfo( SYSTEM_CPU_INFORMATION *info ) #endif info->Level = max(info->Level, 8); info->Architecture = PROCESSOR_ARCHITECTURE_ARM64; + info->MaximumCpus = get_possible_cpus(); } #endif /* End architecture specific feature detection for CPUs */ diff --git a/include/winternl.h b/include/winternl.h index 61bcd0f1d92..22d75b748c4 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -1722,7 +1722,7 @@ typedef struct _SYSTEM_CPU_INFORMATION { WORD Architecture; WORD Level; WORD Revision; /* combination of CPU model and stepping */ - WORD Reserved; /* always zero */ + WORD MaximumCpus; /* number of CPUs if as many as possible are hot-added */ DWORD FeatureSet; /* see bit flags below */ } SYSTEM_CPU_INFORMATION, *PSYSTEM_CPU_INFORMATION; -- 2.30.1