Commit graph

60870 commits

Author SHA1 Message Date
wangchengdong
f87b3997f8 board/qemu-rv: enable hrtimer CITEST on rv-virt:citest64
Enable the default high-resolution timer (hrtimer) using the RB-tree
implementation in the CITEST configuration on rv-virt:citest64.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-28 18:20:41 +08:00
zhenwei fang
2614693bc0 mps:fix AN524 Kconfig symbol (MPS3, not MPS2)
The code currently checks CONFIG_ARCH_CHIP_MPS2_AN524, but
the corresponding Kconfig option is ARCH_CHIP_MPS3_AN524(i.e.
 CONFIG_ARCH_CHIP_MPS3_AN524) in arch/arm/src/mps/Kconfig

Signed-off-by: zhenwei fang <fangzhenwei@bytedance.com>
2026-01-28 18:20:11 +08:00
dongjiuzhu1
90fa0ed122 drivers/sensors: sensor bug fix.
fix deadlock about set_nonwakeup.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-28 16:50:19 +08:00
pangzhen1
7b154402fb sched/irq: Consolidate IRQ bounds checking into IRQ_TO_NDX macro
Previously, IRQ bounds checking (irq >= 0 && irq < NR_IRQS) was duplicated
across multiple IRQ subsystem functions before calling IRQ_TO_NDX(). This
led to code duplication and inconsistency.

This patch consolidates all IRQ bounds checking into the IRQ_TO_NDX() macro
itself, which now returns -EINVAL for out-of-bounds IRQ numbers. This approach:

1. Eliminates duplicated bounds checking code
2. Ensures consistent error handling across all IRQ functions
3. Simplifies caller code - just check if IRQ_TO_NDX() returns negative
4. Makes the macro behavior more predictable and self-contained

Changes:
- Modified IRQ_TO_NDX() to check (irq < 0 || irq >= NR_IRQS) and return -EINVAL
- Removed redundant IRQ range checks in irq_attach(), irq_attach_thread(),
  irq_attach_wqueue(), and irqchain_detach()
- Simplified error handling to check ndx < 0 after IRQ_TO_NDX() call

This consolidation reduces code size and improves maintainability while
preserving all existing error checking functionality.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-28 13:35:30 +08:00
makejian
83fdd685df docs: enhance crypto documentation with key management features
Add detailed documentation for:
- MTD-based key storage and persistence
- AES key generation with multiple key sizes
- ECC P-256 key pair generation for ECDSA operations
- Key lifecycle management (save/load/delete)

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-28 11:52:12 +08:00
makejian
b663bfed8e crypto/keymgmt: return actual length if key exported successfully
When a key is successfully exported, the return value should reflect the actual length of the exported key data.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-28 11:52:12 +08:00
makejian
3271427959 crypto/swkey: support generating ECC P-256 keys
Add support for generating ECC secp256r1 (P-256) key pairs using the software key management backend.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-28 11:52:12 +08:00
makejian
17b7c77d3a crypto/swkey: support generating AES keys
Add support for generating AES keys (128/192/256 bits) using the software key management backend.

The generated keys are random numbers produced by the system PRNG.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-28 11:52:12 +08:00
makejian
c8145313ae crypto: support software key management based on MTD
This patch adds support for managing cryptographic keys using MTD storage.

It enables the persistence of keys across reboots using a software-based key management system.

Includes fixes for compilation warnings and validation logic.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-28 11:52:12 +08:00
buxiasen
9205c60f01 fs/event/open: fix the inode information update outside of lock
For re-enter case, the inode information may unlock with not filled,
and get by other user. that lead to the error behavior.
Especially SMP scene.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-28 10:03:06 +08:00
buxiasen
1794fbaa61 fs/semaphore/open: fix the inode information update outside of lock
For re-enter case, the inode information may unlock with not filled,
and get by other user. that lead to the error behavior.
Especially SMP scene.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-28 10:03:06 +08:00
buxiasen
d3e5e756c5 fs/vfs/symlink: fix the inode information update outside of lock
For re-enter case, the inode information may unlock with not filled,
and get by other user. that lead to the error behavior.
Especially SMP scene.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-28 10:03:06 +08:00
pangzhen1
3650636e39 sched/irq: Avoid out-of-bounds array access
This patch fixes an array out-of-bounds access issue in the irq_get_wqueue() function.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-28 03:34:33 +08:00
yukangzhi
2f9d16372c syscall: add sched_note_event_ip syscall for instrumentation dump
Export the sched_note_event_ip function as a syscall under
CONFIG_SCHED_INSTRUMENTATION_DUMP. This allows user-space or
other kernel components to trigger event-type logs via the
instrumentation dump mechanism.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-28 02:06:23 +08:00
hujun5
49cb8e08e6 sem_trywait.c: coverity HIS_metric_violation(HIS_GOTO)
Refactor sem_trywait.c to replace goto statements with structured control
flow to comply with MISRA HIS coding standards. This improves code clarity
and maintainability while preserving all functional behavior and performance
characteristics.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-27 14:29:33 -03:00
p-gaoxiang43
922426346e sched/semaphore: remove dead code if no CONFIG_PRIORITY_PROTEC
Consolidate CONFIG_PRIORITY_PROTECT checks by moving macro definitions to
their actual usage locations and removing duplicate/dead code in semaphore
implementation. This reduces code duplication and improves maintainability
across sem_wait, sem_trywait, and sem_post functions.

Signed-off-by: p-gaoxiang43 <p-gaoxiang43@xiaomi.com>
2026-01-27 14:29:33 -03:00
wangzhi16
e23f2546c3 sched/sem : Optimize code
Simplify sem_trywait() code structure by removing redundant logic and
consolidating return paths. This optimization maintains functional correctness
while improving code clarity and reducing cyclomatic complexity.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-27 14:29:33 -03:00
hujun5
7443a13bf9 sched/sched/sched_get_stackinfo.c: coverity HIS_metric_violation: RETURN
Consolidate multiple return statements in sched_get_stackinfo() to comply
with MISRA HIS coding standards for safety-critical systems. This refactoring
maintains functional equivalence while improving code verifiability and
reducing cyclomatic complexity for better maintainability.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-28 01:24:58 +08:00
hujun5
e2aec529cb coverity: Dereferencing after a null check (FORWARD_NULL)
Add proper null pointer validation and fix potential dereference after null
check in scheduler critical sections. This addresses Coverity FORWARD_NULL
defect by ensuring pointers are checked before use and maintaining defensive
coding practices throughout the scheduler implementation.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-27 22:29:17 +08:00
hujun5
7f167ecc85 sched/sched/sched_rrgetinterval.c: coverity HIS_metric_violation: RETURN
Consolidate multiple return statements in sched_rrgetinterval() to reduce
function complexity and comply with MISRA HIS coding standards. This refactoring
maintains functional equivalence while improving code maintainability for
safety-critical embedded systems applications.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-27 22:28:59 +08:00
pangzhen1
ce743a22ee sched/irq: Fix type mismatch in irq_dispatch (MISRA C-2012 Rule 10.3)
IRQ_TO_NDX() returns int (can be negative on error), but was assigned
to unsigned int variable 'ndx', violating MISRA C-2012 Rule 10.3.

This also improves the condition check: instead of checking 'irq >= 0 && irq < NR_IRQS',
we now check 'ndx >= 0' which properly handles the error case where IRQ_TO_NDX()
returns a negative error code.

Changes:
- Change 'ndx' type from unsigned int to int
- Simplify condition from 'irq >= 0 && irq < NR_IRQS' to 'ndx >= 0'

This ensures type correctness and proper error handling.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-27 22:28:23 +08:00
chao an
c2eb22d29e sched: Remove FS_PROCFS dependency for SCHED_CRITMONITOR
Allow SCHED_CRITMONITOR to be enabled without requiring FS_PROCFS,
so it can be used in scenarios like calculating CPU load via
SCHED_CPULOAD_CRITMONITOR where procfs is not available.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-01-27 22:01:02 +08:00
wangzhi16
3b11545356 sched/spinlock: Update the information of critmon in docu.
Since the busy-wait time statistics for entering the critical section have been added, the critmon information in the document has been updated accordingly.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-27 21:59:14 +08:00
wangzhi16
30493d558a sched/spinlock: Add time statistics in func enter_critical_section().
Because enter_critical_section() changes from calling spin_lock() to calling spin_lock_wo_note(), it is necessary to count the busywait time in enter_critical_section() additionally.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-27 21:59:14 +08:00
wangzhi16
3116c19efc sched/spinlock: Add configuration to record busywait.
Add configuration "CONFIG_SCHED_CRITMONITOR_MAXTIME_BUSYWAIT", which can record the busy waiting time to get spinlock or enter critical section.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-27 21:59:14 +08:00
hujun5
bb562cf8bf arch/armv8-r64: userspace PMU access
Enable ARCH_HAVE_PERF_EVENTS_USER_ACCESS capability for Cortex-R82 to
allow userspace applications to directly access hardware performance
counters. Move up_perf_gettime() outside kernel-only block so it can
be called from userspace for efficient profiling.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-27 21:57:37 +08:00
yukangzhi
dea1bc1121 note: add NOTE_DUMP_BINARY support for binary log dumping
Add NOTE_DUMP_BINARY to the note_type_e enum and implement its handling
in noteram_dump_one. This enables the recording and dumping of binary
logs in hexadecimal format, improving traceability for binary event data.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-27 21:56:03 +08:00
ganjing
206aaa8612 arch/sim: improve heap management on Simulator
and proper accounting of heap metadata

Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-01-27 21:27:53 +08:00
ganjing
1c1cf74491 mm/tlfs: Account initial size of struct mm_heap_s
and then initialize it.

Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-01-27 21:27:53 +08:00
ganjing
af3d5e2212 fs/procfs: Add mallinfo and memdump callback to procfs_meminfo_entry_s
so the implementation can do the customized action through hook

Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-01-27 21:27:53 +08:00
ganjing
e8bbf496ee mm: Call mm_free_delaylist in mm_mallinfo
and remove it from meminfo_read to enuse caller
always get get accuracy memory information.

Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-01-27 21:27:53 +08:00
ganjing
e941b18e29 mm/umm: Allow customizing the implementation of umm heap
and migrate arch/sim from the customized mm_heap to
umm_heap, so the default mm_heap implementation can
still be used(e.g. shared memory in OpenAMP).

Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-01-27 21:27:53 +08:00
wangzhi16
364a633ec3 sched/signal: Optimize code logic
Adjust the up_schedule_sigaction function to facilitate subsequent spinlock optimization work.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-27 21:24:31 +08:00
hujun5
5775037da6 coverity: Prevent cross-border access(OVERRUN)
Add defensive bounds validation before memory access operations to
prevent out-of-bounds access. This addresses Coverity OVERRUN defect
by ensuring array indices and buffer sizes stay within valid range.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-27 21:22:30 +08:00
hujun5
850bafb13e coverity: HIS_metric_violation(HIS_CALLS)
Refactor sem_reset.c to reduce nested function call depth by consolidating
internal helper functions and optimizing call chains. This addresses Coverity's
HIS_metric_violation(HIS_CALLS) warning to comply with MISRA HIS coding
standards for embedded systems safety and maintainability.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-27 20:54:55 +08:00
xuxin19
a5f3937ff9 cmake(bugfix):change default compile obj extension to .o
CMake uses the `system_name` parameter by default to determine the .obj file extension.
On the Nuttx platform, our `system_name` is `bare matel`,
   while CMake only uses `.o` on Linux/Unix systems  otherwise, it uses `.obj`.

Therefore, we will change it to `.o` by default.

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-01-27 20:54:26 +08:00
xuxin19
80505da579 cmake(bugfix):remove unused libmad link in SIM build
libmad has been ported into apps
and does not require linking to the host.

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-01-27 20:54:26 +08:00
xuxin19
82fc9f4151 cmake(bugfix):Separate extra flags to avoid parsing errors
cc1: note: unrecognized command-line option '-Wno-cpp -Werror' may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option '-Wno-cpp -Werror' may have been intended to silence earlier diagnostics

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-01-27 20:54:26 +08:00
xuxin19
19d6806dbe cmake(bugfix):fix armv8m missing compile option in CMake
fix typo

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-01-27 20:54:26 +08:00
xuxin19
e3fcb025cb cmake(bugfix):fix common/etc confilt with src/etc in CMake genromfs
We use the rules added later to overwrite the previous rules

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-01-27 20:54:26 +08:00
xuxin19
4f80953ecd cmake(bugfix):do not set nuttx_add_app NAME as required
Instead, use direct return, because in non-build targets,
such as savedefconfig, menuconfig, this check is unnecessary

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-01-27 20:54:26 +08:00
pangzhen1
a665cd795a sched/irq: functions should have exactly one exit point
According to MISRA C-2004 Rule 14.7, Every function must have exactly one entry point and one exit point.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-27 19:35:48 +08:00
wangchengdong
165f1cc063 sched/sched: enable OS tickless mode support using hrtimer
Add support for running the OS in tickless mode with hrtimer, allowing
the scheduler to operate without periodic ticks while maintaining
high-resolution timer functionality.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-27 19:35:31 +08:00
wangchengdong
2ae62d71a6 sched/hrtimer: fix hrtimer regression introduced by recent update
The hrtimer subsystem is independent of the OS tick mechanism and tickless
mode. It must always be able to reprogram the hardware timer to achieve
nanosecond-level resolution.

A recent update restricted hardware timer reprogramming to tickless mode
only. As a result, hrtimer no longer functions correctly when the scheduler
is running in tick-based mode.

This change removes the incorrect dependency on tickless mode and restores
proper hrtimer operation.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-27 19:35:31 +08:00
wangchengdong
d9a0cf46ac arch/risc-v: fix timer initialization for SMP using mtimer
Correct timer initialization issue in SMP mode using mtimer to ensure
  per-hart timers are properly set up during boot.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-27 19:34:45 +08:00
likun17
c52d54d500 drivers/sensors: Remove the uncalibrated member of the sensor
lowerhalf layer.

The uncalibrated type is passed in with type. The driver defaults
to the calibrated type.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-27 19:34:33 +08:00
likun17
4f0e71dca1 drivers/sensors: Add new features.
add nine-axis(Accerometer Magnetic Field and Gyroscope) uncalibrated type.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-27 19:34:33 +08:00
wangzhi16
c7e7711db5 sched/spinlock: Call spinlock nopreempt when need disable context switch.
Using spin_lock_irqsave_nopreempt and spin_unlock_irqrestore_nopreempt to replace the following case.
flags = spin_lock_irqsave(lock);
sched_lock();
.....
spin_unlock_irqrestore(lock, flags);
sched_unlock();

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-27 19:33:58 +08:00
pangzhen1
927cccb278 sched/irq: Avoid negative array index in irqchain_dispatch
IRQ_TO_NDX() may return a negative value when the IRQ number is invalid
or not mapped. Using this negative value directly as an array index for
g_irqvector causes undefined behavior and potential memory corruption.

This patch adds a bounds check to ensure ndx is non-negative before
accessing the g_irqvector array, returning the error code if invalid.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-27 19:33:29 +08:00
makejian
5331d5a905 docs: enhance crypto documentation with RSA signature schemes
Add comprehensive documentation for RSA digital signature operations supported by the cryptodev/cryptokey interface.

Includes:
- RSA-PKCS1.5: Traditional PKCS#1 v1.5 padding scheme
  - CRK_RSA_PKCS15_SIGN: Generate RSA signature with PKCS#1 v1.5 padding
  - CRK_RSA_PKCS15_VERIFY: Verify RSA signature with PKCS#1 v1.5 padding

- RSA-PSS: Probabilistic Signature Scheme for enhanced security
  - CRK_RSA_PSS_SIGN: Generate RSA signature with PSS padding
  - CRK_RSA_PSS_VERIFY: Verify RSA signature with PSS padding

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-27 19:30:14 +08:00