A method for quickly establishing security domains for multi-security domain architecture

By adopting the snapshot/recovery mechanism of user-mode security zones and pseudo-parallel CPU resource allocation in a multi-security domain architecture, the problem of low efficiency in establishing and recycling user-mode security zones in the existing technology is solved, and rapid response and recovery of sensitive applications are achieved. Efficient resource management, suitable for edge computing scenarios with high frequency and high computing resource requirements.

CN114579313BActive Publication Date: 2024-09-27CENT SOUTH UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210217892.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-07
Publication Date
2024-09-27
Estimated Expiration
2042-03-07

AI Technical Summary

Technical Problem

The existing multi-security domain architecture cannot quickly establish and recycle user-mode security zones in edge computing scenarios, resulting in long response times for sensitive applications, low resource utilization, and inability to meet application execution with high frequency and high computing resource requirements.

Method used

Adopt the snapshot/recovery mechanism of the user-mode safe zone to save execution environment information and delay memory recycling, optimize the CPU resource allocation process, and shorten the response time and CPU resource allocation time of sensitive applications through the pseudo-parallel removal mechanism and callback function delegated execution.

Benefits of technology

It achieves fast response and efficient resource management for sensitive applications, reduces repeated establishment processes, improves CPU resource allocation efficiency, supports two or more rapid executions of sensitive applications, and saves system resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114579313B
    Figure CN114579313B
Patent Text Reader

Abstract

The present invention discloses a method for quickly establishing a security domain for a multi-security domain architecture. The steps of establishing a user-mode security zone include: when a sensitive application is triggered to execute, if there is a user-mode security zone corresponding to the sensitive application, a fast CPU allocation method is executed to allocate CPU resources to the user-mode security zone, and the execution environment of the user-mode security zone is restored according to the execution environment information of the user-mode security zone; the steps of reclaiming CPU computing resources in the user-mode security zone include: after the sensitive application is executed, the user-mode security zone is closed, the execution environment information of the user-mode security zone is saved to the security world, and finally the CPU resources are reclaimed. The present invention can shorten the response time of sensitive applications and speed up the execution of sensitive applications.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computer resource allocation, and in particular to a method for quickly establishing a security domain oriented to a multi-security domain architecture. Background Art

[0002] To solve the problems of high data transmission cost, long latency and data security in cloud computing, edge computing has been proposed and developed continuously. Applications that require fast response and security and privacy have been deployed on edge platforms in large quantities. Due to the rich ecology and high cost-effectiveness of the ARM platform, modern ARM platform machines have become a typical choice for edge platforms. Therefore, executing sensitive applications (for example, artificial intelligence services and data flow analysis engines) on ARM edge devices is a major trend, and there are challenges in executing sensitive applications reliably and securely on untrusted edge devices.

[0003] TrustZone is a security architecture for trusted execution environments widely deployed on ARM platforms. It provides software with a highly privileged and isolated execution environment based on hardware-based security features. The academic community has proposed a multi-security domain architecture that uses the new features provided by TrustZone to create a security domain (called a user-mode security zone) in the ordinary world. Compared to the original TrustZone architecture that only provides a single security domain (secure world), the multi-security domain architecture not only provides an isolated execution environment for sensitive applications, but also removes the privileges of applications protected by TrustZone.

[0004] like Figure 1 As shown, under the multi-security domain architecture, the life cycle of the user-mode security zone includes two parts: establishment and destruction.

[0005] Establishment of a user-mode security zone. The establishment of a user-mode security zone requires four steps: (1) Loading software binary files: Loading sensitive applications and libraries that support the operation of sensitive applications (usually an operating system kernel, for example, the original multi-security domain architecture prototype uses the Zircon microkernel) into memory; (2) Allocating CPU computing resources: Allocating CPU resources to the security domain to be established; (3) Verifying the security of the user-mode security zone: Verifying the integrity of the runtime library (Zircon kernel) and sensitive applications to prevent tampering; (4) Starting the security domain: Early initialization of the CPU core, initialization of the kernel environment, and establishment of an environment for user program operation.

[0006] Destruction / reclaiming of the user-mode security zone. When the sensitive application is executed, the multi-security domain architecture will reclaim the resources of the user-mode security zone through three processes: (1) Closing the security zone: clearing the CPU cache and stopping the kernel; (2) Unlocking the user-mode security zone: clearing and reclaiming all memory used by the user-mode security zone; (3) Reclaiming CPU resources: The multi-security domain architecture returns the CPU used by the user-mode security zone to the original system through CPU hot plugging.

[0007] like Figure 2 As shown in Figure 1, the Linux kernel CPU hot-plug mechanism only supports serial CPU addition or removal operations, that is, it only supports single CPU online or offline operations at a time. For example, if the system needs to remove two CPUs, CPU2 must wait for CPU1 to complete the three steps of complete CPU removal before entering its own removal process.

[0008] Since the current multi-security domain architecture is designed for low-frequency sensitive application execution on mobile terminals, in the scenario of high-frequency sensitive application execution on the edge, the inefficient establishment of user-mode security zones cannot meet the rapid response execution of sensitive applications; in addition, in the case of unpredictable sensitive application execution timing, in order to meet the rapid response of sensitive applications, the continuous maintenance of sensitive application execution will lead to reduced system resource utilization. In the scenario of high computing resource demand application execution, it is impossible to quickly allocate multiple CPU computing resources to the application to meet the rapid execution of the application. Summary of the invention

[0009] The technical problem to be solved by the present invention is: in view of the technical problems existing in the prior art, the present invention provides a method for quickly establishing a security domain for a multi-security domain architecture, which shortens the response time of sensitive applications and speeds up the execution of sensitive applications.

[0010] In order to solve the above technical problems, the technical solution proposed by the present invention is:

[0011] A method for quickly establishing a security domain for a multi-security domain architecture includes the steps of establishing a user-mode security zone and reclaiming CPU computing resources in the user-mode security zone.

[0012] The step of establishing the user-mode security zone includes: when a sensitive application is triggered to execute, if there is a user-mode security zone corresponding to the sensitive application, allocating CPU resources to the user-mode security zone, and restoring the execution environment of the user-mode security zone according to the execution environment information of the user-mode security zone;

[0013] The step of reclaiming CPU computing resources in the user-mode security zone includes: after the sensitive application is executed, closing the user-mode security zone, saving the execution environment information of the user-mode security zone to the secure world, and finally reclaiming CPU resources.

[0014] Furthermore, the step of establishing the user-state security zone also includes: when a sensitive application is triggered for execution, if there is no user-state security zone corresponding to the sensitive application, the sensitive application and the corresponding library are loaded into the memory, CPU resources are allocated to the user-state security zone, and after verifying the security of the user-state security zone, the user-state security zone is started and the sensitive application is executed.

[0015] Furthermore, the specific steps of allocating CPU resources to the user-mode security zone include:

[0016] Obtaining a CPU mask parameter, and determining a target CPU to be allocated according to the CPU mask parameter;

[0017] Each target CPU executes the callback function of the first part of the OP phase and the callback function of the OAS phase in the CPU removal process, and then allocates each target CPU to the user-mode security zone.

[0018] Furthermore, each target CPU executes the callback function of the first part of the OP stage and the callback function of the OAS stage in the CPU removal process, and then the specific steps of allocating each target CPU to the user state security zone include: the current target CPU executes each callback function of the first part of the OP stage, and then executes each callback function of the OAS stage, and finally the current target CPU is merged into the user state security zone computing resources, and the next target CPU is used as the current target CPU, and this step is repeated until all target CPUs are traversed.

[0019] Furthermore, after each target CPU is assigned to the user-mode security zone, the method further includes: other online CPUs execute the callback function of the second part of the OP phase and the callback function of the SD phase in the CPU removal process of each target CPU.

[0020] Furthermore, the specific steps of other online CPUs executing the callback function of the second part of the OP stage and the callback function of the SD stage in the CPU removal process of each target CPU include: other online CPUs execute each callback function of the second part of the OP stage of the current target CPU, and then execute each callback function of the SD stage of the current target CPU, take the next target CPU as the current target CPU, and repeat this step until all target CPUs are traversed.

[0021] Furthermore, the callback function of the first part of the OP phase includes a callback function sched_cpu_deactivate() for updating variables recording all CPU states in the system, and the lock corresponding to the callback function sched_cpu_deactivate() that protects the variables recording the CPU states is a read-write lock.

[0022] Furthermore, the callback functions of the second part of the OP phase include a callback function free_slot_cache() registered with the memory management subsystem and a callback function cpuhp_cpufreq_offline() registered with the power management subsystem.

[0023] Furthermore, it also includes the step of reclaiming memory resources in the user-state security zone, specifically including: if the memory is insufficient or the memory used by all user-state security zones exceeds a preset threshold when a new user-state security zone is established, then the target user-state security zone is selected according to a preset recycling strategy, and the memory used by the target user-state security zone is recycled.

[0024] Furthermore, the specific steps of saving the execution environment information of the user-mode security zone to the secure world and finally reclaiming CPU resources include:

[0025] Saving a user-mode security zone control block corresponding to the user-mode security zone to the secure world, wherein the user-mode security zone control block includes a user-mode context, a kernel-mode context, all interrupts used, and a system clock of the user-mode security zone;

[0026] The memory used by the user-mode security zone is configured to prohibit CPU access, and the CPU resources allocated by the user-mode security zone are returned to the normal world.

[0027] Compared with the prior art, the advantages of the present invention are:

[0028] 1. The present invention improves the establishment and recovery of the user-mode security zone, and implements a snapshot / recovery mechanism for the user-mode security zone. After the execution of the sensitive application is completed, the execution environment information of the user-mode security zone is saved to the secure world, and the memory resources used by the user-mode security zone are not recovered. When the same sensitive application needs to be executed again, the execution environment of the corresponding user-mode security zone can be directly restored to execute the sensitive application, without repeating the two steps of loading the software binary file and starting the user-mode security zone in the existing user-mode security zone establishment process. The response execution speed of the sensitive application can be accelerated, thereby supporting a fast response when the sensitive application is executed twice or multiple times, and there is no need to maintain the execution of the sensitive application all the time, saving system resources.

[0029] 2. The present invention improves the CPU resource allocation process. When allocating CPU resources to the user-state security zone, each target CPU executes the callback function of the first part of the OP stage and the callback function of the OAS stage in the CPU removal process, and then each target CPU is allocated to the user-state security zone. The callback function of the second part of the OP stage and the callback function of the SD stage of each target CPU are delegated to other online CPUs for execution, thereby realizing a multi-CPU pseudo-parallel removal mechanism. Each CPU only needs to execute part of the steps of CPU hot plugging, which speeds up the CPU resource allocation and improves the efficiency of CPU resource allocation. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 The figure is a flowchart of establishing and reclaiming an existing user-mode security zone.

[0031] Figure 2 A flowchart of the existing multi-CPU removal process is shown below.

[0032] Figure 3 The division of callback functions corresponding to each stage in the CPU removal process.

[0033] Figure 4 Schematic diagram of the CPU resource allocation process when establishing an existing user-mode security zone.

[0034] Figure 5 The figure is a flow chart of establishing and recovering a user-mode security zone when a sensitive application is triggered to execute for the first time in the first embodiment of the present invention.

[0035] Figure 6 The figure is a flow chart of establishing and recovering a user-mode security zone when a sensitive application is triggered to execute twice in the first embodiment of the present invention.

[0036] Figure 7 This is a flow chart of establishing a user-mode security zone in the first embodiment of the present invention.

[0037] Figure 8 The figure is a schematic diagram of the CPU resource allocation process when establishing a user-mode security zone in the first embodiment of the present invention.

[0038] Fig. 9 4 is a flowchart of the pseudo-parallel removal process of CPU1 and CPU2 in the first embodiment of the present invention. DETAILED DESCRIPTION

[0039] The present invention is further described below in conjunction with the accompanying drawings and specific preferred embodiments, but the protection scope of the present invention is not limited thereby.

[0040] Definitions of Abbreviations and Key Terms

[0041] ARM: (Advanced RISC Machines, Advanced Reduced Instruction Set Machine)

[0042] RCU lock: a lock commonly used in the Linux kernel, (Read-Copy-Update) lock

[0043] CPU hotplug: CPU hotplug is a widely used mechanism in Linux to support scaling of processor sets. The CPU hotplug subsystem provides an interface for other kernel subsystems to subscribe to notifications of processor set changes. When a CPU hotplug event occurs, the notification functions (callback functions) registered by other subsystems will be called to ensure that the system can sense and maintain normal operation when a CPU is removed or added, such as Figure 3 As shown in the figure, under the CPU hot-plug mechanism, a complete CPU removal process includes three stages: CPU offline preparation (OP), CPU offline and stop (OAS), and CPU stop completion (SD). Each stage contains a varying number of processing steps (callback functions). When a CPU hot-plug event occurs, the callback functions registered by other subsystems will be called to ensure that the system can sense and maintain normal operation when the CPU is removed or added.

[0044] ARM TrustZone: ARM TrustZone is a hardware-based security feature that provides a highly privileged and isolated execution environment for software. Compared with pure software methods, hardware-assisted security has many advantages: the mechanism is not affected by software attacks, better execution efficiency, and smaller interfaces. This isolation guaranteed by hardware is generally considered more trustworthy than software. Therefore, the execution environment provided by ARM TrusZone is called Trusted Execution Environment (TEE).

[0045] TrustZone multi-security domain architecture: A security architecture proposed by the academic community based on the latest hardware features of ARM TrustZone. Compared with the original TrustZone architecture that only provides a single security domain (secure world), this architecture uses the TrustZone feature to create a security domain that is independent of the secure world and in the ordinary world, thus forming a multi-security domain architecture with a secure world and multiple ordinary world security zones. The basic principle is to specify a continuous section of memory, configure the memory controller so that only the specified CPU can access the memory, load sensitive applications into the memory, and assign the specified CPU to execute sensitive applications.

[0046] User-mode security zone: The common world security zone under the multi-security domain architecture is called the user-mode security zone. The steps of establishing the user-mode security zone under the existing technology can be expanded as follows: Figure 1As shown in the upper part, first load the software binary file: load the sensitive application and the library supporting the operation of the sensitive application into the memory, and then allocate CPU computing resources: the steps of the CPU resource allocation process under the prior art can be expanded as follows Figure 4 As shown, after the three stages of OP, OAS, and SD of the CPU removal process, CPU resource allocation is completed, the allocated CPU verifies and starts the user-mode security zone, and finally runs sensitive applications.

[0047] Embodiment 1

[0048] In this embodiment, the establishment and recovery of the user-mode security zone are processed according to the two situations of the first triggering and executing of the sensitive application and the second (multiple) triggering and executing of the sensitive application:

[0049] like Figure 5 As shown, when the sensitive application is triggered to execute for the first time, the user-mode security zone establishment process of this embodiment still follows the four steps of loading the software binary file, allocating CPU computing resources, verifying the security of the user-mode security zone, and starting the security domain. However, for allocating CPU computing resources, this embodiment proposes and implements a fast CPU allocation method to shorten the establishment time of the user-mode security zone. At the same time, based on the fast CPU allocation method, this embodiment proposes a pseudo-parallel CPU hot-plug mechanism for sensitive applications that require multiple CPU computing resources, which realizes the rapid allocation of multiple CPUs to meet the rapid execution of sensitive applications with heavy computing resource requirements. The user-mode security zone recovery process of this embodiment only recovers CPU computing resources. After closing the user-mode security zone, the memory used by the user-mode security zone is not recovered according to the prior art, but the destruction of the user-mode security zone is delayed, and the execution environment of the user-mode security zone is saved to prepare for the secondary trigger execution of the sensitive application, so as to speed up the secondary trigger execution of the sensitive application.

[0050] like Figure 6 As shown, when the sensitive application is triggered for the second time, during the establishment of the user-mode security zone in this embodiment, the execution environment of the user-mode security zone when the sensitive application is triggered for the first time is saved, and the memory used by the user-mode security zone is not recycled. Therefore, it is only necessary to allocate CPU computing resources again and restore the execution environment of the user-mode security zone to re-establish the user-mode security zone. The user-mode security zone recycling process is consistent with the user-mode security zone recycling process when the sensitive application is triggered for the first time. The execution environment of the user-mode security zone is saved to prepare for the next triggering and execution of the sensitive application, so as to speed up the next triggering and execution of the sensitive application.

[0051] Based on the above concept, this embodiment proposes a method for quickly establishing a security domain for a multi-security domain architecture, including the steps of establishing a user-mode security zone and reclaiming CPU computing resources in the user-mode security zone, wherein:

[0052] like Figure 7 As shown, in this embodiment, the steps of establishing the user-mode security zone include:

[0053] When a sensitive application is triggered for execution, if there is no user-mode security zone corresponding to the sensitive application, the sensitive application and the corresponding library are loaded into the memory to start establishing the user-mode security zone corresponding to the sensitive application, CPU resources are allocated to the user-mode security zone, and after verifying the security of the user-mode security zone, the user-mode security zone is started and the sensitive application is executed;

[0054] When a sensitive application is triggered for execution, if there is a user-mode security zone corresponding to the sensitive application, CPU resources are allocated to the user-mode security zone, the execution environment of the user-mode security zone is restored according to the execution environment information of the user-mode security zone, and the sensitive application is executed;

[0055] The step of reclaiming CPU computing resources in the user-mode security zone includes: after the sensitive application is executed, closing the user-mode security zone, saving the execution environment information of the user-mode security zone to the secure world, and finally reclaiming CPU resources.

[0056] The above steps improve the establishment and recovery of the user-mode security zone. After the sensitive application is executed, the execution environment information of the user-mode security zone is saved to the secure world, and the memory resources used by the user-mode security zone are not recovered. When the same sensitive application needs to be executed again, the execution environment of the corresponding user-mode security zone can be directly restored to execute the sensitive application without repeating the two steps of loading the software binary file and starting the user-mode security zone in the existing user-mode security zone establishment process. This can speed up the response execution speed of sensitive applications, thereby supporting fast response when sensitive applications are executed twice or multiple times.

[0057] Each time a user-mode security zone is established, a CPU allocation step must be performed. To speed up the establishment of a user-mode security zone, the CPU allocation time must be shortened. Therefore, after verification and analysis, this embodiment delegates some stages or steps in the removal process of the CPU to be allocated to other online CPUs for execution, so that the CPU to be allocated only needs to execute the remaining stages or steps, thereby shortening the CPU resource allocation time. The key technologies include:

[0058] (1) Fast CPU allocation path. The fast CPU allocation path means that after the hot plug of the CPU to be allocated passes the OAS stage, the CPU is allocated to the user-mode security zone. When the CPU to be allocated completes the OP and OAS stages of the CPU hot plug and enters the CPU stop state, the remaining SD stage can be completed by other online CPUs in the system to end the entire CPU removal process. The execution of the SD stage is independent of the CPU to be allocated. Therefore, at the end point of the OAS stage, the CPU to be allocated is separated and the user-mode security zone is established to speed up the CPU allocation and shorten the response speed of sensitive tasks.

[0059] (2) Optimization of callback functions. Callback function optimization refers to optimizing the execution time of some steps in the OP phase to shorten the CPU allocation time. Specifically, in this embodiment, the first step in the OP phase is first optimized: the callback function sched_cpu_deactivate() registered by the scheduling subsystem. The callback function sched_cpu_deactivate() is mainly responsible for updating the variables that record the status of all CPUs in the system: marking the CPU to be offline from the active state to the online state. This function needs to be executed synchronously until the variables that record the CPU status in the system are updated. For the lock that protects the variables that record the CPU status, this embodiment uses a read-write lock to replace the RCU lock to reduce the time overhead caused by the callback function sched_cpu_deactivate() waiting for the CPU status update to be completed. Although each access to the variable that records the CPU status needs to be locked after adopting the read-write lock, its performance overhead is not large, so the replacement of the lock will not bring too much performance overhead to the system. The optimized callback function sched_cpu_deactivate() together with the callback functions ledtrig_prepare_down_cpu(), cpuid_cpu_offline(), vmstat_cpu_down_prep(), rcutree_offline_cpu(), workqueue_offline_cpu(), perf_event_exit_cpu(), and smpboot_park_threads() constitute the first part of the OP phase. All callback functions in this part are executed by the assigned CPU.

[0060] (3) Delegated execution of callback functions. Delegated execution of callback functions refers to delegating part of the steps in the OP phase to other online CPUs for execution to shorten the CPU allocation time. Specifically, in this embodiment, some callback functions that are time-consuming and have no effect on CPU hot plugging after sequence modification in the original OP phase constitute the second part of the OP phase, and are delegated to other online CPUs in the system for execution. For example, the callback function free_slot_cache() registered by the Linux kernel memory management subsystem and the callback function cpuhp_cpufreq_offline() registered by the power management subsystem are delegated to other online CPUs for completion. The former is when a CPU removal event occurs, the system needs to release the swap partition cache maintained by the memory management subsystem for the removed CPU, and the latter is to clear the removed CPU from the objects managed by the current frequency adjustment policy of the system. Both of them can be delayed and delegated to other online CPUs in the system for execution. Correspondingly, in this embodiment, a range of CPUHP_AP_DYING_CMON to CPUHP_AP_DYING_CMON_END steps is added in the Linux kernel for registering the callback function to be delegated, and the CPU hot-plug callback function registration interface of the original Linux kernel is reused to register the callback function to be delegated. Therefore, other subsystems can conveniently register any callback function that can be delegated for execution.

[0061] The delegated execution of callback functions is not limited to the above two specific callback functions. Any steps in the OP phase that do not affect the correctness of CPU hot plugging and ensure that the original system can still execute normally under delegated execution can use the delegated execution mechanism.

[0062] like Figure 8 As shown, the CPU to be allocated only needs to execute some callback functions in the OP stage and the callback functions in the OAS stage, and can directly start subsequent verification and start user-mode security zone operations (when sensitive applications are triggered for the first time), or perform subsequent operations to restore the execution environment of the user-mode security zone (when sensitive applications are triggered for the second time) without waiting for the completion of the SD stage.

[0063] At the same time, in edge computing scenarios, a sensitive task with heavy computing load requires multiple CPU computing resources. Since the CPU hot-swap mechanism only supports serial CPU addition or removal operations, even after applying the fast CPU allocation technology, in the case of multiple CPU allocation, the latter CPU still needs to wait for the former CPU to complete the OP, OAS, and SD stages before continuing the removal operation. Therefore, the present invention proposes a CPU pseudo-parallel allocation interface to achieve the following Fig. 9The multi-CPU allocation process shown in the figure. After the first part of the OP phase and the OAS phase of CPU1, CPU1 is now ready to start verification and start the user-mode security zone; after the first part of the OP phase and the OAS phase of CPU2, CPU2 is also ready to be incorporated into the computing resources of the user-mode security zone; finally, other online CPUs complete the finishing work, including the second part of the OP phase and the SD phase of CPU1, and the first part of the OP phase and the SD phase of CPU2.

[0064] Based on the above content, in this embodiment, the specific steps of allocating CPU resources to the user-mode security zone include:

[0065] Get the CPU mask parameter, and determine the target CPU to be allocated according to the CPU mask parameter. Assume that two CPUs (CPU1 and CPU2) need to be allocated to the user-mode security zone. The sensitive application execution triggers the call of the multi-CPU allocation interface, and the CPU mask parameter is passed in. The value is 0b0000_0110 (a binary number, and the corresponding bits 1 (low bit starts from 0) and 2 specify the CPU1 and CPU2 resources to be allocated respectively);

[0066] Each target CPU executes the callback function of the first part of the OP phase and the callback function of the OAS phase in the CPU removal process, and then allocates each target CPU to the user state security zone, specifically including: the current target CPU executes each callback function of the first part of the OP phase, and then executes each callback function of the OAS phase, and finally merges the current target CPU into the user state security zone computing resources, takes the next target CPU as the current target CPU, and repeats this step until all target CPUs are traversed;

[0067] The other online CPUs execute the callback function of the second part of the OP phase and the callback function of the SD phase in the CPU removal process of each target CPU, specifically including: the other online CPUs execute each callback function of the second part of the OP phase of the current target CPU, and then execute each callback function of the SD phase of the current target CPU, take the next target CPU as the current target CPU, and repeat this step until all target CPUs are traversed.

[0068] In this embodiment, the steps of establishing the user-mode security zone when the sensitive application is reclaimed and triggered for execution for the second time include:

[0069] (1) After the sensitive application is executed, the corresponding user-mode security zone is closed;

[0070] (2) Save the execution environment information of the user enclave to the secure world, including: saving the user enclave context, kernel enclave context, all interrupts used, and system clock of the user enclave as UECB (User Enclave Control Block) to the secure world;

[0071] (3) Reclaiming CPU resources, specifically including: configuring the memory ARM TrustZone address space controller TZC-400 to configure the memory used in the user-mode security zone to be inaccessible to any CPU, and returning CPU resources to the normal world system. TZC-400 allows memory access permissions to be set based on the bus master ID. Traditionally, on the ARMv8 architecture, all CPU cores have a uniquely assigned multiprocessor ID (MPID register). For all transactions sent to the system bus, the multiprocessor ID is converted from a dedicated tag component to a bus master ID. By configuring the REGION_ID_ACCESS register of TZC-400 through software, it is possible to allocate a memory region exclusively to a single CPU core by filtering bus transactions tagged with the bus master ID. The upper 16 bits (bit[31:16]) of the REGION_ID_ACCESS register of TZC-400 specify the write enable of the memory, and the lower 16 bits (bit[15:0]) specify the read enable of the memory. Each bit in the upper and lower 16 bits corresponds to the read / write enable of a bus master ID. This means, for example, that if bits 0 and 16 of REGION_ID_ACCESS_1 are set to 1 and all other bits are set to 0, only the bus master with association ID 0 is allowed to perform write or read access to region 1.

[0072] (4) When the sensitive application is triggered again, such as Figure 7 As shown, first, a request is made to the secure world to inquire whether a user-mode security zone has been established for the application. If so, CPU resources are directly allocated to the user-mode security zone. If not, the sensitive application and the corresponding library must be loaded into the memory first, and then CPU resources are allocated to the user-mode security zone. Then, if a user-mode security zone for the application already exists, control is handed over to the secure world operating system (TrustOS) to check the integrity of the memory information used by the user-mode security zone. TrustOS then restores the execution environment of the user-mode security zone based on the saved UECB, and configures the memory access permissions of the CPU resources according to the reverse configuration process of step 3), and finally starts executing the sensitive application. If the user-mode security zone does not exist, the security of the user-mode security zone must be verified first, and then the user-mode security zone must be started, and then the sensitive application can be executed.

[0073] Embodiment 2

[0074] This embodiment is basically the same as the first embodiment, except that, in order to avoid the situation where sensitive applications are no longer executed for a long time and the memory used by the corresponding user-mode security zone occupies memory resources, a lazy recovery mechanism is added in this embodiment to recycle the memory resources used by the user-mode security zone at a certain opportunity, that is, this embodiment includes a step of reclaiming memory resources in the user-mode security zone in addition to the step of establishing the user-mode security zone and the step of reclaiming the CPU computing resources of the user-mode security zone, specifically including: if there is insufficient memory, that is, when OOM (Out Of Memory) occurs in the Linux kernel, or when a new user-mode security zone is established, the memory used by all user-mode security zones exceeds a preset threshold (for example, more than 50% of the total system memory), then the target user-mode security zone is selected according to the preset recovery strategy, and the memory used by the target user-mode security zone is reclaimed.

[0075] In this embodiment, the recycling strategy includes: selecting the user-mode security zone that has not been used for the longest time and has been used the least recently, etc.

[0076] On this basis, the memory resources of the user-mode security zone can be recycled in a more fine-grained manner. That is, when the system memory is insufficient, or when a new user-mode security zone is established and the memory used by all user-mode security zones exceeds the preset threshold, the memory resources of the entire user-mode security zone are not recycled in full, but only the memory resources of some user-mode security zones are recycled, and the information of the recycled memory resources is encrypted and swapped out to the disk. When the sensitive application is executed again, the corresponding encrypted information on the disk is decrypted and swapped into the memory, and then the execution environment of the corresponding user-mode security zone is restored.

[0077] The above is only a preferred embodiment of the present invention, and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment, it is not intended to limit the present invention. Therefore, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the scope of protection of the technical solution of the present invention.

Claims

1. A method for quickly establishing a security domain for a multi-security domain architecture, comprising the steps of establishing a user-mode security zone and reclaiming CPU computing resources in the user-mode security zone, characterized in that: The step of establishing the user-mode security zone includes: when a sensitive application is triggered to execute, if there is a corresponding user-mode security zone, allocating CPU resources to the user-mode security zone, and restoring the execution environment of the user-mode security zone according to the execution environment information of the user-mode security zone; The step of reclaiming CPU computing resources in the user-mode security zone includes: after the sensitive application is executed, closing the user-mode security zone, saving the execution environment information of the user-mode security zone to the secure world, and finally reclaiming CPU resources; The specific steps of allocating CPU resources to the user-mode security zone include: Obtaining a CPU mask parameter, and determining a target CPU to be allocated according to the CPU mask parameter; Each target CPU executes the callback function of the first part of the OP phase and the callback function of the OAS phase in the CPU removal process, and then allocates each target CPU to the user state security zone; Each target CPU executes the callback function of the first part of the OP stage and the callback function of the OAS stage in the CPU removal process, and then the specific steps of allocating each target CPU to the user-state security zone include: the current target CPU executes each callback function of the first part of the OP stage, and then executes each callback function of the OAS stage, and finally merges the current target CPU into the user-state security zone computing resources, takes the next target CPU as the current target CPU, and repeats this step until all target CPUs are traversed.

2. The method for rapidly establishing a security domain for a multi-security domain architecture according to claim 1, characterized in that: The step of establishing the user-state security zone also includes: when a sensitive application is triggered for execution, if there is no user-state security zone corresponding to the sensitive application, the sensitive application and the corresponding library are loaded into the memory, CPU resources are allocated to the user-state security zone, and after verifying the security of the user-state security zone, the user-state security zone is started and the sensitive application is executed.

3. The method for rapidly establishing a security domain for a multi-security domain architecture according to claim 2, characterized in that: After allocating each target CPU to the user-mode security zone, the method further includes: other online CPUs execute the callback function of the second part of the OP phase and the callback function of the SD phase in the CPU removal process of each target CPU.

4. The method for rapidly establishing a security domain for a multi-security domain architecture according to claim 3, characterized in that: The specific steps of other online CPUs executing the callback function of the second part of the OP stage and the callback function of the SD stage in the CPU removal process of each target CPU include: other online CPUs execute each callback function of the second part of the OP stage of the current target CPU, and then execute each callback function of the SD stage of the current target CPU, take the next target CPU as the current target CPU, and repeat this step until all target CPUs are traversed.

5. The method for rapidly establishing a security domain for a multi-security domain architecture according to claim 2, characterized in that: The callback function of the first part of the OP phase includes a callback function sched_cpu_deactivate() for updating variables recording all CPU states in the system. The lock corresponding to the callback function sched_cpu_deactivate() that protects the variables recording the CPU states is a read-write lock.

6. The method for rapidly establishing a security domain for a multi-security domain architecture according to claim 3, characterized in that: The callback functions of the second part of the OP phase include a callback function free_slot_cache() registered with the memory management subsystem and a callback function cpuhp_cpufreq_offline() registered with the power management subsystem.

7. The method for rapidly establishing a security domain for a multi-security domain architecture according to claim 1, characterized in that: It also includes the step of reclaiming memory resources in the user-state security zone, specifically including: if there is insufficient memory or the memory used by all user-state security zones exceeds a preset threshold when a new user-state security zone is established, then a target user-state security zone is selected according to a preset recycling strategy, and the memory used by the target user-state security zone is recycled.

8. The method for rapidly establishing a security domain for a multi-security domain architecture according to claim 1, characterized in that: The specific steps of saving the execution environment information of the user-mode security zone to the secure world and finally reclaiming CPU resources include: Saving a user-mode security zone control block corresponding to the user-mode security zone to the secure world, wherein the user-mode security zone control block includes a user-mode context, a kernel-mode context, all interrupts used, and a system clock of the user-mode security zone; The memory used by the user-mode security zone is configured to prohibit CPU access, and the CPU resources allocated by the user-mode security zone are returned to the normal world.