Commit Graph

21 Commits

Author SHA1 Message Date
anjiahao d1d46335df Replace nxsem API when used as a lock with nxmutex API
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
Xiang Xiao 5253861e7e mm: Fix minor style issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-16 15:24:49 +09:00
chao.an 27c888854d mm_heap/kasan: poison free node after return back the heap list
The free node is still in use after kasan_poison(), the node member
access will cause the assert report by kasan.

|  (gdb) bt
|  #0  kasan_report (addr=1743265406637584896, size=140737337053680, is_write=46) at kasan/kasan.c:97
|  #1  0x0000555555607bdd in __asan_loadN_noabort (addr=140737272831420, size=4) at kasan/kasan.c:289
|  #2  0x0000555555607cd7 in __asan_load4_noabort (addr=140737272831420) at kasan/kasan.c:323
|  #3  0x00005555556061ef in gmtime_r (timep=0x7ffff3275dbc, result=0x7ffff3275e10) at time/lib_gmtimer.c:301
|  #4  0x000055555560e507 in sim_rtc_rdtime (lower=0x55555576b780 <g_sim_rtc>, rtctime=0x7ffff3275e10) at sim/up_rtc.c:77
|  #5  0x00005555555fcbdb in up_rtc_gettime (tp=0x7ffff3275ef0) at timers/arch_rtc.c:128
|  #6  0x00005555555f08b4 in clock_systime_timespec (ts=0x7ffff3275ef0) at clock/clock_systime_timespec.c:72
|  #7  0x00005555555ecc77 in note_common (tcb=0x7ffff31d2180, note=0x7ffff3275f80, length=21 '\025', type=18 '\022') at sched/sched_note.c:144
|  #8  0x00005555555ed706 in sched_note_syscall_enter (nr=1, argc=0) at sched/sched_note.c:765
|  #9  0x000055555560eb37 in __wrap_getpid () at wraps/WRAP_getpid.c:26
|  #10 0x0000555555608d1c in mm_takesemaphore (heap=0x7ffff30ae000) at mm_heap/mm_sem.c:127
|  #11 0x0000555555609477 in mm_free (heap=0x7ffff30ae000, mem=0x7ffff3265b80) at mm_heap/mm_free.c:89
|  #12 0x00005555556070c5 in free (mem=0x7ffff3265b80) at umm_heap/umm_free.c:49
|  #13 0x000055555560c3b0 in up_release_stack (dtcb=0x7ffff31e4b00, ttype=0 '\000') at sim/up_releasestack.c:67
|  #14 0x00005555555f2515 in nxsched_release_tcb (tcb=0x7ffff31e4b00, ttype=0 '\000') at sched/sched_releasetcb.c:134
|  #15 0x00005555556bdf0c in nxtask_terminate (pid=4, nonblocking=true) at task/task_terminate.c:184
|  #16 0x00005555556bdb0f in nxtask_exit () at task/task_exit.c:168
|  #17 0x000055555566e05f in up_exit (status=0) at sim/up_exit.c:64
|  #18 0x000055555564f454 in _exit (status=0) at task/exit.c:78
|  #19 0x000055555560ea89 in __wrap__exit (parm1=0) at wraps/WRAP__exit.c:27
|  #20 0x00005555555eb288 in exit (status=0) at stdlib/lib_exit.c:54
|  #21 0x00005555555fe2cc in nxtask_startup (entrypt=0x555555670c34 <critmon_start_main>, argc=1, argv=0x7ffff3265bb0) at sched/task_startup.c:70
|  #22 0x00005555555f02a0 in nxtask_start () at task/task_start.c:134
|  #23 0x0000000000000000 in ?? ()

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-02 01:45:08 +08:00
ligd 419bc2fd04 mm: handle take mm sem in IRQ
This is a fix of:
0169a51220
This is caused by wrong memory sem operation in IDLE.

Fix:
Obey the original design, don't check the IDLE in mm_takesemaphore()

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-02-21 23:41:06 +08:00
chenwei23 39cdd99d77 mm: Support the kernel address sanitizer
Signed-off-by: chenwei23 <chenwei23@xiaomi.com>
2021-11-02 13:32:47 -03:00
Xiang Xiao 5fe51b923a mm: Simplify the semaphore handling
1.Move all special process to mm_takesemaphore
2.Remove the support of recurive lock
3.Remove mm_trysemaphore function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ie216a6294ab67c5d427f31b089beb15c532f08fe
2021-07-10 16:10:32 -03:00
Xiang Xiao 76cdd5c329 mm: Remove mm_heap_impl_s struct
it's more simple to make mm_heap_s opaque outside of mm

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I5c8e435f6baba6d22b10c5f7e8d9191104fb5af2
2021-07-07 04:25:15 -07:00
ligd aa43a0215d mm: fix memory corruption when loop create/exit thread in SMP mode
Root casue:
when do thread exit, need add free stack operation to mm_delaylist,
but in SMP mode, CPU0 thread1 exit, at this time, CPU1 call malloc
and free mm_delaylist.

Fix:
Divide mm_delaylist for per CPU in SMP mode.

Change-Id: Ibf7d04614ea2f99fb5b506356b7346a0d94f0590
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-02 04:55:46 -05:00
mage1 635cfadc25 mm: Move mm_heap_s related stuff to private header file
since it will improve the modularity and reduce the inforamtion explosion

Change-Id: I085b36adb38993a979625a1f4c252d364a15afa1
2021-03-19 09:56:39 -07:00
Alin Jerpelea bcee9c391c mm: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can mograte the licenses
to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Xiang Xiao eca7059785 Refine __KERNEL__ and CONFIG_BUILD_xxx usage in the code base
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-01 10:43:47 -03:00
ligd ef360394c7 mm/mm_heap: fix mm_heap not support BUILD_FLAT
1. change ifdef __KERNEL__ to:
   if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)

2. change mm_delaylist to *mm_delaylist

3. change FAR struct mm_delaynode_s *new to:
   FAR struct mm_delaynode_s *tmp

4. should check mm_trysemaphore() return values

Change-Id: I57ba991f13c3eaf56dc2d71ac946c11669e32dfa
Signed-off-by: ligd <liguiding@fishsemi.com>
2020-04-10 07:49:32 -06:00
ligd cbf31bca5c global change: fix tools/checkpatch.sh warnnings
Change-Id: I88cfa979c44bcaf3a8f6e036c6bfccd3402ca85a
Signed-off-by: ligd <liguiding@fishsemi.com>
2020-04-09 10:29:28 -06:00
ligd 1d2396353e mm/mm_heap: add mm_delaylist to mm_heap_s struct
Change-Id: I2ffaec5557bf2dd2021baa6cda84bb5318425caa
Signed-off-by: ligd <liguiding@fishsemi.com>
2020-04-09 10:29:28 -06:00
YAMAMOTO Takashi 46ad645efc mm: Add a bunch of assertions 2020-02-13 08:21:18 -06:00
Petteri Aimonen fe0532c226 Merged in paimonen/nuttx/pullreq_libc_libnx_updates (pull request #757)
Pullreq libc libnx updates

* NuttX: make strerror() return 'Success' for 0

* NuttX: fix strrchr() so that it considers null terminator as part of string

    From strrchr(3) man page:
    "The terminating null byte is considered part of the string, so that if c
    is specified as '\0', these functions return a pointer to the terminator."

* NuttX: mm_free(): Add DEBUGASSERT()'s to catch memory corruption early.

    It's easier to find the source when asserts fail already when freeing
    an overflowed buffer, than if the corruption is only detected on next
    malloc().

* MM_FILL_ALLOCATIONS: Add debug option to fill all mallocs()

    This is helpful for detecting uninitialized variables,
    especially in C++ code. I seem to be forgetting to initialize
    member variables and then they just get random values..

* NuttX: nxtk_bitmapwindow: Fix warning message when bitmap is fully off-screen.

* nxfonts_getfont: Avoid unnecessary warnings for other whitespace chars also.

* NuttX: Fix kerning of 'I' in Sans17x22 font

    The I character was running together with some other
    characters, e.g. in sequence "IMI".

* NXMU: Revalidate window pointer for mouse events.

    NXMU caches the previous window pointer so that further mouse
    events can be sent to the same window. However, if the window
    is destroyed while mouse button is held down, the pointer may
    become invalid and cause a crash. This patch revalidates the
    pointer before using it.

Approved-by: GregoryN <gnutt@nuttx.org>
2018-11-12 15:36:35 +00:00
Gregory Nutt fc3540cffe Replace all occurrences of vdbg with vinfo 2016-06-11 11:59:51 -06:00
Gregory Nutt b90da3f27b waitpid: CRITICAL BUGFIX. Add a reference counting mechansim to prevent wait from using stale memory that was freed by the exiting task 2015-12-22 11:48:17 -06:00
Gregory Nutt 06cd5b2fcc mm, audio, crypto, graphics: Fix various spacing/alignment issues 2015-10-08 09:10:22 -06:00
Gregory Nutt b33c2d9cef Move include/nuttx/mm.h to include/nuttx/mm/mm.h 2014-09-24 07:29:09 -06:00
Gregory Nutt 3464089542 Move core heap allocator logic from mm/. to mm/mm_heap/. 2014-09-22 10:53:50 -06:00