Commit Graph

22467 Commits

Author SHA1 Message Date
chenxiaoyi
835aac23b7 sim: change the type of xcpt_reg_t
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
753e4d64ee sim/irq: fix windows64 build error
nuttx\vs2022\include\arch\irq.h(144,9): error C2065: 'mov': undeclared identifier

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
d309d49cae sim/types: fix windows64 build error
nuttx\include\sys\types.h(133,22): error C2371: 'size_t': redefinition; different basic types

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
dongjiuzhu1
3b0e2be058 binfmt/modlib: support loading each sections to different memory for Relocate object
The feature depends on ARCH_USE_SEPARATED_SECTION
the different memory area has different access speed and cache
capability, so the arch can custom allocate them based on
section names to achieve performance optimization

test:
sim:elf
sim:sotest

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-08 23:51:33 +08:00
Ville Juven
10e44f8915 riscv_fork.c: Fix race condition when handling parent integer registers
We need to record the parent's integer register context upon exception
entry to a separate non-volatile area. Why?

Because xcp.regs can move due to a context switch within the fork() system
call, be it either via interrupt or a synchronization point.

Fix this by adding a "sregs" area where the saved user context is placed.
The critical section within fork() is also unnecessary.
2024-10-03 09:07:57 +08:00
Ville Juven
2d3c94411b riscv_fork.c: Fix vfork() for kernel mode + SMP
There was an error in the fork() routine when system calls are in use:
the child context is saved on the child's user stack, which is incorrect,
the context must be saved on the kernel stack instead.

The result is a full system crash if (when) the child executes on a
different CPU which does not have the same MMU mappings active.
2024-10-03 09:07:57 +08:00
hujun5
d1fec65e1b riscv: use g_running_task store current regs
This commit fixes the regression from https://github.com/apache/nuttx/pull/13561

In order to determine whether a context switch has occurred,
we can use g_running_task to store the current regs.
This allows us to compare the current register state with the previously
stored state to identify if a context switch has taken place.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-03 09:07:48 +08:00
chenrun1
ab4d72756e arch/samd2l2:Ignore atomic warning when using clang compiler
When the toolchain does not support atomic, it will use the version implemented by NuttX (low performance version). This scenario is consistent with the original design, so we can ignore it.

see bug here:
https://bugs.llvm.org/show_bug.cgi?id=43603

Error: inode/fs_inodeaddref.c:50:7: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0  bytes) [-Werror,-Watomic-alignment]
   50 |       atomic_fetch_add(&inode->i_crefs, 1);
      |       ^
/tools/clang-arm-none-eabi/lib/clang/17/include/stdatomic.h:152:43: note: expanded from macro 'atomic_fetch_add'
  152 | #define atomic_fetch_add(object, operand) __c11_atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST)
      |                                           ^
1 error generated.
make[1]: *** [Makefile:83: fs_inodeaddref.o] Error 1
Error: inode/fs_inodefind.c:74:7: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0  bytes) [-Werror,-Watomic-alignment]
   74 |       atomic_fetch_add(&node->i_crefs, 1);

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-23 14:07:03 +08:00
chenrun1
4cec713dbf fs_inode:Change the type of i_crefs to atomic_int
Summary:
  1.Modified the i_crefs from int16_t to atomic_int
  2.Modified the i_crefs add, delete, read, and initialize interfaces to atomic operations
The purpose of this change is to avoid deadlock in cross-core scenarios, where A Core blocks B Core’s request for a write operation to A Core when A Core requests a read operation to B Core.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-23 14:07:03 +08:00
hujun5
e4a0470527 riscv: add a return value to riscv_swint indicating whether a context switch is required
This commit fixes the regression from https://github.com/apache/nuttx/pull/13561

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-22 09:38:26 -03:00
Ville Juven
10b40abecc arm64_task/pthread_start: Convert the C / inline ASM code to assembly
The aforementioned functions can/will fail if the C compiler decides
to use the stack for the incoming entrypt/etc. parameters.

Fix this issue by converting the jump to user part into pure assembly,
ensuring the stack is NOT used for the parameters.
2024-09-21 23:24:02 +08:00
Ville Juven
6e15994f4c arm64_addrenv: Add support for 4 level MMU translations
The original code made the incorrect assumption that the amount of
translation levels is 3, but this is incorrect. The amount of levels is 4
and the amount of levels that are utilized / in use is set dynamically
from the amount of VA bits in use.
2024-09-21 08:36:23 -03:00
Ville Juven
a559f3495a arm64_addrenv: Fix the amount of page table levels
The VMSAv8-64 translation system has 4 page table levels in total, ranging
from 0-3. The address environment code assumes only 3 levels, from 1-3 but
this is wrong; the amount of levels _utilized_ depends on the configured
VA size CONFIG_ARM64_VA_BITS. With <= 39 bits 3 levels is enough, while
if the va range is larger, the 4th translation table level is taken into
use dynamically by shifting the base translation table level.

From arm64_mmu.c, where va_bits is the amount of va bits used in address
translations:
(va_bits <= 21)       - base level 3
(22 <= va_bits <= 30) - base level 2
(31 <= va_bits <= 39) - base level 1
(40 <= va_bits <= 48) - base level 0

The base level is what is configured as the page directory root. This also
affects the performance of address translations i.e. if the VA range is
smaller, address translations are also faster as the page table walk is
shorter.
2024-09-21 08:36:23 -03:00
Tiago Medicci Serrano
72acec7275 esp32s3: Fix faulty esp32s3-devkit:stack example
This defconfig is an example of the recorded stack and it became
faulty recently after the implementation of the `up_current_regs`
functions. The `noinstrument_function` directive must be used for
preventing it from being looped when instrumentation is enabled.
Also, this commit places `sched/instrument/stack_record.c` in IRAM.
2024-09-21 10:42:06 +08:00
hujun5
c5ecc49c10 riscv: g_current_regs is only used to determine if we are in irq,
with other functionalities removed.

reason:
  by doing this we can reduce context switch time,
  When we exit from an interrupt handler, we directly use tcb->xcp.regs

before
   text    data     bss     dec     hex filename
 138805     337   24256  163398   27e46 nuttx

after
   text    data     bss     dec     hex filename
 138499     337   24240  163076   27d04 nuttx

 szie change -322
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-21 02:59:57 +08:00
wangmingrong1
469418f3c9 mm/kasan: Kasan global support setting alignment length
1. Similar to asan, supports single byte out of bounds detection
2. Fix the script to address the issue of not supporting the big end

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-09-20 21:47:23 +08:00
wangmingrong1
071af0c993 mm/kasan: Tag kasan and generic kasan use the same instrumentation options
1. Tested on QEMU, the two sockets were basically the same, and their performance was not affected. The size of the generated bin file was also the same
2. Extract global detection as a separate file, both types of Kasan support global variable out of bounds detection simultaneously

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-09-20 21:47:23 +08:00
wangjianyu3
b14b15ac2d nrf91: Update GPS to GNSS
Related: 03f4ec7765ed8b3551f1a2bc8198c5007a542788

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-09-20 14:38:43 +08:00
simbit18
6a0c0722e2 CI: Improvement to speed up compilation and reduce download errors.
The simple improvement is designed to speed up compilation and reduce download errors on github and local.

Added a folder nxtmpdir for storing third-party packages

nuttxworkspace
|
|- nuttx
|- apps
|- nxtmpdir

tools/Unix.mk:
added export NXTMPDIR := $(WSDIR)/nxtmpdir

tools/configure.sh:
added option -S creates the nxtmpdir folder for third-party packages.

tools/Config.mk:
added macro
CLONE - Git clone repository.
CHECK_COMMITSHA - Check if the branch contains the commit SHA-1.

tools/testbuild.sh:
added option -S

For now I added in the folder this package

ESP_HAL_3RDPARTY_URL = https://github.com/espressif/esp-hal-3rdparty.git

ARCH
arch/xtensa/src/esp32/Make.defs
arch/xtensa/src/esp32s2/Make.defs
arch/xtensa/src/esp32s3/Make.defs
arch/risc-v/src/common/espressif/Make.defs
arch/risc-v/src/esp32c3-legacy/Make.defs

but you can also add other packages (maybe also of apps)
2024-09-20 11:26:01 +08:00
Stuart Ianna
b60a8b216b arch/risc-v/src/litex_ticked: Set initial tick count to known value.
The tick count should be manually set as there is no guarantee that the
previous boot stage hasn't modified this count since reset.
2024-09-20 10:51:45 +08:00
chao an
b82717b9e6 arm/cortex-a,r: replace cp15 instruct to macros to align operation
This is continue work of https://github.com/apache/nuttx/pull/13486

Discussion here:
https://github.com/apache/nuttx/pull/13486#discussion_r1764354675

1. move cp15.h to arch public
2. replace cp15 instruct to macros to align operation
3. add memory barrier to avoid compiler optimization

Signed-off-by: chao an <anchao@lixiang.com>
2024-09-20 09:29:57 +08:00
Petro Karashchenko
f0267bc507 arch/arm/samv7: add support of SocketLIN interface
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-09-19 09:39:54 +08:00
hujun5
0561b55860 arm: optimize up_interrupt_context used in armv[6/7/8]-m
resson:
using percpu storage for g_current_regs or leveraging interrupt status
registers to determine if code is running within an interrupt context can enhance performance.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-19 08:30:09 +08:00
hujun5
6a3a32b185 arch: move up_interrupt_context to arch specific irq.h
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-19 08:30:09 +08:00
hujun5
a754c517cc irq: use per-cpu reg to replace g_current_regs
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-19 08:30:09 +08:00
yinshengkai
f326f15b40 sched: move DUMP_ON_EXIT to sched
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-09-19 03:49:12 +08:00
wangmingrong
ae3facda53 kasan: Implementation of Kasan based on software tags.
Currently, only aarch64 is supported

Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
2024-09-19 03:15:29 +08:00
Xiang Xiao
f76c2ed83b can: Add g_ prefix to can_dlc_to_len and len_to_can_dlc.
detail: Add g_ prefix to can_dlc_to_len and len_to_can_dlc to
follow NuttX coding style conventions for global symbols,
improving code readability and maintainability.

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
2024-09-18 23:50:11 +08:00
wanggang26
ae95623b8d arm_addrenv:fix app crash when enable shm in kernel mode
Hello, World!!
ap> [    2.566000] [ 1] arm_addrenv_destroy_region: listlen=1
vaddr=80000000
[    2.566000] [ 1] gran_free: granmask:0xfff, gatmask:0x10000,
gatidx:0x8, priv->gat[gatidx]:0xffffffff granno:0x110 [mem:0x48110000
free_size:0x1000]
[    2.566000] [ 1] gran_free: granmask:0xfff, gatmask:0x8000,
gatidx:0x8, priv->gat[gatidx]:0xfffeffff granno:0x10f [mem:0x4810f000
free_size:0x1000]
[    2.567000] [ 1] arm_addrenv_destroy_region: listlen=1 vaddr=80100000
[    2.567000] [ 1] gran_free: granmask:0xfff, gatmask:0x40000,
gatidx:0x8, priv->gat[gatidx]:0xfffe7fff granno:0x112 [mem:0x48112000
free_size:0x1000]
[    2.567000] [ 1] gran_free: granmask:0xfff, gatmask:0x20000,
gatidx:0x8, priv->gat[gatidx]:0xfffa7fff granno:0x111 [mem:0x48111000
free_size:0x1000]
[    2.568000] [ 1] arm_addrenv_destroy_region: listlen=1 vaddr=80200000
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x100000,
gatidx:0x8, priv->gat[gatidx]:0xfff87fff granno:0x114 [mem:0x48114000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x200000,
gatidx:0x8, priv->gat[gatidx]:0xffe87fff granno:0x115 [mem:0x48115000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x400000,
gatidx:0x8, priv->gat[gatidx]:0xffc87fff granno:0x116 [mem:0x48116000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x800000,
gatidx:0x8, priv->gat[gatidx]:0xff887fff granno:0x117 [mem:0x48117000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x1000000,
gatidx:0x8, priv->gat[gatidx]:0xff087fff granno:0x118 [mem:0x48118000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x2000000,
gatidx:0x8, priv->gat[gatidx]:0xfe087fff granno:0x119 [mem:0x48119000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x4000000,
gatidx:0x8, priv->gat[gatidx]:0xfc087fff granno:0x11a [mem:0x4811a000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x8000000,
gatidx:0x8, priv->gat[gatidx]:0xf8087fff granno:0x11b [mem:0x4811b000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x10000000,
gatidx:0x8, priv->gat[gatidx]:0xf0087fff granno:0x11c [mem:0x4811c000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x20000000,
gatidx:0x8, priv->gat[gatidx]:0xe0087fff granno:0x11d [mem:0x4811d000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x40000000,
gatidx:0x8, priv->gat[gatidx]:0xc0087fff granno:0x11e [mem:0x4811e000
free_size:0x1000]
[    2.568000] [ 1] gran_free: granmask:0xfff, gatmask:0x80000000,
gatidx:0x8, priv->gat[gatidx]:0x80087fff granno:0x11f [mem:0x4811f000
free_size:0x1000]
[    2.574000] [ 1] gran_free: granmask:0xfff, gatmask:0x80000,
gatidx:0x8, priv->gat[gatidx]:0x87fff granno:0x113 [mem:0x48113000
free_size:0x1000]
[    2.574000] [ 1] arm_addrenv_destroy_region: listlen=1 vaddr=80300000
[    2.574000] [ 1] gran_free: granmask:0xfff, gatmask:0x80000,
gatidx:0x8, priv->gat[gatidx]:0x7fff granno:0x113 [mem:0x48113000
free_size:0x1000]
[    2.575000] [ 1] _assert: Current Version: NuttX  0.0.0
fa1e301238-dirty Apr 16 2024 23:18:10 arm
[    2.575000] [ 1] _assert: Assertion failed : at file:
mm_gran/mm_granfree.c:131 task: lpwork process: Kernel 0x602769

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-17 15:26:42 -03:00
Huang Qi
6695affe87 risc-v: Add a new option to control exception reason
The number of exception for risc-v is 16 (0 ~ 15)
for the machine ISA version 1.12 or earlier, the number of exception is 20
(0 ~ 19) from the ISA version 1.13. And maybe changed in the future.

Using a dedicated option to control the exception number to allow the earlier
version chip with customized exception number (e.g. 16 ~ 19 used) to define
the exception reason string correctly.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-09-17 15:26:06 -03:00
simbit18
583f025422 Fix Kconfig style
Remove spaces from Kconfig files
Add TABs
Replace help => ---help---
2024-09-17 22:16:41 +08:00
SPRESENSE
237087f61a arch: cxd56xx: Fix issue by update of inode reference
Fix an issue of driver open failure caused by the following commit
that changes the initial value of inode reference.

43d0d95f81 fs/inode: using inode reference to indicate unlink and simply code
2024-09-17 20:13:15 +08:00
wanggang26
a6c3de6e89 goldfish:add kernel mode support
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-17 20:10:13 +08:00
wanggang26
02287a2976 shm:fix build error
after enable both CONFIG_BUILD_KERNEL and CONFIG_ARCH_VMA_MAPPING
arch.h:141:18: error: 'ARCH_SHM_MAXPAGES' undeclared here

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-17 20:09:39 +08:00
p-szafonimateusz
92cbb63fc8 arch/x86_64: add basic support for R_X86_64_REX_GOTPCRELX relocation
GOTPCRELX reloc available only for CONFIG_ARCH_ADDRENV=y

when CONFIG_ARCH_ADDRENV is not set, CONFIG_ARCH_TEXT_VBASE is not specified
so we can't relocate

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2024-09-17 03:20:03 +08:00
hujun5
c16fd8c911 gicv2:g_gic_init_done need to be protect
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-16 10:30:41 +08:00
ligd
cd88cb1e48 armv7-a/r: check gic init wait done when using sgi
In SMP mode, qemu/goldfish platform, cpu0 use up_cpu_start()
to start others cpus.

But in previous patch(mathion ahead), arm_gic_initialize() will
wait others cpus start, so deadlocked!

Resolve:
Move the wait logic when use using sgi

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-16 10:30:41 +08:00
Bowen Wang
4f5b3f3d82 arm_gicv2: always enable GIC_ICCICRS_ACKTCTL
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-16 10:30:41 +08:00
Bowen Wang
7f0ab52b12 arm_gicv2: cpu 0 wait other cpu gic init done
After move the SGI irq to group1, other cpu can't response the
sgi request from cpu0 when its gic not initialized.
So let cpu0 wait until all other cpus gic initialize done.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-16 10:30:41 +08:00
ligd
4358eba13a armv7-a/r: export __start symbol
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-16 10:30:41 +08:00
ligd
07b55cf7ab armv7-a/r: set up_cpu_start() to wakefunction
cause some platform will have their special way

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-16 10:30:41 +08:00
Masayuki Ishikawa
df298c186f Revert "build depend:Revert Make.dep intermediate ddc file"
This reverts commit ddc3119c4e.
2024-09-15 19:29:47 +08:00
wanggang26
2c24e5b430 arch/arm-m: Clear lr before jump to __start
to fix issue about https://github.com/apache/nuttx/issues/12687

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-15 17:31:12 +08:00
Kevin Zhou
d6ae4a0342 xtensa/esp32s3: Adjust I2C clock timing 2024-09-15 10:23:19 +08:00
xuxin19
ddc3119c4e build depend:Revert Make.dep intermediate ddc file
Revert "Parallelize depend file generation"
This reverts commit d5b6ec450f.

parallel depend ddc does not significantly speed up compilation,
intermediately generated .ddc files can cause problems if compilation is interrupted unexpectedly

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-09-15 10:01:58 +08:00
xuxin19
ab488800bb cmake:enhance the module for adding extra libraries
change the extra library from a file to an import target;
this will avoid differences in the handling of static libraries
between different versions of cmake and different platforms.

after unifying as a target, extra libraries can be
handled as the same as other compiled libraries

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-09-15 10:01:07 +08:00
p-szafonimateusz
2890232f3d arch/intel64: add support for PCI serial
intel64 can work with PCI serial cards now

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2024-09-15 03:37:58 +08:00
p-szafonimateusz
ceb2921d79 drivers: prepare 16550 UART driver to support PCI
prepare 16550 UART driver to support PCI:

- [breaking change] change argument of uart_ioctl() from `struct file *filep` to `FAR struct u16550_s *priv`
  Also fix moxart_16550.c build related to this change

- [breaking change] change argument of uart_getreg() and uart_putreg from `uart_addrwidth_t base` to `FAR struct u16550_s *priv`
  Also fix arch/x86/src/qemu/qemu_serial.c and arch/x86_64/src/intel64/intel64_serial.c related to this change

- [breaking change] change argument of uart_dmachan() from `uart_addrwidth_t base` to `FAR struct u16550_s *priv`

- move `struct u16550_s` to public header

- generalize UART_XXX_OFFSET so we can use it with any register increment

- make u16550_bind(), u16550_interrupt(), u16550_interrupt() public

- remove arch/or1k/src/common/or1k_uart.c and use common 16550 MIMO interfacve

- change irq type in `struct u16550_s` from uint8_t to int to match MSI API

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2024-09-15 03:37:58 +08:00
p-szafonimateusz
a0e00b993a intel64: register PCI controller early but postpone PCI drivers init
Some of PCI drivers require OS interfaces that can't be executed in the INIT context.
In that case we have to postpone PCI drivers probing and call it for example
in board initialization logic.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2024-09-15 03:37:58 +08:00
wangyongrong
ff399054c1 rptun/rpmsg_virtio: fix addrenv/raddrenv num error
Buf fix, simple_addrenv assume the last addrenv in addrenv array
be zero value

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-09-14 17:34:52 +08:00