huojianchaoyy opened a new pull request, #22206:
URL: https://github.com/apache/nuttx/pull/22206

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   Memory management fixes and small additions from Xiaomi Vela.
   
   memdump and `/proc/memdump`:
   - **mm: support memdump default parameters**: `mm_memdump()` keeps its own 
copy of the request; with `CONFIG_MM_BACKTRACE_SEQNO`, seqmin = seqmax = 0 
means the whole sequence range. **mmdump: fix pid ignored in foreach** then 
keeps the pid of the request.
   - **mm/memdump: fix typos**: with `CONFIG_MM_BACKTRACE > 0` and without 
`CONFIG_MM_BACKTRACE_SEQNO`, the format of `memdump_allocnode()` lost the '%' 
of "%*p" and passed an int to "%s" (crash on sim, see Testing).
   
   mm/map:
   - **mm: Fix vm_map_region/vm_unmap_region interface**: both take the 
`mm_map_s` to use instead of the current one; **drivers/video: Adapt to the new 
vm_map_region/vm_unmap_region.** updates `fb.c`, their only in-tree user.
   - **mm: Pass group to unmap when calling mm_destroy_map**: the munmap 
callbacks get the group, as `tcb->group` is already NULL in `group_leave()`.
   - **mm/map: remove error log unmap**: the log in `mm_map_destroy()` could 
deadlock on the UART spinlock.
   - **mm/map: Follow MISRA-C 2012 10.4**; **mm/map: add mm_map_exist()**: 
whether a range overlaps an existing mapping.
   
   mempool:
   - **mempool:fix pool->nalloc missing lock**; **mempool: improve 
debuggability** (check before modifying).
   - **mm/mempool: MISRA-C 2012 9.1, ...**, **mm/mempool: Avoid using global 
variables.**, **coverity/mempool: fix mempool_multiple_init type covert from 
int into size_t**.
   - **mm/mempool: add mempool_zallocate interface**: allocate a zeroed block.
   - **include/mempool: remove unnecessary header file to avoid redefine**: 
`nuttx/list.h`.
   
   heap, sim heap and iob:
   - **mm/mm_heap: fix null pointer dereference in mm_foreach**; **group.h:add 
task_group_s statement** (forward declaration in `kmalloc.h`).
   - **sim/sim_ummheap.c: fix incompatible_cast bug**; **sim/ummheap: panic if 
total memory exceeds limit**; **arch/sim: give the customize heap static its 
own name**.
   - **mm/iob: Remove the dependency of iob debug on SYSLOG_BUFFER.**; 
**mm/iob: add null check for iob2 in iob_clone_partial**; **mm/iob: handle 
overlapping copyin buffers** (`memmove()`).
   
   KASAN and UBSAN:
   - **kasan: fix link error** 
(`__sanitizer_annotate_double_ended_contiguous_container` for libc++); 
**kasan_report: fix spacing**.
   - **mm/kasan: expose compiler-rt __asan_(un)poison_memory_region**: new 
`<sanitizer/asan_interface.h>`.
   - **mm/kasan: default enable DISABLE_READS_CHECK**.
   - **mm/ubsan: Supplementing missing interfaces for ubsan**; **mm/ubsan: 
never report recursively**.
   
   build:
   - **cmake: fix section not take effect**: SEGGER RTT and IOB section names 
are passed quoted, as `locate_data()` needs.
   - **nuttx: Adapt for Tasking compiler**: section macros come from the 
Kconfig symbols (master already has the `syslog_rpmsg.c` part).
   
   Two follow-up commits:
   - **fs/fs_heap: add the missing blank lines after declarations** (first): 
existing nxstyle errors in `fs/fs_heap.c`, which this PR touches.
   - **mm/mempool: add the missing blank line in mempool_zallocate()** 
(nxstyle).
   
   ## Impact
   
   - `CONFIG_MM_KASAN_DISABLE_READS_CHECK` defaults to y: KASAN checks writes 
only unless it is turned off.
   - `vm_map_region()` and `vm_unmap_region()` take the `mm_map_s` as first 
argument; `drivers/video/fb.c` is updated, out-of-tree callers need the same 
change.
   - sim: the user heap reports and panics (`DEBUGPANIC()`) when its usage 
passes the heap size.
   - New APIs: `mempool_zallocate()`, `mm_map_exist()`, 
`__asan_poison_memory_region()` / `__asan_unpoison_memory_region()`.
   
   ## Testing
   
   Host: Ubuntu 22.04 x86_64, GCC 13.4.0 (sim, aarch64-none-elf), Arm GNU 
Toolchain 13.2.rel1, CMake 3.23 + Ninja 1.10, QEMU 10.2.1. Base: master 
1a1a9601120.
   
   `./tools/checkpatch.sh -c -u -m -g HEAD~34..HEAD` passes.
   
   `sim:nsh` with `CONFIG_MM_BACKTRACE=8 CONFIG_MM_BACKTRACE_SEQNO=n`, `echo 
used > /proc/memdump`:
   
   ```
   master:  PID        Size Overhead            Address Backtrace
                 0          88       88*p        <- segmentation fault
   this PR: PID        Size Overhead            Address Backtrace
                 0          88       88     0x731d26000768
   ```
   
   With `CONFIG_MM_BACKTRACE_SEQNO=y` (the default) the `/proc/memdump` output 
(used, pid, leak) is the same as on master.
   
   `sim:ostest` (KASAN and UBSAN): ostest passes run with no KASAN/UBSAN 
report; three passes give the same output as master.
   
   `qemu-armv7a:knsh` boots and runs `hello` and `getprime` from `/system` 
(semihosting).
   
   Builds (CMake): `sim:nsh` with backtrace 8 / 0, with and without 
`MM_BACKTRACE_SEQNO`, with the TLSF manager, with `MM_IOB` and 
`IOB_SECTION=".bss.iob"`, with `VIDEO_FB`; `sim:ostest`; `qemu-armv7a:knsh` 
with and without `VIDEO_FB`; `qemu-armv8a:nsh_smp`; `qemu-armv8a:sw_tags`; 
`mps2-an500:nsh`. Make: `sim:nsh` with the backtrace and mempool options.
   
   Not tested: a Tasking build, SEGGER RTT sections, real hardware.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to