diff options
author | Mingli Yu <mingli.yu@windriver.com> | 2022-09-19 11:31:32 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-09-21 09:20:49 +0100 |
commit | 76b57a8f71848a5905cfa15eabf8bf810ad1c803 (patch) | |
tree | e953342a6bc0054205e7d9a9e786ec4bae0f63fd /meta/recipes-core/busybox | |
parent | 4a0e2eb3ecc85da8169fff56b189502abd45e2f6 (diff) | |
download | poky-76b57a8f71848a5905cfa15eabf8bf810ad1c803.tar.gz |
busybox: add devmem 128-bit support
Add devmem 128-bit support [1].
[1] https://git.busybox.net/busybox/commit/?id=d432049f288c9acdc4a7caa729c68ceba3c5dca1
(From OE-Core rev: d0d78aa7a34fbd7065b31ffc224be8e1984cb7aa)
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/busybox')
-rw-r--r-- | meta/recipes-core/busybox/busybox/0001-devmem-add-128-bit-width.patch | 128 | ||||
-rw-r--r-- | meta/recipes-core/busybox/busybox_1.35.0.bb | 1 |
2 files changed, 129 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-devmem-add-128-bit-width.patch b/meta/recipes-core/busybox/busybox/0001-devmem-add-128-bit-width.patch new file mode 100644 index 0000000000..985e2bf1d9 --- /dev/null +++ b/meta/recipes-core/busybox/busybox/0001-devmem-add-128-bit-width.patch | |||
@@ -0,0 +1,128 @@ | |||
1 | From d432049f288c9acdc4a7caa729c68ceba3c5dca1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Aaro Koskinen <aaro.koskinen@nokia.com> | ||
3 | Date: Thu, 25 Aug 2022 18:47:02 +0300 | ||
4 | Subject: [PATCH] devmem: add 128-bit width | ||
5 | |||
6 | Add 128-bit width if the compiler provides the needed type. | ||
7 | |||
8 | function old new delta | ||
9 | devmem_main 405 464 +59 | ||
10 | .rodata 109025 109043 +18 | ||
11 | ------------------------------------------------------------------------------ | ||
12 | (add/remove: 0/0 grow/shrink: 2/0 up/down: 77/0) Total: 77 bytes | ||
13 | |||
14 | Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=d432049f288c9acdc4a7caa729c68ceba3c5dca1] | ||
15 | |||
16 | Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com> | ||
17 | Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> | ||
18 | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> | ||
19 | Signed-off-by: Mingli Yu <mingli.yu@windriver.com> | ||
20 | --- | ||
21 | miscutils/devmem.c | 68 ++++++++++++++++++++++++++++++---------------- | ||
22 | 1 file changed, 44 insertions(+), 24 deletions(-) | ||
23 | |||
24 | diff --git a/miscutils/devmem.c b/miscutils/devmem.c | ||
25 | index f9f0276bc..f21621bd6 100644 | ||
26 | --- a/miscutils/devmem.c | ||
27 | +++ b/miscutils/devmem.c | ||
28 | @@ -29,7 +29,6 @@ int devmem_main(int argc UNUSED_PARAM, char **argv) | ||
29 | { | ||
30 | void *map_base, *virt_addr; | ||
31 | uint64_t read_result; | ||
32 | - uint64_t writeval = writeval; /* for compiler */ | ||
33 | off_t target; | ||
34 | unsigned page_size, mapped_size, offset_in_page; | ||
35 | int fd; | ||
36 | @@ -64,9 +63,6 @@ int devmem_main(int argc UNUSED_PARAM, char **argv) | ||
37 | width = strchrnul(bhwl, (argv[2][0] | 0x20)) - bhwl; | ||
38 | width = sizes[width]; | ||
39 | } | ||
40 | - /* VALUE */ | ||
41 | - if (argv[3]) | ||
42 | - writeval = bb_strtoull(argv[3], NULL, 0); | ||
43 | } else { /* argv[2] == NULL */ | ||
44 | /* make argv[3] to be a valid thing to fetch */ | ||
45 | argv--; | ||
46 | @@ -96,28 +92,46 @@ int devmem_main(int argc UNUSED_PARAM, char **argv) | ||
47 | virt_addr = (char*)map_base + offset_in_page; | ||
48 | |||
49 | if (!argv[3]) { | ||
50 | - switch (width) { | ||
51 | - case 8: | ||
52 | - read_result = *(volatile uint8_t*)virt_addr; | ||
53 | - break; | ||
54 | - case 16: | ||
55 | - read_result = *(volatile uint16_t*)virt_addr; | ||
56 | - break; | ||
57 | - case 32: | ||
58 | - read_result = *(volatile uint32_t*)virt_addr; | ||
59 | - break; | ||
60 | - case 64: | ||
61 | - read_result = *(volatile uint64_t*)virt_addr; | ||
62 | - break; | ||
63 | - default: | ||
64 | - bb_simple_error_msg_and_die("bad width"); | ||
65 | +#ifdef __SIZEOF_INT128__ | ||
66 | + if (width == 128) { | ||
67 | + unsigned __int128 rd = | ||
68 | + *(volatile unsigned __int128 *)virt_addr; | ||
69 | + printf("0x%016llX%016llX\n", | ||
70 | + (unsigned long long)(uint64_t)(rd >> 64), | ||
71 | + (unsigned long long)(uint64_t)rd | ||
72 | + ); | ||
73 | + } else | ||
74 | +#endif | ||
75 | + { | ||
76 | + switch (width) { | ||
77 | + case 8: | ||
78 | + read_result = *(volatile uint8_t*)virt_addr; | ||
79 | + break; | ||
80 | + case 16: | ||
81 | + read_result = *(volatile uint16_t*)virt_addr; | ||
82 | + break; | ||
83 | + case 32: | ||
84 | + read_result = *(volatile uint32_t*)virt_addr; | ||
85 | + break; | ||
86 | + case 64: | ||
87 | + read_result = *(volatile uint64_t*)virt_addr; | ||
88 | + break; | ||
89 | + default: | ||
90 | + bb_simple_error_msg_and_die("bad width"); | ||
91 | + } | ||
92 | +// printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n", | ||
93 | +// target, virt_addr, | ||
94 | +// (unsigned long long)read_result); | ||
95 | + /* Zero-padded output shows the width of access just done */ | ||
96 | + printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result); | ||
97 | } | ||
98 | -// printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n", | ||
99 | -// target, virt_addr, | ||
100 | -// (unsigned long long)read_result); | ||
101 | - /* Zero-padded output shows the width of access just done */ | ||
102 | - printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result); | ||
103 | } else { | ||
104 | + /* parse VALUE */ | ||
105 | +#ifdef __SIZEOF_INT128__ | ||
106 | + unsigned __int128 writeval = strtoumax(argv[3], NULL, 0); | ||
107 | +#else | ||
108 | + uint64_t writeval = bb_strtoull(argv[3], NULL, 0); | ||
109 | +#endif | ||
110 | switch (width) { | ||
111 | case 8: | ||
112 | *(volatile uint8_t*)virt_addr = writeval; | ||
113 | @@ -135,6 +149,12 @@ int devmem_main(int argc UNUSED_PARAM, char **argv) | ||
114 | *(volatile uint64_t*)virt_addr = writeval; | ||
115 | // read_result = *(volatile uint64_t*)virt_addr; | ||
116 | break; | ||
117 | +#ifdef __SIZEOF_INT128__ | ||
118 | + case 128: | ||
119 | + *(volatile unsigned __int128 *)virt_addr = writeval; | ||
120 | +// read_result = *(volatile uint64_t*)virt_addr; | ||
121 | + break; | ||
122 | +#endif | ||
123 | default: | ||
124 | bb_simple_error_msg_and_die("bad width"); | ||
125 | } | ||
126 | -- | ||
127 | 2.25.1 | ||
128 | |||
diff --git a/meta/recipes-core/busybox/busybox_1.35.0.bb b/meta/recipes-core/busybox/busybox_1.35.0.bb index edf896485e..e9ca6fdb1a 100644 --- a/meta/recipes-core/busybox/busybox_1.35.0.bb +++ b/meta/recipes-core/busybox/busybox_1.35.0.bb | |||
@@ -50,6 +50,7 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ | |||
50 | file://0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch \ | 50 | file://0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch \ |
51 | file://0002-nslookup-sanitize-all-printed-strings-with-printable.patch \ | 51 | file://0002-nslookup-sanitize-all-printed-strings-with-printable.patch \ |
52 | file://CVE-2022-30065.patch \ | 52 | file://CVE-2022-30065.patch \ |
53 | file://0001-devmem-add-128-bit-width.patch \ | ||
53 | " | 54 | " |
54 | SRC_URI:append:libc-musl = " file://musl.cfg " | 55 | SRC_URI:append:libc-musl = " file://musl.cfg " |
55 | 56 | ||