diff mbox series

[v2,4/4] configs/qemu_riscv32_nommu_virt_defconfig: New defconfig

Message ID 20221217051337.3778405-5-Mr.Bossman075@gmail.com
State Changes Requested
Delegated to: Peter Korsgaard
Headers show
Series Add RISC-V 32 NOMMU support | expand

Commit Message

Jesse T Dec. 17, 2022, 5:13 a.m. UTC
Add RISC-V 32-bit nommu defconfig for QEMU virt machine with MMU
disabled.

Unlike qemu_riscv32_virt, qemu_riscv32_nommu_virt does not use OpenSBI,
since the kernel is running in machine mode (M-mode).

Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
Cc: Yimin Gu <ustcymgu@gmail.com>
---
 board/qemu/riscv32-virt/nommu/defconfig       | 16 +++++++
 .../riscv32-virt/nommu/patches/linux-headers  |  1 +
 ...nfig-Allow-RV32-to-build-with-no-MMU.patch | 43 +++++++++++++++++++
 ...le-stat64-and-time32-for-RV32-uclibc.patch | 40 +++++++++++++++++
 board/qemu/riscv32-virt/readme.txt            |  6 ++-
 configs/qemu_riscv32_nommu_virt_defconfig     | 31 +++++++++++++
 6 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 board/qemu/riscv32-virt/nommu/defconfig
 create mode 120000 board/qemu/riscv32-virt/nommu/patches/linux-headers
 create mode 100644 board/qemu/riscv32-virt/nommu/patches/linux/6.0/0001-riscv-Kconfig-Allow-RV32-to-build-with-no-MMU.patch
 create mode 100644 board/qemu/riscv32-virt/nommu/patches/linux/6.0/0002-riscv-Enable-stat64-and-time32-for-RV32-uclibc.patch
 create mode 100644 configs/qemu_riscv32_nommu_virt_defconfig

Comments

Romain Naour Oct. 1, 2023, 7:15 a.m. UTC | #1
Hello,

Le 17/12/2022 à 06:13, Jesse Taube a écrit :
> Add RISC-V 32-bit nommu defconfig for QEMU virt machine with MMU
> disabled.
> 
> Unlike qemu_riscv32_virt, qemu_riscv32_nommu_virt does not use OpenSBI,
> since the kernel is running in machine mode (M-mode).
> 
> Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
> Cc: Yimin Gu <ustcymgu@gmail.com>

I rebased the elf2flt patch for risc32 [1] on top of elf2flt 2023.09 release,
then I enabled the risc32 uclibc-ng support [2] without patching it since we use
the latest release (v1.0.44) containing this commit [3].

But the system doesn't boot due to a reloc issue:

binfmt_flat: reloc outside program 0xfff7b6dc (0 - 0x9cec0/0x8a180), killing sh!
Starting init: /bin/sh exists but couldn't execute it (error -8)

This issue may be related to the toolchain used to build this defconfig (gcc
12.3.0 and binutils 2.40) that is newer than the toolchain used at the time this
series was tested.

[1]
http://patchwork.ozlabs.org/project/buildroot/patch/20221217051337.3778405-2-Mr.Bossman075@gmail.com/

[2]
http://patchwork.ozlabs.org/project/buildroot/patch/20221217051337.3778405-3-Mr.Bossman075@gmail.com/

[3]
https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/?id=0a5466d8d53bc8045ff56ff76cc1880aa85761c2

> ---
>  board/qemu/riscv32-virt/nommu/defconfig       | 16 +++++++
>  .../riscv32-virt/nommu/patches/linux-headers  |  1 +
>  ...nfig-Allow-RV32-to-build-with-no-MMU.patch | 43 +++++++++++++++++++
>  ...le-stat64-and-time32-for-RV32-uclibc.patch | 40 +++++++++++++++++
>  board/qemu/riscv32-virt/readme.txt            |  6 ++-
>  configs/qemu_riscv32_nommu_virt_defconfig     | 31 +++++++++++++
>  6 files changed, 136 insertions(+), 1 deletion(-)
>  create mode 100644 board/qemu/riscv32-virt/nommu/defconfig
>  create mode 120000 board/qemu/riscv32-virt/nommu/patches/linux-headers
>  create mode 100644 board/qemu/riscv32-virt/nommu/patches/linux/6.0/0001-riscv-Kconfig-Allow-RV32-to-build-with-no-MMU.patch
>  create mode 100644 board/qemu/riscv32-virt/nommu/patches/linux/6.0/0002-riscv-Enable-stat64-and-time32-for-RV32-uclibc.patch
>  create mode 100644 configs/qemu_riscv32_nommu_virt_defconfig
> 
> diff --git a/board/qemu/riscv32-virt/nommu/defconfig b/board/qemu/riscv32-virt/nommu/defconfig
> new file mode 100644
> index 0000000000..460907253a
> --- /dev/null
> +++ b/board/qemu/riscv32-virt/nommu/defconfig
> @@ -0,0 +1,16 @@
> +CONFIG_BLK_DEV_INITRD=y
> +# CONFIG_MMU is not set
> +CONFIG_COMPAT_32BIT_TIME=y
> +CONFIG_SOC_VIRT=y
> +CONFIG_NONPORTABLE=y
> +CONFIG_ARCH_RV32I=y
> +CONFIG_BINFMT_FLAT=y
> +CONFIG_SLOB=y
> +CONFIG_VIRTIO_BLK=y
> +CONFIG_SERIAL_8250=y
> +CONFIG_SERIAL_8250_CONSOLE=y
> +CONFIG_SERIAL_OF_PLATFORM=y
> +CONFIG_VIRTIO_MMIO=y
> +CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
> +CONFIG_EXT2_FS=y
> +CONFIG_PRINTK_TIME=y
> diff --git a/board/qemu/riscv32-virt/nommu/patches/linux-headers b/board/qemu/riscv32-virt/nommu/patches/linux-headers
> new file mode 120000
> index 0000000000..ce5e2c77b2
> --- /dev/null
> +++ b/board/qemu/riscv32-virt/nommu/patches/linux-headers
> @@ -0,0 +1 @@
> +linux/
> \ No newline at end of file
> diff --git a/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0001-riscv-Kconfig-Allow-RV32-to-build-with-no-MMU.patch b/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0001-riscv-Kconfig-Allow-RV32-to-build-with-no-MMU.patch
> new file mode 100644
> index 0000000000..af11ddf953
> --- /dev/null
> +++ b/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0001-riscv-Kconfig-Allow-RV32-to-build-with-no-MMU.patch
> @@ -0,0 +1,43 @@
> +From 57800c87e422375ec0df4d5ad7f33659f7b60093 Mon Sep 17 00:00:00 2001
> +From: Yimin Gu <ustcymgu@gmail.com>
> +Date: Sat, 10 Dec 2022 22:27:47 -0500
> +Subject: [PATCH] riscv: Kconfig: Allow RV32 to build with no MMU
> +
> +Some RISC-V 32bit ores do not have an MMU, and the kernel should be
> +able to build for them. This patch enables the RV32 to be built with
> +no MMU support.
> +
> +Signed-off-by: Yimin Gu <ustcymgu@gmail.com>
> +CC=c: Jesse Taube <Mr.Bossman075@gmail.com>
> +Tested-By: Waldemar Brodkorb <wbx@openadk.org>
> +Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
> +---
> + arch/riscv/Kconfig | 5 ++---
> + 1 file changed, 2 insertions(+), 3 deletions(-)
> +
> +diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> +index 59d18881f35b..49759dbe6a8f 100644
> +--- a/arch/riscv/Kconfig
> ++++ b/arch/riscv/Kconfig
> +@@ -163,8 +163,8 @@ config MMU
> + 
> + config PAGE_OFFSET
> + 	hex
> +-	default 0xC0000000 if 32BIT
> +-	default 0x80000000 if 64BIT && !MMU
> ++	default 0xC0000000 if 32BIT && MMU
> ++	default 0x80000000 if !MMU
> + 	default 0xff60000000000000 if 64BIT
> + 
> + config KASAN_SHADOW_OFFSET
> +@@ -262,7 +262,6 @@ config ARCH_RV32I
> + 	select GENERIC_LIB_ASHRDI3
> + 	select GENERIC_LIB_LSHRDI3
> + 	select GENERIC_LIB_UCMPDI2
> +-	select MMU
> + 
> + config ARCH_RV64I
> + 	bool "RV64I"
> +-- 
> +2.38.1
> +
> diff --git a/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0002-riscv-Enable-stat64-and-time32-for-RV32-uclibc.patch b/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0002-riscv-Enable-stat64-and-time32-for-RV32-uclibc.patch
> new file mode 100644
> index 0000000000..f654cca7a6
> --- /dev/null
> +++ b/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0002-riscv-Enable-stat64-and-time32-for-RV32-uclibc.patch
> @@ -0,0 +1,40 @@
> +From 1d985b3cd0fdb37567b4b8263cae740b49a1f46a Mon Sep 17 00:00:00 2001
> +From: Yimin Gu <ustcymgu@gmail.com>
> +Date: Sat, 10 Dec 2022 22:31:06 -0500
> +Subject: [PATCH] riscv: Enable stat64 and time32 for RV32 uclibc
> +
> +To comply with current uclibc, macros __ARCH_WANT_STAT64 and
> +__ARCH_WANT_TIME32_SYSCALLS are defined. CONFIG_COMPAT_32BIT_TIME also
> +has to be turned on.

It would be great if this patch could be upstreamed since we have to patch not
only the kernel running at runtime but also the kernel headers used by the
toolchain.

> +
> +Tested-By: Waldemar Brodkorb <wbx@openadk.org>
> +Signed-off-by: Yimin Gu <ustcymgu@gmail.com>
> +Cc: Jesse Taube <Mr.Bossman075@gmail.com>
> +Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
> +---
> + arch/riscv/include/uapi/asm/unistd.h | 7 ++++++-
> + 1 file changed, 6 insertions(+), 1 deletion(-)
> +
> +diff --git a/arch/riscv/include/uapi/asm/unistd.h b/arch/riscv/include/uapi/asm/unistd.h
> +index 73d7cdd2ec49..3dc774bc201f 100644
> +--- a/arch/riscv/include/uapi/asm/unistd.h
> ++++ b/arch/riscv/include/uapi/asm/unistd.h
> +@@ -15,9 +15,14 @@
> +  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
> +  */
> + 
> +-#if defined(__LP64__) && !defined(__SYSCALL_COMPAT)
> ++#ifndef __SYSCALL_COMPAT
> + #define __ARCH_WANT_NEW_STAT
> + #define __ARCH_WANT_SET_GET_RLIMIT
> ++#endif /* __SYSCALL_COMPAT */
> ++
> ++#ifndef __LP64__
> ++#define __ARCH_WANT_STAT64
> ++#define __ARCH_WANT_TIME32_SYSCALLS
> + #endif /* __LP64__ */
> + 
> + #define __ARCH_WANT_SYS_CLONE3
> +-- 
> +2.38.1
> +
> diff --git a/board/qemu/riscv32-virt/readme.txt b/board/qemu/riscv32-virt/readme.txt
> index 32b4333512..067bb9f436 100644
> --- a/board/qemu/riscv32-virt/readme.txt
> +++ b/board/qemu/riscv32-virt/readme.txt
> @@ -1,5 +1,9 @@
>  Run Linux in emulation with:
>  
> -  qemu-system-riscv32 -M virt -bios output/images/fw_jump.elf -kernel output/images/Image -append "rootwait root=/dev/vda ro" -drive file=output/images/rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic # qemu_riscv32_virt_defconfig
> +qemu_riscv32_virt_defconfig:
> +  qemu-system-riscv32 -M virt -bios output/images/fw_jump.elf -kernel output/images/Image -append "rootwait root=/dev/vda ro" -drive file=output/images/rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic

Please, don't modify "# qemu_riscv32_virt_defconfig" here, it used by the script
that generate the start-qemu.sh script.

> +  
> +qemu_riscv32_nommu_virt_defconfig:
remove "qemu_riscv32_nommu_virt_defconfig:"

> +  qemu-system-riscv32 -M virt -bios none -kernel output/images/Image -append "rootwait root=/dev/vda ro" -drive file=output/images/rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -nographic -cpu rv32,mmu=off

add "# qemu_riscv32_nommu_virt_defconfig" at the end of this line.

Can you have a look and resend an updated version of this series?

Best regards,
Romain


>  
>  The login prompt will appear in the terminal that started Qemu.
> diff --git a/configs/qemu_riscv32_nommu_virt_defconfig b/configs/qemu_riscv32_nommu_virt_defconfig
> new file mode 100644
> index 0000000000..8bfa1f7435
> --- /dev/null
> +++ b/configs/qemu_riscv32_nommu_virt_defconfig
> @@ -0,0 +1,31 @@
> +# Architecture
> +BR2_riscv=y
> +BR2_RISCV_32=y
> +# BR2_RISCV_USE_MMU is not set 
> +
> +# System
> +BR2_TARGET_GENERIC_GETTY=y
> +BR2_PTHREADS_NONE=y
> +
> +# Filesystem
> +BR2_TARGET_ROOTFS_EXT2=y
> +
> +# Image
> +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh"
> +BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)"
> +
> +# Linux headers same as kernel
> +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_0=y
> +
> +# Kernel
> +BR2_LINUX_KERNEL=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.0"
> +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
> +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/riscv32-virt/nommu/defconfig"
> +BR2_LINUX_KERNEL_IMAGE=y
> +BR2_GLOBAL_PATCH_DIR="board/qemu/riscv32-virt/nommu/patches"
> +
> +# host-qemu for gitlab testing
> +BR2_PACKAGE_HOST_QEMU=y
> +BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
Waldemar Brodkorb Oct. 1, 2023, 11:39 a.m. UTC | #2
Hi Romain,

Romain Naour wrote,

> Hello,
> 
> Le 17/12/2022 à 06:13, Jesse Taube a écrit :
> > Add RISC-V 32-bit nommu defconfig for QEMU virt machine with MMU
> > disabled.
> > 
> > Unlike qemu_riscv32_virt, qemu_riscv32_nommu_virt does not use OpenSBI,
> > since the kernel is running in machine mode (M-mode).
> > 
> > Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
> > Cc: Yimin Gu <ustcymgu@gmail.com>
> 
> I rebased the elf2flt patch for risc32 [1] on top of elf2flt 2023.09 release,
> then I enabled the risc32 uclibc-ng support [2] without patching it since we use
> the latest release (v1.0.44) containing this commit [3].
> 
> But the system doesn't boot due to a reloc issue:
> 
> binfmt_flat: reloc outside program 0xfff7b6dc (0 - 0x9cec0/0x8a180), killing sh!
> Starting init: /bin/sh exists but couldn't execute it (error -8)
> 
> This issue may be related to the toolchain used to build this defconfig (gcc
> 12.3.0 and binutils 2.40) that is newer than the toolchain used at the time this
> series was tested.

Can you share your elf2flt patch, please. 

best regards
 Waldemar
Romain Naour Oct. 1, 2023, 12:02 p.m. UTC | #3
Hi Waldemar,

Le 01/10/2023 à 13:39, Waldemar Brodkorb a écrit :
> Hi Romain,
> 
> Romain Naour wrote,
> 
>> Hello,
>>
>> Le 17/12/2022 à 06:13, Jesse Taube a écrit :
>>> Add RISC-V 32-bit nommu defconfig for QEMU virt machine with MMU
>>> disabled.
>>>
>>> Unlike qemu_riscv32_virt, qemu_riscv32_nommu_virt does not use OpenSBI,
>>> since the kernel is running in machine mode (M-mode).
>>>
>>> Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
>>> Cc: Yimin Gu <ustcymgu@gmail.com>
>>
>> I rebased the elf2flt patch for risc32 [1] on top of elf2flt 2023.09 release,
>> then I enabled the risc32 uclibc-ng support [2] without patching it since we use
>> the latest release (v1.0.44) containing this commit [3].
>>
>> But the system doesn't boot due to a reloc issue:
>>
>> binfmt_flat: reloc outside program 0xfff7b6dc (0 - 0x9cec0/0x8a180), killing sh!
>> Starting init: /bin/sh exists but couldn't execute it (error -8)
>>
>> This issue may be related to the toolchain used to build this defconfig (gcc
>> 12.3.0 and binutils 2.40) that is newer than the toolchain used at the time this
>> series was tested.
> 
> Can you share your elf2flt patch, please. 

Sure, It the initial patch from Jesse Taube but without the relocation part that
was part of riscv64 commit:

https://github.com/uclinux-dev/elf2flt/commit/c5c8043c4d79a1cdd9bd359a542e6fdf3b04d5a1

I hope this can help.

Best regards,
Romain


> 
> best regards
>  Waldemar
Waldemar Brodkorb Oct. 1, 2023, 2:09 p.m. UTC | #4
Hi Romain,
Romain Naour wrote,

> Hi Waldemar,
> 
> Le 01/10/2023 à 13:39, Waldemar Brodkorb a écrit :
> > Hi Romain,
> > 
> > Romain Naour wrote,
> > 
> >> Hello,
> >>
> >> Le 17/12/2022 à 06:13, Jesse Taube a écrit :
> >>> Add RISC-V 32-bit nommu defconfig for QEMU virt machine with MMU
> >>> disabled.
> >>>
> >>> Unlike qemu_riscv32_virt, qemu_riscv32_nommu_virt does not use OpenSBI,
> >>> since the kernel is running in machine mode (M-mode).
> >>>
> >>> Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
> >>> Cc: Yimin Gu <ustcymgu@gmail.com>
> >>
> >> I rebased the elf2flt patch for risc32 [1] on top of elf2flt 2023.09 release,
> >> then I enabled the risc32 uclibc-ng support [2] without patching it since we use
> >> the latest release (v1.0.44) containing this commit [3].
> >>
> >> But the system doesn't boot due to a reloc issue:
> >>
> >> binfmt_flat: reloc outside program 0xfff7b6dc (0 - 0x9cec0/0x8a180), killing sh!
> >> Starting init: /bin/sh exists but couldn't execute it (error -8)
> >>
> >> This issue may be related to the toolchain used to build this defconfig (gcc
> >> 12.3.0 and binutils 2.40) that is newer than the toolchain used at the time this
> >> series was tested.
> > 
> > Can you share your elf2flt patch, please. 
> 
> Sure, It the initial patch from Jesse Taube but without the relocation part that
> was part of riscv64 commit:
> 
> https://github.com/uclinux-dev/elf2flt/commit/c5c8043c4d79a1cdd9bd359a542e6fdf3b04d5a1
> 
> I hope this can help.

See attached patch I am using, there is one change missing in your
patch.

best regards
 Waldemar
diff mbox series

Patch

diff --git a/board/qemu/riscv32-virt/nommu/defconfig b/board/qemu/riscv32-virt/nommu/defconfig
new file mode 100644
index 0000000000..460907253a
--- /dev/null
+++ b/board/qemu/riscv32-virt/nommu/defconfig
@@ -0,0 +1,16 @@ 
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_MMU is not set
+CONFIG_COMPAT_32BIT_TIME=y
+CONFIG_SOC_VIRT=y
+CONFIG_NONPORTABLE=y
+CONFIG_ARCH_RV32I=y
+CONFIG_BINFMT_FLAT=y
+CONFIG_SLOB=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_VIRTIO_MMIO=y
+CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
+CONFIG_EXT2_FS=y
+CONFIG_PRINTK_TIME=y
diff --git a/board/qemu/riscv32-virt/nommu/patches/linux-headers b/board/qemu/riscv32-virt/nommu/patches/linux-headers
new file mode 120000
index 0000000000..ce5e2c77b2
--- /dev/null
+++ b/board/qemu/riscv32-virt/nommu/patches/linux-headers
@@ -0,0 +1 @@ 
+linux/
\ No newline at end of file
diff --git a/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0001-riscv-Kconfig-Allow-RV32-to-build-with-no-MMU.patch b/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0001-riscv-Kconfig-Allow-RV32-to-build-with-no-MMU.patch
new file mode 100644
index 0000000000..af11ddf953
--- /dev/null
+++ b/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0001-riscv-Kconfig-Allow-RV32-to-build-with-no-MMU.patch
@@ -0,0 +1,43 @@ 
+From 57800c87e422375ec0df4d5ad7f33659f7b60093 Mon Sep 17 00:00:00 2001
+From: Yimin Gu <ustcymgu@gmail.com>
+Date: Sat, 10 Dec 2022 22:27:47 -0500
+Subject: [PATCH] riscv: Kconfig: Allow RV32 to build with no MMU
+
+Some RISC-V 32bit ores do not have an MMU, and the kernel should be
+able to build for them. This patch enables the RV32 to be built with
+no MMU support.
+
+Signed-off-by: Yimin Gu <ustcymgu@gmail.com>
+CC=c: Jesse Taube <Mr.Bossman075@gmail.com>
+Tested-By: Waldemar Brodkorb <wbx@openadk.org>
+Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
+---
+ arch/riscv/Kconfig | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
+index 59d18881f35b..49759dbe6a8f 100644
+--- a/arch/riscv/Kconfig
++++ b/arch/riscv/Kconfig
+@@ -163,8 +163,8 @@ config MMU
+ 
+ config PAGE_OFFSET
+ 	hex
+-	default 0xC0000000 if 32BIT
+-	default 0x80000000 if 64BIT && !MMU
++	default 0xC0000000 if 32BIT && MMU
++	default 0x80000000 if !MMU
+ 	default 0xff60000000000000 if 64BIT
+ 
+ config KASAN_SHADOW_OFFSET
+@@ -262,7 +262,6 @@ config ARCH_RV32I
+ 	select GENERIC_LIB_ASHRDI3
+ 	select GENERIC_LIB_LSHRDI3
+ 	select GENERIC_LIB_UCMPDI2
+-	select MMU
+ 
+ config ARCH_RV64I
+ 	bool "RV64I"
+-- 
+2.38.1
+
diff --git a/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0002-riscv-Enable-stat64-and-time32-for-RV32-uclibc.patch b/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0002-riscv-Enable-stat64-and-time32-for-RV32-uclibc.patch
new file mode 100644
index 0000000000..f654cca7a6
--- /dev/null
+++ b/board/qemu/riscv32-virt/nommu/patches/linux/6.0/0002-riscv-Enable-stat64-and-time32-for-RV32-uclibc.patch
@@ -0,0 +1,40 @@ 
+From 1d985b3cd0fdb37567b4b8263cae740b49a1f46a Mon Sep 17 00:00:00 2001
+From: Yimin Gu <ustcymgu@gmail.com>
+Date: Sat, 10 Dec 2022 22:31:06 -0500
+Subject: [PATCH] riscv: Enable stat64 and time32 for RV32 uclibc
+
+To comply with current uclibc, macros __ARCH_WANT_STAT64 and
+__ARCH_WANT_TIME32_SYSCALLS are defined. CONFIG_COMPAT_32BIT_TIME also
+has to be turned on.
+
+Tested-By: Waldemar Brodkorb <wbx@openadk.org>
+Signed-off-by: Yimin Gu <ustcymgu@gmail.com>
+Cc: Jesse Taube <Mr.Bossman075@gmail.com>
+Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
+---
+ arch/riscv/include/uapi/asm/unistd.h | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/arch/riscv/include/uapi/asm/unistd.h b/arch/riscv/include/uapi/asm/unistd.h
+index 73d7cdd2ec49..3dc774bc201f 100644
+--- a/arch/riscv/include/uapi/asm/unistd.h
++++ b/arch/riscv/include/uapi/asm/unistd.h
+@@ -15,9 +15,14 @@
+  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+  */
+ 
+-#if defined(__LP64__) && !defined(__SYSCALL_COMPAT)
++#ifndef __SYSCALL_COMPAT
+ #define __ARCH_WANT_NEW_STAT
+ #define __ARCH_WANT_SET_GET_RLIMIT
++#endif /* __SYSCALL_COMPAT */
++
++#ifndef __LP64__
++#define __ARCH_WANT_STAT64
++#define __ARCH_WANT_TIME32_SYSCALLS
+ #endif /* __LP64__ */
+ 
+ #define __ARCH_WANT_SYS_CLONE3
+-- 
+2.38.1
+
diff --git a/board/qemu/riscv32-virt/readme.txt b/board/qemu/riscv32-virt/readme.txt
index 32b4333512..067bb9f436 100644
--- a/board/qemu/riscv32-virt/readme.txt
+++ b/board/qemu/riscv32-virt/readme.txt
@@ -1,5 +1,9 @@ 
 Run Linux in emulation with:
 
-  qemu-system-riscv32 -M virt -bios output/images/fw_jump.elf -kernel output/images/Image -append "rootwait root=/dev/vda ro" -drive file=output/images/rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic # qemu_riscv32_virt_defconfig
+qemu_riscv32_virt_defconfig:
+  qemu-system-riscv32 -M virt -bios output/images/fw_jump.elf -kernel output/images/Image -append "rootwait root=/dev/vda ro" -drive file=output/images/rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic
+  
+qemu_riscv32_nommu_virt_defconfig:
+  qemu-system-riscv32 -M virt -bios none -kernel output/images/Image -append "rootwait root=/dev/vda ro" -drive file=output/images/rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -nographic -cpu rv32,mmu=off
 
 The login prompt will appear in the terminal that started Qemu.
diff --git a/configs/qemu_riscv32_nommu_virt_defconfig b/configs/qemu_riscv32_nommu_virt_defconfig
new file mode 100644
index 0000000000..8bfa1f7435
--- /dev/null
+++ b/configs/qemu_riscv32_nommu_virt_defconfig
@@ -0,0 +1,31 @@ 
+# Architecture
+BR2_riscv=y
+BR2_RISCV_32=y
+# BR2_RISCV_USE_MMU is not set 
+
+# System
+BR2_TARGET_GENERIC_GETTY=y
+BR2_PTHREADS_NONE=y
+
+# Filesystem
+BR2_TARGET_ROOTFS_EXT2=y
+
+# Image
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)"
+
+# Linux headers same as kernel
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_0=y
+
+# Kernel
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.0"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/riscv32-virt/nommu/defconfig"
+BR2_LINUX_KERNEL_IMAGE=y
+BR2_GLOBAL_PATCH_DIR="board/qemu/riscv32-virt/nommu/patches"
+
+# host-qemu for gitlab testing
+BR2_PACKAGE_HOST_QEMU=y
+BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y