diff mbox series

[kirkstone,v2] busybox: add devmem 128-bit support

Message ID 20220914072059.3509603-1-mingli.yu@windriver.com
State New, archived
Headers show
Series [kirkstone,v2] busybox: add devmem 128-bit support | expand

Commit Message

Yu, Mingli Sept. 14, 2022, 7:20 a.m. UTC
From: Mingli Yu <mingli.yu@windriver.com>

Add devmem 128-bit support [1].

[1] https://git.busybox.net/busybox/commit/?id=d432049f288c9acdc4a7caa729c68ceba3c5dca1

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 .../0001-devmem-add-128-bit-width.patch       | 128 ++++++++++++++++++
 meta/recipes-core/busybox/busybox/defconfig   |   2 +-
 meta/recipes-core/busybox/busybox_1.35.0.bb   |   1 +
 3 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-core/busybox/busybox/0001-devmem-add-128-bit-width.patch

Comments

Randy MacLeod Sept. 14, 2022, 2:08 p.m. UTC | #1
On 2022-09-14 03:20, Yu, Mingli wrote:
> From: Mingli Yu<mingli.yu@windriver.com>
>
> Add devmem 128-bit support [1].

We should merge to master as well but I don't think we need to enable 
devmem, especially in kirkstone.
If a user wants to do that, that's fine.

My notes:

I think that back-porting this commit is low risk since it only adds a 
new, non-default ability in a compatible manner and
more importantly 'devmem' is NOT built by default. Therefore, other 
users are not affected by including this patch.

devmem is a small program that reads and writes from physical memory 
using /dev/mem.

Usage is:

$ busybox devmem --help
...
Usage: devmem ADDRESS [WIDTH [VALUE]]
Read/write from physical address
     ADDRESS    Address to act upon
     WIDTH    Width (8/16/...)
     VALUE    Data to be written

This commit adds 128 bit as a supported WIDTH.

The patch cherry-picks back to 1.35.0 *cleanly* and doesn't require 
pulling in any other commits.
It *does add new functionality* but the patch is written such that if 
_/SIZEOF_INT128/_ isn't define, the code is practically unchanged.

There hasn't been a release of busybox since Dec 2021 so we should 
backport this patch to oe-core/master and oe-core/kirkstone.


>
> [1]https://git.busybox.net/busybox/commit/?id=d432049f288c9acdc4a7caa729c68ceba3c5dca1
>
> Signed-off-by: Mingli Yu<mingli.yu@windriver.com>
> ---
>   .../0001-devmem-add-128-bit-width.patch       | 128 ++++++++++++++++++
>   meta/recipes-core/busybox/busybox/defconfig   |   2 +-
>   meta/recipes-core/busybox/busybox_1.35.0.bb   |   1 +
>   3 files changed, 130 insertions(+), 1 deletion(-)
>   create mode 100644 meta/recipes-core/busybox/busybox/0001-devmem-add-128-bit-width.patch
>
> 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 @@
> +From d432049f288c9acdc4a7caa729c68ceba3c5dca1 Mon Sep 17 00:00:00 2001
> +From: Aaro Koskinen<aaro.koskinen@nokia.com>
> +Date: Thu, 25 Aug 2022 18:47:02 +0300
> +Subject: [PATCH] devmem: add 128-bit width
> +
> +Add 128-bit width if the compiler provides the needed type.
> +
> +function                                             old     new   delta
> +devmem_main                                          405     464     +59
> +.rodata                                           109025  109043     +18
> +------------------------------------------------------------------------------
> +(add/remove: 0/0 grow/shrink: 2/0 up/down: 77/0)               Total: 77 bytes
> +
> +Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=d432049f288c9acdc4a7caa729c68ceba3c5dca1]
> +
> +Signed-off-by: Aaro Koskinen<aaro.koskinen@nokia.com>
> +Signed-off-by: Aaro Koskinen<aaro.koskinen@iki.fi>
> +Signed-off-by: Denys Vlasenko<vda.linux@googlemail.com>
> +Signed-off-by: Mingli Yu<mingli.yu@windriver.com>
> +---
> + miscutils/devmem.c | 68 ++++++++++++++++++++++++++++++----------------
> + 1 file changed, 44 insertions(+), 24 deletions(-)
> +
> +diff --git a/miscutils/devmem.c b/miscutils/devmem.c
> +index f9f0276bc..f21621bd6 100644
> +--- a/miscutils/devmem.c
> ++++ b/miscutils/devmem.c
> +@@ -29,7 +29,6 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
> + {
> + 	void *map_base, *virt_addr;
> + 	uint64_t read_result;
> +-	uint64_t writeval = writeval; /* for compiler */
> + 	off_t target;
> + 	unsigned page_size, mapped_size, offset_in_page;
> + 	int fd;
> +@@ -64,9 +63,6 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
> + 			width = strchrnul(bhwl, (argv[2][0] | 0x20)) - bhwl;
> + 			width = sizes[width];
> + 		}
> +-		/* VALUE */
> +-		if (argv[3])
> +-			writeval = bb_strtoull(argv[3], NULL, 0);
> + 	} else { /* argv[2] == NULL */
> + 		/* make argv[3] to be a valid thing to fetch */
> + 		argv--;
> +@@ -96,28 +92,46 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
> + 	virt_addr = (char*)map_base + offset_in_page;
> +
> + 	if (!argv[3]) {
> +-		switch (width) {
> +-		case 8:
> +-			read_result = *(volatile uint8_t*)virt_addr;
> +-			break;
> +-		case 16:
> +-			read_result = *(volatile uint16_t*)virt_addr;
> +-			break;
> +-		case 32:
> +-			read_result = *(volatile uint32_t*)virt_addr;
> +-			break;
> +-		case 64:
> +-			read_result = *(volatile uint64_t*)virt_addr;
> +-			break;
> +-		default:
> +-			bb_simple_error_msg_and_die("bad width");
> ++#ifdef __SIZEOF_INT128__
> ++		if (width == 128) {
> ++			unsigned __int128 rd =
> ++				*(volatile unsigned __int128 *)virt_addr;
> ++			printf("0x%016llX%016llX\n",
> ++				(unsigned long long)(uint64_t)(rd >> 64),
> ++				(unsigned long long)(uint64_t)rd
> ++			);
> ++		} else
> ++#endif
> ++		{
> ++			switch (width) {
> ++			case 8:
> ++				read_result = *(volatile uint8_t*)virt_addr;
> ++				break;
> ++			case 16:
> ++				read_result = *(volatile uint16_t*)virt_addr;
> ++				break;
> ++			case 32:
> ++				read_result = *(volatile uint32_t*)virt_addr;
> ++				break;
> ++			case 64:
> ++				read_result = *(volatile uint64_t*)virt_addr;
> ++				break;
> ++			default:
> ++				bb_simple_error_msg_and_die("bad width");
> ++			}
> ++//			printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n",
> ++//				target, virt_addr,
> ++//				(unsigned long long)read_result);
> ++			/* Zero-padded output shows the width of access just done */
> ++			printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result);
> + 		}
> +-//		printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n",
> +-//			target, virt_addr,
> +-//			(unsigned long long)read_result);
> +-		/* Zero-padded output shows the width of access just done */
> +-		printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result);
> + 	} else {
> ++		/* parse VALUE */
> ++#ifdef __SIZEOF_INT128__
> ++		unsigned __int128 writeval = strtoumax(argv[3], NULL, 0);
> ++#else
> ++		uint64_t writeval = bb_strtoull(argv[3], NULL, 0);
> ++#endif
> + 		switch (width) {
> + 		case 8:
> + 			*(volatile uint8_t*)virt_addr = writeval;
> +@@ -135,6 +149,12 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
> + 			*(volatile uint64_t*)virt_addr = writeval;
> + //			read_result = *(volatile uint64_t*)virt_addr;
> + 			break;
> ++#ifdef __SIZEOF_INT128__
> ++		case 128:
> ++			*(volatile unsigned __int128 *)virt_addr = writeval;
> ++//			read_result = *(volatile uint64_t*)virt_addr;
> ++			break;
> ++#endif
> + 		default:
> + 			bb_simple_error_msg_and_die("bad width");
> + 		}
> +--
> +2.25.1
> +
> diff --git a/meta/recipes-core/busybox/busybox/defconfig b/meta/recipes-core/busybox/busybox/defconfig
> index 5e1e1f5638..58d393ad87 100644
> --- a/meta/recipes-core/busybox/busybox/defconfig
> +++ b/meta/recipes-core/busybox/busybox/defconfig
> @@ -782,7 +782,7 @@ CONFIG_FEATURE_CROND_DIR=""
>   # CONFIG_DEVFSD_FG_NP is not set
>   # CONFIG_DEVFSD_VERBOSE is not set
>   # CONFIG_FEATURE_DEVFS is not set
> -# CONFIG_DEVMEM is not set
> +CONFIG_DEVMEM=y
As mentioned above, I don't think we need to enable DEVMEM but only

carry this small patch.

Thanks,

../Randy


>   # CONFIG_FBSPLASH is not set
>   # CONFIG_FLASH_ERASEALL is not set
>   # CONFIG_FLASH_LOCK is not set
> 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 \ 
> file://0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch 
> \ 
> file://0002-nslookup-sanitize-all-printed-strings-with-printable.patch 
> \ file://CVE-2022-30065.patch \ + 
> file://0001-devmem-add-128-bit-width.patch \ "
>   SRC_URI:append:libc-musl =" file://musl.cfg "
>   
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#170637):https://lists.openembedded.org/g/openembedded-core/message/170637
> Mute This Topic:https://lists.openembedded.org/mt/93673250/3616765
> Group Owner:openembedded-core+owner@lists.openembedded.org
> Unsubscribe:https://lists.openembedded.org/g/openembedded-core/unsub  [randy.macleod@windriver.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Steve Sakoman Sept. 14, 2022, 3:15 p.m. UTC | #2
On Wed, Sep 14, 2022 at 4:08 AM Randy MacLeod
<randy.macleod@windriver.com> wrote:
>
> On 2022-09-14 03:20, Yu, Mingli wrote:
>
> From: Mingli Yu <mingli.yu@windriver.com>
>
> Add devmem 128-bit support [1].
>
> We should merge to master as well but I don't think we need to enable devmem, especially in kirkstone.
> If a user wants to do that, that's fine.

IIf this is also suitable for master, then the patch should be
resubmitted for master and I can then cherry-pick to kirkstone.

Steve

>
> My notes:
>
> I think that back-porting this commit is low risk since it only adds a new, non-default ability in a compatible manner and
> more importantly 'devmem' is NOT built by default. Therefore, other users are not affected by including this patch.
>
> devmem is a small program that reads and writes from physical memory using /dev/mem.
>
> Usage is:
>
> $ busybox devmem --help
> ...
> Usage: devmem ADDRESS [WIDTH [VALUE]]
> Read/write from physical address
>     ADDRESS    Address to act upon
>     WIDTH    Width (8/16/...)
>     VALUE    Data to be written
>
>
>
> This commit adds 128 bit as a supported WIDTH.
>
> The patch cherry-picks back to 1.35.0 cleanly and doesn't require pulling in any other commits.
> It does add new functionality but the patch is written such that if _SIZEOF_INT128_ isn't define, the code is practically unchanged.
>
>
> There hasn't been a release of busybox since Dec 2021 so we should backport this patch to oe-core/master and oe-core/kirkstone.
>
>
>
> [1] https://git.busybox.net/busybox/commit/?id=d432049f288c9acdc4a7caa729c68ceba3c5dca1
>
> Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> ---
>  .../0001-devmem-add-128-bit-width.patch       | 128 ++++++++++++++++++
>  meta/recipes-core/busybox/busybox/defconfig   |   2 +-
>  meta/recipes-core/busybox/busybox_1.35.0.bb   |   1 +
>  3 files changed, 130 insertions(+), 1 deletion(-)
>  create mode 100644 meta/recipes-core/busybox/busybox/0001-devmem-add-128-bit-width.patch
>
> 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 @@
> +From d432049f288c9acdc4a7caa729c68ceba3c5dca1 Mon Sep 17 00:00:00 2001
> +From: Aaro Koskinen <aaro.koskinen@nokia.com>
> +Date: Thu, 25 Aug 2022 18:47:02 +0300
> +Subject: [PATCH] devmem: add 128-bit width
> +
> +Add 128-bit width if the compiler provides the needed type.
> +
> +function                                             old     new   delta
> +devmem_main                                          405     464     +59
> +.rodata                                           109025  109043     +18
> +------------------------------------------------------------------------------
> +(add/remove: 0/0 grow/shrink: 2/0 up/down: 77/0)               Total: 77 bytes
> +
> +Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=d432049f288c9acdc4a7caa729c68ceba3c5dca1]
> +
> +Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
> +Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
> +Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
> +Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> +---
> + miscutils/devmem.c | 68 ++++++++++++++++++++++++++++++----------------
> + 1 file changed, 44 insertions(+), 24 deletions(-)
> +
> +diff --git a/miscutils/devmem.c b/miscutils/devmem.c
> +index f9f0276bc..f21621bd6 100644
> +--- a/miscutils/devmem.c
> ++++ b/miscutils/devmem.c
> +@@ -29,7 +29,6 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
> + {
> + void *map_base, *virt_addr;
> + uint64_t read_result;
> +- uint64_t writeval = writeval; /* for compiler */
> + off_t target;
> + unsigned page_size, mapped_size, offset_in_page;
> + int fd;
> +@@ -64,9 +63,6 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
> + width = strchrnul(bhwl, (argv[2][0] | 0x20)) - bhwl;
> + width = sizes[width];
> + }
> +- /* VALUE */
> +- if (argv[3])
> +- writeval = bb_strtoull(argv[3], NULL, 0);
> + } else { /* argv[2] == NULL */
> + /* make argv[3] to be a valid thing to fetch */
> + argv--;
> +@@ -96,28 +92,46 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
> + virt_addr = (char*)map_base + offset_in_page;
> +
> + if (!argv[3]) {
> +- switch (width) {
> +- case 8:
> +- read_result = *(volatile uint8_t*)virt_addr;
> +- break;
> +- case 16:
> +- read_result = *(volatile uint16_t*)virt_addr;
> +- break;
> +- case 32:
> +- read_result = *(volatile uint32_t*)virt_addr;
> +- break;
> +- case 64:
> +- read_result = *(volatile uint64_t*)virt_addr;
> +- break;
> +- default:
> +- bb_simple_error_msg_and_die("bad width");
> ++#ifdef __SIZEOF_INT128__
> ++ if (width == 128) {
> ++ unsigned __int128 rd =
> ++ *(volatile unsigned __int128 *)virt_addr;
> ++ printf("0x%016llX%016llX\n",
> ++ (unsigned long long)(uint64_t)(rd >> 64),
> ++ (unsigned long long)(uint64_t)rd
> ++ );
> ++ } else
> ++#endif
> ++ {
> ++ switch (width) {
> ++ case 8:
> ++ read_result = *(volatile uint8_t*)virt_addr;
> ++ break;
> ++ case 16:
> ++ read_result = *(volatile uint16_t*)virt_addr;
> ++ break;
> ++ case 32:
> ++ read_result = *(volatile uint32_t*)virt_addr;
> ++ break;
> ++ case 64:
> ++ read_result = *(volatile uint64_t*)virt_addr;
> ++ break;
> ++ default:
> ++ bb_simple_error_msg_and_die("bad width");
> ++ }
> ++// printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n",
> ++// target, virt_addr,
> ++// (unsigned long long)read_result);
> ++ /* Zero-padded output shows the width of access just done */
> ++ printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result);
> + }
> +-// printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n",
> +-// target, virt_addr,
> +-// (unsigned long long)read_result);
> +- /* Zero-padded output shows the width of access just done */
> +- printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result);
> + } else {
> ++ /* parse VALUE */
> ++#ifdef __SIZEOF_INT128__
> ++ unsigned __int128 writeval = strtoumax(argv[3], NULL, 0);
> ++#else
> ++ uint64_t writeval = bb_strtoull(argv[3], NULL, 0);
> ++#endif
> + switch (width) {
> + case 8:
> + *(volatile uint8_t*)virt_addr = writeval;
> +@@ -135,6 +149,12 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
> + *(volatile uint64_t*)virt_addr = writeval;
> + // read_result = *(volatile uint64_t*)virt_addr;
> + break;
> ++#ifdef __SIZEOF_INT128__
> ++ case 128:
> ++ *(volatile unsigned __int128 *)virt_addr = writeval;
> ++// read_result = *(volatile uint64_t*)virt_addr;
> ++ break;
> ++#endif
> + default:
> + bb_simple_error_msg_and_die("bad width");
> + }
> +--
> +2.25.1
> +
> diff --git a/meta/recipes-core/busybox/busybox/defconfig b/meta/recipes-core/busybox/busybox/defconfig
> index 5e1e1f5638..58d393ad87 100644
> --- a/meta/recipes-core/busybox/busybox/defconfig
> +++ b/meta/recipes-core/busybox/busybox/defconfig
> @@ -782,7 +782,7 @@ CONFIG_FEATURE_CROND_DIR=""
>  # CONFIG_DEVFSD_FG_NP is not set
>  # CONFIG_DEVFSD_VERBOSE is not set
>  # CONFIG_FEATURE_DEVFS is not set
> -# CONFIG_DEVMEM is not set
> +CONFIG_DEVMEM=y
>
> As mentioned above, I don't think we need to enable DEVMEM but only
>
> carry this small patch.
>
> Thanks,
>
> ../Randy
>
>
>  # CONFIG_FBSPLASH is not set
>  # CONFIG_FLASH_ERASEALL is not set
>  # CONFIG_FLASH_LOCK is not set
> 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 \
>             file://0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch \
>             file://0002-nslookup-sanitize-all-printed-strings-with-printable.patch \
>             file://CVE-2022-30065.patch \
> +           file://0001-devmem-add-128-bit-width.patch \
>             "
>  SRC_URI:append:libc-musl = " file://musl.cfg "
>
>
>
>
>
> --
> # Randy MacLeod
> # Wind River Linux
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#170658): https://lists.openembedded.org/g/openembedded-core/message/170658
> Mute This Topic: https://lists.openembedded.org/mt/93673250/3617601
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [sakoman@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

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 @@ 
+From d432049f288c9acdc4a7caa729c68ceba3c5dca1 Mon Sep 17 00:00:00 2001
+From: Aaro Koskinen <aaro.koskinen@nokia.com>
+Date: Thu, 25 Aug 2022 18:47:02 +0300
+Subject: [PATCH] devmem: add 128-bit width
+
+Add 128-bit width if the compiler provides the needed type.
+
+function                                             old     new   delta
+devmem_main                                          405     464     +59
+.rodata                                           109025  109043     +18
+------------------------------------------------------------------------------
+(add/remove: 0/0 grow/shrink: 2/0 up/down: 77/0)               Total: 77 bytes
+
+Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=d432049f288c9acdc4a7caa729c68ceba3c5dca1]
+
+Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
+Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
+---
+ miscutils/devmem.c | 68 ++++++++++++++++++++++++++++++----------------
+ 1 file changed, 44 insertions(+), 24 deletions(-)
+
+diff --git a/miscutils/devmem.c b/miscutils/devmem.c
+index f9f0276bc..f21621bd6 100644
+--- a/miscutils/devmem.c
++++ b/miscutils/devmem.c
+@@ -29,7 +29,6 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
+ {
+ 	void *map_base, *virt_addr;
+ 	uint64_t read_result;
+-	uint64_t writeval = writeval; /* for compiler */
+ 	off_t target;
+ 	unsigned page_size, mapped_size, offset_in_page;
+ 	int fd;
+@@ -64,9 +63,6 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
+ 			width = strchrnul(bhwl, (argv[2][0] | 0x20)) - bhwl;
+ 			width = sizes[width];
+ 		}
+-		/* VALUE */
+-		if (argv[3])
+-			writeval = bb_strtoull(argv[3], NULL, 0);
+ 	} else { /* argv[2] == NULL */
+ 		/* make argv[3] to be a valid thing to fetch */
+ 		argv--;
+@@ -96,28 +92,46 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
+ 	virt_addr = (char*)map_base + offset_in_page;
+ 
+ 	if (!argv[3]) {
+-		switch (width) {
+-		case 8:
+-			read_result = *(volatile uint8_t*)virt_addr;
+-			break;
+-		case 16:
+-			read_result = *(volatile uint16_t*)virt_addr;
+-			break;
+-		case 32:
+-			read_result = *(volatile uint32_t*)virt_addr;
+-			break;
+-		case 64:
+-			read_result = *(volatile uint64_t*)virt_addr;
+-			break;
+-		default:
+-			bb_simple_error_msg_and_die("bad width");
++#ifdef __SIZEOF_INT128__
++		if (width == 128) {
++			unsigned __int128 rd =
++				*(volatile unsigned __int128 *)virt_addr;
++			printf("0x%016llX%016llX\n",
++				(unsigned long long)(uint64_t)(rd >> 64),
++				(unsigned long long)(uint64_t)rd
++			);
++		} else
++#endif
++		{
++			switch (width) {
++			case 8:
++				read_result = *(volatile uint8_t*)virt_addr;
++				break;
++			case 16:
++				read_result = *(volatile uint16_t*)virt_addr;
++				break;
++			case 32:
++				read_result = *(volatile uint32_t*)virt_addr;
++				break;
++			case 64:
++				read_result = *(volatile uint64_t*)virt_addr;
++				break;
++			default:
++				bb_simple_error_msg_and_die("bad width");
++			}
++//			printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n",
++//				target, virt_addr,
++//				(unsigned long long)read_result);
++			/* Zero-padded output shows the width of access just done */
++			printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result);
+ 		}
+-//		printf("Value at address 0x%"OFF_FMT"X (%p): 0x%llX\n",
+-//			target, virt_addr,
+-//			(unsigned long long)read_result);
+-		/* Zero-padded output shows the width of access just done */
+-		printf("0x%0*llX\n", (width >> 2), (unsigned long long)read_result);
+ 	} else {
++		/* parse VALUE */
++#ifdef __SIZEOF_INT128__
++		unsigned __int128 writeval = strtoumax(argv[3], NULL, 0);
++#else
++		uint64_t writeval = bb_strtoull(argv[3], NULL, 0);
++#endif
+ 		switch (width) {
+ 		case 8:
+ 			*(volatile uint8_t*)virt_addr = writeval;
+@@ -135,6 +149,12 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
+ 			*(volatile uint64_t*)virt_addr = writeval;
+ //			read_result = *(volatile uint64_t*)virt_addr;
+ 			break;
++#ifdef __SIZEOF_INT128__
++		case 128:
++			*(volatile unsigned __int128 *)virt_addr = writeval;
++//			read_result = *(volatile uint64_t*)virt_addr;
++			break;
++#endif
+ 		default:
+ 			bb_simple_error_msg_and_die("bad width");
+ 		}
+-- 
+2.25.1
+
diff --git a/meta/recipes-core/busybox/busybox/defconfig b/meta/recipes-core/busybox/busybox/defconfig
index 5e1e1f5638..58d393ad87 100644
--- a/meta/recipes-core/busybox/busybox/defconfig
+++ b/meta/recipes-core/busybox/busybox/defconfig
@@ -782,7 +782,7 @@  CONFIG_FEATURE_CROND_DIR=""
 # CONFIG_DEVFSD_FG_NP is not set
 # CONFIG_DEVFSD_VERBOSE is not set
 # CONFIG_FEATURE_DEVFS is not set
-# CONFIG_DEVMEM is not set
+CONFIG_DEVMEM=y
 # CONFIG_FBSPLASH is not set
 # CONFIG_FLASH_ERASEALL is not set
 # CONFIG_FLASH_LOCK is not set
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 \
            file://0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch \
            file://0002-nslookup-sanitize-all-printed-strings-with-printable.patch \
            file://CVE-2022-30065.patch \
+           file://0001-devmem-add-128-bit-width.patch \
            "
 SRC_URI:append:libc-musl = " file://musl.cfg "