-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0d13d3
commit db41909
Showing
12 changed files
with
397 additions
and
87 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
SPECS-EXTENDED/numatop/0001-common-Use-sym_type_t-in-elf64_binary_read-signature.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 06c6d857654fdd4230604b4cd4cc2c127757574d Mon Sep 17 00:00:00 2001 | ||
From: Dridi Boukelmoune <[email protected]> | ||
Date: Mon, 4 Mar 2024 22:57:13 +0100 | ||
Subject: [PATCH 1/9] common: Use sym_type_t in elf64_binary_read() signature | ||
|
||
This silences the enum-int-mismatch warning. | ||
--- | ||
common/os/sym.c | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/common/os/sym.c b/common/os/sym.c | ||
index 9ead1fb..f0b5706 100644 | ||
--- a/common/os/sym.c | ||
+++ b/common/os/sym.c | ||
@@ -463,7 +463,7 @@ L_EXIT: | ||
} | ||
|
||
static int | ||
-elf64_binary_read(sym_binary_t *binary, unsigned int sym_type) | ||
+elf64_binary_read(sym_binary_t *binary, sym_type_t sym_type) | ||
{ | ||
Elf64_Ehdr ehdr; | ||
Elf64_Shdr shdr; | ||
-- | ||
2.44.0 | ||
|
35 changes: 35 additions & 0 deletions
35
SPECS-EXTENDED/numatop/0002-common-Add-format-strings-to-mvwprintw-calls.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From 6316116c1e05031e53a1f5196ed92559c3123cc2 Mon Sep 17 00:00:00 2001 | ||
From: Dridi Boukelmoune <[email protected]> | ||
Date: Mon, 4 Mar 2024 23:00:10 +0100 | ||
Subject: [PATCH 2/9] common: Add format strings to mvwprintw() calls | ||
|
||
This silences the format-security warning. | ||
--- | ||
common/reg.c | 4 ++-- | ||
1 file changed, 2 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/common/reg.c b/common/reg.c | ||
index 1a87161..ad37274 100644 | ||
--- a/common/reg.c | ||
+++ b/common/reg.c | ||
@@ -240,7 +240,7 @@ reg_line_write(win_reg_t *r, int line, reg_align_t align, char *content) | ||
} | ||
|
||
if (len > 0) { | ||
- (void) mvwprintw(r->hdl, line, pos_x, content); | ||
+ (void) mvwprintw(r->hdl, line, pos_x, "%s", content); | ||
} | ||
|
||
if (r->mode != 0) { | ||
@@ -267,7 +267,7 @@ reg_highlight_write(win_reg_t *r, int line, int align, char *content) | ||
} | ||
|
||
if (len > 0) { | ||
- (void) mvwprintw(r->hdl, line, pos_x, content); | ||
+ (void) mvwprintw(r->hdl, line, pos_x, "%s", content); | ||
} | ||
|
||
(void) wattroff(r->hdl, A_REVERSE | A_BOLD); | ||
-- | ||
2.44.0 | ||
|
32 changes: 32 additions & 0 deletions
32
SPECS-EXTENDED/numatop/0003-common-Remove-unnecessary-temp-buffer.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From 79c4cbbdfb603cf52f2b1416d2e1048074eb5a2f Mon Sep 17 00:00:00 2001 | ||
From: Dridi Boukelmoune <[email protected]> | ||
Date: Mon, 4 Mar 2024 23:02:15 +0100 | ||
Subject: [PATCH 3/9] common: Remove unnecessary temp buffer | ||
|
||
--- | ||
common/win.c | 5 +---- | ||
1 file changed, 1 insertion(+), 4 deletions(-) | ||
|
||
diff --git a/common/win.c b/common/win.c | ||
index d0a8f3b..cdc5817 100644 | ||
--- a/common/win.c | ||
+++ b/common/win.c | ||
@@ -484,14 +484,11 @@ topnproc_data_show(dyn_win_t *win) | ||
static void | ||
load_msg_show(void) | ||
{ | ||
- char content[64]; | ||
win_reg_t r; | ||
|
||
- (void) snprintf(content, sizeof (content), "Loading ..."); | ||
- | ||
(void) reg_init(&r, 0, 1, g_scr_width, g_scr_height - 1, A_BOLD); | ||
reg_erase(&r); | ||
- reg_line_write(&r, 1, ALIGN_LEFT, content); | ||
+ reg_line_write(&r, 1, ALIGN_LEFT, "Loading ..."); | ||
reg_refresh(&r); | ||
reg_win_destroy(&r); | ||
} | ||
-- | ||
2.44.0 | ||
|
51 changes: 51 additions & 0 deletions
51
SPECS-EXTENDED/numatop/0004-common-Use-memcpy-to-the-process-name-to-a-line.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
From 5e8f0af6241fdadc7dd52a26c18df0789ebf03e8 Mon Sep 17 00:00:00 2001 | ||
From: Dridi Boukelmoune <[email protected]> | ||
Date: Mon, 4 Mar 2024 23:03:02 +0100 | ||
Subject: [PATCH 4/9] common: Use memcpy() to the process name to a line | ||
|
||
The copy will either collect the whole string, and potentially a little | ||
more, but from a safe location, or a truncated string with a null char | ||
guaranteed by the memset() call above. | ||
|
||
This silences the stringop-truncation warning. | ||
--- | ||
common/win.c | 9 +++------ | ||
1 file changed, 3 insertions(+), 6 deletions(-) | ||
|
||
diff --git a/common/win.c b/common/win.c | ||
index cdc5817..d97da43 100644 | ||
--- a/common/win.c | ||
+++ b/common/win.c | ||
@@ -355,8 +355,7 @@ topnproc_data_save(track_proc_t *proc, int intval, topnproc_line_t *line) | ||
/* | ||
* Cut off the process name if it's too long. | ||
*/ | ||
- (void) strncpy(line->proc_name, proc->name, sizeof (line->proc_name)); | ||
- line->proc_name[WIN_PROCNAME_SIZE - 1] = 0; | ||
+ memcpy(line->proc_name, proc->name, sizeof (line->proc_name) - 1); | ||
line->pid = proc->pid; | ||
line->nlwp = proc_nlwp(proc); | ||
|
||
@@ -2892,8 +2891,7 @@ pqos_cmt_proc_data_save(track_proc_t *proc, track_lwp_t *lwp, int intval, | ||
{ | ||
(void) memset(line, 0, sizeof (pqos_cmt_proc_line_t)); | ||
|
||
- (void) strncpy(line->proc_name, proc->name, sizeof (line->proc_name)); | ||
- line->proc_name[WIN_PROCNAME_SIZE - 1] = 0; | ||
+ memcpy(line->proc_name, proc->name, sizeof (line->proc_name) - 1); | ||
line->pid = proc->pid; | ||
line->nlwp = proc_nlwp(proc); | ||
|
||
@@ -3216,8 +3214,7 @@ pqos_mbm_proc_data_save(track_proc_t *proc, track_lwp_t *lwp, int intval, | ||
{ | ||
(void) memset(line, 0, sizeof (pqos_mbm_proc_line_t)); | ||
|
||
- (void) strncpy(line->proc_name, proc->name, sizeof (line->proc_name)); | ||
- line->proc_name[WIN_PROCNAME_SIZE - 1] = 0; | ||
+ memcpy(line->proc_name, proc->name, sizeof (line->proc_name) - 1); | ||
line->pid = proc->pid; | ||
line->nlwp = proc_nlwp(proc); | ||
|
||
-- | ||
2.44.0 | ||
|
31 changes: 31 additions & 0 deletions
31
SPECS-EXTENDED/numatop/0005-common-Replace-malloc-strncpy-with-strdup.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
From c46ebd47907a77bfbcfa5ac8dacf7536102ae3af Mon Sep 17 00:00:00 2001 | ||
From: Dridi Boukelmoune <[email protected]> | ||
Date: Mon, 4 Mar 2024 23:07:07 +0100 | ||
Subject: [PATCH 5/9] common: Replace malloc()+strncpy() with strdup() | ||
|
||
This silences the stringop-truncation warning. | ||
--- | ||
common/os/os_util.c | 4 +--- | ||
1 file changed, 1 insertion(+), 3 deletions(-) | ||
|
||
diff --git a/common/os/os_util.c b/common/os/os_util.c | ||
index f442729..3fdb4ca 100644 | ||
--- a/common/os/os_util.c | ||
+++ b/common/os/os_util.c | ||
@@ -387,12 +387,10 @@ str_int_extract(char *str, int *arr, int arr_size, int *num) | ||
int len = strlen(str); | ||
boolean_t ret = B_FALSE; | ||
|
||
- if ((scopy = malloc(len + 1)) == NULL) { | ||
+ if ((scopy = strdup(str)) == NULL) { | ||
return (B_FALSE); | ||
} | ||
|
||
- strncpy(scopy, str, len); | ||
- scopy[len] = 0; | ||
cur = scopy; | ||
|
||
while (cur < (scopy + len)) { | ||
-- | ||
2.44.0 | ||
|
117 changes: 117 additions & 0 deletions
117
SPECS-EXTENDED/numatop/0006-common-Build-node-string-with-bound-checks.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
From 48a9a5597c638ca580458753fba564f0cfe248ea Mon Sep 17 00:00:00 2001 | ||
From: Dridi Boukelmoune <[email protected]> | ||
Date: Mon, 4 Mar 2024 23:11:13 +0100 | ||
Subject: [PATCH 6/9] common: Build node string with bound checks | ||
|
||
A print_buf() function is added to keep track of progress inside the s1 | ||
buffer and the remaining space. With s1 acting as a cursor and vsnprintf | ||
taking care of formatting, the temp buffers s2 and s3 are no longer | ||
needed. | ||
|
||
This silences the stringop-overflow warning. | ||
--- | ||
common/os/os_win.c | 44 ++++++++++++++++++++++++++++++-------------- | ||
1 file changed, 30 insertions(+), 14 deletions(-) | ||
|
||
diff --git a/common/os/os_win.c b/common/os/os_win.c | ||
index de198ca..29afc19 100644 | ||
--- a/common/os/os_win.c | ||
+++ b/common/os/os_win.c | ||
@@ -29,6 +29,7 @@ | ||
#include <inttypes.h> | ||
#include <stdlib.h> | ||
#include <sys/types.h> | ||
+#include <stdarg.h> | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
@@ -105,6 +106,28 @@ cpuid_cmp(const void *a, const void *b) | ||
return (0); | ||
} | ||
|
||
+static void | ||
+print_buf(char **destp, int *sizep, const char *fmt, ...) | ||
+{ | ||
+ va_list ap; | ||
+ int len; | ||
+ | ||
+ if (*sizep <= 0) | ||
+ return; | ||
+ | ||
+ va_start(ap, fmt); | ||
+ len = vsnprintf(*destp, *sizep, fmt, ap); | ||
+ va_end(ap); | ||
+ | ||
+ if (len >= *sizep) { | ||
+ *sizep = 0; | ||
+ return; | ||
+ } | ||
+ | ||
+ *destp += len; | ||
+ *sizep -= len; | ||
+} | ||
+ | ||
/* | ||
* Build a readable string of CPU ID and try to reduce the string length. e.g. | ||
* For cpu1, cpu2, cpu3, cpu4, the string is "CPU(1-4)", | ||
@@ -113,7 +136,6 @@ cpuid_cmp(const void *a, const void *b) | ||
static void | ||
node_cpu_string(node_t *node, char *s1, int size) | ||
{ | ||
- char s2[128], s3[128]; | ||
int i, j, k, l, cpuid_start; | ||
int *cpuid_arr; | ||
int ncpus; | ||
@@ -140,8 +162,7 @@ node_cpu_string(node_t *node, char *s1, int size) | ||
cpuid_start = cpuid_arr[0]; | ||
|
||
if (ncpus == 1) { | ||
- (void) snprintf(s2, sizeof (s2), "%d", cpuid_start); | ||
- (void) strncat(s1, s2, strlen(s2)); | ||
+ (void) snprintf(s1, size, "%d", cpuid_start); | ||
free(cpuid_arr); | ||
return; | ||
} | ||
@@ -154,33 +175,28 @@ node_cpu_string(node_t *node, char *s1, int size) | ||
if (cpuid_arr[j] != cpuid_start + l) { | ||
if (k < ncpus) { | ||
if (l == 1) { | ||
- (void) snprintf(s2, sizeof (s2), "%d ", cpuid_start); | ||
+ print_buf(&s1, &size, "%d ", cpuid_start); | ||
} else { | ||
- (void) snprintf(s2, sizeof (s2), | ||
+ print_buf(&s1, &size, | ||
"%d-%d ", cpuid_start, cpuid_start + l - 1); | ||
} | ||
} else { | ||
if (l == 1) { | ||
- (void) snprintf(s2, sizeof (s2), "%d", | ||
- cpuid_start); | ||
+ print_buf(&s1, &size, "%d", cpuid_start); | ||
} else { | ||
- (void) snprintf(s2, sizeof (s2), "%d-%d", | ||
+ print_buf(&s1, &size, "%d-%d", | ||
cpuid_start, cpuid_start + l - 1); | ||
} | ||
|
||
- (void) snprintf(s3, sizeof (s3), " %d", | ||
- cpuid_arr[j]); | ||
- (void) strncat(s2, s3, strlen(s3)); | ||
+ print_buf(&s1, &size, " %d", cpuid_arr[j]); | ||
} | ||
|
||
- (void) strncat(s1, s2, strlen(s2)); | ||
cpuid_start = cpuid_arr[j]; | ||
l = 1; | ||
} else { | ||
if (k == ncpus) { | ||
- (void) snprintf(s2, sizeof (s2), "%d-%d", | ||
+ print_buf(&s1, &size, "%d-%d", | ||
cpuid_start, cpuid_start + l); | ||
- (void) strncat(s1, s2, strlen(s2)); | ||
} else { | ||
l++; | ||
} | ||
-- | ||
2.44.0 | ||
|
29 changes: 29 additions & 0 deletions
29
SPECS-EXTENDED/numatop/0007-common-Increase-node-string-buffer-size.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
From e21a7f17997f2e611e8f706761065c8ec6576f5c Mon Sep 17 00:00:00 2001 | ||
From: Dridi Boukelmoune <[email protected]> | ||
Date: Mon, 4 Mar 2024 23:16:27 +0100 | ||
Subject: [PATCH 7/9] common: Increase node string buffer size | ||
|
||
Since the maximum number of CPUs was doubled, it might be reasonable to | ||
double the size of the buffer for the string representation. | ||
|
||
Refs 6f6cc3b24d84c413556639b64a62aca6ad0b21cc | ||
--- | ||
common/os/os_win.c | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/common/os/os_win.c b/common/os/os_win.c | ||
index 29afc19..c0de320 100644 | ||
--- a/common/os/os_win.c | ||
+++ b/common/os/os_win.c | ||
@@ -222,7 +222,7 @@ nodedetail_line_show(win_reg_t *reg, char *title, char *value, int line) | ||
void | ||
os_nodedetail_data(dyn_nodedetail_t *dyn, win_reg_t *seg) | ||
{ | ||
- char s1[256], s2[32]; | ||
+ char s1[512], s2[32]; | ||
node_t *node; | ||
win_countvalue_t value; | ||
node_meminfo_t meminfo; | ||
-- | ||
2.44.0 | ||
|
41 changes: 41 additions & 0 deletions
41
SPECS-EXTENDED/numatop/0008-x86-Add-missing-fields-to-s_emr_config.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
From e0f2421ecf7bd9b4783901eafea1d9f386c025ac Mon Sep 17 00:00:00 2001 | ||
From: Dridi Boukelmoune <[email protected]> | ||
Date: Mon, 4 Mar 2024 23:19:41 +0100 | ||
Subject: [PATCH 8/9] x86: Add missing fields to s_emr_config | ||
|
||
It looks as if EMR support had been authored before #66 was merged, | ||
leading to a mismatch between the struct definition and this array | ||
initialization. | ||
|
||
This silences the missing-field-initializers warning. | ||
|
||
Refs d3fcffc6a9cc2ad61b6f9a902796cb317bec266a | ||
Refs #66 | ||
--- | ||
x86/skl.c | 10 +++++----- | ||
1 file changed, 5 insertions(+), 5 deletions(-) | ||
|
||
diff --git a/x86/skl.c b/x86/skl.c | ||
index 17cfbcc..a80a868 100644 | ||
--- a/x86/skl.c | ||
+++ b/x86/skl.c | ||
@@ -64,11 +64,11 @@ static plat_event_config_t s_spr_config[PERF_COUNT_NUM] = { | ||
}; | ||
|
||
static plat_event_config_t s_emr_config[PERF_COUNT_NUM] = { | ||
- { PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, 0x53, 0, "cpu_clk_unhalted.core" }, | ||
- { PERF_TYPE_RAW, 0x012A, 0x53, 0x730000001, "off_core_response_0" }, | ||
- { PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, 0x53, 0, "cpu_clk_unhalted.ref" }, | ||
- { PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, 0x53, 0, "instr_retired.any" }, | ||
- { PERF_TYPE_RAW, 0x012B, 0x53, 0x104000001, "off_core_response_1" } | ||
+ { PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, 0x53, 0, 0, 0, "cpu_clk_unhalted.core" }, | ||
+ { PERF_TYPE_RAW, 0x012A, 0x53, 0x730000001, 0, 0, "off_core_response_0" }, | ||
+ { PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, 0x53, 0, 0, 0, "cpu_clk_unhalted.ref" }, | ||
+ { PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, 0x53, 0, 0, 0, "instr_retired.any" }, | ||
+ { PERF_TYPE_RAW, 0x012B, 0x53, 0x104000001, 0, 0, "off_core_response_1" } | ||
}; | ||
|
||
static plat_event_config_t s_skl_ll = { | ||
-- | ||
2.44.0 | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.