From 31fc312337aa11cdfbdec25cd78746140e0e500b Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Sun, 18 Feb 2024 18:24:30 +0000 Subject: [PATCH] [v1.05][X86] Do not stop if cach is NULL and check for non-NULL cache in get_topology_info functions --- src/x86/apic.c | 5 +++++ src/x86/cpuid.c | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/x86/apic.c b/src/x86/apic.c index 2892468..98dd1e4 100644 --- a/src/x86/apic.c +++ b/src/x86/apic.c @@ -369,6 +369,11 @@ bool fill_apic_ids(uint32_t* apic_ids, int first_core, int n, bool x2apic_id) { } bool get_topology_from_apic(struct cpuInfo* cpu, struct topology* topo) { + if (topo->cach == NULL) { + printWarn("get_topology_from_apic: cach is NULL"); + return false; + } + uint32_t apic_id; uint32_t* apic_ids = emalloc(sizeof(uint32_t) * topo->total_cores_module); uint32_t* apic_pkg = emalloc(sizeof(uint32_t) * topo->total_cores_module); diff --git a/src/x86/cpuid.c b/src/x86/cpuid.c index 3507114..3edabc9 100644 --- a/src/x86/cpuid.c +++ b/src/x86/cpuid.c @@ -549,11 +549,7 @@ struct cpuInfo* get_cpu_info(void) { cpu->cpu_name = infer_cpu_name_from_uarch(cpu->arch); } - // If cach is NULL continue, - // as get_topology_info - // requires non-NULL cache ptr->cach = get_cache_info(ptr); - if(ptr->cach == NULL) continue; if(cpu->hybrid_flag) { ptr->topo = get_topology_info(ptr, ptr->cach, i); @@ -573,6 +569,11 @@ struct cpuInfo* get_cpu_info(void) { } bool get_cache_topology_amd(struct cpuInfo* cpu, struct topology* topo) { + if (topo->cach == NULL) { + printWarn("get_cache_topology_amd: cach is NULL"); + return false; + } + if(cpu->maxExtendedLevels >= 0x8000001D && cpu->topology_extensions) { uint32_t i, eax, ebx, ecx, edx, num_sharing_cache, cache_type, cache_level;