nuttx/boards/risc-v/qemu-rv/rv-virt/configs
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
..
citest boards: Enable assert for citest 2023-02-06 21:33:15 +09:00
citest64 boards/citest: disable NET_ARP for usrsocktest 2022-11-24 20:54:18 +08:00
knetnsh64 boards: rv-virt: Add knetnsh64 and knetnsh64_smp 2023-01-16 13:29:40 +08:00
knetnsh64_smp boards: rv-virt: Add knetnsh64 and knetnsh64_smp 2023-01-16 13:29:40 +08:00
knsh64 sched/addrenv: Fix system crash when process group has been deleted 2023-02-08 02:51:23 +08:00
ksmp64 sched/addrenv: Fix system crash when process group has been deleted 2023-02-08 02:51:23 +08:00
netnsh boards: rv-virt: Improve iperf speed for virtio-mmio-net 2022-12-13 13:21:35 +08:00
netnsh64 boards: rv-virt: Improve iperf speed for virtio-mmio-net 2022-12-13 13:21:35 +08:00
netnsh_smp boards: rv-virt: Improve iperf speed for virtio-mmio-net 2022-12-13 13:21:35 +08:00
nsh board: Change CONFIG_SYSTEM_NSH_SYMTAB to CONFIG_NSH_SYMTAB 2022-10-18 22:18:51 +02:00
nsh64 board: Change CONFIG_SYSTEM_NSH_SYMTAB to CONFIG_NSH_SYMTAB 2022-10-18 22:18:51 +02:00
smp boards: Refresh defconfig after the default value of FS_PROCFS_EXCLUDE_xxx 2022-10-18 15:10:26 +09:00
smp64 boards: Refresh defconfig after the default value of FS_PROCFS_EXCLUDE_xxx 2022-10-18 15:10:26 +09:00