? o Index: include/cpu.h =================================================================== RCS file: /cvsroot/src/sys/arch/x86/include/cpu.h,v retrieving revision 1.129 diff -u -p -u -r1.129 cpu.h --- include/cpu.h 8 Aug 2020 19:08:48 -0000 1.129 +++ include/cpu.h 9 Oct 2020 20:46:23 -0000 @@ -487,6 +487,7 @@ void tmx86_init_longrun(void); /* identcpu.c */ void cpu_probe(struct cpu_info *); +void cpu_probe_caches(struct cpu_info *); void cpu_identify(struct cpu_info *); void identify_hypervisor(void); Index: x86/cpu.c =================================================================== RCS file: /cvsroot/src/sys/arch/x86/x86/cpu.c,v retrieving revision 1.198 diff -u -p -u -r1.198 cpu.c --- x86/cpu.c 9 Aug 2020 15:32:44 -0000 1.198 +++ x86/cpu.c 9 Oct 2020 20:46:23 -0000 @@ -274,11 +274,16 @@ cpu_pcpuarea_init(struct cpu_info *ci) static void cpu_vm_init(struct cpu_info *ci) { - int ncolors = 2, i; + unsigned int ncolors = 2; - for (i = CAI_ICACHE; i <= CAI_L2CACHE; i++) { + /* + * If we are not the primary cpu, we might not have hatched yet, + * so probe caches explicitly here. + */ + cpu_probe_caches(ci); + for (unsigned int i = CAI_ICACHE; i <= CAI_L2CACHE; i++) { struct x86_cache_info *cai; - int tcolors; + unsigned int tcolors; cai = &ci->ci_cinfo[i]; @@ -293,24 +298,27 @@ cpu_vm_init(struct cpu_info *ci) default: tcolors /= cai->cai_associativity; } - ncolors = uimax(ncolors, tcolors); - /* - * If the desired number of colors is not a power of - * two, it won't be good. Find the greatest power of - * two which is an even divisor of the number of colors, - * to preserve even coloring of pages. - */ - if (ncolors & (ncolors - 1) ) { - int try, picked = 1; - for (try = 1; try < ncolors; try *= 2) { - if (ncolors % try == 0) picked = try; - } - if (picked == 1) { - panic("desired number of cache colors %d is " - " > 1, but not even!", ncolors); - } - ncolors = picked; + if (tcolors <= ncolors) + continue; + ncolors = tcolors; + } + + /* + * If the desired number of colors is not a power of + * two, it won't be good. Find the greatest power of + * two which is an even divisor of the number of colors, + * to preserve even coloring of pages. + */ + if (ncolors & (ncolors - 1) ) { + unsigned int try, picked = 1; + for (try = 1; try < ncolors; try *= 2) { + if (ncolors % try == 0) picked = try; + } + if (picked == 1) { + panic("desired number of cache colors %u is " + " > 1, but not even!", ncolors); } + ncolors = picked; } /* Index: x86/identcpu.c =================================================================== RCS file: /cvsroot/src/sys/arch/x86/x86/identcpu.c,v retrieving revision 1.117 diff -u -p -u -r1.117 identcpu.c --- x86/identcpu.c 5 Sep 2020 07:45:44 -0000 1.117 +++ x86/identcpu.c 9 Oct 2020 20:46:23 -0000 @@ -858,6 +858,21 @@ cpu_probe_fpu(struct cpu_info *ci) } void +cpu_probe_caches(struct cpu_info *ci) +{ + switch (cpu_vendor) { + case CPUVENDOR_INTEL: + cpu_probe_intel_cache(ci); + return; + case CPUVENDOR_AMD: + cpu_probe_amd_cache(ci); + return; + default: + return; + } +} + +void cpu_probe(struct cpu_info *ci) { u_int descs[4];