GPIO interface unified security management and control method for multi-core heterogeneous system and related equipment

By constructing a GPIO security management and state consistency guarantee system, the implicit conflict and state inaccuracy of GPIO control in multi-core heterogeneous SoC systems are solved, realizing controllable, recyclable and verifiable management of GPIO resources, and ensuring system stability and security.

CN123138002APending Publication Date: 2026-11-20CHINA FAW CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611370698.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-04
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

In multi-core heterogeneous SoC systems, the lack of systematic management of GPIO control leads to implicit control ownership, fragmented lifecycle management, inaccurate hardware and software states, and unrestrained user-mode operations. This results in multi-core/multi-process control conflicts, inability to recover abnormal states, inaccurate hardware and software states, and frequent user-mode operation errors.

Method used

An integrated GPIO security management and state consistency guarantee system is constructed. This system builds a control context for each physical GPIO, stores it in a shared memory area accessible to multiple cores, introduces a cross-core mutual exclusion access mechanism, realizes cross-core control arbitration, performs state comparison calibration and continuous monitoring, executes anomaly handling and state recovery, and builds a layered security access mechanism in user space.

Benefits of technology

It enables controllable, reclaimable, and verifiable management of GPIO resources in a multi-core environment, ensuring real-time synchronization of hardware and software status and auditable management of operational behavior, avoiding system failures and reducing integration and transformation costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123138002A_ABST
    Figure CN123138002A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of embedded system, specifically to a GPIO interface unified security management method for a multi-core heterogeneous system and related equipment, the method comprising: constructing a control context for each physical GPIO and storing it in a shared storage area accessible by multiple cores; in response to a GPIO operation request, performing cross-core control arbitration; in the GPIO usage phase, comparing and calibrating the expected configuration state of the GPIO with the actual hardware state, and continuously monitoring the GPIO state; in the GPIO release phase, in response to an exit trigger event, performing GPIO state recovery and releasing control; before the execution of a GPIO operation, performing operation legality verification and configuration reasonableness verification, and after the completion of the operation, reading the actual hardware state to confirm the operation result. The present application realizes controllable, recyclable and verifiable management of GPIO resources in a multi-core environment, and improves the stability and reliability of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of embedded system technology, and in particular to a unified security management method and related equipment for GPIO interfaces of multi-core heterogeneous systems. Background Technology

[0002] With the rapid development of high-reliability embedded systems such as automotive electronics and industrial control, multi-core heterogeneous SoC (System-on-Chips) architecture has become the mainstream design paradigm. In multi-core heterogeneous SoCs, general-purpose input / output interfaces (GPIOs) serve as the basic hardware resource connecting the processor and peripherals, undertaking key functions such as sensor data acquisition, actuator control, and interrupt triggering. However, current GPIO control lacks a systematic management mechanism, leading to problems such as multi-core / multi-process control conflicts, inaccurate hardware and software states, loss of state control after abnormal exits, and lack of safety constraints on user-mode operations, resulting in decreased system stability.

[0003] While existing technologies have developed three main GPIO control schemes—kernel-mode driver unified management, user-mode interface direct operation, and multi-core independent control—none of them have overcome the following core bottlenecks: First, the ownership of control is implicit, leading to frequent cross-core / process conflicts. Existing solutions lack explicit GPIO control descriptions and arbitration mechanisms, relying solely on manual agreements to define usage scopes. In multi-core heterogeneous scenarios, different processing cores can independently rewrite the same GPIO configuration, and multiple processes can concurrently operate on GPIOs, easily resulting in configuration overwriting and level fluctuations, causing peripheral malfunctions or even hardware burnout. Furthermore, the lack of a global GPIO status view makes troubleshooting extremely difficult.

[0004] Second, lifecycle management is fragmented, and abnormal states cannot be recovered. The logic for requesting, configuring, and releasing GPIO is scattered across the code of various business modules, with some release operations only performed when the program exits normally. When the application exits abnormally, is forcibly terminated, or the system is reset, GPIO is prone to being in an undefined state, and there is no automatic recovery mechanism. The residual state can lead to unpredictable subsequent system behavior.

[0005] Third, there is a lack of accurate hardware and software status and a lack of consistency verification mechanisms. After system startup, the GPIO is in the expected configuration state by default, without an active reading and calibration process for the actual hardware level and pin configuration. During operation, the GPIO hardware state is prone to deviation due to electromagnetic interference, register leakage, cross-core erroneous operations, etc., and the software lacks continuous verification and automatic repair methods. The inaccuracy of hardware and software status will directly cause abnormal operation of peripherals such as sensors and actuators.

[0006] Fourth, user-mode operations are unrestrained, and erroneous operations can easily lead to system crashes. The operating system's native user-mode GPIO operation interface is designed as a "pass-through to hardware," lacking mechanisms for verifying the legality of operations, the rationality of configurations, and the confirmation of operation results. Any process with file operation permissions can arbitrarily configure GPIOs. Erroneous operations on critical GPIOs such as reset and power can directly affect the hardware, causing system-level crashes, without any software-level security barriers. Summary of the Invention

[0007] To address the aforementioned technical issues, this invention proposes a unified security management method and related equipment for GPIO interfaces in multi-core heterogeneous systems. By constructing an integrated GPIO security management and state consistency assurance system, it enables controllable, recyclable, and verifiable management of GPIO resources in a multi-core environment.

[0008] On one hand, embodiments of the present invention provide a unified security management method for GPIO interfaces of multi-core heterogeneous systems, the method comprising the following steps: A control context is constructed for each physical GPIO, and the control context is stored in a shared memory area accessible to multiple cores; In response to a GPIO operation request, cross-core control arbitration is performed based on the control context. Control is allocated when the control context indicates that the current GPIO is idle, and new control requests are rejected when the control context indicates that the current GPIO is occupied. During the GPIO usage phase, the expected configuration state of the GPIO is compared and calibrated with the actual hardware state based on the control context, and the GPIO state is continuously monitored. When a state deviation is detected, exception handling is performed. During the GPIO release phase, in response to the exit trigger event, GPIO state restoration is performed and control is released based on the control context; Before executing a GPIO operation, an operation validity check and a configuration rationality check are performed. If both checks pass, the GPIO operation is executed. After the operation is completed, the actual hardware status of the GPIO is read to confirm the operation result. If the confirmation is successful, the control context is updated.

[0009] Optionally, constructing a control context for each physical GPIO includes: Obtain the hardware identification information of the GPIO to be managed, and assign a unique index identifier to each physical GPIO based on the hardware identification information; The control context adopts a standardized data structure design, and the control context includes at least GPIO hardware identification information, control ownership information, software expected configuration status, lifecycle status information, and abnormal status information. The control context is deployed in the shared memory area or system global variable storage area of ​​a multi-core heterogeneous SoC, so that different processing cores can access the control context of the corresponding GPIO through the unique index identifier; A cross-core mutual exclusion mechanism is introduced when accessing the control context. The cross-core mutual exclusion mechanism uses multi-core spinlocks or atomic operation instructions to ensure that only one execution entity is allowed to modify the control context of the corresponding GPIO at any given time. During the initialization of the control context, GPIO hardware identification information is written into the control context as a static field, control ownership information, lifecycle status information and abnormal status information are initialized to idle status values, and the software expected configuration status is initialized to the system default configuration value.

[0010] Optionally, performing cross-core control arbitration based on the control context includes: During the GPIO request phase, the lifecycle status information in the control context is queried. When the lifecycle status information indicates an idle state, the currently executing core identifier and associated process information are written into the control ownership information in the control context, and the lifecycle status information is updated to an occupied state. When the lifecycle status information indicates an occupancy status, the control ownership information is read to obtain the current occupant identifier, and a rejection response is returned to the requester. For predefined critical GPIOs, a lock attribute field is set in the control context. When the lock attribute field is in a locked state, changes to the control ownership information are restricted, and only execution entities with unlocking permissions are allowed to unlock.

[0011] Optionally, the continuous monitoring of GPIO status includes: During the operation phase, the GPIO hardware register is read according to the preset verification cycle to obtain the actual level state and pin configuration state. The actual level state and pin configuration state are compared with the software expected configuration state in the control context item by item to generate state difference information. In response to GPIO configuration change events or cross-core operation events, an event verification process is triggered, the GPIO hardware registers are read to obtain the current hardware state, the current hardware state is compared with the software expected configuration state, and event trigger difference information is generated. Based on the degree of deviation and the importance level of the GPIO in the state difference information or the event trigger difference information, graded anomaly handling is performed. The graded anomaly handling includes: automatically calibrating the hardware state to the software's desired configuration state and recording the calibration log when there is a slight deviation; recording anomaly alarm information and notifying the upper-level management module when there is a moderate deviation; and implementing a locking strategy for the corresponding GPIO and prohibiting subsequent operations when there is a severe deviation or multiple calibration failures.

[0012] Optionally, the step of restoring the GPIO state and releasing control includes: Monitor multiple exit trigger scenarios, including normal exit signals of user-mode applications, abnormal exit signals, system-level reset events, and runtime anomaly detection trigger signals; After detecting the exit trigger event, read the control ownership information in the control context to determine the list of GPIOs to be reclaimed; For each GPIO in the list of GPIOs to be recycled, its functional attribute field is read. When the functional attribute field indicates a critical GPIO, the GPIO hardware state is restored to a preset safe state. When the functional attribute field indicates a non-critical GPIO, the GPIO hardware state is restored to the system default configuration state. After the state recovery is completed, the control ownership information in the control context is reset to an idle value, the lifecycle state information is updated to an idle state, the dynamic fields are cleared, and the static fields are retained. After recycling is completed, the actual hardware state of GPIO is read and compared with the expected software configuration state in the control context. If the state is not effective, a retry operation is performed according to the preset retry strategy. After multiple retry failures, the exception information is recorded and reported.

[0013] Optionally, the execution operation legality verification and configuration rationality verification include: Before executing a GPIO operation, the control ownership information in the control context is read, and the control ownership information is compared with the execution core identifier and process information of the current requester. If the comparison is consistent, the operation legality check is determined to have passed. If the comparison is inconsistent, the operation legality check is determined to have failed and the GPIO operation request is intercepted. After the operation validity check is passed, the requested configuration parameters are read and compared with the allowed configuration range in the GPIO hardware feature database. If the configuration parameters are within the allowed configuration range, the configuration validity check is passed. If the configuration parameters exceed the allowed configuration range, the configuration validity check is failed and the GPIO operation request is blocked. For critical GPIOs, operation authorization information is further read before the operation is executed. If the operation authorization information indicates that the current requester has operation authorization, the operation is allowed to be executed. If the operation authorization information indicates that the current requester does not have operation authorization, the operation is rejected and an unauthorized access log is recorded.

[0014] Optionally, the step of confirming the operation result by reading the actual hardware state of the GPIO after the operation is completed includes: After the GPIO operation is completed, the actual hardware state is obtained by directly reading the GPIO hardware register, and the actual hardware state is compared with the expected operation state. If the comparison is successful, the desired software configuration state in the control context is updated to the actual hardware state, and an operation success log is recorded. When the comparison is inconsistent, a retry operation is performed according to the preset retry strategy. After the retry, the actual hardware status is read again for comparison. When the final comparison fails, an operation failure log is recorded, the GPIO hardware status is restored to the state before the operation, and the abnormal status information in the control context is updated.

[0015] On the other hand, embodiments of the present invention provide a unified security management device for GPIO interfaces of multi-core heterogeneous systems, comprising: The first module is used to build a control context for each physical GPIO and store the control context in a shared memory area accessible to multiple cores. The second module is used to respond to GPIO operation requests, perform cross-core control arbitration based on the control context, allocate control when the control context indicates that the current GPIO is in an idle state, and reject new control requests when the control context indicates that the current GPIO is in an occupied state. The third module is used to compare and calibrate the expected configuration state of GPIO with the actual hardware state based on the control context during the GPIO usage phase, continuously monitor the GPIO state, and perform exception handling when a state deviation is detected. The fourth module is used to, in response to an exit trigger event, perform GPIO state restoration and release control based on the control context during the GPIO release phase. The fifth module is used to perform operation validity verification and configuration rationality verification before GPIO operation is executed. If both verifications pass, the GPIO operation is executed. After the operation is completed, the actual hardware status of the GPIO is read to confirm the operation result. If the confirmation is successful, the control context is updated.

[0016] On the other hand, embodiments of the present invention provide a unified security management system for GPIO interfaces of multi-core heterogeneous systems, including: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.

[0017] On the other hand, embodiments of the present invention provide a computer-readable storage medium storing a processor-executable program, which, when executed by a processor, is used to perform the above-described method.

[0018] The embodiments of the present invention have the following beneficial effects: This invention constructs a control context data structure and stores it in a shared memory area accessible to multiple cores, introduces a cross-core mutual exclusion access mechanism, and realizes explicit description and global management of GPIO control rights. It fundamentally solves the problems of implicit conflict and configuration overriding of GPIO control rights in a multi-core / multi-process environment, and realizes exclusive and orderly use of GPIO resources through a cross-core control right arbitration strategy.

[0019] This invention constructs a unified GPIO recycling mechanism covering all scenarios, including normal exit, abnormal exit, system reset, and runtime anomalies. It uses the control context as the basis for judgment, implements hierarchical state recovery based on GPIO functional attributes, and introduces a verification and retry process based on the actual hardware state after recycling. This achieves automated recovery of GPIO state, standardized release of control rights, and confirmation of the validity of recycling results, eliminating the uncontrollable state of GPIO resources in abnormal scenarios.

[0020] This invention constructs a full-process state consistency assurance system covering the startup and operation phases. During the startup phase, it performs software and hardware state comparison and forced calibration. During the operation phase, it continuously monitors the system through a combination of periodic verification and event-triggered verification. Furthermore, it implements a graded anomaly handling strategy based on the degree of deviation and the importance of GPIO, thereby achieving proactive verification, automatic calibration, and anomaly repair of software and hardware states and ensuring real-time synchronization of GPIO software and hardware states.

[0021] This invention constructs a layered security access mechanism in user space, sequentially performing operation legality verification and configuration rationality verification. After the operation is completed, the operation result is confirmed by reading the actual hardware status, and a failure retry mechanism is introduced to intercept illegal and unreasonable operations at the software level. For critical GPIO, an operation authorization and log traceability mechanism is further introduced to achieve auditable management of operation behavior and avoid misoperation directly affecting the hardware and causing system failure.

[0022] This invention follows the design principles of lightweight kernel-mode support, user-mode core management, and cross-core collaborative synchronization. It is implemented based on the native interface of the operating system, without relying on specific SoC hardware features or modifying the core source code of the operating system kernel. It achieves the above functions without relying on specific SoC hardware or modifying the core source code of the operating system kernel, adapts to mainstream multi-core heterogeneous embedded platforms, and reduces the integration and transformation costs of existing systems. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a flowchart illustrating the steps of a unified security management method for GPIO interfaces in multi-core heterogeneous systems provided by an embodiment of the present invention. Figure 2 This is a flowchart of the cross-core control arbitration process provided in an embodiment of the present invention; Figure 3 This is a structural block diagram of a unified security management device for GPIO interfaces in multi-core heterogeneous systems provided in an embodiment of the present invention. Detailed Implementation

[0025] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0026] It should be noted that although the device diagram shows a modular division and the flowchart illustrates a logical order, in some cases, the steps shown or described may be performed in a different order than the modular division in the device or the order shown in the flowchart. The terms "first," "second," etc., used in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.

[0028] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a full understanding of embodiments of the invention. However, those skilled in the art will recognize that the technical solutions of the invention can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of the invention.

[0029] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0030] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0031] like Figure 1 As shown, Figure 1 This invention provides a unified security management method for GPIO interfaces in multi-core heterogeneous systems, comprising the following steps: S100, construct a control context for each physical GPIO and store the control context in a shared memory area accessible to multiple cores; S200, in response to a GPIO operation request, performs cross-core control arbitration based on the control context, allocates control when the control context indicates that the current GPIO is in an idle state, and rejects new control requests when the control context indicates that the current GPIO is in an occupied state; S300: During the GPIO usage phase, the expected configuration state of the GPIO is compared and calibrated with the actual hardware state based on the control context, and the GPIO state is continuously monitored. When a state deviation is detected, exception handling is performed. S400, during the GPIO release phase, in response to the exit trigger event, GPIO state recovery is performed and control is released based on the control context; S500: Before executing a GPIO operation, perform operation validity verification and configuration rationality verification. If both verifications pass, execute the GPIO operation. After the operation is completed, read the actual hardware status of the GPIO to confirm the operation result. If the confirmation is successful, update the control context.

[0032] This invention proposes a unified security management method and related devices for GPIO interfaces in multi-core heterogeneous systems. Following the design principles of lightweight kernel-mode support, user-mode core management, and cross-core collaborative synchronization, it is implemented based on the operating system's native interface, requiring no dependence on specific SoC hardware characteristics or modification of the operating system kernel source code. Through a multi-mechanism collaborative approach, an integrated GPIO security management and state consistency guarantee system is constructed, enabling controllable, reclaimable, and verifiable management of GPIO resources in a multi-core environment. The overall technical solution consists of five core mechanisms: a global control context management mechanism, a cross-core control arbitration mechanism, a full-stage state consistency guarantee mechanism, a unified lifecycle reclamation mechanism, and a user-mode layered secure access mechanism. These mechanisms cooperate to form a closed-loop management system.

[0033] refer to Figure 2 The following is a detailed description of the unified security management method for GPIO interfaces in multi-core heterogeneous systems proposed in this invention: In this embodiment, a control context is first constructed for each physical GPIO. Specifically, the hardware identification information of the GPIO to be managed is obtained, including the physical pin number, the GPIO controller number, the register base address, and the bit offset. A unique index identifier is assigned to each physical GPIO based on the hardware identification information. This unique index identifier uses a globally incrementing integer value or a hash value generated based on the hardware identification information. The control context adopts a standardized data structure design, including at least: GPIO hardware identification information, control ownership information, software desired configuration status, lifecycle status information, and abnormal status information. The GPIO hardware identification information includes static attributes such as physical pin number, controller number, and register address; the control ownership information includes the current kernel identifier, associated process identifier, and process name of the GPIO; the software desired configuration status includes direction configuration (input / output), level status (high / low), pull-up / pull-down configuration, and drive capability configuration; the lifecycle status information includes idle status, requesting status, occupied status, releasing status, and abnormal status; the abnormal status information includes the most recent abnormal type, the timestamp of the abnormal occurrence, and the abnormal handling result. After assigning a unique index identifier to each physical GPIO, the control context is stored in a shared memory area accessible to multiple cores. The shared memory area includes the shared memory area of ​​a multi-core heterogeneous SoC or the system global variable storage area to support different processing cores in reading and updating GPIO status information.

[0034] During the system startup phase, the kernel-mode support module initializes the control context. This module runs as an extension module of the operating system kernel or a kernel thread. Early in the system startup phase, it enumerates and registers GPIO hardware resources, creates a corresponding control context instance for each physical GPIO, and writes the GPIO hardware identification information into the control context as a static field. It initializes control ownership information, lifecycle status information, and abnormal status information to idle state values, and initializes the software expected configuration state to the system default configuration value. The user-mode management service runs after system startup, establishing a local index relationship between the unique index identifier and the control context. This local index relationship is stored using a hash table or array structure, allowing upper-layer applications to quickly locate the corresponding control context using the logical GPIO number.

[0035] To ensure consistency during concurrent access across cores, a cross-core mutual exclusion mechanism is introduced when accessing the control context. This mechanism is implemented using multi-core spinlocks or atomic operation instructions. When using multi-core spinlocks, a spinlock instance is allocated to each control context or each GPIO controller. The corresponding spinlock is acquired before modifying the control context and released after modification. When using atomic operation instructions, the processor-provided Atomic Compare-Exchange (CAS) instruction or Atomic Test-Set (TAS) instruction is used to atomically update key fields in the control context, ensuring that only one execution entity is allowed to modify the control context of the corresponding GPIO at any given time.

[0036] In some embodiments, performing cross-core control arbitration based on the control context includes: S311, During the GPIO request phase, query the lifecycle status information in the control context. When the lifecycle status information indicates an idle state, write the currently executing core identifier and associated process information into the control ownership information in the control context, and update the lifecycle status information to an occupied state. S312, when the lifecycle status information indicates an occupancy status, read the control ownership information to obtain the current occupant identifier, and return a rejection response to the requester; S313, For a predefined critical GPIO, a lock attribute field is set in the control context. When the lock attribute field is in a locked state, changes to the control ownership information are restricted, and only execution entities with unlocking permissions are allowed to unlock.

[0037] Specifically, the control context serves as a unified state benchmark, providing a basis for judgment in control arbitration, state verification, and resource reclamation. A cross-core control arbitration strategy is implemented based on this control context: during the GPIO request phase, the control context status is queried first; when it is idle, the currently executing core identifier and associated process information are bound to the control context; when the GPIO is already occupied, new control requests are rejected; for predefined critical GPIOs, locking attributes can be set to restrict changes in control. During system operation, all GPIO request, configuration, release, and state change operations are synchronously updated to the corresponding control context atomically. After a GPIO is released, only dynamic fields related to the running state (such as control ownership information and lifecycle state information) are reset; other static attributes (such as GPIO hardware identifier information) remain unchanged.

[0038] In some embodiments, the continuous monitoring of GPIO status includes: S411, During the operation phase, the GPIO hardware register is read according to the preset verification cycle to obtain the actual level state and pin configuration state. The actual level state and pin configuration state are compared with the software expected configuration state in the control context item by item to generate state difference information. S412, in response to a GPIO configuration change event or a cross-core operation event, triggers an event verification process, reads the GPIO hardware register to obtain the current hardware state, compares the current hardware state with the software expected configuration state, and generates event trigger difference information; S413, based on the degree of deviation and the importance level of the GPIO in the state difference information or the event trigger difference information, perform graded exception handling. The graded exception handling includes: automatically calibrating the hardware state to the software expected configuration state and recording the calibration log when there is a slight deviation; recording the exception alarm information and notifying the upper management module when there is a moderate deviation; and implementing a locking strategy for the corresponding GPIO and prohibiting subsequent operations when there is a serious deviation or multiple calibration failures.

[0039] Specifically, to ensure the consistency of GPIO software and hardware states throughout system operation, this invention introduces a state consistency guarantee mechanism covering both the startup and runtime phases. During startup, this consistency guarantee mechanism is triggered at key times such as system startup, application loading, and the first GPIO request, comparing the expected configuration state of the GPIO with the actual hardware state. When an inconsistency is detected, a forced calibration process is executed to ensure the hardware state matches the expected software state, and the calibration results are recorded for auditing and backtracking. During runtime, GPIOs in use are continuously monitored through a combination of periodic and event-triggered verification. Different verification strategies can be configured for GPIOs of different importance levels (e.g., short-cycle, high-frequency verification for critical GPIOs and long-cycle, low-frequency verification for non-critical GPIOs) to ensure reliability while controlling system overhead. When a state deviation is detected, it is handled in a tiered manner according to the degree of deviation and the GPIO's importance level, including automatic calibration, logging, and anomaly alarms. In the event of multiple calibration failures, a locking strategy is implemented for the corresponding GPIO to prevent further misuse. During the status verification and calibration process, the actual status of GPIO is obtained by directly reading the hardware registers to avoid data deviations caused by software caching or intermediate layers.

[0040] In some embodiments, the step of performing GPIO state recovery and releasing control includes: S511, monitor multiple exit trigger scenarios, including normal exit signal of user-mode application, abnormal exit signal, system-level reset event, and runtime abnormal detection trigger signal; S512, after detecting the exit trigger event, read the control ownership information in the control context and determine the list of GPIOs to be reclaimed; S513, for each GPIO in the list of GPIOs to be recycled, read its functional attribute field. When the functional attribute field indicates a critical GPIO, restore the GPIO hardware state to a preset safe state. When the functional attribute field indicates a non-critical GPIO, restore the GPIO hardware state to the system default configuration state. S514, after completing the state recovery, reset the control ownership information in the control context to an idle value, update the lifecycle state information to an idle state, clear the dynamic fields, and retain the static fields. S515: After recycling is completed, the actual hardware state of GPIO is read and compared with the expected software configuration state in the control context. If the state is not effective, a retry operation is performed according to the preset retry strategy. After multiple retry failures, the exception information is recorded and reported.

[0041] Specifically, to address the resource hanging problem of GPIOs in multi-core environments caused by abnormal application exits, system resets, or runtime anomalies, this invention constructs a unified GPIO lifecycle recycling mechanism. This recycling mechanism covers various exit triggering scenarios, including but not limited to: normal or abnormal exits of user-mode applications, system-level reset events, and runtime anomaly detection triggers. Multiple trigger sources work collaboratively to ensure that GPIO resources can be detected and enter the recycling process under various abnormal conditions. During the recycling process, GPIOs are managed hierarchically according to their functional attributes. For critical GPIOs (such as those controlling power, reset signals, and safety-related peripherals), they are preferentially restored to preset safety states (such as low-level output, high-impedance state, etc.); for non-critical GPIOs, they are restored to the system default configuration state. After state restoration, the control rights of the corresponding GPIOs are released sequentially, and the dynamic state fields in the control context are reset, allowing them to re-enter the available state. After recycling, the actual hardware state of the GPIO is read and compared with the control context information to verify the recycling result; when an invalid state is detected, retrying is performed according to a preset strategy, and after multiple failures, the anomaly information is recorded and reported.

[0042] In some embodiments, the execution operation legality verification and configuration rationality verification include: S611, Before executing the GPIO operation, read the control ownership information in the control context, compare the control ownership information with the execution core identifier and process information of the current requester, determine that the operation legality check is passed when the comparison is consistent, and determine that the operation legality check is not passed when the comparison is inconsistent and intercept the GPIO operation request. S612, after passing the operation validity check, read the requested configuration parameters, compare the configuration parameters with the allowed configuration range in the GPIO hardware feature database, determine that the configuration validity check is passed when the configuration parameters are within the allowed configuration range, and determine that the configuration validity check is not passed when the configuration parameters exceed the allowed configuration range and intercept the GPIO operation request. S613, for critical GPIO, further read operation authorization information before executing the operation. If the operation authorization information indicates that the current requester has operation authorization, allow the operation to be executed. If the operation authorization information indicates that the current requester does not have operation authorization, refuse to execute the operation and record the unauthorized access log.

[0043] Specifically, this invention constructs a layered GPIO security access mechanism in user space to uniformly provide GPIO operation interfaces and manage the operation process. Before executing a GPIO operation, a legality check and a rationality check are performed sequentially: the legality check determines whether the current request has the operation permission and control rights for the corresponding GPIO; the rationality check determines whether the requested configuration parameters meet the hardware characteristics requirements of the GPIO. Operation requests that do not meet the check conditions are intercepted and error or alarm information is returned. After the operation is completed, the operation result is confirmed by reading the actual hardware state of the GPIO; when confirmation is successful, the corresponding control context information is updated; when the operation does not take effect, it is retried according to a preset strategy, and in the event of final failure, exception information is recorded and the system is restored to the state before the operation. For critical GPIOs, an operation authorization and log traceability mechanism is further introduced to record all their operations, achieving auditable management of operation behavior. By providing standardized user-space GPIO operation interfaces to system components, access to GPIO resources through these interfaces is guided and prioritized, thereby reducing the risk of bypassing security control paths.

[0044] In some embodiments, the step of confirming the operation result by reading the actual hardware state of the GPIO after the operation is completed includes: S621, after the GPIO operation is completed, the actual hardware state is obtained by directly reading the GPIO hardware register, and the actual hardware state is compared with the expected operation state. S622, when the comparison is consistent, update the software expected configuration state in the control context to the actual hardware state, and record the operation success log; S623, when the comparison is inconsistent, a retry operation is performed according to the preset retry strategy. After the retry, the actual hardware status is read again for comparison. When the final comparison fails, an operation failure log is recorded, the GPIO hardware status is restored to the state before the operation, and the abnormal status information in the control context is updated.

[0045] The aforementioned control context management mechanism, cross-core control arbitration mechanism, full-stage state consistency guarantee mechanism, full lifecycle reclamation mechanism, and user-mode secure access mechanism work together: the control context serves as a unified state benchmark, providing a basis for judgment in control arbitration, state verification, and resource reclamation; reclamation and access operations are both executed based on the control context; state verification and calibration results are fed back in real time and update the control context information. Through the synergy of these mechanisms, this invention forms a unified, automatically recoverable, state-verifiable, and operable traceable GPIO management system in multi-core heterogeneous systems, achieving secure, reliable, and consistent control of GPIO resources in complex system environments.

[0046] See Figure 3This invention provides a unified security management device for GPIO interfaces in multi-core heterogeneous systems, comprising: The first module is used to build a control context for each physical GPIO and store the control context in a shared memory area accessible to multiple cores. The second module is used to respond to GPIO operation requests, perform cross-core control arbitration based on the control context, allocate control when the control context indicates that the current GPIO is in an idle state, and reject new control requests when the control context indicates that the current GPIO is in an occupied state. The third module is used to compare and calibrate the expected configuration state of GPIO with the actual hardware state based on the control context during the GPIO usage phase, continuously monitor the GPIO state, and perform exception handling when a state deviation is detected. The fourth module is used to, in response to an exit trigger event, perform GPIO state restoration and release control based on the control context during the GPIO release phase. The fifth module is used to perform operation validity verification and configuration rationality verification before GPIO operation is executed. If both verifications pass, the GPIO operation is executed. After the operation is completed, the actual hardware status of the GPIO is read to confirm the operation result. If the confirmation is successful, the control context is updated.

[0047] It is evident that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented in this device embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0048] This invention provides a unified security management system for GPIO interfaces in multi-core heterogeneous systems, comprising: At least one processor; At least one memory for storing at least one program; When at least one program is executed by at least one processor, the at least one processor performs the method described above.

[0049] It is evident that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented in this device embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0050] Furthermore, embodiments of the present invention also disclose a computer program product or computer program stored in a computer-readable storage medium. A processor of a computer device can read the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the computer device to perform the described method. Similarly, the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0051] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0052] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0053] The terms "first," "second," "third," "fourth," etc. (if present) in the specification and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0054] It should be understood that in this invention, "at least one (item)" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0055] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0056] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0057] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0058] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0059] The preferred embodiments of the present invention have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and spirit of the present invention should be within the scope of the claims of the present invention.

Claims

1. A unified security management method for GPIO interfaces in multi-core heterogeneous systems, characterized in that, The method includes the following steps: A control context is constructed for each physical GPIO, and the control context is stored in a shared memory area accessible to multiple cores; In response to a GPIO operation request, cross-core control arbitration is performed based on the control context. Control is allocated when the control context indicates that the current GPIO is idle, and new control requests are rejected when the control context indicates that the current GPIO is occupied. During the GPIO usage phase, the expected configuration state of the GPIO is compared and calibrated with the actual hardware state based on the control context, and the GPIO state is continuously monitored. When a state deviation is detected, exception handling is performed. During the GPIO release phase, in response to the exit trigger event, GPIO state restoration is performed and control is released based on the control context; Before executing a GPIO operation, an operation validity check and a configuration rationality check are performed. If both checks pass, the GPIO operation is executed. After the operation is completed, the actual hardware status of the GPIO is read to confirm the operation result. If the confirmation is successful, the control context is updated.

2. The method according to claim 1, characterized in that, The process of constructing a control context for each physical GPIO includes: Obtain the hardware identification information of the GPIO to be managed, and assign a unique index identifier to each physical GPIO based on the hardware identification information; The control context adopts a standardized data structure design, and the control context includes at least GPIO hardware identification information, control ownership information, software expected configuration status, lifecycle status information, and abnormal status information. The control context is deployed in the shared memory area or system global variable storage area of ​​a multi-core heterogeneous SoC, so that different processing cores can access the control context of the corresponding GPIO through the unique index identifier; A cross-core mutual exclusion mechanism is introduced when accessing the control context. The cross-core mutual exclusion mechanism uses multi-core spinlocks or atomic operation instructions to ensure that only one execution entity is allowed to modify the control context of the corresponding GPIO at any given time. During the initialization of the control context, GPIO hardware identification information is written into the control context as a static field, control ownership information, lifecycle status information and abnormal status information are initialized to idle status values, and the software expected configuration status is initialized to the system default configuration value.

3. The method according to claim 1, characterized in that, The execution of cross-core control arbitration based on the control context includes: During the GPIO request phase, the lifecycle status information in the control context is queried. When the lifecycle status information indicates an idle state, the currently executing core identifier and associated process information are written into the control ownership information in the control context, and the lifecycle status information is updated to an occupied state. When the lifecycle status information indicates an occupancy status, the control ownership information is read to obtain the current occupant identifier, and a rejection response is returned to the requester. For predefined critical GPIOs, a lock attribute field is set in the control context. When the lock attribute field is in a locked state, changes to the control ownership information are restricted, and only execution entities with unlocking permissions are allowed to unlock.

4. The method according to claim 1, characterized in that, The continuous monitoring of GPIO status includes: During the operation phase, the GPIO hardware register is read according to the preset verification cycle to obtain the actual level state and pin configuration state. The actual level state and pin configuration state are compared with the software expected configuration state in the control context item by item to generate state difference information. In response to GPIO configuration change events or cross-core operation events, an event verification process is triggered, the GPIO hardware registers are read to obtain the current hardware state, the current hardware state is compared with the software expected configuration state, and event trigger difference information is generated. Based on the degree of deviation and the importance level of the GPIO in the state difference information or the event trigger difference information, graded anomaly handling is performed. The graded anomaly handling includes: automatically calibrating the hardware state to the software's desired configuration state and recording the calibration log when there is a slight deviation; recording anomaly alarm information and notifying the upper-level management module when there is a moderate deviation; and implementing a locking strategy for the corresponding GPIO and prohibiting subsequent operations when there is a severe deviation or multiple calibration failures.

5. The method according to claim 1, characterized in that, The process of restoring the GPIO state and releasing control includes: Monitor multiple exit trigger scenarios, including normal exit signals of user-mode applications, abnormal exit signals, system-level reset events, and runtime anomaly detection trigger signals; After detecting the exit trigger event, read the control ownership information in the control context to determine the list of GPIOs to be reclaimed; For each GPIO in the list of GPIOs to be recycled, its functional attribute field is read. When the functional attribute field indicates a critical GPIO, the GPIO hardware state is restored to a preset safe state. When the functional attribute field indicates a non-critical GPIO, the GPIO hardware state is restored to the system default configuration state. After the state recovery is completed, the control ownership information in the control context is reset to an idle value, the lifecycle state information is updated to an idle state, the dynamic fields are cleared, and the static fields are retained. After recycling is completed, the actual hardware state of GPIO is read and compared with the expected software configuration state in the control context. If the state is not effective, a retry operation is performed according to the preset retry strategy. After multiple retry failures, the exception information is recorded and reported.

6. The method according to claim 1, characterized in that, The execution operation legality verification and configuration rationality verification include: Before executing a GPIO operation, the control ownership information in the control context is read, and the control ownership information is compared with the execution core identifier and process information of the current requester. If the comparison is consistent, the operation legality check is determined to have passed. If the comparison is inconsistent, the operation legality check is determined to have failed and the GPIO operation request is intercepted. After the operation validity check is passed, the requested configuration parameters are read and compared with the allowed configuration range in the GPIO hardware feature database. If the configuration parameters are within the allowed configuration range, the configuration validity check is passed. If the configuration parameters exceed the allowed configuration range, the configuration validity check is failed and the GPIO operation request is blocked. For critical GPIOs, operation authorization information is further read before the operation is executed. If the operation authorization information indicates that the current requester has operation authorization, the operation is allowed to be executed. If the operation authorization information indicates that the current requester does not have operation authorization, the operation is rejected and an unauthorized access log is recorded.

7. The method according to claim 1, characterized in that, The step of confirming the operation result by reading the actual hardware status of the GPIO after the operation is completed includes: After the GPIO operation is completed, the actual hardware state is obtained by directly reading the GPIO hardware register, and the actual hardware state is compared with the expected operation state. If the comparison is successful, the desired software configuration state in the control context is updated to the actual hardware state, and an operation success log is recorded. When the comparison is inconsistent, a retry operation is performed according to the preset retry strategy. After the retry, the actual hardware status is read again for comparison. When the final comparison fails, an operation failure log is recorded, the GPIO hardware status is restored to the state before the operation, and the abnormal status information in the control context is updated.

8. A unified security management device for GPIO interfaces in multi-core heterogeneous systems, characterized in that, include: The first module is used to build a control context for each physical GPIO and store the control context in a shared memory area accessible to multiple cores. The second module is used to respond to GPIO operation requests, perform cross-core control arbitration based on the control context, allocate control when the control context indicates that the current GPIO is in an idle state, and reject new control requests when the control context indicates that the current GPIO is in an occupied state. The third module is used to compare and calibrate the expected configuration state of GPIO with the actual hardware state based on the control context during the GPIO usage phase, continuously monitor the GPIO state, and perform exception handling when a state deviation is detected. The fourth module is used to, in response to an exit trigger event, perform GPIO state restoration and release control based on the control context during the GPIO release phase. The fifth module is used to perform operation validity verification and configuration rationality verification before GPIO operation is executed. If both verifications pass, the GPIO operation is executed. After the operation is completed, the actual hardware status of the GPIO is read to confirm the operation result. If the confirmation is successful, the control context is updated.

9. A unified security management system for GPIO interfaces in multi-core heterogeneous systems, characterized in that, include: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a processor-executable program, characterized in that, The processor-executable program, when executed by the processor, is used to perform the method as described in any one of claims 1 to 7.