Commit Graph

1135 Commits

Author SHA1 Message Date
simbit18
934814aba1 arch/sim/Kconfig: Fix indentation
Remove spaces from Kconfig
2023-05-10 00:45:29 +08:00
chao an
bebddf3981 sim/asan: disable detect_invalid_pointer_pairs/detect_stack_use_after_return
These 2 detections will have some false positives in coroutine environment

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-09 20:59:41 +08:00
Xiang Xiao
325f395300 Replace all strncpy with strlcpy
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-08 09:57:01 +02:00
hujun5
0f243bde33 arch: fix the issue of asynchronous signal processing
in SMP, signal processing cannot be nested, we use xcp.sigdeliver to identify whether there is currently a signal being processed, but this state does not match the actual situation
One possible scenario is that signal processing has already been completed, but an interrupt occurs, resulting in xcp.sigdeliver not being correctly set to NULL,
At this point, a new signal arrives, which can only be placed in the queue and cannot be processed immediately
Our solution is that signal processing and signal complete status are set in the same critical section, which can ensure status synchronization

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-05-08 09:11:14 +02:00
Xiang Xiao
49fa611fad boards/sim: Enable more sanitizer check when enable
to catch more runtime usage error

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-06 09:09:36 +03:00
zhangyuan21
91d34ffd09 arch/sim: add up_getusrsp for sim
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-05-05 13:40:04 +08:00
fangxinyong
06f8875c0c arch/sim: do not free memory of zero-length reallocation
Follow the change: https://github.com/apache/nuttx/pull/9151,
if MM_CUSTOMIZE_MANAGER is enabled, heap memory manager in host is used,
for example in sim:asan build.

malloc and related allocation APIs will fall back to host_realloc,
do not free memory of zero-length reallocation. So memory allocations
return valid pointer when request zero size in all sim build.

call stack:
    malloc()         (mm/umm_heap/umm_malloc.c)
    mm_malloc()      (arch/sim/src/sim/sim_heap.c)
    mm_realloc()     (arch/sim/src/sim/sim_heap.c)
    host_realloc()   (arch/sim/src/sim/posix/sim_hostmemory.c)
    host_memalign()  (arch/sim/src/sim/posix/sim_hostmemory.c)

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-05-05 00:19:28 +08:00
chao an
1be95c3313 sim/lsan: disable fast-unwind by default
The fast-unwind implementation of leak-sanitizer will obtain the
current stack top/bottom and frame address(Stack Pointer) for
backtrace calculation:

https://github.com/gcc-mirror/gcc/blob/releases/gcc-13/libsanitizer/lsan/lsan.cpp#L39-L42

Since the scheduling mechanism of NuttX sim is coroutine
(setjmp/longjmp), if the Stack Pointer is switched, the fast-unwind
will unable to get the available address, so the memory leaks on the
system/application side that cannot be caught normally. This PR will
disable fast-unwind by default to avoid unwind failure.

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-04 18:05:22 +03:00
chao an
8687fe1b9f sim/usbdev: fix unpaired critical_section() 2023-04-27 00:31:31 +08:00
Huang Qi
3d3a86ae53 arch/sim: Move up_textheap_xxx to common place
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-04-24 19:37:15 +08:00
Huang Qi
97f8817d6b arch/sim: Implement host_freeheap for windows
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-04-24 19:37:15 +08:00
Huang Qi
70395f49b2 arch/sim: Implement text heap
If CONFIG_MM_CUSTOMIZE_MANAGER enabled on sim, malloc/mmap is bypassed to glibc, so the memory allocated without execution permisson.

For this case, CONFIG_ARCH_USE_TEXT_HEAP can be used.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-04-24 10:29:20 +08:00
zhanghongyu
50488ac8f3 sim: multi netdevice forward issue when ll_guardsize not 14
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-04-23 10:37:50 +03:00
zhanghongyu
37644c8818 Revert "sim: multi netdevice forward issue when ll_guardsize not 14"
This reverts commit a69c6c1dac.
2023-04-23 10:37:50 +03:00
zhanghongyu
a69c6c1dac sim: multi netdevice forward issue when ll_guardsize not 14
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-04-22 01:41:01 +08:00
Zhe Weng
f21742899f net/netdev: Use upper half of netdev to simplify sim driver
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-04-22 01:41:01 +08:00
chao an
899be58905 sim/win/hostfs: set O_BINARY for windows hostfs as default
Since the initial default setting in MSVC is text mode ( O_TEXT ):

https://learn.microsoft.com/en-us/cpp/c-runtime-library/text-and-binary-mode-file-i-o?view=msvc-170

In order to unify the translation behavior with unix,
1. set O_BINARY for hostfs as default
2. enable default text mode if the application specifies flag O_TEXT

Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-19 02:55:15 +08:00
chao an
49c863f238 sim/win/hostuart: only read key event from console
This commit will detect input events and filter out events(mouse/window/etc) other than key

Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-19 02:52:16 +08:00
yinshengkai
b705d9b1d5 sim: switch working directory
If this option is enabled, the working path of nuttx will be modified to the folder where the nuttx file is located.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-04-17 16:48:52 +08:00
chao an
3f05df3fbb sim/win/hosttime: calculate sec/ms independently to avoid overflow
In the previous implementation, PerformanceCounter would cause overflow
after running for a long time, This commit will separate the calculation
of the sec/ms part to avoid this issue, Reference:

https://github.com/cygwin/cygwin/blob/main/winsup/cygwin/clock.cc#L194-L217

Signed-off-by: chao an <anchao@xiaomi.com>
2023-04-12 08:38:34 +02:00
pengyiqiang
961b86642a sim_x11eventloop: fix X11 event accumulation
sim_x11events should process all x11 events in each event loop,
otherwise it will cause events to accumulate in the queue and affect the interaction.

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
2023-04-06 10:24:17 -03:00
Xiang Xiao
901cd599b1 arch: Remove MIN macro definition
use the definition from sys/param.h instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-22 17:26:37 -03:00
Shoukui Zhang
947100c5b8 sim: Fix iic/spi bus open failed
when CONFIG_SIM_I2CBUS or CONFIG_SIM_SPI enabled,the iic/spi
bus will report open failed

Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
2023-03-20 14:17:35 +01:00
xinbingnan
14d1f3b995 sim_linuxi2c: fix snprintf parameter
use `sizeof` instead of constant number

Signed-off-by: xinbingnan <xinbingnan@xiaomi.com>
2023-03-20 10:18:44 +01:00
dongjiuzhu1
baa10ee047 sim/uart_ioctl: return -ENOTTY for cmd which don't support
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-03-17 11:48:58 -03:00
zhangyuan21
12bb4f04f1 arch: fixed error in the calculation of nwords caused an out of bounds
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-03-13 16:12:11 +09:00
Petro Karashchenko
4581a84064 nuttx: fix indentation issue
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-03-09 16:27:07 -03:00
Zhe Weng
0e018308a3 net/pkt: Add readahead queue for pkt, call input for tx on sim
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-03-08 23:09:25 +02:00
zhangyuan21
0af63cfc48 sim/usb: add sim usb host
signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-03-03 14:31:30 -03:00
zhangyuan21
c61c694a77 sim/usb: add sim usb device
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-03-03 14:31:30 -03:00
Xiang Xiao
8b4ecac6c2 libc: Move math library from libs/libc/math to libs/libm/libm
to prepare the support of other implementation e.g.:
https://github.com/JuliaMath/openlibm
https://gitlab.com/gtd-gmbh/libmcs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-23 10:40:07 +02:00
Jackson R
37db965cff This simulator was tested on ARM MacBook.
Updating Simulator for macOS

macOS requires genromfs and X11 Libraries to run Simulators.
* Added instructions to install genromfs
* Added instructions to install X11
Adding Xorg Server

The linker was unable to identify the location of X11 libraries.

removed -L/opt/X11/lib from ln 145

Updating Changes to streamline with other Hosts
2023-02-16 09:27:54 +08:00
chao an
1e7014262c sim/windows: fix build break on visual studio
1. fix build break on visual studio
2. enable more net config

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-13 20:37:25 +08:00
ligd
87a92d995f sim: fix nuttx consumes much CPU time
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-13 18:41:43 +09:00
ligd
758668d11a sim: remove sim_saveusercontext() return value
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-13 18:41:43 +09:00
ligd
7e3e99c940 sim: fix vfork report error
user_main: vfork() test
=================================================================
==3754757==ERROR: AddressSanitizer: stack-buffer-underflow on address 0xae9126f0 at pc 0x56845661 bp 0xae912570 sp 0xae912560
READ of size 1 at 0xae9126f0 thread T0
    #0 0x56845660 in memcpy string/lib_memcpy.c:44
    #1 0x56b70f61 in up_vfork sim/sim_vfork.c:133
    #2 0x567c0b85 in vfork (/home/ligd/platform/sim/nuttx/nuttx+0x26bb85)

0xae9126f0 is located 73456 bytes inside of 73728-byte region [0xae900800,0xae912800)
allocated by thread T0 here:
    #0 0xf7ab1c2f in __interceptor_posix_memalign ../../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:226

SUMMARY: AddressSanitizer: stack-buffer-underflow string/lib_memcpy.c:44 in memcpy

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-12 02:37:25 +08:00
ligd
1cc6e4b1fa sim: add uart dma mode & use work instead of loop.
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-10 13:54:42 +08:00
Peter Bee
2ebccd82b6 drivers/video: add timestamp support
Add support for timestamp and change in related drivers

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2023-02-09 23:27:15 +08:00
chao an
3a0fdb019d nuttx: replace all ARRAY_SIZE()/ARRAYSIZE() to nitems()
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:05:44 +08:00
ligd
9b35a2e1a1 sim: fix compile warning
sim/sim_doirq.c: In function 'sim_doirq':
Error: sim/sim_doirq.c:79:10: error: function may return address of local variable [-Werror=return-local-addr]
   79 |   return regs;
      |          ^~~~
sim/sim_doirq.c:44:14: note: declared here
   44 |   xcpt_reg_t tmp[XCPTCONTEXT_REGS];
      |              ^~~

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-09 14:22:38 +08:00
ligd
16367aa084 sim: correct save irq flags error when use sim 64bits
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-09 14:22:38 +08:00
ligd
8aecad287c sim: set loop task duration to 10ms
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-09 14:19:09 +08:00
ligd
f102837fe1 sim: realize sim timer tickless
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-09 14:19:09 +08:00
ligd
24cdcd9a6e sim: fix kasan report memalign crash when alignment is 1
(0)Allocating 3 bytes aligned to 0x00000001
=================================================================
==1461685==ERROR: AddressSanitizer: invalid alignment requested in posix_memalign: 1, alignment must be a power of two and a multiple of sizeof(void*) == 4 (thread T0)
    #0 0xf7ab1c2f in __interceptor_posix_memalign ../../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:226

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-08 20:37:43 +08:00
ligd
8d0094f6c9 sim: fix color running stack crash when use -Os
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-08 20:37:43 +08:00
qiaohaijiao1
b6472b8b15 sim/sim_alsa: add audio offload capture support.
use host liblame as encoder.

Signed-off-by: qiaohaijiao1 <qiaohaijiao1@xiaomi.com>
2023-02-08 13:55:17 +08:00
chao an
edfae1fe21 sim/hcisocket: correct teardown device index
Parameter of HCIDEVDOWN should be the corresponding device id, not 0

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-03 23:22:54 +08:00
Xiang Xiao
09841300b0 Remove the remain MIN/MAX like macro
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-03 20:42:57 +08:00
ligd
3ae4a6b8c3 sim/uart: do uart_xmitchars() when tty_txint enabled
to speed up the logout speed

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-02 18:27:39 +08:00
chao an
03b164f59c tools/makefile: silent all compile output
In order to make compilation warnings and errors easier to be found out,
this commit will disable the printing of the compilation process as much
as possible, and also if you want to restore the log information of the
compilation process, please enable verbose build on command line:

$ make V=0
OR
$ make V=1

| V=0:   Exit silent mode
| V=1,2: Enable echo of commands
| V=2:   Enable bug/verbose options in tools and scripts

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-02 17:40:19 +08:00