When the system startup from the PL1 SYS mode, the initialization
of the PL2 HYP register needs to be skipped. Put the Hypervisor
initialization code together and skip it all at once.
Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
Add default values (0x0) for ARCH_TEXT_VBASE, ARCH_DATA_VBASE, and
ARCH_HEAP_VBASE to resolve cmake configuration warnings when these
values are not explicitly set during initialization.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Remove redundant leave_critical_section() call in nxsem_trywait_slow() as the
critical section is properly released at the exit point via 'out' label, making
the intermediate call unnecessary and eliminating code duplication.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Prevent getenv() from being called in interrupt context by adding
up_interrupt_context() check. This ensures thread-safe access to
environment variables in multi-threaded scenarios.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Set the thread ID (tl_tid) to the destination task's pid during TLS
duplication in fork operations. This ensures the duplicated TLS info
correctly reflects the forked task's thread identifier.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add support for managing hrtimers using a simple list. This approach
is more memory-efficient, as list nodes use less memory, and it is
preferable to an RB-tree when the number of hrtimers is relatively small.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
Stop the report handler from re-entering KASAN by halting checks when printing.
Reuse the dump_only flag so read/write panic toggles only emit stack traces.
Retain stack dumps for panic-disabled paths without risking another overflow.
Signed-off-by: anpeiyun <anpeiyun@xiaomi.com>
Remove redundant robust mutex owner validation code from pthread_mutex_timedlock
that duplicates similar logic already present in pthread_mutex_take. This reduces
code duplication and improves maintainability.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace spin_lock_irqsave with spin_lock_irqsave_nopreempt in
pthread_mutex_inconsistent to prevent preemption during mutex list
manipulation and avoid potential deadlocks or race conditions.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Enable building the legacy idf format of nuttx when rtc is enabled.
Without this addition the build fails because the rtc data is placed in
rom.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
After adding the cross-core crypto driver, there are now three encryption modes:
1. Hardware driver in local core
2. Crypto driver in remote core
3. Software encryption in local core
This prioritizes local hardware driver first, then remote driver (typically hardware),
and finally local software encryption as a fallback.
Signed-off-by: makejian <makejian@xiaomi.com>
Replace dynamic memory allocation with stack-based variables in cryptodev_op().
This eliminates kmm_malloc/kmm_free overhead and simplifies error handling
by removing the need for goto bail cleanup paths.
Signed-off-by: makejian <makejian@xiaomi.com>
Add ivlen field to crypt_op and crp_ivlen to cryptop structure to support
cipher algorithms with different IV lengths.
Signed-off-by: makejian <makejian@xiaomi.com>
Add olen field to crypt_op structure and crp_olen to cryptop structure
to support output length tracking in virtio crypto mode.
Signed-off-by: makejian <makejian@xiaomi.com>
Change TLS_ALIGNED default configuration to enable when either BUILD_KERNEL
or BUILD_PROTECTED is selected. Protected mode requires stack alignment to
properly handle TLS data structure at stack base.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Remove restore_critical_section() call from up_switch_context() in simulator
as it is not necessary during interrupt context switching. The critical
section state is properly managed elsewhere in the interrupt handling flow.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Remove restore_critical_section() call from common_handler() in x86_64 interrupt
processing as it is not necessary during interrupt handling. The critical section
state is properly managed by the interrupt framework elsewhere.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
In usrsock_pollsetup, only set POLLIN if USRSOCK_EVENT_RECVFROM_AVAIL is set when remote is closed, avoiding invalid POLLIN events.
Signed-off-by: daichuan <daichuan@xiaomi.com>
Clear USRSOCK_EVENT_RECVFROM_AVAIL flag when remote closes connection during accept to prevent repeated POLLIN events and EPIPE loop.
Signed-off-by: daichuan <daichuan@xiaomi.com>
Add pid field to task_info_s and move getpid() implementation to user
space TLS access. Remove getpid from syscall interface as it now returns
cached PID from thread local storage instead of kernel lookup.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Move tls_dup_info() call to after child process priority is set, ensuring
the child's pid is properly initialized before duplicating TLS information.
This fixes incorrect thread ID assignment during task fork operations.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
the virtual address of the page table (PT) is saved into the page directory (PD) entry, but the PD entry should store the physical address instead
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
Add documentation for the Whetstone floating-point benchmark
application which is being added to nuttx-apps.
The documentation includes:
- Overview of the benchmark
- Configuration options
- Usage examples
- Output interpretation
- Test modules description
Signed-off-by: makejian <makejian@xiaomi.com>
Replace global enter_critical_section() calls with lightweight spinlock in
addrenv_switch() to reduce interrupt latency, and convert refs counter to
atomic_t for thread-safe reference counting without blocking operations.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add CONFIG_NET_NO_LTO to allow compiling the network stack with -fno-lto.
This is useful for avoiding LTO-related issues in the network layer.
Signed-off-by: daichuan <daichuan@xiaomi.com>
When an unrecognized ICMP (type=3, code=2) packet is received, the ICMP flow does not set dev->d_len to 0, causing a devif_loopback dead loop.
Therefore, in ICMP input processing, when an ICMP_DEST_UNREACHABLE message is received, if it is not ICMP_FRAG_NEEDED code, jump to typeerr for error handling.
Signed-off-by: daichuan <daichuan@xiaomi.com>
Consolidate nxsched_process_timer into sched_timer.c, and introduce
nxsched_process_tick() to improve readability and maintainability of
the scheduler timer processing logic.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
When an interrupt occurs, the hardware automatically pushes the current RIP/RSP onto the interrupt stack. During the interrupt return, the iretq instruction pops them back. The problem is that the RIP/RSP modified by the signal is stored in the XCP context, whereas iretq operates on the interrupt stack. As a result, the RIP/RSP modified by the signal does not take effect in the iretq instruction, causing the task receiving the signal to fail to jump correctly to the signal handler. This behavior appears as if the signal is lost
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
Add a new license configuration option for components that have
custom permissive licenses which are not covered by the standard
license options (BSD, MIT, GPL, etc.).
This option allows projects to explicitly opt-in to using components
with custom permissive licenses that allow free use, modification,
and distribution but may have specific attribution or notice
requirements.
Also update the License Setup documentation section to include
this new option.
Signed-off-by: makejian <makejian@xiaomi.com>
Move stack alignment and kernel stack macros from architecture-specific internal
headers to public include/nuttx/irq.h. Consolidates duplicate definitions across
17 architecture families, reducing code duplication while enabling common code
to access these core alignment utilities without architecture dependencies.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
When _LIBCPP_HAS_NO_CONTENTION_TABLE is defined, libcxx will not
allocate the contention table used for semaphore implementation,
which can save significant RAM on memory-constrained embedded systems.
This optimization is particularly useful for NuttX targets where
every byte of RAM matters.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
nuttx/libs/libm/openlibm/openlibm/src/k_rem_pio2.c:421:24: error: 'fq' may be used uninitialized [-Werror=maybe-uninitialized]
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Building C object libs/libm/openlibm/CMakeFiles/m.dir/openlibm/src/s_clog.c.obj
In file included from /work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/math_private.h:22,
from /work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/s_clog.c:61:
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/s_clog.c:78:33: warning: ‘clogl’ alias between functions of incompatible types ‘_Complex long double(_Complex long double)’ and ‘_Complex double(_Complex double)’ [-Wattribute-alias=]
78 | openlibm_strong_reference(clog, clogl);
| ^~~~~
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/cdefs-compat.h:24:50: note: in definition of macro ‘openlibm_strong_reference’
24 | OLM_DLLEXPORT extern __typeof (aliassym) aliassym __attribute__ ((__alias__ (#sym)));
| ^~~~~~~~
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/src/s_clog.c:64:1: note: aliased declaration here
64 | clog(double complex z)
Building C object libs/libm/openlibm/CMakeFiles/m.dir/openlibm/amd64/fenv.c.obj
In file included from /work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/include/openlibm_fenv.h:8,
from /work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/amd64/fenv.c:35:
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/include/openlibm_fenv_amd64.h:99:1: warning: declaration of ‘feclearexcept’ shadows a built-in function [-Wshadow]
99 | feclearexcept(int __excepts)
| ^~~~~~~~~~~~~
/work/rel-5.0/nuttx/libs/libm/openlibm/openlibm/include/openlibm_fenv_amd64.h:117:1: warning: declaration of ‘fegetexceptflag’ shadows a built-in function [-Wshadow]
117 | fegetexceptflag(fexcept_t *__flagp, int __excepts)
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Rename siphash related symbols to avoid conflicts with compiler-generated
section names. Tricore-gcc produces function sections with '_end' suffix,
which conflicts with siphash_end symbol.
Signed-off-by: makejian <makejian@xiaomi.com>
Already copy the rpmsg_internal.h from openamp to the nuttx/include,
so do not need add the include patch for .c files.
Signed-off-by: yangao1 <yangao1@xiaomi.com>
Signed-off-by: wangshaoxin <wangshaoxin@xiaomi.com>