Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature k210 #16

Merged
merged 5 commits into from Dec 31, 2019
Merged

feature k210 #16

merged 5 commits into from Dec 31, 2019

Conversation

masayuki2009
Copy link
Contributor

Summary

  • Added initial support for Sipeed Maix Bit board with Kendryte K210 processor.
  • K210 has two RV64GC cores but in this PR only the primary core is enabled.

Impact

  • Some common files for RISC-V have been modified to support RV64GC.
  • I also checked this PR with my SparkFun RED-V Plus which has SiFive FE310 core (RV32IMAC)

Limitations / TODO

  • Because this is a initial porting some drivers such as GPIO/I2C/SPI are missing.
  • Also, nuttx (elf file) must be loaded with openocd-k210.

These limitations and TODO are described in README.txt under the board directory.

Testing

  • I confirmed that ostest passed. Also, basic commands such as uname/ps/free/sleep work as well.

include/stdint.h Outdated
typedef _intptr_t intptr_t;
typedef _uintptr_t uintptr_t;
#endif

Copy link
Contributor

@patacongo patacongo Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe that this is a correct change. You should not put any CPU specific definitions in the POSIX standard stdint.h. That is the wrong way to go. It violates the basic layering within the OS.

Instead, you need to change arch/risc-v/include/types.h. That is the appropriate place for this change. arch/risc-v/include/types.h defines _intptr_t and _uintptr_t and is included by include/stdint.h. This was designed this way to specifically to prohibit CPU-specific changes in stdint.h.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patacongo Thanks for the comment. I understand what I should do. I'll fix the commits and force to push again.

@masayuki2009
Copy link
Contributor Author

@patacongo I fixed what you pointed out and pushed again.

@patacongo patacongo changed the base branch from master to dev December 31, 2019 14:53
@patacongo patacongo merged commit fbc046e into apache:dev Dec 31, 2019
patacongo pushed a commit that referenced this pull request Dec 31, 2019
Author: Gregory Nutt <gnutt@nuttx.org>

    Run all .c and .h modified in PR through nxstyle.

Author: Masayuki Ishikawa <masayuki.ishikawa@gmail.com>

    feature k210 (#16)

    * arch: risc-v: Add support for __LP64__ to types.h
    * arch: risc-v: Add support for RV64GC to common files
    * arch: risc-v: Add support for Kendryte K210 processor (RV64GC)
    * boards: risk-v: Add support for Sipeed Maix Bit with K210
    * tools: Add support for Kendryte K210 processor
xiaoxiang781216 referenced this pull request in xiaoxiang781216/incubator-nuttx Dec 31, 2019
Author: Gregory Nutt <gnutt@nuttx.org>

    Run all .c and .h modified in PR through nxstyle.

Author: Masayuki Ishikawa <masayuki.ishikawa@gmail.com>

    feature k210 (#16)

    * arch: risc-v: Add support for __LP64__ to types.h
    * arch: risc-v: Add support for RV64GC to common files
    * arch: risc-v: Add support for Kendryte K210 processor (RV64GC)
    * boards: risk-v: Add support for Sipeed Maix Bit with K210
    * tools: Add support for Kendryte K210 processor
@masayuki2009 masayuki2009 deleted the feature_k210 branch March 20, 2020 01:07
anchao added a commit to anchao/nuttx that referenced this pull request Jun 15, 2020
ASAN trace:
...
==32087==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4502120 at pc 0x56673ca3 bp 0xff9b6a08 sp 0xff9b69f8
WRITE of size 1 at 0xf4502120 thread T0
    #0 0x56673ca2 in strcpy string/lib_strcpy.c:64

0xf4502120 is located 0 bytes to the right of 8224-byte region [0xf4500100,0xf4502120)
allocated by thread T0 here:
    #0 0xf7a60f54 in malloc (/usr/lib32/libasan.so.4+0xe5f54)
    #1 0x5667725d in up_create_stack sim/up_createstack.c:135
    #2 0x56657ed8 in nxthread_create task/task_create.c:125
    #3 0x566580bb in kthread_create task/task_create.c:297
    #4 0x5665935f in work_start_highpri wqueue/kwork_hpthread.c:149
    #5 0x56656f31 in nx_workqueues init/nx_bringup.c:181
    #6 0x56656fc6 in nx_bringup init/nx_bringup.c:436
    apache#7 0x56656e95 in nx_start init/nx_start.c:809
    apache#8 0x566548d4 in main sim/up_head.c:95
    apache#9 0xf763ae80 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x18e80)

CALLSTACK:
    apache#8  0xf79de7a5 in __asan_report_store1 () from /usr/lib32/libasan.so.4
    apache#9  0x565fd4d7 in strcpy (dest=0xf4a02121 "", src=0xf5c00895 "k") at string/lib_strcpy.c:64
    apache#10 0x565e4eb2 in nxtask_setup_stackargs (tcb=0xf5c00810, argv=0x0) at task/task_setup.c:570
    apache#11 0x565e50ff in nxtask_setup_arguments (tcb=0xf5c00810, name=0x5679e580 "hpwork", argv=0x0) at task/task_setup.c:714
    apache#12 0x565e414e in nxthread_create (name=0x5679e580 "hpwork", ttype=2 '\002', priority=224, stack=0x0, stack_size=8192, entry=0x565e54e1 <work_hpthread>, argv=0x0) at task/task_create.c:143
    apache#13 0x565e42e3 in kthread_create (name=0x5679e580 "hpwork", priority=224, stack_size=8192, entry=0x565e54e1 <work_hpthread>, argv=0x0) at task/task_create.c:297
    apache#14 0x565e5557 in work_start_highpri () at wqueue/kwork_hpthread.c:149
    apache#15 0x565e3e32 in nx_workqueues () at init/nx_bringup.c:181
    apache#16 0x565e3ec7 in nx_bringup () at init/nx_bringup.c:436
    apache#17 0x565e3d96 in nx_start () at init/nx_start.c:809
    apache#18 0x565e3195 in main (argc=1, argv=0xffe6b954, envp=0xffe6b95c) at sim/up_head.c:95

Change-Id: I096f7952aae67d055daa737e967242eb217ef8ac
Signed-off-by: chao.an <anchao@xiaomi.com>
patacongo pushed a commit that referenced this pull request Jun 15, 2020
ASAN trace:
...
==32087==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4502120 at pc 0x56673ca3 bp 0xff9b6a08 sp 0xff9b69f8
WRITE of size 1 at 0xf4502120 thread T0
    #0 0x56673ca2 in strcpy string/lib_strcpy.c:64

0xf4502120 is located 0 bytes to the right of 8224-byte region [0xf4500100,0xf4502120)
allocated by thread T0 here:
    #0 0xf7a60f54 in malloc (/usr/lib32/libasan.so.4+0xe5f54)
    #1 0x5667725d in up_create_stack sim/up_createstack.c:135
    #2 0x56657ed8 in nxthread_create task/task_create.c:125
    #3 0x566580bb in kthread_create task/task_create.c:297
    #4 0x5665935f in work_start_highpri wqueue/kwork_hpthread.c:149
    #5 0x56656f31 in nx_workqueues init/nx_bringup.c:181
    #6 0x56656fc6 in nx_bringup init/nx_bringup.c:436
    #7 0x56656e95 in nx_start init/nx_start.c:809
    #8 0x566548d4 in main sim/up_head.c:95
    #9 0xf763ae80 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x18e80)

CALLSTACK:
    #8  0xf79de7a5 in __asan_report_store1 () from /usr/lib32/libasan.so.4
    #9  0x565fd4d7 in strcpy (dest=0xf4a02121 "", src=0xf5c00895 "k") at string/lib_strcpy.c:64
    #10 0x565e4eb2 in nxtask_setup_stackargs (tcb=0xf5c00810, argv=0x0) at task/task_setup.c:570
    #11 0x565e50ff in nxtask_setup_arguments (tcb=0xf5c00810, name=0x5679e580 "hpwork", argv=0x0) at task/task_setup.c:714
    #12 0x565e414e in nxthread_create (name=0x5679e580 "hpwork", ttype=2 '\002', priority=224, stack=0x0, stack_size=8192, entry=0x565e54e1 <work_hpthread>, argv=0x0) at task/task_create.c:143
    #13 0x565e42e3 in kthread_create (name=0x5679e580 "hpwork", priority=224, stack_size=8192, entry=0x565e54e1 <work_hpthread>, argv=0x0) at task/task_create.c:297
    #14 0x565e5557 in work_start_highpri () at wqueue/kwork_hpthread.c:149
    #15 0x565e3e32 in nx_workqueues () at init/nx_bringup.c:181
    #16 0x565e3ec7 in nx_bringup () at init/nx_bringup.c:436
    #17 0x565e3d96 in nx_start () at init/nx_start.c:809
    #18 0x565e3195 in main (argc=1, argv=0xffe6b954, envp=0xffe6b95c) at sim/up_head.c:95

Change-Id: I096f7952aae67d055daa737e967242eb217ef8ac
Signed-off-by: chao.an <anchao@xiaomi.com>
donghengqaz pushed a commit to donghengqaz/incubator-nuttx that referenced this pull request Jul 20, 2020
…nnerat-images-devkit

Feature/sdc integration generation images for devkit
anchao added a commit to anchao/nuttx that referenced this pull request Dec 14, 2020
Deadlock during recursive access if unionfs overlays procfs,
check the critical segment only and remove the useless protection part.

|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
...
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026

original call stack:
(gdb) bt
|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
|#1  0x08071629 in mountpoint_filter (node=0xf3df4540, dirpath=0xf3df4a28 "/proc", arg=0xf3de2fc4) at mount/fs_foreachmountpoint.c:119
|#2  0x0807171b in foreach_inodelevel (node=0xf3df4540, info=0xf3df4a20) at inode/fs_foreachinode.c:90
|#3  0x08071898 in foreach_inode (handler=0x8071530 <mountpoint_filter>, arg=0xf3de2fc4) at inode/fs_foreachinode.c:193
|#4  0x080716c1 in foreach_mountpoint (handler=0x8070e2f <blocks_entry>, arg=0xf3de300c) at mount/fs_foreachmountpoint.c:169
|#5  0x08071399 in mount_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at mount/fs_procfs_mount.c:537
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026
|apache#8  0x080657a2 in file_read (filep=0xf3de219c, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:110
|apache#9  0x0806581a in nx_read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:175
|apache#10 0x08065847 in read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:206
|apache#11 0x0805a242 in nsh_catfile (vtbl=0xf3df3f10, cmd=0xf3df4378 "df", filepath=0x808d5ed "/proc/fs/blocks") at nsh_fsutils.c:116
|apache#12 0x0805b1de in cmd_df (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_mntcmds.c:73
|apache#13 0x08056370 in nsh_command (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_command.c:1061
|apache#14 0x08053b16 in nsh_execute (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0, redirfile=0x0, oflags=0) at nsh_parse.c:741
|apache#15 0x08055998 in nsh_parse_command (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2578
|apache#16 0x08055a7b in nsh_parse (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2662
|apache#17 0x0805d691 in nsh_session (pstate=0xf3df3f10, login=1 '\001', argc=1, argv=0xf3de34b0) at nsh_session.c:191
|apache#18 0x0805b542 in nsh_consolemain (argc=1, argv=0xf3de34b0) at nsh_consolemain.c:115
|apache#19 0x0805346c in nsh_main (argc=1, argv=0xf3de34b0) at nsh_main.c:168
|apache#20 0x0805075a in nxtask_startup (entrypt=0x805340a <nsh_main>, argc=1, argv=0xf3de34b0) at sched/task_startup.c:165
|apache#21 0x08049713 in nxtask_start () at task/task_start.c:144
|apache#22 0x00000000 in ?? ()

Change-Id: Ic4c7aff0ea50388a371c525745e817a787dabcca
Signed-off-by: chao.an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Dec 14, 2020
Deadlock during recursive access if unionfs overlays procfs,
check the critical segment only and remove the useless protection part.

|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
...
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026

original call stack:
(gdb) bt
|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
|#1  0x08071629 in mountpoint_filter (node=0xf3df4540, dirpath=0xf3df4a28 "/proc", arg=0xf3de2fc4) at mount/fs_foreachmountpoint.c:119
|#2  0x0807171b in foreach_inodelevel (node=0xf3df4540, info=0xf3df4a20) at inode/fs_foreachinode.c:90
|#3  0x08071898 in foreach_inode (handler=0x8071530 <mountpoint_filter>, arg=0xf3de2fc4) at inode/fs_foreachinode.c:193
|#4  0x080716c1 in foreach_mountpoint (handler=0x8070e2f <blocks_entry>, arg=0xf3de300c) at mount/fs_foreachmountpoint.c:169
|#5  0x08071399 in mount_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at mount/fs_procfs_mount.c:537
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026
|apache#8  0x080657a2 in file_read (filep=0xf3de219c, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:110
|apache#9  0x0806581a in nx_read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:175
|apache#10 0x08065847 in read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:206
|apache#11 0x0805a242 in nsh_catfile (vtbl=0xf3df3f10, cmd=0xf3df4378 "df", filepath=0x808d5ed "/proc/fs/blocks") at nsh_fsutils.c:116
|apache#12 0x0805b1de in cmd_df (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_mntcmds.c:73
|apache#13 0x08056370 in nsh_command (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_command.c:1061
|apache#14 0x08053b16 in nsh_execute (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0, redirfile=0x0, oflags=0) at nsh_parse.c:741
|apache#15 0x08055998 in nsh_parse_command (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2578
|apache#16 0x08055a7b in nsh_parse (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2662
|apache#17 0x0805d691 in nsh_session (pstate=0xf3df3f10, login=1 '\001', argc=1, argv=0xf3de34b0) at nsh_session.c:191
|apache#18 0x0805b542 in nsh_consolemain (argc=1, argv=0xf3de34b0) at nsh_consolemain.c:115
|apache#19 0x0805346c in nsh_main (argc=1, argv=0xf3de34b0) at nsh_main.c:168
|apache#20 0x0805075a in nxtask_startup (entrypt=0x805340a <nsh_main>, argc=1, argv=0xf3de34b0) at sched/task_startup.c:165
|apache#21 0x08049713 in nxtask_start () at task/task_start.c:144
|apache#22 0x00000000 in ?? ()

Change-Id: Ic4c7aff0ea50388a371c525745e817a787dabcca
Signed-off-by: chao.an <anchao@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Dec 15, 2020
Deadlock during recursive access if unionfs overlays procfs,
check the critical segment only and remove the useless protection part.

|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
...
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026

original call stack:
(gdb) bt
|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
|#1  0x08071629 in mountpoint_filter (node=0xf3df4540, dirpath=0xf3df4a28 "/proc", arg=0xf3de2fc4) at mount/fs_foreachmountpoint.c:119
|#2  0x0807171b in foreach_inodelevel (node=0xf3df4540, info=0xf3df4a20) at inode/fs_foreachinode.c:90
|#3  0x08071898 in foreach_inode (handler=0x8071530 <mountpoint_filter>, arg=0xf3de2fc4) at inode/fs_foreachinode.c:193
|#4  0x080716c1 in foreach_mountpoint (handler=0x8070e2f <blocks_entry>, arg=0xf3de300c) at mount/fs_foreachmountpoint.c:169
|#5  0x08071399 in mount_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at mount/fs_procfs_mount.c:537
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026
|#8  0x080657a2 in file_read (filep=0xf3de219c, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:110
|#9  0x0806581a in nx_read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:175
|#10 0x08065847 in read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:206
|#11 0x0805a242 in nsh_catfile (vtbl=0xf3df3f10, cmd=0xf3df4378 "df", filepath=0x808d5ed "/proc/fs/blocks") at nsh_fsutils.c:116
|#12 0x0805b1de in cmd_df (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_mntcmds.c:73
|#13 0x08056370 in nsh_command (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_command.c:1061
|#14 0x08053b16 in nsh_execute (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0, redirfile=0x0, oflags=0) at nsh_parse.c:741
|#15 0x08055998 in nsh_parse_command (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2578
|#16 0x08055a7b in nsh_parse (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2662
|#17 0x0805d691 in nsh_session (pstate=0xf3df3f10, login=1 '\001', argc=1, argv=0xf3de34b0) at nsh_session.c:191
|#18 0x0805b542 in nsh_consolemain (argc=1, argv=0xf3de34b0) at nsh_consolemain.c:115
|#19 0x0805346c in nsh_main (argc=1, argv=0xf3de34b0) at nsh_main.c:168
|#20 0x0805075a in nxtask_startup (entrypt=0x805340a <nsh_main>, argc=1, argv=0xf3de34b0) at sched/task_startup.c:165
|#21 0x08049713 in nxtask_start () at task/task_start.c:144
|#22 0x00000000 in ?? ()

Change-Id: Ic4c7aff0ea50388a371c525745e817a787dabcca
Signed-off-by: chao.an <anchao@xiaomi.com>
GUIDINGLI added a commit to GUIDINGLI/incubator-nuttx that referenced this pull request Mar 25, 2022
VELAPLATFO-1942

-apache#9  0xf7abf899 in __asan::__asan_report_load2 (addr=4072681776) at ../../../../../src/libsanitizer/asan/asan_rtl.cc:117
-apache#10 0x5693f718 in inode_release (node=0xf2c03124) at inode/fs_inoderelease.c:69
-apache#11 0x568ea61b in file_close (filep=0xf55fedd0) at vfs/fs_close.c:79
-apache#12 0x568e7e56 in nx_close (fd=3) at inode/fs_files.c:528
-apache#13 0x568e7f0e in close (fd=3) at inode/fs_files.c:562
-apache#14 0x56e76c39 in epoll_close (epfd=3) at vfs/fs_epoll.c:252
-apache#15 0x56c33829 in sensor_service_delete (ctrl=0x578b8540 <control>) at src/common.c:439
-apache#16 0x56a0561e in sensor_middle_service_main (argc=1, argv=0xf55de820) at sensor_main.c:118
-apache#17 0x56878675 in nxtask_startup (entrypt=0x56a054cc <sensor_middle_service_main>, argc=1, argv=0xf55de820) at sched/task_startup.c:70
-apache#18 0x5684427a in nxtask_start () at task/task_start.c:133
-apache#19 0xdeadbeef in ?? ()

reason:
epoll_close -> close -> epoll_do_close (free inode)
                     -> inode_release  (reuse inode, crash)

fix:
use the global inode to match the fd which will return to user.
like the g_sock_inode in fs/socket/socket.c

Change-Id: I0096ac691ce9cf4169d1fb8bfa6d27a8c1ee7d52
Signed-off-by: ligd <liguiding1@xiaomi.com>
GUIDINGLI added a commit to GUIDINGLI/incubator-nuttx that referenced this pull request Mar 25, 2022
-apache#9  0xf7abf899 in __asan::__asan_report_load2 (addr=4072681776) at ../../../../../src/libsanitizer/asan/asan_rtl.cc:117
-apache#10 0x5693f718 in inode_release (node=0xf2c03124) at inode/fs_inoderelease.c:69
-apache#11 0x568ea61b in file_close (filep=0xf55fedd0) at vfs/fs_close.c:79
-apache#12 0x568e7e56 in nx_close (fd=3) at inode/fs_files.c:528
-apache#13 0x568e7f0e in close (fd=3) at inode/fs_files.c:562
-apache#14 0x56e76c39 in epoll_close (epfd=3) at vfs/fs_epoll.c:252
-apache#15 0x56c33829 in sensor_service_delete (ctrl=0x578b8540 <control>) at src/common.c:439
-apache#16 0x56a0561e in sensor_middle_service_main (argc=1, argv=0xf55de820) at sensor_main.c:118
-apache#17 0x56878675 in nxtask_startup (entrypt=0x56a054cc <sensor_middle_service_main>, argc=1, argv=0xf55de820) at sched/task_startup.c:70
-apache#18 0x5684427a in nxtask_start () at task/task_start.c:133
-apache#19 0xdeadbeef in ?? ()

reason:
epoll_close -> close -> epoll_do_close (free inode)
                     -> inode_release  (reuse inode, crash)

fix:
use the global inode to match the fd which will return to user.
like the g_sock_inode in fs/socket/socket.c

Signed-off-by: ligd <liguiding1@xiaomi.com>
pkarashchenko pushed a commit that referenced this pull request Mar 27, 2022
-#9  0xf7abf899 in __asan::__asan_report_load2 (addr=4072681776) at ../../../../../src/libsanitizer/asan/asan_rtl.cc:117
-#10 0x5693f718 in inode_release (node=0xf2c03124) at inode/fs_inoderelease.c:69
-#11 0x568ea61b in file_close (filep=0xf55fedd0) at vfs/fs_close.c:79
-#12 0x568e7e56 in nx_close (fd=3) at inode/fs_files.c:528
-#13 0x568e7f0e in close (fd=3) at inode/fs_files.c:562
-#14 0x56e76c39 in epoll_close (epfd=3) at vfs/fs_epoll.c:252
-#15 0x56c33829 in sensor_service_delete (ctrl=0x578b8540 <control>) at src/common.c:439
-#16 0x56a0561e in sensor_middle_service_main (argc=1, argv=0xf55de820) at sensor_main.c:118
-#17 0x56878675 in nxtask_startup (entrypt=0x56a054cc <sensor_middle_service_main>, argc=1, argv=0xf55de820) at sched/task_startup.c:70
-#18 0x5684427a in nxtask_start () at task/task_start.c:133
-#19 0xdeadbeef in ?? ()

reason:
epoll_close -> close -> epoll_do_close (free inode)
                     -> inode_release  (reuse inode, crash)

fix:
use the global inode to match the fd which will return to user.
like the g_sock_inode in fs/socket/socket.c

Signed-off-by: ligd <liguiding1@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Apr 12, 2022
The different optimization of compilers will cause ambiguity in
obtaining sp through up_getsp() in arm_stack_color(), if compile
with clang and enable the optimization flag (-Ofast), up_getsp()
call will be earlier than push {r0-r9,lr}, the end address of color
stack will overlap with saved registers.

Compile line:
clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \
-mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o  arm_checkstack.o

Assembler code:
llvm-objdump -aS arm_checkstack.o
------------------------------------
|00000000 <arm_stack_color>:
|;   start = INT32_ALIGN_UP((uintptr_t)stackbase);
|       0: c2 1c         adds  r2, r0, #3
|       2: 22 f0 03 02   bic r2, r2, #3
|;   end   = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) :
|       6: 19 b1         cbz r1, 0x10 <arm_stack_color+0x10> @ imm = #6
|       8: 08 44         add r0, r1
|       a: 20 f0 03 00   bic r0, r0, #3
|       e: 00 e0         b 0x12 <arm_stack_color+0x12> @ imm = #0
|;   __asm__
|      10: 68 46         mov r0, sp                               <--- fetch the sp before push {r7 lr}
|      12: 80 b5         push  {r7, lr}                           <--- sp changed
|;   nwords = (end - start) >> 2;
|      14: 80 1a         subs  r0, r0, r2
|      16: 80 08         lsrs  r0, r0, #2
|; }
|      18: 08 bf         it  eq
|      1a: 80 bd         popeq {r7, pc}
|      1c: 4b f6 ef 63   movw  r3, #48879
|      20: cd f6 ad 63   movt  r3, #57005
|      24: a0 ee 10 3b   vdup.32 q0, r3
|;   while (nwords-- > 0)
|      28: 20 f0 01 e0   dlstp.32  lr, r0
|;       *ptr++ = STACK_COLOR;
|      2c: a2 ec 04 1f   vstrw.32  q0, [r2], apache#16
|      30: 1f f0 05 c0   letp  lr, 0x2c <arm_stack_color+0x2c> @ imm = #-8
|; }
|      34: 80 bd         pop {r7, pc}
------------------------------------

Signed-off-by: chao.an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Apr 12, 2022
The different optimization of compilers will cause ambiguity in
obtaining sp through up_getsp() in arm_stack_color(), if compile
with clang and enable the optimization flag (-Ofast), up_getsp()
call will be earlier than push {r0-r9,lr}, the end address of color
stack will overlap with saved registers.

Compile line:
clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \
-mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o  arm_checkstack.o

Assembler code:
llvm-objdump -aS arm_checkstack.o
------------------------------------
|00000000 <arm_stack_color>:
|;   start = INT32_ALIGN_UP((uintptr_t)stackbase);
|       0: c2 1c         adds  r2, r0, #3
|       2: 22 f0 03 02   bic r2, r2, #3
|;   end   = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) :
|       6: 19 b1         cbz r1, 0x10 <arm_stack_color+0x10> @ imm = #6
|       8: 08 44         add r0, r1
|       a: 20 f0 03 00   bic r0, r0, #3
|       e: 00 e0         b 0x12 <arm_stack_color+0x12> @ imm = #0
|;   __asm__
|      10: 68 46         mov r0, sp                               <--- fetch the sp before push {r7 lr}
|      12: 80 b5         push  {r7, lr}                           <--- sp changed
|;   nwords = (end - start) >> 2;
|      14: 80 1a         subs  r0, r0, r2
|      16: 80 08         lsrs  r0, r0, #2
|; }
|      18: 08 bf         it  eq
|      1a: 80 bd         popeq {r7, pc}
|      1c: 4b f6 ef 63   movw  r3, #48879
|      20: cd f6 ad 63   movt  r3, #57005
|      24: a0 ee 10 3b   vdup.32 q0, r3
|;   while (nwords-- > 0)
|      28: 20 f0 01 e0   dlstp.32  lr, r0
|;       *ptr++ = STACK_COLOR;                                    <--- overwrite
|      2c: a2 ec 04 1f   vstrw.32  q0, [r2], apache#16
|      30: 1f f0 05 c0   letp  lr, 0x2c <arm_stack_color+0x2c> @ imm = #-8
|; }
|      34: 80 bd         pop {r7, pc}
------------------------------------

Signed-off-by: chao.an <anchao@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Apr 13, 2022
The different optimization of compilers will cause ambiguity in
obtaining sp through up_getsp() in arm_stack_color(), if compile
with clang and enable the optimization flag (-Ofast), up_getsp()
call will be earlier than push {r0-r9,lr}, the end address of color
stack will overlap with saved registers.

Compile line:
clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \
-mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o  arm_checkstack.o

Assembler code:
llvm-objdump -aS arm_checkstack.o
------------------------------------
|00000000 <arm_stack_color>:
|;   start = INT32_ALIGN_UP((uintptr_t)stackbase);
|       0: c2 1c         adds  r2, r0, #3
|       2: 22 f0 03 02   bic r2, r2, #3
|;   end   = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) :
|       6: 19 b1         cbz r1, 0x10 <arm_stack_color+0x10> @ imm = #6
|       8: 08 44         add r0, r1
|       a: 20 f0 03 00   bic r0, r0, #3
|       e: 00 e0         b 0x12 <arm_stack_color+0x12> @ imm = #0
|;   __asm__
|      10: 68 46         mov r0, sp                               <--- fetch the sp before push {r7 lr}
|      12: 80 b5         push  {r7, lr}                           <--- sp changed
|;   nwords = (end - start) >> 2;
|      14: 80 1a         subs  r0, r0, r2
|      16: 80 08         lsrs  r0, r0, #2
|; }
|      18: 08 bf         it  eq
|      1a: 80 bd         popeq {r7, pc}
|      1c: 4b f6 ef 63   movw  r3, #48879
|      20: cd f6 ad 63   movt  r3, #57005
|      24: a0 ee 10 3b   vdup.32 q0, r3
|;   while (nwords-- > 0)
|      28: 20 f0 01 e0   dlstp.32  lr, r0
|;       *ptr++ = STACK_COLOR;                                    <--- overwrite
|      2c: a2 ec 04 1f   vstrw.32  q0, [r2], #16
|      30: 1f f0 05 c0   letp  lr, 0x2c <arm_stack_color+0x2c> @ imm = #-8
|; }
|      34: 80 bd         pop {r7, pc}
------------------------------------

Signed-off-by: chao.an <anchao@xiaomi.com>
SimonFilgis referenced this pull request in SimonFilgis/incubator-nuttx May 3, 2022
Signed-off-by: 田昕 <tianxin7@xiaomi.com>

workqueue: add work_foreach support

Signed-off-by: ligd <liguiding1@xiaomi.com>

arch/risc-v: Rename up_fpuconfig to riscv_fpuconfig

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Use riscv_fpuconfig to enable FPU

Use common function instead of chip specified code.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

riscv/bl602: Implement SPI Cmd/Data

To control the Data/Command Pin on ST7789 SPI Display, the SPI Driver flips the MISO Pin as though it was a GPIO.

To implement this on BL602, we reconfigure MISO from SPI Pin to GPIO Pin on the fly inside `bl602_spi_cmddata()`.

When the SPI Port is deselected (after the SPI operation), we revert MISO back from GPIO Pin to SPI Pin. We implement this inside `bl602_spi_select()`.

[More Details Here](https://github.com/lupyuen/st7789-nuttx#spi-cmddata)

This change impacts 3 LCD drivers that call `SPI_CMDDATA()`: ST7735, ST7789, GC9A01.

Previously the BL602 SPI Driver would fail with "SPI cmddata not supported" when the above drivers are used.

After the change, the above drivers will set the LCD Data/Command Pin correctly.

We tested this implementation of SPI Cmd/Data with NuttX ST7789 Driver and a Logic Analyser on PineCone BL602:

-   [Testing with Logic Analyser](https://github.com/lupyuen/st7789-nuttx#spi-cmddata)

We also tested LVGL with ST7789 on PineCone BL602:

-   [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo)

As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602:

-   [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-29)

arch/risc-v/litex: add cache_invalidate

driver/mmcsd: add option to support SD/MMC PHYs that only run in 4-bit mode

arch/risc-v/src/litex/litex_sdio: add litesdcard peripheral driver

See the following for details on the pepheral:
https://github.com/enjoy-digital/litesdcard

boards/risc-v/litex/arty_a7: add SDCARD support for the Arty_A7 board

boards/risc-v/litex/arty_a7: update README to include building in LITESDCARD peripheral

opendir: use inode_find() instead when opendir()

Signed-off-by: ligd <liguiding1@xiaomi.com>

arm/cortex-[a|r]: IRQ Switch return should with shadow SPSR

The SPSR is used to store the current value of the CPSR when an exception
is taken so that it can be restored after handling the exception.
Each exception handling mode can access its own SPSR.

User mode and System mode do not have an SPSR because they are not
exception handling modes.

Signed-off-by: chao.an <anchao@xiaomi.com>

signal: Don't do schedule_sigaction when there is no action

Signed-off-by: ligd <liguiding1@xiaomi.com>

task: don't set default signal in kernal thread

Signed-off-by: ligd <liguiding1@xiaomi.com>

riscv/bl602: Remove check for LCD driver

`bl602_spi_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: https://github.com/apache/incubator-nuttx/pull/5898

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

We tested with LVGL and ST7789 on PineCone BL602:

-   [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo)

As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602:

-   [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-30)

riscv/esp32c3: Remove check for LCD driver

`esp32c3_spi2_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: https://github.com/apache/incubator-nuttx/pull/5898

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

This is a minor patch so no testing is needed.

xtensa: Move XCHAL_SWINT_CALL definition into syscall header

This is required to avoid the interface header (syscall.h) depending on
the xtensa_swi.h header from the implementation

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

xtensa: Build OS-assisted atomic operations on ESP32-S2

ESP32-S2 lacks support for conditional load/store instructions.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

risc-v/esp32c3: Fix inclusion of C++ constructors/destructors table

RISC-V GCC is configured with --enable-initfini-array so it emits an
.init_array section instead of .ctors

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

xtensa|risc-v: Make CXX exception and RTTI depend on Kconfig options

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

libcxx: Add patch for preventing redefinition of PS macro on Xtensa

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

libcxx: Fix libc++ for archs without conditional load/store support

This commit brings a patch already merged to upstream LLVM project:
https://reviews.llvm.org/D118391

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

esp32[s2/s3/c3]: Add defconfigs for testing C++

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

arch/arm: Make CXX exception and RTTI depend on Kconfig options

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

documentation: Add release notes for 10.3.0 release

This is a local copy taken from the confluence notes
https://cwiki.apache.org/confluence/display/NUTTX/NuttX+10.3

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

fs/romfs: fix bug about compare path with same prefix

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

boards/boardctl:common boardctl to read reset cause.

Signed-off-by: 田昕 <tianxin7@xiaomi.com>

rptun: set rptun thread default stack size to 4K

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rptun_force_panic support

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rptun_reset support

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: use HPWORK instead of thread

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rptun_panic for both master & salve

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rpmsg_wait/post support for recursive dispatch

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: divide shram to TX & RX

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rptun dump support

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: pm_stay when send msg & pm_relax when all tx buffer returned

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: enable rx interrupts for virtq

use wait_tx_buffer method need enable rx interrupts

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add ping rpmsg support

Signed-off-by: ligd <liguiding1@xiaomi.com>

openamp: add openamp patches

0006-openamp-fix-scenario-case.patch
0007-openamp-divide-shram-to-TX-shram-RX-shram.patch
0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: forward panic/reset to lowerhalf

Signed-off-by: ligd <liguiding1@xiaomi.com>

remove DISCLAIMER-WIP

most licenses have been converted to Apache and the non Apache
licenses have been documented.
We can assume that now it should be the time to remove DISCLAIMER-WIP

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch/risc-v/mpfs: Remove duplicated riscv_restorefpu

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

ioe_rpmsg: use rptun_wait/post to resolve deadlock with usrsock

Signed-off-by: ligd <liguiding1@xiaomi.com>

arch/risc-v: Store/Restore FPU register in exception_common

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Rename up_doirq to riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Remove deprecated logic from riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Merge duplicated logic by riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Dont' disable/enable irq in riscv_doirq

Since these codes added to all chips but not fully tested,
so we should changd this behavior.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Remove unneeded group_addrenv call which handled by riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: move REGLOAD/REGSTORE macro to riscv_internal.h

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/risc-v: include csr.h indirectly through nuttx/irq.h

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/risc-v: fix ARCH_RV32 offset for the stub lookup table calculation

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

mm/mm_heap: place alloc-bit at the LSB of node->preceeding.

Heap always allocate the memory at least 2bytes alignment.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

mm_heap: heapsize align with MM_MIN_CHUNK.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

driver/syslog: Add microseconds after date time

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

ARCH_ADDRENV: Add guard against mis-configuration

When process a is switched to process b, the address environment is
swapped with a call to group_addrenv(). The stack upon entry will be
a's, and upon exit b's. This will fail, so a neutral stack is required,
either a kernel stack or an IRQ stack.

Infrastructure for an IRQ stack is already in place, so give a hint
that an interrupt stack should be provided if address environments
are enabled.

arch/risc-v: get wider visibility for arch instruction macros

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

rpmsgfs: add wait ready to rpmsgfs

Signed-off-by: ligd <liguiding1@xiaomi.com>

rpmsgfs: add timeout when mount in rpmsgfs

Signed-off-by: ligd <liguiding1@xiaomi.com>

rpmsgfs: use rptun_wait/post to resolve deadlock with usrsock

Signed-off-by: ligd <liguiding1@xiaomi.com>

sigact: get free sigact from freelist always successful

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

netdev_file_ioctl: Fix fcntl F_SETFL O_NONBLOCK regression

This fixes a regression caused by the following commit,
which prevents the file flag from being updated.

```
commit 28860b5242dd5efd86b5da8a089e5d898cd8a9a1
Author: chao.an <anchao@xiaomi.com>
Date:   Sat Mar 19 14:47:37 2022 +0800

    net/netdev: fix switch case missing break

    Signed-off-by: chao.an <anchao@xiaomi.com>
```

Note: some applications like mbedtls uses F_GETFL to confirm
the nonblock-ness of the socket. This is critical for such
applications.

nuttx: Add "#include <nuttx/fs/ioctl.h>" to tioctl.h

Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>

fs/unionfs: fix bug about use after free about ui

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/unionfs: check return value to avoid unused value

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/unionfs: add sanity check for parameter

if relpath is NULL, it will cause system crash:
unionfs_opendir with relpath NULL
    ->	unionfs_tryopendir
	    ->	unionfs_offsetpath
		->  strncmp(prefix, relpath, pfxlen

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

SEGGER_RTT: solve compile error when enable segger rtt in armv7m.

1. SEGGER_RTT_ASM_ARMv7M include SEGGER_RTT.h, and SEGGER_RTT.h
include SEGGER_RTT_Conf.h, so add __ASSEMBLY__ in
SEGGER_RTT_Conf.h;
2. AFLAG add segger/config because SEGGER_RTT_ASM_ARMv7M.S
include SEGGER_RTT_Conf.h;

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

fs/procfstcbinfo: minor bug about print address

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/romfs: fix string overflow when the length of rn_name exceeds NAME_MAX + 1

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs and unistd: increase OPEN_MAX by claiming a Kconfig.

Signed-off-by: 田昕 <tianxin7@xiaomi.com>

rpmsgfs: do NOT access the pointer when do remote ioctl

Signed-off-by: ligd <liguiding1@xiaomi.com>

fs/rpmsgfs: fix bug about using uninit variable "times"

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

arch/xtensa: add syscall note support in the flat build

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/note: unify the data format

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/trace: correct the note print format

note print should with Instruction pointer.

e.g:

        trace_printk("hello NuttX");

trace dump:

hello-6  [000] .... 23080.367994: 0xc044a005: hello NuttX

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/note: add support of trace section mark

The implementation of this feature is based on android systrace:

https://source.android.com/devices/tech/debug/ftrace

Application developers are more concerned about the performance of
the specified application section,
added two APIs to implement performance measurement:

void sched_note_begin(uintptr_t ip, FAR const char *buf);
void sched_note_end(uintptr_t ip, FAR const char *buf);
or
SCHED_NOTE_BEGIN();  /* defined to sched_note_begin(_THIS_IP_, __FUNCTION__) */
SCHED_NOTE_END();    /* defined to sched_note_end(_THIS_IP_, __FUNCTION__) */

Signed-off-by: chao.an <anchao@xiaomi.com>

unistd:rename CONFIG_OPEN_MAX to CONFIG_LIBC_OPEN_MAX

Signed-off-by: 田昕 <tianxin7@xiaomi.com>

sim: Fix init of static C++ constructors when using glibc >= 2.34

glibc 2.34 changed the dynamic linker behavior during the startup
process, which makes the previous "__init_array_start" replacement trick
non-effective.
Now the dynamic linker parses the constructors/destructors information
from the DYNAMIC segment of the program.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

libs/libc/lib_err.c:add va_end to vwarn

call va_copy,after need call va_end
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

local socket: cancel assert about backlog exceed 255

Signed-off-by: zhanghu6 <zhanghu6@xiaomi.com>

net/local: change 255 to UINT8_MAX

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

power: unify lock states

unify critical_section and nxsem with pm_lock/pm_unlock

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

power:driver: move pm_auto_update to outer dir

Pm_auto_update maybe called by outter PM users

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

lib_chdir:use change ret judgment method

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

modlib/modlib_bind:fix unsigned_compare with zero

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

Update libs/libc/modlib/modlib_bind.c

u are right

Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>

Update libs/libc/modlib/modlib_bind.c

Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>

mmcsd: Add gotextcsd callback to sdio_dev_s

so the driver implementation could get critical EXTCSD info

Signed-off-by: anjianjun <anjianjun@xiaomi.com>

mmcsd: Move SDIO_GOTEXTCSD after SDIO_DMASENDSETUP

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

mmcsd: Fix mmc card error but system can not catch it

Signed-off-by: anjianjun <anjianjun@xiaomi.com>

risc-v/esp32c3: Fix regression on IRQ handling for ECALL instruction

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

RISC-V: Implement option to run NuttX in supervisor mode (S-mode)

- Add config "ARCH_USE_S_MODE" which controls whether the kernel
  runs in M-mode or S-mode
- Add more MSTATUS and most of the SSTATUS register definitions
- Add more MIP flags for interrupt delegation
- Add handling of interrupts from S-mode
- Add handling of FPU from S-mode
- Add new context handling functions that are not dependent on the trap
  handlers / ecall

NOTE: S-mode requires a companion SW (SBI) which is not yet implemented,
      thus S-mode is not usable as is, yet.

RISC-V: Implement skeleton for a per CPU structure

It might be useful to store things in memory per CPU. The tricky part
is that all CPUs run the same code and see the same memory, so some
kind of centralized access is required.

For now, the structure contains the hart id.

Access to the structure elements is provided via sscratch, which is
unique for every hart!

Fix ESP32-C3 toolchain download link

arch/xtensa: Add xtensa_tcbinfo struct that contains helpful offsets.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

fix:Temporarily remove udp send large pkt assert

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

net: tcp/udp/icmp/icmpv6 add FIONSPACE support

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

timerexpiration:fix DEADCODE when RR_INTERVAL or SCHED_SPORADIC not select

tmp is always true for CONFIG_RR_INTERVAL > 0
and CONFIG_SCHED_SPORADIC not select

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

arch/riscv: Align the macro definition in csr.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Rename riscv_syscall_dispatch to riscv_dispatch_syscall

follow other function naming(e.g. riscv_dispatch_irq)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Remove riscv_sbi.c since it doesn't exist

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Rename riscv_exception_macros.S to riscv_macros.S

since macro defined in this file is also used in the normal context

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Access [m|s]scratch through CSR_SCRATCH macro

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Rename g_scratch to g_percpu

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched_note: fix buffer size warning in coverity

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

mod_insmod: fix coverity warning

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

stm32: add support for up_perf

boards/nucleo-f446re: initialize up_perf

note_sysview.c: fix compilation for CONFIG_TASK_NAME_SIZE == 0

note_sysview.c: fix compilation if CONFIG_SCHED_INSTRUMENTATION_FILTER not defined

arm/chip: add backtrace support for all chips that support thumb instruction set.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

usrsock: Move event field to usrsock_message_common_s

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

net:fix coverity warning

Signed-off-by: hejianliang3 <hejianliang3@xiaomi.com>

stm32u5: stm32_stdclockconfig fixes

Fix stm32_stdclockconfig for stm32u585xx to the extend that the
B-U585I-IOT02A board's clock tree can be configured.  This board uses
the MSIS as PLL1's input clock and the LSE to autotrim the MSIS.

b-u585i-iot02a: Fix stdclock initialization

Correct the respective defines to initialize the B-U585I-IOT02A clock
tree correctly by means of stm32_stdclockconfig().

b-u585i-iot02a:nsh: Drop TrustedFirmware-M dependency

Make the nsh defconfig for the b-u585i-iot02a run stand-alone (i.e. not
as a companion that relies on TF-M doing low-level board
initialization).

net/utils: fix IPv4 checksum calculation

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/risc-v: use STACK_FRAME_SIZE for in S-mode syscall asm

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/riscv: Rename SCRATCH_HARTID_OFFSET to RISCV_PERCPU_HARTID_OFFSET

and fix the typo error

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

modlib_bind.c: Restore "Relocation address out of range" checks

Restore the checks which got completely broken by the following change.
```
commit 15142a8b106bee8db6ac744b963969feba5c8289
Author: anjiahao <anjiahao@xiaomi.com>
Date:   Fri Apr 1 16:20:03 2022 +0800

    modlib/modlib_bind:fix unsigned_compare with zero

    Signed-off-by: anjiahao <anjiahao@xiaomi.com>
```

syscall: Fix Makefile:69: target 'syscall_names.o' given more than once in the same rule

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/netdb: Support the recursive lock

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/netdb: Remove the temporary unlock in dns_foreach_nameserver

since netdb support the recursive lock

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/netdb: Hold dns lock when operating with resolv.conf

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/xtensa: Build the xtensa_tcbinfo.c file for S2 and S3.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

nuttx: unify FAR attribute usage across the code

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

RISC-V: Fix file name of riscv_dispatch_syscall

RISC-V: Fix usage of static_assert in riscv_percpu.c

There is no alias for struct riscv_percu_s

Update cpp_cmake.rst

update CMAKE_C_FLAGS when compile C file

Update cpp_cmake.rst

openamp: Change the dependence from OPENAMP to RPTUN

since all rpmsg driver need the extension api exposed by rptun driver

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/string: Fix the minor style issue

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc: Avoid the compiler generate code call self(memcpy/memmove/memset/memcmp) recursively

please reference the similar change done by other libc implementation:
https://reviews.llvm.org/D68028?id=224286
https://github.com/bminor/glibc/commit/85c2e6110c9a01ec817c30f1b7e20549d7229987
https://github.com/bminor/musl/commit/4a1f55e92fa74ee382909baa96302231f566b5e1
https://github.com/bminor/newlib/commit/82dfae9ab0734b9946321590162dc6021057fec1

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch:tcbinfo: update tcbinfo as xcpcontext update

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

jlink-nuttx: update regs as nuttx regs save path change

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

include/nuttx: remove double definitions of UNUSED macro

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

fix uinput rpmsg logic error

xtensa/esp32: Add support to TWAI/CANBus controller

esp32: Add board support to TWAI/CANBus

arch/sim: support simulator keyboard devices

arch/risc-v: Replace riscv_fault with riscv_exception

Remove riscv_fault since its code is duplicated with riscv_exception,
and there are textual excpetion reason in riscv_exception.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

fs/epoll: change type of eventset from uint8_t to uint32_t

to support EPOLLONESHOT and so on.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/poll: change format for type pollevent_t

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

lib_lib_vsprintf/backtrace: fix the type issue

using 't': For integer types, causes printf to expect
a ptrdiff_t-sized integer argument.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/poll: change format for type pollevent_t

complete the following commits:

commit d87cf8d4ca5fe69c71c131015a7b64b68c917593
Author: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date:   Fri Apr 1 20:59:55 2022 +0800

    fs/poll: change format for type pollevent_t

    Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

commit d535943a69f03033b077cb95cce162bb28b40b56
Author: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date:   Fri Apr 1 17:49:10 2022 +0800

    fs/epoll: change type of eventset from uint8_t to uint32_t

    to support EPOLLONESHOT and so on.

    Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/risc-v: Remove the unnecessary inclusion of board header files

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

MPFS: Prepare support for S-mode

- Access to PLIC via S-mode registers
- Access to IRQs via S-mode registers / definitions
- Initialize S-mode registers upon boot
- Initialize per CPU area before nx_start

NOTE: S-mode requires a companion SW (SBI) which is not yet implemented,
thus S-mode is not usable as is, yet.

esp32c3: Simplify irq dispatch logic

ESP32C3 use customized irq encoding so it's hard to share further code
with other risc-v based chips, in this patch, we keep the exception
number definition with risc-v spec.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

Documentation/guides/pysimcoder.rst: update pysimCoder dependencies

CONFIG_LIBM option may be required by some toolchains that do not include
standard math library. Morover CONFIG_PTHREAD_STACK_MIN was listed twice
in the list.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>

arch/riscv: Minor style change and text correction

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

sched/pthread:need check pthread is DETACHED

pthread_join need check thread is DETACHED,
Whether to wait according to the result.And,
if a thread is DETACHED,it will not set a new
attr.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

sched/note: add dummy definition if CONFIG_SCHED_INSTRUMENTATION disabled

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/note: correct flatten format

Signed-off-by: chao.an <anchao@xiaomi.com>

arm/armv[7|8]-m: skip the fpu save/restore if stack frame is integer-only

Signed-off-by: chao.an <anchao@xiaomi.com>

fs/vfs: fix st_mode mask check

The full mask for st_mode is 0177777
Now modify any file permissions in hostfs and all will fail

arch/risc-v: Add handler for misaligned load/store

Some risc-v based chips don't support unaligned data access,
it will trigger a exception and then lead to crash.

In this patch, we handle the misaligned access by software to make
system run continue.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

tools/checkrelease.sh: Don't check DISCLAIMER-WIP anymore

since all license is clean up now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/wqueue: Simplify CALL_WORKER dispatch condition

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/irq: Remove CONFIG_SCHED_IRQMONITOR when define CALL_VECTOR

since up_perf_ API doesn't couple with CONFIG_SCHED_IRQMONITOR

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/irq: Fix array overrun in coverity check

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

boards/nucleo-h743zi2: Enable up_perf API

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

boards/lx_cpu: Enable up_perf API

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/risc-v: Align prototype of riscv_exception with xcpt_t

Thus we can attach it to irq handler without any cast.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Attach exception handler in common place

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Move epc adjustment to riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

checkpatch.sh: add -m option to enable/disable Change-Id check

Defaultly disable Change-Id check in commit message.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>

.github/workflows/check.yml: Enable Change-ID check explicitly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Make top Make.defs symlink to board Make.defs instead

Symlink to board Make.defs for top Make.defs, so top Make.defs
syncs in realtime.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>

riscv/riscv_exception_commin.S: Don't call riscv_hartid in single core
mode.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

riscv/riscv_exception_common.S: Allow chips to define the exception
section.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

riscv/esp32c3: Use the common exception handler.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

riscv/bl602/chip.h: Add assembly guards for standard includes.

tools/mkdeps: Extend MAX_SHQUOTE to 3072

Signed-off-by: nietingting <nietingting@xiaomi.com>

audio: Return audio_lowerhalf_s pointer instead error code in audio_comp_initialize

audio: Don't register audio device if name isn't given in audio_comp_initialize

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Fixes some issues with the implementation of the balance
functionality. In function "wm8904_hw_reset" the priv->balance
is initialized with b16HALF, indicating a range from
0 to b16ONE. In function "wm8904_setvolume" the assumed
range for priv->balance is between 0 and 1000. The changes
now make this consistent for 0 to b16ONE-1. Furthermore,
in wm8904_configure the change of balance was not implemented.

Minor fix, function name was wm8994_setvolume instead of
wm8904_setvolume.

Fixed source code format errors.

Revert "mm_heap: heapsize align with MM_MIN_CHUNK."

This reverts commit 69e69740b5f578e035befc762538b282d91ed1ba.

mm_initialize: malloc() return aligend pointer.

malloc() should return aligned (with MM_MIN_CHUNK) pointer, but
pr #5906 destroy that, this pr find a better method to solve
these questions.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
and
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

arch/riscv: Add mtimer driver

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/note: include-able from C++ files

Signed-off-by: chao.an <anchao@xiaomi.com>

drivers/sensors: Add new driver for scd41 sensor module

Add Sensirion's SCD41 CO2, temperature and humidity sensor driver.

drivers/sensors/scd30: Fix invalid parameter check

Fix invalid parameter check and redundant conditions.

drivers/sensors/sgp30: Fix redundant parameter check

Fix redundant conditions.

littelfs: deal with block devices w/o ioctl

Note: Some block devices has ioctl == NULL. eg. drivers/loop

netdb/lib_dnsaddserver.c: Do not insert the duplicate DNS address

Signed-off-by: songlinzhang <songlinzhang@xiaomi.com>

graphics/nxterm: Avoid accessing freed memory

Fix accessing freed priv data.

drivers/syslog: update description if Kconfig

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

libc/lib_localtime:fix deadcode

isdst always is false

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

RISC-V: Combine 3 variables that depend on CPU amount into one

IRQ_NSTACKS, ARCH_CPU_COUNT, CONFIG_SMP_NCPUS all relate to each
other. However, a bit of clean up can be done and everything can
be merged into SMP_NCPUS.

The MPFS bootloader case works also as it requires only 1 IRQ stack
for the hart that executes as bootloader.

RISC-V: Remove riscv_cpuindex.c from platforms that don't need it

riscv_mhartid is no longer called by exception_common, so can remove
this file from platforms that don't need it.

Also fixes make warning:
Makefile:123: target 'riscv_cpuindex.o' given more than once in the same rule

RISC-V: Add setintstack for k210 and qemu

This fixes CI issue, and I think the old implementation with SMP
shared 1 IRQ stack for multiple CPUs.

sched/init: drivers_initialize() should be late than up_initialize()

up_initialize
|
 ->up_serialinit
   |
    ->uart_register  /* ("/dev/console", &CONSOLE_DEV); */

drivers_initialize
|
 ->syslog_console_init
   |
    ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */

Signed-off-by: chao.an <anchao@xiaomi.com>

arch: cxd56xx: update loader and gnssfw version

Update loader and gnssfw to version 2.2.20585

cxd56xx/cxd56_emmc.c: Fix compile warning

Add necessary include header named debug.h for using ferr and
finfo.

arch: cxd56xx: Fix critical section in scu driver

Add critical section to scu one-shot sequencer.

boards: cxd56xx: Fix an issue i2c tool not working

It caused i2c tool not to work due to i2c uninitializing processing.
Since this process is not necessary in the normal case, we will
move it to the error case.

boards: cxd56xx: Make board_late_initialize a weak function

Add a weak_function to the board_late_initialize function so that
it can be replaced by another file, such as a user application.

board/spresense: Add pin selection of ILI934x

Add Kconfig choice for selecting RST and DC pins on ILI934x LCD.

boards: cxd56xx: Add board function for scd41 sensor driver

Add board function for SCD41 CO2, temperature and humidity sensor driver.

cxd56/spresense: Add callback mechanism to notice SDCard injection

Add a mechanism to callback to an application to notice the SDCard
status is changed (inserted or ejected).

.github/gcc.json: Fix space/tab inconsistency

sim: bt: Add specific bluetooth HCI number id

Add option for attached the local bluetooth device use
specific bluetooth HCI number id.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>

lib_localtime:fix unsigned compare with zero

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

arch/risc-v: Apply common mtime driver to mtime based chps

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

risc-v/c906: fix build break

chip/c906_timerisr.c: In function 'up_timer_initialize':
Error: chip/c906_timerisr.c:71:3: error: implicit declaration of function 'DEBUGASSERT' [-Werror=implicit-function-declaration]
   DEBUGASSERT(lower);
   ^~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: chao.an <anchao@xiaomi.com>

libc/lib_glob:use strlcpy instead of memcpy

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/net:use strlcpy instead of strncpy

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

arch/risc-v: Add missing DMB to mtimer / setmtimecmp

The memory mapped mtimecmp lives in I/O space so must add barrier
to make sure the value sticks. Otherwise a new IRQ might fire
at once.

arch/risc-v: Apply misaligned access handler for k210/bl602

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/riscv: Move toolchain config to arch/risc-v/Kconfig like xtensa

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

riscv/riscv_schedulesigaction.c: Remove the duplicate state saving.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch/arm: Move FPU initialization to common place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/stack_color: correct the end address of stack color

The different optimization of compilers will cause ambiguity in
obtaining sp through up_getsp() in arm_stack_color(), if compile
with clang and enable the optimization flag (-Ofast), up_getsp()
call will be earlier than push {r0-r9,lr}, the end address of color
stack will overlap with saved registers.

Compile line:
clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \
-mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o  arm_checkstack.o

Assembler code:
llvm-objdump -aS arm_checkstack.o
------------------------------------
|00000000 <arm_stack_color>:
|;   start = INT32_ALIGN_UP((uintptr_t)stackbase);
|       0: c2 1c         adds  r2, r0, #3
|       2: 22 f0 03 02   bic r2, r2, #3
|;   end   = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) :
|       6: 19 b1         cbz r1, 0x10 <arm_stack_color+0x10> @ imm = #6
|       8: 08 44         add r0, r1
|       a: 20 f0 03 00   bic r0, r0, #3
|       e: 00 e0         b 0x12 <arm_stack_color+0x12> @ imm = #0
|;   __asm__
|      10: 68 46         mov r0, sp                               <--- fetch the sp before push {r7 lr}
|      12: 80 b5         push  {r7, lr}                           <--- sp changed
|;   nwords = (end - start) >> 2;
|      14: 80 1a         subs  r0, r0, r2
|      16: 80 08         lsrs  r0, r0, #2
|; }
|      18: 08 bf         it  eq
|      1a: 80 bd         popeq {r7, pc}
|      1c: 4b f6 ef 63   movw  r3, #48879
|      20: cd f6 ad 63   movt  r3, #57005
|      24: a0 ee 10 3b   vdup.32 q0, r3
|;   while (nwords-- > 0)
|      28: 20 f0 01 e0   dlstp.32  lr, r0
|;       *ptr++ = STACK_COLOR;                                    <--- overwrite
|      2c: a2 ec 04 1f   vstrw.32  q0, [r2], #16
|      30: 1f f0 05 c0   letp  lr, 0x2c <arm_stack_color+0x2c> @ imm = #-8
|; }
|      34: 80 bd         pop {r7, pc}
------------------------------------

Signed-off-by: chao.an <anchao@xiaomi.com>

arm/armv8-m: indicating no low-overhead-loop predication by default

Fix usage fault on clang version 13.0.0 (-Ofast):
------------------------------------------------------------------
| arm_hardfault: Hard Fault escalation:
| arm_usagefault: PANIC!!! Usage Fault:
| arm_usagefault:  IRQ: 3 regs: 0x3c58c510
| arm_usagefault:  BASEPRI: 00000080 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000004
| arm_usagefault:  CFSR: 00020000 HFSR: 40000000 DFSR: 00000000 BFAR: 01608050 AFSR: 00000000
| arm_usagefault: Usage Fault Reason:
| arm_usagefault:  Invalid state
| up_assert: Assertion failed at file:armv8-m/arm_usagefault.c line: 113 task: lpwork
| backtrace:
| [ 2] [<0x2c58124a>] up_backtrace+0xa/0x2e2
| [ 2] [<0x2c56f7cc>] sched_dumpstack+0x28/0x66
| [ 2] [<0x2c580cd0>] up_assert+0x62/0x254
| [ 2] [<0x2c56ab8a>] _assert+0/0xa
| [ 2] [<0x2c55575a>] nxsched_add_prioritized+0x38/0xa2
| [ 2] [<0x2c555894>] nxsched_add_blocked+0x2e/0x44
| [ 2] [<0x2c580748>] up_block_task+0x2a/0x96
| [ 2] [<0x2c5569ea>] nxsem_wait+0x64/0xb4
| [ 2] [<0x2c556a40>] nxsem_wait_uninterruptible+0x6/0x10
| [ 2] [<0x2c559b9a>] work_thread+0x1c/0x48
-------------------------------------------------------------------

usage fault on 0x2c55575a:

------------------------------------
|2c555722 <nxsched_add_prioritized>:
|; {
|2c555722: 80 b5         push  {r7, lr}
|...
|2c55575a: 2f f0 17 c0   le  0x2c555732 <nxsched_add_prioritized+0x10> @ imm = #-44
|...
------------------------------------

Arm v8-M Architecture Reference Manual:

C2.4.103 LE, LETP

B3.28 Low overhead loops:

An INVSTATE UsageFault is raised if a LE instruction is executed and FPSCR.LTPSIZE does not read as four.
When a new floating-point context is created and FPCCR.ASPEN is set to zero it is the responsibility of software
to correctly initialize FPSCR.LTPSIZE.

Signed-off-by: chao.an <anchao@xiaomi.com>

fs/vfs/fs_truncate.c: Use ioctl to truncate on non-mountpoint inode

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>

libc/time: add strptime porting support

lib_strptime.c copies from android bionic/libc/tzcode.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/strptime:_conv_num skip space

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/strptime: fix warning unused-value

warning: value computed is not used [-Wunused-value]
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/lib_strptime:change code format & add notes

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

RISC-V: Move mhartid to own assembly macro+function

Hartid and cpuindex are not the same thing. Hartid is needed regardless
of SMP, for external interrupt handling etc.

SMP needs cpuindex which might not be index == hartid, so both are
needed. IMO it is clearer to provide separate API for both.

Currently the implementation of up_cpu_index is done a bit lazily,
because it assumes hartid == cpu index, but this is not 100% accurate,
so it is still missing some logic.

arch/risc-v/riscv_misaligned: Correct sw source register

If source register of sw instruction is x0, we must point it to a constant zero
since in NuttX's context,
value of index 0 is EPC.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Correct format of 32-bit insn in misaligned handler

FIx:
Format specifies type 'unsigned long' but the argument has type 'uint32_t' (aka 'unsigned int')

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

power/governor: Remove the duplicated function prototype

since they are declared include/nuttx/power/pm.h by:
commit 5ce181e6b702cedbd79790fbe40aab7d29dae7c0
Author: zhuyanlin <zhuyanlin1@xiaomi.com>
Date:   Mon Feb 14 15:32:40 2022 +0800

    power:govorner: add govorner to per domain.

    For mult domains scene,,
    activity and greety can be used at same time.
    Let user to select domain governor.

    Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

and add static const to g_pmgovernor

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

drivers/power: Remove activity_governor.h and greedy_governor.h

since they aren't really used anymore

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

MPFS: Fix mtimecmp address

MTIMECMP0 was incorrect

MPFS: Use riscv_exception_attach like the others do

Exception / fault handling goes to unexpected ISR, fix by setting the
common ISR handlers like all other RISC-V platforms do.

arch: Fix compile error when enabling CONFIG_DUMP_ON_EXIT

"error: incompatible types when assigning to type 'struct filelist *' from type 'struct filelist'
   filelist = tcb->group->tg_filelist;"

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch: Move the DUMP_ON_EXIT logic after nxtask_exit.

Otherwise we will try to dump the state of the current task, however the
exit handler has already started doing some cleanup and invalidated its
group.  Accessing the group from dumponexit will crash.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch/Kconfig: Move the DUMP_ON_EXIT option out of the Bring-up group.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

sched/pthread_create:fix bug,delete data_sem

if a pthread set attr is detach,and when call pthread_create,
new thread exit quikly,new thread's tcb be free,then pthread_create
use new thread's tcb will crash.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

rpmsg_usrsock: Support the wireless ioctl which contain pointer 1/2

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

fix: usrsock iovec_do skip empty iov

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

sched/environ: Ensure tg_envp terminated by double '\0'

so we can compute the whole environ string length from it

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

RISC-V: Add SBI glue logic

Currently only stubs for mtime handling added, with a gentle reminder
that the actual implementation is still missing.

RISC-V: mtimer register via SBI when S-mode is in use

Cannot access the memory mapped registers directly when the kernel
runs in S-mode, must forward the access to SBI.

arch/[arm|sparc]: replace INT32_ALIGN_* to STACK_ALIGN_*

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/stack_color: correct the stack top of running task

This PR to ensure the stack pointer is locate to the stack top

Signed-off-by: chao.an <anchao@xiaomi.com>

arm/rtl8720c: Remove up_getsp which is already implemented in arch/arm/arch.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

MPFS: Set correct interrupt per mode (M-/S-mode) for mtimer

libc/string: Use Byte-Shift algorithm for very long needles

Reference here:
https://github.com/taleinat/byteshift_strstr

Signed-off-by: chao.an <anchao@xiaomi.com>
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/string:delete small to big endian marco

avoid byte alignment
Signed-off-by: haopengxiang <haopengxiang@xiaomi.com>
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/string:add LICENSE info

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

Add SPIRAM to ESP32-S2

driver/mmcsdio: do not hold the semaphore on interrupt context

so we can do the full dump to mmc/sd card in the panic case

Signed-off-by: chao.an <anchao@xiaomi.com>

driver/mmcsdio: do not hold the semaphore in idle thread too

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

fs/fcntl: add O_APPEND flag judge in fcntl

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>

vfs/fcntl: Minor style fix

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arm/armv7-[a|r]: move fpu save/restore to assembly handler

Save/Restore FPU registers in C environment is dangerous practive,
which cannot guarantee the compiler won't generate the assembly code
with float point registers, especially in interrupt handling

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/arm/src/sam34/sam_hsmci.c: delay required after sending command

arch/arm/src/sam34/sam_hsmci.c: DMA setup before write is required

arch/arm/src/sam34/sam_hsmci: DMA also present on SAM3X chips

arch/arm/src/sam34/sam_hsmci.c: SAM3X GPIO setup

arch/arm/src/sam34/Kconfig: fix typo in device name

boards/arm/a1x: Remove the check CONFIG_ARCH_FPU around arm_fpuconfig

forget in below change:
commit df5a8a53ae92606e2d65149c6b5159b82dfc5d76
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Tue Apr 12 03:18:46 2022 +0800

    arch/arm: Move FPU initialization to common place

    Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

boards/esp32_twai: Remove arm_arch.h from comment

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

drivers: remove unimplemented open/close/ioctl interfaces

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/risc-v: Use fs status definition from csr.h

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/riscv/esp32c3: esp32c3_twai.h TWAI (CAN) controller registers provided by Espressif.

File provided by Abdelatif Guettouche

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

arch/riscv/esp32c3: ESP32C3 TWAI (CAN) controller driver.

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

arch/riscv/esp32c3: ESP32C3 TWAI (CAN) controller included into Kconfig.

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

boards/risc-v/esp32c3: ESP32C3 TWAI (CAN) controller bringup for DevKitM-1.

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

boards/risc-v/esp32c3: ESP32C3 TWAI (CAN) controller config for DevKitM-1.

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

Fixed a compile error, presumably caused by C&P error.

arch/armv[7|8]m: enhance the clang support

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/Toolchain.defs: replace all ${/$} with $(/$)

Signed-off-by: chao.an <anchao@xiaomi.com>

semaphore: fix usage of NXSEM_INITIALIZER

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/xtensa: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/ceva: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/sim: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/x86_64: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/or1k: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/misoc: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/mips: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/sparc: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arm/arch: using __builtin_frame_address(0) implement up_getsp().

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

arch/arm: Move arm_signal_dispatch.c to common folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Remove the unneeded worker_t cast

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Remove the unneeded void cast

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arm/a1x: fix compile break

Signed-off-by: chao.an <anchao@xiaomi.com>

wireless/80211: update the 80211 header

Upstream from:
https://github.com/freebsd/freebsd-src/blob/main/sys/net80211/ieee80211.h

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/environ: Refine the environment variables storage layout

to confirm the standard and then implement get_environ_ptr correctly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc: Don't duplicate string in chdir and lib_restoredir

since the new layout doesn't reallocate the unchanged environ variable anymore

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

tools/cibuild.sh: Migrate risc-v toolchian from 8.3.0 to 10.2.0

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

tools/cibuild.sh: Download risc-v toolchain with --no-check-certificate

untils SiFive update their certification

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/arm: export arm_saveusercontext()

rename arm_saveusercontext() -> up_arm_saveusercontext()

Signed-off-by: chao.an <anchao@xiaomi.com>

boards/ostest: remove board ostest implement

Signed-off-by: chao.an <anchao@xiaomi.com>

board/arch_fpu*: move arch_[get|cmp]fpu to common arch

rename the arch api:
arch_getfpu  -> up_saveusercontext
arch_cmpfpu  -> up_cmpfpu

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/mips: Remove unneeded group_addrenv call which handled by mips_doirq

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/misoc: Remove unneeded group_addrenv call which handled by [lm32|minerva]_doirq

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/xtensa: Remove unneeded group_addrenv call which handled by xtensa_irq_dispatch

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/sparc: Remove unneeded group_addrenv call which handled by up_doirq

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/blockstream: add block out stream backend

Signed-off-by: chao.an <anchao@xiaomi.com>

libc/blkoutstream: Minor style fix

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/arm: Remove unneeded group_addrenv call which handled by arm_doirq

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/risc-v: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/arm: Remove FAR and CODE from common/ and arm*/ folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Revert "tools/cibuild.sh: Download risc-v toolchain with --no-check-certificate"

This reverts commit 3b97e37b525d50d8a78765f85276f900129dade5.

arch/arm: Remove all lazy fpu related code

since it is broken and inefficient, and then removed by:
commit dc961baaea17107109d94575e9bb5d9fb725b801
Author: chao.an <anchao@xiaomi.com>
Date:   Thu Apr 14 18:07:14 2022 +0800

    arm/armv7-[a|r]: move fpu save/restore to assembly handler

    Save/Restore FPU registers in C environment is dangerous practive,
    which cannot guarantee the compiler won't generate the assembly code
    with float point registers, especially in interrupt handling

    Signed-off-by: chao.an <anchao@xiaomi.com>

commit 8d66dbc0680cb81f91674ace814b2b8a94c49cd2
Author: chao.an <anchao@xiaomi.com>
Date:   Thu Apr 7 13:48:04 2022 +0800

    arm/armv[7|8]-m: skip the fpu save/restore if stack frame is integer-only

    Signed-off-by: chao.an <anchao@xiaomi.com>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/armv[7|8]-m: Compare all FPU registers in up_fpucmp

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/armv7-[a|r]: correct the handing of group env switch

This PR resolved 2 issues:
1. CURRENT_REGS is not set correctly on swint handling
2. group env is not changed properly

Signed-off-by: chao.an <anchao@xiaomi.com>

fs:oflag need consistent with psock

if don't consistent with psock,call fcntl will have differet flag
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

arm/arm_assert.c Fix dumping of status from ISR

The status dump did not work if the first fault triggers before
the first context switch (during nx_start()).

risc-v/riscv_assert.c Fix dumping of status from ISR

The status dump did not work if the first fault triggers before
the first context switch (during nx_start()).

fs:fs_getfilep changes fd judgment method

if a fd was closed,need return EBADF
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

arch/armv8-m: Unify the toolchain definition of eabi/clang for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/armv7-m: Unify the toolchain definition of eabi/clang/iar for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/arm/armv6-m: Unify the toolchain definition of eabi for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/armv7-a/r: Unify the toolchain definition of eabi for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/risc-v: Unify the toolchain definition of RVG for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/misoc: Unify the toolchain definition of GNU for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/z80: Unify the toolchain definition of SDCC for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

armv7/r:cp15_cache_all: fix error in LineSize 'r5' mask

r5 = r3 & r1

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

arch/sparc,xtensa: Control output by $(Q) as other arch

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

LICENSE: document missing armv7-x files

add missing armv7-a/armv7-r files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing lpc files

add missing lpc files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing samdxxx files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing am335x files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: cxd56xx: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: imxrt: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: lpc43xx: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: phy62xx: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: stm32l4: remove empty files

during contribution empty files have been pushed.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing tiva files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: mor1kx: remove empty files

during contribution empty files have been pushed.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing mor1k files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: sama5: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: stm32: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

boards: sim: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

drivers: leds: ncp5623c: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing mtd files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

drivers: mtd: gd5f: migrate the license to Apache

Xiaomi has submitted the SGA
as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

drivers: sensors: mlx90614: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing bcm43xxx files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing nfs files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

include: himem: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

include: leds: ncp5623c: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing uIP files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing bluetooth files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

include: wireless: bluetooth: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing sixlowpan files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing igmp files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing wireless files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing libc files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch/risc-v: Change riscv_savefpu/riscv_loadfpu to macro

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/armv6-m: add support of LLVM Clang

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/clang: add support for Clang LTO

add support of Clang's Link Time Optimization (LTO) on NuttX build system

Reference:
https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
https://llvm.org/docs/LinkTimeOptimization.html

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/xtensa: Use syscall interface for xtensa_save/restore_context.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch.h: Fix up_exit prototype.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch/xtensa: Move xtensa_save_context to up_saveusercontext for
consistency with other archs.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arm/armv[7|8]m: compare of hardware fp registers should skip REG_FP_RESERVED

Fix fpu test break

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/risc-v: Don't clear reserved bits in fcsr in riscv_fpuconfig

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

pipe: Increase buffer size by one byte to ompensate the full indicator

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

boards/sim: support rc.sysinit

Follow: http://glennastory.net/boot/sysinit.html

This is first script that init runs is rc.sysinit. This
script does serval initialization tasks about basic service.

The boot sequence currently provided to the board level is:
board_earlyinitialize->
    board_lateinitialize(Peripherals driver, core driver, ...)->
	run rcS script(mount fs, run service) ->
	    board_appinitialize->

After this patch:
The boot sequence currently provided to the board level is:
board_earlyinitialize->
    board_lateinitialize(core driver,...)->
	run rc.sysinit script(mount fs, run core service) ->
	    board_appinitialize(Peripherals driver)->
		run rcS script(run other service)->

So, Peripheral drivers can do more with the file system and
core services.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

arch/arm: Switch the context of save and restore from assembler to c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/arm: Move the duplicated assembly code to common folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

binfmt_execmodule: add errout_with_args exit point

Ensures that when errout_xx is taken, args are freed

env_dup: Fix copying of env between address environments

If address environments are in use, it is not possible to simply
memcpy from from one process to another. The current implementation
of env_dup does precisely this and thus, it fails at once when it is
attempted between two user processes.

The solution is to use the kernel's heap as an intermediate buffer.
This is a simple, effective and common way to do a fork().

Obviously this is not needed for kernel processes.

syscall: Add call gate for get_environ_ptr

Now that the environment strings are stored as an array of strings,
they can be passed from the application via char **environ, which
is really defined as a function call to get_environ_ptr().

This works as is for flat build, but protected mode and kernel mode
require a call gate, which is added here.

binfmt_execmodule: If incoming envp is NULL get parent envp

This keeps backwards compatibility with apps that do not provide
envp. The old implementation passes NULL always and this change fixes
any regression caused by it.

assert: static_assert is not support in c standard C89,C99.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

arch/xtensa: Color the other CPUs task when they are created.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

compile/opt: add config DEBUG_OPT_UNUSED_SECTIONS

Enable this option to optimization the unused input sections with the
linker by compiling with " -ffunction-sections -fdata-sections ", and
linking with " --gc-sections ".

Signed-off-by: chao.an <anchao@xiaomi.com>

compile/opt: add config DEBUG_LINK_MAP

Selecting this option will pass "-Map=$(TOPDIR)$(DELIM)nuttx.map" to ld
when linking NuttX ELF. That file can be useful for verifying
and debugging magic section games, and for seeing which
pieces of code get eliminated with DEBUG_OPT_UNUSED_SECTIONS.

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/risc-v: Enable FPU for K210

K210 support rv64gc ISA, now we enable F/D extension for it.

Note: QEMU for K210 don't support FPU now.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

sched/task: Correct the comment about environment variable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/environ: Remove the unneeded cast in env_dup

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/environ: Replace get_environ_ptr with environ

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

environ: Don't expose get_environ_ptr in csdlib

since it isn't defined in c/c++ standard

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/risc-v/riscv_misaligned: Implement float load/store support

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch: risc-v: Do not enable FPU for K210 with QEMU

Summary:
- I noticed that maix-bit:smp does not work with QEMU.
- Actually, QEMU supports sifive_u (not K210) but it works
  if FPU is disabled.
- This commit fixes this issue.

Impact:
- K210 with QEMU only

Testing:
- Tested with qemu-5.2

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

sched/task: Implement execle and execve

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc: Implement execvp, execlp and execvpe as macro

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc: Fix typo error in execle

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

syscall: Fix prototype of exec() to syscall.csv

pm: Move pm_initialize call from driver_initialize to xxx_pminitialize

since it's too late with the below commit:
ommit a594a5d7a8dcd756884ca7d3449f37ba77f96af3
Author: chao.an <anchao@xiaomi.com>
Date:   Mon Apr 11 19:44:26 2022 +0800

    sched/init: drivers_initialize() should be late than up_initialize()

    up_initialize
    |
     ->up_serialinit
       |
        ->uart_register  /* ("/dev/console", &CONSOLE_DEV); */

    drivers_initialize
    |
     ->syslog_console_init
       |
        ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched: remove DEBUGASSERT from nx_waitpid

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

xtensa_user_handler.S: Use the `ps_setup` macro when dealing with an
exception.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

xtensa_user_handler.S: Fix backtrace.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch/xtensa: No need to save SP in EXCSAVE_1 when linking the interrupt
frame with the previous frame.  The SP is already saved in A12.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

boards/boardctl: correct boarctl return value

Summary:
- Correct boardctl function's return value
- In case of BOARDIOC_TESTSET, `ret' has 0 or 1 or an error,
  but `ret' is ignored except error.

Impact:
- boardctl return value except errors

Testing:
- custom Cortex-A9 board

Signed-off-by: Oki Minabe <minabe.oki@gmail.com>

libc/string: strcmp/strncmp cast unsigned char

Summary:
- Cast to unsigned char for strcmp and strncmp
- strcmp and strncmp are described following by opengroup.org

  The sign of a non-zero return value shall be determined by the sign
  of the difference between the values of the first pair of bytes
  (both interpreted as type unsigned char) that differ in the strings
  being compared.

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html
  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncmp.html

Impact:
- strcmp and strncmp return value

Testing:
- ostest on sabre-6quad:smp w/ qemu

Signed-off-by: Oki Minabe <minabe.oki@gmail.com>

compiler.h: optimization option is not supported before GCC 4.6

-fno-tree-loop-distribute-patterns is not supported before
GCC 4.6

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

libs/libc/string: unify implementation across the functions

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

tools:fix parsememdump.py match error

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/fixedmatch: Avoid "divide by zero" error

Signed-off-by: Xiang Xiao <xiaoxia…
anchao added a commit to anchao/nuttx that referenced this pull request Aug 1, 2022
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
|  apache#7  0x00005555555ecc77 in note_common (tcb=0x7ffff31d2180, note=0x7ffff3275f80, length=21 '\025', type=18 '\022') at sched/sched_note.c:144
|  apache#8  0x00005555555ed706 in sched_note_syscall_enter (nr=1, argc=0) at sched/sched_note.c:765
|  apache#9  0x000055555560eb37 in __wrap_getpid () at wraps/WRAP_getpid.c:26
|  apache#10 0x0000555555608d1c in mm_takesemaphore (heap=0x7ffff30ae000) at mm_heap/mm_sem.c:127
|  apache#11 0x0000555555609477 in mm_free (heap=0x7ffff30ae000, mem=0x7ffff3265b80) at mm_heap/mm_free.c:89
|  apache#12 0x00005555556070c5 in free (mem=0x7ffff3265b80) at umm_heap/umm_free.c:49
|  apache#13 0x000055555560c3b0 in up_release_stack (dtcb=0x7ffff31e4b00, ttype=0 '\000') at sim/up_releasestack.c:67
|  apache#14 0x00005555555f2515 in nxsched_release_tcb (tcb=0x7ffff31e4b00, ttype=0 '\000') at sched/sched_releasetcb.c:134
|  apache#15 0x00005555556bdf0c in nxtask_terminate (pid=4, nonblocking=true) at task/task_terminate.c:184
|  apache#16 0x00005555556bdb0f in nxtask_exit () at task/task_exit.c:168
|  apache#17 0x000055555566e05f in up_exit (status=0) at sim/up_exit.c:64
|  apache#18 0x000055555564f454 in _exit (status=0) at task/exit.c:78
|  apache#19 0x000055555560ea89 in __wrap__exit (parm1=0) at wraps/WRAP__exit.c:27
|  apache#20 0x00005555555eb288 in exit (status=0) at stdlib/lib_exit.c:54
|  apache#21 0x00005555555fe2cc in nxtask_startup (entrypt=0x555555670c34 <critmon_start_main>, argc=1, argv=0x7ffff3265bb0) at sched/task_startup.c:70
|  apache#22 0x00005555555f02a0 in nxtask_start () at task/task_start.c:134
|  apache#23 0x0000000000000000 in ?? ()

Signed-off-by: chao.an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Aug 1, 2022
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
|  apache#7  0x00005555555ecc77 in note_common (tcb=0x7ffff31d2180, note=0x7ffff3275f80, length=21 '\025', type=18 '\022') at sched/sched_note.c:144
|  apache#8  0x00005555555ed706 in sched_note_syscall_enter (nr=1, argc=0) at sched/sched_note.c:765
|  apache#9  0x000055555560eb37 in __wrap_getpid () at wraps/WRAP_getpid.c:26
|  apache#10 0x0000555555608d1c in mm_takesemaphore (heap=0x7ffff30ae000) at mm_heap/mm_sem.c:127
|  apache#11 0x0000555555609477 in mm_free (heap=0x7ffff30ae000, mem=0x7ffff3265b80) at mm_heap/mm_free.c:89
|  apache#12 0x00005555556070c5 in free (mem=0x7ffff3265b80) at umm_heap/umm_free.c:49
|  apache#13 0x000055555560c3b0 in up_release_stack (dtcb=0x7ffff31e4b00, ttype=0 '\000') at sim/up_releasestack.c:67
|  apache#14 0x00005555555f2515 in nxsched_release_tcb (tcb=0x7ffff31e4b00, ttype=0 '\000') at sched/sched_releasetcb.c:134
|  apache#15 0x00005555556bdf0c in nxtask_terminate (pid=4, nonblocking=true) at task/task_terminate.c:184
|  apache#16 0x00005555556bdb0f in nxtask_exit () at task/task_exit.c:168
|  apache#17 0x000055555566e05f in up_exit (status=0) at sim/up_exit.c:64
|  apache#18 0x000055555564f454 in _exit (status=0) at task/exit.c:78
|  apache#19 0x000055555560ea89 in __wrap__exit (parm1=0) at wraps/WRAP__exit.c:27
|  apache#20 0x00005555555eb288 in exit (status=0) at stdlib/lib_exit.c:54
|  apache#21 0x00005555555fe2cc in nxtask_startup (entrypt=0x555555670c34 <critmon_start_main>, argc=1, argv=0x7ffff3265bb0) at sched/task_startup.c:70
|  apache#22 0x00005555555f02a0 in nxtask_start () at task/task_start.c:134
|  apache#23 0x0000000000000000 in ?? ()

Signed-off-by: chao.an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Aug 1, 2022
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
|  apache#7  0x00005555555ecc77 in note_common (tcb=0x7ffff31d2180, note=0x7ffff3275f80, length=21 '\025', type=18 '\022') at sched/sched_note.c:144
|  apache#8  0x00005555555ed706 in sched_note_syscall_enter (nr=1, argc=0) at sched/sched_note.c:765
|  apache#9  0x000055555560eb37 in __wrap_getpid () at wraps/WRAP_getpid.c:26
|  apache#10 0x0000555555608d1c in mm_takesemaphore (heap=0x7ffff30ae000) at mm_heap/mm_sem.c:127
|  apache#11 0x0000555555609477 in mm_free (heap=0x7ffff30ae000, mem=0x7ffff3265b80) at mm_heap/mm_free.c:89
|  apache#12 0x00005555556070c5 in free (mem=0x7ffff3265b80) at umm_heap/umm_free.c:49
|  apache#13 0x000055555560c3b0 in up_release_stack (dtcb=0x7ffff31e4b00, ttype=0 '\000') at sim/up_releasestack.c:67
|  apache#14 0x00005555555f2515 in nxsched_release_tcb (tcb=0x7ffff31e4b00, ttype=0 '\000') at sched/sched_releasetcb.c:134
|  apache#15 0x00005555556bdf0c in nxtask_terminate (pid=4, nonblocking=true) at task/task_terminate.c:184
|  apache#16 0x00005555556bdb0f in nxtask_exit () at task/task_exit.c:168
|  apache#17 0x000055555566e05f in up_exit (status=0) at sim/up_exit.c:64
|  apache#18 0x000055555564f454 in _exit (status=0) at task/exit.c:78
|  apache#19 0x000055555560ea89 in __wrap__exit (parm1=0) at wraps/WRAP__exit.c:27
|  apache#20 0x00005555555eb288 in exit (status=0) at stdlib/lib_exit.c:54
|  apache#21 0x00005555555fe2cc in nxtask_startup (entrypt=0x555555670c34 <critmon_start_main>, argc=1, argv=0x7ffff3265bb0) at sched/task_startup.c:70
|  apache#22 0x00005555555f02a0 in nxtask_start () at task/task_start.c:134
|  apache#23 0x0000000000000000 in ?? ()

Signed-off-by: chao.an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Aug 1, 2022
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
|  apache#7  0x00005555555ecc77 in note_common (tcb=0x7ffff31d2180, note=0x7ffff3275f80, length=21 '\025', type=18 '\022') at sched/sched_note.c:144
|  apache#8  0x00005555555ed706 in sched_note_syscall_enter (nr=1, argc=0) at sched/sched_note.c:765
|  apache#9  0x000055555560eb37 in __wrap_getpid () at wraps/WRAP_getpid.c:26
|  apache#10 0x0000555555608d1c in mm_takesemaphore (heap=0x7ffff30ae000) at mm_heap/mm_sem.c:127
|  apache#11 0x0000555555609477 in mm_free (heap=0x7ffff30ae000, mem=0x7ffff3265b80) at mm_heap/mm_free.c:89
|  apache#12 0x00005555556070c5 in free (mem=0x7ffff3265b80) at umm_heap/umm_free.c:49
|  apache#13 0x000055555560c3b0 in up_release_stack (dtcb=0x7ffff31e4b00, ttype=0 '\000') at sim/up_releasestack.c:67
|  apache#14 0x00005555555f2515 in nxsched_release_tcb (tcb=0x7ffff31e4b00, ttype=0 '\000') at sched/sched_releasetcb.c:134
|  apache#15 0x00005555556bdf0c in nxtask_terminate (pid=4, nonblocking=true) at task/task_terminate.c:184
|  apache#16 0x00005555556bdb0f in nxtask_exit () at task/task_exit.c:168
|  apache#17 0x000055555566e05f in up_exit (status=0) at sim/up_exit.c:64
|  apache#18 0x000055555564f454 in _exit (status=0) at task/exit.c:78
|  apache#19 0x000055555560ea89 in __wrap__exit (parm1=0) at wraps/WRAP__exit.c:27
|  apache#20 0x00005555555eb288 in exit (status=0) at stdlib/lib_exit.c:54
|  apache#21 0x00005555555fe2cc in nxtask_startup (entrypt=0x555555670c34 <critmon_start_main>, argc=1, argv=0x7ffff3265bb0) at sched/task_startup.c:70
|  apache#22 0x00005555555f02a0 in nxtask_start () at task/task_start.c:134
|  apache#23 0x0000000000000000 in ?? ()

Signed-off-by: chao.an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Aug 1, 2022
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
|  apache#7  0x00005555555ecc77 in note_common (tcb=0x7ffff31d2180, note=0x7ffff3275f80, length=21 '\025', type=18 '\022') at sched/sched_note.c:144
|  apache#8  0x00005555555ed706 in sched_note_syscall_enter (nr=1, argc=0) at sched/sched_note.c:765
|  apache#9  0x000055555560eb37 in __wrap_getpid () at wraps/WRAP_getpid.c:26
|  apache#10 0x0000555555608d1c in mm_takesemaphore (heap=0x7ffff30ae000) at mm_heap/mm_sem.c:127
|  apache#11 0x0000555555609477 in mm_free (heap=0x7ffff30ae000, mem=0x7ffff3265b80) at mm_heap/mm_free.c:89
|  apache#12 0x00005555556070c5 in free (mem=0x7ffff3265b80) at umm_heap/umm_free.c:49
|  apache#13 0x000055555560c3b0 in up_release_stack (dtcb=0x7ffff31e4b00, ttype=0 '\000') at sim/up_releasestack.c:67
|  apache#14 0x00005555555f2515 in nxsched_release_tcb (tcb=0x7ffff31e4b00, ttype=0 '\000') at sched/sched_releasetcb.c:134
|  apache#15 0x00005555556bdf0c in nxtask_terminate (pid=4, nonblocking=true) at task/task_terminate.c:184
|  apache#16 0x00005555556bdb0f in nxtask_exit () at task/task_exit.c:168
|  apache#17 0x000055555566e05f in up_exit (status=0) at sim/up_exit.c:64
|  apache#18 0x000055555564f454 in _exit (status=0) at task/exit.c:78
|  apache#19 0x000055555560ea89 in __wrap__exit (parm1=0) at wraps/WRAP__exit.c:27
|  apache#20 0x00005555555eb288 in exit (status=0) at stdlib/lib_exit.c:54
|  apache#21 0x00005555555fe2cc in nxtask_startup (entrypt=0x555555670c34 <critmon_start_main>, argc=1, argv=0x7ffff3265bb0) at sched/task_startup.c:70
|  apache#22 0x00005555555f02a0 in nxtask_start () at task/task_start.c:134
|  apache#23 0x0000000000000000 in ?? ()

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

Signed-off-by: chao.an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Aug 31, 2022
apps/examples/usrsocktest/usrsocktest_basic_daemon.c:

321 static void basic_daemon_dup2(FAR struct usrsocktest_daemon_conf_s *dconf)
322 {
...
335   ret = dup2(sd2, sd);
352 }

Usrsocktest Task hold the file group lock and send the close request to usrsock deamon :

| #0  net_lockedwait_uninterruptible (sem=0x5555555f8ba2 <g_usrsockdev+34>) at utils/net_lock.c:427
| #1  0x000055555557489c in usrsockdev_do_request (conn=0x5555555f8800 <g_usrsock_connections>, iov=0x7ffff3f36040, iovcnt=1) at usrsock/usrsock_dev.c:1185
|                           --> send close request to usrsock deamon
|
| #2  0x00005555555d0439 in do_close_request (conn=0x5555555f8800 <g_usrsock_connections>) at usrsock/usrsock_close.c:109
| #3  0x00005555555d04f5 in usrsock_close (conn=0x5555555f8800 <g_usrsock_connections>) at usrsock/usrsock_close.c:157
| #4  0x00005555555cf100 in usrsock_sockif_close (psock=0x7ffff3ea4a60) at usrsock/usrsock_sockif.c:234
| #5  0x00005555555c7b2f in psock_close (psock=0x7ffff3ea4a60) at socket/net_close.c:102
| #6  0x000055555557a518 in sock_file_close (filep=0x7ffff3f253d0) at socket/socket.c:115
| apache#7  0x000055555557678f in file_close (filep=0x7ffff3f253d0) at vfs/fs_close.c:74
| apache#8  0x000055555557694c in file_dup2 (filep1=0x7ffff3f253e8, filep2=0x7ffff3f253d0) at vfs/fs_dup2.c:129
|                           --->  hold group file list lock  ( _files_semtake(list) )
|
| apache#9  0x0000555555575aab in nx_dup2 (fd1=7, fd2=6) at inode/fs_files.c:451
| apache#10 0x0000555555575af3 in dup2 (fd1=7, fd2=6) at inode/fs_files.c:473
| apache#11 0x000055555559d937 in basic_daemon_dup2 (dconf=0x5555555f8d80 <usrsocktest_daemon_config>) at usrsocktest_basic_daemon.c:335
| apache#12 0x000055555559ed80 in usrsocktest_test_basic_daemon_basic_daemon_dup2 () at usrsocktest_basic_daemon.c:612
| apache#13 0x000055555559f18d in usrsocktest_group_basic_daemon_run () at usrsocktest_basic_daemon.c:666
| apache#14 0x0000555555599f8d in run_tests (name=0x5555555dc8c3 "basic_daemon", test_fn=0x55555559ef50 <usrsocktest_group_basic_daemon_run>) at usrsocktest_main.c:117
| apache#15 0x000055555559a06c in run_all_tests () at usrsocktest_main.c:154
| apache#16 0x000055555559a3d1 in usrsocktest_main (argc=1, argv=0x7ffff3f25450) at usrsocktest_main.c:248
| apache#17 0x000055555555cad8 in nxtask_startup (entrypt=0x55555559a357 <usrsocktest_main>, argc=1, argv=0x7ffff3f25450) at sched/task_startup.c:70
| apache#18 0x0000555555559938 in nxtask_start () at task/task_start.c:134

Usrsock Deamon weakup and setup the poll want to perform close request, but locked on fs_getfilep():

| #0  _files_semtake (list=0x7ffff3f250b8) at inode/fs_files.c:51
|                           --> Request group lock but which hold by close request, deadlock
| #1  0x00005555555758b1 in fs_getfilep (fd=5, filep=0x7ffff3f47190) at inode/fs_files.c:375
| #2  0x00005555555d3064 in poll_fdsetup (fd=5, fds=0x7ffff3f47290, setup=true) at vfs/fs_poll.c:79
| #3  0x00005555555d3243 in poll_setup (fds=0x7ffff3f47290, nfds=2, sem=0x7ffff3f47206) at vfs/fs_poll.c:139
| #4  0x00005555555d39a6 in nx_poll (fds=0x7ffff3f47290, nfds=2, timeout=-1) at vfs/fs_poll.c:383
| #5  0x00005555555d3abd in poll (fds=0x7ffff3f47290, nfds=2, timeout=-1) at vfs/fs_poll.c:501
|                           --> daemon weak up
| #6  0x00005555555c62c7 in usrsocktest_daemon (param=0x5555555f5360 <g_ub_daemon>) at usrsocktest_daemon.c:1846
| apache#7  0x000055555559161e in pthread_startup (entry=0x5555555c60d3 <usrsocktest_daemon>, arg=0x5555555f5360 <g_ub_daemon>) at pthread/pthread_create.c:59
| apache#8  0x00005555555d45f0 in pthread_start () at pthread/pthread_create.c:175
| apache#9  0x0000000000000000 in ?? ()

Signed-off-by: chao an <anchao@xiaomi.com>
CV-Bowen added a commit to CV-Bowen/incubator-nuttx that referenced this pull request Sep 1, 2022
==2117790==ERROR: AddressSanitizer: global-buffer-overflow on address 0x64d9e3c0 at pc 0x59ac4e16 bp 0xcefe8058 sp 0xcefe8048
READ of size 1 at 0x64d9e3c0 thread T0
    #0 0x59ac4e15 in up_nputs sim/up_nputs.c:54
    #1 0x59a67e4c in syslog_default_write syslog/syslog_channel.c:220
    #2 0x59a67823 in syslog_default_write syslog/syslog_write.c:101
    apache#3 0x59a67f10 in syslog_write syslog/syslog_write.c:153
    apache#4 0x59a651c3 in syslogstream_flush syslog/syslog_stream.c:60
    apache#5 0x59a6564e in syslogstream_addchar syslog/syslog_stream.c:104
    apache#6 0x59a6576f in syslogstream_putc syslog/syslog_stream.c:140
    apache#7 0x5989fc4d in vsprintf_internal stdio/lib_libvsprintf.c:952
    apache#8 0x598a1298 in lib_vsprintf stdio/lib_libvsprintf.c:1379
    apache#9 0x59a64ea4 in nx_vsyslog syslog/vsyslog.c:223
    apache#10 0x598a601a in vsyslog syslog/lib_syslog.c:68
    apache#11 0x59b0e3dc in AIOTJS::logPrintf(int, char const*, ...) src/ajs_log.cpp:45
    apache#12 0x59b03d56 in jse_dump_obj src/jse/quickjs/jse_quickjs.cpp:569
    apache#13 0x59b03ea1 in jse_dump_error1(JSContext*, unsigned long long) src/jse/quickjs/jse_quickjs.cpp:602
    apache#14 0x59b03dd9 in jse_dump_error(JSContext*) src/jse/quickjs/jse_quickjs.cpp:591
    apache#15 0x59bed615 in ferry::DomComponent::callHook(char const*) src/framework/dom/component.cpp:65
    apache#16 0x59bfe0ff in ferry::DomComponent::initialize() src/framework/dom/component.cpp:645
    apache#17 0x59bb141d in dom_create_component(JSContext*, unsigned long long, unsigned long long, unsigned long long) (/home/wangbowen/project/central/vela_miot_bes_m0/bin/audio+0x365c41d)
    apache#18 0x59b4c0d3 in AIOTJS::__createComponent(JSContext*, unsigned long long, int, unsigned long long*) (/home/wangbowen/project/central/vela_miot_bes_m0/bin/audio+0x35f70d3)
    apache#19 0x5a56ec17 in js_call_c_function quickjs/quickjs.c:16108

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Sep 1, 2022
apps/examples/usrsocktest/usrsocktest_basic_daemon.c:

321 static void basic_daemon_dup2(FAR struct usrsocktest_daemon_conf_s *dconf)
322 {
...
335   ret = dup2(sd2, sd);
352 }

Usrsocktest Task hold the file group lock and send the close request to usrsock deamon :

| #0  net_lockedwait_uninterruptible (sem=0x5555555f8ba2 <g_usrsockdev+34>) at utils/net_lock.c:427
| #1  0x000055555557489c in usrsockdev_do_request (conn=0x5555555f8800 <g_usrsock_connections>, iov=0x7ffff3f36040, iovcnt=1) at usrsock/usrsock_dev.c:1185
|                           --> send close request to usrsock deamon
|
| #2  0x00005555555d0439 in do_close_request (conn=0x5555555f8800 <g_usrsock_connections>) at usrsock/usrsock_close.c:109
| #3  0x00005555555d04f5 in usrsock_close (conn=0x5555555f8800 <g_usrsock_connections>) at usrsock/usrsock_close.c:157
| #4  0x00005555555cf100 in usrsock_sockif_close (psock=0x7ffff3ea4a60) at usrsock/usrsock_sockif.c:234
| #5  0x00005555555c7b2f in psock_close (psock=0x7ffff3ea4a60) at socket/net_close.c:102
| #6  0x000055555557a518 in sock_file_close (filep=0x7ffff3f253d0) at socket/socket.c:115
| apache#7  0x000055555557678f in file_close (filep=0x7ffff3f253d0) at vfs/fs_close.c:74
| apache#8  0x000055555557694c in file_dup2 (filep1=0x7ffff3f253e8, filep2=0x7ffff3f253d0) at vfs/fs_dup2.c:129
|                           --->  hold group file list lock  ( _files_semtake(list) )
|
| apache#9  0x0000555555575aab in nx_dup2 (fd1=7, fd2=6) at inode/fs_files.c:451
| apache#10 0x0000555555575af3 in dup2 (fd1=7, fd2=6) at inode/fs_files.c:473
| apache#11 0x000055555559d937 in basic_daemon_dup2 (dconf=0x5555555f8d80 <usrsocktest_daemon_config>) at usrsocktest_basic_daemon.c:335
| apache#12 0x000055555559ed80 in usrsocktest_test_basic_daemon_basic_daemon_dup2 () at usrsocktest_basic_daemon.c:612
| apache#13 0x000055555559f18d in usrsocktest_group_basic_daemon_run () at usrsocktest_basic_daemon.c:666
| apache#14 0x0000555555599f8d in run_tests (name=0x5555555dc8c3 "basic_daemon", test_fn=0x55555559ef50 <usrsocktest_group_basic_daemon_run>) at usrsocktest_main.c:117
| apache#15 0x000055555559a06c in run_all_tests () at usrsocktest_main.c:154
| apache#16 0x000055555559a3d1 in usrsocktest_main (argc=1, argv=0x7ffff3f25450) at usrsocktest_main.c:248
| apache#17 0x000055555555cad8 in nxtask_startup (entrypt=0x55555559a357 <usrsocktest_main>, argc=1, argv=0x7ffff3f25450) at sched/task_startup.c:70
| apache#18 0x0000555555559938 in nxtask_start () at task/task_start.c:134

Usrsock Deamon weakup and setup the poll want to perform close request, but locked on fs_getfilep():

| #0  _files_semtake (list=0x7ffff3f250b8) at inode/fs_files.c:51
|                           --> Request group lock but which hold by close request, deadlock
| #1  0x00005555555758b1 in fs_getfilep (fd=5, filep=0x7ffff3f47190) at inode/fs_files.c:375
| #2  0x00005555555d3064 in poll_fdsetup (fd=5, fds=0x7ffff3f47290, setup=true) at vfs/fs_poll.c:79
| #3  0x00005555555d3243 in poll_setup (fds=0x7ffff3f47290, nfds=2, sem=0x7ffff3f47206) at vfs/fs_poll.c:139
| #4  0x00005555555d39a6 in nx_poll (fds=0x7ffff3f47290, nfds=2, timeout=-1) at vfs/fs_poll.c:383
| #5  0x00005555555d3abd in poll (fds=0x7ffff3f47290, nfds=2, timeout=-1) at vfs/fs_poll.c:501
|                           --> daemon weak up
| #6  0x00005555555c62c7 in usrsocktest_daemon (param=0x5555555f5360 <g_ub_daemon>) at usrsocktest_daemon.c:1846
| apache#7  0x000055555559161e in pthread_startup (entry=0x5555555c60d3 <usrsocktest_daemon>, arg=0x5555555f5360 <g_ub_daemon>) at pthread/pthread_create.c:59
| apache#8  0x00005555555d45f0 in pthread_start () at pthread/pthread_create.c:175
| apache#9  0x0000000000000000 in ?? ()

Signed-off-by: chao an <anchao@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Sep 1, 2022
==2117790==ERROR: AddressSanitizer: global-buffer-overflow on address 0x64d9e3c0 at pc 0x59ac4e16 bp 0xcefe8058 sp 0xcefe8048
READ of size 1 at 0x64d9e3c0 thread T0
    #0 0x59ac4e15 in up_nputs sim/up_nputs.c:54
    #1 0x59a67e4c in syslog_default_write syslog/syslog_channel.c:220
    #2 0x59a67823 in syslog_default_write syslog/syslog_write.c:101
    #3 0x59a67f10 in syslog_write syslog/syslog_write.c:153
    #4 0x59a651c3 in syslogstream_flush syslog/syslog_stream.c:60
    #5 0x59a6564e in syslogstream_addchar syslog/syslog_stream.c:104
    #6 0x59a6576f in syslogstream_putc syslog/syslog_stream.c:140
    #7 0x5989fc4d in vsprintf_internal stdio/lib_libvsprintf.c:952
    #8 0x598a1298 in lib_vsprintf stdio/lib_libvsprintf.c:1379
    #9 0x59a64ea4 in nx_vsyslog syslog/vsyslog.c:223
    #10 0x598a601a in vsyslog syslog/lib_syslog.c:68
    #11 0x59b0e3dc in AIOTJS::logPrintf(int, char const*, ...) src/ajs_log.cpp:45
    #12 0x59b03d56 in jse_dump_obj src/jse/quickjs/jse_quickjs.cpp:569
    #13 0x59b03ea1 in jse_dump_error1(JSContext*, unsigned long long) src/jse/quickjs/jse_quickjs.cpp:602
    #14 0x59b03dd9 in jse_dump_error(JSContext*) src/jse/quickjs/jse_quickjs.cpp:591
    #15 0x59bed615 in ferry::DomComponent::callHook(char const*) src/framework/dom/component.cpp:65
    #16 0x59bfe0ff in ferry::DomComponent::initialize() src/framework/dom/component.cpp:645
    #17 0x59bb141d in dom_create_component(JSContext*, unsigned long long, unsigned long long, unsigned long long) (/home/wangbowen/project/central/vela_miot_bes_m0/bin/audio+0x365c41d)
    #18 0x59b4c0d3 in AIOTJS::__createComponent(JSContext*, unsigned long long, int, unsigned long long*) (/home/wangbowen/project/central/vela_miot_bes_m0/bin/audio+0x35f70d3)
    #19 0x5a56ec17 in js_call_c_function quickjs/quickjs.c:16108

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Sep 1, 2022
apps/examples/usrsocktest/usrsocktest_basic_daemon.c:

321 static void basic_daemon_dup2(FAR struct usrsocktest_daemon_conf_s *dconf)
322 {
...
335   ret = dup2(sd2, sd);
352 }

Usrsocktest Task hold the file group lock and send the close request to usrsock deamon :

| #0  net_lockedwait_uninterruptible (sem=0x5555555f8ba2 <g_usrsockdev+34>) at utils/net_lock.c:427
| #1  0x000055555557489c in usrsockdev_do_request (conn=0x5555555f8800 <g_usrsock_connections>, iov=0x7ffff3f36040, iovcnt=1) at usrsock/usrsock_dev.c:1185
|                           --> send close request to usrsock deamon
|
| #2  0x00005555555d0439 in do_close_request (conn=0x5555555f8800 <g_usrsock_connections>) at usrsock/usrsock_close.c:109
| #3  0x00005555555d04f5 in usrsock_close (conn=0x5555555f8800 <g_usrsock_connections>) at usrsock/usrsock_close.c:157
| #4  0x00005555555cf100 in usrsock_sockif_close (psock=0x7ffff3ea4a60) at usrsock/usrsock_sockif.c:234
| #5  0x00005555555c7b2f in psock_close (psock=0x7ffff3ea4a60) at socket/net_close.c:102
| #6  0x000055555557a518 in sock_file_close (filep=0x7ffff3f253d0) at socket/socket.c:115
| #7  0x000055555557678f in file_close (filep=0x7ffff3f253d0) at vfs/fs_close.c:74
| #8  0x000055555557694c in file_dup2 (filep1=0x7ffff3f253e8, filep2=0x7ffff3f253d0) at vfs/fs_dup2.c:129
|                           --->  hold group file list lock  ( _files_semtake(list) )
|
| #9  0x0000555555575aab in nx_dup2 (fd1=7, fd2=6) at inode/fs_files.c:451
| #10 0x0000555555575af3 in dup2 (fd1=7, fd2=6) at inode/fs_files.c:473
| #11 0x000055555559d937 in basic_daemon_dup2 (dconf=0x5555555f8d80 <usrsocktest_daemon_config>) at usrsocktest_basic_daemon.c:335
| #12 0x000055555559ed80 in usrsocktest_test_basic_daemon_basic_daemon_dup2 () at usrsocktest_basic_daemon.c:612
| #13 0x000055555559f18d in usrsocktest_group_basic_daemon_run () at usrsocktest_basic_daemon.c:666
| #14 0x0000555555599f8d in run_tests (name=0x5555555dc8c3 "basic_daemon", test_fn=0x55555559ef50 <usrsocktest_group_basic_daemon_run>) at usrsocktest_main.c:117
| #15 0x000055555559a06c in run_all_tests () at usrsocktest_main.c:154
| #16 0x000055555559a3d1 in usrsocktest_main (argc=1, argv=0x7ffff3f25450) at usrsocktest_main.c:248
| #17 0x000055555555cad8 in nxtask_startup (entrypt=0x55555559a357 <usrsocktest_main>, argc=1, argv=0x7ffff3f25450) at sched/task_startup.c:70
| #18 0x0000555555559938 in nxtask_start () at task/task_start.c:134

Usrsock Deamon weakup and setup the poll want to perform close request, but locked on fs_getfilep():

| #0  _files_semtake (list=0x7ffff3f250b8) at inode/fs_files.c:51
|                           --> Request group lock but which hold by close request, deadlock
| #1  0x00005555555758b1 in fs_getfilep (fd=5, filep=0x7ffff3f47190) at inode/fs_files.c:375
| #2  0x00005555555d3064 in poll_fdsetup (fd=5, fds=0x7ffff3f47290, setup=true) at vfs/fs_poll.c:79
| #3  0x00005555555d3243 in poll_setup (fds=0x7ffff3f47290, nfds=2, sem=0x7ffff3f47206) at vfs/fs_poll.c:139
| #4  0x00005555555d39a6 in nx_poll (fds=0x7ffff3f47290, nfds=2, timeout=-1) at vfs/fs_poll.c:383
| #5  0x00005555555d3abd in poll (fds=0x7ffff3f47290, nfds=2, timeout=-1) at vfs/fs_poll.c:501
|                           --> daemon weak up
| #6  0x00005555555c62c7 in usrsocktest_daemon (param=0x5555555f5360 <g_ub_daemon>) at usrsocktest_daemon.c:1846
| #7  0x000055555559161e in pthread_startup (entry=0x5555555c60d3 <usrsocktest_daemon>, arg=0x5555555f5360 <g_ub_daemon>) at pthread/pthread_create.c:59
| #8  0x00005555555d45f0 in pthread_start () at pthread/pthread_create.c:175
| #9  0x0000000000000000 in ?? ()

Signed-off-by: chao an <anchao@xiaomi.com>
Shunichi-K referenced this pull request in SPRESENSE/nuttx Nov 7, 2022
Author: Gregory Nutt <gnutt@nuttx.org>

    Run all .c and .h modified in PR through nxstyle.

Author: Masayuki Ishikawa <masayuki.ishikawa@gmail.com>

    feature k210 (#16)

    * arch: risc-v: Add support for __LP64__ to types.h
    * arch: risc-v: Add support for RV64GC to common files
    * arch: risc-v: Add support for Kendryte K210 processor (RV64GC)
    * boards: risk-v: Add support for Sipeed Maix Bit with K210
    * tools: Add support for Kendryte K210 processor

(cherry picked from commit e33fc3d)

Conflicts:
	tools/refresh.sh
	tools/testbuild.sh
anchao added a commit to anchao/nuttx that referenced this pull request Jan 10, 2023
tg_info is still in use after task_uninit_info() unifies
lib_stream_* with life cycle of task info to avoid this issue.

|apache#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|apache#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|apache#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|apache#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|apache#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|apache#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|apache#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|apache#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|apache#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|apache#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|apache#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|apache#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|apache#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|apache#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Jan 10, 2023
tg_info is still in use after task_uninit_info() unifies
lib_stream_* with life cycle of task info to avoid this issue.

| ==1940861==ERROR: AddressSanitizer: heap-use-after-free on address 0xf47032e0 at pc 0x5676dc4f bp 0xf2f38c68 sp 0xf2f38c58
|
|apache#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|apache#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|apache#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|apache#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|apache#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|apache#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|apache#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|apache#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|apache#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|apache#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|apache#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|apache#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|apache#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|apache#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Jan 10, 2023
tg_info is still in use after task_uninit_info(), unifies
lib_stream_* with life cycle of task info to avoid this issue.

| ==1940861==ERROR: AddressSanitizer: heap-use-after-free on address 0xf47032e0 at pc 0x5676dc4f bp 0xf2f38c68 sp 0xf2f38c58
|
|apache#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|apache#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|apache#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|apache#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|apache#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|apache#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|apache#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|apache#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|apache#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|apache#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|apache#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|apache#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|apache#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|apache#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Jan 10, 2023
tg_info is still in use after task_uninit_info(), unifies
lib_stream_* with life cycle of task info to avoid this issue.

| ==1940861==ERROR: AddressSanitizer: heap-use-after-free on address 0xf47032e0 at pc 0x5676dc4f bp 0xf2f38c68 sp 0xf2f38c58
|
|#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
chenzhihong007 pushed a commit to hpmicro/nuttx that referenced this pull request Mar 8, 2023
tg_info is still in use after task_uninit_info(), unifies
lib_stream_* with life cycle of task info to avoid this issue.

| ==1940861==ERROR: AddressSanitizer: heap-use-after-free on address 0xf47032e0 at pc 0x5676dc4f bp 0xf2f38c68 sp 0xf2f38c58
|
|apache#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|apache#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|apache#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|apache#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|apache#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|apache#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|apache#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|apache#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|apache#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|apache#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|apache#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|apache#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|apache#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|apache#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
chenzhihong007 pushed a commit to hpmicro/nuttx that referenced this pull request Aug 1, 2023
- add  pwm driver
Signed-off-by: Runcheng Lu <runcheng.lu@hpmicro.com>
anchao added a commit to anchao/nuttx that referenced this pull request Nov 6, 2023
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| #1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| #2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| #3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| #4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| #5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| #6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| apache#7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| apache#8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| apache#9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| apache#10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| apache#11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| apache#12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| apache#13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| apache#14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| apache#15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| apache#16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| apache#17 0x020b363c in nxtask_start () at task/task_start.c:134

Change-Id: I6996b4f7891e9e4452f3182f42360b66bdbc2d4c
Signed-off-by: chao an <anchao@xiaomi.com>
anchao added a commit to anchao/nuttx that referenced this pull request Nov 6, 2023
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| #1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| #2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| #3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| #4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| #5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| #6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| apache#7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| apache#8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| apache#9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| apache#10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| apache#11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| apache#12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| apache#13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| apache#14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| apache#15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| apache#16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| apache#17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Nov 7, 2023
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| #1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| #2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| #3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| #4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| #5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| #6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| #7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| #8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| #9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| #10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| #11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| #12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| #13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| #14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| #15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| #16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| #17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
freakishness pushed a commit to freakishness/incubator-nuttx that referenced this pull request Feb 18, 2024
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| #1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| #2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| #3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| #4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| #5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| #6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| apache#7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| apache#8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| apache#9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| apache#10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| apache#11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| apache#12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| apache#13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| apache#14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| apache#15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| apache#16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| apache#17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
chenzhihong007 pushed a commit to hpmicro/nuttx that referenced this pull request Feb 23, 2024
- add  pwm driver
Signed-off-by: Runcheng Lu <runcheng.lu@hpmicro.com>
halyssonJr pushed a commit to halyssonJr/nuttx that referenced this pull request Apr 10, 2024
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| apache#1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| apache#2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| apache#3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| apache#4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| apache#5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| apache#6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| apache#7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| apache#8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| apache#9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| apache#10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| apache#11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| apache#12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| apache#13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| apache#14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| apache#15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| apache#16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| apache#17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <anchao@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants