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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Instead, use direct return, because in non-build targets,
such as savedefconfig, menuconfig, this check is unnecessary
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
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>
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>
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>
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>
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>
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>