Skip to content

Commit a542f25

Browse files
committed
odroidgoa kernel gcc-10 patches
Also sent upstream hardkernel/linux#410 The kernel builds with these patches and aarch64 linux-tools perf also builds Signed-off-by: Gleb Mazovetskiy <[email protected]>
1 parent 4d706ef commit a542f25

13 files changed

+6099
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
From 02bcb5a7a3dc63346c14fc7aaae3102db548542d Mon Sep 17 00:00:00 2001
2+
From: Al Viro <[email protected]>
3+
Date: Sat, 10 Sep 2016 16:50:00 -0400
4+
Subject: [PATCH] BACKPORT: arm64: don't zero in __copy_from_user{,_inatomic}
5+
6+
Signed-off-by: Al Viro <[email protected]>
7+
---
8+
arch/arm64/include/asm/uaccess.h | 11 +++++++----
9+
arch/arm64/lib/copy_from_user.S | 7 +------
10+
2 files changed, 8 insertions(+), 10 deletions(-)
11+
12+
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
13+
index d0919bcb1953..b26ad8507e93 100644
14+
--- a/arch/arm64/include/asm/uaccess.h
15+
+++ b/arch/arm64/include/asm/uaccess.h
16+
@@ -410,12 +410,15 @@ static inline unsigned long __must_check __copy_to_user(void __user *to, const v
17+
18+
static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
19+
{
20+
+ unsigned long res = n;
21+
+
22+
if (access_ok(VERIFY_READ, from, n)) {
23+
check_object_size(to, n, false);
24+
- n = __arch_copy_from_user(to, from, n);
25+
- } else /* security hole - plug it */
26+
- memset(to, 0, n);
27+
- return n;
28+
+ res = __arch_copy_from_user(to, from, n);
29+
+ }
30+
+ if (unlikely(res))
31+
+ memset(to + (n - res), 0, res);
32+
+ return res;
33+
}
34+
35+
static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
36+
diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S
37+
index 683adc358be7..c7a7d9689e8f 100644
38+
--- a/arch/arm64/lib/copy_from_user.S
39+
+++ b/arch/arm64/lib/copy_from_user.S
40+
@@ -74,11 +74,6 @@ ENDPROC(__arch_copy_from_user)
41+
42+
.section .fixup,"ax"
43+
.align 2
44+
-9998:
45+
- sub x0, end, dst
46+
-9999:
47+
- strb wzr, [dst], #1 // zero remaining buffer space
48+
- cmp dst, end
49+
- b.lo 9999b
50+
+9998: sub x0, end, dst // bytes not copied
51+
ret
52+
.previous
53+
--
54+
2.27.0
55+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From 7cdd201761fea40d7467b97fb9f2e2bcd5ec63c4 Mon Sep 17 00:00:00 2001
2+
From: Gleb Mazovetskiy <[email protected]>
3+
Date: Mon, 25 Jan 2021 00:41:55 +0000
4+
Subject: [PATCH 01/12] perf: cs-etm: fix duplicate def of traceid_list
5+
6+
Backport of 168200b6d6ea0cb5765943ec5da5b8149701f36a upstream
7+
8+
Signed-off-by: Gleb Mazovetskiy <[email protected]>
9+
---
10+
tools/perf/util/cs-etm.c | 3 +++
11+
tools/perf/util/cs-etm.h | 3 ---
12+
2 files changed, 3 insertions(+), 3 deletions(-)
13+
14+
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
15+
index ca93257a6cb7..ee23fd37f241 100644
16+
--- a/tools/perf/util/cs-etm.c
17+
+++ b/tools/perf/util/cs-etm.c
18+
@@ -91,6 +91,9 @@ struct cs_etm_queue {
19+
bool kernel_mapped;
20+
};
21+
22+
+/* RB tree for quick conversion between traceID and metadata pointers */
23+
+static struct intlist *traceid_list;
24+
+
25+
static int cs_etm__get_trace(struct cs_etm_buffer *buff, struct cs_etm_queue *etmq);
26+
static int cs_etm__update_queues(struct cs_etm_auxtrace *);
27+
static int cs_etm__process_queues(struct cs_etm_auxtrace *, u64);
28+
diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h
29+
index ec6ff78f1905..1f785a92fb20 100644
30+
--- a/tools/perf/util/cs-etm.h
31+
+++ b/tools/perf/util/cs-etm.h
32+
@@ -65,9 +65,6 @@ enum {
33+
CS_ETMV4_PRIV_MAX,
34+
};
35+
36+
-/* RB tree for quick conversion between traceID and CPUs */
37+
-struct intlist *traceid_list;
38+
-
39+
#define KiB(x) ((x) * 1024)
40+
#define MiB(x) ((x) * 1024 * 1024)
41+
42+
--
43+
2.27.0
44+
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
From 62b75df5f013d9f7b5b47ff5369dd4b3143ab965 Mon Sep 17 00:00:00 2001
2+
From: Gleb Mazovetskiy <[email protected]>
3+
Date: Mon, 25 Jan 2021 00:52:10 +0000
4+
Subject: [PATCH 02/12] perf bench: Share some global variables to fix build
5+
with gcc 10
6+
7+
Based on https://git.yoctoproject.org/cgit/cgit.cgi/meta-arm/tree/meta-arm-bsp/recipes-kernel/linux/linux-yocto-5.3/0003-perf-bench-Share-some-global-variables-to-fix-build-.patch
8+
9+
Signed-off-by: Gleb Mazovetskiy <[email protected]>
10+
---
11+
tools/perf/bench/bench.h | 4 ++++
12+
tools/perf/bench/futex-hash.c | 12 ++++++------
13+
tools/perf/bench/futex-lock-pi.c | 11 +++++------
14+
3 files changed, 15 insertions(+), 12 deletions(-)
15+
16+
diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
17+
index a50df86f2b9b..e758896f4995 100644
18+
--- a/tools/perf/bench/bench.h
19+
+++ b/tools/perf/bench/bench.h
20+
@@ -1,6 +1,10 @@
21+
#ifndef BENCH_H
22+
#define BENCH_H
23+
24+
+#include <sys/time.h>
25+
+
26+
+extern struct timeval bench__start, bench__end, bench__runtime;
27+
+
28+
/*
29+
* The madvise transparent hugepage constants were added in glibc
30+
* 2.13. For compatibility with older versions of glibc, define these
31+
diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c
32+
index fc9bebd2cca0..80313b40d324 100644
33+
--- a/tools/perf/bench/futex-hash.c
34+
+++ b/tools/perf/bench/futex-hash.c
35+
@@ -28,7 +28,7 @@ static unsigned int nfutexes = 1024;
36+
static bool fshared = false, done = false, silent = false;
37+
static int futex_flag = 0;
38+
39+
-struct timeval start, end, runtime;
40+
+struct timeval bench__start, bench__end, bench__runtime;
41+
static pthread_mutex_t thread_lock;
42+
static unsigned int threads_starting;
43+
static struct stats throughput_stats;
44+
@@ -92,8 +92,8 @@ static void toggle_done(int sig __maybe_unused,
45+
{
46+
/* inform all threads that we're done for the day */
47+
done = true;
48+
- gettimeofday(&end, NULL);
49+
- timersub(&end, &start, &runtime);
50+
+ gettimeofday(&bench__end, NULL);
51+
+ timersub(&bench__end, &bench__start, &bench__runtime);
52+
}
53+
54+
static void print_summary(void)
55+
@@ -103,7 +103,7 @@ static void print_summary(void)
56+
57+
printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n",
58+
!silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg),
59+
- (int) runtime.tv_sec);
60+
+ (int) bench__runtime.tv_sec);
61+
}
62+
63+
int bench_futex_hash(int argc, const char **argv,
64+
@@ -148,7 +148,7 @@ int bench_futex_hash(int argc, const char **argv,
65+
66+
threads_starting = nthreads;
67+
pthread_attr_init(&thread_attr);
68+
- gettimeofday(&start, NULL);
69+
+ gettimeofday(&bench__start, NULL);
70+
for (i = 0; i < nthreads; i++) {
71+
worker[i].tid = i;
72+
worker[i].futex = calloc(nfutexes, sizeof(*worker[i].futex));
73+
@@ -191,7 +191,7 @@ int bench_futex_hash(int argc, const char **argv,
74+
pthread_mutex_destroy(&thread_lock);
75+
76+
for (i = 0; i < nthreads; i++) {
77+
- unsigned long t = worker[i].ops/runtime.tv_sec;
78+
+ unsigned long t = worker[i].ops/bench__runtime.tv_sec;
79+
update_stats(&throughput_stats, t);
80+
if (!silent) {
81+
if (nfutexes == 1)
82+
diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c
83+
index bc6a16adbca8..8d0f60456a95 100644
84+
--- a/tools/perf/bench/futex-lock-pi.c
85+
+++ b/tools/perf/bench/futex-lock-pi.c
86+
@@ -29,7 +29,6 @@ static bool silent = false, multi = false;
87+
static bool done = false, fshared = false;
88+
static unsigned int ncpus, nthreads = 0;
89+
static int futex_flag = 0;
90+
-struct timeval start, end, runtime;
91+
static pthread_mutex_t thread_lock;
92+
static unsigned int threads_starting;
93+
static struct stats throughput_stats;
94+
@@ -56,7 +55,7 @@ static void print_summary(void)
95+
96+
printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n",
97+
!silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg),
98+
- (int) runtime.tv_sec);
99+
+ (int) bench__runtime.tv_sec);
100+
}
101+
102+
static void toggle_done(int sig __maybe_unused,
103+
@@ -65,8 +64,8 @@ static void toggle_done(int sig __maybe_unused,
104+
{
105+
/* inform all threads that we're done for the day */
106+
done = true;
107+
- gettimeofday(&end, NULL);
108+
- timersub(&end, &start, &runtime);
109+
+ gettimeofday(&bench__end, NULL);
110+
+ timersub(&bench__end, &bench__start, &bench__runtime);
111+
}
112+
113+
static void *workerfn(void *arg)
114+
@@ -172,7 +171,7 @@ int bench_futex_lock_pi(int argc, const char **argv,
115+
116+
threads_starting = nthreads;
117+
pthread_attr_init(&thread_attr);
118+
- gettimeofday(&start, NULL);
119+
+ gettimeofday(&bench__start, NULL);
120+
121+
create_threads(worker, thread_attr);
122+
pthread_attr_destroy(&thread_attr);
123+
@@ -198,7 +197,7 @@ int bench_futex_lock_pi(int argc, const char **argv,
124+
pthread_mutex_destroy(&thread_lock);
125+
126+
for (i = 0; i < nthreads; i++) {
127+
- unsigned long t = worker[i].ops/runtime.tv_sec;
128+
+ unsigned long t = worker[i].ops/bench__runtime.tv_sec;
129+
130+
update_stats(&throughput_stats, t);
131+
if (!silent)
132+
--
133+
2.27.0
134+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From 89b28cc5ae940970fa4530722c1419dd728a6e15 Mon Sep 17 00:00:00 2001
2+
From: Gleb Mazovetskiy <[email protected]>
3+
Date: Mon, 25 Jan 2021 00:57:06 +0000
4+
Subject: [PATCH 03/12] perf: Make perf able to build with latest libbfd
5+
6+
Based on http://lore.kernel.org/lkml/[email protected]
7+
8+
Signed-off-by: Gleb Mazovetskiy <[email protected]>
9+
---
10+
tools/perf/util/srcline.c | 16 +++++++++++++++-
11+
1 file changed, 15 insertions(+), 1 deletion(-)
12+
13+
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
14+
index b4db3f48e3b0..2853d4728ab9 100644
15+
--- a/tools/perf/util/srcline.c
16+
+++ b/tools/perf/util/srcline.c
17+
@@ -86,16 +86,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
18+
bfd_vma pc, vma;
19+
bfd_size_type size;
20+
struct a2l_data *a2l = data;
21+
+ flagword flags;
22+
23+
if (a2l->found)
24+
return;
25+
26+
- if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
27+
+#ifdef bfd_get_section_flags
28+
+ flags = bfd_get_section_flags(abfd, section);
29+
+#else
30+
+ flags = bfd_section_flags(section);
31+
+#endif
32+
+ if ((flags & SEC_ALLOC) == 0)
33+
return;
34+
35+
pc = a2l->addr;
36+
+#ifdef bfd_get_section_vma
37+
vma = bfd_get_section_vma(abfd, section);
38+
+#else
39+
+ vma = bfd_section_vma(section);
40+
+#endif
41+
+#ifdef bfd_get_section_size
42+
size = bfd_get_section_size(section);
43+
+#else
44+
+ size = bfd_section_size(section);
45+
+#endif
46+
47+
if (pc < vma || pc >= vma + size)
48+
return;
49+
--
50+
2.27.0
51+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
From 186f5ff69e29e0b1add523bb03462a690b2348c0 Mon Sep 17 00:00:00 2001
2+
From: Andrey Zhizhikin <[email protected]>
3+
Date: Wed, 11 Dec 2019 08:01:09 +0000
4+
Subject: [PATCH 04/12] tools lib api fs: Fix gcc9 stringop-truncation
5+
compilation error
6+
7+
GCC9 introduced string hardening mechanisms, which exhibits the error
8+
during fs api compilation:
9+
10+
error: '__builtin_strncpy' specified bound 4096 equals destination size
11+
[-Werror=stringop-truncation]
12+
13+
This comes when the length of copy passed to strncpy is is equal to
14+
destination size, which could potentially lead to buffer overflow.
15+
16+
There is a need to mitigate this potential issue by limiting the size of
17+
destination by 1 and explicitly terminate the destination with NULL.
18+
19+
Signed-off-by: Andrey Zhizhikin <[email protected]>
20+
Reviewed-by: Petr Mladek <[email protected]>
21+
Acked-by: Jiri Olsa <[email protected]>
22+
Cc: Alexei Starovoitov <[email protected]>
23+
Cc: Andrii Nakryiko <[email protected]>
24+
Cc: Daniel Borkmann <[email protected]>
25+
Cc: Kefeng Wang <[email protected]>
26+
Cc: Martin KaFai Lau <[email protected]>
27+
Cc: Petr Mladek <[email protected]>
28+
Cc: Sergey Senozhatsky <[email protected]>
29+
Cc: Song Liu <[email protected]>
30+
Cc: Yonghong Song <[email protected]>
31+
32+
33+
Link: http://lore.kernel.org/lkml/[email protected]
34+
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
35+
---
36+
tools/lib/api/fs/fs.c | 4 +++-
37+
1 file changed, 3 insertions(+), 1 deletion(-)
38+
39+
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
40+
index 459599d1b6c4..58f05748dd39 100644
41+
--- a/tools/lib/api/fs/fs.c
42+
+++ b/tools/lib/api/fs/fs.c
43+
@@ -179,6 +179,7 @@ static bool fs__env_override(struct fs *fs)
44+
size_t name_len = strlen(fs->name);
45+
/* name + "_PATH" + '\0' */
46+
char upper_name[name_len + 5 + 1];
47+
+
48+
memcpy(upper_name, fs->name, name_len);
49+
mem_toupper(upper_name, name_len);
50+
strcpy(&upper_name[name_len], "_PATH");
51+
@@ -188,7 +189,8 @@ static bool fs__env_override(struct fs *fs)
52+
return false;
53+
54+
fs->found = true;
55+
- strncpy(fs->path, override_path, sizeof(fs->path));
56+
+ strncpy(fs->path, override_path, sizeof(fs->path) - 1);
57+
+ fs->path[sizeof(fs->path) - 1] = '\0';
58+
return true;
59+
}
60+
61+
--
62+
2.27.0
63+

0 commit comments

Comments
 (0)