Data processing method, device, computing equipment and medium
By writing the virtual machine's register data to the KVM module and VMCS module when the operating system kernel crashes, and copying it to the preset storage area, it solves the problem that the existing technology cannot save the virtual machine CPU state and kernel state, and realizes the Efficient preservation and analysis support of virtual machine state.
Patent Information
- Application Number
- CN202210210905.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-04
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2042-03-04
AI Technical Summary
Existing Kdump memory data dump schemes cannot save the CPU and kernel state of the virtual machine when the kernel crashes.
When the kernel of the operating system crashes, the virtual machine's register data is written into the KVM module and VMCS module, thereby obtaining and copying the data to the preset storage area, and finally storing it in the target memory area.
It realizes the saving of the virtual machine CPU state and kernel state when the operating system kernel crashes, and provides data support for analyzing the cause of the crash.
Smart Images

Figure CN114691291B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of computer technology, and in particular, to a data processing method, apparatus, computing device, and medium. Background Art
[0002] Kdump is a service used to dump memory data when the operating system kernel crashes. After the kernel crashes, it can be quickly started to save the system's central processing unit (CPU) state and kernel state. The saved CPU state and memory state can provide data support for operation and maintenance personnel to analyze the cause of the kernel crash.
[0003] With the continuous development of network technology, cloud computing, as a technology that can process tens of thousands of data in a very short time, has been widely used in the field of network technology. Among them, virtualization is one of the key technologies of cloud computing, and cloud servers with virtual machines as the core are also the infrastructure of cloud computing. However, the above-mentioned Kdump-based memory operation data dump solution cannot save the CPU state and kernel state of the virtual machine when the kernel crashes. Summary of the invention
[0004] In view of this, one or more embodiments of the present specification provide a data processing method, apparatus, computing device, and medium.
[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0006] According to a first aspect of one or more embodiments of this specification, a data processing method is proposed, the method comprising:
[0007] In the case of a kernel crash of the operating system, first data in a first register of the virtual machine is written into a kernel-based virtual machine KVM module, and second data in a second register of the virtual machine and a central processing unit CPU of the virtual machine is written into a virtual machine control structure VMCS module, wherein the first register is used to store the first data as an operand or a result of operation, and the second register is used to store the second data as a segment address;
[0008] Acquire the first data from the KVM module, and acquire a target pointer from the KVM module, the target pointer pointing to an address of a VMCS module for storing the second data;
[0009] Based on the target pointer, copy the second data from the VMCS module pointed to by the target pointer to a preset storage area, where the preset storage area is located in the memory corresponding to the target CPU;
[0010] The second data is acquired from a preset storage area, and the first data and the second data are stored in a target memory area, where the target memory area is a part of the physical memory area pre-divided from the physical memory area.
[0011] In some embodiments, the KVM module includes a plurality of target pointers, each target pointer points to an address of a VMCS module corresponding to a corresponding virtual machine central processing unit CPU, and each target pointer corresponds to a different preset storage area;
[0012] Based on the target pointer, copying the second data from the VMCS module pointed to by the target pointer to a preset storage area includes:
[0013] For any target pointer, the second data is copied from the VMCS module pointed to by the target pointer to the preset storage area corresponding to the target pointer.
[0014] In some embodiments, obtaining the second data from a preset storage area includes:
[0015] The second data is loaded from the preset storage area to the target CPU through the first preset instruction, and the second data is obtained from the target CPU through the second preset instruction.
[0016] In some embodiments, the first preset instruction is a VMPTRLD instruction, and the second preset instruction is a VMREAD instruction.
[0017] In some embodiments, the method further comprises:
[0018] In the memory corresponding to the target CPU, a memory area of a preset size is divided for each virtual machine CPU as a preset storage area corresponding to each virtual machine CPU.
[0019] In some embodiments, when the kernel of the operating system crashes, writing the first data in the first register of the virtual machine into the kernel-based virtual machine KVM module, and writing the second data in the second register of the virtual machine and the virtual machine central processing unit CPU into the virtual machine control structure VMCS module includes:
[0020] In the case of a kernel crash of the operating system, the crashed CPU is controlled to trigger a non-maskable interrupt NMI request, and an NMI request is sent to each CPU in the kernel;
[0021] Controlling the virtual machine CPU in each CPU to respond to the NMI request, execute the virtual machine exit VM-Exit event, and when executing the VM-Exit event, write the first data in the first register of the virtual machine into the KVM module, and write the second data in the second register of the virtual machine into the VMCS module;
[0022] When the VM-Exit event is executed, a VMCLEAR instruction is executed to write the second data in the cache corresponding to each virtual machine CPU into the corresponding virtual machine CPU through the VMCLEAR instruction;
[0023] When the VMCLEAR instruction is executed, the second data in the virtual machine CPU is written into the corresponding VMCS module.
[0024] In some embodiments, the first register is a general register and the second register is a segment register.
[0025] According to a second aspect of one or more embodiments of this specification, a data processing device is provided, the device comprising:
[0026] a data writing unit, used for, in the case of a kernel crash of the operating system, writing first data in a first register of the virtual machine into a kernel-based virtual machine KVM module, and writing second data in a second register of the virtual machine and a central processing unit CPU of the virtual machine into a virtual machine control structure VMCS module, wherein the first register is used to store the first data as an operand or a result of an operation, and the second register is used to store the second data as a segment address;
[0027] An acquisition unit, used for acquiring the first data from the KVM module, and acquiring a target pointer from the KVM module, wherein the target pointer points to an address of a VMCS module for storing the second data;
[0028] A copying unit, configured to copy the second data from the VMCS module pointed to by the target pointer to a preset storage area based on the target pointer, where the preset storage area is located in a memory corresponding to the target CPU;
[0029] The acquiring unit is further used to acquire the second data from the preset storage area;
[0030] The storage unit is used to store the first data and the second data in a target memory area, where the target memory area is a part of the physical memory area pre-divided from the physical memory area.
[0031] In some embodiments, the KVM module includes a plurality of target pointers, each target pointer points to an address of a VMCS module corresponding to a corresponding virtual machine central processing unit CPU, and each target pointer corresponds to a different preset storage area;
[0032] The copying unit, when used to copy the second data from the VMCS module pointed to by the target pointer to the preset storage area based on the target pointer, is used to:
[0033] For any target pointer, the second data is copied from the VMCS module pointed to by the target pointer to the preset storage area corresponding to the target pointer.
[0034] In some embodiments, the acquiring unit, when used to acquire the second data from the preset storage area, is used to:
[0035] The second data is loaded from the preset storage area to the target CPU through the first preset instruction, and the second data is obtained from the target CPU through the second preset instruction.
[0036] In some embodiments, the first preset instruction is a VMPTRLD instruction, and the second preset instruction is a VMREAD instruction.
[0037] In some embodiments, the apparatus further comprises:
[0038] The partitioning unit is used to partition a memory area of a preset size for each virtual machine CPU in the memory corresponding to the target CPU as a preset storage area corresponding to each virtual machine CPU.
[0039] In some embodiments, the data writing unit, when used to write the first data in the first register of the virtual machine into the kernel-based virtual machine KVM module and write the second data in the second register of the virtual machine and the virtual machine central processing unit CPU into the virtual machine control structure VMCS module in the case that the kernel of the operating system crashes, is used to:
[0040] In the case of a kernel crash of the operating system, the crashed CPU is controlled to trigger a non-maskable interrupt NMI request, and an NMI request is sent to each CPU in the kernel;
[0041] Controlling the virtual machine CPU in each CPU to respond to the NMI request, execute the virtual machine exit VM-Exit event, and when executing the VM-Exit event, write the first data in the first register of the virtual machine into the KVM module, and write the second data in the second register of the virtual machine into the VMCS module;
[0042] When the VM-Exit event is executed, a VMCLEAR instruction is executed to write the second data in the cache corresponding to each virtual machine CPU into the corresponding virtual machine CPU through the VMCLEAR instruction;
[0043] When the VMCLEAR instruction is executed, the second data in the virtual machine CPU is written into the corresponding VMCS module.
[0044] In some embodiments, the first register is a general register and the second register is a segment register.
[0045] According to a third aspect of one or more embodiments of this specification, a computing device is provided, the computing device comprising:
[0046] processor;
[0047] a memory for storing processor-executable instructions;
[0048] The processor implements the operations performed by the data processing method provided in the first aspect and any embodiment of the first aspect by running executable instructions.
[0049] According to the fourth aspect of one or more embodiments of this specification, a computer-readable storage medium is proposed, on which computer instructions are stored. When the instructions are executed by a processor, the operations performed by the data processing method provided in the above-mentioned first aspect and any embodiment of the first aspect are implemented.
[0050] According to the fifth aspect of one or more embodiments of this specification, a computer program product is proposed, including a computer program, which, when executed by a processor, implements the operations performed by the data processing method provided in the above-mentioned first aspect and any embodiment of the first aspect.
[0051] The present application divides a part of the area from the physical memory area in advance as the target memory area, so that when the kernel of the operating system crashes, the first data in the first register of the virtual machine can be written into the KVM module, and the second data in the second register of the virtual machine and the CPU of the virtual machine can be written into the VMCS module, so as to obtain the first data and a target pointer pointing to the address of the VMCS module for storing the second data from the KVM module, and then based on the target pointer, copy the second data from the VMCS module pointed to by the target pointer to a preset storage area, and then obtain the second data from the preset storage area, so as to store the first data and the second data in the target memory area, so as to realize the preservation of the CPU state and the kernel state of the virtual machine in the case of a kernel crash of the operating system. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a flowchart of a data processing method provided by an exemplary embodiment.
[0053] Figure 2 is a flow chart of a data writing process provided by an exemplary embodiment.
[0054] Figure 3 It is an overall architecture diagram of a data processing method provided by an exemplary embodiment.
[0055] Figure 4 It is a flowchart of a data processing method provided by an exemplary embodiment.
[0056] Figure 5 It is a block diagram of a data processing device provided by an exemplary embodiment.
[0057] Figure 6 It is a schematic structural diagram of a computing device provided by an exemplary embodiment. DETAILED DESCRIPTION
[0058] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0059] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0060] The present application provides a data processing method for dumping data in a central processing unit (CPU) and data in registers of a virtual machine when the kernel of an operating system crashes, so that the dumped data related to the virtual machine can be subsequently obtained, thereby providing data support for analyzing the cause of the kernel crash.
[0061] The above data processing method can be executed by a computing device, which can be a server, such as a server, multiple servers, a server cluster, a cloud computing platform, etc. This application does not limit the device type and number of computing devices. It should be noted that the operating system installed on the computing device can be a Linux operating system.
[0062] Among them, the kernel of the computing device may include multiple CPUs, and these multiple CPUs may include both the host CPU and the virtual machine CPU. Each CPU has corresponding registers (including general registers and segment registers). Through the data processing method provided by the present application, when the kernel of the operating system crashes, the virtual machine CPU and the data in the registers of the virtual machine can be dumped to the target memory area of the computing device, and the host CPU and the data in the registers of the host can be dumped to the memory of the computing device through the Kdump service, so that the data corresponding to each CPU when the kernel crashes can be obtained from the memory of the computing device, and then the cause of the kernel crash can be analyzed based on the obtained data.
[0063] The above is an introduction to the application environment of the present application. The following is an explanation of the implementation process of the data processing method provided by the present application.
[0064] See also Figure 1 , Figure 1 is a flowchart of a data processing method provided by an exemplary embodiment, the method comprising:
[0065] Step 101. In the event that the kernel of the operating system crashes, the first data in the first register of the virtual machine is written into the kernel-based virtual machine KVM module, and the second data in the second register of the virtual machine and the virtual machine central processing unit CPU is written into the virtual machine control structure VMCS module, wherein the first register is used to store the first data as an operand or a calculation result, and the second register is used to store the second data as a segment address.
[0066] It should be noted that the kernel crash of the operating system may be caused by a failure in the operation of the CPU in the kernel, and the failed CPU may be the host CPU or the virtual machine CPU in the root operation mode, which is not limited in this application. However, it should be noted that for the virtual machine CPU in the non-root operation mode, when the operation of the virtual machine CPU in the non-root operation mode fails, the kernel crash of the operating system will not be caused.
[0067] Among them, the kernel-based virtual machine (KVM) module is a kernel module in the operating system, which can be used to temporarily store data in the first register of the virtual machine when the kernel crashes. In addition, the KVM module can also be used to store a target pointer pointing to the address of the VMCS module.
[0068] The Virtual Machine Control Structure (VMCS) module is a physical memory area of a set size in the physical memory, which can be used to temporarily store the second register of the virtual machine and the data in the virtual machine CPU when the kernel crashes.
[0069] Step 102: Acquire the first data from the KVM module, and acquire a target pointer from the KVM module, where the target pointer points to an address of a VMCS module for storing the second data.
[0070] Step 103: Based on the target pointer, copy the second data from the VMCS module pointed to by the target pointer to a preset storage area, where the preset storage area is located in the memory corresponding to the target CPU.
[0071] The target CPU may be a CPU specifically used to save the CPU state and kernel state of the virtual machine when the kernel of the operating system crashes.
[0072] Step 104: Acquire the second data from the preset storage area, and store the first data and the second data in the target memory area, where the target memory area is a part of the physical memory area pre-divided from the physical memory area.
[0073] The present application divides a part of the area from the physical memory area in advance as the target memory area, so that when the kernel of the operating system crashes, the first data in the first register of the virtual machine can be written into the KVM module, and the second data in the second register of the virtual machine and the CPU of the virtual machine can be written into the VMCS module, so as to obtain the first data and the target pointer pointing to the address of the VMCS module from the KVM module, and then based on the target pointer, copy the second data from the VMCS module pointed to by the target pointer to the preset storage area, and then obtain the second data from the preset storage area, so as to store the first data and the second data in the target memory area, so as to realize the preservation of the CPU state and the kernel state of the virtual machine in the case of the kernel crash of the operating system.
[0074] After introducing the basic implementation process of the present application, the data processing method provided by the present application is further explained below in combination with multiple optional embodiments of the present application.
[0075] In some embodiments, for step 101, when writing the first data in the first register of the virtual machine into the kernel-based virtual machine KVM module, and writing the second data in the second register of the virtual machine and the virtual machine central processing unit CPU into the virtual machine control structure VMCS module, the following steps may be included:
[0076] Step 1011: When the kernel of the operating system crashes, the crashed CPU is controlled to trigger a non-maskable interrupt NMI request, and the NMI request is sent to each CPU in the kernel.
[0077] It should be noted that, in the event of an operating system kernel crash (that is, a failure occurs in the operation of the host CPU in the kernel, and / or a failure occurs in the operation of the virtual machine CPU in the root operation mode in the kernel), the crashed CPU will automatically perform a crash handling process to trigger a non-maskable interrupt (NMI) request, and send the triggered NMI request to each CPU in the kernel, including the host CPU and the virtual machine CPU.
[0078] Step 1012, control the virtual machine CPU in each CPU to respond to the NMI request, execute the virtual machine exit VM-Exit event, and when executing the VM-Exit event, write the first data in the first register of the virtual machine into the KVM module, and write the second data in the second register of the virtual machine into the VMCS module.
[0079] In addition, the host CPU among the CPUs may stop the ongoing task in response to the NMI request.
[0080] Through the above process, it can be ensured that each CPU in the kernel no longer executes tasks at this time, so that the data processing scene when the kernel crashes can be captured later.
[0081] Step 1013: When the VM-Exit event is executed, execute the VMCLEAR instruction to write the second data in the cache corresponding to each virtual machine CPU into the corresponding virtual machine CPU through the VMCLEAR instruction.
[0082] Through the VMCLEAR instruction (or VMCS clear instruction), the data in the cache of each virtual machine can be flushed to the CPU of the virtual machine, thereby reducing the occurrence of data asynchrony in the CPUs of each virtual machine due to possible cache.
[0083] Step 1014: When the VMCLEAR instruction is executed, the second data in the virtual machine CPU is written into the corresponding VMCS module.
[0084] Through the above step 1013, the synchronization of data in each virtual machine CPU can be guaranteed. In this case, the second data in the virtual machine CPU is written into the VMCS module so that the data being processed in the CPU when the kernel crashes can be subsequently obtained from the VMCS module, thereby ensuring the integrity of the data dumped when the kernel crashes.
[0085] The implementation process of the above embodiment can be found in Figure 2 , Figure 2 is a flow chart of a data writing process provided by an exemplary embodiment. Figure 2 As shown, in the case of a kernel crash of the computing device, the computing device sends an NMI request to each CPU it includes. When each virtual machine CPU receives the NMI request, it can automatically execute the VM-Exit event, and when the VM-Exit event is executed, the data in the cache corresponding to each virtual machine CPU is synchronized to the corresponding virtual machine CPU through the VMCLEAR instruction.
[0086] In some embodiments, the first register may be a general register and the second register may be a segment register.
[0087] Among them, general registers can be used to transmit and temporarily store data, and can also participate in arithmetic and logical operations and save the results of operations. Taking a 16-bit CPU as an example, a 16-bit CPU can include 8 types of general registers, namely, Accumulator Register (AX), Base Register (BX), Count Register (CX), Data Register (DX), Base Pointer Register (BP), Stack Pointer Register (SP), Source Index Register (SI), Destination Index Register (DI). These 8 types of general registers can all be used as ordinary data registers.
[0088] Segment registers are set based on the memory segmentation management. Different segment registers are assigned to memory in different address segments. Segment registers can include code segment register (CS), data segment register (DS), stack segment register (SS) and extra segment register (ES).
[0089] Through the above process, the first data in the first register of the virtual machine (such as the general register) has been exported to the KVM module, and the second register of the virtual machine (such as the segment register) and the data in the virtual machine CPU have been exported to the VMCS module. Therefore, data dumping when the kernel crashes can be achieved based on the data in the KVM module and the VMCS module.
[0090] In addition, after writing the second register of the virtual machine and the second data in the virtual machine CPU into the VMCS module, the address of the VMCS module of each virtual machine can be obtained, thereby generating a target pointer based on the obtained address, and then storing the target pointer in the KVM module, so that the second data can be copied based on the target pointer in the KVM module later. The obtained address of the VMCS module can be the physical address of the VMCS module.
[0091] It should be noted that when generating a target pointer based on the acquired address of the VMCS module, a target pointer can be generated for the address of each VMCS module, so that multiple target pointers pointing to the addresses of multiple VMCS modules can be obtained, and then the generated multiple target pointers are all stored in the KVM module, so that the KVM module can include multiple target pointers, each target pointer pointing to the address of the VMCS module corresponding to the corresponding virtual machine CPU.
[0092] For example, there are 5 virtual machine CPUs in the kernel, and accordingly, there are 5 VMCS modules. Therefore, 5 target pointers can be generated, each of which points to the address of a VMCS module.
[0093] For the first data that has been stored in the KVM module, since the KVM module can be directly read by the virtual machine CPU, the first data can be directly obtained from the KVM module. However, for the second data that has been stored in the VMCS module, since the virtual machine CPU cannot directly read the data from the VMCS module, the second data can be obtained from the VMCS module through the following process.
[0094] In some embodiments, a memory area of a preset size can be pre-allocated in the memory corresponding to the target CPU for each virtual machine CPU as a preset storage area corresponding to each virtual machine CPU that meets the target condition, so that the second data in the VMCS module of each virtual machine can be copied to the corresponding preset storage area, so that the second data can be read from the preset storage area. It should be noted that the target CPU can be a CPU of a kernel module specifically used to dump data corresponding to the virtual machine.
[0095] Among them, the VMCS module is part of the memory, and its size is fixed at 4 kilobytes (KB), that is, the VMCS module is a 4K page. Therefore, when a memory area of a preset size is divided for each virtual machine CPU, the preset size can also be 4KB, thereby reducing the waste of memory resources of the computing device.
[0096] After a preset storage area of a preset size is divided for each virtual machine CPU in the memory corresponding to the target CPU, the second data can be read through the preset storage area.
[0097] It should be noted that, since a preset storage area of a preset size is allocated for each virtual machine CPU, data in different virtual machines can be stored in different preset storage areas, that is, the preset storage area corresponding to each target pointer can be different.
[0098] In some embodiments, for step 103, when the second data is copied from the VMCS module pointed to by the target pointer to the preset storage area based on the target pointer, it can be implemented in the following manner:
[0099] For any target pointer, the second data is copied from the VMCS module pointed to by the target pointer to the preset storage area corresponding to the target pointer.
[0100] By copying the second data based on the target pointer, the second data corresponding to each virtual machine can be copied to the respective corresponding preset storage areas, so that the second data corresponding to different virtual machines can be stored in different preset storage areas, and the block storage of the second data corresponding to different virtual machines is realized, so that the required second data can be read from the corresponding position later.
[0101] In addition, by copying the second data from the VMCS module to the preset storage area, the virtual machine CPU can obtain the same data as the data stored in the VMCS module from the preset storage area, which is equivalent to realizing the acquisition of the second data in the VMCS module, so as to overcome the problem in the related art that the virtual machine CPU cannot directly read data from the VMCS module.
[0102] After the second data is copied from the VMCS module to the corresponding preset storage area, the second data can be obtained from the preset storage area. In some embodiments, for step 104, when the second data is obtained from the preset storage area, it can be implemented as follows:
[0103] The second data is loaded from the preset storage area to the target CPU through the first preset instruction, and the second data is obtained from the target CPU through the second preset instruction.
[0104] The first preset instruction may be a VMPTRLD instruction, and the second preset instruction may be a VMREAD instruction.
[0105] After obtaining the second data, the first data and the second data can be stored in the target memory area through step 104, and the data related to the operation status of the virtual machine when the kernel crashes can be obtained from the target memory area later, so that when Kdump captures the kernel memory, the first data and the second data located in the target memory area can be saved to the disk together, so that after the computing device is restarted, the kernel crash situation can be analyzed based on the first data and the second data in the disk.
[0106] The target memory area may be a portion of the physical memory area that is pre-divided from the physical memory area of the computing device before the virtual machine is started, and is used as a location for storing virtual machine related data after the kernel crashes. Since the amount of virtual machine related data is very small, when dividing the target memory area, a memory area of 1 megabyte (M) in size may be divided from the physical memory area as the target memory area. That is, the method of dividing the target memory area from the physical memory area of the computing device and storing virtual machine related data after the kernel crashes occupies very little memory resources of the computing device.
[0107] First, the second data is read from the preset storage area through a specific preset instruction, and then the second data is stored in a target memory area that does not need to be read through a specific instruction, so that when Kdump captures the kernel memory later, the first data and the second data can be directly obtained from the target memory area without reading through a specific instruction.
[0108] It should be noted that the data processing methods in each of the above-mentioned embodiments can be implemented through corresponding functions. Therefore, in some embodiments, the functions used to implement the above-mentioned data processing methods can be registered in advance, so that when the kernel crashes, the registered functions can be directly called to capture the data corresponding to each virtual machine when the kernel crashes through the data processing method provided by this application.
[0109] In a possible implementation, when registering the function for implementing the above data processing method, the function for implementing the above data processing method may be registered to a kernel crash notification chain.
[0110] Among them, the kernel crash notification chain Linux kernel crash processing function pointer linked list is used to notify the kernel modules to perform final processing after the kernel crashes. By registering the function used to implement the data processing method of the present application to the kernel crash notification chain, the function registered in the kernel crash notification chain can be automatically executed after the kernel crashes, thereby capturing the data corresponding to each virtual machine at the time of the kernel crash.
[0111] The overall architecture of the data processing method described in the above embodiments can be found in Figure 3 , Figure 3 This is an overall architecture diagram of a data processing method provided by an exemplary embodiment. The computing device as a host machine may include multiple virtual machine CPUs, such as Figure 3 As shown, the computing device as the host includes 2 virtual machines, and each virtual machine may include 2 CPUs, so that the computing device as the host includes 4 virtual machine CPUs. In the case of a kernel crash of the computing device, the function registered in the kernel crash notification chain may be called to save the data of the virtual machine CPU through the data processing method provided by the present application, and then the saved data is stored in the target memory area divided from the physical memory area of the host, so as to analyze the cause of the crash based on the data of the virtual machine CPU in the target memory area.
[0112] based on Figure 3 The overall architecture provided and the process of the data processing method provided in this application can be found in Figure 4 , Figure 4 is a flow chart of a data processing method provided by an exemplary embodiment. Figure 4 As shown, in the case of a kernel crash, the crashed CPU can send an NMI request to all CPUs, and the virtual machine CPU that receives the NMI request can execute a VM-Exit event, and when the VM-Exit event is executed, execute a VMCS clear instruction (that is, a VMCLEAR instruction), thereby saving the virtual machine CPU data to the reserved memory (that is, the target memory area) through the function registered in the kernel crash notification chain, so that Kdump can capture the virtual machine CPU data in the reserved memory to the disk when capturing the kernel memory to the disk, so that after the host machine is restarted, the cause of the crash can be analyzed based on the data in the disk. The above is only a procedural description of the data processing method of the present application. The specific implementation of each step can be referred to the above embodiments, which will not be repeated here.
[0113] Corresponding to the aforementioned method embodiments, this specification also provides embodiments of an apparatus and a computing device used therein.
[0114] See also Figure 5 , Figure 5 is a block diagram of a data processing device provided by an exemplary embodiment, the device comprising:
[0115] a data writing unit, used for, in the case of a kernel crash of the operating system, writing first data in a first register of the virtual machine into a kernel-based virtual machine KVM module, and writing second data in a second register of the virtual machine and a central processing unit CPU of the virtual machine into a virtual machine control structure VMCS module, wherein the first register is used to store the first data as an operand or a result of an operation, and the second register is used to store the second data as a segment address;
[0116] An acquisition unit, used for acquiring the first data from the KVM module, and acquiring a target pointer from the KVM module, wherein the target pointer points to an address of a VMCS module for storing the second data;
[0117] A copying unit, configured to copy the second data from the VMCS module pointed to by the target pointer to a preset storage area based on the target pointer, where the preset storage area is located in a memory corresponding to the target CPU;
[0118] The acquiring unit is further used to acquire the second data from the preset storage area;
[0119] The storage unit is used to store the first data and the second data in a target memory area, where the target memory area is a part of the physical memory area pre-divided from the physical memory area.
[0120] In some embodiments, the KVM module includes a plurality of target pointers, each target pointer points to an address of a VMCS module corresponding to a corresponding virtual machine central processing unit CPU, and each target pointer corresponds to a different preset storage area;
[0121] The copying unit, when used to copy the second data from the VMCS module pointed to by the target pointer to the preset storage area based on the target pointer, is used to:
[0122] For any target pointer, the second data is copied from the VMCS module pointed to by the target pointer to the preset storage area corresponding to the target pointer.
[0123] In some embodiments, the acquiring unit, when used to acquire the second data from the preset storage area, is used to:
[0124] The second data is loaded from the preset storage area to the target CPU through the first preset instruction, and the second data is obtained from the target CPU through the second preset instruction.
[0125] In some embodiments, the first preset instruction is a VMPTRLD instruction, and the second preset instruction is a VMREAD instruction.
[0126] In some embodiments, the apparatus further comprises:
[0127] The partitioning unit is used to partition a memory area of a preset size for each virtual machine CPU in the memory corresponding to the target CPU as a preset storage area corresponding to each virtual machine CPU.
[0128] In some embodiments, the data writing unit, when used to write the first data in the first register of the virtual machine into the kernel-based virtual machine KVM module and write the second data in the second register of the virtual machine and the virtual machine central processing unit CPU into the virtual machine control structure VMCS module in the case that the kernel of the operating system crashes, is used to:
[0129] In the case of a kernel crash of the operating system, the crashed CPU is controlled to trigger a non-maskable interrupt NMI request, and an NMI request is sent to each CPU in the kernel;
[0130] Controlling the virtual machine CPU in each CPU to respond to the NMI request, execute the virtual machine exit VM-Exit event, and when executing the VM-Exit event, write the first data in the first register of the virtual machine into the KVM module, and write the second data in the second register of the virtual machine into the VMCS module;
[0131] When the VM-Exit event is executed, a VMCLEAR instruction is executed to write the second data in the cache corresponding to each virtual machine CPU into the corresponding virtual machine CPU through the VMCLEAR instruction;
[0132] When the VMCLEAR instruction is executed, the second data in the virtual machine CPU is written into the corresponding VMCS module.
[0133] In some embodiments, the first register is a general register and the second register is a segment register.
[0134] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0135] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this specification. Ordinary technicians in this field can understand and implement it without paying creative work.
[0136] The present application also provides a computing device, see Figure 6 , Figure 6 is a schematic structural diagram of a computing device provided by an exemplary embodiment. Figure 6 At the hardware level, the device includes a processor 602, an internal bus 604, a network interface 606, a memory 608, and a non-volatile memory 610, and may also include hardware required to implement other functions. One or more embodiments of this specification may be implemented based on software, such as the processor 602 reading the corresponding computer program from the non-volatile memory 610 into the memory 608 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0137] The present application also provides a computer program product, including a computer program, which implements the data generation method provided in any embodiment of the present application when the computer program is executed by a processor.
[0138] The systems, devices or modules described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0139] In a typical configuration, a computer includes one or more processors (Central Processing Unit, CPU), input / output interface, network interface and memory.
[0140] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0141] Computer readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. According to the definition in this article, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0142] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0143] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0144] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0145] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0146] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.
Claims
1. A data processing method, characterized in that: The method comprises: In the case of a kernel crash of the operating system, first data in a first register of the virtual machine is written into a kernel-based virtual machine KVM module, and second data in a second register of the virtual machine and a central processing unit CPU of the virtual machine is written into a virtual machine control structure VMCS module, wherein the first register is used to store the first data as an operand or a calculation result, and the second register is used to store the second data as a segment address; Acquire the first data from the KVM module, and acquire a target pointer from the KVM module, the target pointer pointing to an address of the VMCS module for storing second data; Based on the target pointer, copying the second data from the VMCS module pointed to by the target pointer to a preset storage area, wherein the preset storage area is located in a memory corresponding to the target CPU; Acquire the second data from the preset storage area, and store the first data and the second data in a target memory area, where the target memory area is a part of the physical memory area pre-divided from the physical memory area; The KVM module includes a plurality of target pointers, each of which points to an address of a VMCS module corresponding to a central processing unit (CPU) of a corresponding virtual machine, and each of which corresponds to a different preset storage area.
2. The method according to claim 1, characterized in that The step of copying the second data from the VMCS module pointed to by the target pointer to a preset storage area based on the target pointer includes: For any target pointer, the second data is copied from the VMCS module pointed to by the target pointer to a preset storage area corresponding to the target pointer.
3. The method according to claim 1, characterized in that The acquiring the second data from the preset storage area includes: The second data is loaded from the preset storage area to the target CPU through a first preset instruction, and the second data is acquired from the target CPU through a second preset instruction.
4. The method according to claim 3, characterized in that The first preset instruction is a VMPTRLD instruction, and the second preset instruction is a VMREAD instruction.
5. The method according to claim 3, characterized in that: The method further comprises: In the memory corresponding to the target CPU, a memory area of a preset size is divided for each virtual machine CPU as a preset storage area corresponding to each virtual machine CPU.
6. The method according to claim 1, characterized in that In the case where the kernel of the operating system crashes, the first data in the first register of the virtual machine is written into the kernel-based virtual machine KVM module, and the second data in the second register of the virtual machine and the virtual machine central processing unit CPU is written into the virtual machine control structure VMCS module, including: In the case of a kernel crash of the operating system, controlling the crashed CPU to trigger a non-maskable interrupt NMI request, and sending the NMI request to each CPU in the kernel; Controlling the virtual machine CPU in each CPU to respond to the NMI request, execute the virtual machine exit VM-Exit event, and when executing the VM-Exit event, write the first data in the first register of the virtual machine into the KVM module, and write the second data in the second register of the virtual machine into the VMCS module; When the VM-Exit event is executed, a VMCLEAR instruction is executed to write the second data in the cache corresponding to each virtual machine CPU into the corresponding virtual machine CPU through the VMCLEAR instruction; When the VMCLEAR instruction is executed, the second data in the virtual machine CPU is written into the corresponding VMCS module.
7. The method according to any one of claims 1 to 6, characterized in that: The first register is a general register, and the second register is a segment register.
8. A data processing device, characterized in that: The device comprises: a data writing unit, used for, in the case of a kernel crash of the operating system, writing first data in a first register of the virtual machine into a kernel-based virtual machine KVM module, and writing second data in a second register of the virtual machine and a central processing unit CPU of the virtual machine into a virtual machine control structure VMCS module, wherein the first register is used to store first data as an operand or a result of operation, and the second register is used to store second data as a segment address; an acquisition unit, configured to acquire the first data from the KVM module, and acquire a target pointer from the KVM module, wherein the target pointer points to an address of the VMCS module for storing the second data; a copying unit, configured to copy the second data from the VMCS module pointed to by the target pointer to a preset storage area based on the target pointer, wherein the preset storage area is located in a memory corresponding to the target CPU; The acquisition unit is further configured to acquire the second data from the preset storage area; A storage unit, used for storing the first data and the second data in a target memory area, wherein the target memory area is a part of a physical memory area pre-divided from a physical memory area; The KVM module includes a plurality of target pointers, each of which points to an address of a VMCS module corresponding to a central processing unit (CPU) of a corresponding virtual machine, and each of which corresponds to a different preset storage area.
9. A computing device, characterized in that The computing device comprises: processor; a memory for storing processor-executable instructions; The processor implements the data processing method according to any one of claims 1 to 7 by running the executable instructions.
10. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instructions are executed by a processor, the data processing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Modular computer forensic system and method based on hardware virtualization
CN104021063A
Virtual machine crash management
US20150161008A1