WO2022268150A1 - 一种虚拟机与安全隔离区间的通信方法及相关装置 - Google Patents

一种虚拟机与安全隔离区间的通信方法及相关装置 Download PDF

Info

Publication number
WO2022268150A1
WO2022268150A1 PCT/CN2022/100659 CN2022100659W WO2022268150A1 WO 2022268150 A1 WO2022268150 A1 WO 2022268150A1 CN 2022100659 W CN2022100659 W CN 2022100659W WO 2022268150 A1 WO2022268150 A1 WO 2022268150A1
Authority
WO
WIPO (PCT)
Prior art keywords
vms
vmm
indicated
identifier
spm
Prior art date
Application number
PCT/CN2022/100659
Other languages
English (en)
French (fr)
Inventor
章张锴
姚冬冬
陈谋
Original Assignee
华为技术有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2022268150A1 publication Critical patent/WO2022268150A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring 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/53Monitoring 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45587Isolation or security of virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Definitions

  • the embodiments of the present application relate to the field of computers, and in particular to a communication method and a related device between a virtual machine and a security isolation zone.
  • a terminal equipment security framework represented by ARM (advanced RISC machines) has emerged (the full English name of RISC is reduced instruction set computer).
  • SoC system on chips
  • REE rich execution environment
  • TEE trusted execution environment
  • REE and TEE run on the same physical device and run a set of operating systems respectively.
  • REE runs the client application (CA) with low security requirements; TEE runs the trusted application (TA) whose security needs to be guaranteed, providing a secure execution environment for the authorized trusted application TA.
  • CA and TA communicate through the provided communication mechanism, just like client and server.
  • TEEos trusted operating system
  • SPs secure partitions
  • VM Virtual Machine
  • multiple VMs are created on the REE side.
  • a SP will be started on the TEE side accordingly, and TEEos will run on the SP to support security services in the VM.
  • the CA in the VM will request the security services of the TA in the SP.
  • the embodiment of the present application provides a communication method and a related device between a virtual machine and a security isolation area.
  • the method enables the security isolation area to actively notify the virtual machine to perform a certain operation, which is more convenient and flexible.
  • the first aspect of the embodiment of the present application provides a communication method between a virtual machine and a security isolation zone, the method is applied to a computer system, and a Rich Execution Environment REE and a Trusted Execution Environment TEE are deployed on the computer system, and a virtual machine manager is deployed on the REE VMM and X virtual machine VMs, TEE is deployed with a security isolation zone manager SPM and X security isolation zone SPs, one SP corresponds to one VM, where X is a positive integer, the method includes: the first SP writes the request to the second In the first shared memory of a SP and the first VM, the first shared memory is usually established during the startup process of the first VM and the first SP, the first SP is one of the X SPs, and the first VM is X One of the VMs corresponding to the first SP, the request is used to instruct the first VM to execute the target operation.
  • the first SP triggers the first virtual interrupt
  • the first virtual interrupt is used to make the SPM notify the first VM to obtain a request from the first shared memory through the VMM;
  • the process of the first SP triggering the first virtual interrupt may specifically include: the first SP writes a piece of memory without access rights , because there is no access right, the write operation will cause a page fault, and the page operation will be sensed by the SPM, thereby completing the triggering of the first virtual interrupt.
  • the first SP writes the request into the first shared memory of the first SP and the first VM, and triggers the first virtual interrupt, so that the SPM notifies the first VM through the VMM to obtain the request from the first shared memory, realizing the first
  • the active notification of the SP to the first VM makes the communication between the first SP and the first VM more flexible and convenient.
  • the second aspect of the embodiment of the present application provides a communication method between a virtual machine and a security isolation zone, the method is applied to a computer system, and a Rich Execution Environment REE and a Trusted Execution Environment TEE are deployed on the computer system, and a virtual machine manager is deployed on the REE VMM and X virtual machine VMs, TEE is deployed with a security isolation zone manager SPM and X security isolation zone SPs, one SP corresponds to one VM, where X is a positive integer, and the method includes: responding to Y first virtual interrupts , the SPM acquires the identifications of Y SPs that trigger Y first virtual interrupts.
  • the SPM can acquire the identifications of Y SPs from the register, wherein, Y SPs belong to X SPs, and Y is a positive value less than or equal to X. Integer; the SPM determines the identifications of Y VMs corresponding to the identifications of Y SPs, and the identification of an SP corresponds to the identification of a VM. Specifically, the SPM can obtain Y VMs based on the correspondence between the identifications of the SPs and the identifications of the VMs.
  • Y VMs belong to X VMs; the SPM transfers the Y VMs’ IDs to the VMM, so that the VMM notifies the Y VMs indicated by the Y VMs’ IDs.
  • Obtain Y requests in a shared memory wherein there are many ways to transfer the identifiers of Y VMs, which is not specifically limited in the embodiment of the present application.
  • a VM and an SP correspond to a first shared memory, and a first shared memory
  • a request is stored in memory, and the request is used to instruct the VM to perform the targeted operation.
  • the SPM acquires the identifications of Y SPs that trigger Y first virtual interrupts, and then passes the identifications of Y VMs corresponding to the identifications of Y SPs to the VMM, so that the VMM notifies the Y VMs indicated by the identifications of the Y VMs, thereby realizing
  • the active notification of the first SP to the first VM is realized, so that the communication between the first SP and the first VM is more flexible and convenient.
  • Y is greater than 1, and the identifiers of Y VMs include the first identifier and the second identifier; the SPM transfers the identifiers of the Y VMs to the VMM, so that the VMM notifies the Y VMs indicated by the identifiers of the Y VMs , obtaining Y requests from Y first shared memories of Y VMs and Y SPs includes: SPM writes the first identifier into the second shared memories of SPM and VMM; SPM triggers a first physical interrupt, and the first physical The interrupt is used to make the VMM obtain the first identifier from the second shared memory under the control of the first central processing CPU, and notify the VM indicated by the first identifier to obtain the first identifier from the VM indicated by the first identifier and the SP indicated by the third identifier.
  • the third identification is one of the identifications of Y SPs and corresponds to the first identification, and the first CPU is used to run the VM indicated by the first identification; the process of responding to the first physical interrupt may specifically include :
  • the VMM obtains the interrupt number of the first physical interrupt. In the case that the interrupt number of the first physical interrupt is the interrupt number (preset) notified by the SP to the VM, the VMM obtains the first identifier from the second shared memory.
  • the SPM writes the second identifier into the second shared memory of the SPM and the VMM; the SPM triggers a second physical interrupt, and the second physical interrupt is used to make the VMM obtain the second identifier from the second shared memory under the control of the second CPU , and notify the VM indicated by the second identifier to obtain the request from the first shared memory of the VM indicated by the second identifier and the SP indicated by the fourth identifier, and the fourth identifier is one of Y SP identifiers and corresponds to the second identifier , the second CPU is used to run the VM indicated by the second identifier.
  • the operation of notifying the VM needs to be executed under the control of the CPU that can run the VM, if the physical terminal is responded by the CPU that cannot run the VM, it needs to switch to the CPU that can run the VM after the response, and then be completed by the CPU that can run the VM Notification to the VM; and the embodiment of the present application sets the affinity of the physical interrupt, that is, the processing of the specific physical interrupt is completed by a specific CPU; specifically, for the first identification, the VM indicated by the first identification can run The first CPU processes the first physical interrupt, so that the VMM acquires the first identifier under the control of the first CPU, and notifies the VM indicated by the first identifier to obtain the request; for the second identifier, the second identifier that can run the VM indicated by the second identifier The second CPU processes the first physical interrupt, so that the VMM obtains the second identifier under the control of the second CPU, and notifies the VM indicated by the second identifier of the acquisition request; thus, the operation of CPU
  • the SPM transfers the identifiers of Y VMs to the VMM, so that the VMM notifies the Y VMs indicated by the identifiers of the Y VMs, and acquires them from the Y first shared memories of the Y VMs and Y SPs.
  • the Y requests include: the SPM writes the identifications of the Y VMs into the second shared memory of the SPM and the VMM; the SPM triggers a third physical interrupt, and the third physical interrupt is used to make the VMM, under the control of the third CPU, from the second Obtaining the identifiers of Y VMs in the shared memory, and notifying the Y VMs indicated by the identifiers of the Y VMs to obtain Y requests from the Y first shared memories of the Y VMs and Y SPs, wherein the third CPU can be Any one of multiple physical CPUs in a computer system.
  • the SPM can write the identifiers of multiple VMs into the second shared memory of the SPM and the VMM at one time, and only trigger one third physical interrupt, and the VMM can write the identifiers of multiple VMs at one time under the control of the third CPU Get multiple VMs, so better efficiency and better concurrency.
  • the SPM transmits the identifiers of Y VMs to the VMM, so that the VMM notifies the Y VMs indicated by the identifiers of the Y VMs, from the Y first shared memories of the Y VMs and Y SPs
  • the method further includes: establishing a second shared memory between the SPM and the VMM.
  • the establishment of the second shared memory is usually when SPM and VMM are started. Specifically, the establishment of the second shared memory may include: when SPM and VMM are started, EL2 applies for a piece of continuous physical memory, and then allocates this continuous physical memory The address of the shared memory is passed to SEL2, and SEL2 maps the address of this continuous physical memory to its own virtual address space, thereby completing the establishment of the second shared memory.
  • the third aspect of the embodiment of the present application provides a communication method between a virtual machine and a security isolation zone, the method is applied to a computer system, and a Rich Execution Environment REE and a Trusted Execution Environment TEE are deployed on the computer system, and a virtual machine manager is deployed on the REE VMM and X virtual machine VMs, TEE is deployed with a security isolation zone manager SPM and X security isolation zone SPs, one SP corresponds to one VM, where X is a positive integer, the method includes: VMM obtains Y VMs delivered by the SPM wherein, Y VMs belong to X VMs, and Y is a positive integer less than or equal to X; the VMM notifies the Y VMs indicated by the IDs of the Y VMs that Y first shares from Y VMs and Y SPs Y requests are obtained in the memory, wherein, Y SPs belong to X SPs, a VM and an SP correspond to a first shared
  • the VMM obtains the identifiers of the Y VMs passed by the SPM, and notifies the Y VMs indicated by the identifiers of the Y VMs, and obtains Y requests from the Y first shared memories of the Y VMs and Y SPs, thereby realizing the first
  • the active notification of the SP to the first VM makes the communication between the first SP and the first VM more flexible and convenient.
  • the identifiers of the Y VMs include the first identifier and the second identifier; the VMM obtaining the identifiers of the Y VMs delivered by the SPM includes: responding to the first physical interrupt, the VMM under the control of the first CPU from The first identifier is obtained from the second shared memory of the SPM and the VMM, and the first CPU is used to run the VM indicated by the first identifier; in response to the second physical interrupt, the VMM obtains the first identifier from the second shared memory of the SPM and the VMM under the control of the second CPU. The second identifier is acquired in the memory, and the second CPU is used to run the VM indicated by the second identifier.
  • the VMM Since the VM indicated by the first identification is the first CPU, and the VM indicated by the second identification is the second CPU, if the VMM obtains the first identification and the second identification under the control of one CPU, the VM will be notified later.
  • the VMM responds to the first physical interrupt under the control of the first CPU to obtain the first identifier, and then the VMM can notify the The VM indicated by the first identification; the VMM responds to the second physical interrupt under the control of the second CPU to obtain the second identification, and then the VMM can notify the VM indicated by the first identification under the control of the first CPU; by contrast , which can save CPU switching.
  • the VMM notifies the Y VMs indicated by the identifiers of the Y VMs, and acquiring Y requests from the Y first shared memories of the Y VMs and Y SPs includes: the VMM controls the first CPU Inject the second virtual interrupt into the VM indicated by the first identifier; the VMM injects the second virtual interrupt into the VM indicated by the second identifier under the control of the second CPU; inject the second virtual interrupt in the VM indicated by the first identifier It is used to make the VM indicated by the first identifier acquire a request from the first shared memory of the VM indicated by the first identifier and the SP indicated by the third identifier, and the third identifier is one of Y SP identifiers and is identical to the first identifier Corresponding; the second virtual interrupt injected into the VM indicated by the second identification is used to make the VM indicated by the second identification obtain the request from the first shared memory of the VM indicated by the second identification and the SP indicated by the fourth identification,
  • the VMM is in the first
  • the second virtual interrupt is injected into the VM indicated by the first identifier under the control of the CPU, and the VMM injects the second virtual interrupt into the VM indicated by the second identifier under the control of the second CPU, so that CPU switching can be omitted.
  • the VMM obtaining the identifiers of the Y VMs delivered by the SPM includes: in response to the third physical interrupt, the VMM obtains the identifiers of the Y VMs from the second shared memory of the SPM and the VMM under the control of the third CPU. logo.
  • the VMM can obtain multiple VMs at one time under the control of the third CPU, so the efficiency is better and the concurrency is better.
  • the VMM notifies the Y VMs indicated by the identifiers of the Y VMs, and obtaining Y requests from the Y first shared memories of the Y VMs and Y SPs includes: the VMM assigns the Y second virtual The interrupt is injected into the Y VMs indicated by the identifiers of the Y VMs, one second virtual interrupt corresponds to one VM, and the second virtual interrupt is used to make the VM obtain a request from the first shared memory of the VM and the SP.
  • the VMM By injecting the second virtual interrupt into the VM, the VMM makes the VM obtain a request from the first shared memory of the VM and the SP, which is applicable to a virtualization scenario.
  • the identifiers of the Y VMs include the fifth identifier and the sixth identifier, and correspondingly, injecting Y second virtual interrupts into the Y VMs indicated by the identifiers of the Y VMs by the VMM includes: Under the control of the three CPUs, a second virtual interrupt is injected into the VM indicated by the fifth identification, and the third CPU is used to run the VM indicated by the fifth identification; the VMM is switched from the third CPU to the fourth CPU under the control of the third CPU , the fourth CPU is used to run the VM indicated by the sixth identification; the VMM injects another second virtual interrupt into the VM indicated by the sixth identification under the control of the fourth CPU; the second virtual interrupt injected into the VM indicated by the fifth identification
  • the interrupt is used to make the VM indicated by the fifth identification obtain a request from the first shared memory of the VM indicated by the fifth identification and the SP indicated by the seventh identification, and the seventh identification is one of the identifications of Y SPs and is identical to the
  • the VMM After acquiring the fifth ID and the sixth ID at one time, the VMM realizes injecting the second virtual interrupt into the VM indicated by the fifth ID and the VM indicated by the sixth ID respectively through CPU switching, which has better efficiency and more concurrency. it is good.
  • the fourth aspect of the embodiment of the present application provides a communication method between a virtual machine and a security isolation zone, the method is applied to a computer system, a rich execution environment REE and a trusted execution environment TEE are deployed on the computer system, and a virtual machine manager is deployed on the REE VMM and X virtual machine VMs, TEE is deployed with a security isolation zone manager SPM and X security isolation zone SPs, one SP corresponds to one VM, wherein, X is a positive integer, the method includes: in response to the second virtual interrupt, the first A VM acquires a request from the first shared memory of the first VM and the first SP, and the request is used to instruct the first VM to perform a target operation, the first VM is one of the X VMs, and the first SP is the same as among the X SPs One corresponding to the first VM; the first VM executes a target operation, and there may be many types of target operations, which are not specifically limited in this embodiment of the present application.
  • the first VM acquires a request from the first shared memory of the first VM and the first SP, and executes the target operation indicated by the request, realizing the active notification of the first SP to the first VM, so that The communication between the first SP and the first VM is more flexible and convenient.
  • the fifth aspect of the embodiment of the present application provides a computer system.
  • a rich execution environment REE and a trusted execution environment TEE are deployed on the computer system.
  • the REE is deployed with a virtual machine manager VMM and X virtual machine VMs.
  • the TEE is deployed with security isolation
  • the zone manager SPM and X security isolated zone SPs, one SP corresponds to one VM, wherein X is a positive integer;
  • the first SP is used for: writing the request into the first shared memory of the first SP and the first VM,
  • the first SP is one of the X SPs, the first VM is one of the X VMs corresponding to the first SP, and the request is used to instruct the first VM to perform the target operation;
  • the first virtual interrupt is triggered, and the first virtual interrupt is used for
  • the SPM is made to notify the first VM to obtain a request from the first shared memory through the VMM.
  • the sixth aspect of the embodiment of the present application provides a computer system.
  • a rich execution environment REE and a trusted execution environment TEE are deployed on the computer system.
  • the REE is deployed with a virtual machine manager VMM and X virtual machine VMs.
  • the TEE is deployed with security isolation.
  • the area manager SPM and X security isolation area SPs one SP corresponds to one VM, wherein X is a positive integer; SPM is used to: respond to Y first virtual interrupts, and obtain Y triggering Y first virtual interrupts
  • the identification of SP wherein, Y SPs belong to X SPs, and Y is a positive integer less than or equal to X; determine the identifications of Y VMs corresponding to the identifications of Y SPs, and the identification of one SP corresponds to the identification of a VM, wherein, Y VMs belong to X VMs; pass the identifiers of Y VMs to the VMM, so that the VMM notifies the Y VMs indicated by the identifiers of the Y VMs, and obtains Y from the Y first shared memory of the Y VMs and Y SPs
  • a request wherein a VM and an SP correspond to a first shared memory, and a request is stored in a first shared memory, and
  • the identifiers of the Y VMs include a first identifier and a second identifier; the SPM is used to transfer the identifiers of the Y VMs to the VMM, so that the VMM notifies the Y VMs indicated by the identifiers of the Y VMs,
  • Obtaining Y requests from Y first shared memories of Y VMs and Y SPs includes: writing the first identification into the second shared memories of SPM and VMM; triggering a first physical interrupt, and the first physical interrupt is used for Make the VMM obtain the first identification from the second shared memory under the control of the first central processing CPU, and notify the VM indicated by the first identification to obtain the first shared memory from the VM indicated by the first identification and the SP indicated by the third identification
  • the third identification is one of the identifications of Y SPs and corresponds to the first identification
  • the first CPU is used to run the VM indicated by the first identification; write the second identification into the second shared memory of SPM and
  • the SPM is used to write the identifiers of Y VMs into the second shared memory of the SPM and the VMM; trigger a third physical interrupt, and the third physical interrupt is used to make the VMM under the control of the third CPU , acquire the identifiers of Y VMs from the second shared memory, and notify the Y VMs indicated by the identifiers of the Y VMs to obtain Y requests from the Y first shared memories of the Y VMs and Y SPs.
  • the SPM is used to establish a second shared memory with the VMM.
  • the seventh aspect of the embodiment of the present application provides a computer system.
  • a rich execution environment REE and a trusted execution environment TEE are deployed on the computer system.
  • the REE is deployed with a virtual machine manager VMM and X virtual machine VMs.
  • the TEE is deployed with security isolation
  • the area manager SPM and X security isolated area SPs, one SP corresponds to one VM, wherein X is a positive integer;
  • the VMM is used to obtain the identifiers of Y VMs delivered by the SPM, wherein Y VMs belong to X VMs, Y is a positive integer less than or equal to X; notify Y VMs indicated by the identifiers of Y VMs to obtain Y requests from Y first shared memories of Y VMs and Y SPs, wherein Y SPs belong to X
  • Each SP, one VM and one SP correspond to a first shared memory, and a request is stored in a first shared memory, and the request is used to
  • Y is greater than 1, and the identifiers of the Y VMs include the first identifier and the second identifier; the VMM is used to respond to the first physical interrupt, under the control of the first CPU, from the second identifier of the SPM and the VMM Obtaining the first identification in the shared memory, the first CPU is used to run the VM indicated by the first identification; in response to the second physical interrupt, obtaining the second identification from the second shared memory of the SPM and the VMM under the control of the second CPU, The second CPU is used to run the VM indicated by the second identifier.
  • the VMM is configured to inject the second virtual interrupt into the VM indicated by the first identifier under the control of the first CPU; inject the second virtual interrupt into the VM indicated by the second identifier under the control of the second CPU In the VM; the second virtual interrupt injected into the VM indicated by the first identification is used to make the VM indicated by the first identification obtain a request from the first shared memory of the VM indicated by the first identification and the SP indicated by the third identification, The third identification is one of the identifications of Y SPs and corresponds to the first identification; the second virtual interrupt injected into the VM indicated by the second identification is used to make the VM indicated by the second identification from the VM indicated by the second identification and The acquisition request in the first shared memory of the SP indicated by the fourth identifier, where the fourth identifier is one of Y SP identifiers and corresponds to the second identifier.
  • the VMM is configured to, in response to the third physical interrupt, obtain the identifiers of Y VMs from the second shared memory of the SPM and the VMM under the control of the third CPU.
  • the VMM is used to inject Y second virtual interrupts into Y VMs indicated by the identifiers of Y VMs, one second virtual interrupt corresponds to one VM, and the second virtual interrupt is used to make the VM from Get the request in the first shared memory of VM and SP.
  • Y is greater than 1, and the identifiers of Y VMs include the fifth identifier and the sixth identifier; the VMM is used to inject a second virtual interrupt into the VM indicated by the fifth identifier under the control of the third CPU Among them, the third CPU is used to run the VM indicated by the fifth identification; under the control of the third CPU, switch from the third CPU to the fourth CPU, and the fourth CPU is used to run the VM indicated by the sixth identification; Injecting another second virtual interrupt into the VM indicated by the sixth identifier under control;
  • the second virtual interrupt injected into the VM indicated by the fifth identification is used to make the VM indicated by the fifth identification obtain a request from the first shared memory of the VM indicated by the fifth identification and the SP indicated by the seventh identification, and the seventh identification is One of the Y SP identifiers and corresponds to the fifth identifier;
  • the second virtual interrupt injected into the VM indicated by the sixth identification is used to make the VM indicated by the sixth identification obtain a request from the first shared memory of the VM indicated by the sixth identification and the SP indicated by the eighth identification, and the eighth identification is One of the identities of Y SPs and corresponds to the six identities.
  • the eighth aspect of the embodiment of the present application provides a computer system.
  • a rich execution environment REE and a trusted execution environment TEE are deployed on the computer system.
  • the REE is deployed with a virtual machine manager VMM and X virtual machine VMs.
  • the TEE is deployed with security isolation
  • the area manager SPM and X security isolation area SPs, one SP corresponds to one VM, wherein, X is a positive integer
  • the method includes: the first VM is used to: respond to the second virtual interrupt, from the first VM and the first SP Get a request in the first shared memory of the first VM, the request is used to instruct the first VM to execute the target operation, the first VM is one of the X VMs, and the first SP is one of the X SPs corresponding to the first VM; execute the target operation .
  • the ninth aspect of the embodiment of the present application provides a computer system, the computer system includes a memory and a processor, the memory is used to store computer-readable instructions (or called computer programs), and the processor is used to read the The above computer-readable instructions are used to implement the method provided by any of the foregoing implementation manners.
  • the tenth aspect of the embodiment of the present application provides a computer program product containing instructions, which is characterized in that, when it is run on a computer, the computer executes any one of the above-mentioned aspects and various possible implementations.
  • the computer program product may be SP software that implements the method described in the aforementioned first aspect or software including the SP software; for another example, the computer program product may be any one of the aforementioned second aspect or the second aspect.
  • the SPM software that implements the method or software that includes the SPM software.
  • the software including SP and the software including SPM may be different program products, or may be the same program product, which is not limited in this application. The realization of other program products can refer to the above description.
  • the eleventh aspect of the embodiment of the present application provides a computer-readable storage medium, including instructions, which is characterized in that, when the instructions are run on a computer, the computer executes the above-mentioned first aspect and various possible implementations. any one of the methods described.
  • the twelfth aspect of the embodiment of the present application provides a chip, including one or more processors. Part or all of the processor is used to read and execute the computer program stored in the memory, so as to execute the method in any possible implementation manner of the first aspect above.
  • the chip includes a memory, and the memory and the processor are connected to the memory through a circuit or wires. Further optionally, the chip further includes a communication interface, and the processor is connected to the communication interface.
  • the communication interface is used to receive data and/or information to be processed, and the processor obtains the data and/or information from the communication interface, processes the data and/or information, and outputs the processing result through the communication interface.
  • the communication interface may be an input-output interface.
  • some of the one or more processors may implement some of the steps in the above method through dedicated hardware, for example, the processing related to the neural network model may be performed by a dedicated neural network processor or graphics processor to achieve.
  • the method provided in the embodiment of the present application may be implemented by one chip, or may be implemented by multiple chips in cooperation.
  • FIG. 1 is a schematic diagram of a hardware architecture provided by an embodiment of the present application.
  • Figure 2 is a schematic diagram of instruction execution in kernel mode
  • FIG. 3 is a schematic diagram of a server structure of an ARM architecture
  • FIG. 4 is a schematic structural diagram of an intelligent terminal
  • FIG. 5 is a schematic diagram of an embodiment of a communication method provided in an embodiment of the present application.
  • FIG. 6 is a schematic diagram of an embodiment of a computer system provided in an embodiment of the present application.
  • FIG. 7 is a schematic diagram of an embodiment of processing one request at a time in the embodiment of the present application.
  • FIG. 8 is a schematic diagram of an embodiment of processing multiple requests at one time in the embodiment of the present application.
  • FIG. 9 is a schematic diagram of an embodiment of injecting a second virtual interrupt in the embodiment of the present application.
  • FIG. 10 is a schematic diagram of a process in which SP1 proactively notifies VM1;
  • FIG. 11 is a schematic structural diagram of a computer system provided in this embodiment.
  • the embodiment of the present application provides a communication method and a related device between a virtual machine and a security isolation area.
  • the method enables the security isolation area to actively notify the virtual machine to perform a certain operation, which is more convenient and flexible.
  • plural means two or more.
  • the term “and/or” or the character “/” in this application is just an association relationship describing associated objects, indicating that there may be three relationships, for example, A and/or B, or A/B, which may indicate: A alone exists, both A and B exist, and B exists alone.
  • the ARM TrustZone technology was first introduced in the ARMv6 version as a security extension. It divides hardware resources into two worlds, the non-secure world (rich execution environment (REE) side) and the secure world (trusted execution environment (trusted execution environment, TEE) side). Among them, the operating system closely related to the user works in the non-secure world, and TrustZone, as a hardware security feature, works in the secure world.
  • the non-secure world does not mean that the operating system or software running in it is malicious, but that the security of its environment is lower than that of the secure world.
  • TrustZone can set sensitive memory as Secure Memory by configuring TZASC (TrustZone Address Space Contoller) register and TZMA (TrustZone Memory Adapter) register, and the non-secure world cannot access this memory.
  • TZASC TrustZone Address Space Contoller
  • TZMA TrustZone Memory Adapter
  • FIG. 1 describes the hardware architecture of ARMv7.
  • the left side is the architecture of the non-secure world.
  • ARM has added the HYP mode (HYP mode) based on the two CPU modes of the user mode (USR mode) and the kernel mode (SVC mode).
  • the operating system closely related to the user runs in the user mode and kernel mode of the non-secure world, and the Hypervisor runs in the newly added HYP mode.
  • HYP mode is a CPU mode with the highest authority in the non-secure world. When the CPU works in this mode, it can access all hardware resources in user mode, kernel mode and HYP mode; but when the CPU runs in the other two modes, it Cannot access HYP-related hardware resources.
  • the Hypervisor has higher authority than the operating system.
  • the secure world on the right also includes two CPU operating modes, user mode and kernel mode.
  • ARMv7 Secure World does not support hardware virtualization, so it does not include HYP mode, but in the latest ARMv8.4 architecture, Secure World starts to support hardware virtualization.
  • Secure World also includes a special, highest-privilege CPU mode: Monitor mode. Monitor mode is the mode with the highest CPU authority. When the CPU works in this mode, it can not only access all hardware resources in the secure world, but also access all hardware resources in the non-secure world. TrustZone can configure Hypervisor-related control registers to initialize and activate the Hypervisor in monitor mode.
  • the monitor mode is also a portal for the non-secure world to enter the secure world.
  • execute the SMC (Secure Monitor Call) command to actively switch from the non-secure world to the monitor mode of the secure world.
  • Executing the ERET instruction in monitor mode the CPU decides to return to the non-secure world or stay in the secure world by checking the NS (non-secure) bit of the SCR (Secure Control Register) register.
  • NS position 1
  • the return operation in the monitoring mode returns to the core of the non-secure world, and the world switch (world switch) operation is performed; when the NS position is 0, the return operation in the monitoring mode returns to the kernel of the secure world, without Perform world switching operations.
  • Hypervisor as a virtualization extension of ARM was first introduced in the ARMv7 version.
  • the non-secure world contains three permission levels: PL0, PL1, and PL2.
  • Hypervisor works in PL2, the highest permission level in the non-secure world.
  • Executing the HVC (Hypervisor Call) instruction in the kernel mode of the non-secure world is a common way to enter the Hypervisor; executing the ERET instruction in the HYP mode returns to the kernel mode (as shown in Figure 2).
  • HVC Hypervisor Call
  • ERET Errvisor Call
  • HYP mode returns to the kernel mode (as shown in Figure 2).
  • ARM introduces the memory virtualization technology of the second layer of memory address translation (Stage-2translation).
  • the common one-level memory address translation from virtual address to physical address (VA->PA) is transformed into virtual address to intermediate physical address IPA, and then from intermediate physical address to physical address (VA->IPA->PA ) for two-level memory address translation.
  • IPA->PA intermediate physical address to physical address translation
  • the process of the second layer of memory address translation (IPA->PA) is completely controlled by the Hypervisor and is transparent to the operating system. From the perspective of the operating system, IPA is the "physical address" it uses.
  • the Hypervisor can control the memory access of the operating system.
  • the page table entry contains three control bits for reading (R), writing (W), and executing (X).
  • the read and write control bits are related to the data protection of the memory
  • the execution control bits are related to the code execution of the memory.
  • the design of the TEE side is slightly different from that of the REE side.
  • the memory management unit MMU
  • the MMU will select vttbr_el2 as the base address register when performing Stage-2 translation
  • the page table entry When the NS bit is 0, the MMU will select vsttbr_el2 as the base address register for Stage-2 translation.
  • vttbr_el2 and vsttbr_el2 registers are: when the CPU works on the TEE side, it may access secure memory, and it may also access non-secure memory, and secure memory and non-secure memory can be distinguished by these two sets of Stage-2 page tables .
  • the system can ensure that the physical address translated by the Stage-2 page table pointed to by vttbr_el2 falls on the non-secure memory; the physical address translated by the page table of vsttbr_el2 falls on the secure memory.
  • the MMU will check the configuration of the system. Once the used page table and the corresponding relationship between the physical address and the memory attribute are violated, the translation process will go wrong.
  • This application can be applied to servers based on the ARM architecture.
  • both the Rich Execution Environment REE and the Trusted Execution Environment TEE support hardware virtualization features, and tenants will create multiple virtual machines (Virtual Machines, VMs) on the REE side.
  • VMs Virtual Machines
  • a secure partition secure partition, SP
  • TEEos will be started in the SP to support the security in the VM business, its architecture is shown in Figure 3.
  • the client application Client Application, CA
  • TA trusted Application
  • This application can also be applied to smart terminals (such as smart phones and other portable devices), as shown in Figure 4, in the smart terminal scenario, although REE and TEE do not have a strong
  • the guest system Guest OS (such as Android os) on the REE side can be considered to be running in the VM
  • the TEEos on the TEE side can be considered to be running in the SP.
  • the interaction between the REE and the TEE can also be Think of it as an interaction between VM and SP.
  • the method provided by the embodiment of the present application can be used to implement active notification of the SP to the VM.
  • the foregoing server and smart terminal may include a processor and a memory.
  • a processor may also be called a central processing unit (central processing unit, CPU) or a central processing unit.
  • processors in the computer system are an Advanced RISC Machines (ARM) processor.
  • memory in the computer are random access memory (random access memory, RAM) or flash memory (Flash). Wherein, RAM may also be referred to as main memory or internal memory.
  • Storage has access rights attributes such as read-only, writable, executable, and inaccessible.
  • the virtualization technology is used in the processor of the computer system.
  • the virtualization technology can hide the underlying physical hardware in the computer, so that multiple independent operating systems (operator system, OS) can transparently use and share the hardware resources of the computer.
  • OS operating system
  • Simply put, virtualization technology enables the computer to run multiple OSs concurrently.
  • the processor in the computer provides program codes with different permission levels to access resources in the computer, so as to protect data in the computer and prevent malicious behaviors in the computer, thereby ensuring the security of the computer.
  • exception levels can be defined in the ARM processor, namely EL0, EL1, EL2 and EL3.
  • the abnormality level with a larger numerical value is higher, and the abnormality level with a smaller numerical value is lower.
  • the level of EL0 is lower than the level of EL1
  • the level of EL1 is lower than the level of EL2
  • the level of EL2 is lower than the level of EL3.
  • a larger value has a lower level of the abnormal level, and a smaller value has a higher level of the abnormal sector, which is not limited in this embodiment of the present application.
  • Firmware such as ARM Trusted firmware (ATF) is the first thing that runs when the processor boots. Firmware provides services such as platform initialization, installation of a trusted operating system, and routing of commands to the security monitor.
  • the CPU execution unit can manage or access the memory through a memory management unit (MMU).
  • MMU memory management unit
  • the MMU can perform address mapping and provide memory access authorization and other operations.
  • the MMU when the program codes running in the running spaces corresponding to different exception levels access the memory, the MMU performs different address mapping and different memory access authorization processes.
  • the abnormal levels on the REE side are called ELO, EL1, EL2, and EL3, and the abnormal levels on the TEE side are called SEL0, SEL1, SEL2, and SEL3.
  • an embodiment of the present application provides an embodiment of a communication method between a virtual machine and a security isolation zone, and the method is applied to a computer system.
  • a rich execution environment REE and a trusted execution environment TEE are deployed on the computer system
  • a virtual machine manager Virtual Machine monitor, VMM
  • X virtual machine VMs are deployed on the REE
  • security isolation is deployed on the TEE
  • a zone manager secure partition monitor secure partition monitor, SPM
  • X security partition SPs one SP corresponds to one VM, where X is a positive integer.
  • the VMM can be understood as a virtual monitoring device, which can be of various types. For example, it can be a hypervisor as shown in FIG. 6 .
  • the VMM can be deployed inside the host operating system, or it can be deployed separately from the host operating system. VMM is responsible for managing one or more virtual machines running on it.
  • the VM includes guest operating system (Guest OS) and various applications (including CA).
  • the virtual machine VM may contain a container (container), and the container is equivalent to an application.
  • the virtualization layer is implemented by lightweight virtualization technology, such as libOS.
  • a libOS usually contains an application, and the entire libOS is one or more libraries, which are linked with the application to form a single address space image.
  • the embodiments of the present application generally take a virtual machine implemented by a traditional virtualization technology as an example, and reference may be made to the implementation of a virtual machine for other types of virtualization architectures.
  • ARM introduced the new CPU working mode of SEL2, which supports the hardware virtualization technology on the TEE side.
  • the TEE side can build a virtualization environment similar to the REE side, and create multiple SPs (Secure Partitions).
  • Each SP can run a TEEos and a trusted application (Enclave Application, EA).
  • EA Enclave Application
  • VMs and SPs There are various ways to create VMs and SPs. For example, every time a VM is started on the REE side, a corresponding SP is started on the TEE side, and the VM interacts with the corresponding SP during runtime, or multiple SPs are started on the TEE side first, and the REE starts again. When multiple VMs are running, the VM selects one of the SPs to interact.
  • the method provided by the embodiment of the present application can be used, so that the SP can proactively notify the VM.
  • X can be 1 or greater than 1; taking Fig. 6 as an example, Fig. 6 shows a VM (VM1) and two SPs (SP1 and SP2), wherein the CA And a Guest OS, running a TEEos and EA in SP1, running an application (Application, APP) and a Guest OS in SP2.
  • the method includes:
  • Step 101 the first SP writes the request into the first shared memory of the first SP and the first VM.
  • the first SP is one of the X SPs
  • the first VM is one of the X VMs corresponding to the first SP
  • the request is used to instruct the first VM to execute the target operation.
  • the shared memory generally includes two shared memories, and one shared memory is used for SMC communication , another shared memory is used for interrupt notification; in this embodiment, the shared memory used for interrupt notification is called the first shared memory, where the first shared memory is physical memory.
  • the method of establishing a shared memory is a relatively mature technology, and the embodiment of the present application will not repeat it here.
  • Step 102 the first SP triggers a first virtual interrupt.
  • the first virtual interrupt is used to make the SPM notify the first VM to obtain a request from the first shared memory through the VMM.
  • the process of the first SP triggering the first virtual interrupt may specifically include: the first SP writes a piece of memory without access rights. Since there is no access right, the write operation will cause a page fault, and the page operation will be perceived by the SPM , thus completing the triggering of the first virtual interrupt.
  • the identifier of the first SP will be written into a corresponding register.
  • Step 103 in response to the Y first virtual interrupts, the SPM acquires the identities of the Y SPs that trigger the Y first virtual interrupts.
  • steps 101 and 102 use the first SP as an example to illustrate the process of triggering the first virtual interrupt; in fact, among the X SPs, there may be one SP that triggers the virtual interrupt, and There may be multiple SPs that trigger virtual interrupts; therefore, in this embodiment of the application, it is assumed that Y SPs trigger Y first virtual interrupts, where Y SPs belong to X SPs, and Y is less than or equal to X A positive integer, specifically, Y can be 1, or 2, 3, etc.
  • the process of SPM responding to the first virtual interrupt may include: first, the SPM intercepts the first virtual interrupt (specifically, the SPM may perceive a page fault caused by the write operation of the first SP); then, the SPM checks the first The legality of the virtual interrupt, in the case that the first virtual interrupt is legal, the SPM reads the identifier (for example, the identifier of the first SP) that triggers the first virtual interrupt from the register.
  • the SPM intercepts the first virtual interrupt (specifically, the SPM may perceive a page fault caused by the write operation of the first SP); then, the SPM checks the first The legality of the virtual interrupt, in the case that the first virtual interrupt is legal, the SPM reads the identifier (for example, the identifier of the first SP) that triggers the first virtual interrupt from the register.
  • the SPM acquires the identities of the Y SPs that trigger the Y first virtual interrupts, which means that all the Y first virtual interrupts are legal.
  • step 104 the SPM determines the identities of Y VMs corresponding to the identities of Y SPs.
  • one SP corresponds to one VM
  • an SP identifier corresponds to a VM identifier, wherein Y VMs belong to X VMs.
  • the SPM may obtain the identifiers of Y VMs based on the correspondence between the identifiers of the SPs and the identifiers of the VMs.
  • Step 105 the SPM transmits the identifiers of Y VMs to the VMM, so that the VMM notifies the Y VMs indicated by the identifiers of the Y VMs, and obtains Y requests from the Y first shared memories of the Y VMs and Y SPs.
  • a VM and an SP correspond to a first shared memory, and a request is stored in a first shared memory, and the request is used to instruct the VM to perform a target operation.
  • the SPM transfers the VM ID to the VMM, which is not specifically limited in the embodiment of the present application; for example, the VM ID can be written into the second shared memory of the SPM and the VMM, and then through a physical interrupt The VMM is notified to read the identifier of the VM from the second shared memory.
  • SPM can write the identifiers of Y VMs into the second shared memory in batches, or write the identifiers of VMs into the second shared memory one by one, as described below These two writing methods are described separately.
  • the second shared memory needs to be utilized during the process of passing the VM ID, the second shared memory needs to be established before step 105 is performed, wherein the second shared memory is a physical memory.
  • the second shared memory can be called the shared memory between VMM and SPM; since the VMM is located in the running space corresponding to EL2, and the SPM is located in the running space corresponding to SEL2, the second shared memory can also be called between EL2 and SEL2 of shared memory.
  • the establishment of the second shared memory is usually when SPM and VMM are started. Specifically, the establishment of the second shared memory may include: when SPM and VMM are started, EL2 applies for a piece of continuous physical memory, and then allocates this continuous physical memory The address of the shared memory is passed to SEL2, and SEL2 maps the address of this continuous physical memory to its own virtual address space, thereby completing the establishment of the second shared memory.
  • the VMM obtains the identifiers of the Y VMs delivered by the SPM.
  • Y VMs belong to X VMs, and Y is a positive integer less than or equal to X.
  • the method for the VMM to obtain the VM ID is related to the method for the SPM to transfer the VM ID to the VMM; for example, the VMM may read the VM ID from the second shared memory of the SPM and the VMM in response to a physical interrupt.
  • Y can be 1 or greater than 1; when Y is greater than 1, the VMM can batch read the VM identifiers from the second shared memory of the SPM and the VMM, or read them from the second shared memory of the SPM and the VMM Read the identities of the VMs one by one.
  • Step 106 the VMM notifies Y VMs indicated by the identifiers of the Y VMs, and obtains Y requests from the Y first shared memories of the Y VMs and Y SPs.
  • Y SPs belong to X SPs
  • a VM and an SP correspond to a first shared memory
  • a request is stored in a first shared memory, and the request is used to instruct the VM to perform a target operation.
  • VMM To notify the VM indicated by the VM identifier, which is not specifically limited in this embodiment of the present application.
  • the VMM may inject a second virtual interrupt into the first VM indicated by the identifier of the first VM, so that the first VM responds to the second virtual interrupt, from the first VM and the second virtual interrupt.
  • An SP gets the first shared memory request.
  • the second virtual interrupt is similar to the first virtual interrupt, and you can refer to the relevant description of the first virtual interrupt to understand the second virtual interrupt; the method of injecting the second virtual interrupt is a relatively mature technology, and the embodiment of this application is here Do not elaborate.
  • the VMM can read VM identifiers one by one from the second shared memory of the SPM and VMM, and the VMM can read VM identifiers in batches from the second shared memory of the SPM and VMM, corresponding to the above two methods of reading VMs.
  • Y VMs indicated by the identifications of Y VMs may be notified through two methods, and the two notification methods will be described respectively below.
  • Step 107 in response to the second virtual interrupt, the first VM obtains a request from the first shared memory of the first VM and the first SP, the request is used to instruct the first VM to perform the target operation, and the first VM is one of the X VMs One, the first SP is the one corresponding to the first VM among the X SPs.
  • Step 108 the first VM executes the target operation.
  • the SPM can process multiple requests at one time, or Process a request.
  • the SPM processes one request at a time.
  • SPM will intercept two first virtual interrupts and obtain the identification of two VMs; after that, SPM first writes the identification of a VM into the second shared memory, and then the The VMM reads the identification of the VM and completes the injection of the second virtual interrupt based on the identification of the VM; then the SPM writes the identification of another VM into the second shared memory, and then the VMM reads the identification of the VM and based on the VM The mark of completes the injection of the second virtual interrupt.
  • Y is greater than 1
  • the identifiers of the Y VMs include the first identifier and the second identifier.
  • this embodiment includes:
  • step 201 the SPM writes the first identifier into the second shared memory of the SPM and the VMM.
  • the second shared memory can be understood by referring to the relevant description above.
  • step 202 the SPM triggers a first physical interrupt.
  • the first physical interrupt is used to make the VMM obtain the first identifier from the second shared memory under the control of the first central processing CPU, and notify the VM indicated by the first identifier to obtain the VM indicated by the first identifier and the VM indicated by the third identifier.
  • the request is obtained from the first shared memory of the SP, the third ID is one of Y SP IDs and corresponds to the first ID, and the first CPU is used to run the VM indicated by the first ID.
  • Step 202 may specifically include: the SPM triggers the first physical interrupt by setting a specific pending bit.
  • the SPM triggers a physical interrupt
  • one of the physical CPUs will handle the physical interrupt; and in this embodiment, in order to realize the first physical interrupt can be To be processed by the first CPU, the content related to the first physical interrupt may be written into a register associated with the first CPU, so that the first physical interrupt can only be processed by the first CPU.
  • Step 203 in response to the first physical interrupt, the VMM obtains the first identifier from the second shared memory of the SPM and the VMM under the control of the first CPU, and the first CPU is used to run the VM indicated by the first identifier.
  • the process of responding to the first physical interrupt may include: the VMM obtains the interrupt number of the first physical interrupt, and when the interrupt number of the first physical interrupt is the interrupt number (preset) notified by the SP to the VM, the VMM starts from the first 2. Obtain the first identifier from the shared memory.
  • Step 204 the VMM injects the second virtual interrupt into the VM indicated by the first identifier under the control of the first CPU.
  • the second virtual interrupt injected into the VM indicated by the first identification is used to make the VM indicated by the first identification obtain a request from the first share of the VM indicated by the first identification and the SP indicated by the third identification, and the third identification is One of the Y SP identifiers and corresponds to the first identifier.
  • the first request is processed through steps 201 to 204, so that the VM indicated by the first identifier can obtain the request.
  • Step 205 the SPM writes the second identifier into the second shared memory of the SPM and the VMM.
  • step 205 only needs to be performed after step 203, that is, as long as the Step 205 may be executed after the first identifier is acquired; step 205 may be executed before step 204 or after step 204 .
  • Step 206 the SPM triggers a second physical interrupt.
  • the second physical interrupt is used to make the VMM obtain the second identifier from the second shared memory under the control of the second CPU, and notify the VM indicated by the second identifier to obtain the information from the VM indicated by the second identifier and the SP indicated by the fourth identifier.
  • the request is obtained from the first shared memory
  • the fourth identifier is one of Y SP identifiers and corresponds to the second identifier
  • the second CPU is used to run the VM indicated by the second identifier.
  • Step 207 in response to the second physical interrupt, the VMM obtains the second identifier from the second shared memory of the SPM and the VMM under the control of the second CPU, and the second CPU is used to run the VM indicated by the second identifier.
  • Step 208 the VMM injects a second virtual interrupt into the VM indicated by the second identifier under the control of the second CPU;
  • the second virtual interrupt injected into the VM indicated by the second identification is used to make the VM indicated by the second identification obtain a request from the first shared memory of the VM indicated by the second identification and the SP indicated by the fourth identification, and the fourth identification is One of the identities of Y SPs and corresponds to the second identities.
  • steps 205 to 208 are similar to steps 201 to 204, and can be understood by referring to the relevant descriptions of steps 201 to 204; the difference is that during the execution of steps 205 to 208, by The second CPU handles the second physical interrupt.
  • step 201 , step 202 , step 205 and step 206 constitute step 105
  • step 203 and step 207 describe the specific process for the VMM to obtain the identifiers of Y VMs
  • step 204 and step 208 constitute step 106 .
  • the SPM handles multiple requests at a time.
  • the SPM writes the identifiers of Y VMs into the second shared memory of the SPM and the VMM at one time, and then the VMM reads the identifiers of the Y VMs and completes the injection of the Y second virtual interrupts.
  • this embodiment includes:
  • step 301 the SPM writes the identifiers of Y VMs into the second shared memory of the SPM and the VMM.
  • Step 302 the SPM triggers a third physical interrupt, and the third physical interrupt is used to make the VMM obtain the identifications of Y VMs from the second shared memory under the control of the third CPU, and notify the Y VMs indicated by the identifications of the Y VMs.
  • the VM gets Y requests from Y first shared memories of Y VMs and Y SPs.
  • Step 303 in response to the third physical interrupt, the VMM acquires identifiers of Y VMs from the second shared memory of the SPM and the VMM under the control of the third CPU.
  • step 304 the VMM injects Y second virtual interrupts into the Y VMs indicated by the identifiers of the Y VMs, one second virtual interrupt corresponds to one VM, and the second virtual interrupt is used to enable the VM to share Get the request in memory.
  • the third CPU may be any one of multiple physical CPUs in the computer system.
  • steps 301 to 304 are similar to steps 201 to 204 , for details, please refer to the relevant description of steps 201 to 204 to understand steps 301 to 304 .
  • step 301 and step 302 constitute step 105
  • step 303 is equivalent to step 105
  • step 304 is equivalent to step 106 .
  • VMM is to inject the second virtual interrupt into a VM
  • the VMM needs to run under the CPU used to run the VM; if the VMM does not run under the CPU used to run the VM, it needs to pass Inter-core communication to achieve CPU switching.
  • step 304 the VMM needs to inject Y second virtual interrupts into the Y VMs indicated by the identifiers of the Y VMs, and the VMM is currently running on the third CPU, so if all the Y VMs can run on the third CPU , then there is no need to switch CPUs, and the injection of all the second virtual interrupts can be completed by the third CPU; if there is a VM among the Y VMs that cannot run under the third CPU, then CPU switching is required, as follows Introduce this situation.
  • Y is greater than 1, and the identifiers of Y VMs include fifth identifiers and sixth identifiers.
  • step 304 includes:
  • Step 401 the VMM injects a second virtual interrupt into the VM indicated by the fifth identifier under the control of the third CPU, and the third CPU is used to run the VM indicated by the fifth identifier;
  • the second virtual interrupt injected into the VM indicated by the fifth identification is used to make the VM indicated by the fifth identification obtain a request from the first shared memory of the VM indicated by the fifth identification and the SP indicated by the seventh identification, and the seventh identification is One of the Y SP identifiers and corresponds to the fifth identifier;
  • Step 402 the VMM is switched from the third CPU to the fourth CPU under the control of the third CPU, and the fourth CPU is used to run the VM indicated by the sixth identifier.
  • switching from the third CPU to the fourth CPU may be implemented through inter-core communication.
  • Step 403 the VMM injects another second virtual interrupt into the VM indicated by the sixth identifier under the control of the fourth CPU;
  • the second virtual interrupt injected into the VM indicated by the sixth identification is used to make the VM indicated by the sixth identification obtain a request from the first shared memory of the VM indicated by the sixth identification and the SP indicated by the eighth identification, and the eighth identification is One of the identities of Y SPs and corresponds to the six identities.
  • this example is a specific description of the process in which SP1 proactively notifies VM1.
  • SP1 writes a request to the shared memory SPI_el1share memory of SP1 and VM1, and then triggers the first virtual interrupt.
  • SPM responds to this first virtual interrupt, obtains the mark of SP1, and obtains the mark of VM1 through the corresponding relationship between the mark of SP1 and the mark of VM1; Then SPM saves the mark of VM1 to In its own memory, Figure 10 calls this memory the SPI send queue.
  • the SPM writes the identifier of VM1 into the shared memory SPI_el2share memory of the SPM and the VMM, and triggers a physical interrupt.
  • the VMM i.e. the hypervisor in Figure 10
  • the VMM reads the identification of VM1 from the shared memory SPI_el2 shared memory, and saves the identification of VM1 in its own memory, Figure 10 calls this memory the SPI recv queue.
  • the VMM injects the second virtual interrupt into VM1, so that VM1 reads the requested content from the shared memory SPI_el1 shared memory, and performs corresponding operations.
  • the embodiment of the present application also provides a computer system.
  • the computer system is deployed with a rich execution environment REE and a trusted execution environment TEE.
  • the REE is deployed with a virtual machine manager VMM and X virtual machine VMs.
  • the TEE is deployed with a security isolation zone management device SPM and X security isolation zone SPs, one SP corresponds to one VM, where X is a positive integer; the first SP is used to: write the request into the first shared memory of the first SP and the first VM, and the first The SP is one of the X SPs, the first VM is one of the X VMs corresponding to the first SP, the request is used to instruct the first VM to perform the target operation; the first virtual interrupt is triggered, and the first virtual interrupt is used to make the SPM
  • the VMM notifies the first VM to acquire the request from the first shared memory.
  • the embodiment of the present application also provides a computer system.
  • the computer system is deployed with a rich execution environment REE and a trusted execution environment TEE.
  • the REE is deployed with a virtual machine manager VMM and X virtual machine VMs.
  • the TEE is deployed with a security isolation zone management
  • One SP corresponds to one VM, and X is a positive integer;
  • the SPM is used for: responding to Y first virtual interrupts, obtaining the Y SPs that trigger Y first virtual interrupts Identification, wherein, Y SPs belong to X SPs, and Y is a positive integer less than or equal to X; determine the identifications of Y VMs corresponding to the identifications of Y SPs, and the identification of one SP corresponds to the identification of a VM, wherein, Y
  • the VM belongs to X VMs; the identifiers of Y VMs are passed to the VMM, so that the VMM notifies the Y VMs indicated by the identifier
  • the identifiers of the Y VMs include a first identifier and a second identifier; the SPM is used to transfer the identifiers of the Y VMs to the VMM, so that the VMM notifies the Y VMs indicated by the identifiers of the Y VMs,
  • Obtaining Y requests from Y first shared memories of Y VMs and Y SPs includes: writing the first identification into the second shared memories of SPM and VMM; triggering a first physical interrupt, and the first physical interrupt is used for Make the VMM obtain the first identification from the second shared memory under the control of the first central processing CPU, and notify the VM indicated by the first identification to obtain the first shared memory from the VM indicated by the first identification and the SP indicated by the third identification
  • the third identification is one of the identifications of Y SPs and corresponds to the first identification
  • the first CPU is used to run the VM indicated by the first identification; write the second identification into the second shared memory of SPM and
  • the SPM is used to write the identifiers of Y VMs into the second shared memory of the SPM and the VMM; trigger a third physical interrupt, and the third physical interrupt is used to make the VMM under the control of the third CPU , acquire the identifiers of Y VMs from the second shared memory, and notify the Y VMs indicated by the identifiers of the Y VMs to obtain Y requests from the Y first shared memories of the Y VMs and Y SPs.
  • the SPM is used to establish a second shared memory with the VMM.
  • the embodiment of the present application also provides a computer system.
  • the computer system is deployed with a rich execution environment REE and a trusted execution environment TEE.
  • the REE is deployed with a virtual machine manager VMM and X virtual machine VMs.
  • the TEE is deployed with a security isolation zone management
  • One SP corresponds to one VM, where X is a positive integer; the VMM is used to obtain the identifications of Y VMs delivered by the SPM, where Y VMs belong to X VMs, and Y is A positive integer less than or equal to X; notify Y VMs indicated by the identifiers of Y VMs to obtain Y requests from Y first shared memories of Y VMs and Y SPs, wherein Y SPs belong to X SPs , a VM and an SP correspond to a first shared memory, and a request is stored in a first shared memory, and the request is used to instruct the VM to perform a target operation.
  • Y is greater than 1, and the identifiers of the Y VMs include the first identifier and the second identifier; the VMM is used to respond to the first physical interrupt, under the control of the first CPU, from the second identifier of the SPM and the VMM Obtaining the first identification in the shared memory, the first CPU is used to run the VM indicated by the first identification; in response to the second physical interrupt, obtaining the second identification from the second shared memory of the SPM and the VMM under the control of the second CPU, The second CPU is used to run the VM indicated by the second identifier.
  • the VMM is configured to inject the second virtual interrupt into the VM indicated by the first identifier under the control of the first CPU; inject the second virtual interrupt into the VM indicated by the second identifier under the control of the second CPU In the VM; the second virtual interrupt injected into the VM indicated by the first identification is used to make the VM indicated by the first identification obtain a request from the first shared memory of the VM indicated by the first identification and the SP indicated by the third identification, The third identification is one of the identifications of Y SPs and corresponds to the first identification; the second virtual interrupt injected into the VM indicated by the second identification is used to make the VM indicated by the second identification from the VM indicated by the second identification and The acquisition request in the first shared memory of the SP indicated by the fourth identifier, where the fourth identifier is one of Y SP identifiers and corresponds to the second identifier.
  • the VMM is configured to, in response to the third physical interrupt, obtain the identifiers of Y VMs from the second shared memory of the SPM and the VMM under the control of the third CPU.
  • the VMM is used to inject Y second virtual interrupts into Y VMs indicated by the identifiers of Y VMs, one second virtual interrupt corresponds to one VM, and the second virtual interrupt is used to make the VM from Get the request in the first shared memory of VM and SP.
  • Y is greater than 1, and the identifiers of Y VMs include the fifth identifier and the sixth identifier; the VMM is used to inject a second virtual interrupt into the VM indicated by the fifth identifier under the control of the third CPU Among them, the third CPU is used to run the VM indicated by the fifth identification; under the control of the third CPU, switch from the third CPU to the fourth CPU, and the fourth CPU is used to run the VM indicated by the sixth identification; Injecting another second virtual interrupt into the VM indicated by the sixth identifier under control;
  • the second virtual interrupt injected into the VM indicated by the fifth identification is used to make the VM indicated by the fifth identification obtain a request from the first shared memory of the VM indicated by the fifth identification and the SP indicated by the seventh identification, and the seventh identification is One of the Y SP identifiers and corresponds to the fifth identifier;
  • the second virtual interrupt injected into the VM indicated by the sixth identification is used to make the VM indicated by the sixth identification obtain a request from the first shared memory of the VM indicated by the sixth identification and the SP indicated by the eighth identification, and the eighth identification is One of the identities of Y SPs and corresponds to the six identities.
  • the embodiment of the present application also provides a computer system.
  • the computer system is deployed with a rich execution environment REE and a trusted execution environment TEE.
  • the REE is deployed with a virtual machine manager VMM and X virtual machine VMs.
  • the TEE is deployed with a security isolation zone management
  • One SP corresponds to one VM, wherein X is a positive integer, and the method includes: the first VM is used to: respond to the second virtual interrupt, from the first VM and the first SP An acquisition request in the shared memory, the request is used to instruct the first VM to execute the target operation, the first VM is one of the X VMs, and the first SP is one of the X SPs corresponding to the first VM; execute the target operation.
  • the present application also provides a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium contains computer instructions, and when the computer instructions are executed by a computer, the interrupt processing method in the above-mentioned embodiments can be realized.
  • FIG. 11 is a schematic structural diagram of a computer system provided by this embodiment.
  • the computer system may be a terminal device (or called an intelligent terminal) or a server.
  • the computer system includes a communication module 810 , a sensor 820 , a user input module 830 , an output module 840 , a processor 850 , an audio and video input module 860 , a memory 870 and a power supply 880 .
  • the communication module 810 may include at least one module that enables communication between the computer system and a communication system or other computer systems.
  • the communication module 810 may include one or more of a wired network interface, a broadcast receiving module, a mobile communication module, a wireless Internet module, a local area communication module, and a location (or positioning) information module.
  • the sensor 820 may sense the current state of the system, such as open/closed state, position, whether there is contact with a user, direction, and acceleration/deceleration, and the sensor 820 may generate a sensing signal for controlling the operation of the system.
  • the user input module 830 is configured to receive input digital information, character information or contact touch operation/non-contact gesture, and receive signal input related to system user settings and function control.
  • the user input module 830 includes a touch panel and/or other input devices.
  • the output module 840 includes a display panel for displaying information input by the user, information provided to the user, or various menu interfaces of the system, and the like.
  • the display panel may be configured in the form of a liquid crystal display (liquid crystal display, LCD) or an organic light-emitting diode (organic light-emitting diode, OLED).
  • the touch panel can cover the display panel to form a touch display screen.
  • the output module 840 may also include an audio output module, an alarm, a haptic module, and the like.
  • the audio and video input module 860 is used for inputting audio signals or video signals.
  • the audio and video input module 860 may include a camera and a microphone.
  • the power supply 880 may receive external power and internal power under the control of the processor 850, and provide power required for operations of various components of the system.
  • the processor 850 includes one or more processors, for example, the processor 850 may include a central processing unit and a graphics processing unit.
  • the central processing unit has multiple cores and belongs to the multi-core processor. These multiple cores can be integrated on the same chip, or can be independent chips.
  • the memory 870 stores computer programs including an operating system program 872, an application program 871, and the like.
  • Typical operating systems such as Windows of Microsoft Corporation, MacOS of Apple Corporation, etc. are used for desktop or notebook systems, and systems such as Android-based systems developed by Google are used for mobile terminals.
  • the methods provided in the foregoing embodiments may be implemented in software, and may be regarded as a specific implementation of the operating system program 872 .
  • Memory 870 may be one or more of the following types: flash memory, hard disk type memory, micro multimedia card type memory, card type memory (such as SD or XD memory), random access memory (random access memory) , RAM), static random access memory (static RAM, SRAM), read only memory (read only memory, ROM), electrically erasable programmable read only memory (electrically erasable programmable readonly memory, EEPROM), programmable read only memory Memory (programmable ROM, PROM), rollback protection memory block (replay protected memory block, RPMB), magnetic storage, magnetic disk or optical disk.
  • the storage 870 may also be a network storage device on the Internet, and the system may perform operations such as updating or reading the storage 870 on the Internet.
  • the processor 850 is used to read the computer program in the memory 870, and then execute the method defined by the computer program, for example, the processor 850 reads the operating system program 872 to run the operating system in the system and realize various functions of the operating system, or read One or more application programs 871 are fetched to run applications on the system.
  • the memory 870 also stores other data 873 besides computer programs.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Storage Device Security (AREA)

Abstract

本申请实施例公开了一种虚拟机与安全隔离区间的通信方法及相关装置,该方法使得安全隔离区能够主动通知虚拟机执行某种操作,更加方便、灵活;该方法包括:第一安全隔离区SP将请求写入第一SP和第一虚拟机VM的第一共享内存中,第一SP为X个SP中的一个,第一VM为X个VM中与第一SP对应的一个,请求用于指示第一VM执行目标操作。

Description

一种虚拟机与安全隔离区间的通信方法及相关装置
本申请要求于2021年06月23日提交中国专利局、申请号为202110700462.4、发明名称为“一种虚拟机与安全隔离区间的通信方法及相关装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及计算机领域,尤其涉及一种虚拟机与安全隔离区间的通信方法及相关装置。
背景技术
为了保证终端设备的安全性,出现了以ARM(advanced RISC machines)为代表的终端设备安全框架(其中,RISC的英文全称为reduced instruction set computer)。在ARM框架下,系统级的安全是通过将片上系统(system on chips,SoC)的软硬件资源划分到两个世界中获得的。这两个世界即正常世界(normal world)和安全世界(secure world)(也可以叫安全域和非安全域),这两个世界分别对应富执行环境(rich execution environment,REE)和可信执行环境(trusted execution environment,TEE)。REE和TEE运行于同一台物理设备上,分别运行一套操作系统。REE运行安全性要求低的客户端应用(client application,CA);TEE则运行需要保障其安全性的可信应用(trusted application,TA),为授权的可信应用TA提供安全的执行环境。CA和TA之间通过提供的通信机制进行通信,就如同客户端和服务器一般。
随着TrustZone技术的不断发展,各大厂商都纷纷采用自己的可信操作系统(trusted operating system,TEEos),ARM在v8.4的版本中,引入了SEL2这一新的CPU工作模式,支持TEE侧的硬件虚拟化技术。基于该技术,TEE侧可以和REE侧类似地构建虚拟化环境,创建多个安全隔离区(secure partition,SP),每个SP中可以运行一个TEEos。多TEEos架构可以解决TEEos碎片和支持REE侧多虚拟机(Virtual Machine,VM)这两个问题。
具体地,在REE侧创建多个VM,为了给每个VM提供TEE的支持,VM启动时,会相应地在TEE侧启动一个SP,并在SP中运行TEEos,以支持VM中的安全业务。在运行时,VM中的CA会请求SP中TA的安全服务。
然而,在目前ARM的机制和规范中,只提供了REE主动通知TEE执行操作的方法,并没有提供TEE主动通知REE执行操作的方法;TEE若想通知REE执行某种操作,只能在REE主动通知TEE的过程中,通过返回信息通知REE执行相应地操作,这种方式不够灵活、方便。
发明内容
本申请实施例提供了一种虚拟机与安全隔离区间的通信方法及相关装置,该方法使得安全隔离区能够主动通知虚拟机执行某种操作,更加方便、灵活。
本申请实施例第一方面提供了一种虚拟机与安全隔离区间的通信方法,方法应用于计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个 SP对应对一个VM,其中,X为正整数,方法包括:第一SP将请求写入第一SP和第一VM的第一共享内存中,第一共享内存通常是在第一VM和第一SP启动的过程中建立的,第一SP为X个SP中的一个,第一VM为X个VM中与第一SP对应的一个,请求用于指示第一VM执行目标操作,目标操作的种类可以有很多,本申请实施例对此不做具体限定;第一SP触发第一虚拟中断,第一虚拟中断用于使得SPM通过VMM通知第一VM从第一共享内存中获取请求;第一SP触发第一虚拟中断的过程具体可以包括:第一SP对一块无访问权限的内存进行写操作,由于无访问权限,所以该写操作会导致页错误,该页操作会被SPM感知到,从而完成了第一虚拟中断的触发。
第一SP将请求写入第一SP和第一VM的第一共享内存中,并触发第一虚拟中断,以使得SPM通过VMM通知第一VM从第一共享内存中获取请求,实现了第一SP对第一VM的主动通知,使得第一SP和第一VM之间的通信更加灵活、方便。
本申请实施例第二方面提供了一种虚拟机与安全隔离区间的通信方法,方法应用于计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数,方法包括:响应于Y个第一虚拟中断,SPM获取触发Y个第一虚拟中断的Y个SP的标识,具体地,SPM可以从寄存器中获取Y个SP的标识,其中,Y个SP属于X个SP,Y为小于或等于X的正整数;SPM确定Y个SP的标识对应的Y个VM的标识,一个SP的标识对应一个VM的标识,具体地,SPM可以基于SP的标识与VM的标识之间的对应关系,得到Y个VM的标识,其中,Y个VM属于X个VM;SPM向VMM传递Y个VM的标识,以使得VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求,其中,传递Y个VM的标识的方法有多种,本申请实施例对此不做具体限定,一个VM和一个SP对应一个第一共享内存,一个第一共享内存中存储有一个请求,请求用于指示VM执行目标操作。
SPM获取触发Y个第一虚拟中断的Y个SP的标识,然后将Y个SP的标识对应的Y个VM的标识传递给VMM,使得VMM通知Y个VM的标识指示的Y个VM,从而实现了第一SP对第一VM的主动通知,使得第一SP和第一VM之间的通信更加灵活、方便。
作为一种可实现的方式,Y大于1,Y个VM的标识包括第一标识和第二标识;SPM向VMM传递Y个VM的标识,以使得VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求包括:SPM将第一标识写入SPM和VMM的第二共享内存中;SPM触发第一物理中断,第一物理中断用于使得VMM在第一中央处理CPU的控制下,从第二共享内存中获取第一标识,并通知第一标识指示的VM从第一标识指示的VM和第三标识指示的SP的第一共享内存中获取请求,第三标识为Y个SP的标识中的一个且与第一标识对应,第一CPU用于运行第一标识指示的VM;响应于第一物理中断的过程可以具体包括:VMM获取第一物理中断的中断号,在第一物理中断的中断号是SP通知VM的中断号(预先设置的)的情况下,VMM从第二共享内存中获取第一标识。
SPM将第二标识写入SPM和VMM的第二共享内存中;SPM触发第二物理中断,第二物理中断用于使得VMM在第二CPU的控制下,从第二共享内存中获取第二标识,并通知第二标 识指示的VM从第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,第四标识为Y个SP的标识中的一个且与第二标识对应,第二CPU用于运行第二标识指示的VM。
由于通知VM的操作需要在能够运行VM的CPU的控制下执行,所以若物理终端由无法运行VM的CPU响应,那在响应后需要切换至能够运行VM的CPU,然后由能够运行VM的CPU完成对VM的通知;而本申请实施例设置了物理中断的亲和性,即由特定的CPU完成对特定物理中断的处理;具体地,对于第一标识,由能够运行第一标识指示的VM的第一CPU处理第一物理中断,使得VMM在第一CPU的控制下获取第一标识,并通知第一标识指示的VM获取请求;对于第二标识,由能够运行第二标识指示的VM的第二CPU处理第一物理中断,使得VMM在第二CPU的控制下获取第二标识,并通知第二标识指示的VM获取请求;这样,便省去了CPU切换的操作。
作为一种可实现的方式,SPM向VMM传递Y个VM的标识,以使得VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求包括:SPM将Y个VM的标识写入SPM和VMM的第二共享内存中;SPM触发第三物理中断,第三物理中断用于使得VMM在第三CPU的控制下,从第二共享内存中获取Y个VM的标识,并通知Y个VM的标识指示的Y个VM从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求,其中,第三CPU可以是计算机系统中多个物理CPU中的任意一个。
当Y大于1时,SPM可以一次性地将多个VM的标识写入SPM和VMM的第二共享内存中,并仅触发一个第三物理中断,VMM在第三CPU的控制下可以一次性地获取多个VM,所以效率更好,并发性更好。
作为一种可实现的方式,在SPM向VMM传递Y个VM的标识,以使得VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求之前,方法还包括:SPM与VMM建立第二共享内存。
第二共享内存的建立通常在SPM和VMM启动时,具体地,第二共享内存的建立可以包括:在SPM和VMM启动时,由EL2申请一片连续的物理内存,然后将这段连续的物理内存的地址传递给SEL2,SEL2将这段连续的物理内存的地址映射到自身的虚拟地址空间,从而完成第二共享内存的建立。
本申请实施例第三方面提供了一种虚拟机与安全隔离区间的通信方法,方法应用于计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数,方法包括:VMM获取SPM传递的Y个VM的标识,其中,Y个VM属于X个VM,Y为小于或等于X的正整数;VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求,其中,Y个SP属于X个SP,一个VM和一个SP对应一个第一共享内存,一个第一共享内存中存储有一个请求,请求用于指示VM执行目标操作。
VMM获取SPM传递的Y个VM的标识,并通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求,从而实现了第一SP对第一VM的主动通知,使得第一SP和第一VM之间的通信更加灵活、方便。
作为一种可实现的方式,Y个VM的标识包括第一标识和第二标识;VMM获取SPM传递的Y个VM的标识包括:响应于第一物理中断,VMM在第一CPU的控制下从SPM和VMM的第二共享内存中获取第一标识,第一CPU用于运行第一标识指示的VM;响应于第二物理中断,VMM在第二CPU的控制下从SPM和VMM的第二共享内存中获取第二标识,第二CPU用于运行第二标识指示的VM。
由于运行第一标识指示的VM是第一CPU,运行第二标识指示的VM是第二CPU,所以若由VMM在一个CPU的控制下获取第一标识和第二标识,则在后续通知VM的过程中,需要进行CPU的切换;而在该可实现的方式中,VMM在第一CPU的控制下响应于第一物理中断,获取第一标识,之后VMM在第一CPU的控制下便可以通知第一标识指示的VM;VMM在第二CPU的控制下响应于第二物理中断,获取第二标识,之后VMM在第一CPU的控制下便可以通知第一标识指示的VM;相比之下,该可实现的方式能够省去CPU的切换。
作为一种可实现的方式,VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求包括:VMM在第一CPU的控制下将第二虚拟中断注入第一标识指示的VM中;VMM在第二CPU的控制下将第二虚拟中断注入第二标识指示的VM中;注入第一标识指示的VM中的第二虚拟中断用于使得,第一标识指示的VM从第一标识指示的VM和第三标识指示的SP的第一共享内存中获取请求,第三标识为Y个SP的标识中的一个且与第一标识对应;注入第二标识指示的VM中的第二虚拟中断用于使得,第二标识指示的VM从第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,第四标识为Y个SP的标识中的一个且与二标识对应。
由于将第二虚拟中断注入VM需要在能够运行VM的CPU的控制下进行,而运行第一标识指示的VM是第一CPU,运行第二标识指示的VM是第二CPU,所以VMM在第一CPU的控制下将第二虚拟中断注入第一标识指示的VM中,VMM在第二CPU的控制下将第二虚拟中断注入第二标识指示的VM中,能够省去CPU的切换。
作为一种可实现的方式,VMM获取SPM传递的Y个VM的标识包括:响应于第三物理中断,VMM在第三CPU的控制下从SPM和VMM的第二共享内存中获取Y个VM的标识。
当Y大于1时,VMM在第三CPU的控制下可以一次性地获取多个VM,所以效率更好,并发性更好。
作为一种可实现的方式,VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求包括:VMM将Y个第二虚拟中断注入Y个VM的标识指示的Y个VM中,一个第二虚拟中断对应一个VM,且第二虚拟中断用于使得VM从VM和SP的第一共享内存中获取请求。
VMM通过向VM中注入第二虚拟中断,使得VM从VM和SP的第一共享内存中获取请求,适用于虚拟化的场景。
作为一种可实现的方式,Y个VM的标识包括第五标识和第六标识,相应地,VMM将Y个第二虚拟中断注入Y个VM的标识指示的Y个VM中包括:VMM在第三CPU的控制下将一个第二虚拟中断注入第五标识指示的VM中,第三CPU用于运行第五标识指示的VM;VMM在第三CPU的控制下从第三CPU切换到第四CPU,第四CPU用于运行第六标识指示的VM;VMM 在第四CPU的控制下将另一个第二虚拟中断注入第六标识指示的VM中;注入第五标识指示的VM中的第二虚拟中断用于使得,第五标识指示的VM从第五标识指示的VM和第七标识指示的SP的第一共享内存中获取请求,第七标识为Y个SP的标识中的一个且与第五标识对应;注入第六标识指示的VM中的第二虚拟中断用于使得,第六标识指示的VM从第六标识指示的VM和第八标识指示的SP的第一共享内存中获取请求,第八标识为Y个SP的标识中的一个且与六标识对应。
在一次性获取第五标识和第六标识后,VMM通过CPU切换的方式实现了将第二虚拟中断分别注入到第五标识指示的VM和第六标识指示的VM,效率更好,并发性更好。
本申请实施例第四方面提供了一种虚拟机与安全隔离区间的通信方法,方法应用于计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数,方法包括:响应于第二虚拟中断,第一VM从第一VM和第一SP的第一共享内存中获取请求,请求用于指示第一VM执行目标操作,第一VM为X个VM中的一个,第一SP为X个SP中与第一VM对应的一个;第一VM执行目标操作,目标操作的种类可以有很多,本申请实施例对此不做具体限定。
响应于第二虚拟中断,第一VM从第一VM和第一SP的第一共享内存中获取请求,并执行请求所指示的目标操作,实现了第一SP对第一VM的主动通知,使得第一SP和第一VM之间的通信更加灵活、方便。
本申请实施例第五方面提供了一种计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数;第一SP用于:将请求写入第一SP和第一VM的第一共享内存中,第一SP为X个SP中的一个,第一VM为X个VM中与第一SP对应的一个,请求用于指示第一VM执行目标操作;触发第一虚拟中断,第一虚拟中断用于使得SPM通过VMM通知第一VM从第一共享内存中获取请求。
本申请实施例第六方面提供了一种计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数;SPM用于:响应于Y个第一虚拟中断,获取触发Y个第一虚拟中断的Y个SP的标识,其中,Y个SP属于X个SP,Y为小于或等于X的正整数;确定Y个SP的标识对应的Y个VM的标识,一个SP的标识对应一个VM的标识,其中,Y个VM属于X个VM;向VMM传递Y个VM的标识,以使得VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求,其中,一个VM和一个SP对应一个第一共享内存,一个第一共享内存中存储有一个请求,请求用于指示VM执行目标操作。
其中,以上各单元的具体实现、相关说明以及技术效果请参考本申请实施例第一方面的描述。
作为一种可实现的方式,Y个VM的标识包括第一标识和第二标识;SPM用于,向VMM传递Y个VM的标识,以使得VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP 的Y个第一共享内存中获取Y个请求包括:将第一标识写入SPM和VMM的第二共享内存中;触发第一物理中断,第一物理中断用于使得VMM在第一中央处理CPU的控制下,从第二共享内存中获取第一标识,并通知第一标识指示的VM从第一标识指示的VM和第三标识指示的SP的第一共享内存中获取请求,第三标识为Y个SP的标识中的一个且与第一标识对应,第一CPU用于运行第一标识指示的VM;将第二标识写入SPM和VMM的第二共享内存中;触发第二物理中断,第二物理中断用于使得VMM在第二CPU的控制下,从第二共享内存中获取第二标识,并通知第二标识指示的VM从第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,第四标识为Y个SP的标识中的一个且与第二标识对应,第二CPU用于运行第二标识指示的VM。
作为一种可实现的方式,SPM用于将Y个VM的标识写入SPM和VMM的第二共享内存中;触发第三物理中断,第三物理中断用于使得VMM在第三CPU的控制下,从第二共享内存中获取Y个VM的标识,并通知Y个VM的标识指示的Y个VM从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求。
作为一种可实现的方式,SPM用于,与VMM建立第二共享内存。
其中,以上各单元的具体实现、相关说明以及技术效果请参考本申请实施例第二方面的描述。
本申请实施例第七方面提供了一种计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数;VMM用于,获取SPM传递的Y个VM的标识,其中,Y个VM属于X个VM,Y为小于或等于X的正整数;通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求,其中,Y个SP属于X个SP,一个VM和一个SP对应一个第一共享内存,一个第一共享内存中存储有一个请求,请求用于指示VM执行目标操作。
作为一种可实现的方式,Y大于1,Y个VM的标识包括第一标识和第二标识;VMM用于响应于第一物理中断,在第一CPU的控制下从SPM和VMM的第二共享内存中获取第一标识,第一CPU用于运行第一标识指示的VM;响应于第二物理中断,在第二CPU的控制下从SPM和VMM的第二共享内存中获取第二标识,第二CPU用于运行第二标识指示的VM。
作为一种可实现的方式,VMM用于,在第一CPU的控制下将第二虚拟中断注入第一标识指示的VM中;在第二CPU的控制下将第二虚拟中断注入第二标识指示的VM中;注入第一标识指示的VM中的第二虚拟中断用于使得,第一标识指示的VM从第一标识指示的VM和第三标识指示的SP的第一共享内存中获取请求,第三标识为Y个SP的标识中的一个且与第一标识对应;注入第二标识指示的VM中的第二虚拟中断用于使得,第二标识指示的VM从第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,第四标识为Y个SP的标识中的一个且与二标识对应。
作为一种可实现的方式,VMM用于响应于第三物理中断,在第三CPU的控制下从SPM和VMM的第二共享内存中获取Y个VM的标识。
作为一种可实现的方式,VMM用于将Y个第二虚拟中断注入Y个VM的标识指示的Y个 VM中,一个第二虚拟中断对应一个VM,且第二虚拟中断用于使得VM从VM和SP的第一共享内存中获取请求。
作为一种可实现的方式,Y大于1,Y个VM的标识包括第五标识和第六标识;VMM用于,在第三CPU的控制下将一个第二虚拟中断注入第五标识指示的VM中,第三CPU用于运行第五标识指示的VM;在第三CPU的控制下从第三CPU切换到第四CPU,第四CPU用于运行第六标识指示的VM;在第四CPU的控制下将另一个第二虚拟中断注入第六标识指示的VM中;
注入第五标识指示的VM中的第二虚拟中断用于使得,第五标识指示的VM从第五标识指示的VM和第七标识指示的SP的第一共享内存中获取请求,第七标识为Y个SP的标识中的一个且与第五标识对应;
注入第六标识指示的VM中的第二虚拟中断用于使得,第六标识指示的VM从第六标识指示的VM和第八标识指示的SP的第一共享内存中获取请求,第八标识为Y个SP的标识中的一个且与六标识对应。
其中,以上各单元的具体实现、相关说明以及技术效果请参考本申请实施例第三方面的描述。
本申请实施例第八方面提供了一种计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数,方法包括:第一VM用于:响应于第二虚拟中断,从第一VM和第一SP的第一共享内存中获取请求,请求用于指示第一VM执行目标操作,第一VM为X个VM中的一个,第一SP为X个SP中与第一VM对应的一个;执行目标操作。
其中,以上各单元的具体实现、相关说明以及技术效果请参考本申请实施例第四方面的描述。
本申请实施例第九方面提供一种计算机系统,所述计算机系统包括存储器和处理器,所述存储器用于存储计算机可读指令(或者称之为计算机程序),所述处理器用于读取所述计算机可读指令以实现前述任意实现方式提供的方法。
本申请实施例第十方面提供了一种包含指令的计算机程序产品,其特征在于,当其在计算机上运行时,使得所述计算机执行如前述任一方面以及各种可能的实现方式中任一项所述的方法。例如,该计算机程序产品可以为实现前述第一方面所述的方法的SP软件或包含该SP软件的软件;再例如,该计算机程序产品可以为实现前述第二方面或第二方面的任意一种实现方式的SPM软件或包含该SPM软件的软件。包含SP的软件和包含SPM的软件可以为不同的程序产品,也可以为同一程序产品,本申请不做限定。其它程序产品的实现可参考以上说明。
本申请实施例第十一方面提供了一种计算机可读存储介质,包括指令,其特征在于,当所述指令在计算机上运行时,使得计算机执行如上述第一方面以及各种可能的实现方式中任一项所述的方法。
本申请实施例第十二方面提供了一种芯片,包括一个或多个处理器。所述处理器中的部分或全部用于读取并执行存储器中存储的计算机程序,以执行上述第一方面任意可能的 实现方式中的方法。
可选地,该芯片该包括存储器,该存储器与该处理器通过电路或电线与存储器连接。进一步可选地,该芯片还包括通信接口,处理器与该通信接口连接。通信接口用于接收需要处理的数据和/或信息,处理器从该通信接口获取该数据和/或信息,并对该数据和/或信息进行处理,并通过该通信接口输出处理结果。该通信接口可以是输入输出接口。
在一些实现方式中,所述一个或多个处理器中还可以有部分处理器是通过专用硬件的方式来实现以上方法中的部分步骤,例如涉及神经网络模型的处理可以由专用神经网络处理器或图形处理器来实现。
本申请实施例提供的方法可以由一个芯片实现,也可以由多个芯片协同实现。
附图说明
图1为本申请实施例提供的一种硬件架构示意;
图2为内核模式的指令执行示意;
图3为一种ARM架构的服务器结构示意;
图4为一种智能终端的结构示意;
图5为本申请实施例提供了的通信方法的一个实施例示意图;
图6为本申请实施例提供的计算机系统的一个实施例示意图;
图7为本申请实施例中一次处理一个请求的实施例示意图;
图8为本申请实施例中一次处理多个请求的实施例示意图;
图9为本申请实施例中注入第二虚拟中断的实施例示意图;
图10为SP1主动通知VM1的过程的示意图;
图11为本实施例提供的一种计算机系统的结构示意。
具体实施方式
本申请实施例提供了一种虚拟机与安全隔离区间的通信方法及相关装置,该方法使得安全隔离区能够主动通知虚拟机执行某种操作,更加方便、灵活。
下面结合附图,对本申请的实施例进行描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。本领域普通技术人员可知,随着技术的发展和新场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或模块的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或模块,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或模块。在本申请中出现的对步骤进行的命名或者编号,并不意味着必须按照命名或者编号所指示的时间/逻辑先后顺序执行方法流程中的步骤,已经命名或者编号的流 程步骤可以根据要实现的技术目的变更执行次序,只要能达到相同或者相类似的技术效果即可。
另外,在本发明的描述中,除非另有说明,“多个”的含义是两个或两个以上。本申请中的术语“和/或”或字符“/”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,或A/B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。
智能移动终端的飞速发展给我们的生活带来了极大的便利,绝大多数的移动终端都运行ARM中央处理单元(central processing unit,CPU)上。随着ARM CPU性能的不断提升,ARM CPU开始广泛应用于服务器。如今,智能终端和云服务器携带了越来越多的用户个人信息,用户也越来越重视设备的安全性。ARM CPU上,当前主流的系统级解决方案是TrustZone技术。
ARM TrustZone技术作为安全拓展最早是在ARMv6的版本中被引入的,它把硬件的资源划分为两个世界,非安全世界(富执行环境(rich execution environment,REE)侧)和安全世界(可信执行环境(trusted execution environment,TEE)侧)。其中与用户关系密切的操作系统工作在非安全世界,TrustZone作为硬件安全特性,工作在安全世界。非安全世界并不是指运行在其中的操作系统或者软件是恶意的,而是它所处环境的安全性比安全世界低。因为当CPU工作在非安全世界的时候,安全世界的资源(如寄存器、内存、高速缓冲存储器(Cache)、外设等)是被禁止访问的,一旦CPU试图访问这些资源,系统将会直接崩溃。例如,TrustZone可以通过配置TZASC(TrustZone Address Space Contoller)寄存器和TZMA(TrustZone Memory Adapter)寄存器,把敏感的内存设置为Secure Memory(安全内存),非安全世界就无法对这片内存进行访问。当CPU工作在安全世界时,它既可以访问安全世界的资源,又可以访问非安全世界的资源。正是由于拥有比非安全世界的操作系统更高的权限,TrustZone可以作为可信根为非安全世界的操作系统提供更高级别的安全保护方案。
图1描述了ARMv7的硬件架构。左侧是非安全世界的架构,为了支持CPU的硬件虚拟化,ARM在用户模式(USR mode)和内核模式(SVC mode)的两种CPU模式基础上新增了HYP模式(HYP mode)。和用户联系紧密的操作系统运行在非安全世界的用户模式和内核模式下,Hypervisor运行在新增的HYP模式下。HYP模式是非安全世界权限最高的一个CPU模式,当CPU工作在该模式下时,它可以访问用户模式、内核模式和HYP模式的所有硬件资源;但是当CPU运行在其他两个模式下时,它不能访问HYP相关硬件资源。因此,Hypervisor拥有比操作系统更高的权限。和非安全世界一样,右侧的安全世界同样包含用户模式和内核模式这两种CPU的工作模式。在ARMv7上,安全世界不支持硬件虚拟化,因此它不包含HYP模式,但在最新的ARMv8.4架构中,安全世界开始支持硬件虚拟化。安全世界还包含一个特殊的、权限最高的CPU模式:监控模式(Monitor mode)。监控模式是CPU权限最高的一个模式,当CPU工作在该模式下时,它不仅可以访问安全世界所有的硬件资源,还可以访问非安全世界所有的硬件资源。TrustZone可以在监控模式下,配置Hypervisor相关的控制寄存器来初始化并激活Hypervisor。监控模式也是非安全世界进 入安全世界的一个门户,在非安全世界的内核模式或者HYP模式下,执行SMC(Secure Monitor Call)指令,可以主动地从非安全世界切换到安全世界的监控模式。在监控模式下执行ERET指令,CPU通过检查SCR(Secure Control Register)寄存器的NS(non-secure)位来决定返回非安全世界还是继续停留在安全世界。当NS位置为1时,监控模式下的返回操作返回非安全世界的内核,执行世界切换(world switch)的操作;当NS位置为0时,监控模式下的返回操作返回安全世界的内核,不执行世界切换的操作。
Hypervisor作为ARM的虚拟化拓展最早是在ARMv7的版本中被引入的。如图1所示,非安全世界包含三个权限等级:PL0、PL1、PL2。Hypervisor工作在非安全世界权限等级最高的PL2。在非安全世界的内核模式执行HVC(Hypervisor Call)指令是进入Hypervisor的一种常见方式;在HYP模式下执行ERET指令返回内核模式(如图2所示)。为了支持内存虚拟化,ARM引入了第二层内存地址翻译(Stage-2translation)的内存虚拟化技术。利用该技术,常见的虚拟地址到物理地址(VA->PA)的一层内存地址翻译就转变为虚拟地址到中间物理地址IPA,再从中间物理地址到物理地址(VA->IPA->PA)的两层内存地址翻译。其中第二层内存地址翻译(IPA->PA)的这个过程是由Hypervisor完全控制的,对于操作系统来说是透明的,在操作系统看来,IPA就是它所使用的“物理地址”。通过设置第二层内存地址翻译页表项(page table descriptor)访问监控位的属性,Hypervisor可以对操作系统的内存访问进行访问控制。页表项包含读(R)、写(W)、执行(X)三个控制位。其中读、写控制位和内存的数据保护相关,执行控制位和内存代码执行相关。通过对读、写和执行三个控制位的配置,Hypervisor能够实现以页粒度监控物理内存的访问,从而保护相关敏感的信息。
在内存虚拟化的支持上,TEE侧的设计和REE侧略有不同,TEE侧Stage-2的基址寄存器有两个:vttbr_el2和vsttbr_el2,而REE侧仅仅只有一个Stage-2的基址寄存器vttbr_el2。在进行Stage-1翻译过程中,若页表项中NS bit为1,内存管理单元(memory management unit,MMU)在进行Stage-2翻译时,会选择vttbr_el2作为基址寄存器;若页表项中NS bit为0,MMU会选在vsttbr_el2作为基址寄存器进行Stage-2的翻译。这个过程是MMU自动完成的,不需要软件参与。vttbr_el2和vsttbr_el2两个寄存器设计的目的是:CPU工作在TEE侧的时候可能访问安全内存,也有可能访问非安全内存,而安全内存和非安全内存可以通过这两套Stage-2的页表来区分。通过配置,系统可以保证通过vttbr_el2指向的Stage-2页表翻译出来的物理地址落在非安全内存上;通过vsttbr_el2的页表翻译出来的物理地址落在安全内存上。在翻译过程中,MMU会对系统的配置做检查,一旦违反所采用的页表以及物理地址和内存属性之间的对应关系,翻译过程将会出错。
接下来描述本申请应用的场景。
第一场景。本申请可以应用于基于ARM架构的服务器中,ARM服务器场景中,富执行环境REE和可信执行环境TEE都支持硬件虚拟化特性,租户会在REE侧建立多个虚拟机(Virtual Machine,VM),为了给每个租户提供TEE可信执行环境的支持,VM启动时,会相应地在TEE侧启动一个安全隔离区(secure partition,SP),并在SP中启动TEEos,以支持VM中的安全业务,其架构如图3所示。在运行时,VM中的客户端应用(Client  Application,CA)会请求SP中可信应用(Trusted Application,TA)的安全服务。
第二场景。本申请还可以应用于智能终端(例如智能手机等便携式设备中),如图4所示,在智能终端的场景中,虽然REE和TEE启动多个VM/SP的需求并不强烈,但是当REE侧和TEE侧内存虚拟化特性打开后,REE侧的客户系统Guest OS(例如Android os)可以认为运行在VM中,TEE侧的TEEos可以认为运行在SP中,这样,REE和TEE的交互也可以看作是VM和SP之间的交互。
在上述两种场景中,可以采用本申请实施例提供的方法实现SP对VM的主动通知。
上述服务器以及智能终端(本申请实施例中也可以称之为计算机系统)可以包括处理器和存储器。处理器也可以称为中央处理单元(central processing unit,CPU)或中央处理器。
该计算机系统中的处理器的一种示例为精简指令系统(Advanced RISC Machines,ARM)处理器。该计算机中的存储器的示例为随机存取存储器(random access memory,RAM)或闪存(Flash)。其中,RAM也可以称为主存或者内存。存储器具有访问权限属性,例如只读、可写、可执行和不可访问。
该计算机系统的处理器中使用了虚拟化技术。虚拟化技术可以隐藏该计算机中的底层物理硬件,从而可以让多个各自独立运行的操作系统(operator system,OS)透明地使用和共享该计算机的硬件资源。简单地说,虚拟化技术可以使得该计算机能并发运行多个OS。
该计算机中的处理器为程序代码提供了不同的权限级别来访问该计算机中的资源,以保护该计算机中的数据和阻止该计算机中发生恶意行为,从而确保该计算机的安全。
例如,ARM处理器中可以定义四种异常级别(Exception levels,EL),分别为EL0、EL1、EL2和EL3。其中,数值越大的异常级别的等级越高,数值越小的异常级别的等级越低。例如,EL0的等级低于EL1的等级,EL1的等级低于EL2的等级,EL2的等级低于EL3的等级。当然,也可以是数值越大的异常级别的等级越低,数值越小的异常界别的等级越高,本申请实施例对此不作限制。
不同等级的异常级别对应不同等级的运行空间。异常级别的划分或者说运行空间的划分为处理器中所有操作状态的软件提供了逻辑分离的执行权限。应理解,本申请所说的异常级别与计算机科学中常见的等级保护域相似并且支持等级保护域中涉及的概念。
运行在这四种异常级别中每种异常级别下的软件的示例如下。普通的用户应用程序运行在EL0对应的运行空间中;操作系统内核,例如Linux或Windows,可以运行在EL1对应的运行空间中,操作系统内核通常被认为具有特权;管理程序(hypervisor)运行在EL2对应的运行空间中;低级别的固件,例如安全监视器运行在EL3对应的运行空间中。hypervisor也可以称为超级管理器。管理程序在使能状态下可以为一个或多个操作系统内核提供虚拟化服务。
固件(例如ARM可信固件(ARM Trusted firmware,ATF))是处理器启动时运行的第一个东西。固件提供很多服务,例如,平台初始化、可信任操作系统的安装以及安全监视器的命令的路由等。该计算机的处理器中,CPU执行单元可以通过内存管理单元(memory management unit,MMU)来管理或访问存储器。例如,MMU可以执行地址映射以及提供内存 访问授权等操作。
处理器中,不同异常级别对应的运行空间中运行的程序代码对存储器进行访问时,MMU进行不同的地址映射和不同的内存访问授权流程。
为了便于区分,在本申请实施例中,将REE侧的异常级别称为EL0、EL1、EL2和EL3,将TEE侧的异常级别称为SEL0、SEL1、SEL2和SEL3。
请参阅图5,本申请实施例提供了一种虚拟机与安全隔离区间的通信方法的一个实施例,该方法应用于计算机系统。
如图6所示,该计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器(Virtual Machine monitor,VMM)VMM和X个虚拟机VM,TEE部署有安全隔离区管理器安全隔离区(secure partition monitor,SPM)和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数。
VMM可以理解为虚拟监控装置,其类型可以有多种,例如,可以是图6中所示的hypervisor,下文的实施例也以VMM为hypervisor为例进行说明。VMM可以部署在宿主机操作系统内部,也可以和宿主机操作系统分开部署。VMM负责管理在其上运行的一台或多台虚拟机。
VM包括客户操作系统(Guest OS)以及多种应用(包括CA)。虚拟机VM内可以包含容器(container),容器相当于应用。在其他一些实施例中,虚拟化层由轻量级虚拟化技术实现,例如libOS。一个libOS内通常包含一个应用,整个libOS是一个或多个库,和该应用链接成一个单地址空间镜像。本申请实施例通常以传统虚拟化技术实现的虚拟机为例,其他类型的虚拟化架构可参考虚拟机的实现。
ARM在v8.4的版本中,引入了SEL2这一新的CPU工作模式,支持TEE侧的硬件虚拟化技术。基于该技术,TEE侧可以和REE侧类似地构建虚拟化环境,创建多个SP(Secure Partition),每个SP中可以运行一个TEEos以及可信应用(Enclave Application,EA),下文采用TA代替EA。
VM和SP的创建流程有多种形式,例如,REE侧每启动一个VM,TEE侧启动一个对应的SP,运行时VM和对应的SP进行交互,或者TEE侧先启动多个SP,REE再启动多个VM,运行时,VM选择其中一个SP进行交互。
在交互过程中,则可以使用本申请实施例提供的方法,使得SP可以主动通知VM。
需要说明的是,X的取值可以为1,也可以大于1;以图6为例,图6示出了一个VM(VM1)和两个SP(SP1和SP2),其中,VM1中运行CA和一个Guest OS,SP1中运行一个TEEos及EA,SP2中运行一个应用(Application,APP)和一个Guest OS。
基于上述计算机系统,该方法包括:
步骤101,第一SP将请求写入第一SP和第一VM的第一共享内存中。
其中,第一SP为X个SP中的一个,第一VM为X个VM中与第一SP对应的一个,请求用于指示第一VM执行目标操作。
需要说明的是,在第一VM和第一SP启动的过程中,会建立第一VM和第一SP之间的共享内存,该共享内存一般包含两个共享内存,一个共享内存用于SMC通信,另一个共享 内存用于中断通知;该实施例将用于中断通知的共享内存称为第一共享内存,其中,第一共享内存为物理内存。
建立共享内存的方法是较成熟的技术,本申请实施例在此不做赘述。
步骤102,第一SP触发第一虚拟中断。
第一虚拟中断用于使得SPM通过VMM通知第一VM从第一共享内存中获取请求。
第一SP触发第一虚拟中断的过程具体可以包括:第一SP对一块无访问权限的内存进行写操作,由于无访问权限,所以该写操作会导致页错误,该页操作会被SPM感知到,从而完成了第一虚拟中断的触发。
需要说明的是,在第一SP触发第一虚拟中断的同时,第一SP的标识会被写入相应地寄存器中。
步骤103,响应于Y个第一虚拟中断,SPM获取触发Y个第一虚拟中断的Y个SP的标识。
可以理解的是,步骤101和步骤102是以第一SP为例,对触发第一虚拟中断的过程进行的说明;而实际上,在X个SP中,可能存在一个触发虚拟中断的SP,也可能存在多个触发虚拟中断的SP;为此,在本申请实施例中,假设Y个SP触发了Y个第一虚拟中断,其中,Y个SP属于X个SP,Y为小于或等于X的正整数,具体地,Y可以为1,也可以为2、3等。
以第一SP为例,SPM响应第一虚拟中断的过程可以包括:首先SPM拦截第一虚拟中断(具体可以为SPM感知到第一SP的写操作导致的页错误);接着,SPM检查第一虚拟中断的合法性,在第一虚拟中断合法的情况下,SPM从寄存器中读取触发第一虚拟中断的标识(例如第一SP的标识)。
在该实施例中,SPM获取触发Y个第一虚拟中断的Y个SP的标识,这意味着,Y个第一虚拟中断都是合法的。
步骤104,SPM确定Y个SP的标识对应的Y个VM的标识。
基于前述说明可知,一个SP对应一个VM,相应地,一个SP的标识对应一个VM的标识,其中,Y个VM属于X个VM。
具体地,SPM可以基于SP的标识与VM的标识之间的对应关系,得到Y个VM的标识。
步骤105,SPM向VMM传递Y个VM的标识,以使得VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求。
其中,一个VM和一个SP对应一个第一共享内存,一个第一共享内存中存储有一个请求,请求用于指示VM执行目标操作。
SPM向VMM传递VM的标识的方法有多种,本申请实施例对此不做具体限定;例如,可以将VM的标识写入SPM和VMM的第二共享内存中,然后再通过物理中断的方式通知VMM从第二共享内存中读取VM的标识。
由于Y可以为1,也可以大于1,所以当Y大于1时,SPM可以将Y个VM的标识批量写入第二共享内存,也可以逐个将VM的标识写入第二共享内存,下文会分别对这两种写入方式进行说明。
可以理解的是,由于在传递VM的标识的过程中,需要利用第二共享内存,所以在执行步骤105前需要先建立第二共享内存,其中,第二共享内存为物理内存。
该第二共享内存可以称为VMM和SPM之间的共享内存;由于VMM位于EL2对应的运行空间中,SPM位于SEL2对应的运行空间中,所以第二共享内存也可以称为EL2和SEL2之间的共享内存。
第二共享内存的建立通常在SPM和VMM启动时,具体地,第二共享内存的建立可以包括:在SPM和VMM启动时,由EL2申请一片连续的物理内存,然后将这段连续的物理内存的地址传递给SEL2,SEL2将这段连续的物理内存的地址映射到自身的虚拟地址空间,从而完成第二共享内存的建立。
相应地,VMM获取SPM传递的Y个VM的标识。
其中,Y个VM属于X个VM,Y为小于或等于X的正整数。
需要说明的是,VMM获取VM的标识的方法与SPM向VMM传递VM的标识的方法相关;例如,VMM可以响应于物理中断,从SPM和VMM的第二共享内存中读取VM的标识。
同样地,Y可以为1,也可以大于1;当Y大于1时,VMM可以从SPM和VMM的第二共享内存中批量读取VM的标识,也可以从SPM和VMM的第二共享内存中逐个读取VM的标识。
对应VM的标识的两种传递方式,下文会分别对这两种读取方式进行说明。
步骤106,VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求。
其中,Y个SP属于X个SP,一个VM和一个SP对应一个第一共享内存,一个第一共享内存中存储有一个请求,请求用于指示VM执行目标操作。
VMM通知VM的标识指示的VM的方法有多种,本申请实施例对此不做具体限定。
例如,以第一VM的标识为例,VMM可以将第二虚拟中断注入到第一VM的标识指示的第一VM中,以使得第一VM响应于第二虚拟中断,从第一VM和第一SP的第一共享内存中获取请求。
其中,第二虚拟中断和第一虚拟中断类似,具体可参阅第一虚拟中断的相关说明对第二虚拟中断进行理解;注入第二虚拟中断的方法为较成熟的技术,本申请实施例在此不做详述。
基于前文可知,VMM可以从SPM和VMM的第二共享内存中逐个读取VM的标识,VMM可以从SPM和VMM的第二共享内存中批量读取VM的标识,对应上述两种读取VM的标识的方式,可以通过两种方法通知Y个VM的标识指示的Y个VM,下文会分别对这两种通知方法进行说明。
步骤107,响应于第二虚拟中断,第一VM从第一VM和第一SP的第一共享内存中获取请求,请求用于指示第一VM执行目标操作,第一VM为X个VM中的一个,第一SP为X个SP中与第一VM对应的一个。
步骤108,第一VM执行目标操作。
基于上述实施例可知,在X个SP中,可能存在一个SP将一个请求写入第一共享内存中并触发第一虚拟中断,也可能存在多个SP将多个请求写入多个第一共享内存中并触发多 个第一虚拟中断;当存在多个SP将多个请求写入多个第一共享内存中并触发多个第一虚拟中断时,SPM可以一次处理多个请求,也可以一次处理一个请求。
下面分别以两个实施例对SPM一次处理多个请求的过程以及一次处理一个请求的过程进行说明。
在第一实施例中,SPM一次处理一个请求。
具体地,以两个请求为例,相应地,SPM则会拦截到两个第一虚拟中断并得到两个VM的标识;此后,SPM先将一个VM的标识写入第二共享内存,然后由VMM读取该VM的标识并基于该VM的标识完成第二虚拟中断的注入;然后SPM再将另一个VM的标识写入第二共享内存,然后由VMM读取该VM的标识并基于该VM的标识完成第二虚拟中断的注入。
具体地,作为一种可实现的方式,Y大于1,Y个VM的标识包括第一标识和第二标识。
具体地,如图7所示,该实施例包括:
步骤201,SPM将第一标识写入SPM和VMM的第二共享内存中。
其中,第二共享内存可参阅前文的相关说明进行理解。
步骤202,SPM触发第一物理中断。
第一物理中断用于使得VMM在第一中央处理CPU的控制下,从第二共享内存中获取第一标识,并通知第一标识指示的VM从第一标识指示的VM和第三标识指示的SP的第一共享内存中获取请求,第三标识为Y个SP的标识中的一个且与第一标识对应,第一CPU用于运行第一标识指示的VM。
步骤202可以具体包括:SPM通过设置具体的挂起pending位来实现第一物理中断的触发。
需要说明的是,在计算机系统具备多个物理CPU的情况下,若SPM触发物理中断,则会由其中一个物理CPU来处理该物理中断;而在该实施例中,为了实现第一物理中断能够由第一CPU处理,可以将与第一物理中断相关的内容写入与第一CPU关联的寄存器中,这样,就只能由第一CPU来处理第一物理中断。
步骤203,响应于第一物理中断,VMM在第一CPU的控制下从SPM和VMM的第二共享内存中获取第一标识,第一CPU用于运行第一标识指示的VM。
其中,响应于第一物理中断的过程可以包括:VMM获取第一物理中断的中断号,在第一物理中断的中断号是SP通知VM的中断号(预先设置的)的情况下,VMM从第二共享内存中获取第一标识。
步骤204,VMM在第一CPU的控制下将第二虚拟中断注入第一标识指示的VM中。
注入第一标识指示的VM中的第二虚拟中断用于使得,第一标识指示的VM从第一标识指示的VM和第三标识指示的SP的第一共享内中获取请求,第三标识为Y个SP的标识中的一个且与第一标识对应。
需要说明的是,通过步骤201至步骤204实现了第一个请求的处理,使得第一标识指示的VM可以获取请求。
步骤205,SPM将第二标识写入SPM和VMM的第二共享内存中。
需要说明的是,SPM将第一标识和第二标识分开写入第二共享内存的原因在于,若第 一标识和第二标识同时存在第二共享内存中,那会导致在第一CPU控制下的VMM错误地获取到第二标识;所以,SPM将第一标识和第二标识分开写入第二共享内存。
基于上述说明可知,将第一标识和第二标识分开写入第二共享内存是为了避免造成混淆,因此,步骤205的执行只要位于步骤203之后即可,即只要在VMM从第二共享内存中获取到第一标识之后执行步骤205即可;步骤205的执行可以在步骤204之前,也可以在步骤204之后。
步骤206,SPM触发第二物理中断。
第二物理中断用于使得VMM在第二CPU的控制下,从第二共享内存中获取第二标识,并通知第二标识指示的VM从第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,第四标识为Y个SP的标识中的一个且与第二标识对应,第二CPU用于运行第二标识指示的VM。
步骤207,响应于第二物理中断,VMM在第二CPU的控制下从SPM和VMM的第二共享内存中获取第二标识,第二CPU用于运行第二标识指示的VM。
步骤208,VMM在第二CPU的控制下将第二虚拟中断注入第二标识指示的VM中;
注入第二标识指示的VM中的第二虚拟中断用于使得,第二标识指示的VM从第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,第四标识为Y个SP的标识中的一个且与二标识对应。
需要说明的是,步骤205至步骤208与步骤201至步骤204类似,具体可参阅步骤201至步骤204的相关说明进行理解;其中,不同的是,在执行步骤205至步骤208的过程中,由第二CPU处理第二物理中断。
另外,步骤201、步骤202、步骤205和步骤206组成了步骤105,步骤203和步骤207介绍了VMM获取Y个VM的标识的具体过程,步骤204和步骤208组成了步骤106。
在第二实施例中,SPM一次处理多个请求。
具体地,SPM一次性将Y个VM的标识都写入SPM和VMM的第二共享内存中,然后由VMM读取Y个VM的标识并完成Y个第二虚拟中断的注入。
具体地,作为一种可实现的方式,如图8所示,该实施例包括:
步骤301,SPM将Y个VM的标识写入SPM和VMM的第二共享内存中。
步骤302,SPM触发第三物理中断,第三物理中断用于使得VMM在第三CPU的控制下,从第二共享内存中获取Y个VM的标识,并通知Y个VM的标识指示的Y个VM从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求。
步骤303,响应于第三物理中断,VMM在第三CPU的控制下从SPM和VMM的第二共享内存中获取Y个VM的标识。
步骤304,VMM将Y个第二虚拟中断注入Y个VM的标识指示的Y个VM中,一个第二虚拟中断对应一个VM,且第二虚拟中断用于使得VM从VM和SP的第一共享内存中获取请求。
在该实施例,无论Y为1还是Y大于1,SPM都只触发一个物理中断(即第三物理中断),处理该第三物理中断的CPU也只有第三CPU;由于只有第三CPU处理第三物理中断,因此即使存在多个VM的标识,也不需要分开写入第二共享内存。
其中,第三CPU可以是计算机系统中多个物理CPU中的任意一个。
除此上述内容外,步骤301至步骤304与步骤201至步骤204类似,具体可参阅步骤201至步骤204的相关说明对步骤301至步骤304进行理解。
在该实施例中,步骤301和步骤302组成了步骤105,步骤303相当于步骤105,步骤304相当于步骤106。
需要说明的是,若VMM要将第二虚拟中断注入到一个VM中,那么VMM需要运行在用于运行该VM的CPU下;若VMM未运行在用于运行该VM的CPU下,则需要通过核间通信以实现CPU的切换。
在步骤304中,VMM需要将Y个第二虚拟中断注入Y个VM的标识指示的Y个VM中,而VMM当前运行在第三CPU中,所以若Y个VM都可以运行在第三CPU下,那么则不需要进行CPU的切换,可以由第三CPU完成所有第二虚拟中断的注入;若Y个VM中存在无法运行在第三CPU下的VM,那么则需要进行CPU的切换,下面对这种情况进行介绍。
作为一种可实现的方式,Y大于1,Y个VM的标识包括第五标识和第六标识。
如图9所示,步骤304包括:
步骤401,VMM在第三CPU的控制下将一个第二虚拟中断注入第五标识指示的VM中,第三CPU用于运行第五标识指示的VM;
注入第五标识指示的VM中的第二虚拟中断用于使得,第五标识指示的VM从第五标识指示的VM和第七标识指示的SP的第一共享内存中获取请求,第七标识为Y个SP的标识中的一个且与第五标识对应;
步骤402,VMM在第三CPU的控制下从第三CPU切换到第四CPU,第四CPU用于运行第六标识指示的VM。
具体地,可以通过核间通信实现从第三CPU到第四CPU的切换。
步骤403,VMM在第四CPU的控制下将另一个第二虚拟中断注入第六标识指示的VM中;
注入第六标识指示的VM中的第二虚拟中断用于使得,第六标识指示的VM从第六标识指示的VM和第八标识指示的SP的第一共享内存中获取请求,第八标识为Y个SP的标识中的一个且与六标识对应。
对比第一实施例和第二实施例可知,若SPM一次处理一个请求,则不需要进行CPU的切换;SPM一次处理多个请求,效率更好,并发性更好,但可能需要进行CPU的切换。
为了便于理解,下面通过一具体示例对SP主动通知VM的过程进行介绍。
如图10所示,该示例是对SP1主动通知VM1的过程的具体说明。
首先,如图10中的路径1所示,SP1向SP1和VM1的共享内存SPI_el1share memory中写入请求,然后触发第一虚拟中断。
如图10中的路径2所示,SPM响应于该第一虚拟中断,获取SP1的标识,并通过SP1的标识和VM1的标识间的对应关系得到VM1的标识;然后SPM将VM1的标识保存到自己的内存中,图10将该内存称为SPI send queue。
接着,如图10中的路径3所示,SPM将VM1的标识写入SPM和VMM的共享内存SPI_el2share memory中,并触发物理中断。
如图10中的路径4所示,响应于该物理中断,VMM(即图10中的hypervisor)从共享内存SPI_el2 share memory中读取VM1的标识,并将VM1的标识保存至自己的内存中,图10将该内存称为SPI recv queue。
此后,如图10中的路径5所示,VMM将第二虚拟中断注入VM1中,使得VM1从共享内存SPI_el1 share memory中读取请求的内容,并执行相应的操作。
本申请实施例还提供了一种计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数;第一SP用于:将请求写入第一SP和第一VM的第一共享内存中,第一SP为X个SP中的一个,第一VM为X个VM中与第一SP对应的一个,请求用于指示第一VM执行目标操作;触发第一虚拟中断,第一虚拟中断用于使得SPM通过VMM通知第一VM从第一共享内存中获取请求。
本申请实施例还提供了一种计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数;SPM用于:响应于Y个第一虚拟中断,获取触发Y个第一虚拟中断的Y个SP的标识,其中,Y个SP属于X个SP,Y为小于或等于X的正整数;确定Y个SP的标识对应的Y个VM的标识,一个SP的标识对应一个VM的标识,其中,Y个VM属于X个VM;向VMM传递Y个VM的标识,以使得VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求,其中,一个VM和一个SP对应一个第一共享内存,一个第一共享内存中存储有一个请求,请求用于指示VM执行目标操作。
作为一种可实现的方式,Y个VM的标识包括第一标识和第二标识;SPM用于,向VMM传递Y个VM的标识,以使得VMM通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求包括:将第一标识写入SPM和VMM的第二共享内存中;触发第一物理中断,第一物理中断用于使得VMM在第一中央处理CPU的控制下,从第二共享内存中获取第一标识,并通知第一标识指示的VM从第一标识指示的VM和第三标识指示的SP的第一共享内存中获取请求,第三标识为Y个SP的标识中的一个且与第一标识对应,第一CPU用于运行第一标识指示的VM;将第二标识写入SPM和VMM的第二共享内存中;触发第二物理中断,第二物理中断用于使得VMM在第二CPU的控制下,从第二共享内存中获取第二标识,并通知第二标识指示的VM从第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,第四标识为Y个SP的标识中的一个且与第二标识对应,第二CPU用于运行第二标识指示的VM。
作为一种可实现的方式,SPM用于将Y个VM的标识写入SPM和VMM的第二共享内存中;触发第三物理中断,第三物理中断用于使得VMM在第三CPU的控制下,从第二共享内存中获取Y个VM的标识,并通知Y个VM的标识指示的Y个VM从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求。
作为一种可实现的方式,SPM用于,与VMM建立第二共享内存。
本申请实施例还提供了一种计算机系统,计算机系统上部署有富执行环境REE和可信 执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数;VMM用于,获取SPM传递的Y个VM的标识,其中,Y个VM属于X个VM,Y为小于或等于X的正整数;通知Y个VM的标识指示的Y个VM,从Y个VM和Y个SP的Y个第一共享内存中获取Y个请求,其中,Y个SP属于X个SP,一个VM和一个SP对应一个第一共享内存,一个第一共享内存中存储有一个请求,请求用于指示VM执行目标操作。
作为一种可实现的方式,Y大于1,Y个VM的标识包括第一标识和第二标识;VMM用于响应于第一物理中断,在第一CPU的控制下从SPM和VMM的第二共享内存中获取第一标识,第一CPU用于运行第一标识指示的VM;响应于第二物理中断,在第二CPU的控制下从SPM和VMM的第二共享内存中获取第二标识,第二CPU用于运行第二标识指示的VM。
作为一种可实现的方式,VMM用于,在第一CPU的控制下将第二虚拟中断注入第一标识指示的VM中;在第二CPU的控制下将第二虚拟中断注入第二标识指示的VM中;注入第一标识指示的VM中的第二虚拟中断用于使得,第一标识指示的VM从第一标识指示的VM和第三标识指示的SP的第一共享内存中获取请求,第三标识为Y个SP的标识中的一个且与第一标识对应;注入第二标识指示的VM中的第二虚拟中断用于使得,第二标识指示的VM从第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,第四标识为Y个SP的标识中的一个且与二标识对应。
作为一种可实现的方式,VMM用于响应于第三物理中断,在第三CPU的控制下从SPM和VMM的第二共享内存中获取Y个VM的标识。
作为一种可实现的方式,VMM用于将Y个第二虚拟中断注入Y个VM的标识指示的Y个VM中,一个第二虚拟中断对应一个VM,且第二虚拟中断用于使得VM从VM和SP的第一共享内存中获取请求。
作为一种可实现的方式,Y大于1,Y个VM的标识包括第五标识和第六标识;VMM用于,在第三CPU的控制下将一个第二虚拟中断注入第五标识指示的VM中,第三CPU用于运行第五标识指示的VM;在第三CPU的控制下从第三CPU切换到第四CPU,第四CPU用于运行第六标识指示的VM;在第四CPU的控制下将另一个第二虚拟中断注入第六标识指示的VM中;
注入第五标识指示的VM中的第二虚拟中断用于使得,第五标识指示的VM从第五标识指示的VM和第七标识指示的SP的第一共享内存中获取请求,第七标识为Y个SP的标识中的一个且与第五标识对应;
注入第六标识指示的VM中的第二虚拟中断用于使得,第六标识指示的VM从第六标识指示的VM和第八标识指示的SP的第一共享内存中获取请求,第八标识为Y个SP的标识中的一个且与六标识对应。
本申请实施例还提供了一种计算机系统,计算机系统上部署有富执行环境REE和可信执行环境TEE,REE部署有虚拟机管理器VMM和X个虚拟机VM,TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个SP对应对一个VM,其中,X为正整数,方法包括:第一VM用于:响应于第二虚拟中断,从第一VM和第一SP的第一共享内存中获取请求,请求用于指示第一VM执行目标操作,第一VM为X个VM中的一个,第一SP为X个SP中与第一 VM对应的一个;执行目标操作。
本实施例中计算机系统的相关描述可以参照上述实施例中图1至图10以及相关实施例的描述,这里不再赘述。
本申请还提供了一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质包含计算机指令,当计算机指令被计算机执行时可以实现上述实施例中的中断处理方法。
请参考图11,为本实施例提供的一种计算机系统的结构示意图。该计算机系统可以为终端设备(或者称之为智能终端)或者服务器。如图所示,该计算机系统包括通信模块810、传感器820、用户输入模块830、输出模块840、处理器850、音视频输入模块860、存储器870以及电源880。
通信模块810可以包括至少一个能使该计算机系统与通信系统或其他计算机系统之间进行通信的模块。例如,通信模块810可以包括有线网络接口,广播接收模块、移动通信模块、无线因特网模块、局域通信模块和位置(或定位)信息模块等其中的一个或多个。这多种模块均在现有技术中有多种实现,本申请不一一描述。
传感器820可以感测系统的当前状态,诸如打开/闭合状态、位置、与用户是否有接触、方向、和加速/减速,并且传感器820可以生成用于控制系统的操作的感测信号。
用户输入模块830,用于接收输入的数字信息、字符信息或接触式触摸操作/非接触式手势,以及接收与系统的用户设置以及功能控制有关的信号输入等。用户输入模块830包括触控面板和/或其他输入设备。
输出模块840包括显示面板,用于显示由用户输入的信息、提供给用户的信息或系统的各种菜单界面等。可选的,可以采用液晶显示器(liquid crystal display,LCD)或有机发光二极管(organic light-emitting diode,OLED)等形式来配置显示面板。在其他一些实施例中,触控面板可覆盖显示面板上,形成触摸显示屏。另外,输出模块840还可以包括音频输出模块、告警器以及触觉模块等。
音视频输入模块860,用于输入音频信号或视频信号。音视频输入模块860可以包括摄像头和麦克风。
电源880可以在处理器850的控制下接收外部电力和内部电力,并且提供系统的各个组件的操作所需的电力。
处理器850包括一个或多个处理器,例如,处理器850可以包括一个中央处理器和一个图形处理器。中央处理器在本申请中具有多个核,属于多核处理器。这多个核可以集成在同一块芯片上,也可以各自为独立的芯片。
存储器870存储计算机程序,该计算机程序包括操作系统程序872和应用程序871等。典型的操作系统如微软公司的Windows,苹果公司的MacOS等用于台式机或笔记本的系统,又如谷歌公司开发的基于的安卓系统等用于移动终端的系统。前述实施例提供的方法可以通过软件的方式实现,可以认为是操作系统程序872的具体实现。存储器870可以是以下类型中的一种或多种:闪速(flash)存储器、硬盘类型存储器、微型多媒体卡型存储器、卡式存储器(例如SD或XD存储器)、随机存取存储器(random access memory,RAM)、静态随机存取存储器(static RAM,SRAM)、只读存储器(read only memory,ROM)、电可擦除可编 程只读存储器(electrically erasable programmable readonly memory,EEPROM)、可编程只读存储器(programmable ROM,PROM)、回滚保护存储块(replay protected memory block,RPMB)、磁存储器、磁盘或光盘。在其他一些实施例中,存储器870也可以是因特网上的网络存储设备,系统可以对在因特网上的存储器870执行更新或读取等操作。
处理器850用于读取存储器870中的计算机程序,然后执行计算机程序定义的方法,例如处理器850读取操作系统程序872从而在该系统运行操作系统以及实现操作系统的各种功能,或读取一种或多种应用程序871,从而在该系统上运行应用。
存储器870还存储有除计算机程序之外的其他数据873。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。

Claims (19)

  1. 一种虚拟机与安全隔离区间的通信方法,其特征在于,所述方法应用于计算机系统,所述计算机系统上部署有富执行环境REE和可信执行环境TEE,所述REE部署有虚拟机管理器VMM和X个虚拟机VM,所述TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个所述SP对应对一个所述VM,其中,X为正整数,所述方法包括:
    第一SP将请求写入所述第一SP和第一VM的第一共享内存中,所述第一SP为所述X个SP中的一个,所述第一VM为所述X个VM中与所述第一SP对应的一个,所述请求用于指示所述第一VM执行目标操作;
    所述第一SP触发第一虚拟中断,所述第一虚拟中断用于使得所述SPM通过所述VMM通知所述第一VM从所述第一共享内存中获取所述请求。
  2. 一种虚拟机与安全隔离区间的通信方法,其特征在于,所述方法应用于计算机系统,所述计算机系统上部署有富执行环境REE和可信执行环境TEE,所述REE部署有虚拟机管理器VMM和X个虚拟机VM,所述TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个所述SP对应对一个所述VM,其中,X为正整数,所述方法包括:
    响应于Y个第一虚拟中断,所述SPM获取触发所述Y个第一虚拟中断的Y个SP的标识,其中,所述Y个SP属于所述X个SP,Y为小于或等于X的正整数;
    所述SPM确定所述Y个SP的标识对应的Y个VM的标识,一个所述SP的标识对应一个所述VM的标识,其中,所述Y个VM属于所述X个VM;
    所述SPM向所述VMM传递所述Y个VM的标识,以使得所述VMM通知所述Y个VM的标识指示的所述Y个VM,从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求,其中,一个所述VM和一个所述SP对应一个所述第一共享内存,一个所述第一共享内存中存储有一个所述请求,所述请求用于指示所述VM执行目标操作。
  3. 根据权利要求2所述的方法,其特征在于,Y大于1,所述Y个VM的标识包括第一标识和第二标识;
    所述SPM向所述VMM传递所述Y个VM的标识,以使得所述VMM通知所述Y个VM的标识指示的所述Y个VM,从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求包括:
    所述SPM将所述第一标识写入所述SPM和所述VMM的第二共享内存中;
    所述SPM触发第一物理中断,所述第一物理中断用于使得所述VMM在第一中央处理CPU的控制下,从所述第二共享内存中获取所述第一标识,并通知所述第一标识指示的VM从所述第一标识指示的VM和第三标识指示的SP的第一共享内存中获取请求,所述第三标识为所述Y个SP的标识中的一个且与所述第一标识对应,所述第一CPU用于运行所述第一标识指示的VM;
    所述SPM将所述第二标识写入所述SPM和所述VMM的第二共享内存中;
    所述SPM触发第二物理中断,所述第二物理中断用于使得所述VMM在第二CPU的控制 下,从所述第二共享内存中获取所述第二标识,并通知所述第二标识指示的VM从所述第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,所述第四标识为所述Y个SP的标识中的一个且与所述第二标识对应,所述第二CPU用于运行所述第二标识指示的VM。
  4. 根据权利要求2所述的方法,其特征在于,所述SPM向所述VMM传递所述Y个VM的标识,以使得所述VMM通知所述Y个VM的标识指示的所述Y个VM,从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求包括:
    所述SPM将所述Y个VM的标识写入所述SPM和所述VMM的第二共享内存中;
    所述SPM触发第三物理中断,所述第三物理中断用于使得所述VMM在第三CPU的控制下,从所述第二共享内存中获取所述Y个VM的标识,并通知所述Y个VM的标识指示的所述Y个VM从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求。
  5. 根据权利要求3或4所述的方法,其特征在于,在所述SPM向所述VMM传递所述Y个VM的标识,以使得所述VMM通知所述Y个VM的标识指示的所述Y个VM,从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求之前,所述方法还包括:
    所述SPM与所述VMM建立所述第二共享内存。
  6. 一种虚拟机与安全隔离区间的通信方法,其特征在于,所述方法应用于计算机系统,所述计算机系统上部署有富执行环境REE和可信执行环境TEE,所述REE部署有虚拟机管理器VMM和X个虚拟机VM,所述TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个所述SP对应对一个所述VM,其中,X为正整数,所述方法包括:
    所述VMM获取所述SPM传递的Y个VM的标识,其中,所述Y个VM属于所述X个VM,Y为小于或等于X的正整数;
    所述VMM通知所述Y个VM的标识指示的所述Y个VM,从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求,其中,所述Y个SP属于所述X个SP,一个所述VM和一个所述SP对应一个所述第一共享内存,一个所述第一共享内存中存储有一个所述请求,所述请求用于指示所述VM执行目标操作。
  7. 根据权利要求6所述的方法,其特征在于,Y大于1,所述Y个VM的标识包括第一标识和第二标识;
    所述VMM获取所述SPM传递的Y个VM的标识包括:
    响应于第一物理中断,所述VMM在第一CPU的控制下从所述SPM和所述VMM的第二共享内存中获取所述第一标识,所述第一CPU用于运行所述第一标识指示的VM;
    响应于第二物理中断,所述VMM在第二CPU的控制下从所述SPM和所述VMM的第二共享内存中获取所述第二标识,所述第二CPU用于运行所述第二标识指示的VM。
  8. 根据权利要求7所述的方法,其特征在于,所述VMM通知所述Y个VM的标识指示的所述Y个VM,从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求包括:
    所述VMM在所述第一CPU的控制下将第二虚拟中断注入所述第一标识指示的VM中;
    所述VMM在所述第二CPU的控制下将第二虚拟中断注入所述第二标识指示的VM中;
    注入所述第一标识指示的VM中的所述第二虚拟中断用于使得,所述第一标识指示的VM从所述第一标识指示的VM和第三标识指示的SP的第一共享内存中获取请求,所述第三标识为所述Y个SP的标识中的一个且与所述第一标识对应;
    注入所述第二标识指示的VM中的所述第二虚拟中断用于使得,所述第二标识指示的VM从所述第二标识指示的VM和第四标识指示的SP的第一共享内存中获取请求,所述第四标识为所述Y个SP的标识中的一个且与所述二标识对应。
  9. 根据权利要求6所述的方法,其特征在于,所述VMM获取所述SPM传递的Y个VM的标识包括:
    响应于第三物理中断,所述VMM在所述第三CPU的控制下从所述SPM和所述VMM的第二共享内存中获取Y个VM的标识。
  10. 根据权利要求9所述的方法,其特征在于,所述VMM通知所述Y个VM的标识指示的所述Y个VM,从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求包括:
    所述VMM将Y个第二虚拟中断注入所述Y个VM的标识指示的所述Y个VM中,一个所述第二虚拟中断对应一个所述VM,且所述第二虚拟中断用于使得所述VM从所述VM和所述SP的第一共享内存中获取请求。
  11. 根据权利要求10所述的方法,其特征在于,Y大于1,所述Y个VM的标识包括第五标识和第六标识;
    所述VMM将Y个第二虚拟中断注入所述Y个VM的标识指示的所述Y个VM中包括:
    所述VMM在所述第三CPU的控制下将一个第二虚拟中断注入所述第五标识指示的VM中,所述第三CPU用于运行所述第五标识指示的VM;
    所述VMM在所述第三CPU的控制下从所述第三CPU切换到第四CPU,所述第四CPU用于运行所述第六标识指示的VM;
    所述VMM在所述第四CPU的控制下将另一个第二虚拟中断注入所述第六标识指示的VM中;
    注入所述第五标识指示的VM中的所述第二虚拟中断用于使得,所述第五标识指示的VM从所述第五标识指示的VM和第七标识指示的SP的第一共享内存中获取请求,所述第七标识为所述Y个SP的标识中的一个且与所述第五标识对应;
    注入所述第六标识指示的VM中的所述第二虚拟中断用于使得,所述第六标识指示的VM从所述第六标识指示的VM和第八标识指示的SP的第一共享内存中获取请求,所述第八标识为所述Y个SP的标识中的一个且与所述六标识对应。
  12. 一种虚拟机与安全隔离区间的通信方法,其特征在于,所述方法应用于计算机系统,所述计算机系统上部署有富执行环境REE和可信执行环境TEE,所述REE部署有虚拟机管理器VMM和X个虚拟机VM,所述TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个所述SP对应对一个所述VM,其中,X为正整数,所述方法包括:
    响应于第二虚拟中断,第一VM从所述第一VM和第一SP的第一共享内存中获取请求,所述请求用于指示所述第一VM执行目标操作,所述第一VM为所述X个VM中的一个,所述第一SP为所述X个SP中与所述第一VM对应的一个;
    所述第一VM执行所述目标操作。
  13. 一种计算机系统,其特征在于,所述计算机系统上部署有富执行环境REE和可信执行环境TEE,所述REE部署有虚拟机管理器VMM和X个虚拟机VM,所述TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个所述SP对应对一个所述VM,其中,X为正整数;
    第一SP用于:将请求写入所述第一SP和第一VM的第一共享内存中,所述第一SP为所述X个SP中的一个,所述第一VM为所述X个VM中与所述第一SP对应的一个,所述请求用于指示所述第一VM执行目标操作;
    触发第一虚拟中断,所述第一虚拟中断用于使得所述SPM通过所述VMM通知所述第一VM从所述第一共享内存中获取所述请求。
  14. 一种计算机系统,其特征在于,所述计算机系统上部署有富执行环境REE和可信执行环境TEE,所述REE部署有虚拟机管理器VMM和X个虚拟机VM,所述TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个所述SP对应对一个所述VM,其中,X为正整数;
    所述SPM用于:响应于Y个第一虚拟中断,获取触发所述Y个第一虚拟中断的Y个SP的标识,其中,所述Y个SP属于所述X个SP,Y为小于或等于X的正整数;
    确定所述Y个SP的标识对应的Y个VM的标识,一个所述SP的标识对应一个所述VM的标识,其中,所述Y个VM属于所述X个VM;
    向所述VMM传递所述Y个VM的标识,以使得所述VMM通知所述Y个VM的标识指示的所述Y个VM,从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求,其中,一个所述VM和一个所述SP对应一个所述第一共享内存,一个所述第一共享内存中存储有一个所述请求,所述请求用于指示所述VM执行目标操作。
  15. 一种计算机系统,其特征在于,所述计算机系统上部署有富执行环境REE和可信执行环境TEE,所述REE部署有虚拟机管理器VMM和X个虚拟机VM,所述TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个所述SP对应对一个所述VM,其中,X为正整数;
    所述VMM用于,获取所述SPM传递的Y个VM的标识,其中,所述Y个VM属于所述X个VM,Y为小于或等于X的正整数;
    通知所述Y个VM的标识指示的所述Y个VM,从所述Y个VM和所述Y个SP的Y个第一共享内存中获取Y个请求,其中,所述Y个SP属于所述X个SP,一个所述VM和一个所述SP对应一个所述第一共享内存,一个所述第一共享内存中存储有一个所述请求,所述请求用于指示所述VM执行目标操作。
  16. 一种计算机系统,其特征在于,所述计算机系统上部署有富执行环境REE和可信执行环境TEE,所述REE部署有虚拟机管理器VMM和X个虚拟机VM,所述TEE部署有安全隔离区管理器SPM和X个安全隔离区SP,一个所述SP对应对一个所述VM,其中,X为正整数,所述方法包括:
    第一VM用于:响应于第二虚拟中断,从所述第一VM和第一SP的第一共享内存中获取请求,所述请求用于指示所述第一VM执行目标操作,所述第一VM为所述X个VM中的一个,所述第一SP为所述X个SP中与所述第一VM对应的一个;
    执行所述目标操作。
  17. 一种计算机系统,其特征在于,包括存储器和处理器,其中,
    所述存储器用于存储计算机可读指令;所述处理器用于读取所述计算机可读指令并实现如权利要求1-12任意一项所述的方法。
  18. 一种计算机存储介质,其特征在于,存储有计算机可读指令,且所述计算机可读指令在被处理器执行时实现如权利要求1-12任意一项所述的方法。
  19. 一种计算机程序产品,其特征在于,所述计算机程序产品中包含计算机可读指令,当该计算机可读指令被处理器执行时实现如权利要求1-12任意一项所述的方法。
PCT/CN2022/100659 2021-06-23 2022-06-23 一种虚拟机与安全隔离区间的通信方法及相关装置 WO2022268150A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110700462.4 2021-06-23
CN202110700462.4A CN115509677A (zh) 2021-06-23 2021-06-23 一种虚拟机与安全隔离区间的通信方法及相关装置

Publications (1)

Publication Number Publication Date
WO2022268150A1 true WO2022268150A1 (zh) 2022-12-29

Family

ID=84499795

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/100659 WO2022268150A1 (zh) 2021-06-23 2022-06-23 一种虚拟机与安全隔离区间的通信方法及相关装置

Country Status (2)

Country Link
CN (1) CN115509677A (zh)
WO (1) WO2022268150A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117009108A (zh) * 2023-02-24 2023-11-07 荣耀终端有限公司 消息处理方法、设备及存储介质

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114490450A (zh) * 2020-11-12 2022-05-13 华为技术有限公司 一种地址转换关系的配置方法及计算机系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130031374A1 (en) * 2011-07-29 2013-01-31 Microsoft Corporation Firmware-based trusted platform module for arm processor architectures and trustzone security extensions
CN106547618A (zh) * 2016-10-19 2017-03-29 沈阳微可信科技有限公司 通信系统和电子设备
CN108959916A (zh) * 2017-05-22 2018-12-07 华为技术有限公司 用于访问安全世界的方法、装置和系统
CN109960582A (zh) * 2018-06-19 2019-07-02 华为技术有限公司 在tee侧实现多核并行的方法、装置及系统
CN111859395A (zh) * 2020-07-21 2020-10-30 中国人民解放军国防科技大学 具备tee扩展的计算平台上的通信优化方法及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130031374A1 (en) * 2011-07-29 2013-01-31 Microsoft Corporation Firmware-based trusted platform module for arm processor architectures and trustzone security extensions
CN106547618A (zh) * 2016-10-19 2017-03-29 沈阳微可信科技有限公司 通信系统和电子设备
CN108959916A (zh) * 2017-05-22 2018-12-07 华为技术有限公司 用于访问安全世界的方法、装置和系统
CN109960582A (zh) * 2018-06-19 2019-07-02 华为技术有限公司 在tee侧实现多核并行的方法、装置及系统
CN111859395A (zh) * 2020-07-21 2020-10-30 中国人民解放军国防科技大学 具备tee扩展的计算平台上的通信优化方法及系统

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117009108A (zh) * 2023-02-24 2023-11-07 荣耀终端有限公司 消息处理方法、设备及存储介质

Also Published As

Publication number Publication date
CN115509677A (zh) 2022-12-23

Similar Documents

Publication Publication Date Title
US9898601B2 (en) Allocation of shared system resources
US8832352B2 (en) Hypervisor-driven protection of data from virtual machine clones
CN108475217B (zh) 用于审计虚拟机的系统及方法
US10176007B2 (en) Guest code emulation by virtual machine function
US7421533B2 (en) Method to manage memory in a platform with virtual machines
US10075296B2 (en) Loading and virtualizing cryptographic keys
US9189609B1 (en) Securing virtual machines with virtual volumes
WO2022268150A1 (zh) 一种虚拟机与安全隔离区间的通信方法及相关装置
US8775715B2 (en) Protection of data from virtual machine clones via paravirtualization
EP3047419B1 (en) Virtual secure mode for virtual machines
US10067777B2 (en) Supporting multiple operating system environments in computing device without contents conversion
US20180203730A1 (en) Synchronous user space function execution from a kernel context
US10255088B2 (en) Modification of write-protected memory using code patching
KR101920980B1 (ko) 멀티-운영 체제 디바이스들에 대한 액세스 격리
US7840964B2 (en) Mechanism to transition control between components in a virtual machine environment
US11163597B2 (en) Persistent guest and software-defined storage in computing fabric
TWI734379B (zh) 用於使用初始程式載入機制啟動安全客體之電腦實施方法、電腦系統及電腦程式產品
US9910690B2 (en) PCI slot hot-addition deferral for multi-function devices
US10545783B2 (en) Technologies for securing data structures for controlling virtual machines
CN114625484B (zh) 虚拟化实现方法、装置、电子设备、介质及arm平台
US20230281135A1 (en) Method for configuring address translation relationship, and computer system
Vahidi et al. VETE: Virtualizing the Trusted Execution Environment
US9558364B2 (en) Computing machine, access management method, and access management program
US10127064B2 (en) Read-only VM function chaining for secure hypervisor access
CN116881987A (zh) Pcie设备直通虚拟机的方法、装置及相关设备

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: 22827642

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22827642

Country of ref document: EP

Kind code of ref document: A1