diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index f813d8ed4..3706ff7f7 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -7,12 +7,15 @@ enum { enum { _CPU_BRAND_STRING = 1000, + _CPU_MAX_BASIC=999, }; static sysctl_handler(handle_brand_string); +static sysctl_handler(handle_max_basic); const struct known_sysctl sysctls_machdep_cpu[] = { { .oid = _CPU_BRAND_STRING, .type = CTLTYPE_STRING, .exttype = "S", .name = "brand_string", .handler = handle_brand_string }, + { .oid = _CPU_MAX_BASIC, .type = CTLTYPE_INT, .exttype = "I", .name = "max_basic", .handler = handle_max_basic }, { .oid = -1 } }; @@ -51,3 +54,26 @@ sysctl_handler(handle_brand_string) return 0; } +sysctl_handler(handle_max_basic) +{ + unsigned int level = 0; + unsigned int eax = 0; + union + { + struct + { + unsigned int ebx; + unsigned int edx; + unsigned int ecx; + }; + char name[13]; + } v; + + __cpuid(level, eax, v.ebx, v.ecx, v.edx); + + + sprintf(old,"%d",eax); + + return 0; +} + -- 2.51.2 From 2497356622dcdfa57ffaca66d0b845e8d448c5d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20B=C3=A1lint?= Date: Tue, 21 Apr 2020 00:07:20 +0200 Subject: [PATCH 02/10] Implement brand_string, max_basic, stepping, family, model, features --- .../emulation/linux/misc/sysctl_machdep.c | 169 +++++++++++++++--- 1 file changed, 149 insertions(+), 20 deletions(-) diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index 3706ff7f7..2db9ce697 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -6,16 +6,31 @@ enum { }; enum { - _CPU_BRAND_STRING = 1000, - _CPU_MAX_BASIC=999, + _CPU_VENDOR = 1000, + _CPU_MAX_BASIC, + _CPU_FAMILY, + _CPU_MODEL, + _CPU_STEPPING, + _CPU_BRAND_STRING, + _CPU_FEATURES, }; -static sysctl_handler(handle_brand_string); +static sysctl_handler(handle_vendor); static sysctl_handler(handle_max_basic); +static sysctl_handler(handle_family); +static sysctl_handler(handle_model); +static sysctl_handler(handle_stepping); +static sysctl_handler(handle_brand_string); +static sysctl_handler(handle_features); const struct known_sysctl sysctls_machdep_cpu[] = { - { .oid = _CPU_BRAND_STRING, .type = CTLTYPE_STRING, .exttype = "S", .name = "brand_string", .handler = handle_brand_string }, - { .oid = _CPU_MAX_BASIC, .type = CTLTYPE_INT, .exttype = "I", .name = "max_basic", .handler = handle_max_basic }, + { .oid = _CPU_MAX_BASIC, .type = CTLTYPE_INT, .exttype = "I", .name = "max_basic", .handler = handle_max_basic }, + { .oid = _CPU_VENDOR, .type = CTLTYPE_STRING, .exttype = "S", .name = "vendor", .handler = handle_vendor }, + { .oid = _CPU_FAMILY, .type = CTLTYPE_INT, .exttype = "I", .name = "family", .handler = handle_family }, + { .oid = _CPU_MODEL, .type = CTLTYPE_INT, .exttype = "I", .name = "model", .handler = handle_model }, + { .oid = _CPU_STEPPING, .type = CTLTYPE_INT, .exttype = "I", .name = "stepping", .handler = handle_stepping }, + { .oid = _CPU_BRAND_STRING, .type = CTLTYPE_STRING, .exttype = "S", .name = "vendor", .handler = handle_brand_string }, + { .oid = _CPU_FEATURES, .type = CTLTYPE_STRING, .exttype = "S", .name = "features", .handler = handle_features }, { .oid = -1 } }; @@ -31,7 +46,15 @@ const struct known_sysctl sysctls_machdep[] = { : "0" (level)) #endif -sysctl_handler(handle_brand_string) +#ifndef setup +#define setup(value)\ + unsigned int level = 0;\ + unsigned int eax = value;\ + unsigned int ebx;\ + unsigned int edx;\ + unsigned int ecx + +sysctl_handler(handle_vendor) { unsigned int level = 0; unsigned int eax = 0; @@ -56,24 +79,130 @@ sysctl_handler(handle_brand_string) sysctl_handler(handle_max_basic) { - unsigned int level = 0; - unsigned int eax = 0; - union - { - struct - { - unsigned int ebx; - unsigned int edx; - unsigned int ecx; - }; - char name[13]; - } v; + setup(0); + + + __cpuid(level, eax, ebx, ecx, edx); - __cpuid(level, eax, v.ebx, v.ecx, v.edx); - sprintf(old,"%d",eax); return 0; } +sysctl_handler(handle_family) +{ + setup(1); + + __cpuid(level, eax, ebx, ecx, edx); + + eax = eax >> 7; + eax &= 15; + + sprintf(old,"%d",eax); + + return 0; +} + +sysctl_handler(handle_model) +{ + setup(1); + + __cpuid(level, eax, ebx, ecx, edx); + + eax = eax >> 3; + eax &= 15; + + sprintf(old,"%d",eax); + + return 0; +} + +sysctl_handler(handle_stepping) +{ + setup(1); + + __cpuid(level, eax, ebx, ecx, edx); + + eax &= 15; + + sprintf(old,"%d",eax); + + return 0; +} + +sysctl_handler(handle_brand_string) +{ + unsigned int level = 0; + unsigned int eax = 0x80000000; + + unsigned int test[3]; + + __cpuid(level,eax,test, test+1,test+2); + + if(eax < 0x80000004) // the information is not implemented + return 2; + + eax = 0x80000001; + + union + { + unsigned int brand[12]; + char name[49]; + } v; + + __cpuid(level, eax, v.brand+0x1, v.brand+0x2, v.brand+0x3); + v.brand[0x0] = eax; + eax = 0x80000002; + + __cpuid(level, eax, v.brand+0x5, v.brand+0x6, v.brand+0x7); + v.brand[0x4] = eax; + eax = 0x80000003; + + __cpuid(level, eax, v.brand+0x9, v.brand+0xa, v.brand+0xb); + v.brand[0x8] = eax; + + v.name[48] = 0; + copyout_string(v.name, (char*) old, oldlen); + + return 0; +} +sysctl_handler(handle_features) +{ + setup(1); + + char *features[] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", NULL,"SEP","PGE","MCA", + "CMOV", "PAT", "PSE-36", "PSN", "CLFSH", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", + "HTT", "TM", NULL, "PBE"}; + + char *out = (char*)(calloc(119, sizeof(char))); //"worst" case: we have all of it plus null termination + + __cpuid(0,eax,ebx,ecx,edx); + + int j = 0; + int size = sizeof(char); + int counter = 0; + + for (int i = 0; i < 32; ++i) + { + if(edx>>i&1) + { + for(j=0;j< sizeof(features[i])/size; j++) + { + out[counter+j] = features[i][j] + } + + counter = counter + j + 1; + + out[counter] = ' '; + + counter += 1; + + } + } + + copyout_string(out,(*char) old, oldlen); + + return 0; + +} -- 2.51.2 From 54cb6e7d259088287656d731610b67a3b2b8df56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20B=C3=A1lint?= Date: Wed, 22 Apr 2020 09:15:09 +0200 Subject: [PATCH 03/10] Adding changes according to review --- .../emulation/linux/misc/sysctl_machdep.c | 68 +++++++++++-------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index 2db9ce697..872ad9d90 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -1,5 +1,7 @@ #include "sysctl_machdep.h" +#include "simple.h" #include +#include enum { _MACHDEP_CPU = 1000, @@ -53,6 +55,7 @@ const struct known_sysctl sysctls_machdep[] = { unsigned int ebx;\ unsigned int edx;\ unsigned int ecx +#endif sysctl_handler(handle_vendor) { @@ -113,7 +116,7 @@ sysctl_handler(handle_model) eax = eax >> 3; eax &= 15; - sprintf(old,"%d",eax); + __simple_sprintf(old,"%d",eax); return 0; } @@ -133,17 +136,14 @@ sysctl_handler(handle_stepping) sysctl_handler(handle_brand_string) { - unsigned int level = 0; - unsigned int eax = 0x80000000; - - unsigned int test[3]; + setup(0x80000000); - __cpuid(level,eax,test, test+1,test+2); + __cpuid(level,eax,eabx, eacx, eadx); if(eax < 0x80000004) // the information is not implemented return 2; - eax = 0x80000001; + union { @@ -151,16 +151,15 @@ sysctl_handler(handle_brand_string) char name[49]; } v; - __cpuid(level, eax, v.brand+0x1, v.brand+0x2, v.brand+0x3); - v.brand[0x0] = eax; - eax = 0x80000002; - - __cpuid(level, eax, v.brand+0x5, v.brand+0x6, v.brand+0x7); - v.brand[0x4] = eax; - eax = 0x80000003; - - __cpuid(level, eax, v.brand+0x9, v.brand+0xa, v.brand+0xb); - v.brand[0x8] = eax; + for (int i = 1; i < 4; i++) + { + eax = 0x80000000+i; + __cpuid(level, eax, ebx, ecx, edx); + v.brand[0x0+(i-1)*4] = eax; + v.brand[0x1+(i-1)*4] = ebx; + v.brand[0x2+(i-1)*4] = ecx; + v.brand[0x3+(i-1)*4] = edx; + } v.name[48] = 0; copyout_string(v.name, (char*) old, oldlen); @@ -171,37 +170,48 @@ sysctl_handler(handle_features) { setup(1); - char *features[] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", NULL,"SEP","PGE","MCA", - "CMOV", "PAT", "PSE-36", "PSN", "CLFSH", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", - "HTT", "TM", NULL, "PBE"}; + char *features[] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", NULL,"SEP","MTRR","PGE", + "MCA", "CMOV", "PSE-36", "PSN", "CLFSH", NULL, "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", + "HTT", "TM","IA64","PBE"}; - char *out = (char*)(calloc(119, sizeof(char))); //"worst" case: we have all of it plus null termination + char *out = ""; //"worst" case: we have all of it plus null termination __cpuid(0,eax,ebx,ecx,edx); int j = 0; - int size = sizeof(char); int counter = 0; - for (int i = 0; i < 32; ++i) + for (int i = 0; i < 32; i++) { if(edx>>i&1) { - for(j=0;j< sizeof(features[i])/size; j++) + int len = __simple_strlen(features[i]); + int out_len = ____simple_strlen(out); + char *new_out = alloca((len+out_len+1)*sizeof(char)) + for(j=0; j < out_len; j++) + { + new_out[j] = out[j]; + } + + for(j=0; j < len; j++) { - out[counter+j] = features[i][j] + new_out[counter+j] = features[i][j]; } - counter = counter + j + 1; + counter = counter + j; - out[counter] = ' '; + new_out[counter] = ' '; - counter += 1; + out=new_out; + + counter++; } } - copyout_string(out,(*char) old, oldlen); + out[counter] = 0; + + copyout_string(out,(char*) old, oldlen); return 0; -- 2.51.2 From 7d3434e7a2719231dc5033bb76fbdaf3472d9f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20B=C3=A1lint?= Date: Wed, 22 Apr 2020 17:49:25 +0200 Subject: [PATCH 04/10] Simplifying handle_features and replacing sprintf with copyout_string --- .../emulation/linux/misc/sysctl_machdep.c | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index 872ad9d90..59d11960b 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -57,6 +57,15 @@ const struct known_sysctl sysctls_machdep[] = { unsigned int ecx #endif + +inline void copyout_int(int value, char* to_copy, int to_copy_leng) +{ + char tmp[64]; + __simple_sprintf(tmp, "%d", value); + copyout_string(tmp, to_copy, to_copy_leng); +} + + sysctl_handler(handle_vendor) { unsigned int level = 0; @@ -88,7 +97,9 @@ sysctl_handler(handle_max_basic) __cpuid(level, eax, ebx, ecx, edx); - sprintf(old,"%d",eax); + + + copyout_int(eax, (char*)old,oldlen); return 0; } @@ -102,7 +113,7 @@ sysctl_handler(handle_family) eax = eax >> 7; eax &= 15; - sprintf(old,"%d",eax); + copyout_string(old,"%d",eax); return 0; } @@ -116,7 +127,7 @@ sysctl_handler(handle_model) eax = eax >> 3; eax &= 15; - __simple_sprintf(old,"%d",eax); + copyout_int(eax,(char*)old, oldlen); return 0; } @@ -129,7 +140,7 @@ sysctl_handler(handle_stepping) eax &= 15; - sprintf(old,"%d",eax); + copyout_int(eax,(char*)old, oldlen); return 0; } @@ -168,50 +179,40 @@ sysctl_handler(handle_brand_string) } sysctl_handler(handle_features) { - setup(1); - char *features[] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", NULL,"SEP","MTRR","PGE", - "MCA", "CMOV", "PSE-36", "PSN", "CLFSH", NULL, "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", - "HTT", "TM","IA64","PBE"}; + if(old != NULL) + { + setup(1); - char *out = ""; //"worst" case: we have all of it plus null termination + char features[][] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", "","SEP","MTRR","PGE", + "MCA", "CMOV", "PAT", "PSE-36", "PSN", "CLFSH", "", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", + "HTT", "TM","IA64","PBE"}; - __cpuid(0,eax,ebx,ecx,edx); + __cpuid(0,eax,ebx,ecx,edx); - int j = 0; - int counter = 0; + int counter = 0; + int current_old_len = __simple_strlen(old); - for (int i = 0; i < 32; i++) - { - if(edx>>i&1) + for (int i = 0; i < 32; i++) { - int len = __simple_strlen(features[i]); - int out_len = ____simple_strlen(out); - char *new_out = alloca((len+out_len+1)*sizeof(char)) - for(j=0; j < out_len; j++) - { - new_out[j] = out[j]; - } - - for(j=0; j < len; j++) - { - new_out[counter+j] = features[i][j]; - } - counter = counter + j; + if(i == 10 || i == 20) + continue; - new_out[counter] = ' '; + if(edx>>i&1 && current_old_len < oldlen) + { + int len = __simple_strlen(features[i]); + __simple_sprintf(old,"%s %s",old,features[i]); - out=new_out; + counter = counter + len + 1; - counter++; + current_old_len = __simple_strlen(old); + } } - } - out[counter] = 0; - - copyout_string(out,(char*) old, oldlen); + + } return 0; -- 2.51.2 From 698668a5ac2fe6f2bf8174b2a9c837594f7bcce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20B=C3=A1lint?= Date: Wed, 22 Apr 2020 19:55:03 +0200 Subject: [PATCH 05/10] changing copyout_int's signature, fixing typos, fixing handle_features --- .../emulation/linux/misc/sysctl_machdep.c | 63 ++++++++++++++----- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index 59d11960b..2dc2927be 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -3,6 +3,8 @@ #include #include +extern char *strcpy(char *dest, const char *src); + enum { _MACHDEP_CPU = 1000, }; @@ -58,11 +60,11 @@ const struct known_sysctl sysctls_machdep[] = { #endif -inline void copyout_int(int value, char* to_copy, int to_copy_leng) +static inline void copyout_int(int value, char* to_copy, size_t to_copy_length) { char tmp[64]; __simple_sprintf(tmp, "%d", value); - copyout_string(tmp, to_copy, to_copy_leng); + copyout_string(tmp, to_copy, to_copy_length); } @@ -113,7 +115,7 @@ sysctl_handler(handle_family) eax = eax >> 7; eax &= 15; - copyout_string(old,"%d",eax); + copyout_int(eax, old, oldlen); return 0; } @@ -149,7 +151,7 @@ sysctl_handler(handle_brand_string) { setup(0x80000000); - __cpuid(level,eax,eabx, eacx, eadx); + __cpuid(level,eax,ebx, ecx, edx); if(eax < 0x80000004) // the information is not implemented return 2; @@ -180,18 +182,19 @@ sysctl_handler(handle_brand_string) sysctl_handler(handle_features) { - if(old != NULL) - { - setup(1); + setup(1); - char features[][] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", "","SEP","MTRR","PGE", + static const char features[][7] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", "","SEP","MTRR","PGE", "MCA", "CMOV", "PAT", "PSE-36", "PSN", "CLFSH", "", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", "HTT", "TM","IA64","PBE"}; __cpuid(0,eax,ebx,ecx,edx); + if(old != NULL) + { + int counter = 0; - int current_old_len = __simple_strlen(old); + int j = 0; for (int i = 0; i < 32; i++) { @@ -199,20 +202,52 @@ sysctl_handler(handle_features) if(i == 10 || i == 20) continue; - if(edx>>i&1 && current_old_len < oldlen) + if(edx>>i&1 && counter < oldlen) { int len = __simple_strlen(features[i]); - __simple_sprintf(old,"%s %s",old,features[i]); + + strncpy(old,features[i]); - counter = counter + len + 1; + counter = counter + len; + + if(counter < oldlen) + { - current_old_len = __simple_strlen(old); + old[counter] = ' '; + + counter++; + + } } } + } + else + { + int len = 0; + + for (int i = 0; i < 32; i++) + { + + if(i == 10 || i == 20) + continue; + + if(edx>>i&1) + { + if (len != 0) + len++; + + len += __simple_strlen(features[i]); + } + + } + + if (oldlen) + *oldlen = len; - } + + return 0; -- 2.51.2 From 6c6f92d41b88ef7479e15a8110d499b006697de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20B=C3=A1lint?= Date: Wed, 22 Apr 2020 20:01:00 +0200 Subject: [PATCH 06/10] fixing pointer issues --- src/kernel/emulation/linux/misc/sysctl_machdep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index 2dc2927be..ad3282342 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -60,7 +60,7 @@ const struct known_sysctl sysctls_machdep[] = { #endif -static inline void copyout_int(int value, char* to_copy, size_t to_copy_length) +static inline void copyout_int(int value, char* to_copy, size_t* to_copy_length) { char tmp[64]; __simple_sprintf(tmp, "%d", value); @@ -202,7 +202,7 @@ sysctl_handler(handle_features) if(i == 10 || i == 20) continue; - if(edx>>i&1 && counter < oldlen) + if(edx>>i&1 && counter < *oldlen) { int len = __simple_strlen(features[i]); @@ -210,7 +210,7 @@ sysctl_handler(handle_features) counter = counter + len; - if(counter < oldlen) + if(counter < *oldlen) { old[counter] = ' '; -- 2.51.2 From 844b2281ddb0ab1c90ce3c05cbec55b67031b290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20B=C3=A1lint?= Date: Sat, 25 Apr 2020 08:59:32 +0200 Subject: [PATCH 07/10] renaming counter and changing space adding --- .../emulation/linux/misc/sysctl_machdep.c | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index ad3282342..d365275aa 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -3,7 +3,7 @@ #include #include -extern char *strcpy(char *dest, const char *src); +extern char *strncpy(char *dest, const char *src); enum { _MACHDEP_CPU = 1000, @@ -179,6 +179,7 @@ sysctl_handler(handle_brand_string) return 0; } + sysctl_handler(handle_features) { @@ -193,7 +194,8 @@ sysctl_handler(handle_features) if(old != NULL) { - int counter = 0; + char *outsr = (char*)old; + int current_length = 0; int j = 0; for (int i = 0; i < 32; i++) @@ -202,25 +204,41 @@ sysctl_handler(handle_features) if(i == 10 || i == 20) continue; - if(edx>>i&1 && counter < *oldlen) + if(edx>>i&1 && current_length < *oldlen) { - int len = __simple_strlen(features[i]); - - strncpy(old,features[i]); - counter = counter + len; + if (current_length) + { + + outsr[current_length] = ' '; + + current_length++; + + } - if(counter < *oldlen) + if(current_length < *oldlen) { - old[counter] = ' '; + int len = __simple_strlen(features[i]); + + strncpy(outsr + current_length, features[i], + (len < (*oldlen - current_length) ? len : (*oldlen - current_length))); - counter++; + current_length = current_length + len; } } + + } + + if(current_length < *oldlen) + { + + outsr[current_length] = '\0'; + } + } else { -- 2.51.2 From 59dc43681350fbf477a14a877766ec71481b18cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20B=C3=A1lint?= Date: Sat, 25 Apr 2020 14:25:42 +0200 Subject: [PATCH 08/10] Fixing strncpy signature --- src/kernel/emulation/linux/misc/sysctl_machdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index d365275aa..65043eb1f 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -3,7 +3,7 @@ #include #include -extern char *strncpy(char *dest, const char *src); +extern char *strncpy(char *dest, const char *src, __SIZE_TYPE__ n); enum { _MACHDEP_CPU = 1000, -- 2.51.2 From aaca658bf9c41cd1abf7939ac462eb9037efa0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20B=C3=A1lint?= Date: Tue, 28 Apr 2020 11:18:35 +0200 Subject: [PATCH 09/10] Removing redundant variable and fixing formatting --- .../emulation/linux/misc/sysctl_machdep.c | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index 65043eb1f..5ab768ccf 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -52,10 +52,10 @@ const struct known_sysctl sysctls_machdep[] = { #ifndef setup #define setup(value)\ - unsigned int level = 0;\ - unsigned int eax = value;\ - unsigned int ebx;\ - unsigned int edx;\ + unsigned int level = 0; \ + unsigned int eax = value; \ + unsigned int ebx; \ + unsigned int edx; \ unsigned int ecx #endif @@ -98,9 +98,6 @@ sysctl_handler(handle_max_basic) __cpuid(level, eax, ebx, ecx, edx); - - - copyout_int(eax, (char*)old,oldlen); return 0; @@ -153,7 +150,7 @@ sysctl_handler(handle_brand_string) __cpuid(level,eax,ebx, ecx, edx); - if(eax < 0x80000004) // the information is not implemented + if (eax < 0x80000004) // the information is not implemented return 2; @@ -191,20 +188,19 @@ sysctl_handler(handle_features) __cpuid(0,eax,ebx,ecx,edx); - if(old != NULL) + if (old != NULL) { char *outsr = (char*)old; int current_length = 0; - int j = 0; for (int i = 0; i < 32; i++) { - if(i == 10 || i == 20) + if (i == 10 || i == 20) continue; - if(edx>>i&1 && current_length < *oldlen) + if ( (edx & (1<>i&1) + if (edx>>i&1) { if (len != 0) len++; -- 2.51.2 From c9fc45f8340e65b9641db94470b86f3286171896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20B=C3=A1lint?= Date: Tue, 28 Apr 2020 11:27:18 +0200 Subject: [PATCH 10/10] Fixing formatting --- .../emulation/linux/misc/sysctl_machdep.c | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/kernel/emulation/linux/misc/sysctl_machdep.c b/src/kernel/emulation/linux/misc/sysctl_machdep.c index 5ab768ccf..80d09ac14 100644 --- a/src/kernel/emulation/linux/misc/sysctl_machdep.c +++ b/src/kernel/emulation/linux/misc/sysctl_machdep.c @@ -182,63 +182,51 @@ sysctl_handler(handle_features) setup(1); - static const char features[][7] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", "","SEP","MTRR","PGE", - "MCA", "CMOV", "PAT", "PSE-36", "PSN", "CLFSH", "", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", - "HTT", "TM","IA64","PBE"}; + static const char features[][7] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", "","SEP","MTRR","PGE", + "MCA", "CMOV", "PAT", "PSE-36", "PSN", "CLFSH", "", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", + "HTT", "TM","IA64","PBE"}; - __cpuid(0,eax,ebx,ecx,edx); + __cpuid(0,eax,ebx,ecx,edx); + int current_length = 0; if (old != NULL) { char *outsr = (char*)old; - int current_length = 0; for (int i = 0; i < 32; i++) { - if (i == 10 || i == 20) continue; if ( (edx & (1<>i&1) + if (edx & (1<