Memory management method and device applied to virtual machine platform
By static memory allocation on the embedded multi-operating system virtual machine platform, the complex and security vulnerabilities of memory dynamic management are solved, and the security and isolation reliability of memory access are improved.
Patent Information
- Application Number
- CN202411340431.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-02-07
AI Technical Summary
In embedded multi-operating system virtual machine platforms, memory dynamic management is complex, security vulnerabilities are prone to occur, and the memory isolation reliability of the virtual machine platform is low.
By determining the hardware memory resources and memory configuration parameters of the hardware terminal device, static memory allocation is performed to ensure that each operating system allocates its required target memory resources, including private memory resources and shared memory resources.
It improves the security of memory access on the virtual machine platform and the isolation reliability of memory space, and reduces possible security vulnerabilities in the dynamic memory management process.
Smart Images

Figure CN119396520A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer virtualization, and in particular to a memory management method and device applied to a virtual machine platform. Background Art
[0002] In computer systems, memory management is one of the core functions of the system, especially virtual memory management, which allows the operating system to transcend the limitations of physical memory and provide continuous and large virtual memory space for applications. Virtual memory management is a memory management technology implemented between computer hardware and software, which maps the memory address (virtual address) used by the program to the physical address in the computer memory, allowing the program to use more memory space than the physical memory. The basic principle of virtual memory management is to expand the physical memory to a part of the hard disk space, mainly relying on paging or segmentation mechanism, among which paging is the most common method. The paging mechanism divides the physical memory and virtual memory into fixed-size units, called "pages". When the program needs to access memory, the operating system converts the virtual address to the physical address. If the required page is not in the physical memory, the operating system will call the required page from the swap space of the hard disk. Only when the page is actually accessed will it be loaded into the physical memory, thereby reducing memory waste.
[0003] Practice has found that in some embedded multi-operating system virtual machine platforms such as industrial SoC (System on Chip) and automotive SoC, the dynamic memory management process is complicated and prone to security vulnerabilities because the operating system needs to be constantly destroyed or created according to actual tasks; and because the virtual machine platform has a virtual machine operating system with a high privilege level (usually with access rights to all memory), the reliability of memory isolation is low.
[0004] Therefore, how to allocate and manage the memory of the virtual machine platform to improve the security of memory access of the virtual machine platform and the isolation reliability of the memory space is a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present invention provides a memory management method and device applied to a virtual machine platform, which can improve the security of memory access of the virtual machine platform and the isolation reliability of memory space.
[0006] In order to solve the above technical problems, the first aspect of the present invention discloses a memory management method applied to a virtual machine platform, wherein the virtual machine platform is mounted on a hardware terminal device, the virtual machine platform includes at least one virtual machine, and each of the virtual machines is used to run an operating system uniquely corresponding to the virtual machine and store resources corresponding to the operating system, the method comprising:
[0007] Determine the hardware memory resources and at least one memory configuration parameter of the hardware terminal device; wherein each of the memory configuration parameters includes a configuration identifier, and each of the memory configuration parameters has an operating system that uniquely corresponds to the memory configuration parameter;
[0008] Performing a static memory allocation operation on the hardware memory resources according to all the memory configuration parameters, so that an operating system corresponding to each memory configuration parameter is allocated to a target memory resource corresponding to the operating system;
[0009] The target memory resources corresponding to each operating system include private memory resources that only the operating system is allowed to access and / or shared memory resources that other operating systems are allowed to access.
[0010] As an optional implementation, in the first aspect of the present invention, the performing a static memory allocation operation on the hardware memory resources according to all the memory configuration parameters so that the operating system corresponding to each memory configuration parameter is allocated to the target memory resource corresponding to the operating system includes:
[0011] For each of the memory configuration parameters, determine the operating system corresponding to the memory configuration parameter, and statically allocate the hardware memory resources according to the memory configuration parameter when compiling the operating system, so that the operating system corresponding to the memory configuration parameter is allocated to the corresponding initial memory resources;
[0012] Integrate all information about initial memory resources allocated by the operating system to obtain memory allocation information;
[0013] Performing a memory address management operation on the initial memory resources corresponding to all the operating systems according to the memory allocation information, so that each operating system obtains the memory resources corresponding to the operating system after the management operation is performed;
[0014] For each of the operating systems, an isolation and locking operation is performed on the memory resources corresponding to the operating system after the management operation is executed, so that the operating system obtains the corresponding target memory resources.
[0015] As an optional implementation, in the first aspect of the present invention, each of the operating systems has a unique corresponding addressing mapping table, each of the addressing mapping tables includes at least one memory addressing mapping, and the memory addressing mapping is used to characterize the addressing route from the virtual memory address of the operating system to the physical memory address of the hardware terminal device;
[0016] The initial memory resource corresponding to each of the operating systems includes at least one initial memory address;
[0017] The performing a memory address management operation on the initial memory resources corresponding to all the operating systems according to the memory allocation information so that each operating system obtains the memory resources corresponding to the operating system after the management operation is performed, includes:
[0018] For each of the operating systems, a private address identification operation is performed on all initial memory addresses included in the initial memory resources corresponding to the operating system to obtain a private identification result uniquely corresponding to each of the initial memory addresses;
[0019] Performing a first memory address grouping operation according to the private identification results corresponding to all the initial memory addresses to obtain a private address group and a shared address group; wherein the initial memory addresses in the private address group and the shared address group are different from each other;
[0020] For each initial memory address in the private address group, a private address filling operation is performed on the initial memory address according to the memory allocation information, so that the operating system corresponding to the initial memory address obtains the memory resource after the address filling is performed on the initial memory address;
[0021] For each initial memory address in the shared address group, a shared address management operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after address management is performed on the initial memory address.
[0022] As an optional implementation, in the first aspect of the present invention, for each initial memory address in the private address group, performing a private address filling operation on the initial memory address according to the memory allocation information, so that the operating system corresponding to the initial memory address obtains the memory resource after the address filling is performed on the initial memory address, including:
[0023] Performing an address alignment identification operation on all initial memory addresses in the private address group according to a preset address alignment condition to obtain an alignment identification result uniquely corresponding to each initial memory address in the private address group;
[0024] For each initial memory address in the private address group, when the alignment identification result corresponding to the initial memory address is characterized as that the initial memory address satisfies the address alignment condition, determine the addressing mapping table corresponding to the operating system to which the initial memory address belongs, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the initial memory address obtains the corresponding memory resources.
[0025] As an optional implementation, in the first aspect of the present invention, for each initial memory address in the shared address group, performing a shared address management operation on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after address management is performed on the initial memory address, including:
[0026] Performing an address type identification operation on all initial memory addresses in the shared address group to obtain a type identification result uniquely corresponding to each initial memory address in the shared address group;
[0027] A second memory address grouping operation is performed according to the type identification results corresponding to all the initial memory addresses in the shared address group to obtain a common address group, a device address group and a controller address group; wherein the initial memory address in the common address group is an initial memory address of other types in the shared address group except for the device address type and the controller address type, and the initial memory addresses in the common address group, the device address group and the controller address group are different from each other;
[0028] For each initial memory address in the common address group, a shared address filling operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after the address filling is performed on the initial memory address;
[0029] For each initial memory address in the device address group, a shielding simulation operation is performed on the initial memory address so that an operating system accessing the initial memory address obtains a simulation access result;
[0030] For each initial memory address in the controller address group, a mapping construction operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after mapping and constructing the initial memory address.
[0031] As an optional implementation, in the first aspect of the present invention, for each initial memory address in the common address group, performing a shared address filling operation on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after the address filling is performed on the initial memory address, including:
[0032] For each initial memory address in the common address group, determine, according to the memory allocation information, addressing mapping tables corresponding to all operating systems to which the initial memory address belongs, to obtain an addressing mapping table set corresponding to the initial memory address;
[0033] For each addressing mapping table in the addressing mapping table set corresponding to the initial memory address, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the addressing mapping table obtains the corresponding memory resources.
[0034] As an optional implementation, in the first aspect of the present invention, for each initial memory address in the device address group, performing a shielding simulation operation on the initial memory address so that an operating system accessing the initial memory address obtains a simulated access result, including:
[0035] For each initial memory address in the device address group, the initial memory address is isolated and shielded, and a simulation processing function uniquely corresponding to the initial memory address is registered in a preset synchronization exception processing function table according to the initial memory address;
[0036] The simulation processing function corresponding to the initial memory address is used to simulate the process of accessing the address when the initial memory address is accessed by any operating system, and to feed back the simulation access result to the operating system that accesses the initial memory address.
[0037] As an optional implementation, in the first aspect of the present invention, for each initial memory address in the controller address group, performing a mapping construction operation on the initial memory address according to the memory allocation information so that all operating systems corresponding to the initial memory address obtain memory resources after mapping and constructing the initial memory address, including:
[0038] For each initial memory address in the controller address group, determine all operating systems to which the initial memory address belongs according to the memory allocation information, construct a mapping route between the initial memory address and all operating systems to which the initial memory address belongs in a preset controller mapping table, and register a port processing function uniquely corresponding to the initial memory address in a preset port exception processing function table;
[0039] The port processing function corresponding to the initial memory address is used to process an abnormal access request when the initial memory address is accessed by an operating system other than the operating system to which the initial memory address belongs.
[0040] As an optional implementation, in the first aspect of the present invention, for each of the operating systems, performing an isolation and locking operation on the memory resources corresponding to the operating system after the management operation is executed so that the operating system obtains the corresponding target memory resources, including:
[0041] For each of the operating systems, the addressing mapping table corresponding to the operating system after the execution management operation is determined, and the editing permissions of all the memory addressing mappings in the addressing mapping table are changed to a read-only state and locked so that the operating system obtains the corresponding target memory resources.
[0042] A second aspect of the present invention discloses a memory management device applied to a virtual machine platform, wherein the virtual machine platform is mounted on a hardware terminal device, the virtual machine platform includes at least one virtual machine, and each of the virtual machines is used to run an operating system uniquely corresponding to the virtual machine and store resources corresponding to the operating system, the device includes:
[0043] A parameter determination module, used to determine the hardware memory resources and at least one memory configuration parameter of the hardware terminal device; wherein each of the memory configuration parameters includes a configuration identifier, and each of the memory configuration parameters has an operating system that uniquely corresponds to the memory configuration parameter;
[0044] A memory management module, used to perform a static memory allocation operation on the hardware memory resources according to all the memory configuration parameters, so that the operating system corresponding to each memory configuration parameter is allocated to the target memory resource corresponding to the operating system;
[0045] The target memory resources corresponding to each operating system include private memory resources that only the operating system is allowed to access and / or shared memory resources that other operating systems are allowed to access.
[0046] As an optional implementation, in the second aspect of the present invention, the memory management module performs a static memory allocation operation on the hardware memory resources according to all the memory configuration parameters, so that the operating system corresponding to each memory configuration parameter is allocated to the target memory resource corresponding to the operating system. The specific manner includes:
[0047] For each of the memory configuration parameters, determine the operating system corresponding to the memory configuration parameter, and statically allocate the hardware memory resources according to the memory configuration parameter when compiling the operating system, so that the operating system corresponding to the memory configuration parameter is allocated to the corresponding initial memory resources;
[0048] Integrate all information about initial memory resources allocated by the operating system to obtain memory allocation information;
[0049] Performing a memory address management operation on the initial memory resources corresponding to all the operating systems according to the memory allocation information, so that each operating system obtains the memory resources corresponding to the operating system after the management operation is performed;
[0050] For each of the operating systems, an isolation and locking operation is performed on the memory resources corresponding to the operating system after the management operation is executed, so that the operating system obtains the corresponding target memory resources.
[0051] As an optional implementation, in the second aspect of the present invention, each of the operating systems has a unique corresponding addressing mapping table, each of the addressing mapping tables includes at least one memory addressing mapping, and the memory addressing mapping is used to characterize the addressing route from the virtual memory address of the operating system to the physical memory address of the hardware terminal device;
[0052] The initial memory resource corresponding to each of the operating systems includes at least one initial memory address;
[0053] The memory management module performs a memory address management operation on the initial memory resources corresponding to all the operating systems according to the memory allocation information, so that each operating system obtains the memory resources corresponding to the operating system after the execution management operation. The specific manner includes:
[0054] For each of the operating systems, a private address identification operation is performed on all initial memory addresses included in the initial memory resources corresponding to the operating system to obtain a private identification result uniquely corresponding to each of the initial memory addresses;
[0055] Performing a first memory address grouping operation according to the private identification results corresponding to all the initial memory addresses to obtain a private address group and a shared address group; wherein the initial memory addresses in the private address group and the shared address group are different from each other;
[0056] For each initial memory address in the private address group, a private address filling operation is performed on the initial memory address according to the memory allocation information, so that the operating system corresponding to the initial memory address obtains the memory resource after the address filling is performed on the initial memory address;
[0057] For each initial memory address in the shared address group, a shared address management operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after address management is performed on the initial memory address.
[0058] As an optional implementation, in the second aspect of the present invention, the memory management module performs a private address filling operation on each initial memory address in the private address group according to the memory allocation information, so that the operating system corresponding to the initial memory address obtains the memory resource after the initial memory address is filled with the address. The specific manner includes:
[0059] Performing an address alignment identification operation on all initial memory addresses in the private address group according to a preset address alignment condition to obtain an alignment identification result uniquely corresponding to each initial memory address in the private address group;
[0060] For each initial memory address in the private address group, when the alignment identification result corresponding to the initial memory address is characterized as that the initial memory address satisfies the address alignment condition, determine the addressing mapping table corresponding to the operating system to which the initial memory address belongs, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the initial memory address obtains the corresponding memory resources.
[0061] As an optional implementation, in the second aspect of the present invention, the memory management module performs a shared address management operation on each initial memory address in the shared address group according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after address management of the initial memory address. The specific manner includes:
[0062] Performing an address type identification operation on all initial memory addresses in the shared address group to obtain a type identification result uniquely corresponding to each initial memory address in the shared address group;
[0063] A second memory address grouping operation is performed according to the type identification results corresponding to all the initial memory addresses in the shared address group to obtain a common address group, a device address group and a controller address group; wherein the initial memory address in the common address group is an initial memory address of other types in the shared address group except for the device address type and the controller address type, and the initial memory addresses in the common address group, the device address group and the controller address group are different from each other;
[0064] For each initial memory address in the common address group, a shared address filling operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after the address filling is performed on the initial memory address;
[0065] For each initial memory address in the device address group, a shielding simulation operation is performed on the initial memory address so that an operating system accessing the initial memory address obtains a simulation access result;
[0066] For each initial memory address in the controller address group, a mapping construction operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after mapping and constructing the initial memory address.
[0067] As an optional implementation, in the second aspect of the present invention, the memory management module performs a shared address filling operation on each initial memory address in the common address group according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after the address filling is performed on the initial memory address. The specific manner includes:
[0068] For each initial memory address in the common address group, determine, according to the memory allocation information, addressing mapping tables corresponding to all operating systems to which the initial memory address belongs, to obtain an addressing mapping table set corresponding to the initial memory address;
[0069] For each addressing mapping table in the addressing mapping table set corresponding to the initial memory address, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the addressing mapping table obtains the corresponding memory resources.
[0070] As an optional implementation, in the second aspect of the present invention, the memory management module performs a shielding simulation operation on each initial memory address in the device address group so that the operating system accessing the initial memory address obtains a simulation access result. The specific manner includes:
[0071] For each initial memory address in the device address group, the initial memory address is isolated and shielded, and a simulation processing function uniquely corresponding to the initial memory address is registered in a preset synchronization exception processing function table according to the initial memory address;
[0072] The simulation processing function corresponding to the initial memory address is used to simulate the process of accessing the address when the initial memory address is accessed by any operating system, and to feed back the simulation access result to the operating system that accesses the initial memory address.
[0073] As an optional implementation, in the second aspect of the present invention, the memory management module performs a mapping construction operation on each initial memory address in the controller address group according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain the memory resources after mapping and constructing the initial memory address. The specific manner includes:
[0074] For each initial memory address in the controller address group, determine all operating systems to which the initial memory address belongs according to the memory allocation information, construct a mapping route between the initial memory address and all operating systems to which the initial memory address belongs in a preset controller mapping table, and register a port processing function uniquely corresponding to the initial memory address in a preset port exception processing function table;
[0075] The port processing function corresponding to the initial memory address is used to process an abnormal access request when the initial memory address is accessed by an operating system other than the operating system to which the initial memory address belongs.
[0076] As an optional implementation, in the second aspect of the present invention, the memory management module performs an isolation and locking operation on the memory resources corresponding to each operating system after the management operation is executed by the operating system, so that the operating system obtains the corresponding target memory resources. The specific manner includes:
[0077] For each of the operating systems, the addressing mapping table corresponding to the operating system after the execution management operation is determined, and the editing permissions of all the memory addressing mappings in the addressing mapping table are changed to a read-only state and locked so that the operating system obtains the corresponding target memory resources.
[0078] The third aspect of the present invention discloses another memory management device applied to a virtual machine platform, wherein the virtual machine platform is mounted on a hardware terminal device, the virtual machine platform includes at least one virtual machine, and each of the virtual machines is used to run an operating system uniquely corresponding to the virtual machine and store resources corresponding to the operating system, the device includes:
[0079] A memory storing executable program code;
[0080] a processor coupled to the memory;
[0081] The processor calls the executable program code stored in the memory to execute the memory management method applied to the virtual machine platform disclosed in the first aspect of the present invention.
[0082] The fourth aspect of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called by a processor, they are used to execute the memory management method applied to a virtual machine platform disclosed in the first aspect of the present invention.
[0083] Compared with the prior art, the present invention has the following beneficial effects:
[0084] In the present invention, the hardware memory resources of the hardware terminal device and the memory configuration parameters corresponding to each virtual machine operating system in the virtual machine platform are first obtained, and then the hardware memory resources are statically allocated according to all the memory configuration parameters, so that the operating system corresponding to each memory configuration parameter is allocated to the target memory resources required by the operating system, and the target memory resources include private memory resources that are only allowed to be accessed by the operating system and / or shared memory resources that are allowed to be accessed by other operating systems. It can be seen that the present invention can statically allocate hardware memory resources to the corresponding operating system according to the memory configuration parameters, reduce the situation where security vulnerabilities may occur during the dynamic memory management process, improve the security of memory access, and limit the access rights to the target memory resources allocated to each operating system, thereby improving the isolation reliability of the memory space. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0086] Figure 1 It is a flow chart of a memory management method applied to a virtual machine platform disclosed in the present invention;
[0087] Figure 2 It is a flow chart of another memory management method applied to a virtual machine platform disclosed in the present invention;
[0088] Figure 3 It is a structural schematic diagram of a memory management device applied to a virtual machine platform disclosed in an embodiment of the present invention;
[0089] Figure 4 The present invention discloses a memory management device for a virtual machine platform. DETAILED DESCRIPTION
[0090] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0091] The terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product or end including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or ends.
[0092] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0093] In computer systems, memory management is one of the core functions of the system, especially virtual memory management, which allows the operating system to transcend the limitations of physical memory and provide continuous and large virtual memory space for applications. Virtual memory management is a memory management technology implemented between computer hardware and software, which maps the memory address (virtual address) used by the program to the physical address in the computer memory, allowing the program to use more memory space than the physical memory. The basic principle of virtual memory management is to expand the physical memory to a part of the hard disk space, mainly relying on paging or segmentation mechanism, among which paging is the most common method. The paging mechanism divides the physical memory and virtual memory into fixed-size units, called "pages". When the program needs to access memory, the operating system converts the virtual address to the physical address. If the required page is not in the physical memory, the operating system will call the required page from the swap space of the hard disk. Only when the page is actually accessed will it be loaded into the physical memory, thereby reducing memory waste. Practice has found that in some embedded multi-operating system virtual machine platforms such as industrial SoC (System on Chip) and automotive SoC, the dynamic memory management process is complicated and prone to security vulnerabilities because the operating system needs to be constantly destroyed or created according to actual tasks; and because the virtual machine platform has a virtual machine operating system with a high privilege level (usually with access rights to all memory), the reliability of memory isolation is low. Therefore, how to allocate and manage the memory of the virtual machine platform to improve the security of the virtual machine platform's memory access and the reliability of memory space isolation is a technical problem that needs to be solved urgently.
[0094] In order to solve the above technical problems, the present invention discloses a memory management method and device applied to a virtual machine platform, aiming to improve the security of memory access of the virtual machine platform and the isolation reliability of memory space. The following are detailed descriptions.
[0095] In order to better understand the memory management method and device applied to the virtual machine platform involved in the present invention, the virtual machine platform applied by the present invention is first described. The virtual machine platform applied by the present invention is mounted on a hardware terminal device, which is a device configured with at least one hardware processor capable of data processing and executable instructions, such as a computer host, an industrial SoC terminal, a vehicle-mounted SoC terminal, etc. The virtual machine platform includes at least one virtual machine, each of which is used to run the operating system uniquely corresponding to the virtual machine and store the resources corresponding to the operating system, thereby simulating the functions of the corresponding hardware operating system in the virtual machine platform. The virtual machine system also includes a virtual machine manager, a resource scheduler, a virtual interrupt controller, etc. In the art, the resource scheduler and the virtual interrupt controller are usually integrated in the virtual machine manager. The virtual machine software corresponding to the virtual machine system applied by the present invention includes KVM, Citrix Hypervisor, Xen, etc.
[0096] Embodiment 1
[0097] See also Figure 1 , Figure 1 This is a flow chart of a memory management method applied to a virtual machine platform disclosed in the present invention. Figure 1 The method shown can be applied to a memory management device, which can allocate the hardware memory resources of a hardware terminal device to a virtual machine operating system inside a virtual machine platform carried by the hardware terminal device. Furthermore, the memory management device can be integrated into the hardware terminal device or the virtual machine platform, or can exist independently of the hardware terminal device and the virtual machine platform, which is not limited in the embodiments of the present invention. Figure 1 As shown, a memory management method applied to a virtual machine platform disclosed in an embodiment of the present invention includes but is not limited to the following operations:
[0098] 101. Determine hardware memory resources and at least one memory configuration parameter of a hardware terminal device.
[0099] Each memory configuration parameter includes a configuration identifier, and each memory configuration parameter has an operating system that uniquely corresponds to the memory configuration parameter.
[0100] In an embodiment of the present invention, the hardware memory resources of the hardware terminal device include all memory address resources it possesses. The configuration identifier represents the memory resources that need to be configured to the corresponding virtual machine operating system, such as the size of the memory space that needs to be configured for the operating system. Furthermore, the memory configuration parameters may also include a level identifier that represents the importance of the operating system, and when allocating memory resources based on the level identifier, priority may be given to operating systems with higher levels. It should be noted that other types of identification data may be set in the memory configuration parameters as required by the application scenario, and the memory configuration parameters may also include multiple identification parameter types at the same time.
[0101] 102. Perform a static memory allocation operation on the hardware memory resources according to all memory configuration parameters, so that the operating system corresponding to each memory configuration parameter is allocated to the target memory resource corresponding to the operating system.
[0102] The target memory resources corresponding to each operating system include private memory resources that only the operating system is allowed to access and / or shared memory resources that other operating systems are allowed to access.
[0103] It can be seen that the embodiment of the present invention can statically allocate hardware memory resources to the corresponding operating system according to the memory configuration parameters, reduce the possibility of security vulnerabilities in the dynamic memory management process, improve the security of memory access, and limit the access rights to the target memory resources allocated to each operating system, thereby improving the isolation reliability of the memory space.
[0104] In an optional embodiment, performing a memory static allocation operation on hardware memory resources according to all memory configuration parameters so that an operating system corresponding to each memory configuration parameter is allocated to a target memory resource corresponding to the operating system may include:
[0105] For each memory configuration parameter, determine the operating system corresponding to the memory configuration parameter, and statically allocate hardware memory resources according to the memory configuration parameter when compiling the operating system, so that the operating system corresponding to the memory configuration parameter is allocated to the corresponding initial memory resources;
[0106] Integrate the information of initial memory resources allocated by all operating systems to obtain memory allocation information;
[0107] Performing memory address management operations on initial memory resources corresponding to all operating systems according to the memory allocation information, so that each operating system obtains the memory resources corresponding to the operating system after the management operation is performed;
[0108] For each operating system, an isolation and locking operation is performed on the memory resources corresponding to the operating system after the management operation is executed, so that the operating system obtains the corresponding target memory resources.
[0109] It can be seen that in this optional embodiment, in the compilation stage of the operating system, memory resources such as DDR memory and IO port memory are statically divided according to memory configuration parameters, and the divided memory information is integrated. After obtaining the overall memory allocation information, the divided memory resources are further managed and isolated and locked so that each operating system obtains the corresponding static memory resources. Specifically, by constructing a memory management function to scan and integrate the divided memory information, the required memory allocation information can be obtained more conveniently.
[0110] In another optional embodiment, after integrating the information of the initial memory resources allocated to all operating systems to obtain the memory allocation information, a memory management method applied to a virtual machine platform in an embodiment of the present invention may further include:
[0111] Perform memory diagnosis on initial memory resources corresponding to all operating systems according to the memory allocation information to obtain memory diagnosis results;
[0112] When the memory diagnosis result indicates that there are no duplicate private memory addresses, a step is triggered to perform memory address management operations on the initial memory resources corresponding to all operating systems according to the memory allocation information, so that each operating system obtains the memory resources corresponding to the operating system after the execution management operation.
[0113] In this optional embodiment, memory diagnosis is performed before performing memory address management operations, and subsequent memory address management operations are performed only after confirming that memory allocation is normal and there are no duplicated private memory addresses.
[0114] Furthermore, when the memory diagnosis result indicates that there are duplicate private memory addresses, an alarm message indicating memory allocation failure is output. After receiving the alarm message, the maintenance personnel of the virtual machine platform can check and adjust the memory configuration parameter settings and restart the memory static allocation operation.
[0115] In yet another optional embodiment, each operating system has a unique corresponding addressing mapping table, each addressing mapping table includes at least one memory addressing mapping, and the memory addressing mapping is used to represent the addressing route from the virtual memory address of the operating system to the physical memory address of the hardware terminal device;
[0116] The initial memory resource corresponding to each operating system includes at least one initial memory address;
[0117] Performing a memory address management operation on the initial memory resources corresponding to all operating systems according to the memory allocation information so that each operating system obtains the memory resources corresponding to the operating system after the management operation is performed may include:
[0118] For each operating system, a private address identification operation is performed on all initial memory addresses included in the initial memory resources corresponding to the operating system to obtain a private identification result uniquely corresponding to each initial memory address;
[0119] Performing a first memory address grouping operation according to the private identification results corresponding to all the initial memory addresses to obtain a private address group and a shared address group; wherein the initial memory addresses in the private address group and the shared address group are different from each other;
[0120] For each initial memory address in the private address group, a private address filling operation is performed on the initial memory address according to the memory allocation information, so that the operating system corresponding to the initial memory address obtains the memory resource after the address filling is performed on the initial memory address;
[0121] For each initial memory address in the shared address group, a shared address management operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after address management is performed on the initial memory address.
[0122] In this optional embodiment, the initial memory resources allocated to the operating system are grouped according to whether the address is private, so that the allocated private memory addresses and shared memory addresses are managed separately. Specifically, for the virtual machine operating system in the virtual machine platform, the memory addressing mapping includes: a first addressing mapping from a virtual memory address to an intermediate memory address and a second addressing mapping from an intermediate memory address to a physical memory address, that is, the virtual machine operating system usually needs to go through two levels of conversion to access the physical memory address of the hardware terminal device.
[0123] In yet another optional embodiment, for each initial memory address in the private address group, performing a private address filling operation on the initial memory address according to the memory allocation information so that the operating system corresponding to the initial memory address obtains the memory resource after the address filling is performed on the initial memory address, which may include:
[0124] Performing an address alignment recognition operation on all initial memory addresses in the private address group according to a preset address alignment condition, and obtaining an alignment recognition result uniquely corresponding to each initial memory address in the private address group;
[0125] For each initial memory address in the private address group, when the alignment identification result corresponding to the initial memory address indicates that the initial memory address satisfies the address alignment condition, determine the addressing mapping table corresponding to the operating system to which the initial memory address belongs, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the initial memory address obtains the corresponding memory resources.
[0126] It can be seen that in this optional embodiment, for private memory addresses that meet the address alignment condition, the memory address is filled into the addressing mapping table of the corresponding operating system to update a memory addressing mapping that has not been updated during this memory static allocation operation. When the operating system accesses the private memory address, the memory management unit automatically finds the correct physical memory address according to the corresponding memory addressing mapping, while other operating systems cannot access the private memory address because they do not have the corresponding memory addressing mapping, thereby improving the isolation reliability of the memory address space. In addition, compared with conventional virtual machine memory management technologies in the field, the present invention does not call computing resources to dynamically allocate memory during the operation of the virtual machine, but statically allocates memory in advance and constructs a memory addressing mapping, which can significantly improve the efficiency of memory access.
[0127] In yet another optional embodiment, for each initial memory address in the shared address group, performing a shared address management operation on the initial memory address according to the memory allocation information so that all operating systems corresponding to the initial memory address obtain memory resources after address management is performed on the initial memory address, may include:
[0128] Performing an address type identification operation on all initial memory addresses in the shared address group to obtain a type identification result uniquely corresponding to each initial memory address in the shared address group;
[0129] A second memory address grouping operation is performed according to the type identification results corresponding to all the initial memory addresses in the shared address group to obtain a common address group, a device address group and a controller address group; wherein the initial memory address in the common address group is an initial memory address of other types in the shared address group except for the device address type and the controller address type, and the initial memory addresses in the common address group, the device address group and the controller address group are different from each other;
[0130] For each initial memory address in the common address group, a shared address filling operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after the address filling is performed on the initial memory address;
[0131] For each initial memory address in the device address group, a shielding simulation operation is performed on the initial memory address so that an operating system accessing the initial memory address obtains a simulation access result;
[0132] For each initial memory address in the controller address group, a mapping construction operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after the mapping construction is performed on the initial memory address.
[0133] In this optional embodiment, the shared memory addresses are further grouped and managed according to the address types, which can improve the efficiency of memory management.
[0134] In yet another optional embodiment, for each initial memory address in the common address group, performing a shared address filling operation on the initial memory address according to the memory allocation information so that all operating systems corresponding to the initial memory address obtain memory resources after the address filling is performed on the initial memory address, may include:
[0135] For each initial memory address in the common address group, determine the addressing mapping tables corresponding to all the operating systems to which the initial memory address belongs according to the memory allocation information, and obtain the addressing mapping table set corresponding to the initial memory address;
[0136] For each addressing mapping table in the addressing mapping table set corresponding to the initial memory address, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the addressing mapping table obtains the corresponding memory resources.
[0137] It can be seen that in this optional embodiment, for each shared memory address of the common address type, the shared memory address is filled into the corresponding addressing mapping table of all operating systems, so that all operating systems sharing the address have permission to access. The corresponding operating system accesses the shared memory address through the shared access mechanism, thereby improving the access security of the shared memory address and maintaining the stability between the operating systems corresponding to the address.
[0138] In yet another optional embodiment, for each initial memory address in the device address group, performing a masking simulation operation on the initial memory address so that an operating system accessing the initial memory address obtains a simulation access result may include:
[0139] For each initial memory address in the device address group, the initial memory address is isolated and shielded, and a simulation processing function uniquely corresponding to the initial memory address is registered in a preset synchronization exception processing function table according to the initial memory address;
[0140] The simulation processing function corresponding to the initial memory address is used to simulate the process of accessing the address when the initial memory address is accessed by any operating system, and to feed back the simulation access result to the operating system that accesses the initial memory address.
[0141] It can be seen that in this optional embodiment, the shared memory addresses of the device address type are actually not allowed to be accessed by the operating system. Therefore, through the page fault exception mechanism of the operating system, the simulation processing function corresponding to the shared memory address of each device address type is registered in the synchronization exception processing function table of the virtual machine manager, and the virtual machine manager simulates the process of the operating system accessing these addresses. That is, when the operating system accesses these addresses, the real physical memory address is not returned. Instead, the virtual machine manager simulates the access process and returns a non-blank simulation result, thereby improving the security of the memory space.
[0142] In yet another optional embodiment, for each initial memory address in the controller address group, performing a mapping construction operation on the initial memory address according to the memory allocation information so that all operating systems corresponding to the initial memory address obtain memory resources after mapping and constructing the initial memory address may include:
[0143] For each initial memory address in the controller address group, all operating systems to which the initial memory address belongs are determined according to the memory allocation information, a mapping route between the initial memory address and all operating systems to which the initial memory address belongs is constructed in a preset controller mapping table, and a port processing function uniquely corresponding to the initial memory address is registered in a preset port exception processing function table;
[0144] The port processing function corresponding to the initial memory address is used to process an abnormal access request when the initial memory address is accessed by an operating system other than the operating system to which the initial memory address belongs.
[0145] It can be seen that in this optional embodiment, for shared memory addresses of controller address types (such as the addresses of clock controllers, pin controllers, etc.), a controller mapping table is set in the virtual machine manager, and the exception handling functions corresponding to the shared memory addresses of each controller address type are registered in the table. The virtual machine manager uniformly manages the memory read and write access rights of each controller, thereby improving the isolation of the operating system's access to the required controller addresses.
[0146] In yet another optional embodiment, for each operating system, performing an isolation and locking operation on the memory resources corresponding to the operating system after the management operation is executed so that the operating system obtains the corresponding target memory resources may include:
[0147] For each operating system, the addressing mapping table corresponding to the operating system after the management operation is performed is determined, and the editing authority of all memory addressing mappings in the addressing mapping table is changed to a read-only state and locked, so that the operating system obtains the corresponding target memory resource.
[0148] It can be seen that in this optional embodiment, the addressing mapping tables of each operating system are locked and isolated after the memory address management operation is completed to improve the isolation reliability of static memory allocation. Furthermore, if the memory information is scanned and integrated by constructing a memory management function to obtain memory allocation information, then after the memory address management operation is completed, the memory management function can also be deregistered so that the later startup program cannot modify the allocated static memory resources. Thereby further improving the isolation reliability of static memory allocation.
[0149] In yet another alternative embodiment, see Figure 2 , Figure 2 It is a flowchart of another memory management method applied to a virtual machine platform disclosed in the present invention. In this embodiment, the memory management method of the present invention is applied to a Xen virtual machine platform, and the corresponding memory management is completed through a virtual machine controller at the EL2 exception level, and a handler_mem_access memory management function and a memblock_access global variable are pre-configured. The optional memory management process is as follows:
[0150] 1. When compiling the operating system, memory resources (DDR memory address, IO port memory address, etc.) are statically divided according to memory configuration parameters and device tree properties.
[0151] Second, execute the handler_mem_access memory management function to perform a global scan of the static memory address allocation registered in the device tree and code segment, and fill all memory information into the memblock_access global variable. This global variable records the base address, address length, address type, sharing status, and ownership domain of each segment address.
[0152] 3. Check whether there are address segments that are repeatedly allocated to multiple operating systems and not marked as shared based on the memory information in the memblock_access global variable. If so, the memory allocation fails and the memory resources are reallocated after adjusting the memory configuration parameters. If not, execute the subsequent steps.
[0153] 4. Detect the address type of each address segment separately, and perform memory address management operations according to the detection results of each address segment:
[0154] If a private address that meets the 4K alignment condition is detected, the virtual machine manager is called to fill the address into the addressing mapping table of the corresponding operating system through page table translation technology;
[0155] If a shared address of the common address type is detected, the virtual machine manager is called to fill the address into the address mapping table of all operating systems sharing the address;
[0156] If a shared address of the device address type is detected, a simulation processing function of the address is registered in the virtual machine manager through the page fault exception mechanism of the operating system;
[0157] If a shared address of the control address type is detected, a mapping route is constructed between the address and its corresponding operating system, and the port processing function corresponding to the address is registered in the virtual machine manager. The virtual machine manager uniformly manages the read and write access rights of each controller to ensure the read and write isolation and constraints of each operating system on the required controller.
[0158] 5. After managing all the allocated addresses, cancel the code definition and code space of the handler_mem_access memory management function, and set the addressing mapping table of each operating system to read-only permission and lock it. This ensures the reliability of static memory partitioning until the operating system terminates.
[0159] Embodiment 2
[0160] See also Figure 3 , Figure 3 1 is a schematic diagram of a memory management device for a virtual machine platform disclosed in an embodiment of the present invention. Figure 3 The device shown is used to implement the memory management method applied to the virtual machine platform described in the first embodiment. Furthermore, the memory management device can be integrated into the hardware terminal device or the virtual machine platform, or can exist independently of the hardware terminal device and the virtual machine platform, which is not limited in the embodiment of the present invention. Figure 3 As shown, a memory management device applied to a virtual machine platform disclosed in an embodiment of the present invention includes but is not limited to the following modules:
[0161] The parameter determination module 201 is used to determine the hardware memory resources and at least one memory configuration parameter of the hardware terminal device; wherein each memory configuration parameter includes a configuration identifier, and each memory configuration parameter has an operating system that uniquely corresponds to the memory configuration parameter;
[0162] The memory management module 202 is used to perform a static memory allocation operation on the hardware memory resources according to all memory configuration parameters, so that the operating system corresponding to each memory configuration parameter is allocated to the target memory resource corresponding to the operating system;
[0163] The target memory resources corresponding to each operating system include private memory resources that only the operating system is allowed to access and / or shared memory resources that other operating systems are allowed to access.
[0164] It can be seen that the embodiment of the present invention can statically allocate hardware memory resources to the corresponding operating system according to the memory configuration parameters, reduce the possibility of security vulnerabilities in the dynamic memory management process, improve the security of memory access, and limit the access rights to the target memory resources allocated to each operating system, thereby improving the isolation reliability of the memory space.
[0165] In an optional embodiment, the memory management module 202 performs a static memory allocation operation on the hardware memory resources according to all memory configuration parameters so that the operating system corresponding to each memory configuration parameter is allocated to the target memory resource corresponding to the operating system. The specific manner includes:
[0166] For each memory configuration parameter, determine the operating system corresponding to the memory configuration parameter, and statically allocate hardware memory resources according to the memory configuration parameter when compiling the operating system, so that the operating system corresponding to the memory configuration parameter is allocated to the corresponding initial memory resources;
[0167] Integrate the information of initial memory resources allocated by all operating systems to obtain memory allocation information;
[0168] Performing memory address management operations on initial memory resources corresponding to all operating systems according to the memory allocation information, so that each operating system obtains the memory resources corresponding to the operating system after the management operation is performed;
[0169] For each operating system, an isolation and locking operation is performed on the memory resources corresponding to the operating system after the management operation is executed, so that the operating system obtains the corresponding target memory resources.
[0170] In this optional embodiment, during the compilation stage of the operating system, memory resources such as DDR memory and IO port memory are statically divided according to memory configuration parameters, and the divided memory information is integrated to obtain the overall memory allocation information. The divided memory resources are further managed and isolated and locked so that each operating system obtains the corresponding static memory resources.
[0171] In an optional embodiment, each operating system has a unique corresponding addressing mapping table, each addressing mapping table includes at least one memory addressing mapping, and the memory addressing mapping is used to represent the addressing route from the virtual memory address of the operating system to the physical memory address of the hardware terminal device;
[0172] The initial memory resource corresponding to each operating system includes at least one initial memory address;
[0173] The memory management module 202 performs memory address management operations on the initial memory resources corresponding to all operating systems according to the memory allocation information, so that each operating system obtains the memory resources corresponding to the operating system after the execution management operation. The specific manner includes:
[0174] For each operating system, a private address identification operation is performed on all initial memory addresses included in the initial memory resources corresponding to the operating system to obtain a private identification result uniquely corresponding to each initial memory address;
[0175] Performing a first memory address grouping operation according to the private identification results corresponding to all the initial memory addresses to obtain a private address group and a shared address group; wherein the initial memory addresses in the private address group and the shared address group are different from each other;
[0176] For each initial memory address in the private address group, a private address filling operation is performed on the initial memory address according to the memory allocation information, so that the operating system corresponding to the initial memory address obtains the memory resource after the address filling is performed on the initial memory address;
[0177] For each initial memory address in the shared address group, a shared address management operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after address management is performed on the initial memory address.
[0178] In this optional embodiment, the initial memory resources allocated by the operating system are grouped according to whether the addresses are private, so that the allocated private memory addresses and shared memory addresses are managed separately.
[0179] In an optional embodiment, the memory management module 202 performs a private address filling operation on each initial memory address in the private address group according to the memory allocation information, so that the operating system corresponding to the initial memory address obtains the memory resource after the initial memory address is filled. The specific manner includes:
[0180] Performing an address alignment recognition operation on all initial memory addresses in the private address group according to a preset address alignment condition, and obtaining an alignment recognition result uniquely corresponding to each initial memory address in the private address group;
[0181] For each initial memory address in the private address group, when the alignment identification result corresponding to the initial memory address indicates that the initial memory address satisfies the address alignment condition, determine the addressing mapping table corresponding to the operating system to which the initial memory address belongs, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the initial memory address obtains the corresponding memory resources.
[0182] It can be seen that in this optional embodiment, for a private memory address that meets the address alignment condition, the memory address is filled into the addressing mapping table of the corresponding operating system to update a memory addressing mapping that has not been updated during this memory static allocation operation. When the operating system accesses the private memory address, the memory management unit automatically finds the correct physical memory address according to the corresponding memory addressing mapping, while other operating systems cannot access the private memory address because they do not have the corresponding memory addressing mapping, thereby improving the isolation reliability of the memory address space.
[0183] In an optional embodiment, the memory management module 202 performs a shared address management operation on each initial memory address in the shared address group according to the memory allocation information so that all operating systems corresponding to the initial memory address obtain the memory resource after the address management is performed on the initial memory address. The specific manner includes:
[0184] Performing an address type identification operation on all initial memory addresses in the shared address group to obtain a type identification result uniquely corresponding to each initial memory address in the shared address group;
[0185] A second memory address grouping operation is performed according to the type identification results corresponding to all the initial memory addresses in the shared address group to obtain a common address group, a device address group and a controller address group; wherein the initial memory address in the common address group is an initial memory address of other types in the shared address group except for the device address type and the controller address type, and the initial memory addresses in the common address group, the device address group and the controller address group are different from each other;
[0186] For each initial memory address in the common address group, a shared address filling operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after the address filling is performed on the initial memory address;
[0187] For each initial memory address in the device address group, a shielding simulation operation is performed on the initial memory address so that an operating system accessing the initial memory address obtains a simulation access result;
[0188] For each initial memory address in the controller address group, a mapping construction operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after the mapping construction is performed on the initial memory address.
[0189] In this optional embodiment, the shared memory addresses are further grouped and managed according to the address types, which can improve the efficiency of memory management.
[0190] In an optional embodiment, the memory management module 202 performs a shared address filling operation on each initial memory address in the common address group according to the memory allocation information so that all operating systems corresponding to the initial memory address obtain the memory resource after the address filling is performed on the initial memory address. The specific manner includes:
[0191] For each initial memory address in the common address group, determine the addressing mapping tables corresponding to all the operating systems to which the initial memory address belongs according to the memory allocation information, and obtain the addressing mapping table set corresponding to the initial memory address;
[0192] For each addressing mapping table in the addressing mapping table set corresponding to the initial memory address, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the addressing mapping table obtains the corresponding memory resources.
[0193] In this optional embodiment, for each shared memory address of the common address type, the shared memory address is filled into the corresponding addressing mapping tables of all operating systems, so that all operating systems sharing the address have permission to access it.
[0194] In an optional embodiment, the memory management module 202 performs a shielding simulation operation on each initial memory address in the device address group so that the operating system accessing the initial memory address obtains a simulation access result. The specific manner includes:
[0195] For each initial memory address in the device address group, the initial memory address is isolated and shielded, and a simulation processing function uniquely corresponding to the initial memory address is registered in a preset synchronization exception processing function table according to the initial memory address;
[0196] The simulation processing function corresponding to the initial memory address is used to simulate the process of accessing the address when the initial memory address is accessed by any operating system, and to feed back the simulation access result to the operating system that accesses the initial memory address.
[0197] It can be seen that in this optional embodiment, the shared memory addresses of the device address type are actually not allowed to be accessed by the operating system. Therefore, through the page fault exception mechanism of the operating system, the simulation processing function corresponding to the shared memory address of each device address type is registered in the synchronization exception processing function table of the virtual machine manager, and the virtual machine manager simulates the process of the operating system accessing these addresses. That is, when the operating system accesses these addresses, the real physical memory address is not returned. Instead, the virtual machine manager simulates the access process and returns a non-blank simulation result, thereby improving the security of the memory space and the isolation reliability.
[0198] In an optional embodiment, the memory management module 202 performs a mapping construction operation on each initial memory address in the controller address group according to the memory allocation information so that all operating systems corresponding to the initial memory address obtain the memory resource after the initial memory address is mapped and constructed. The specific manner includes:
[0199] For each initial memory address in the controller address group, all operating systems to which the initial memory address belongs are determined according to the memory allocation information, a mapping route between the initial memory address and all operating systems to which the initial memory address belongs is constructed in a preset controller mapping table, and a port processing function uniquely corresponding to the initial memory address is registered in a preset port exception processing function table;
[0200] The port processing function corresponding to the initial memory address is used to process an abnormal access request when the initial memory address is accessed by an operating system other than the operating system to which the initial memory address belongs.
[0201] It can be seen that in this optional embodiment, for shared memory addresses of controller address types (such as the addresses of clock controllers, pin controllers, etc.), a controller mapping table is set in the virtual machine manager, and the exception handling functions corresponding to the shared memory addresses of each controller address type are registered in the table. The virtual machine manager uniformly manages the memory read and write access rights of each controller, thereby improving the isolation of the operating system's access to the required controller addresses.
[0202] In an optional embodiment, the memory management module 202 performs an isolation and locking operation on the memory resources corresponding to each operating system after the management operation is performed, so that the operating system obtains the corresponding target memory resources. The specific manner includes:
[0203] For each operating system, the addressing mapping table corresponding to the operating system after the management operation is performed is determined, and the editing authority of all memory addressing mappings in the addressing mapping table is changed to a read-only state and locked, so that the operating system obtains the corresponding target memory resource.
[0204] It can be seen that in this optional embodiment, the addressing mapping tables of each operating system are locked and isolated after the memory address management operation is completed, so as to improve the isolation reliability of static memory allocation.
[0205] Embodiment 3
[0206] See also Figure 4 , Figure 4 1 is a schematic diagram of a memory management device for a virtual machine platform disclosed in an embodiment of the present invention. Figure 4 The device shown is used to implement the memory management method applied to the virtual machine platform described in the first embodiment. Furthermore, the memory management device can be integrated into the hardware terminal device or the virtual machine platform, or can exist independently of the hardware terminal device and the virtual machine platform, which is not limited in the embodiment of the present invention. Figure 4 As shown, a memory management device applied to a virtual machine platform disclosed in an embodiment of the present invention includes but is not limited to:
[0207] A memory 301 storing executable program codes;
[0208] a processor 302 coupled to the memory 301;
[0209] The processor 302 calls the executable program code stored in the memory 301 to execute part or all of the steps of the memory management method applied to the virtual machine platform described in the first embodiment of the present invention.
[0210] Embodiment 4
[0211] An embodiment of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called by a processor, they are used to execute some or all steps of the memory management method applied to a virtual machine platform described in the first embodiment of the present invention.
[0212] The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, and may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative work.
[0213] Through the specific description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the above technical solution can be essentially or partly contributed to the prior art in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0214] Finally, it should be noted that the memory management method and device for a virtual machine platform disclosed in the embodiment of the present invention disclose only the preferred embodiments of the present invention, which are only used to illustrate the technical solution of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A memory management method applied to a virtual machine platform, wherein the virtual machine platform is mounted on a hardware terminal device, characterized in that: The virtual machine platform includes at least one virtual machine, and each of the virtual machines is used to run an operating system uniquely corresponding to the virtual machine and store resources corresponding to the operating system. The method includes: Determine the hardware memory resources and at least one memory configuration parameter of the hardware terminal device; wherein each of the memory configuration parameters includes a configuration identifier, and each of the memory configuration parameters has an operating system that uniquely corresponds to the memory configuration parameter; Performing a static memory allocation operation on the hardware memory resources according to all the memory configuration parameters, so that an operating system corresponding to each memory configuration parameter is allocated to a target memory resource corresponding to the operating system; The target memory resources corresponding to each operating system include private memory resources that only the operating system is allowed to access and / or shared memory resources that other operating systems are allowed to access.
2. The memory management method applied to a virtual machine platform according to claim 1, characterized in that: The performing a memory static allocation operation on the hardware memory resources according to all the memory configuration parameters so that an operating system corresponding to each memory configuration parameter is allocated to a target memory resource corresponding to the operating system, comprises: For each of the memory configuration parameters, determine the operating system corresponding to the memory configuration parameter, and statically allocate the hardware memory resources according to the memory configuration parameter when compiling the operating system, so that the operating system corresponding to the memory configuration parameter is allocated to the corresponding initial memory resources; Integrate the information of the initial memory resources allocated by all the operating systems to obtain memory allocation information; Performing a memory address management operation on the initial memory resources corresponding to all the operating systems according to the memory allocation information, so that each operating system obtains the memory resources corresponding to the operating system after the management operation is performed; For each of the operating systems, an isolation and locking operation is performed on the memory resources corresponding to the operating system after the management operation is executed, so that the operating system obtains the corresponding target memory resources.
3. The memory management method applied to a virtual machine platform according to claim 2, characterized in that: Each of the operating systems has a unique corresponding addressing mapping table, each of the addressing mapping tables includes at least one memory addressing mapping, and the memory addressing mapping is used to represent the addressing route from the virtual memory address of the operating system to the physical memory address of the hardware terminal device; The initial memory resource corresponding to each of the operating systems includes at least one initial memory address; The performing a memory address management operation on the initial memory resources corresponding to all the operating systems according to the memory allocation information so that each operating system obtains the memory resources corresponding to the operating system after the management operation is performed, includes: For each of the operating systems, a private address identification operation is performed on all initial memory addresses included in the initial memory resources corresponding to the operating system to obtain a private identification result uniquely corresponding to each of the initial memory addresses; Performing a first memory address grouping operation according to the private identification results corresponding to all the initial memory addresses to obtain a private address group and a shared address group; wherein the initial memory addresses in the private address group and the shared address group are different from each other; For each initial memory address in the private address group, a private address filling operation is performed on the initial memory address according to the memory allocation information, so that the operating system corresponding to the initial memory address obtains the memory resource after the address filling is performed on the initial memory address; For each initial memory address in the shared address group, a shared address management operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after address management is performed on the initial memory address.
4. The memory management method applied to a virtual machine platform according to claim 3, characterized in that: For each initial memory address in the private address group, performing a private address filling operation on the initial memory address according to the memory allocation information, so that the operating system corresponding to the initial memory address obtains the memory resource after the address filling is performed on the initial memory address, including: Performing an address alignment identification operation on all initial memory addresses in the private address group according to a preset address alignment condition to obtain an alignment identification result uniquely corresponding to each initial memory address in the private address group; For each initial memory address in the private address group, when the alignment identification result corresponding to the initial memory address is characterized as that the initial memory address satisfies the address alignment condition, determine the addressing mapping table corresponding to the operating system to which the initial memory address belongs, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the initial memory address obtains the corresponding memory resources.
5. The memory management method applied to a virtual machine platform according to claim 3, characterized in that: For each initial memory address in the shared address group, performing a shared address management operation on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after address management is performed on the initial memory address, including: Performing an address type identification operation on all initial memory addresses in the shared address group to obtain a type identification result uniquely corresponding to each initial memory address in the shared address group; A second memory address grouping operation is performed according to the type identification results corresponding to all the initial memory addresses in the shared address group to obtain a common address group, a device address group and a controller address group; wherein the initial memory address in the common address group is an initial memory address of other types in the shared address group except for the device address type and the controller address type, and the initial memory addresses in the common address group, the device address group and the controller address group are different from each other; For each initial memory address in the common address group, a shared address filling operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after the address filling is performed on the initial memory address; For each initial memory address in the device address group, a shielding simulation operation is performed on the initial memory address so that an operating system accessing the initial memory address obtains a simulation access result; For each initial memory address in the controller address group, a mapping construction operation is performed on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after mapping and constructing the initial memory address.
6. The memory management method applied to a virtual machine platform according to claim 5, characterized in that: For each initial memory address in the common address group, performing a shared address filling operation on the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after address filling of the initial memory address, including: For each initial memory address in the common address group, determine, according to the memory allocation information, addressing mapping tables corresponding to all operating systems to which the initial memory address belongs, to obtain an addressing mapping table set corresponding to the initial memory address; For each addressing mapping table in the addressing mapping table set corresponding to the initial memory address, determine a memory addressing mapping that has not been updated during this memory static allocation operation in the addressing mapping table, and fill the initial memory address into the addressing mapping table to update the memory addressing mapping, so that the operating system corresponding to the addressing mapping table obtains the corresponding memory resources.
7. The memory management method applied to a virtual machine platform according to claim 5, characterized in that: For each initial memory address in the device address group, performing a shielding simulation operation on the initial memory address so that an operating system accessing the initial memory address obtains a simulation access result, including: For each initial memory address in the device address group, the initial memory address is isolated and shielded, and a simulation processing function uniquely corresponding to the initial memory address is registered in a preset synchronization exception processing function table according to the initial memory address; The simulation processing function corresponding to the initial memory address is used to simulate the process of accessing the address when the initial memory address is accessed by any operating system, and to feed back the simulation access result to the operating system that accesses the initial memory address.
8. The memory management method applied to a virtual machine platform according to claim 5, characterized in that: For each initial memory address in the controller address group, mapping and constructing the initial memory address according to the memory allocation information, so that all operating systems corresponding to the initial memory address obtain memory resources after mapping and constructing the initial memory address, including: For each initial memory address in the controller address group, determine all operating systems to which the initial memory address belongs according to the memory allocation information, construct a mapping route between the initial memory address and all operating systems to which the initial memory address belongs in a preset controller mapping table, and register a port processing function uniquely corresponding to the initial memory address in a preset port exception processing function table; The port processing function corresponding to the initial memory address is used to process an abnormal access request when the initial memory address is accessed by an operating system other than the operating system to which the initial memory address belongs.
9. The memory management method applied to a virtual machine platform according to any one of claims 3 to 8, characterized in that: For each of the operating systems, performing an isolation and locking operation on the memory resources corresponding to the operating system after the management operation is performed, so that the operating system obtains the corresponding target memory resources, including: For each of the operating systems, the addressing mapping table corresponding to the operating system after the execution management operation is determined, and the editing permissions of all the memory addressing mappings in the addressing mapping table are changed to a read-only state and locked so that the operating system obtains the corresponding target memory resources.
10. A memory management device applied to a virtual machine platform, wherein the virtual machine platform is mounted on a hardware terminal device, characterized in that: The virtual machine platform includes at least one virtual machine, and each of the virtual machines is used to run an operating system uniquely corresponding to the virtual machine and store resources corresponding to the operating system. The device includes: A parameter determination module, used to determine the hardware memory resources and at least one memory configuration parameter of the hardware terminal device; wherein each of the memory configuration parameters includes a configuration identifier, and each of the memory configuration parameters has an operating system that uniquely corresponds to the memory configuration parameter; A memory management module, used to perform a static memory allocation operation on the hardware memory resources according to all the memory configuration parameters, so that the operating system corresponding to each memory configuration parameter is allocated to the target memory resource corresponding to the operating system; The target memory resources corresponding to each operating system include private memory resources that only the operating system is allowed to access and / or shared memory resources that other operating systems are allowed to access.
11. A memory management device applied to a virtual machine platform, wherein the virtual machine platform is mounted on a hardware terminal device, characterized in that: The virtual machine platform includes at least one virtual machine, and each of the virtual machines is used to run an operating system uniquely corresponding to the virtual machine and store resources corresponding to the operating system. The device includes: A memory storing executable program code; a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the memory management method applied to a virtual machine platform as described in any one of claims 1 to 9.
12. A computer storage medium storing computer instructions, wherein the computer instructions, when called by a processor, are used to execute the memory management method applied to a virtual machine platform as claimed in any one of claims 1 to 9.