nuttx/boards/arm/sama5/sama5d4-ek/configs/knsh/defconfig
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

87 lines
2.3 KiB
Plaintext

#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_MMCSD_MMCSUPPORT is not set
# CONFIG_SAMA5_UART0 is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_ADDRENV=y
CONFIG_ARCH_BOARD="sama5d4-ek"
CONFIG_ARCH_BOARD_SAMA5D4_EK=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_CHIP="sama5"
CONFIG_ARCH_CHIP_ATSAMA5D44=y
CONFIG_ARCH_CHIP_SAMA5=y
CONFIG_ARCH_CHIP_SAMA5D4=y
CONFIG_ARCH_DATA_NPAGES=256
CONFIG_ARCH_DATA_VBASE=0x80100000
CONFIG_ARCH_HEAP_NPAGES=256
CONFIG_ARCH_HEAP_VBASE=0x80200000
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_IRQBUTTONS=y
CONFIG_ARCH_LOWVECTORS=y
CONFIG_ARCH_PGPOOL_MAPPING=y
CONFIG_ARCH_PGPOOL_PBASE=0x28000000
CONFIG_ARCH_PGPOOL_SIZE=134217728
CONFIG_ARCH_PGPOOL_VBASE=0x28000000
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_TEXT_NPAGES=256
CONFIG_ARCH_TEXT_VBASE=0x80000000
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=65775
CONFIG_BOOT_RUNFROMSDRAM=y
CONFIG_BUILD_KERNEL=y
CONFIG_DEV_ZERO=y
CONFIG_ELF=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_HOST_WINDOWS=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_MAX_EXITFUNS=2
CONFIG_MMCSD=y
CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
CONFIG_MMCSD_SDIO=y
CONFIG_MM_PGALLOC=y
CONFIG_NSH_FILE_APPS=y
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=268435456
CONFIG_RAM_START=0x20000000
CONFIG_RAM_VSTART=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SAMA5D4EK_528MHZ=y
CONFIG_SAMA5D4EK_HSMCI0_MOUNT=y
CONFIG_SAMA5_BOOT_SDRAM=y
CONFIG_SAMA5_DDRCS_HEAP_END=0x28000000
CONFIG_SAMA5_DDRCS_PGHEAP_OFFSET=0x08000000
CONFIG_SAMA5_DDRCS_PGHEAP_SIZE=134217728
CONFIG_SAMA5_DDRCS_RESERVE=y
CONFIG_SAMA5_HSMCI0=y
CONFIG_SAMA5_PIOE_IRQ=y
CONFIG_SAMA5_PIO_IRQ=y
CONFIG_SAMA5_RTC=y
CONFIG_SAMA5_TRNG=y
CONFIG_SAMA5_USART3=y
CONFIG_SAMA5_USART4=y
CONFIG_SAMA5_XDMAC0=y
CONFIG_SCHED_HAVE_PARENT=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKPRIORITY=192
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDIO_BLOCKSETUP=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NSH_PROGNAME="init"
CONFIG_USART3_SERIAL_CONSOLE=y