Commit Graph

50 Commits

Author SHA1 Message Date
heyuanjie87
c16d14e70b [mm]修复unmap内存时遗漏刷新地址转换表的问题,避免dcache(PIPT)出错 2025-03-10 22:32:32 +08:00
Shell
d9b36c8d18 feat: improve Kconfig structure on MM
Signed-off-by: Shell <smokewood@qq.com>
2025-02-25 11:26:30 +08:00
Shell
60f7b3affc feat: mm: page poison debugging and assertion enhancements
This commit introduces a page poison debugging mechanism and additional
assertions for memory management, improving system maintainability and
debugging capabilities. The changes aim to detect illegal memory usage
early and provide better clarity in managing page allocations.

Changes:
- Added `RT_DEBUGGING_PAGE_POISON` option to enable memory usage tracing.
- Introduced a page poisoner for detecting illegal memory usage.
- Implemented region-based memory tracking using bitmaps.
- Enhanced spinlock protection for memory management operations.
- Fixed several assertion checks for memory safety.
- Renamed macros for consistency (`FLOOR` to `CEIL`).
- Refined memory allocation and deallocation logic to include poisoning.
- Updated Kconfig to add configurable `RT_PAGE_MAX_ORDER` and poison debugging.
- Improved debugging outputs for page regions and memory operations.

Signed-off-by: Shell <smokewood@qq.com>
2025-02-25 11:26:30 +08:00
Shell
269d28ac3b feat: mm: install page in a discrete method
This patch refactors the `rt_page_install` function by delegating specific
operations to new helper functions. Besides, the contiguous page regions
are now separated to segments of fixed size. The goal is to improve the
overall code readability, enhance modularity, and ensure better handling
of page installation logic through clearer separation of concerns.

Changes:
- Introduced `_get_mpr_ready_n_install` to encapsulate memory preparation
  and page installation logic.
- Added `_update_region_list` for updating the installed page registry.
- Defined `_PAGE_STRIPE` for optimized region processing.
- Modified `rt_page_install` to handle regions in smaller chunks using
  helper functions for better maintainability.
- Improved locking mechanisms with `rt_spin_lock` for thread safety.
- Reduced code duplication and clarified shadow region calculations.

Signed-off-by: Shell <smokewood@qq.com>
2025-02-25 11:26:30 +08:00
Shell
9386411d13 feat: mm: added affinity pages allocator
This patch introduces a tagged pages allocator to address the existing problems
of page aliasing on specific platforms and the requirement of page coloring.
It implements an affinity-id aware page manager by separating the runtime page
list into two types: a normal single linked-list and a multi-dimensional affinity-list.

Changes:
- Introduced tagged pages allocator and managing algorithm for affinity pages list
- Modified components to support affinity-id list management
- Updated page allocation and freeing functions to handle tagged pages
- Added configuration options for page affinity block size and debugging
- Modified mmap and elf loading to respect affinity settings
- Enhanced page list management to support multi-dimensional affinity-list

Signed-off-by: Shell <smokewood@qq.com>
2025-02-25 11:26:30 +08:00
zhujiale
e7b30ed2cc [componets] fix when printf 0 addr by %p will return nil 2024-12-09 19:45:40 -05:00
Shell
beee77f372 feat: support ARCH_REMAP_KERNEL on libcpu/c906 (#9123)
feat: [libcpu/c906] support ARCH_REMAP_KERNEL

This change was necessary to enable the remapping of the kernel image to
a high virtual address region on the c906 platform.

Changes:
- Introduced new configuration options `ARCH_REMAP_KERNEL`, and
  `ARCH_USING_ASID` under the `ARCH_RISCV64` section.
- Updated MMU initialization and switching functions to incorporate
  remapping handling.
- Modified page table setup for proper memory attribute settings.
- Added support for early memory setup, kernel remapping
- Added conditional compilation for ASID support in the `rt_aspace` struct,
  since this is not enable currently for most architecture.

Signed-off-by: Shell <smokewood@qq.com>
2024-07-11 11:00:04 +08:00
zms123456
b785ef9ed7 [libcpu][aarch64]memory setup using memblock (#9092)
* memory setup using memblock

* map pages later
2024-06-26 14:36:49 +08:00
Shell
fa2d80679e [smart] add mprotect config (#9082)
Signed-off-by: Shell <smokewood@qq.com>
2024-06-22 13:30:55 +08:00
Shell
f00db6381a [mm] precise & readable mm fault type (#9047)
* [smart] fixup: precise mm fault type

Also, fixup arm64 read access fault

* arm64: using meaningful macro on trap

* fixup: renaming macro
2024-06-07 21:34:03 +08:00
Chen Wang
f0af6ef809 component:mm: improve sconscript (#9028)
There is no next-level directory under the components/mm/
directory. Do not need to enter the next-level directory
to process the SConscript file.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
2024-06-05 10:04:32 +08:00
Shell
9ba6cec663 [libcpu/arm64] dealing with mem region out of kernel space (#8847)
* [ofw] dealing with mem region out of kernel space

- Fix parameter checking in _out_of_range() that NULL is excluded for
  fixed mapping
- Split page install with a deferred stage to avoid mapping over
  ARCH_EARLY_MAP_SIZE

Signed-off-by: Shell <smokewood@qq.com>

* fixup: restrict vstart for using of RT_NULL

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-08 09:23:31 +08:00
Shell
864055bf18 [fixup] aarch64 UMP compiler error (#8677)
Signed-off-by: Shell <smokewood@qq.com>
2024-03-30 17:58:38 +08:00
Shell
83e95bdff4 sync smart & dfs (#8672)
Signed-off-by: xqyjlj <xqyjlj@126.com>
Signed-off-by: Shell <smokewood@qq.com>
Co-authored-by: xqyjlj <xqyjlj@126.com>
2024-03-28 23:42:56 +08:00
Shell
53754ff50a [fixup] check NULL pointer before access (#8573)
Signed-off-by: Shell <smokewood@qq.com>
2024-03-02 16:05:19 +08:00
Shell
71560bafb5 🎯 Sync smart & scheduler codes (#8537)
Signed-off-by: Shell <smokewood@qq.com>
Co-authored-by: xqyjlj <xqyjlj@126.com>
2024-02-23 17:49:15 +08:00
fangjianzhou
b233e29bb6 [libcpu][aarch64] 使用设备树对内存进行初始化 (#8320) 2023-12-16 18:08:11 +08:00
geniusgogo
7aa130c83c update mm. (#8334) 2023-12-05 16:44:00 +08:00
Shell
c87872c9c7 [mm] Bugs fix for page_install on shadow region (#8308)
Signed-off-by: Shell <smokewood@qq.com>
2023-11-30 22:00:54 +08:00
Shell
c2036e769a [smart] fixup of lwp recycling and mm varea (#8206)
Signed-off-by: shell <wangxiaoyao@rt-thread.com>
Signed-off-by: Shell <smokewood@qq.com>
Co-authored-by: xqyjlj <xqyjlj@126.com>
2023-11-02 20:23:11 +08:00
xqyjlj
3283f54c7a 🎈 perf: perf rt_hw_interrupt_disable/enable (#8042)
Signed-off-by: Shell <smokewood@qq.com>
Co-authored-by: Shell <smokewood@qq.com>
2023-10-25 20:31:25 +08:00
Shell
e94b759160 [quality] fixup: vulnerability in kernel
including out-of-bound access in dfs, and use-after-free in
aspace_traversal

Signed-off-by: Shell <smokewood@qq.com>
2023-10-25 18:40:44 +08:00
Shell
fb78a71020 [smart] replace varea pgmgr and fixup of dfs mmap (#8184)
Signed-off-by: shell <smokewood@qq.com>
Signed-off-by: Shell <smokewood@qq.com>
2023-10-25 14:59:48 +08:00
geniusgogo
ecd29fda60 Sync dfs lwp (#8123) 2023-10-17 13:07:59 +08:00
zms123456
a39da9cb59 [components][mm]添加预留内存支持 (#8025) 2023-10-14 14:10:57 +08:00
Meco Man
5f948690c9 [rtdef] rename RT_CTASSERT to RT_STATIC_ASSERT 2023-09-06 22:21:22 -04:00
xiao-mang
348c1fcecd fix list_page (#7968) 2023-08-21 10:05:19 +08:00
Shell
d862816a51 [components/mm] add unmap page API (#7834)
Signed-off-by: Shell <smokewood@qq.com>
2023-08-16 15:38:59 +08:00
GUI
d3417aa0d7 Prepare some api for DM (#7894)
Signed-off-by: GuEe-GUI <GuEe-GUI@github.com>
2023-08-02 12:48:24 +08:00
Man, Jianting (Meco)
244b903e5d [debug] 整理debug宏并增加RT_DEBUGING_CONTEXT (#7805) 2023-07-22 10:36:42 +08:00
Shell
af01d1fd1c [components/mm] improve output of list_page (#7779) 2023-07-05 17:54:28 +08:00
geniusgogo
0315c0dee7 add lstat&sysinfo....syscall. (#7555) 2023-05-23 22:43:38 +08:00
Shell
6e7c5d9bc9 [libcpu/aarch64] fix cache invalidate operation (#7363) 2023-04-26 17:17:42 +08:00
Shell
470454d201 [components/mm] support for scalable memory management (#7277)
* [mm/page] multi-list page manager
[mm/page] page debugger
[libcpu/aarch64] hugepage support

* [quality] remove void-arith

* [format] remove kasan codes
2023-04-22 23:59:11 +08:00
xiaoniaoyou6hua
4f1c3a1472 fix warning (#7340) 2023-04-22 09:25:52 +08:00
Shell
897ba365ba [fix] compilation error from rpi (#7143)
* [fix] compile error from rpi
2023-03-31 20:58:01 +08:00
Shell
eec78d9f5d [rt-smart] testcase & improvements for memory management (#7099)
* [utest/mm] add testcase for create/init
format codes of create/init in components/mm

* [libcpu/aarch64] fix user stack check routine

* [kservice] export API for utest

* [utest/mm] testcase for aspace_map
format & modify the files under components/mm related with aspace_map

* [lwp/user_mm] add user_map_varea for mmap feature

* [mm] rename rt_mm_fault_try_fix to rt_aspace_fault_try_fix

* [utest/mm] testcase for synchronization

* [mm] modify unmap api to improve throughput

* [utest/mm] testcases for cache and varea map

* [format] remove extra space

* [utest/mm] fix testcase problem in header

* [lwp] extend map_user_varea with a flag

* [utest/mm] testcase for lwp_map_user_varea

* [libcpu/arm/cortex-a] fix kernel space layout

* [utest/mm] adjust for armv7 arch
2023-03-30 08:25:15 +08:00
Shell
dd2f1a795a [rt-smart] fix competition on aspace (#7064)
* [mm] mmu operations should be wrapped by _aspace_bst_insert & _aspace_bst_remove to avoid competition on page table

* [lwp] may not return null on failed
2023-03-19 14:41:50 +08:00
Shell
18a14cc935 [rt-smart] move sys_cacheflush to lwp_syscall.c (#7048)
* [syscall] move sys_cacheflush to lwp_syscall.c

* [syscall] improve assertion

* [format] rename to rt_ctassert

* [debug] modified ct assertion on mm_page.c
2023-03-17 15:11:38 +08:00
张世争
334c609c6c [components][mm] add ioremap for normal memory api (#7050) 2023-03-16 10:27:16 +08:00
Shell
2394e75265 [libcpu/risc-v] support noncached normal memory (#7051)
* [libcpu/risc-v] support noncached normal memory

* [mm] check before dereference in _fetch_page

* [mm] add comments on ioremap

* [ioremap] report more info on failed
2023-03-16 10:26:55 +08:00
Shell
0de21341f9 [fix] mm bugs (#7010)
* [fix] implementation fault on avl

* [fix] mm may free varea allocated statically

* [test] add test and benchmark for avl
2023-03-03 11:51:21 +08:00
wangxiaoyao
484a0d602e [fixup] add cache maintenance ops;
fix bugs on cache maintenance when starting user app
2023-02-21 08:48:49 +08:00
wangxiaoyao
855aef9c9c [mm] distinguish NULL and MAP_FAILED 2023-02-21 08:48:49 +08:00
Shell
2d09749086 [rt-smart] PV_OFFSET as a variable (#6904)
* [rt-smart/mem] remove pv_offset

* [rt-smart] list kernel space command

* [rt-smart] restore ioremap region

* [revert] restore kernel space isolation

* [rt-smart/pv_off] code format

* [rt-smart] add get_pvoff()

* [pvoffset] pvoff as constant for C codes

* [pvoff] pvoff as interfaces
2023-02-14 23:08:32 +08:00
chenhy0106
9db73a47c4 为c906添加asid支持 (#6870)
* [rt-smart] asid for c906
2023-01-28 13:08:40 -05:00
Shell
f0dadcb3c3 [rt-smart] porting c906 and D1s to mm (#6848)
* [rv64/bsp] porting to mm

* [mm] report more info for debugging

* [fix] code format

* [libcpu/c906] porting to RTOS

* [fix] using rtdbg api

* [fix] add return

* [fix] report more information for debugging

* [fix] use assert 0 for unrecoverable error
2023-01-16 08:24:03 +08:00
Shell
12189d533a [rt-smart/mm] enable mm on armv7, armv8, rv64 only (#6834)
* [mm] enable mm on armv7, armv8, rv64 only

* [mm] config on ARCH_MM_MMU
2023-01-11 16:24:51 +08:00
Meco Man
9bc68d26a4 format Kconfig and sconscript 2023-01-08 22:52:13 -05:00
Shell
7450ef6c4d [rt-smart] kernel virtual memory management layer (#6809)
synchronize virtual memory system works.
adding kernel virtual memory management layer for page-based MMU enabled architecture
porting libcpu MMU codes
porting lwp memory related codes
2023-01-08 21:08:55 -05:00