Unifying the Lunaix's Physical Memory Model (#28) feat/user_model
authorLunaixsky <lunaixsky@qq.com>
Sat, 2 Mar 2024 00:22:18 +0000 (00:22 +0000)
committerGitHub <noreply@github.com>
Sat, 2 Mar 2024 00:22:18 +0000 (00:22 +0000)
commitc166bd62fbb907f95f79f621e2a2fb4fdde08e01
treea81d8c2935d6d1255c9b40258608ba98313a9bfb
parent095a899a9749b85443e546b1062026747445658c
Unifying the Lunaix's Physical Memory Model (#28)

* * Introduce new physical page model, which swap out the previous
  address based one, also support dynamically allocate required
  page list based on system mem map provided by upstream bootloader

* Rename page alignment utils from pagetable.h for better expresivenness

* Rewrite the next fit allocator with order-based free-list caching
  feature. (PMALLOC_SIMPLE)

* Intented to add more advanced pmem allocator.

* Add config.h file that provide finer control on the "hyperparameter"
  of Lunaix kernel (we should switch to tools like kconfig later)

* * Introduce struct leaflet, which is a wrapper around struct ppage
  used to tackle the ambiguity of head or tail when struct ppage
  has a order > 0 base page compounded.

* Refactoring done regarding to this new abstraction.

* * Fix compiler-time errors

* Remove the pmm_init_freeze_range api and init_begin/end things
  this forcing allocator to explicitly initialize entire pplist
  during a single pmm_init invoke

* Address all issues found when doing smoking through bootstraping
  stage

* * Fix issues discovered when preforming smoke test from bootstage to
  initd spawn.

     1. pte skipped from copying for grouped pages.
     2. symlink creation ignore the null terminator in ramfs
     3. Add null-ptr termination on when user-provided envp
        and argc are absent (thus only default one get injected)
     4. physical page does not get marked as initialized when
        allocated from uninitialized memory region
     5. a typo cause vunmap accidentially remove L0T mapping
     6. ahci: fis and cb region should not mapped through ioremap.

* Need investigate: seems the physical page got smashed with each
  other when intensive alloc and freeing taking place. Could be
  issues within allocator

* * Fix issue that dup_leaflet copy incomplete data when dealing with
  leaflet with order > 1. This due to lack of flush ranged tlb records

* Fix a memory leakage on leaflet when releasing thread kstack

* * Rework the tlb flushing functions, introduce the ability to respect
  different address space, this allow seamless porting to architecture
  with TLB ASID-tagging support to eliminate un-needed tlb flushing

* * Remove obsoleted vmm api

* * Move all kernel built-in stack to dedicated section

* Add failsafe stack to run failsafe handler without need to worry
  current stack validity (as everything could be messed up when
  shit happened)

* Add failsafe handler to gather diagnostic info and centralise
  stack trace printing, which is robost as it use an dedicated
  stack and all calling being inlined so avoid any stack operation
  before entering it

* Add check on init stack smashing.

* * (LunaDBG) update pmem profiling to reflect the latest changes
62 files changed:
lunaix-os/.vscode/c_cpp_properties.json
lunaix-os/arch/i386/boot/kpt_setup.c
lunaix-os/arch/i386/boot/prologue.S
lunaix-os/arch/i386/exceptions/intr_routines.c
lunaix-os/arch/i386/failsafe.S [new file with mode: 0644]
lunaix-os/arch/i386/includes/sys/cpu.h
lunaix-os/arch/i386/includes/sys/failsafe.h [new file with mode: 0644]
lunaix-os/arch/i386/includes/sys/mm/mempart.h
lunaix-os/arch/i386/includes/sys/mm/mm_defs.h
lunaix-os/arch/i386/includes/sys/mm/pagetable.h
lunaix-os/arch/i386/includes/sys/mm/physical.h [new file with mode: 0644]
lunaix-os/arch/i386/includes/sys/mm/tlb.h [new file with mode: 0644]
lunaix-os/arch/i386/includes/sys/trace.h [new file with mode: 0644]
lunaix-os/arch/i386/mm/pmm.c [new file with mode: 0644]
lunaix-os/arch/i386/mm/tlb.c [new file with mode: 0644]
lunaix-os/arch/i386/mm/vmutils.c
lunaix-os/config.h [new file with mode: 0644]
lunaix-os/hal/ahci/ahci.c
lunaix-os/includes/lunaix/boot_generic.h
lunaix-os/includes/lunaix/compiler.h
lunaix-os/includes/lunaix/failsafe.h [new file with mode: 0644]
lunaix-os/includes/lunaix/mm/fault.h
lunaix-os/includes/lunaix/mm/page.h [new file with mode: 0644]
lunaix-os/includes/lunaix/mm/pagetable.h
lunaix-os/includes/lunaix/mm/physical.h [new file with mode: 0644]
lunaix-os/includes/lunaix/mm/pmm.h
lunaix-os/includes/lunaix/mm/vmm.h
lunaix-os/includes/lunaix/mm/vmtlb.h [new file with mode: 0644]
lunaix-os/includes/lunaix/process.h
lunaix-os/kernel.mk
lunaix-os/kernel/boot_helper.c
lunaix-os/kernel/debug/failsafe.c [new file with mode: 0644]
lunaix-os/kernel/debug/trace.c
lunaix-os/kernel/exe/elf32/ldelf32.c
lunaix-os/kernel/exe/exec.c
lunaix-os/kernel/fs/pcache.c
lunaix-os/kernel/fs/ramfs/ramfs.c
lunaix-os/kernel/kinit.c
lunaix-os/kernel/lunad.c
lunaix-os/kernel/mm/cake.c
lunaix-os/kernel/mm/fault.c
lunaix-os/kernel/mm/mmap.c
lunaix-os/kernel/mm/mmio.c
lunaix-os/kernel/mm/page.c [new file with mode: 0644]
lunaix-os/kernel/mm/pmalloc_buddy.c [new file with mode: 0644]
lunaix-os/kernel/mm/pmalloc_ncontig.c [new file with mode: 0644]
lunaix-os/kernel/mm/pmalloc_simple.c [new file with mode: 0644]
lunaix-os/kernel/mm/pmm.c
lunaix-os/kernel/mm/pmm_internal.h [new file with mode: 0644]
lunaix-os/kernel/mm/procvm.c
lunaix-os/kernel/mm/region.c
lunaix-os/kernel/mm/vmap.c
lunaix-os/kernel/mm/vmm.c
lunaix-os/kernel/process/fork.c
lunaix-os/kernel/process/process.c
lunaix-os/kernel/process/thread.c
lunaix-os/kernel/spike.c
lunaix-os/link/linker.ld
lunaix-os/scripts/gdb/lunadbg/profiling/pmstat.py
lunaix-os/scripts/gdb/lunadbg/structs/page.py
lunaix-os/scripts/gdb/lunadbg/structs/pmem.py [new file with mode: 0644]
lunaix-os/scripts/templates/i386/config.json