[PATCH v3 00/10] fhandler_proc.cc(format_proc_cpuinfo): fix issues, add fields, feature flags
* fix cache size return code handling and make AMD/Intel code common * fix cpuid level count as number of non-zero leafs excluding sub-leafs * fix AMD physical cores count documented as core_info low byte + 1 * round cpu MHz to correct Windows and match Linux cpuinfo * add bogomips which has been cpu MHz*2 since Pentium MMX * add microcode from Windows registry Update Revision REG_BINARY * feature test print macro makes cpuid feature, bit, and flag text comparison and checking easier; handle as common former Intel only feature flags also supported on AMD; change order and some flag names to agree with current Linux * add 99 feature flags inc. AVX512 extensions, AES, SHA with 20 cpuid calls * comment out flags not reported by Linux in cpuinfo although some flags may not be used by Linux * or model extension bits into high model bits instead of adding arithmetically like family extension bits winsup/cygwin/fhandler_proc.cc | 737 +++-- 1 file changed, 434 insertions(+), 303 deletions(-) -- 2.21.0
[PATCH v3 01/10] fhandler_proc.cc(format_proc_cpuinfo): fix cache size
fix cache size return code handling and make AMD/Intel code common --- winsup/cygwin/fhandler_proc.cc | 45 ++ 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 48476beb8..13cc36858 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -744,6 +744,8 @@ format_proc_cpuinfo (void *, char *&destbuf) int cache_size = -1, clflush = 64, cache_alignment = 64; + long (*get_cpu_cache) (int, uint32_t) = NULL; + uint32_t max; if (features1 & (1 << 19)) /* CLFSH */ clflush = ((extra_info >> 8) & 0xff) << 3; if (is_intel && family == 15) @@ -751,45 +753,34 @@ format_proc_cpuinfo (void *, char *&destbuf) if (is_intel) { extern long get_cpu_cache_intel (int sysc, uint32_t maxf); - long cs; - - cs = get_cpu_cache_intel (_SC_LEVEL3_CACHE_SIZE, maxf); - if (cs == -1) - cs = get_cpu_cache_intel (_SC_LEVEL2_CACHE_SIZE, maxf); - if (cs == -1) - { - cs = get_cpu_cache_intel (_SC_LEVEL1_ICACHE_SIZE, maxf); - if (cs != -1) - cache_size = cs; - cs = get_cpu_cache_intel (_SC_LEVEL1_DCACHE_SIZE, maxf); - if (cs != -1) - cache_size += cs; - } - else - cache_size = cs; - if (cache_size != -1) - cache_size >>= 10; + get_cpu_cache = get_cpu_cache_intel; + max = maxf; /* Intel uses normal cpuid levels */ } else if (is_amd) { extern long get_cpu_cache_amd (int sysc, uint32_t maxe); + get_cpu_cache = get_cpu_cache_amd; + max = maxe; /* AMD uses extended cpuid levels */ + } + if (get_cpu_cache) + { long cs; - cs = get_cpu_cache_amd (_SC_LEVEL3_CACHE_SIZE, maxe); - if (cs == -1) - cs = get_cpu_cache_amd (_SC_LEVEL2_CACHE_SIZE, maxe); - if (cs == -1) + cs = get_cpu_cache (_SC_LEVEL3_CACHE_SIZE, max); + if (cs <= 0) + cs = get_cpu_cache (_SC_LEVEL2_CACHE_SIZE, max); + if (cs <= 0) { - cs = get_cpu_cache_amd (_SC_LEVEL1_ICACHE_SIZE, maxe); - if (cs != -1) + cs = get_cpu_cache (_SC_LEVEL1_ICACHE_SIZE, max); + if (cs > 0) cache_size = cs; - cs = get_cpu_cache_amd (_SC_LEVEL1_DCACHE_SIZE, maxe); - if (cs != -1) + cs = get_cpu_cache (_SC_LEVEL1_DCACHE_SIZE, max); + if (cs > 0) cache_size += cs; } else cache_size = cs; - if (cache_size != -1) + if (cache_size > 0) cache_size >>= 10; } bufptr += __small_sprintf (bufptr, "cpu family\t: %d\n" -- 2.21.0
[PATCH v3 02/10] fhandler_proc.cc(format_proc_cpuinfo): fix cpuid level count
fix cpuid level count as number of non-zero leafs excluding sub-leafs --- winsup/cygwin/fhandler_proc.cc | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 13cc36858..78518baf9 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -927,13 +927,30 @@ format_proc_cpuinfo (void *, char *&destbuf) } + /* level is number of non-zero leafs exc. sub-leafs */ + int level = maxf + 1 + (maxe & 0x7fff) + 1; + + for (uint32_t l = maxe; 0x8001 < l; --l) +{ + uint32_t a, b, c, d; + cpuid (&a, &b, &c, &d, l); + if (!(a | b | c | d)) --level; +} + + for (uint32_t l = maxf; 1 < l; --l) +{ + uint32_t a, b, c, d; + cpuid (&a, &b, &c, &d, l); + if (!(a | b | c | d)) --level; +} + bufptr += __small_sprintf (bufptr, "fpu\t\t: %s\n" "fpu_exception\t: %s\n" "cpuid level\t: %d\n" "wp\t\t: yes\n", (features1 & (1 << 0)) ? "yes" : "no", (features1 & (1 << 0)) ? "yes" : "no", -maxf); +level); print ("flags\t\t:"); if (features1 & (1 << 0)) print (" fpu"); -- 2.21.0
[PATCH v3 03/10] fhandler_proc.cc(format_proc_cpuinfo): fix AMD physical cores count
fix AMD physical cores count documented as core_info low byte + 1 --- winsup/cygwin/fhandler_proc.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 78518baf9..c94cde910 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -885,11 +885,10 @@ format_proc_cpuinfo (void *, char *&destbuf) cpuid (&unused, &unused, &core_info, &unused, 0x8008); cpuid (&unused, &cus, &unused, &unused, 0x801e); - siblings = (core_info & 0xff) + 1; + siblings = cpu_cores = (core_info & 0xff) + 1; logical_bits = (core_info >> 12) & 0xf; cus = ((cus >> 8) & 0x3) + 1; ht_bits = mask_bits (cus); - cpu_cores = siblings >> ht_bits; } else if (maxe >= 0x8008) { -- 2.21.0
[PATCH v3 05/10] fhandler_proc.cc(format_proc_cpuinfo): add bogomips
add bogomips which has been cpu MHz*2 since Pentium MMX --- winsup/cygwin/fhandler_proc.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 86c1f6253..8c290d2ff 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -696,6 +696,7 @@ format_proc_cpuinfo (void *, char *&destbuf) RtlQueryRegistryValues (RTL_REGISTRY_ABSOLUTE, cpu_key, tab, NULL, NULL); cpu_mhz = ((cpu_mhz - 1) / 10 + 1) * 10; /* round up to multiple of 10 */ + DWORD bogomips = cpu_mhz * 2; /* bogomips is double cpu MHz since MMX */ bufptr += __small_sprintf (bufptr, "processor\t: %d\n", cpu_number); uint32_t maxf, vendor_id[4], unused; @@ -1228,7 +1229,8 @@ format_proc_cpuinfo (void *, char *&destbuf) print ("\n"); - /* TODO: bogomips */ + bufptr += __small_sprintf (bufptr, "bogomips\t: %d.00\n", + bogomips); bufptr += __small_sprintf (bufptr, "clflush size\t: %d\n" "cache_alignment\t: %d\n", -- 2.21.0
[PATCH v3 08/10] fhandler_proc.cc(format_proc_cpuinfo): add feature flags
add 99 feature flags inc. AVX512 extensions, AES, SHA with 20 cpuid calls --- winsup/cygwin/fhandler_proc.cc | 238 +++-- 1 file changed, 229 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index fbcec38df..13338230d 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -1019,6 +1019,21 @@ format_proc_cpuinfo (void *, char *&destbuf) ftcprint (features1, 30, "3dnowext"); /* 3DNow extensions */ ftcprint (features1, 31, "3dnow");/* 3DNow */ } + /* AMD cpuid 0x8007 edx */ + if (is_amd && maxe >= 0x8007) + { + cpuid (&unused, &unused, &unused, &features1, 0x8007); + + ftcprint (features1, 8, "constant_tsc"); /* TSC constant rate */ + ftcprint (features1, 8, "nonstop_tsc"); /* nonstop C states */ + } + /* cpuid 0x0006 ecx */ + if (maxf >= 0x06) + { + cpuid (&unused, &unused, &features1, &unused, 0x06); + + ftcprint (features1, 0, "aperfmperf"); /* P state hw coord fb */ + } /* cpuid 0x0001 ecx */ ftcprint (features2, 0, "pni"); /* xmm3 sse3 */ @@ -1044,6 +1059,7 @@ format_proc_cpuinfo (void *, char *&destbuf) ftcprint (features2, 21, "x2apic"); /* x2 APIC */ ftcprint (features2, 22, "movbe");/* movbe instruction */ ftcprint (features2, 23, "popcnt"); /* popcnt instruction */ + ftcprint (features2, 24, "tsc_deadline_timer"); /* TSC deadline timer */ ftcprint (features2, 25, "aes"); /* AES instructions */ ftcprint (features2, 26, "xsave");/* xsave/xrstor/xsetbv/xgetbv */ ftcprint (features2, 27, "osxsave"); /* not output on Linux */ @@ -1084,25 +1100,83 @@ format_proc_cpuinfo (void *, char *&destbuf) ftcprint (features1, 22, "topoext"); /* topology ext */ ftcprint (features1, 23, "perfctr_core"); /* core perf ctr ext */ ftcprint (features1, 24, "perfctr_nb"); /* NB perf ctr ext */ + ftcprint (features1, 26, "bpext");/* data brkpt ext */ + ftcprint (features1, 27, "ptsc"); /* perf timestamp ctr */ ftcprint (features1, 28, "perfctr_llc"); /* ll cache perf ctr */ ftcprint (features1, 29, "mwaitx"); /* monitor/mwaitx ext */ } } /* features scattered in various CPUID levels. */ - /* thermal & power cpuid 0x0006 eax ecx */ + /* cpuid 0x8007 edx */ + if (maxf >= 0x07) + { + cpuid (&unused, &unused, &unused, &features1, 0x8007); + + ftcprint (features1, 9, "cpb"); /* core performance boost */ + } + /* cpuid 0x0006 ecx */ if (maxf >= 0x06) { - cpuid (&features1, &unused, &features2, &unused, 0x06); + cpuid (&unused, &unused, &features1, &unused, 0x06); - ftcprint (features2, 3, "epb"); /* energy perf bias */ + ftcprint (features1, 3, "epb"); /* energy perf bias */ + } + /* cpuid 0x0010 ebx */ + if (maxf >= 0x10) + { + cpuid (&unused, &features1, &unused, &unused, 0x10); - ftcprint (features1, 0, "dtherm"); /* digital thermal sensor */ - ftcprint (features1, 1, "ida"); /* Intel dynamic acceleration */ - ftcprint (features1, 2, "arat"); /* always running APIC timer */ - ftcprint (features1, 4, "pln"); /* power limit notification */ - ftcprint (features1, 6, "pts"); /* package thermal status */ + ftcprint (features1, 1, "cat_l3"); /* cache alloc tech l3 */ + ftcprint (features1, 2, "cat_l2"); /* cache alloc tech l2 */ + + /* cpuid 0x0010:1 ecx */ + cpuid (&unused, &unused, &features1, &unused, 0x10, 1); + + ftcprint (features1, 2, "cdp_l3"); /* code data prior l3 */ + } + /* cpuid 0x8007 edx */ + if (maxe >= 0x8007) + { + cpuid (&unused, &unused, &unused, &features1, 0x8007); + + ftcprint (features1, 7, "hw_pstate");/* hw P state */ + ftcprint (features1, 11, "proc_feedback"); /* proc feedback interf */ + } + /* cpuid 0x801f eax */ + if (maxe >= 0x801f) + { + cpuid (&features1, &unused, &unused, &unused, 0x801f); + + ftcprint (features1, 0, "sme"); /* secure memory encryption */ + } + /* cpuid 0x0010:2 ecx */ + if (maxf >= 0x10) + { + cpuid (&unused, &unused, &features1, &unused, 0x10, 2); + + ftcprint (features1, 2, "cdp_l2"); /* code data prior l2 */ + + /* cpuid 0x0010 ebx */ + cpuid (&unused, &features1, &unused, &unused, 0x10); + + ftcprint (features1, 3, "mba"); /* memory bandwidth alloc */ + } + /* cpuid 0x8008 ebx */ + i
[PATCH v3 09/10] fhandler_proc.cc(format_proc_cpuinfo): comment flags not reported
comment out flags not reported by Linux in cpuinfo, although some flags may not be used at all by Linux --- winsup/cygwin/fhandler_proc.cc | 30 +++--- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 13338230d..c924cf2e0 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -1062,7 +1062,7 @@ format_proc_cpuinfo (void *, char *&destbuf) ftcprint (features2, 24, "tsc_deadline_timer"); /* TSC deadline timer */ ftcprint (features2, 25, "aes"); /* AES instructions */ ftcprint (features2, 26, "xsave");/* xsave/xrstor/xsetbv/xgetbv */ - ftcprint (features2, 27, "osxsave"); /* not output on Linux */ +/*ftcprint (features2, 27, "osxsave"); */ /* not output on Linux */ ftcprint (features2, 28, "avx"); /* advanced vector extensions */ ftcprint (features2, 29, "f16c"); /* 16 bit FP conversions */ ftcprint (features2, 30, "rdrand"); /* RNG rdrand instruction */ @@ -1187,14 +1187,14 @@ format_proc_cpuinfo (void *, char *&destbuf) ftcprint (features1, 3, "bmi1"); /* bit manip ext group 1 */ ftcprint (features1, 4, "hle"); /* hardware lock elision */ ftcprint (features1, 5, "avx2"); /* AVX ext instructions */ - ftcprint (features1, 6, "fpdx"); /* FP data ptr upd on exc */ +/* ftcprint (features1, 6, "fpdx"); */ /* FP data ptr upd on exc */ ftcprint (features1, 7, "smep"); /* super mode exec prot */ ftcprint (features1, 8, "bmi2"); /* bit manip ext group 2 */ ftcprint (features1, 9, "erms"); /* enh rep movsb/stosb */ ftcprint (features1, 10, "invpcid"); /* inv proc context id */ ftcprint (features1, 11, "rtm"); /* restricted txnal mem */ ftcprint (features1, 12, "cqm"); /* cache QoS monitoring */ - ftcprint (features1, 13, "fpcsdsz"); /* zero FP cs/ds */ +/* ftcprint (features1, 13, "fpcsdsz"); */ /* zero FP cs/ds */ ftcprint (features1, 14, "mpx"); /* mem prot ext */ ftcprint (features1, 15, "rdt_a");/* rsrc dir tech alloc */ ftcprint (features1, 16, "avx512f"); /* vec foundation */ @@ -1255,15 +1255,15 @@ format_proc_cpuinfo (void *, char *&destbuf) ftcprint (features1, 0, "clzero"); /* clzero instruction */ ftcprint (features1, 1, "irperf"); /* instr retired count */ ftcprint (features1, 2, "xsaveerptr"); /* save/rest FP err ptrs */ - ftcprint (features1, 6, "mba"); /* memory BW alloc */ +/* ftcprint (features1, 6, "mba"); */ /* memory BW alloc */ ftcprint (features1, 9, "wbnoinvd"); /* wbnoinvd instruction */ - ftcprint (features1, 12, "ibpb" );/* ind br pred barrier */ - ftcprint (features1, 14, "ibrs" );/* ind br restricted spec */ - ftcprint (features1, 15, "stibp");/* 1 thread ind br pred */ - ftcprint (features1, 17, "stibp_always_on"); /* stibp always on */ - ftcprint (features1, 24, "ssbd"); /* spec store byp dis */ +/* ftcprint (features1, 12, "ibpb" ); */ /* ind br pred barrier */ +/* ftcprint (features1, 14, "ibrs" ); */ /* ind br restricted spec */ +/* ftcprint (features1, 15, "stibp"); */ /* 1 thread ind br pred */ +/* ftcprint (features1, 17, "stibp_always_on"); */ /* stibp always on */ +/* ftcprint (features1, 24, "ssbd"); */ /* spec store byp dis */ ftcprint (features1, 25, "virt_ssbd");/* vir spec store byp dis */ - ftcprint (features1, 26, "ssb_no"); /* ssb fixed in hardware */ +/* ftcprint (features1, 26, "ssb_no"); *//* ssb fixed in hardware */ } /* thermal & power cpuid 0x0006 eax */ @@ -1392,13 +1392,13 @@ format_proc_cpuinfo (void *, char *&destbuf) ftcprint (features1, 5, "stc"); /* sw thermal control */ ftcprint (features1, 6, "100mhzsteps"); /* 100 MHz mult control */ ftcprint (features1, 7, "hwpstate"); /* hw P state control */ - ftcprint (features1, 8, "invariant_tsc"); /* TSC invariant */ +/* ftcprint (features1, 8, "invariant_tsc"); */ /* TSC invariant */ ftcprint (features1, 9, "cpb"); /* core performance boost */ ftcprint (features1, 10, "eff_freq_ro"); /* ro eff freq interface */ - ftcprint (features1, 11, "proc_feedback"); /* proc feedback if */ - ftcprint (features1, 12, "acc_power");/* core power reporting */ - ftcprint (features1, 13, "connstby"); /* connected standby */ - ftcprint (features1, 14, "rapl"); /* running average power limit */ +/* ftcprint (features1, 11, "proc_feedback"); */ /* proc
[PATCH v3 04/10] fhandler_proc.cc(format_proc_cpuinfo): round cpu MHz
round cpu MHz to correct Windows and match Linux cpuinfo --- winsup/cygwin/fhandler_proc.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index c94cde910..86c1f6253 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -695,6 +695,7 @@ format_proc_cpuinfo (void *, char *&destbuf) RtlQueryRegistryValues (RTL_REGISTRY_ABSOLUTE, cpu_key, tab, NULL, NULL); + cpu_mhz = ((cpu_mhz - 1) / 10 + 1) * 10; /* round up to multiple of 10 */ bufptr += __small_sprintf (bufptr, "processor\t: %d\n", cpu_number); uint32_t maxf, vendor_id[4], unused; -- 2.21.0
[PATCH v3 10/10] fhandler_proc.cc(format_proc_cpuinfo): or model extension bits
or model extension bits into model high bits instead of adding arithmetically like family extension --- winsup/cygwin/fhandler_proc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index c924cf2e0..8c331f5f4 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -740,7 +740,7 @@ format_proc_cpuinfo (void *, char *&destbuf) if (family == 15) family += (cpuid_sig >> 20) & 0xff; if (family >= 6) - model += ((cpuid_sig >> 16) & 0x0f) << 4; + model |= ((cpuid_sig >> 16) & 0x0f) << 4; /* ext model << 4 | model */ uint32_t maxe = 0; cpuid (&maxe, &unused, &unused, &unused, 0x8000); -- 2.21.0
[PATCH v3 06/10] fhandler_proc.cc(format_proc_cpuinfo): add microcode
add microcode from Windows registry Update Revision REG_BINARY --- winsup/cygwin/fhandler_proc.cc | 26 +- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 8c290d2ff..51bbdc43f 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -687,16 +687,30 @@ format_proc_cpuinfo (void *, char *&destbuf) yield (); DWORD cpu_mhz = 0; - RTL_QUERY_REGISTRY_TABLE tab[2] = { - { NULL, RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_NOSTRING, - L"~Mhz", &cpu_mhz, REG_NONE, NULL, 0 }, - { NULL, 0, NULL, NULL, 0, NULL, 0 } - }; + union +{ + LONG uc_len; /* -max size of buffer before call */ + char uc_microcode[16]; +} uc; + RTL_QUERY_REGISTRY_TABLE tab[3] = +{ + { NULL, RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_NOSTRING, + L"~Mhz", &cpu_mhz, REG_NONE, NULL, 0 }, + { NULL, RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_NOSTRING, + L"Update Revision", &uc, REG_NONE, NULL, 0 }, + { NULL, 0, NULL, NULL, 0, NULL, 0 } +}; + + memset (&uc, 0, sizeof (uc.uc_microcode)); + uc.uc_len = -16; /* -max size of microcode buffer */ RtlQueryRegistryValues (RTL_REGISTRY_ABSOLUTE, cpu_key, tab, NULL, NULL); cpu_mhz = ((cpu_mhz - 1) / 10 + 1) * 10; /* round up to multiple of 10 */ DWORD bogomips = cpu_mhz * 2; /* bogomips is double cpu MHz since MMX */ + long long microcode = 0; /* at least 8 bytes for AMD */ + memcpy (µcode, &uc, sizeof (microcode)); + bufptr += __small_sprintf (bufptr, "processor\t: %d\n", cpu_number); uint32_t maxf, vendor_id[4], unused; @@ -789,11 +803,13 @@ format_proc_cpuinfo (void *, char *&destbuf) "model\t\t: %d\n" "model name\t: %s\n" "stepping\t: %d\n" +"microcode\t: 0x%x\n" "cpu MHz\t\t: %d.000\n", family, model, in_buf.s + strspn (in_buf.s, " "), stepping, +microcode, cpu_mhz); if (cache_size >= 0) -- 2.21.0
[PATCH v3 07/10] fhandler_proc.cc(format_proc_cpuinfo): use feature test print macro
feature test print macro makes feature, bit, and flag text comparison and checking easier; handle as common former Intel only feature flags also supported on AMD; change order and some flag names to agree with current Linux --- winsup/cygwin/fhandler_proc.cc | 421 - 1 file changed, 153 insertions(+), 268 deletions(-) diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 51bbdc43f..fbcec38df 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -609,6 +609,8 @@ format_proc_stat (void *, char *&destbuf) } #define print(x) { bufptr = stpcpy (bufptr, (x)); } +/* feature test bit position (0-32) and conditional print */ +#define ftcprint(feat,bitno,msg) if ((feat) & (1 << (bitno))) { print (" " msg); } static inline uint32_t get_msb (uint32_t in) @@ -969,278 +971,170 @@ format_proc_cpuinfo (void *, char *&destbuf) (features1 & (1 << 0)) ? "yes" : "no", level); print ("flags\t\t:"); - if (features1 & (1 << 0)) - print (" fpu"); - if (features1 & (1 << 1)) - print (" vme"); - if (features1 & (1 << 2)) - print (" de"); - if (features1 & (1 << 3)) - print (" pse"); - if (features1 & (1 << 4)) - print (" tsc"); - if (features1 & (1 << 5)) - print (" msr"); - if (features1 & (1 << 6)) - print (" pae"); - if (features1 & (1 << 7)) - print (" mce"); - if (features1 & (1 << 8)) - print (" cx8"); - if (features1 & (1 << 9)) - print (" apic"); - if (features1 & (1 << 11)) - print (" sep"); - if (features1 & (1 << 12)) - print (" mtrr"); - if (features1 & (1 << 13)) - print (" pge"); - if (features1 & (1 << 14)) - print (" mca"); - if (features1 & (1 << 15)) - print (" cmov"); - if (features1 & (1 << 16)) - print (" pat"); - if (features1 & (1 << 17)) - print (" pse36"); - if (features1 & (1 << 18)) - print (" pn"); - if (features1 & (1 << 19)) - print (" clflush"); - if (is_intel && features1 & (1 << 21)) - print (" dts"); - if (is_intel && features1 & (1 << 22)) - print (" acpi"); - if (features1 & (1 << 23)) - print (" mmx"); - if (features1 & (1 << 24)) - print (" fxsr"); - if (features1 & (1 << 25)) - print (" sse"); - if (features1 & (1 << 26)) - print (" sse2"); - if (is_intel && (features1 & (1 << 27))) - print (" ss"); - if (features1 & (1 << 28)) - print (" ht"); - if (is_intel) - { - if (features1 & (1 << 29)) - print (" tm"); - if (features1 & (1 << 30)) - print (" ia64"); - if (features1 & (1 << 31)) - print (" pbe"); - } - + /* cpuid 0x0001 edx */ + ftcprint (features1, 0, "fpu"); /* x87 floating point */ + ftcprint (features1, 1, "vme"); /* VM enhancements */ + ftcprint (features1, 2, "de"); /* debugging extensions */ + ftcprint (features1, 3, "pse"); /* page size extensions */ + ftcprint (features1, 4, "tsc"); /* rdtsc/p */ + ftcprint (features1, 5, "msr"); /* rd/wrmsr */ + ftcprint (features1, 6, "pae"); /* phy addr extensions */ + ftcprint (features1, 7, "mce"); /* Machine check exception */ + ftcprint (features1, 8, "cx8"); /* cmpxchg8b */ + ftcprint (features1, 9, "apic"); /* APIC enabled */ + ftcprint (features1, 11, "sep"); /* sysenter/sysexit */ + ftcprint (features1, 12, "mtrr"); /* memory type range registers */ + ftcprint (features1, 13, "pge"); /* page global extension */ + ftcprint (features1, 14, "mca"); /* machine check architecture */ + ftcprint (features1, 15, "cmov"); /* conditional move */ + ftcprint (features1, 16, "pat"); /* page attribute table */ + ftcprint (features1, 17, "pse36");/* 36 bit page size extensions */ + ftcprint (features1, 18, "pn"); /* processor serial number */ + ftcprint (features1, 19, "clflush"); /* clflush instruction */ + ftcprint (features1, 21, "dts"); /* debug store */ + ftcprint (features1, 22, "acpi"); /* ACPI via MSR */ + ftcprint (features1, 23, "mmx"); /* multimedia extensions */ + ftcprint (features1, 24, "fxsr"); /* fxsave/fxrstor */ + ftcprint (features1, 25, "sse"); /* xmm */ + ftcprint (features1, 26, "sse2"); /* xmm2 */ + ftcprint (features1, 27, "ss"); /* CPU self snoop */ + ftcprint (features1, 28, "ht"); /* hyper threading */ + ftcprint (features1, 29, "tm"); /* acc automatic clock control */ + ftcprint (features1, 30, "ia64"); /* IA 64 processor */ + ftcprint (features1, 31, "pbe"); /* pending break enable */ + + /* AMD cpuid 0x8001 edx */ if (is_amd && maxe >= 0x8001) { cpuid (&un
Re: [PATCH v3 00/10] fhandler_proc.cc(format_proc_cpuinfo): fix issues, add fields, feature flags
On 10/7/2019 12:22 PM, Brian Inglis wrote: > * fix cache size return code handling and make AMD/Intel code common > * fix cpuid level count as number of non-zero leafs excluding sub-leafs > * fix AMD physical cores count documented as core_info low byte + 1 > * round cpu MHz to correct Windows and match Linux cpuinfo > * add bogomips which has been cpu MHz*2 since Pentium MMX > * add microcode from Windows registry Update Revision REG_BINARY > * feature test print macro makes cpuid feature, bit, and flag text > comparison and checking easier; > handle as common former Intel only feature flags also supported on AMD; > change order and some flag names to agree with current Linux > * add 99 feature flags inc. AVX512 extensions, AES, SHA with 20 cpuid calls > * comment out flags not reported by Linux in cpuinfo although some flags > may not be used by Linux > * or model extension bits into high model bits instead of adding > arithmetically like family extension bits > > winsup/cygwin/fhandler_proc.cc | 737 +++-- > 1 file changed, 434 insertions(+), 303 deletions(-) Series pushed, with minor tweaks to the commit messages. (Except for the first line, the commit message should consist of complete sentences, starting with capitals and ending with periods.) Thanks very much. Ken
Re: [PATCH] Cygwin: mkdir and rmdir: treat drive names specially
On 9/27/2019 2:44 PM, Ken Brown wrote: > If the directory name has the form 'x:' followed by one or more > slashes or backslashes, and if there's at least one backslash, assume > that the user is referring to 'x:\', the root directory of drive x, > and don't strip the backslash. > > Previously all trailing slashes and backslashes were stripped, and the > name was treated as a relative file name containing a literal colon. > > Addresses https://cygwin.com/ml/cygwin/2019-08/msg00334.html. > --- > winsup/cygwin/dir.cc | 33 - > 1 file changed, 28 insertions(+), 5 deletions(-) No complaints, so I've pushed this. Ken