WO2024051311A1 - 数据处理方法、终端设备和可读存储介质 - Google Patents
数据处理方法、终端设备和可读存储介质 Download PDFInfo
- Publication number
- WO2024051311A1 WO2024051311A1 PCT/CN2023/103965 CN2023103965W WO2024051311A1 WO 2024051311 A1 WO2024051311 A1 WO 2024051311A1 CN 2023103965 W CN2023103965 W CN 2023103965W WO 2024051311 A1 WO2024051311 A1 WO 2024051311A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- execution environment
- task
- thread
- shared memory
- trusted
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0806—Multiuser, multiprocessor or multiprocessing cache systems
- G06F12/084—Multiuser, multiprocessor or multiprocessing cache systems with a shared cache
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0806—Multiuser, multiprocessor or multiprocessing cache systems
- G06F12/0842—Multiuser, multiprocessor or multiprocessing cache systems for multiprocessing or multitasking
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/14—Protection against unauthorised use of memory or access to memory
- G06F12/1458—Protection against unauthorised use of memory or access to memory by checking the subject access rights
- G06F12/1491—Protection against unauthorised use of memory or access to memory by checking the subject access rights in a hierarchical protection system, e.g. privilege levels, memory rings
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/50—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
- G06F21/52—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
- G06F21/53—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow by executing in a restricted environment, e.g. sandbox or secure virtual machine
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/70—Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
- G06F21/71—Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information
- G06F21/72—Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information in cryptographic circuits
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/70—Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
- G06F21/71—Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information
- G06F21/74—Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information operating in dual or compartmented mode, i.e. at least one secure mode
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/50—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
- G06F21/57—Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5011—Pool
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5018—Thread allocation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/548—Queue
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Definitions
- the embodiments of the present application relate to the field of computer technology, and in particular, to a data processing method, terminal device, and readable storage medium.
- ARM means advanced reduced instruction set processors (advanced RISC machines)
- RISC means reduced instruction set computer (reduced instruction set computer)
- TrustZone means trust zone.
- the software and hardware resources of terminal devices are divided into two worlds, called the secure world and the normal world.
- the execution environment corresponding to the secure world is called a trusted execution environment (TEE), and a trusted application (TA) runs in the TEE.
- the execution environment corresponding to the normal world is called rich execution environment (rich execution environment, REE), and common applications (common application, CA) run in REE.
- REE and TEE are isolated from each other, and TEE has higher safety requirements.
- Embodiments of the present application provide a data processing method, a terminal device and a readable storage medium, which improve data processing efficiency.
- a data processing method is provided, applied to a terminal device, and the terminal device deploys a trusted execution environment and a non-trusted execution environment; the method includes: in the first execution environment, the first application program passes the first thread The initiated task is stored in the shared memory; the task is used to call the software function provided by the second application in the second execution environment; the shared memory is pre-applied for the first application in the untrusted execution environment and is used for untrusted The physical memory area accessed by the execution environment and the trusted execution environment; the first execution environment is a non-trusted execution environment and the second execution environment is a trusted execution environment, or the first execution environment is a trusted execution environment and the second execution environment It is a non-trusted execution environment; in the second execution environment, the task is obtained from the shared memory; in the second execution environment, the second thread is assigned to the task; the second thread is created in the second execution environment, and the second thread The processing units bound to the first thread are different; in the second execution environment, the second application program executes the task through
- the data processing method provided in the first aspect by pre-applying for shared memory for the first application in the first execution environment, and storing relevant data of the execution task in the shared memory, the trusted execution environment and the non-trusted execution environment pass Accessing shared memory completes data transfer without requiring multiple copies of data, shortens the data transmission path between the trusted execution environment and the non-trusted execution environment, and improves the efficiency of data processing.
- the processing unit bound to the first thread does not need to perform CPU mode switching, reducing the It reduces CPU switching overhead and improves processing efficiency.
- the processing unit bound to the second thread can execute the task initiated by the first application program in the second execution environment without switching the CPU mode. Reduces CPU switching overhead and improves processing efficiency.
- storing the task in the shared memory includes: in the first execution environment, serializing the task and obtaining the serialized message of the task; in the first execution environment, storing the task in the shared memory.
- the serialized messages of the tasks are stored in the message queue; the message queue is stored in the shared memory and is used to store serialized messages corresponding to multiple tasks initiated by the first application program; in the first execution environment, the serialized messages of the tasks are stored in the shared memory.
- the execution flag bit of is set to the first value; where the first value is used to indicate Indicates that the status of the serialized message is pending execution.
- the second execution environment can quickly obtain the unprocessed task, thereby improving processing efficiency.
- obtaining the task from the shared memory includes: in the second execution environment, accessing the message queue to obtain the serialized message of the task whose execution flag bit is the first value; In the second execution environment, the serialized message of the task is parsed to obtain the task.
- the second execution environment after the second application program executes the task through the second thread, obtains the task result, and stores the task result in the shared memory, it also includes: in the second execution environment , setting the execution flag bit of the serialized message of the task to a second value; wherein the second value is used to indicate that the status of the serialized message is an executed state.
- the method before storing the task initiated by the first application program through the first thread in the first execution environment into the shared memory, the method further includes: in the first execution environment, by the first application program through the first thread.
- a thread initiates a task and registers a callback function.
- the first application by registering the callback function, after the first application initiates a task, it does not need to wait for the task result, but can perform subsequent application business logic processing through the first thread.
- the waiting time after the first application initiates a task is shortened, and the problem of the second execution environment execution task blocking the execution of the business logic of the first application is solved.
- the method further includes: in the first execution environment, calling the callback function through a third thread; the third thread is different from the first thread.
- the number of third threads is less than or equal to the number of tasks initiated by the first application.
- the task includes incoming parameters and outgoing parameters, and the storage locations of the incoming parameters and outgoing parameters are located in the shared memory; in the first execution environment, the task will be initiated by the first application through the first thread.
- the task Before the task is stored in the shared memory, it also includes: in the first execution environment, obtaining the first reference address of the shared memory in the first execution environment, the first input address of the incoming parameter in the first execution environment and the outgoing The first output address of the parameter in the first execution environment; in the first execution environment, convert the first input address to a first input offset relative to the first base address, and convert the first output address to a first input offset relative to the first base address. The first output offset of the first base address.
- the method before the second application program executes the task through the second thread in the second execution environment, the method further includes: in the second execution environment, obtaining the second shared memory in the second execution environment. Base address; in the second execution environment, obtain the second input address of the incoming parameter in the second execution environment according to the second base address and the first input offset, and obtain the second input address of the incoming parameter in the second execution environment according to the second base address and the first output offset Get the second output address of the outgoing parameter in the second execution environment.
- the first execution environment is a trusted execution environment
- the second execution environment is a non-trusted execution environment
- the task is an ocall task.
- the first execution environment is a non-trusted execution environment
- the second execution environment is a trusted execution environment
- the task is an ecall task.
- a thread pool is established for the first application in the second execution environment.
- the thread pool includes multiple threads, and the threads in the thread pool are created in the second execution environment; the second thread Is an idle thread in the thread pool.
- the method further includes: in the second execution environment, obtaining the first number of idle threads in the thread pool; in the second execution environment, obtaining the number of unexecuted tasks in at least one task initiated by the first application program. a second number of tasks; in the second execution environment, adjust the number of threads in the thread pool according to the first number and the second number.
- the number of threads in the thread pool is adjusted in real time according to the first number of idle threads in the thread pool and the second number of unprocessed tasks, thereby avoiding CPU waste and improving data processing efficiency.
- the number of threads in the thread pool is adjusted according to the first number and the second number, including: if the first number is greater than the second number, and the total number of threads in the thread pool is greater than the minimum threshold, then in the second execution environment, destroy a thread in the thread pool; or, if the first number is less than the second number, and the total number of threads in the thread pool is less than the maximum threshold, then in the second execution environment, Create at least one thread in the thread pool; at least one thread has a number less than or Equal to the difference between the maximum threshold and the total number of threads in the thread pool.
- the method further includes: in the first execution environment, sending a minimum value to the second execution environment. threshold, maximum threshold and intermediate threshold; the intermediate threshold is greater than the minimum threshold and less than the maximum threshold; in the second execution environment, a thread pool is established for the first application, and the number of threads in the thread pool is the intermediate threshold.
- the method further includes: in the first execution environment, obtaining the memory size of the shared memory; In the first execution environment, the shared memory is allocated according to the memory size; in the first execution environment, the related information of the shared memory is sent to the second execution environment.
- the memory size includes a first memory size occupied by the message queue and a second memory size occupied by the application data; the message queue is stored in the shared memory and is used to store multiple tasks initiated by the first application program respectively.
- the addresses of the first memory space and the second memory space are consecutive.
- a terminal device in the second aspect, deploys a trusted execution environment and a non-trusted execution environment.
- the trusted execution environment deploys trusted applications and trusted processing modules.
- the untrusted execution environment deploys untrusted applications and untrusted processing modules.
- the first processing module in the first execution environment is used to store the task initiated by the first application program through the first thread into the shared memory; the task is used to call the software function provided by the second application program in the second execution environment; the shared memory It is a physical memory area that is applied in advance for the first application in the untrusted execution environment and is used for access by the untrusted execution environment and the trusted execution environment; the first execution environment is the untrusted execution environment and the second execution environment is a trusted execution environment, the first processing module is an untrusted processing module, and the second processing module is a trusted processing module, or the first execution environment is a trusted execution environment, the second execution environment is an untrusted execution environment, The first processing module is a trusted processing module and the second processing module is an untrusted processing module; the second processing module in the second execution environment is used to obtain tasks from the shared memory; the second processing module in the second execution environment , used to allocate a second thread to a task; the second thread is created in the second execution environment, and the second thread and the first thread are respectively bound to
- the first processing module in the first execution environment is used to: serialize the task in the first execution environment and obtain the serialization message of the task; in the first execution environment, convert the task's The serialized message is stored in the message queue; the message queue is stored in the shared memory and is used to store serialized messages corresponding to multiple tasks initiated by the first application program; in the first execution environment, the serialized message of the task is executed
- the flag bit is set to a first value; wherein the first value is used to indicate that the status of the serialized message is a pending execution status.
- the second processing module in the second execution environment is used to: in the second execution environment, access the message queue to obtain the serialized message of the task whose execution flag bit is the first value; In the second execution environment, parse the serialized message of the task and obtain the task.
- the second processing module in the second execution environment is also used to: after the second application executes the task through the second thread, obtains the task result, and stores the task result in the shared memory,
- the execution flag bit of the serialized message of the task is set to a second value; wherein the second value is used to indicate that the status of the serialized message is an executed status.
- the first application program in the first execution environment is used to: initiate a task through the first thread in the first execution environment and register a callback function.
- the first processing module in the first execution environment is also used to: in the first execution environment, call the callback function through a third thread; the third thread is different from the first thread.
- the number of third threads is less than or equal to the number of tasks initiated by the first application.
- the task includes incoming parameters and outgoing parameters, and the storage locations of the incoming parameters and outgoing parameters are located in the shared memory; the first processing module in the first execution environment is also used to: Before the first application program is stored in the shared memory through a task initiated by the first thread, in the first execution environment, the first reference address of the shared memory in the first execution environment and the first reference address of the incoming parameter in the first execution environment are obtained. An input address and a first output address of the outgoing parameter in the first execution environment; in the first execution environment, convert the first input address to a first input offset relative to the first base address, convert the first The output address is converted to a first output offset relative to the first base address.
- the second processing module in the second execution environment is also used to: before the second application program executes the task through the second thread, in the second execution environment, obtain the shared memory for the second execution The second base address in the environment; in the second execution environment, obtain the second input address of the incoming parameter in the second execution environment according to the second base address and the first input offset, and obtain the second input address of the incoming parameter in the second execution environment according to the second base address and the first input offset.
- An output offset obtains the second output address of the outgoing parameter in the second execution environment.
- the first execution environment is a trusted execution environment
- the second execution environment is a non-trusted execution environment
- the task is an ocall task.
- the first execution environment is a non-trusted execution environment
- the second execution environment is a trusted execution environment
- the task is an ecall task.
- a thread pool is established for the first application in the second execution environment.
- the thread pool includes multiple threads, and the threads in the thread pool are created in the second execution environment; the second thread Is an idle thread in the thread pool.
- the second processing module in the second execution environment is also used to: in the second execution environment, obtain the first number of idle threads in the thread pool; in the second execution environment, obtain the first number of idle threads in the thread pool. A second number of unexecuted tasks in at least one task initiated by an application program; in the second execution environment, adjust the number of threads in the thread pool according to the first number and the second number.
- the second processing module in the second execution environment is used to: if the first number is greater than the second number, and the total number of threads in the thread pool is greater than the minimum threshold, then in the second execution environment, Destroy one thread in the thread pool; or, if the first number is less than the second number and the total number of threads in the thread pool is less than the maximum threshold, create at least one thread in the thread pool in the second execution environment; at least one thread The number is less than or equal to the difference between the maximum threshold and the total number of threads in the thread pool.
- the first processing module in the first execution environment is also configured to: before storing the task initiated by the first application program through the first thread into the shared memory, in the first execution environment, The second execution environment sends the minimum threshold, the maximum threshold and the intermediate threshold; the intermediate threshold is greater than the minimum threshold and less than the maximum threshold; the second processing module in the second execution environment is also used to: in the second execution environment, for the first application
- the program establishes a thread pool, and the number of threads in the thread pool is an intermediate threshold.
- the first processing module in the first execution environment is also used to: before storing the task initiated by the first application program through the first thread into the shared memory, in the first execution environment, obtain The memory size of the shared memory; in the first execution environment, allocate the shared memory according to the memory size; in the first execution environment, send the relevant information of the shared memory to the second execution environment.
- the memory size includes a first memory size occupied by the message queue and a second memory size occupied by the application data; the message queue is stored in the shared memory and is used to store multiple tasks initiated by the first application program respectively.
- the addresses of the first memory space and the second memory space are consecutive.
- a third aspect provides a terminal device, including a processor.
- the processor is configured to be coupled to a memory, read instructions in the memory, and cause the terminal device to execute the method provided in the first aspect according to the instructions.
- a fourth aspect provides a program, which when executed by a processor is used to perform the method provided in the first aspect.
- a computer-readable storage medium is provided. Instructions are stored in the computer-readable storage medium. When the instructions are run on a computer or processor, the method provided in the first aspect is implemented.
- a sixth aspect provides a program product, the program product comprising a computer program, the computer program being stored in a readable storage medium, and at least one processor of the device being able to read the computer program from the readable storage medium. , the at least one processor executes the computer program so that the device implements the method provided in the first aspect.
- 1A to 1B are a set of architectural schematic diagrams of terminal equipment provided by embodiments of the present application.
- Figure 1C is another architectural schematic diagram of a terminal device provided by an embodiment of the present application.
- Figure 2 is another architectural schematic diagram of a terminal device provided by an embodiment of the present application.
- Figures 3A to 3D are a set of schematic diagrams of shared memory provided by embodiments of the present application.
- Figure 4 is a flow chart of the data processing method provided by the embodiment of the present application.
- Figure 5 is another flow chart of the data processing method provided by the embodiment of the present application.
- Figure 6 is another flow chart of the data processing method provided by the embodiment of the present application.
- Figure 7 is another flow chart of the data processing method provided by the embodiment of the present application.
- Figure 8 is a schematic structural diagram of a terminal device provided by an embodiment of the present application.
- the data processing method provided by the embodiment of this application is applied to terminal equipment.
- the embodiment of the present application does not limit the name of the terminal device.
- the terminal device is also called: terminal, electronic device, computer device, computing device or computer system, etc.
- Common terminal devices include, for example: mobile phones, tablets, laptops, desktop computers, servers, wearable devices (such as smart watches or smart bracelets), smart home devices (such as smart speakers or smart TVs), vehicle-mounted smart devices, wireless devices, etc.
- Human driving equipment virtual reality (VR) equipment, augmented reality (AR) equipment, mixed reality (MR) equipment, and artificial intelligence (artificial intelligence, AI) equipment, etc.
- OS operating system
- APP application
- the OS and APP provide rich functions for the terminal device.
- types and number of APPs are increasing, and terminal devices support more and more functions, which puts forward higher requirements for user privacy and information security.
- the software and hardware resources of the terminal device can be divided into two worlds, called the secure world and the non-secure world.
- the safe world and the non-safe world are relative concepts. Perform operations that require confidentiality in the secure world and store data that require confidentiality, such as fingerprint recognition, face recognition, password processing, data encryption and decryption, security authentication, etc., while the remaining operations are performed in the non-secure world.
- a security world is also called a security domain.
- the non-safe world is also called the non-safe domain, normal world or common world.
- the names of the secure world and the non-secure world may be different.
- the execution environment corresponding to the secure world is called a trusted execution environment
- the execution environment corresponding to the non-secure world is called a non-trusted execution environment.
- Trusted execution environment and non-trusted execution environment are relative concepts. The trusted execution environment and the non-trusted execution environment are isolated from each other. Therefore, operations that need to be kept confidential can be performed in the trusted execution environment, data that needs to be kept confidential can be stored, and key program logic and high-value data can be protected.
- Trusted applications are deployed in the trusted execution environment, and untrusted applications are deployed in the untrusted execution environment.
- Trusted applications and untrusted applications are relative concepts.
- trusted applications include but are not limited to fingerprint recognition programs, face recognition programs, etc.
- the embodiments of this application do not limit the names of trusted execution environments, non-trusted execution environments, trusted execution programs, and non-trusted execution programs. In different architectures of terminal devices, the names of these concepts may be different. Please refer to the subsequent descriptions of GP architecture and Intel SGX architecture.
- the behavior initiated in a non-trusted execution environment to call the trusted execution environment function interface is called an entry call (ecall) task or ecall call.
- the function of the trusted execution environment that is called is called the ecall function. .
- the behavior initiated in the trusted execution environment to call the non-trusted execution environment function interface is called an out call (ocall) task or ocall call.
- the function of the called non-trusted execution environment The function is called the ocall function.
- a program usually refers to a piece of executable code.
- Application can provide specific functions.
- a fingerprint recognition application provides fingerprint recognition functionality
- a face recognition application provides face recognition functionality.
- Process refers to a running activity of a program and is the basic unit of resource allocation by the operating system. It can be understood that a running program is a process. Processes have their own address space. A process can include a thread, At this point, the process is single-threaded. A process can also include multiple threads, and multiple threads can perform different tasks in parallel. At this time, the process is multi-threaded.
- Thread included in the process, is the basic unit of operation scheduling by the operating system. It can be understood that a thread is a single sequential control flow in a process. Threads are sometimes also called lightweight processes (LWP).
- LWP lightweight processes
- Central processing unit (CPU) binding refers to binding a process or thread to a designated CPU core for execution in a multi-core CPU system.
- the Global Platform has developed open architecture and application programming interface (API) standards for trusted execution environments.
- the non-safe world is called the ordinary world or normal world.
- the trusted execution environment corresponding to the secure world is called TEE, and the untrusted execution environment corresponding to the non-secure world is called REE.
- the trusted application running in TEE is called TA, and the untrusted application running in REE is called CA.
- ARM TrustZone is an architecture developed based on GP standards.
- ARM TrustZone is a hardware-based security function that introduces a secure world and a non-secure world at the processor level.
- the processor only runs in one of the worlds at any time.
- When the processor runs in the safe world it runs the code of the safe world; when the processor runs in the non-safe world, it runs the code of the non-safe world.
- the secure world and the non-secure world are switched through Monitor Mode.
- Hardware isolation of secure and non-secure worlds provides an effective mechanism for protecting application code and data.
- FIG. 1A is an architectural schematic diagram of a terminal device provided by an embodiment of the present application.
- the terminal device adopts GP architecture or ARM TrustZone architecture.
- the terminal device includes a hardware layer and a software layer.
- the hardware layer includes but is not limited to: processor and storage media.
- the software layer includes REE and TEE.
- the REE operating system and CA are deployed on the REE side.
- the REE operating system is also called a rich operating system (Rich OS), such as the existing Linux operating system or Windows operating system.
- the TEE operating system and TA are deployed on the TEE side.
- the TEE operating system is also called a trusted operating system (Trusted OS).
- Both the REE side and the TEE side include application state (or user state) and kernel state.
- the kernel state on the REE side includes the REE operating system, and the application state on the REE side includes CA.
- the kernel state on the TEE side includes the TEE operating system, and the application state on the TEE side includes TA.
- the CA can initiate an ecall task and call the API provided by the TEE side to complete certain safe and protected business logic.
- TA can also initiate ocall tasks and call the API provided by the REE side to complete some common business logic.
- some application scenarios are: in terminal device unlocking, application login, financial payment and other scenarios, CA is an unlocking application or financial payment application, and TA is a fingerprint recognition application or face recognition application.
- the CA initiates an ecall task and calls the fingerprint recognition or face recognition function provided by the TA on the TEE side.
- the CA and the TA collaborate to complete the unlocking of the terminal device, login of the application, fingerprint payment or face payment.
- REE and TEE run on separate physical memories, that is, memory isolation.
- the REE side cannot access the physical memory on the TEE side, and conversely, the TEE side cannot access the physical memory on the REE side.
- the physical memory corresponding to the REE side is called REE memory
- the physical memory corresponding to the TEE side is called TEE memory.
- the processor includes multiple processor cores, labeled core 0 to core n. At any time, the processor core is running on the REE side or on the TEE side. For example, core 0 runs in REE and is in REE mode or REE state; core 1 runs in TEE and is in TEE mode or TEE state.
- the processor includes multiple processing units.
- the embodiments of this application do not limit the type and name of the processor, and the type, name, and quantity of the processing units.
- the processor is a CPU
- the processing unit is a CPU core (or CPU core, CPU core).
- the CPU core is an important part of the CPU and is used to complete calculations, accept or store commands, process data, etc.
- Storage media also known as memory, are used to store executable program code and/or data, and the executable program code may include instructions.
- the storage medium may include a program storage area and a data storage area.
- the storage medium may include high-speed random access memory and non-volatile memory, for example, at least one magnetic disk storage device, hard disk drive (HDD), solid-state drive (SS), flash memory device, general-purpose flash memory (universal flash storage, UFS), etc., can also include volatile Memory (volatile memory), such as random-access memory (random-access memory, RAM), etc.
- the CA and TA exchange data through the REE communication agent, the message channel of the hardware layer, and the TEE communication agent.
- the REE communication agent, message channel and TEE communication agent establish a secure communication channel for CA and TA.
- the CA calls the TEE client API to communicate with the corresponding TA, and the TA calls the TEE internal API to use the programming resources provided by the TEE to implement related functions.
- Intel SGX is a technology that meets the needs of trusted computing. It is similar to ARM TrustZone and can implement a trusted execution environment.
- FIG. 1C is another architectural schematic diagram of a terminal device provided by an embodiment of the present application.
- the terminal device adopts Intel SGX architecture or SGX architecture, showing the software layer.
- the untrusted execution environment includes the operating system and applications.
- the operating system is, for example, a Linux operating system or a Windows operating system.
- Applications can be divided into two parts: the secure part (or trusted part, trusted application) and the non-secure part (or untrusted part, untrusted application).
- an application When an application needs to process confidential data, it creates a secure area (called an enclave, or trusted area, or trusted execution environment) located in trusted memory to store enclave code and enclave data, and then calls trusted functions (Also known as the enclave function, it is a function created by the developer to be executed specifically within the safe zone). Once the trusted function is called, the application will execute in the trusted zone and plainly access the enclave code and enclave data in the safe zone. In addition, any attempt to access the safe zone from outside the safe zone will be rejected by the processor. . After the trusted function is executed, the enclave data in the safe zone still remains in the trusted memory, and the application returns to the untrusted zone (or untrusted execution environment) to continue execution and loses access to the trusted memory. permissions.
- an enclave or trusted area, or trusted execution environment
- the trusted execution environment is part of the host process, which means that the application contains its own code (called application code), data (called application data) and enclave, see the left side of Figure 1C part.
- the enclave also contains its own code (called enclave code) and its own data (called enclave data), see the right part of Figure 1C.
- SGX protects the confidentiality and integrity of enclave code and enclave data.
- the embodiment of the present application takes the GP architecture as an example to describe the data processing method provided by the embodiment of the present application.
- FIG. 2 is another architectural schematic diagram of a terminal device provided by an embodiment of the present application.
- shared memory is added to the storage medium
- an untrusted processing module is added to the application state of REE
- a trusted processing module is added to the application state of TEE.
- the untrusted processing module is used to process relevant data in the REE or during the task initiated by the application in the TEE.
- the trusted processing module is used to process relevant data in the TEE during tasks initiated by REE or applications in the TEE.
- the data processing method provided by the embodiment of this application allows the REE side and the TEE side to access the data in the shared memory by applying for shared memory in advance, completing the data transfer between the REE side and the TEE side. , does not require multiple copies of data, shortens the data transmission path between REE and TEE, and improves the efficiency of data processing. Moreover, threads that perform the same task on the REE side and the TEE side are bound to different processing units. The threads that perform the task on the TEE side are created on the TEE side, which reduces CPU switching overhead and improves data processing efficiency.
- the first execution environment is an untrusted execution environment and the second execution environment is a trusted execution environment.
- the first execution environment is a trusted execution environment and the second execution environment is an untrusted execution environment. .
- the first application program is an application program in the first execution environment
- the second application program is an application program in the second execution environment.
- a task refers to a software function initiated by a first application program through a first thread in the first execution environment and used to call a software function provided by a second application program in the second execution environment.
- the first execution environment is REE
- the first application is CA
- the second execution environment is TEE
- the second application is TA.
- a user uses a payment APP to pay through fingerprint recognition.
- CA is a payment APP
- TA is a fingerprint recognition application.
- REE when the CA (payment APP) is running, the ecall task is initiated, the fingerprint identification function provided by the TA (fingerprint identification application) in the TEE is called, and the fingerprint payment is completed in the payment APP.
- Optional tasks include ecall tasks and ocall tasks.
- shared memory refers to a memory area that is applied in advance for the first application program in the non-trusted execution environment and is used for access by the non-trusted execution environment and the trusted execution environment.
- the first execution environment is REE
- the first application is CA
- CA initiates an ecall task.
- physical memory management of end devices is performed by an untrusted execution environment.
- REE a physical memory area is applied for in advance for CA, and both REE and TEE can access this physical memory area.
- the CA initiates the ecall task
- the relevant data of the ecall task can be stored in the shared memory. Therefore, the TEE side can obtain the relevant data of the ecall task from the shared memory and then execute the ecall task.
- the task result of the ecall task can be stored in the shared memory. Therefore, the REE side can obtain the task result of the ecall task from the shared memory and complete the data transmission. Since data transmission is completed without data copying, the efficiency of data processing is improved.
- the shared memory stores the incoming parameters and outgoing parameters of the function called by the task.
- the shared memory may be a physical memory area that is pre-applied for tasks initiated by the first application in the untrusted execution environment and used for access by the untrusted execution environment and the trusted execution environment.
- the embodiment of this application does not limit the memory size and location of the shared memory.
- the memory size and location of shared memory can be different when the first application is different.
- the first application includes CA1 and CA2.
- the shared memory size of CA1 is 5MB, and the starting address is 0x40000000.
- the shared memory size of CA2 is 1MB, and the starting address is 0x50000000.
- the memory size of the shared memory includes the first memory size occupied by the message queue and the second memory size occupied by the application data.
- the message queue is used to store serialized messages corresponding to multiple tasks initiated by the first application program.
- the application data includes interaction data during the execution of a task initiated by the first application.
- the embodiment of the present application does not limit the name of application data. For example, it may also be called interaction data, task data, or shared data.
- the shared memory includes a first memory space and a second memory space.
- the size of the first memory space is the first memory size and is used to store the message queue.
- the size of the second memory space is the second memory size and is used to store application data.
- the embodiments of this application do not limit the names of the first memory space and the second memory space.
- the second memory space is also called the data buffer.
- the embodiments of the present application do not limit the values of the first memory size and the second memory size, and do not limit the starting positions of the first memory space and the second memory space.
- the addresses of the first memory space and the second memory space are consecutive.
- the first application when it declares the initialization configuration, it may include at least one of the following: the memory size of the shared memory, the first memory size, the second memory size, and the number of tasks initiated by the first application.
- the first application declares the initialization configuration, it may include at least one of the following: the memory size of the shared memory, the first memory size, the second memory size, and the number of tasks initiated by the first application.
- the shared memory will be exemplarily explained below with reference to Figures 3A to 3D. Assume that the first application is CA.
- REE apply for a block according to the memory size of the shared memory.
- the physical memory area with consecutive addresses is used as the shared memory of CA.
- in REE apply for a physical memory area with consecutive addresses based on the first memory size as the first memory space in the CA shared memory for storing messages. Queue; apply for a physical memory area with consecutive addresses based on the size of the second memory as the second memory space in the CA shared memory for storing application data. Wherein, the addresses of the first memory space and the second memory space are consecutive, and the first memory space is located after the address of the second memory space.
- the first memory space and the second memory space are respectively applied for according to the first memory size and the second memory size.
- the similarity between Figure 3C and Figure 3B is that the addresses of the first memory space and the second memory space are consecutive.
- the first memory space is located before the address of the second memory space.
- the first memory space and the second memory space are respectively applied for according to the first memory size and the second memory size.
- the difference between Figure 3D, Figure 3B and Figure 3C is that in Figure 3D, the addresses of the first memory space and the second memory space are not consecutive.
- the message queue is stored in the shared memory and is used to store serialized messages corresponding to multiple tasks initiated by the first application program.
- the embodiments of this application do not limit the number of tasks that the message queue can store or the number of serialized messages that can be stored. When applications are different, the number of tasks initiated by the application program is usually different, and the capacity of the message queue is different.
- serialization is a data processing mechanism.
- IO input/output
- Serialization converts an object into a stream of bytes that a computing device can understand. Through serialization, data can be stored and transmitted in a more comprehensive way.
- serialization refers to restoring the received byte stream into an object that can be recognized by the program.
- the task before the task is stored in the message queue, the task needs to be serialized and a serialized message of the task needs to be generated. Accordingly, after retrieving the serialized message corresponding to the task from the message queue, the serialized message corresponding to the task needs to be deserialized or parsed to restore the task.
- a thread pool is established for untrusted applications in the untrusted execution environment.
- the thread pool includes multiple threads, and the threads in the thread pool are all created in a trusted execution environment. Threads in the thread pool are used to perform ecall tasks initiated by untrusted applications.
- the number of threads in the thread pool has a minimum value and a maximum value, which are called the minimum threshold and the maximum threshold respectively.
- the embodiments of this application do not limit the number of minimum thresholds and maximum thresholds.
- the minimum threshold it is ensured that there are threads in the trusted execution environment for executing ecall tasks initiated by untrusted applications, avoiding the situation where the ecall task cannot be executed.
- the maximum threshold the maximum number of threads that can execute ecall tasks initiated by untrusted applications in a trusted execution environment is limited, avoiding resource waste caused by fewer ecall tasks.
- the number of threads in the thread pool can be adjusted in real time between the minimum threshold and the maximum threshold based on the number of ecall tasks initiated by untrusted applications.
- the number of threads in the thread pool can be adjusted in real time between the minimum threshold and the maximum threshold based on the number of ecall tasks initiated by untrusted applications.
- the number of threads in the thread pool can be an intermediate threshold, where minimum threshold ⁇ intermediate threshold ⁇ maximum threshold.
- At least one of the minimum threshold, the maximum threshold and the intermediate threshold can be set for the trusted execution environment side, or for the non-trusted execution environment side, or for the trusted execution environment side and the non-trusted execution environment side. Determined after mutual negotiation between the trusted execution environment sides.
- At least one of the minimum threshold, the maximum threshold and the intermediate threshold corresponding to the thread pool may be the same or different.
- thread pool 1 is established for CA1, and the corresponding minimum threshold, maximum threshold and intermediate threshold are 2, 5 and 10 respectively.
- Thread pool 2 is established for CA2, and the corresponding minimum threshold, maximum threshold and intermediate threshold are 3, 6 and 10 respectively.
- 6 threads are created for CA2.
- a callback function is a function that is passed as a parameter.
- the process of using a callback function may include: (1) Defining a callback function; (2) The party providing the function implementation registers the function pointer of the callback function to the caller during initialization; (3) When a specific event or condition is met , the caller uses the function pointer to call the callback function to process the event.
- the pointer of the function to be called can be passed to a function as a parameter, so that the function can flexibly use different methods when handling similar events.
- a data processing method is provided, and the execution subject is a terminal device.
- the execution subject is a terminal device.
- trusted execution environments and non-trusted execution environments deployed in terminal devices. This embodiment does not limit the manner in which the terminal device implements the trusted execution environment.
- terminal equipment can adopt GP architecture or SGX architecture.
- Applications and processing modules are deployed in both trusted execution environments and non-trusted execution environments. Among them, the applications deployed in the trusted execution environment are called trusted applications, and the processing modules are called trusted processing modules. Applications deployed in a non-trusted execution environment are called non-trusted applications, and processing modules are called non-trusted processing modules.
- the data processing method provided by this embodiment is suitable for the scenario where the terminal device initiates a task through the first thread through the first application program in the first execution environment.
- the application program deployed in the first execution environment is called the first application program, and the deployed processing module is called the first processing module.
- the application program deployed in the second execution environment is called the second application program, and the deployed processing module is called the second processing module.
- the first execution environment is a non-trusted execution environment
- the first application program is an untrusted application program
- the second execution environment is a trusted execution environment
- the second application program is a trusted Applications and tasks are ecall tasks.
- the first execution environment is a trusted execution environment
- the first application program is a trusted application program
- the second execution environment is a non-trusted execution environment
- the second application program is a non-trustable execution environment.
- Letter applications and tasks are ocall tasks.
- the data processing method provided in this embodiment can be applied to at least the following scenarios:
- Scenario 1 The terminal device adopts GP architecture. Please refer to the structure shown in Figure 2.
- the first execution environment is REE
- the first application program is CA
- the first processing module is an untrusted processing module
- the second execution environment is TEE
- the second application program is TA
- the second processing module is a trusted processing module.
- the terminal device initiates the ecall task through the first thread in the REE by the CA.
- the terminal device adopts GP architecture. Please refer to the structure shown in Figure 2.
- the first execution environment is TEE
- the first application program is TA
- the first processing module is a trusted processing module
- the second execution environment is REE
- the second application program is CA
- the second processing module is an untrusted processing module.
- the terminal device initiates the ocall task through the first thread in the TEE.
- the terminal device adopts the SGX architecture. Please refer to the structure shown in Figure 1C.
- the first execution environment is a non-trusted execution environment
- the first application is the non-secure part of the application
- the first processing module is the non-trusted processing module
- the second execution environment is the Enclave
- the second application is the security of the application.
- Part and the second processing module are trusted processing modules.
- the terminal device initiates an ecall task through the first thread by the non-secure part of the application in a non-trusted execution environment.
- Scenario 4 The terminal device adopts SGX architecture, as shown in Figure 1C.
- the first execution environment is the Enclave
- the first application is the secure part of the application
- the first processing module is the trusted processing module
- the second execution environment is the untrusted execution environment
- the second application is the non-secure part of the application.
- the second processing module is an untrusted processing module.
- the terminal device initiates the ocall task through the first thread in the Enclave by the security part of the application.
- this embodiment takes scenario 1 as an example to describe the data processing method provided by this embodiment.
- FIG. 4 is a flow chart of the data processing method provided by the embodiment of the present application.
- the data processing method provided by this embodiment may include:
- CA initiates the ecall task through the first thread.
- CA initiates an ecall task to call the software function provided by TA in TEE.
- the first thread is CA’s creation in REE
- the created thread is bound to a CPU core.
- This embodiment does not limit the CPU core to which the first thread is bound.
- the CPU includes core 0 to core 31, and the CPU core bound to the first thread is core 0.
- the ecall task can include but is not limited to the following information: the function name of the called ecall function, incoming parameters, outgoing parameters, and function return value type.
- the untrusted processing module stores the ecall task in the shared memory.
- shared memory is a memory area that is pre-applied for CA in REE and used for REE and TEE access.
- the meaning of shared memory can be found in the previous relevant descriptions of this application and will not be repeated here.
- the storage locations of the incoming parameters and outgoing parameters of the ecall function are also located in the shared memory.
- both REE and TEE can access the shared memory, after the untrusted processing module stores the ecall task initiated by the CA into the shared memory, the TEE side can obtain the ecall task by accessing the shared memory, so that no data copy is required. This completes the data transfer from the REE side to the TEE side, shortens the data transmission path under the GP architecture, and improves the efficiency of data processing.
- the trusted processing module obtains tasks from the shared memory.
- the trusted processing module on the TEE side accesses the shared memory and obtains the tasks stored in the shared memory.
- the trusted processing module allocates a second thread to the ecall task.
- the second thread is created in the TEE, and the second thread and the first thread are respectively bound to different processing units.
- the processing unit is a CPU core of the processor.
- This embodiment does not limit the CPU core to which the second thread is bound.
- the CPU includes cores 0 to 31, and the CPU core bound to the second thread is core 10.
- the CA on the REE side creates a second thread and binds it to a CPU core, for example, core 10. After that, the core 10 bound to the second thread is switched from the REE side to the TEE side, and the core 10 is switched from the REE mode to the TEE mode.
- the processing unit (core 10) bound to the second thread is initially in TEE mode and does not need to switch the CPU, thereby improving data processing efficiency.
- TA executes the ecall task through the second thread, obtains the task result, and stores the task result into the shared memory.
- the second thread can call the function entry provided by TA, perform the ecall task, and write the outgoing parameters and function return value to the shared area specified by the parameters in the ecall function.
- the thread that CA initiates the ecall task is the first thread, and the bound processing unit is core 0.
- the thread in which TA executes the ecall function called by the ecall task is the second thread, which is bound to CPU core 10. Since the CPU cores bound to the second thread and the first thread are different, when TA executes the ecall function, it does not need to switch the CPU core (core 0) bound to the first thread on the REE side to the TEE side, thus reducing CPU switching. overhead, improving processing efficiency.
- TA since both REE and TEE can access the shared memory, TA stores the task results in the shared memory after executing the ecall task.
- the REE side can obtain the task results of the ecall task by accessing the shared memory, thus completing the data transfer from the TEE side to the REE side without the need for data copy, shortening the data transmission path under the GP architecture, and improving the efficiency of the ecall task. Data processing efficiency.
- a data processing method is provided, which is suitable for the scenario where the terminal device initiates a task through the first thread through the first application program in the first execution environment.
- the relevant data of the execution task such as the incoming and outgoing parameters of the task calling function, task results, etc. are stored in the shared memory.
- the execution environment and the non-trusted execution environment complete data transfer by accessing shared memory, without requiring multiple copies of data, shortening the data transmission path between REE and TEE, and improving the efficiency of data processing.
- the processing unit bound to the first thread does not need to perform CPU mode switching, reducing the It reduces CPU switching overhead and improves processing efficiency.
- the processing unit bound to the second thread can execute the task initiated by the first application program in the second execution environment without switching the CPU mode. Reduces CPU switching overhead and improves processing efficiency.
- the data processing method provided by this embodiment may also include: before the untrusted processing module stores the ecall task in the shared memory in S402:
- the untrusted processing module obtains the instruction information of the ecall task.
- the instruction information is used to determine the ecall task Whether to use the data processing method provided by this embodiment.
- the untrusted processing module determines whether the ecall task adopts the data processing method provided by this embodiment based on the instruction information of the ecall task.
- the process will be performed according to the existing ecall task processing flow.
- the instruction information of the ecall task is used to determine whether the ecall task initiated by the CA executes the data processing method provided in this embodiment, which improves the compatibility between the data processing method provided by this embodiment and the existing ecall task processing flow, and improves the data processing flexibility.
- the indication information may include at least one of the following: configuration information of the ecall task or the keyword of the ecall function called by the ecall task.
- the keyword parameters of the function refer to the parameters sent through the syntax when calling the function.
- the function call keyword method by using the function call keyword method, it can be determined whether the ecall task initiated by the CA executes the data processing method provided by this embodiment.
- the data processing method provided by this embodiment may also include: before the untrusted processing module stores the ecall task in the shared memory in S402:
- the untrusted processing module obtains the first base address of the shared memory in the REE, the first input address of the incoming parameter in the REE, and the first output address of the outgoing parameter in the REE.
- the untrusted processing module converts the first input address into a first input offset relative to the first base address, and converts the first output address into a first output offset relative to the first base address.
- the first base address of the shared memory in the REE can reflect the layout information of the shared memory in the CA address space, such as the starting position, offset, etc.
- the ecall task also includes a first input offset and a first output offset.
- the data processing method provided by this embodiment may also include: before the trusted processing module allocates the second thread to the task in S404:
- the trusted processing module obtains the second base address of the shared memory in the TEE.
- the trusted processing module obtains the second input address of the incoming parameter in the TEE based on the second reference address and the first input offset, and obtains the outgoing parameter based on the second reference address and the first output offset. Second output address in TEE.
- the second base address of the shared memory in the TEE can reflect the layout information of the shared memory in the TA address space, such as the starting position, offset, etc.
- the address spaces on the TEE side and the REE side are completely isolated.
- the address mapping of shared memory is taken care of by the REE operating system.
- the address mapping of shared memory is taken care of by the TEE operating system.
- the shared memory on the REE side and the TEE side will be mapped to different areas of the CA process address and the TA process address by different operating systems. In this way, when CA initiates an ecall task, the incoming parameters, outgoing parameters, etc. located in the shared memory will not be accessible by TA. Vice versa, the parameters passed by TA and located in shared memory cannot be accessed by CA.
- the address of the parameter located in the shared memory passed by CA is converted into an offset relative to the shared memory base address, so that on the TEE side, the offset of the parameter address can be converted into the TEE address space
- the address in TA can successfully access. vice versa.
- the first base address of the shared memory in the REE is the starting address of the shared memory in the CA address space, which is 0x40000000 and has a length of 1MB.
- the first input address of the incoming parameter in REE is 0x40001000, and the length is 8 bytes.
- the address of the passed parameter determines whether the address of the passed parameter will exceed the range of the memory address. For example, in this example, the length of the incoming parameter is 8 bytes, the first input address is 0x40001000, and the length of the shared memory is 1MB, the starting address is 0x40000000, and the incoming parameter does not exceed the range of the memory address.
- the TEE side after obtaining the second input address of the incoming parameter in the TEE, it can be determined whether the address of the incoming parameter is Will it exceed the range of the memory address to ensure that the access to the shared memory does not cross the boundary.
- the data processing method provided by this embodiment may also include: before the CA initiates the ecall task through the first thread in S401:
- the untrusted processing module obtains the memory size of the shared memory.
- the untrusted processing module pre-allocates shared memory according to the memory size.
- the information related to the shared memory includes at least the physical address range of the shared memory.
- the information transmission channel in the existing technology can be used.
- the data processing method provided in this embodiment may also include:
- the untrusted processing module releases the shared memory.
- Figure 5 is another flow chart of the data processing method provided by the embodiment of the present application, providing the implementation of S402 and S403.
- S402 includes S4021 ⁇ S4023.
- S403 includes S4031 ⁇ S4032.
- S401, S403-S405 may refer to the description in the embodiment shown in Figure 4, and will not be described again here.
- the data processing method provided by this embodiment may include:
- CA initiates the ecall task through the first thread.
- the untrusted processing module serializes the ecall task and obtains the serialized message of the ecall task.
- the untrusted processing module stores the serialized message of the ecall task into the message queue.
- the message queue is stored in the shared memory and is used to store serialized messages corresponding to multiple ecall tasks initiated by CA.
- the untrusted processing module sets the execution flag bit of the serialized message of the ecall task to the first value.
- the first value is used to indicate that the status of the serialized message in the message queue is the pending execution status, so that the TEE side obtains the unprocessed ecall task from the message queue after accessing the shared memory.
- the first numerical value and the second numerical value are relative concepts.
- the second value is used to indicate that the status of the serialized message in the message queue is the executed status, so as to notify the REE side that the ecall task is completed.
- the first numerical value and the second numerical value have different values.
- the embodiments of the present application do not limit the values of the first numerical value and the second numerical value.
- the first value is 0 and the second value is 1; or the first value is 1 and the second value is 0.
- the trusted processing module accesses the message queue and obtains the serialized message of the ecall task whose execution flag bit is the first value.
- this embodiment does not limit the rules for the trusted processing module on the TEE side to access the message queue.
- the unprocessed ecall task whose execution flag bit is the first value in the message queue can be discovered through polling or by configuring a specified thread to monitor the corresponding message queue.
- the trusted processing module parses the serialized message of the ecall task and obtains the ecall task.
- parsing and deserialization have the same meaning.
- the serialized message of the unprocessed ecall task the serialized message is restored to the ecall function called by the ecall task.
- the trusted processing module allocates a second thread to the ecall task.
- TA executes the ecall task through the second thread, obtains the task result, and stores the task result into the shared memory.
- the trusted processing module sets the execution flag bit of the serialized message of the ecall task to the second value.
- the data processing method provided by this embodiment is suitable for the scenario where the terminal device initiates a task through the first thread through the first application program in the first execution environment.
- the non-trusted execution environment apply for shared memory in advance for the first application.
- Both the non-trusted execution environment and the trusted execution environment can access the shared memory.
- the shared memory stores message queues and related data during task execution. Set the task's execution flag to a different value to indicate whether the task has been processed.
- the CPU switching overhead is reduced. Improved data processing efficiency.
- the second thread is created in the second execution environment, CPU switching overhead is reduced and data processing efficiency is improved.
- a data processing method is provided, and the execution subject is a terminal device.
- the execution subject is a terminal device.
- trusted execution environments and non-trusted execution environments deployed in terminal devices. This embodiment does not limit the manner in which the terminal device implements the trusted execution environment.
- terminal equipment can adopt GP architecture or SGX architecture.
- Applications and processing modules are deployed in both trusted execution environments and non-trusted execution environments. Among them, the applications deployed in the trusted execution environment are called trusted applications, and the processing modules are called trusted processing modules. Applications deployed in a non-trusted execution environment are called non-trusted applications, and processing modules are called non-trusted processing modules.
- the data processing method provided by this embodiment is suitable for the scenario where the terminal device initiates a task through the first thread through the first application program in the first execution environment.
- the data processing method provided in this embodiment can be applied to at least the above scenarios one to four.
- this embodiment takes scenario 1 as an example to describe the data processing method provided by this embodiment.
- FIG. 6 is another flow chart of the data processing method provided by the embodiment of the present application.
- the data processing method provided by this embodiment may include:
- CA initiates the ecall task through the first thread and registers the callback function.
- CA initiates an ecall task to call the software function provided by TA in TEE.
- the first thread is the thread created by CA in REE.
- CA initiates an ecall task, it provides the address of the callback function.
- the ecall task can include but is not limited to the following information: the function name of the called ecall function, incoming parameters, outgoing parameters, and function return value type.
- the ecall task also includes callback functions.
- the untrusted processing module calls the callback function through the third thread.
- the third thread is different from the first thread.
- the third thread is a thread created by CA in REE.
- the REE side determines that the ecall task executed by the TEE side has ended, calls the callback function through the third thread, and then automatically completes the processing of the outgoing parameters and function return values returned by the TEE side.
- the CA initiates the ecall task through the first thread and registers the callback function at the same time. After the CA initiates the ecall task, it does not need to wait for the task result of the ecall task executed by the TEE side. Instead, it can perform the ecall task through the first thread. Perform subsequent application business logic processing. After the ecall task is executed on the TEE side, the REE side calls the callback function through the third thread to automatically complete the processing of the outgoing parameters and function return values returned by the TEE side. By registering the callback function, the waiting time after the REE side initiates the ecall task is shortened, and the problem that the TEE side ecall task execution blocks the execution of the REE side application business logic is solved.
- the number of third threads is less than or equal to the number of ecall tasks initiated by the CA.
- each third thread can execute one ecall task, which improves data processing efficiency.
- CA initiates three ecall tasks, namely: ecall task 1 to ecall task 3.
- thread 31 calls the callback function corresponding to ecall task 1
- thread 32 calls the callback function corresponding to ecall task 2
- thread 33 calls the callback function corresponding to ecall task 3. This embodiment does not limit the correspondence between the third thread and the callback function of the ecall task.
- third threads If the number of third threads is less than the number of ecall tasks initiated by CA, then there is at least one third thread, and the third thread calls callback functions corresponding to at least two ecall tasks.
- CA initiates three ecall tasks, namely: ecall task 1 to ecall task 3.
- thread 31 and thread 32 There are two third threads, namely thread 31 and thread 32.
- thread 31 calls the callback functions corresponding to ecall task 1 and ecall task 2
- thread 32 calls the callback function corresponding to ecall task 3.
- thread 31 calls the callback function corresponding to ecall task 1
- thread 32 calls the callback functions corresponding to ecall task 2 and ecall task 3.
- This embodiment does not limit the correspondence between the third thread and the callback function of the ecall task.
- the callback functions can be called sequentially in chronological order.
- a data processing method is provided, and the execution subject is a terminal device.
- the execution subject is a terminal device.
- trusted execution environments and non-trusted execution environments deployed in terminal devices. This embodiment does not limit the manner in which the terminal device implements the trusted execution environment.
- terminal equipment can adopt GP architecture or SGX architecture.
- Applications and processing modules are deployed in both trusted execution environments and non-trusted execution environments. Among them, the applications deployed in the trusted execution environment are called trusted applications, and the processing modules are called trusted processing modules. Applications deployed in a non-trusted execution environment are called non-trusted applications, and processing modules are called non-trusted processing modules.
- the data processing method provided by this embodiment is suitable for the scenario where the terminal device initiates a task through the first thread through the first application program in the first execution environment.
- the first execution environment is an untrusted execution environment
- the first application program is an untrusted application program
- the second execution environment is a trusted execution environment
- the second application program is a trusted application program
- the task is an ecall task.
- the data processing method provided in this embodiment can be applied to at least the above scenario one and scenario three.
- this embodiment takes scenario 1 as an example to describe the data processing method provided by this embodiment.
- FIG. 7 is another flow chart of the data processing method provided by the embodiment of the present application.
- the data processing method provided by this embodiment may include:
- the trusted processing module establishes a thread pool for the CA in the REE, and the thread pool includes multiple threads.
- each thread in the thread pool is created in TEE.
- CA initiates the ecall task through the first thread.
- the trusted processing module allocates a second thread to the ecall task.
- the second thread is an idle thread in the thread pool.
- the trusted processing module obtains the first number of idle threads in the thread pool.
- the trusted processing module obtains the second number of unexecuted ecall tasks in at least one ecall task initiated by the CA.
- the trusted processing module adjusts the number of threads in the thread pool based on the first number and the second number.
- a thread pool is established for the CA in the REE, and the thread pool includes multiple threads.
- the number of threads in the thread pool is adjusted in real time to avoid having no threads available on the TEE side due to too many ecall tasks initiated by CA. situation, it also avoids CPU waste on the TEE side due to fewer ecall tasks initiated by the CA, improves the flexibility of thread management on the TEE side, improves resource utilization on the TEE side, and improves the processing efficiency of ecall tasks.
- the trusted processing module adjusts the number of threads in the thread pool based on the first number and the second number, which may include:
- the trusted processing module destroys a thread in the thread pool.
- the trusted processing module creates at least one thread in the thread pool.
- the number of at least one thread is less than or equal to the maximum threshold minus the total number of threads in the thread pool.
- this embodiment does not limit the number of at least one thread created. However, after creating at least one thread, you need to ensure that the total number of all threads in the thread pool is less than or equal to the maximum threshold.
- the number of at least one thread is 1. That is, a new thread is created each time.
- the number of at least one thread is a minimum threshold.
- the number of threads in the thread pool has a minimum value and a maximum value, which are called the minimum threshold and the maximum threshold respectively.
- a thread is destroyed in the thread pool until the number of threads in the thread pool reaches the minimum threshold, ensuring that There are threads in the TEE for executing ecall tasks initiated by CA, which avoids the situation where the ecall task cannot be executed.
- the number of idle threads in the thread pool is less than the number of unprocessed ecall tasks initiated by CA, at least one new thread is created in the thread pool, and the number of threads in the thread pool is gradually or rapidly increased until the thread pool The number of threads in the thread reaches the maximum threshold.
- the trusted processing module establishes a thread pool for the CA in the REE, which may include:
- REE send minimum threshold, maximum threshold and intermediate threshold to TEE.
- the intermediate threshold is greater than the minimum threshold and less than the maximum threshold.
- the trusted processing module establishes a thread pool for CA, and the number of threads in the thread pool is an intermediate threshold.
- the information transmission channel in the existing technology can be used.
- the TEE side establishes a thread pool for CA based on the minimum threshold, maximum threshold, and intermediate threshold set by the REE side, which improves the rationality and accuracy of managing the thread pool.
- the data processing method provided in this embodiment may also include:
- the untrusted processing module calls the destruction interface function.
- the destruction interface function is used to instruct the destruction of all threads in the thread pool in TEE.
- the trusted processing module destroys all threads in the thread pool according to the destruction interface function.
- the various embodiments of the present application can be combined with each other, and the combination method is not limited.
- the embodiment shown in Figure 4 and the embodiment shown in Figure 6 can be combined with each other.
- the embodiment shown in Figure 4 and the embodiment shown in Figure 7 can be combined with each other.
- the terminal device includes hardware and/or software modules corresponding to each function.
- the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is performed by hardware or by computer software driving the hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions in conjunction with the embodiments for each specific application, but such implementations should not be considered beyond the scope of this application.
- Embodiments of the present application can divide the terminal device into functional modules according to the above method examples. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one module. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. In actual implementation, there may be other division methods. It should be noted that the names of the modules in the embodiments of this application are schematic, and there are no restrictions on the names of the modules during actual implementation.
- an embodiment of the present application provides a terminal device.
- the terminal device deploys a trusted execution environment and a non-trusted execution environment.
- the trusted execution environment deploys trusted applications and trusted processing modules.
- the untrusted execution environment deploys untrusted applications and untrusted processing modules.
- the first processing module in the first execution environment is used to store tasks initiated by the first application program through the first thread into the shared memory; the tasks are used to call software functions provided by the second application program in the second execution environment;
- the shared memory is a physical memory area that is applied in advance for the first application program in the non-trusted execution environment and is used for access by the non-trusted execution environment and the trusted execution environment;
- the third An execution environment is the non-trusted execution environment, the second execution environment is the trusted execution environment, the first processing module is the non-trusted processing module, and the second processing module is the trusted processing module, or the first execution environment is the trusted execution environment, the second execution environment is the non-trusted execution environment, the first processing module is the trusted processing module, and the second execution environment is the trusted execution environment.
- the processing module is the untrusted processing module;
- the second processing module in the second execution environment is used to obtain the task from the shared memory
- the second processing module in the second execution environment is used to allocate a second thread to the task; the second thread is created in the second execution environment, and the second thread and the The first threads are respectively bound to different processing units;
- the second application program in the second execution environment is configured to execute the task through the second thread, obtain a task result, and store the task result in the shared memory.
- the first processing module in the first execution environment is used for:
- the serialized message of the task is stored in a message queue; the message queue is stored in the shared memory and is used to store the corresponding corresponding tasks of multiple tasks initiated by the first application program. serialized message;
- the execution flag bit of the serialized message of the task is set to a first value; wherein the first value is used to indicate that the status of the serialized message is a pending execution state.
- the second processing module in the second execution environment is used for:
- the serialized message of the task is parsed to obtain the task.
- the second processing module in the second execution environment is also used to:
- the execution flag bit of the serialized message is set to a second value; wherein the second value is used to indicate that the status of the serialized message is an executed status.
- the first application program in the first execution environment is used for:
- the task is initiated through the first thread, and a callback function is registered.
- the first processing module in the first execution environment is also used to:
- the callback function is called through a third thread; the third thread is different from the first thread.
- the number of the third threads is less than or equal to the number of tasks initiated by the first application program.
- the task includes incoming parameters and outgoing parameters, and the storage locations of the incoming parameters and outgoing parameters are located in the shared memory;
- the first processing module in the first execution environment is also used to:
- the first execution environment Before storing the task initiated by the first application program through the first thread into the shared memory, in the first execution environment, obtain the first reference address and the first reference address of the shared memory in the first execution environment. The first input address of the incoming parameter in the first execution environment and the first output address of the outgoing parameter in the first execution environment;
- the first output offset of the address In the first execution environment, convert the first input address to a first input offset relative to the first base address, and convert the first output address to a first input offset relative to the first base address. The first output offset of the address.
- the second processing module in the second execution environment is also used to:
- the second execution environment obtain the second input address of the incoming parameter in the second execution environment according to the second base address and the first input offset.
- the base address and the first output offset obtain the second output address of the outgoing parameter in the second execution environment.
- the first execution environment is the trusted execution environment
- the second execution environment is the non-trusted execution environment
- the task is an ocall task.
- the first execution environment is the untrusted execution environment
- the second execution environment is the trusted execution environment
- the task is an ecall task.
- a thread pool is established for the first application in the second execution environment, the thread pool includes multiple threads, and the threads in the thread pool are in the second execution environment. created;
- the second thread is an idle thread in the thread pool.
- the second processing module in the second execution environment is also used to:
- the number of threads in the thread pool is adjusted according to the first number and the second number.
- the second processing module in the second execution environment is used for:
- first number is greater than the second number, and the total number of threads in the thread pool is greater than the minimum threshold, then in the second execution environment, one thread is destroyed in the thread pool; or,
- the first number is less than the second number, and the total number of threads in the thread pool is less than the maximum threshold, then in the second execution environment, at least one thread is created in the thread pool; the at least The number of one thread is less than or equal to the difference between the maximum threshold and the total number of threads in the thread pool.
- the first processing module in the first execution environment is also used to:
- the first execution environment Before storing the task initiated by the first application program through the first thread into the shared memory, in the first execution environment, send a minimum threshold, a maximum threshold and an intermediate threshold to the second execution environment; the intermediate The threshold is greater than the minimum threshold and less than the maximum threshold;
- the second processing module in the second execution environment is also used to:
- the thread pool is established for the first application program, and the number of threads in the thread pool is the intermediate threshold.
- the first processing module in the first execution environment is also used to:
- the related information of the shared memory is sent to the second execution environment.
- the memory size includes a first memory size occupied by a message queue and a second memory size occupied by application data; the message queue is stored in the shared memory and is used to store messages initiated by the first application program. Serialized messages corresponding to multiple tasks;
- the shared memory includes a first memory space of the first memory size and a second memory space of the second memory size.
- the addresses of the first memory space and the second memory space are consecutive.
- FIG. 8 shows another structure of a terminal device provided by an embodiment of the present application.
- the terminal device includes: processor 801, memory 804 and bus 805.
- a receiver 802 and a transmitter 803 may also be included.
- the processor 801 includes one or more processing cores.
- the processor 801 executes various functional applications and information processing by running software programs and modules.
- the memory 804 can be used to store at least one program instruction, and the processor 801 is used to execute at least one program instruction to implement the technical solutions of the above embodiments.
- the receiver 802 and the transmitter 803 can be implemented as a communication component, and the communication component can be a baseband chip.
- the memory 804 is connected to the processor 801 through a bus 805. The implementation principles and technical effects are similar to the above-mentioned method-related embodiments, and will not be described again here.
- FIG. 8 only shows one memory and processor. In an actual terminal device, there may be multiple processors and memories.
- the memory may also be called a storage medium or a storage device, which is not limited in the embodiments of the present application.
- the processor may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, which may implement or Execute each method, step and logical block diagram disclosed in the embodiment of this application.
- a general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in conjunction with the embodiments of the present application can be directly implemented by a hardware processor, or executed by a combination of hardware and software modules in the processor.
- the memory may be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SS), etc., or it may be a volatile memory (volatile memory), such as Random-access memory (RAM).
- Memory is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by the computer, without limitation.
- the memory in the embodiment of the present application can also be a circuit or any other device capable of realizing the storage function, used for storing programs. sequence instructions and/or data.
- the methods provided by the embodiments of this application can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
- the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part.
- the computer may be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user equipment, or other programmable device.
- the computer instructions may be stored in or transmitted from one computer-readable storage medium to another, e.g., the computer instructions may be transferred from a website, computer, server, or data center Transmit to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means.
- the readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains one or more available media integrated.
- the available media can be magnetic media (for example, floppy disks, hard disks, tapes ), optical media (for example, digital video disc (DWD), or semiconductor media (for example, SSD), etc.).
- Embodiments of the present application provide a computer program product.
- the computer program product When the computer program product is run on a terminal device, it causes the terminal device to execute the technical solutions in the above embodiments.
- the implementation principles and technical effects are similar to the above-mentioned related embodiments and will not be described again here.
- Embodiments of the present application provide a computer-readable storage medium on which program instructions are stored.
- program instructions When the program instructions are executed by a terminal device, they cause the terminal device to execute the technical solutions of the above embodiments.
- the implementation principles and technical effects are similar to the above-mentioned related embodiments and will not be described again here.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Computer Hardware Design (AREA)
- Mathematical Physics (AREA)
- Storage Device Security (AREA)
- Stored Programmes (AREA)
Abstract
Description
Claims (20)
- 一种数据处理方法,其特征在于,应用于终端设备,所述终端设备部署可信执行环境和非可信执行环境;所述方法包括:在第一执行环境中,将由第一应用程序通过第一线程发起的任务存入共享内存;所述任务用于调用第二执行环境中第二应用程序提供的软件功能;所述共享内存是在所述非可信执行环境中针对所述第一应用程序预先申请的且用于所述非可信执行环境和所述可信执行环境访问的物理内存区域;所述第一执行环境为所述非可信执行环境、所述第二执行环境为所述可信执行环境,或者,所述第一执行环境为所述可信执行环境、所述第二执行环境为所述非可信执行环境;在所述第二执行环境中,从所述共享内存获取所述任务;在所述第二执行环境中,为所述任务分配第二线程;所述第二线程是在所述第二执行环境中创建的,所述第二线程和所述第一线程分别绑定的处理单元不同;在所述第二执行环境中,由所述第二应用程序通过所述第二线程执行所述任务,得到任务结果,并将所述任务结果存入所述共享内存。
- 根据权利要求1所述的方法,其特征在于,所述在所述第一执行环境中,将所述任务存入共享内存,包括:在所述第一执行环境中,序列化所述任务,得到所述任务的序列化消息;在所述第一执行环境中,将所述任务的序列化消息存入消息队列;所述消息队列存储在所述共享内存中,用于存储所述第一应用程序发起的多个任务分别对应的序列化消息;在所述第一执行环境中,将所述任务的序列化消息的执行标志位设置为第一数值;其中,第一数值用于指示序列化消息的状态为待执行状态。
- 根据权利要求2所述的方法,其特征在于,所述在所述第二执行环境中,从所述共享内存获取所述任务,包括:在所述第二执行环境中,访问所述消息队列,获取执行标志位为所述第一数值的所述任务的序列化消息;在所述第二执行环境中,解析所述任务的序列化消息,得到所述任务。
- 根据权利要求2所述的方法,其特征在于,所述在所述第二执行环境中,由所述第二应用程序通过所述第二线程执行所述任务,得到任务结果,并将所述任务结果存入所述共享内存之后,还包括:在所述第二执行环境中,将所述任务的序列化消息的所述执行标志位设置为第二数值;其中,第二数值用于指示序列化消息的状态为已执行状态。
- 根据权利要求1-4中任一项所述的方法,其特征在于,所述在第一执行环境中,将由第一应用程序通过第一线程发起的任务存入共享内存之前,还包括:在所述第一执行环境中,由所述第一应用程序通过所述第一线程发起所述任务,并注册回调函数。
- 根据权利要求5所述的方法,其特征在于,所述方法还包括:在所述第一执行环境中,通过第三线程调用所述回调函数;所述第三线程和所述第一线程不同。
- 根据权利要求6所述的方法,其特征在于,所述第三线程的数量小于或等于所述第一应用程序发起的任务的数量。
- 根据权利要求1-7中任一项所述的方法,其特征在于,所述任务包括传入参数和传出参数,所述传入参数和所述传出参数的存储位置位于所述共享内存中;所述在第一执行环境中,将由第一应用程序通过第一线程发起的任务存入共享内存之前,还包括:在所述第一执行环境中,获取所述共享内存在所述第一执行环境中的第一基准地址、所述传入参数在所述第一执行环境中的第一输入地址和所述传出参数在所述第一执行环境中的第一输出地址;在所述第一执行环境中,将所述第一输入地址转换为相对于所述第一基准地址的第一输入偏 移量,将所述第一输出地址转换为相对于所述第一基准地址的第一输出偏移量。
- 根据权利要求8所述的方法,其特征在于,所述在所述第二执行环境中,由所述第二应用程序通过所述第二线程执行所述任务之前,还包括:在所述第二执行环境中,获取所述共享内存在所述第二执行环境中的第二基准地址;在所述第二执行环境中,根据所述第二基准地址和所述第一输入偏移量获取所述传入参数在所述第二执行环境中的第二输入地址,根据所述第二基准地址和所述第一输出偏移量获取所述传出参数在所述第二执行环境中的第二输出地址。
- 根据权利要求1-9中任一项所述的方法,其特征在于,所述第一执行环境为所述可信执行环境,所述第二执行环境为所述非可信执行环境,所述任务为ocall任务。
- 根据权利要求1-9中任一项所述的方法,其特征在于,所述第一执行环境为所述非可信执行环境,所述第二执行环境为所述可信执行环境,所述任务为ecall任务。
- 根据权利要求11所述的方法,其特征在于,在所述第二执行环境中针对所述第一应用程序建立有线程池,所述线程池中包括多个线程,所述线程池中的线程是在所述第二执行环境中创建的;所述第二线程为所述线程池中的空闲线程。
- 根据权利要求12所述的方法,其特征在于,所述方法还包括:在所述第二执行环境中,获取所述线程池中空闲线程的第一数量;在所述第二执行环境中,获取所述第一应用程序发起的至少一个任务中未执行的任务的第二数量;在所述第二执行环境中,根据所述第一数量和所述第二数量,调整所述线程池中线程的数量。
- 根据权利要求13所述的方法,其特征在于,所述在所述第二执行环境中,根据所述第一数量和所述第二数量,调整所述线程池中线程的数量,包括:若所述第一数量大于所述第二数量,且所述线程池中线程的总数大于最小阈值,则在所述第二执行环境中,在所述线程池中销毁一个线程;或者,若所述第一数量小于所述第二数量,且所述线程池中线程的总数小于最大阈值,则在所述第二执行环境中,在所述线程池中创建至少一个线程;所述至少一个线程的数量小于或等于所述最大阈值与所述线程池中线程的总数之差。
- 根据权利要求12所述的方法,其特征在于,所述在第一执行环境中,将由第一应用程序通过第一线程发起的任务存入共享内存之前,还包括:在所述第一执行环境中,向所述第二执行环境发送最小阈值、最大阈值和中间阈值;所述中间阈值大于所述最小阈值且小于所述最大阈值;在所述第二执行环境中,针对所述第一应用程序建立所述线程池,所述线程池中线程的数量为所述中间阈值。
- 根据权利要求11所述的方法,其特征在于,所述在第一执行环境中,将由第一应用程序通过第一线程发起的任务存入共享内存之前,还包括:在所述第一执行环境中,获取所述共享内存的内存大小;在所述第一执行环境中,根据所述内存大小分配所述共享内存;在所述第一执行环境中,向所述第二执行环境发送所述共享内存的相关信息。
- 根据权利要求16所述的方法,其特征在于,所述内存大小包括消息队列占用的第一内存大小和应用数据占用的第二内存大小;所述消息队列存储在所述共享内存中,用于存储所述第一应用程序发起的多个任务分别对应的序列化消息;所述共享内存包括所述第一内存大小的第一内存空间和所述第二内存大小的第二内存空间。
- 根据权利要求17所述的方法,其特征在于,所述第一内存空间和所述第二内存空间的地址连续。
- 一种终端设备,其特征在于,包括处理器,所述处理器用于与存储器耦合,并读取存储器中的指令并根据所述指令使得所述终端设备执行如权利要求1-18中任一项所述的方法。
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机指令,当 所述计算机指令在终端设备上运行时,使得所述终端设备执行如权利要求1-18中任一项所述的方法。
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| EP23862012.4A EP4575861A4 (en) | 2022-09-07 | 2023-06-29 | DATA PROCESSING METHOD, TERMINAL DEVICE AND READABLE STORAGE MEDIA |
| US19/071,949 US20250238269A1 (en) | 2022-09-07 | 2025-03-06 | Data processing method, terminal device, and readable storage medium |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211091500.1 | 2022-09-07 | ||
| CN202211091500.1A CN117707799A (zh) | 2022-09-07 | 2022-09-07 | 数据处理方法、终端设备和可读存储介质 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US19/071,949 Continuation US20250238269A1 (en) | 2022-09-07 | 2025-03-06 | Data processing method, terminal device, and readable storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024051311A1 true WO2024051311A1 (zh) | 2024-03-14 |
Family
ID=90157553
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2023/103965 Ceased WO2024051311A1 (zh) | 2022-09-07 | 2023-06-29 | 数据处理方法、终端设备和可读存储介质 |
Country Status (4)
| Country | Link |
|---|---|
| US (1) | US20250238269A1 (zh) |
| EP (1) | EP4575861A4 (zh) |
| CN (1) | CN117707799A (zh) |
| WO (1) | WO2024051311A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118409751A (zh) * | 2024-04-12 | 2024-07-30 | 北京天数智芯半导体科技有限公司 | Ai加速卡计算误差自动分析方法、系统、装置及设备 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20180288095A1 (en) * | 2017-03-29 | 2018-10-04 | At&T Intellectual Property I, L.P. | Method and system to secure and dynamically share iot information cross multiple platforms in 5g network |
| CN109460373A (zh) * | 2017-09-06 | 2019-03-12 | 阿里巴巴集团控股有限公司 | 一种数据共享方法、终端设备和存储介质 |
| CN110442462A (zh) * | 2019-07-16 | 2019-11-12 | 阿里巴巴集团控股有限公司 | Tee系统中的多线程数据传输方法和装置 |
| CN111585999A (zh) * | 2020-04-28 | 2020-08-25 | 深圳震有科技股份有限公司 | 一种数据转换方法、系统及存储介质 |
| CN111859395A (zh) * | 2020-07-21 | 2020-10-30 | 中国人民解放军国防科技大学 | 具备tee扩展的计算平台上的通信优化方法及系统 |
| CN111858004A (zh) * | 2020-07-21 | 2020-10-30 | 中国人民解放军国防科技大学 | 基于tee扩展的计算机安全世界实时应用动态加载方法及系统 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109960582B (zh) * | 2018-06-19 | 2020-04-28 | 华为技术有限公司 | 在tee侧实现多核并行的方法、装置及系统 |
| DE102018132970A1 (de) * | 2018-10-10 | 2020-04-16 | Bayerische Motoren Werke Aktiengesellschaft | Verfahren und Vorrichtung zur Isolation von sensiblem nichtvertrauenswürdigem Programmcode auf mobilen Endgeräten |
| CN114661380B (zh) * | 2020-12-31 | 2024-10-01 | 支付宝(杭州)信息技术有限公司 | 面向可信执行环境的系统调用处理方法及装置 |
| CN113138845B (zh) * | 2021-04-25 | 2024-10-22 | 北京小米移动软件有限公司 | 指纹识别方法、装置、终端及存储介质 |
-
2022
- 2022-09-07 CN CN202211091500.1A patent/CN117707799A/zh active Pending
-
2023
- 2023-06-29 WO PCT/CN2023/103965 patent/WO2024051311A1/zh not_active Ceased
- 2023-06-29 EP EP23862012.4A patent/EP4575861A4/en active Pending
-
2025
- 2025-03-06 US US19/071,949 patent/US20250238269A1/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20180288095A1 (en) * | 2017-03-29 | 2018-10-04 | At&T Intellectual Property I, L.P. | Method and system to secure and dynamically share iot information cross multiple platforms in 5g network |
| CN109460373A (zh) * | 2017-09-06 | 2019-03-12 | 阿里巴巴集团控股有限公司 | 一种数据共享方法、终端设备和存储介质 |
| CN110442462A (zh) * | 2019-07-16 | 2019-11-12 | 阿里巴巴集团控股有限公司 | Tee系统中的多线程数据传输方法和装置 |
| CN111585999A (zh) * | 2020-04-28 | 2020-08-25 | 深圳震有科技股份有限公司 | 一种数据转换方法、系统及存储介质 |
| CN111859395A (zh) * | 2020-07-21 | 2020-10-30 | 中国人民解放军国防科技大学 | 具备tee扩展的计算平台上的通信优化方法及系统 |
| CN111858004A (zh) * | 2020-07-21 | 2020-10-30 | 中国人民解放军国防科技大学 | 基于tee扩展的计算机安全世界实时应用动态加载方法及系统 |
Non-Patent Citations (1)
| Title |
|---|
| See also references of EP4575861A4 |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118409751A (zh) * | 2024-04-12 | 2024-07-30 | 北京天数智芯半导体科技有限公司 | Ai加速卡计算误差自动分析方法、系统、装置及设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| EP4575861A4 (en) | 2025-11-26 |
| EP4575861A1 (en) | 2025-06-25 |
| US20250238269A1 (en) | 2025-07-24 |
| CN117707799A (zh) | 2024-03-15 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US7200695B2 (en) | Method, system, and program for processing packets utilizing descriptors | |
| US20220091911A1 (en) | Method and apparatus for inter-process communication, and computer device | |
| US11507285B1 (en) | Systems and methods for providing high-performance access to shared computer memory via different interconnect fabrics | |
| US11847225B2 (en) | Blocking access to firmware by units of system on chip | |
| CN113495795B (zh) | 一种进程间通信方法及相关设备 | |
| US8244826B2 (en) | Providing a memory region or memory window access notification on a system area network | |
| US8131814B1 (en) | Dynamic pinning remote direct memory access | |
| US10104005B2 (en) | Data buffering | |
| EP1861778B1 (en) | Data processing system | |
| US20050038941A1 (en) | Method and apparatus for accessing a memory | |
| WO2022228485A1 (zh) | 一种数据传输方法、数据处理方法及相关产品 | |
| US20120131124A1 (en) | Rdma read destination buffers mapped onto a single representation | |
| EP4421631A1 (en) | Data migration method and apparatus, and electronic device | |
| US11010309B2 (en) | Computer system and method for executing one or more software applications, host computer device and method for a host computer device, memory device and method for a memory device and non-transitory computer readable medium | |
| CN105009134B (zh) | 提供安全操作的方法、装置、系统和计算机可读介质 | |
| US20230168953A1 (en) | Inter-process communication method and apparatus | |
| CN113591091A (zh) | 应用程序的处理方法、装置、云环境及存储介质 | |
| CN113302613A (zh) | 旁路保护 | |
| WO2025161674A1 (zh) | 网络报文处理方法、装置、计算机设备和存储介质 | |
| US20250238269A1 (en) | Data processing method, terminal device, and readable storage medium | |
| US20080080715A1 (en) | Apparatus and method for high-speed, large-volume data encryption using secure memory | |
| US20070169120A1 (en) | Mechanism to transition control between components in a virtual machine environment | |
| CN112231124B (zh) | 基于隐私保护的应用间通信方法及装置 | |
| US7089378B2 (en) | Shared receive queues | |
| US20040019882A1 (en) | Scalable data communication model |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23862012 Country of ref document: EP Kind code of ref document: A1 |
|
| WWE | Wipo information: entry into national phase |
Ref document number: 2023862012 Country of ref document: EP |
|
| ENP | Entry into the national phase |
Ref document number: 2023862012 Country of ref document: EP Effective date: 20250320 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| WWP | Wipo information: published in national office |
Ref document number: 2023862012 Country of ref document: EP |