Commit Graph

56 Commits

Author SHA1 Message Date
Inochi Amaoto 49b3f52db1 arch/riscv/qemu-rv: replace M-mode init code with SBI in kernel build
The qemu-rv use a small init code for M mode in kernel build.
It is hard-coding and is difficult to change. Due to the fact,
introduce a already mature SBI implement (e.g OpenSBI) to
replace existing code is a better choice.

This patch introduce some change for qemu-rv:
1. use SSTC to provide time interrupt in kernel build
2. remove uncessary M mode trap.

For simplicity, this patch does not add support for booting
nuttx for any core, but force boot core to start core 0 and
let core 0 do the initialization.

Signed-off-by: Inochi Amaoto <inochiama@outlook.com>
2024-04-27 22:09:22 -03:00
chao an 28044f7d5a arch/risc-v: add support of save/restore vector registers
Reference:
https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc
https://github.com/torvalds/linux/blob/master/arch/riscv/include/asm/vector.h

Signed-off-by: chao an <anchao@lixiang.com>
2024-04-23 16:18:46 -03:00
Yanfeng Liu 7a9690dee7 rv-virt/knsh32: enable debugging options
This enables debugging options for `rv-virt/knsh32` as it is more
convenient for debugging and testing.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-04-16 19:09:31 +08:00
vela-mib 9847c6219d add libuv and cmocka test cases with file system on sim and qemu on CI
Signed-off-by: vela-mib <vela-mib@xiaomi.com>
2024-04-10 14:46:53 +08:00
Alan Carvalho de Assis 46b1eb44b6 boards: Fix board configs after disabling NSH_DISABLE_HELP 2024-04-04 12:27:03 +08:00
vela-mib 8ff3b90742 add open posix test cases on qemu and sim on CI
Signed-off-by: vela-mib <vela-mib@xiaomi.com>
2024-03-21 18:42:47 +08:00
Tiago Medicci Serrano c67502d9b4 riscv: Implement page-fault exception and on-demand paging
When an application is being loaded `up_addrenv_create ` calls
`create_region` to create the address environment. Only the first
entry is mapped when the region is created. Virtual memory that is
not mapped will trigger an exception when accessed. Other memory
pages are allocated and mapped on-demand. This enables setting
larger heap and stack for the process without compromising the
overall system memory.
2024-03-05 09:45:49 +08:00
Huang Qi 561378ba6b rv-virt: Add libcxx to configs
Basic configs for libcxx and cxxtest on rv32/rv64.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-02-27 21:25:20 +08:00
Tiago Medicci Serrano cb32e6d50a risc-v/qemu-rv/rv-virt: Add support to loader ROMFS image in kernel
Use ROMFS to load user applications in kernel mode instead of using
hostfs.
2024-02-07 19:46:42 -08:00
Masayuki Ishikawa 38f8aae3be boards: rv-virt: Add nxrecorder to defconfigs
Summary:
- This commit adds nxrecorder to netnsh/netnsh_smp/netnsh64/
  netnsh64_smp defconfigs.

Impact:
- None

Testing:
- Tested with qemu-8.2.0 on Raspi4B with USB Audio

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2024-02-06 00:41:44 -08:00
Masayuki Ishikawa 78d22b997c boards: rv-virt: Fix the hello app crash with nsh64
Summary:
- I noticed that the hello app crashes due to
  https://github.com/apache/nuttx/pull/11576
- This is a tentative fix to avoid the crash

Impact:
- None

Testing:
- Tested with qemu-8.2.0

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2024-01-22 23:18:43 -08:00
Yanfeng Liu b46ee08230 rv-virt/configs: avoid build errors
- disable NSH_SYMTAB to avoid build errors with cmake.
- enable LIBM to avoid build errors with Ubuntu stock
  gcc-riscv64-unknown-elf toolchain.
- use HELLO=y for easy use within qemu console.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-01-22 08:18:04 +01:00
Yanfeng Liu a9372627d8 risc-v/rv-virt: use fully linked apps for kernel build
Fully linked apps take less storage and are efficient to load. This
is to enable them for rv-vrit configurations in KERNEL build.

Changes:

- arch/risc-v/Kconfig       select BINFMT_ELF_EXECUTABLE for QEMU-RV
- boards/risc-v/qemu-rv/rv-virt/configs
  - knsh32/defconfig        enable ELF_EXECUTABLE, LIBM, OSTEST
  - knsh64/defconfig        enable ELF_EXECUTABLE, LIBM, OSTEST
  - ksmp64/defconfig        enable ELF_EXECUTABLE, LIBM, OSTEST
  - knetnsh64/defconfig     enable ELF_EXECUTABLE, LIBM, OSTEST
  - knetnsh64_smp/defconfig enable ELF_EXECUTABLE, LIBM, OSTEST

Additions:
- boards/risc-v/qemu-rv/rv-virt/scripts/
  - gnu-elf.ld              apps linker script

The ARCH_TEXT_VBASE of knsh32 is set to same as that of 64bit to reuse
the apps linker script.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-01-11 00:51:07 -08:00
Xiang Xiao b9bd88d9d3 rptun: Select OPENMAP under RPTUN
to simplify the IPC related configuration

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-12-28 11:08:57 +08:00
Masayuki Ishikawa 80ca3e9308 boards: rv-virt: Add virtio-sound
Summary:
- Add virtio-sound to the following configs
  netnsh, netnsh_smp, netnsh64, netnsh64_smp

Impact:
- None

Testing:
- nxplayer works on qemu-8.2.0-rc3 (ubuntu-20.04 amd64)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-12-14 20:01:25 +08:00
Ville Juven 20eb1831b1 rv-virt/knsh: Set correct RAM_START and RAM_SIZE
Also, set RAM_VSTART, because we have vaddr=paddr mapping. Otherwise
RAM_VSTART gets its default value which is 0.
2023-11-24 04:39:25 -08:00
Bowen Wang f01f290c3f qemu/config: enable CONFIG_DEV_SIMPLE_ADDRENV for all qemu configs
Enable CONFIG_DEV_SIMPLE_ADDRENV for all the qemu configs that used
the virtio driver to fix compile error when use the NuttX implemented
metal io read/write operations.
Becasue up_addrenv_pa_to_va() and up_addrenv_va_to_pa() are not
implemented by default.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-11-17 09:42:52 +01:00
Alan Carvalho de Assis c27c33e9a9 Run refresh.sh to update all board configs 2023-09-02 14:45:44 +08:00
Peter Bee 99c2a6ffbe boards: add defconfig for virtio-gpu fb showcase
Usage example:

tools/configure.sh qemu-armv8a:fb
make -j
qemu-system-aarch64 -cpu cortex-a53 \
    -machine virt,virtualization=on,gic-version=3 \
    -chardev stdio,id=con,mux=on -serial chardev:con \
    -global virtio-mmio.force-legacy=false \
    -device virtio-gpu-device,xres=640,yres=480,bus=virtio-mmio-bus.1 \
    -mon chardev=con,mode=readline \
    -kernel ./nuttx

tools/configure.sh rv-virt:fb
make -j
qemu-system-riscv32 -semihosting -M virt -cpu rv32 -smp 8 -bios none -chardev stdio,id=con,mux=on -serial chardev:con -device virtio-gpu-device,xres=640,yres=480,bus=virtio-mmio-bus.1 -mon chardev=con,mode=readline -kernel ./nuttx

tools/configure.sh rv-virt:fb64
make -j
qemu-system-riscv64 -semihosting -M virt -cpu rv64 -smp 8 -bios none -chardev stdio,id=con,mux=on -serial chardev:con -device virtio-gpu-device,xres=640,yres=480,bus=virtio-mmio-bus.1 -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2023-08-11 20:20:11 +08:00
Xiang Xiao 6b4e5c0d15 binfmt: Change the default of BINFMT_DISABLE to DEFAULT_SMALL
to optimize the image size when and DEFAULT_SMALL is enabled
and refresh the defconfig in boards/

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-08-10 11:35:41 +03:00
wangbowen6 9aa57b6c53 virtio: add virtio framework in NuttX
1. virtio devics/drivers match and probe/remote mechanism;
2. virtio mmio transport layer based on OpenAmp (Compatible with both
   virtio mmio version 1 and 2);
3. virtio-serial driver based on new virtio framework;
4. virtio-rng driver based on new virtio framework;
5. virtio-net driver based on new virtio framework
   (IOB Offload implementation);
6. virtio-blk driver based on new virtio framework;
7. Remove the old virtio mmio framework, the old framework only
   support mmio transport layer, and the new framwork support
   more transport layer and this commit has implemented all the
   old virtio drivers;
8. Refresh the the qemu-arm64 and qemu-riscv virtio related
   configs, and update its README.txt;

New virtio-net driver has better performance
Compared with previous virtio-mmio-net:
|                        | master/-c | master/-s | this/-c | this/-s |
| :--------------------: | :-------: | :-------: | :-----: | :-----: |
| qemu-armv8a:netnsh     |  539Mbps  |  524Mbps  | 906Mbps | 715Mbps |
| qemu-armv8a:netnsh_smp |  401Mbps  |  437Mbps  | 583Mbps | 505Mbps |
| rv-virt:netnsh         |  487Mbps  |  512Mbps  | 760Mbps | 634Mbps |
| rv-virt:netnsh_smp     |  387Mbps  |  455Mbps  | 447Mbps | 502Mbps |
| rv-virt:netnsh64       |  602Mbps  |  595Mbps  | 881Mbps | 769Mbps |
| rv-virt:netnsh64_smp   |  414Mbps  |  515Mbps  | 491Mbps | 525Mbps |
| rv-virt:knetnsh64      |  515Mbps  |  457Mbps  | 606Mbps | 540Mbps |
| rv-virt:knetnsh64_smp  |  308Mbps  |  389Mbps  | 415Mbps | 474Mbps |
Note: Both CONFIG_IOB_NBUFFERS=64, using iperf command, all in Mbits/sec
      Tested in QEMU 7.2.2

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-10 03:39:39 +08:00
Brennan Ashton 46b0f6d6ee fdt: Add initial FDT support and procfs for userspace export
VELAPLATFO-12536

This provides the initial hooks for Flattened Device Tree support
with QEMU RV. It also provides a new procfs file that exposes the
fdt to userspace much like the /sys/firmware/fdt endpoint in Linux.
See https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-ofw

Nodes in the fdt are not yet usable by the OS.

Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
Signed-off-by: liaoao <liaoao@xiaomi.com>
2023-08-05 12:41:06 -07:00
Ville Juven 61460efe3c riscv/qemu-rv: Add FPU support back to qemu-rv
The FPU restore issue does not show itself any longer, so FPU support
can be re-enabled.
2023-07-31 07:48:53 -07:00
Masayuki Ishikawa 8bbe7a8825 boards: Enable virtio-blk and FAT for virt configurations
Summary:
- I noticed that virtio-blk and FAT are not enabled for some
  virt configurations.
- This commit enables them for testing.

Impact:
- None

Testing:
- Tested with qemu-7.1
- NOTE: file copy with rv-virt:knetnsh64 is sometimes unstable.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-07-01 13:10:40 +08:00
Masayuki Ishikawa a85c87436e boards: rv-virt: Add netnsh64_smp to test virtio
Summary:
- This commit adds netnsh64_smp to test virtio

Impact:
- None

Testing:
- Tested with qemu-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-06-12 08:17:38 +02:00
Masayuki Ishikawa 08da38b535 boards: Enable md5 to test virtio
Summary:
- This commit enables md5 to test virtio

Impact:
- None

Testing:
- Tested with qemu-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-06-11 22:54:06 +08:00
Masayuki Ishikawa 766e0a3b05 boards: Enable NFS to test virtio-mmio-net
Summary:
- This commit enables NFS to test virtio-mmio-net

Impact:
- None

Testing:
- Tested with qemu-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-06-02 16:28:34 +08:00
Masayuki Ishikawa 8a70f8a76d boards: Add virtio blk driver to qemu-arm8a and rv-virt
Summary:
- This commit adds blk driver to qemu-armv8a:netnsh,
  rv-virt:netnsh and rv-virt:netnsh64
- Also updates README.txt

Impact:
- None

Testing:
- Tested with qemu-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-05-13 13:58:09 +08:00
chao an 5945f080b9 boars/spawn_proxy: remove all CONFIG_POSIX_SPAWN_PROXY_STACKSIZE
Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-27 17:35:58 +08:00
chao an f620b039aa rv-virt/knsh64: increase proxy stack size to avoid overflow
Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-24 12:59:39 +03:00
chao an f2257ffd80 rv-virt/nsh64: enable CONFIG_BCH to support block device access
Since ramdisk is registered as block device, enable CONFIG_BCH
to support block device access

Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-23 23:27:23 +08:00
Stuart Ianna 01b0305ab5 risc-v: SV32 MMU support for qemu-rv. 2023-03-29 22:15:19 +09:00
Xiang Xiao 66c5f86018 sched: Disable stdio api by default when DEFAULT_SMALL equals y
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-03 00:18:03 +02:00
Xiang Xiao 8b4ecac6c2 libc: Move math library from libs/libc/math to libs/libm/libm
to prepare the support of other implementation e.g.:
https://github.com/JuliaMath/openlibm
https://gitlab.com/gtd-gmbh/libmcs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-23 10:40:07 +02:00
Ville Juven 09e7987121 sched/addrenv: Fix system crash when process group has been deleted
There is currently a big problem in the address environment handling which
is that the address environment is released too soon when the process is
exiting. The current MMU mappings will always be the exiting process's, which means
the system needs them AT LEAST until the next context switch happens. If
the next thread is a kernel thread, the address environment is needed for
longer.

Kernel threads "lend" the address environment of the previous user process.
This is beneficial in two ways:
- The kernel processes do not need an allocated address environment
- When a context switch happens from user -> kernel or kernel -> kernel,
  the TLB does not need to be flushed. This must be done only when
  changing to a different user address environment.

Another issue is when a new process is created; the address environment
of the new process must be temporarily instantiated by up_addrenv_select().
However, the system scheduler does not know that the process has a different
address environment to its own and when / if a context restore happens, the
wrong MMU page directory is restored and the process will either crash or
do something horribly wrong.

The following changes are needed to fix the issues:
- Add mm_curr which is the current address environment of the process
- Add a reference counter to safeguard the address environment
- Whenever an address environment is mapped to MMU, its reference counter
  is incremented
- Whenever and address environment is unmapped from MMU, its reference
  counter is decremented, and tested. If no more references -> drop the
  address environment and release the memory as well
- To limit the context switch delay, the address environment is freed in
  a separate low priority clean-up thread (LPWORK)
- When a process temporarily instantiates another process's address
  environment, the scheduler will now know of this and will restore the
  correct mappings to MMU

Why is this not causing more noticeable issues ? The problem only happens
under the aforementioned special conditions, and if a context switch or
IRQ occurs during this time.
2023-02-08 02:51:23 +08:00
Xiang Xiao d8a8c2fdd8 boards: Enable assert for citest
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-06 21:33:15 +09:00
Masayuki Ishikawa 896dbb2499 boards: rv-virt: Add knetnsh64 and knetnsh64_smp
Summary:
- This commit adds knetnsh64 and knetnsh64_smp

Impact:
- None

Testing:
- Tested with ping, telnet and iperf on QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-01-16 13:29:40 +08:00
Masayuki Ishikawa f4c349963a boards: rv-virt: Improve iperf speed for virtio-mmio-net
Summary:
- This commit improves iperf speed for virtio-mmio-net

Impact:
- None

Testing:
- Tested with QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-12-13 13:21:35 +08:00
Masayuki Ishikawa 5c8d9c928a boards: rv-virt: Add virtio-net to netnsh/netnsh_smp/netnsh64
Summary:
- This commit add virtio-net to netnsh/netnsh_smp/netnsh64

Impact:
- None

Testing:
- Tested iperf and telnetd with QEMU-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-11-29 13:16:44 +08:00
chao an 6d8c28a83c boards/citest: disable NET_ARP for usrsocktest
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-24 20:54:18 +08:00
nietingting f361d1cd41 CI: add example to sim
Signed-off-by: nietingting <nietingting@xiaomi.com>
2022-10-26 10:55:50 +08:00
nietingting 8438396f33 ci: add qemu run support
Signed-off-by: nietingting <nietingting@xiaomi.com>
2022-10-21 14:57:43 +08:00
Xiang Xiao edd68d8ae9 board: Change CONFIG_SYSTEM_NSH_SYMTAB to CONFIG_NSH_SYMTAB
follow the apps side change

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-18 22:18:51 +02:00
Xiang Xiao 7923ea3bef boards: Refresh defconfig after the default value of FS_PROCFS_EXCLUDE_xxx
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-18 15:10:26 +09:00
Masayuki Ishikawa d5d76560ef boards: rv-virt: Add ksmp64 configuration
Summary:
- This commit adds ksmp64 configuration to test BUILD_KERNEL+SMP
- NOTE: README.txt has been updated

Impact:
- None

Testing:
- Tested with QEMU 6.2

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-10-08 09:25:41 +08:00
Xiang Xiao af12a552fe sched/Kconfig: let PREALLOC_TIMERS depends on !DISABLE_POSIX_TIMERS
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-19 11:39:22 -03:00
Masayuki Ishikawa 0ba9d8e9f5 boards: rv-virt: Assign dedicated text/heap area in knsh64/defconfig
Summary:
- This commit assigns dedicated text/heap areas that improve
  stability issues with rv-virt:knsh64

Impact:
- None

Testing:
- Tested with qemu-6.2

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-08-30 22:52:01 +08:00
Masayuki Ishikawa dc2a01e75a boards: rv-virt: Add knsh64 related files
Summary:
- This commit adds knsh64 related files

Impact:
- None

Testing:
- Tested with qemu-6.2

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-05-13 04:14:01 +08:00
Masayuki Ishikawa 0908c67d73 boards: rv-virt: Add support ELF to nsh and nsh64 defconfigs
Summary:
- This commit adds support ELF to nsh and nsh64 defconfigs

Impact:
- None

Testing:
  nsh> mount -t hostfs -o fs=../apps/bin /system/bin
  nsh> hello
  Hello, World!!

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-05-03 13:57:24 +08:00
Masayuki Ishikawa 9b20f97064 boards: rv-virt: Add hostfs support to nsh and nsh64 defconfigs
Summary:
- This commit adds hostfs support to nsh and nsh64 defconfigs

Impact:
- None

Testing:
- Tested with qemu-6.2

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-05-02 19:46:58 +08:00