System startup memory detection method and device, equipment and storage medium

By calculating the early virtual address mapping range during the hypervisor startup phase and outputting an error prompt when detecting memory page address exceeds, the problem of difficulty in troubleshooting mapping anomalies during the hypervisor startup phase is solved, and memory error detection is achieved before the system crashes.

CN120523747BActive Publication Date: 2025-10-10KYLIN CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511007047.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-22
Publication Date
2025-10-10
Estimated Expiration
2045-07-22

AI Technical Summary

Technical Problem

In the prior art, a memory detection method for a hypervisor during the startup phase has the problem that mapping anomalies make troubleshooting difficult.

Method used

By calculating the maximum value of the early virtual address mapping range of the Hypervisor before the final page table takes effect, the base address of the allocated memory page is used to detect whether the virtual address range of the allocated memory page exceeds the maximum value, and an error prompt is output if it exceeds the maximum value.

Benefits of technology

This enables accurate detection of memory errors before the system crashes, making it easier for developers to locate the cause of the failure and reducing the possibility of inaccurate traditional estimates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120523747B_ABST
    Figure CN120523747B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a system startup memory detection method, device, equipment and storage medium, the method comprises: before the final page table takes effect, the maximum value of the early virtual address mapping range of Hypervisor is calculated according to the first address of Hypervisor running;When allocating memory pages by using a dynamic allocation pool, the virtual address range of the allocated memory page is determined by using the base address of the allocated memory page, and it is detected whether the virtual address range of the allocated memory page exceeds the maximum value of the early virtual address mapping range of Hypervisor;When exceeding the maximum value of the early virtual address mapping range of Hypervisor, an error prompt is output, and a memory error is returned.Compared with the traditional estimation method, the possibility of inaccurate estimation caused by changes in dynamic allocation is reduced, the memory error can be accurately detected in advance before the system crashes, and the developer can locate the cause of the crash.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Hypervisor technology, and in particular to a system startup memory detection method, device, equipment and storage medium. Background Art

[0002] During the Jailhouse Hypervisor boot process, when the memory management unit (MMU) is enabled, a simple temporary page table is created to support memory access during the early initialization phase. This temporary page table is typically a three-level page table structure used to map virtual addresses to physical addresses. After initialization is complete, a continuous mapped address space is obtained.

[0003] During the hypervisor's startup phase, it pre-establishes a physical memory pool for dynamic allocation of physical page frames. Free physical pages are managed using a bitmap or linked list, ensuring rapid allocation of physical memory before the page table takes effect. Page table pages (such as those in multi-level page tables) are not allocated all at once but are allocated dynamically as needed. If an allocated memory page is not mapped, an error will occur, leading to a system crash without any error output, making troubleshooting difficult. Summary of the Invention

[0004] The embodiments of the present invention provide a system startup memory detection method, apparatus, device and storage medium to solve the technical problem in the prior art that faults caused by abnormal hypervisor mapping during the startup phase are difficult to troubleshoot.

[0005] In a first aspect, an embodiment of the present invention provides a system startup memory detection method, comprising:

[0006] Before the final page table takes effect, the maximum value of the hypervisor's early virtual address mapping range is calculated based on the first address of the hypervisor operation;

[0007] When allocating memory pages using the dynamic allocation pool, the base address of the allocated memory page is used to determine the virtual address range of the allocated memory page, and whether the virtual address range of the allocated memory page exceeds the maximum value of the early virtual address mapping range of the hypervisor;

[0008] When the maximum value of the Hypervisor's early virtual address mapping range is exceeded, an error message is output and a memory error is returned.

[0009] In a second aspect, an embodiment of the present invention further provides a system startup memory detection device, comprising:

[0010] A calculation module is used to calculate the maximum value of the early virtual address mapping range of the hypervisor based on the first address of the hypervisor operation before the final page table takes effect;

[0011] a detection module, configured to determine a virtual address range of the allocated memory page using a base address of the allocated memory page when allocating the memory page using the dynamic allocation pool, and to detect whether the virtual address range of the allocated memory page exceeds a maximum value of an early virtual address mapping range of the hypervisor;

[0012] The output module is used to output an error prompt and return a memory error when the maximum value of the early virtual address mapping range of the Hypervisor is exceeded.

[0013] In a third aspect, an embodiment of the present invention further provides a device for configuring a jailhouse hypervisor, including:

[0014] one or more processors;

[0015] a storage device for storing one or more programs,

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the system startup memory detection method as described in any one of the above embodiments.

[0017] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the system startup memory detection method provided in the above embodiment.

[0018] The system startup memory detection method, apparatus, device, and storage medium provided by the embodiments of the present invention calculate the maximum value of the hypervisor's early virtual address mapping range based on the first address of the hypervisor operation before the final page table takes effect. When allocating memory pages using the dynamic allocation pool, the base address of the allocated memory page is used to determine the allocated memory page virtual address range, and detect whether the allocated memory page virtual address range exceeds the maximum value of the hypervisor's early virtual address mapping range. If the maximum value of the hypervisor's early virtual address mapping range is exceeded, an error prompt is output and a memory error is returned. The maximum range value of the virtual address determined in the early mapping process can be calculated based on the characteristics of the hypervisor operation.

[0019] Since the virtual address has continuity, the base address can be used to determine the memory page virtual address range. When a new CPU is allocated, it is determined whether the allocated address is within the memory page virtual address range, whether the memory is incorrect, and a specific prompt can be returned for such errors. Compared with the traditional estimation method, the possibility of inaccurate estimation caused by changes in dynamic allocation is reduced, the memory error can be accurately detected in advance before the system crashes, and the developer can locate the cause of the crash. BRIEF DESCRIPTION OF DRAWINGS

[0020] Other features, objects and advantages of the present application will become more apparent from the following detailed description of non-limiting embodiments thereof, read in conjunction with the accompanying drawings:

[0021] Figure 1 is a flowchart of a system startup memory detection method provided by an embodiment of the present application;

[0022] Figure 2 is a flowchart of a system startup memory detection method provided by an embodiment of the present application;

[0023] Figure 3 is a schematic diagram of the memory layout of the jailhouse Hypervisor in the system startup memory detection method provided by the second embodiment of the present application;

[0024] Figure 4 is a structural schematic diagram of a system startup memory detection device provided by an embodiment of the present application;

[0025] Figure 5 is a structural schematic diagram of a device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0026] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application. In addition, it should be noted that, for the sake of description, only the parts related to the present application are shown in the drawings, not all the structures.

[0027] Embodiment 1

[0028] Figure 1 is a flowchart of a system startup memory detection method provided by an embodiment of the present application, which can be applicable to the case of checking memory errors caused by Hypervisor allocating memory pages before the final page table takes effect. The method can be executed by a system startup memory detection device, and specifically includes the following steps:

[0029] Step 110, before the final page table takes effect, a maximum value of the Hypervisor early virtual address mapping range is calculated according to the first address of the Hypervisor running.

[0030] Before the final page table takes effect, the Hypervisor needs to go through Stage 2 to realize the page table construction and activation. The function of the specific implementation is to realize the mapping between the physical address and the virtual address. The final page table corresponds to the memory virtual page table allocated for each CPU.

[0031] In the embodiment, the first address of the Hypervisor running can be obtained by reading the first address of the Hypervisor temporary page table from the key register of the memory management. Optionally, the key register of the memory management can be the TTBR0_EL2 register. Further, since the TTBR0_EL2 register stores the physical address of the temporary page table, the physical address of the temporary page table needs to be converted into a virtual address by the offset of the Hypervisor virtual address and the physical address, that is, the first address of the Hypervisor running is obtained. After the first address is obtained, the maximum value of the Hypervisor early virtual address mapping range can be calculated according to the size of the early virtual address mapping space generated in the initial stage.

[0032] Step 120, when the memory page is allocated by using the dynamic allocation pool, the base address of the allocated memory page is used to determine the virtual address range of the allocated memory page, and it is detected whether the virtual address range of the allocated memory page exceeds the maximum value of the Hypervisor early virtual address mapping range.

[0033] In the embodiment, the Hypervisor abstracts the physical memory into a shared memory pool for the system corresponding to multiple CPUs to share. The process is to allocate the memory page for each CPU in turn. And the page map of the initially formed page allocation pool is modified according to the memory page allocation result, so that the virtual address range of the corresponding allocated memory page can be determined according to the base address of the allocated memory page of each CPU.

[0034] After each allocation, the virtual address range of the memory page to be allocated for each CPU can be compared with the maximum value of the Hypervisor early virtual address mapping range obtained in the above step to determine whether the maximum value of the Hypervisor early virtual address mapping range is exceeded.

[0035] Step 130, when the maximum value of the Hypervisor early virtual address mapping range is exceeded, an error prompt is output, and a memory error is returned.

[0036] With the determination result of the above steps, when not exceeding, the memory page allocation of the next CPU is continued until all CPUs are allocated. When exceeding, an error prompt is output, and a memory error is returned in the program. Thus, a direct system crash without any prompt is avoided, and the developer can accurately locate the error according to the error prompt, facilitating the adjustment and optimization in the later period.

[0037] The embodiment calculates the maximum value of the early virtual address mapping range of the Hypervisor according to the start address of the Hypervisor running before the final page table takes effect; determines the virtual address range of the allocated memory page according to the base address of the allocated memory page when the memory page is allocated by using the dynamic allocation pool, detects whether the virtual address range of the allocated memory page exceeds the maximum value of the early virtual address mapping range of the Hypervisor, and outputs an error prompt and returns a memory error when the maximum value of the early virtual address mapping range of the Hypervisor is exceeded. The maximum value of the determined virtual address in the early mapping process can be calculated based on the characteristics of the Hypervisor. Since the virtual address has continuity, the virtual address range of the memory page can be determined by using the base address, the memory error can be determined according to whether the allocated address is in the virtual address range of the memory page when the new CPU is allocated, and a specific prompt can be returned for the error. Compared with the traditional estimation method, the possibility of inaccurate estimation caused by the change of the dynamic allocation is reduced, the memory error can be accurately detected in advance before the system crashes, and the developer can locate the cause of the system crash.

[0038] Embodiment Two

[0039] Figure 2 FIG. 1 is a flowchart of a system startup memory detection method provided by the embodiment two of the present application. The embodiment is optimized on the basis of the above embodiment, and the method can further include the following steps: reading the start address of the temporary page table of the Hypervisor from the key register of the memory management; searching the page table according to the start address of the Hypervisor running, calculating the size of the address space continuously mapped below the start address; calculating the data size used in the early initialization of the Hypervisor according to the memory layout of the jailhouse Hypervisor, and judging whether the data size used in the early initialization exceeds the size of the address space continuously mapped below the start address, and returning a Hypervisor initial failure memory error when the size exceeds.

[0040] Referring to Figure 2 , the system startup memory detection method comprises the following steps.

[0041] In step 210, the start address of the temporary page table of the Hypervisor is read from the key register of the memory management.

[0042] When performing early initialization, the temporary page table also corresponds to a mapped virtual address space range. According to the memory layout of the Jailhouse Hypervisor, the required memory during early initialization is not fixed, but is determined by multiple dynamic factors, including: Hypervisor image size: the size of the Hypervisor binary itself, which determines the code and static data footprint. PerCPU variable size: PerCPU variables are private copies for each CPU core to avoid lock contention when accessing multiple cores. The total memory consumption of PerCPU variables is directly proportional to the number of CPU cores, as each core requires an independent data copy. The allocation of space from the reserved memory during initialization, and the increase in the number of variables and cores, significantly expands the demand. CPU core number: the number of cores directly affects the total size of PerCPU variables and page table overhead. For example, more cores require more PerCPU copies and can increase the management burden of the page table hierarchy. Configuration file data size: Jailhouse configuration files (such as.cell files) define resource boundaries (such as memory regions and IOMMU cells), and these data are loaded into memory during startup, occupying additional space. The size of the configuration file depends on the complexity of the virtual machine (VM), such as the defined physical start address, size, and permission settings.

[0043] If the Hypervisor uses a virtual address space that exceeds the 2MB temporary mapping limit during early initialization, the system will immediately crash abnormally (such as a hardware fault or unhandled trap), and no error information will be output. This makes problem troubleshooting extremely difficult, as developers cannot obtain the crash context (such as the specific address or error code), and the log only shows an initialization interruption without detailed diagnostics. In traditional methods, this problem is solved by increasing the early virtual address mapping space, but this method is not a permanent solution because the memory requirement is dynamic and affected by the aforementioned factors (such as the number of CPU cores or the size of the configuration file). Increasing the space only temporarily alleviates the problem, not a permanent solution, so even if the mapping is expanded, it cannot ensure the safety of the early mapping. Therefore, in this embodiment, the memory also needs to be detected, and error information needs to be output when an exception occurs, to facilitate developers to locate the crash cause.

[0044] For example, the first address of the Hypervisor temporary page table can be read from the TTBR0_EL2 register.

[0045] Step 220, according to the first address of the Hypervisor running, retrieve the page table, calculate the size of the address space continuously mapped below the first address.

[0046] Exemplarily, the method may include: calculating an index value of a first-level page table mapped by the hypervisor according to the first address of the hypervisor, determining a first-level page table entry according to the index value of the first-level page table, and obtaining a second-level page table base address from the first-level page table entry;

[0047] According to the first address of the hypervisor, the index value of the second-level page table mapped by the hypervisor is calculated. According to the second-level page table base address and the index value of the second-level page table, the second-level page table entry is determined. The third-level page table base address is obtained from the second-level page table entry.

[0048] According to the first address of the hypervisor operation, the index value of the third-level page table mapped by the hypervisor is calculated, the third-level page table entry is determined according to the third-level page table base address and the index value of the third-level page table, and the size of the address space continuously mapped below the first address is determined according to the third-level page table entry.

[0049] Optionally, the index value of the first-level page table mapped by the Hypervisor can be calculated based on the first address of the Hypervisor operation, which is a virtual address specified by the Hypervisor during compilation. The index value can be the value of bit

[39] to bit

[47] of the virtual address. The first-level page table entry is obtained by adding the base address of the Hypervisor temporary page table to the index value of the first-level page table. This entry is the physical address of the base address of the second-level page table. Then, the physical address of the base address of the second-level page table is converted into a virtual address through the offset between the virtual address and the physical address of the Hypervisor.

[0050] Then, based on the first address of the Hypervisor, calculate the index value of the second-level page table mapped by the Hypervisor, and the value of bits

[30] to

[38] of the virtual address. Add the base address of the second-level page table obtained in the above steps to the index value of the second-level page table to obtain the second-level page table entry, which is the physical address of the base address of the third-level page table. Then, through the offset between the virtual address and the physical address of the Hypervisor, convert the physical address of the base address of the third-level page table into a virtual address.

[0051] Then, based on the first address of the hypervisor, calculate the index value of the third-level page table mapped by the hypervisor, and the values ​​of bits

[21] to

[29] of the virtual address. The third-level page table entry is obtained by adding the base address of the third-level page table obtained in the above steps to the index value of the third-level page table. This entry is the first entry in the hypervisor address mapping, and the scope of this entry is 2MB.

[0052] Correspondingly, determining the size of the address space continuously mapped below the first address based on the third-level page table entry may include: reading the first entry of the third-level page table, judging whether there is a valid flag based on the flag bit in the first entry, and when there is a valid flag, marking the size of the continuously mapped address space as the initial set page space size; reading the next entry, judging whether there is a valid flag based on the flag bit in the next entry, and when there is a valid flag, marking the size of the continuously mapped space as twice the initial set page space size, otherwise, marking the size of the continuously mapped address space as the size of the continuously mapped address space marked by the last entry; returning to the step of reading the next entry until there is no valid flag in the flag bit.

[0053] The Hypervisor temporary page table is a three-level page table, and the memory used for early Hypervisor initialization only creates block type entries on the third-level page table. Therefore, only the entries on the third-level page table need to be retrieved to calculate the address mapping space size.

[0054] If bit[0] of the page table entry is 1, it means the entry is valid; if bit[0] is 0, it means the page table is invalid; if bit[1] of the page table entry is 1, it means the entry contains the base address pointing to the next level page table; if bit[1] is 0, it means the entry is a block type. The memory block size of the third-level page table is 2MB.

[0055] Read the first entry in the hypervisor address mapping three-level page table and determine whether bits [0] and [1] are 1 and 0, respectively, to determine whether it is a valid block type entry. If it is a valid block type entry, the address mapping space size is 2MB. Read the second entry in the hypervisor address mapping three-level page table and determine whether it is a valid block type entry. If it is an invalid entry, the hypervisor address mapping space size is 2MB; if it is a valid block type entry, the hypervisor address mapping space size increases by 2MB. If the second entry in the hypervisor address mapping three-level page table is a valid block type entry, continue searching subsequent entries until an invalid entry is found. At this point, the number of valid block type entries is N, and the total size of the hypervisor address mapping space is 2NMB. Using this method, we can determine that the size of the hypervisor's early virtual address mapping space is 2N (N is greater than or equal to 1) MB.

[0056] Step 230 , based on the jailhouse Hypervisor memory layout, calculate the size of the data used for early initialization of the Hypervisor, and determine whether the size of the data used for early initialization exceeds the size of the address space continuously mapped below the first address. If so, return a Hypervisor initialization failure memory error.

[0057] Figure 3 is a schematic diagram of memory layout of jailhouse Hypervisor in the system startup memory detection method provided by Embodiment Two of the present application, referring to Figure 3 , the data size occupied by the Hypervisor image size, PerCPU variable, configuration file data and page allocation pool usage bitmap is calculated respectively. For example, the Hypervisor image size can be calculated according to the compilation link symbol; the PerCPU variable size can be calculated by using the PerCPU variable data structure size and the maximum CPU number; the configuration file data size can be calculated according to the parsed configuration file data structure; and the page allocation pool usage bitmap size can be calculated by dividing the contained memory page (4k) by the bit number of each page (4k*8). Alternatively, the Hypervisor image size can be calculated by the difference between the image end position symbol and the image first address symbol defined in the compilation link file. Since the data structure size of the PerCPU variable is a relatively fixed size, the total memory size required by the PerCPU can be determined by the data structure size of the PerCPU variable and the CPU number. As for the configuration file, the data structure of the starting part of the configuration file is fixed, which contains the number of variable configurations described in the following part, so that the configuration file data size can be calculated. The memory managed by the page allocation pool usage bitmap includes the total size of the Hypervisor memory minus the size of the Hypervisor image, and the total size of the Hypervisor memory can be obtained through the configuration file. The memory size of the page allocation pool usage bitmap is the memory managed by the page allocation pool usage bitmap divided by the bit number of each page (4k*8).

[0058] By using the above method, memory errors can be detected when the Hypervisor is initialized, and the corresponding memory error information can be returned.

[0059] In step 240, the maximum value of the early virtual address mapping range of the Hypervisor is calculated according to the first address of the Hypervisor running before the final page table takes effect.

[0060] In step 250, when the memory page is allocated by using the dynamic allocation pool, the virtual address range of the allocated memory page is determined by using the base address of the allocated memory page, and it is detected whether the virtual address range of the allocated memory page exceeds the maximum value of the early virtual address mapping range of the Hypervisor.

[0061] In step 260, when the virtual address range of the allocated memory page exceeds the maximum value of the early virtual address mapping range of the Hypervisor, an error prompt is output, and the memory error is returned.

[0062] This embodiment adds the following steps: reading the first address of the hypervisor temporary page table from a key register of memory management; searching the page table based on the first address of the hypervisor operation and calculating the size of the address space continuously mapped below the first address; calculating the size of the data used for early initialization of the hypervisor based on the jailhouse hypervisor memory layout, and determining whether the size of the data used for early initialization exceeds the size of the address space continuously mapped below the first address. If so, a hypervisor initialization failure memory error is returned. This allows for dynamic detection of the virtual address range of the allocated memory page during early virtual address mapping, accurately determining whether it exceeds the hypervisor's early virtual address mapping range using a three-level page table, and outputting an error message when the maximum value of the hypervisor's early virtual address mapping range is exceeded, making it easier for developers to locate the cause of the crash.

[0063] Example 3

[0064] Figure 4 This is a schematic diagram of the structure of the system startup memory detection device provided by the third embodiment of the present invention, see Figure 4 , the system starts the memory detection device, including:

[0065] The calculation module 310 is used to calculate the maximum value of the early virtual address mapping range of the hypervisor according to the first address of the hypervisor operation before the final page table takes effect;

[0066] A detection module 320 is configured to determine a virtual address range of the allocated memory page using a base address of the allocated memory page when allocating the memory page using the dynamic allocation pool, and to detect whether the virtual address range of the allocated memory page exceeds a maximum value of an early virtual address mapping range of the hypervisor;

[0067] The output module 330 is configured to output an error prompt and return a memory error when the maximum value of the early virtual address mapping range of the Hypervisor is exceeded.

[0068] The system startup memory detection device provided by the embodiment can calculate the maximum value of the early virtual address mapping range of the Hypervisor according to the starting address of the Hypervisor before the final page table takes effect; when allocating a memory page by using a dynamic allocation pool, the base address of the allocated memory page is used to determine the virtual address range of the allocated memory page, and it is detected whether the virtual address range of the allocated memory page exceeds the maximum value of the early virtual address mapping range of the Hypervisor; when the virtual address range of the allocated memory page exceeds the maximum value of the early virtual address mapping range of the Hypervisor, an error prompt is output, and a memory error is returned. The maximum value of the determined virtual address in the early mapping process can be calculated based on the characteristics of the Hypervisor, the memory page virtual address range is determined by using the continuity of the virtual address and the base address, when a new CPU is allocated, whether the allocated address is in the memory page virtual address range is determined to determine whether the memory is incorrect, and a specific prompt can be returned for this error. Compared with the traditional estimation method, the possibility of inaccurate estimation caused by changes in dynamic allocation is reduced, the memory error can be accurately detected in advance before the system crashes, and the developer can locate the cause of the crash.

[0069] On the basis of each of the above embodiments, the device further comprises:

[0070] The reading module is configured to read the starting address of the temporary page table of the Hypervisor from a key register of memory management.

[0071] The address space size calculation module is configured to retrieve a page table according to the starting address of the Hypervisor, and calculate the size of the continuously mapped address space below the starting address.

[0072] On the basis of each of the above embodiments, the calculation module comprises:

[0073] The second-level page table base address obtaining unit is configured to calculate the index value of the first-level page table mapped by the Hypervisor according to the starting address of the Hypervisor, determine the first-level page table entry according to the index value of the first-level page table, and obtain the second-level page table base address from the first-level page table entry.

[0074] The third-level page table base address obtaining unit is configured to calculate the index value of the second-level page table mapped by the Hypervisor according to the starting address of the Hypervisor, determine the second-level page table entry according to the second-level page table base address and the index value of the second-level page table, and obtain the third-level page table base address from the second-level page table entry.

[0075] The unit for obtaining the size of the continuously mapped address space is configured to calculate an index value of a third-level page table mapped by the Hypervisor according to a first address where the Hypervisor runs, determine a third-level page table entry according to a third-level page table base address and the index value of the third-level page table, and determine the size of the continuously mapped address space below the first address according to the third-level page table entry.

[0076] On the basis of the above embodiments, the unit for obtaining the size of the continuously mapped address space comprises:

[0077] The first judging sub-unit is configured to read a first entry of the third-level page table, judge whether there is a valid flag according to a flag bit in the first entry, and mark the size of the continuously mapped address space as an initial set page space size when there is the valid flag.

[0078] The second judging sub-unit is configured to read a next entry, judge whether there is a valid flag according to a flag bit in the next entry, and mark the size of the continuously mapped address space as twice the initial set page space size when there is the valid flag, or mark the size of the continuously mapped address space as the size of the continuously mapped address space marked by a last entry when there is no valid flag.

[0079] The returning sub-unit is configured to return to the step of reading the next entry until there is no valid flag in the flag bit.

[0080] On the basis of the above embodiments, the apparatus further comprises:

[0081] The initial failure memory error returning module is configured to calculate a data size used by the Hypervisor in early initialization according to a jailhouse Hypervisor memory layout, judge whether the data size used in the early initialization exceeds the size of the continuously mapped address space below the first address, and return an initial failure memory error of the Hypervisor when the data size exceeds the size of the continuously mapped address space.

[0082] On the basis of the above embodiments, the initial failure memory error returning module comprises:

[0083] The data calculating unit is configured to calculate a Hypervisor image size, a PerCPU variable, a configuration file data, and a data size occupied by a page allocation pool usage bitmap according to a jailhouse Hypervisor memory layout.

[0084] On the basis of the above embodiments, the data calculating unit is configured to:

[0085] calculate the Hypervisor image size according to a compilation link symbol;

[0086] Calculate the PerCPU variable size using the PerCPU variable data structure size and the maximum number of CPUs;

[0087] Calculate the configuration file data size based on the parsed configuration file data structure;

[0088] The size of the bitmap used by the page allocation pool is obtained by dividing the number of memory pages (4k) by the number of bits per page (4k*8).

[0089] The system startup memory detection device provided by the embodiment of the present invention can execute the system startup memory detection method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0090] Example 4

[0091] Figure 5 This is a structural diagram of a device configured with a Jailhouse Hypervisor provided in the fourth embodiment of the present invention. Figure 5 A block diagram of an exemplary device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 5 The device 12 shown is only an example and should not bring any limitation to the functionality and scope of use of the embodiments of the present invention.

[0092] like Figure 5 As shown, device 12 is implemented as a general-purpose computing device. Components of device 12 may include, but are not limited to, one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including system memory 28 and processing unit 16).

[0093] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0094] Device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by device 12, including volatile and non-volatile media, removable and non-removable media.

[0095] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache 32. Device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be configured to read and write non-removable, non-volatile magnetic media ( Figure 5 Not shown, usually called a "hard drive"). Although Figure 5 Although not shown, a magnetic disk drive for reading and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), as well as an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present invention.

[0096] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 42 generally implement the functions and / or methodologies of the embodiments described herein.

[0097] Device 12 may also communicate with one or more external devices 14 (e.g., a keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with device 12, and / or any device that enables device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). This communication may occur via input / output (I / O) interface 22. Furthermore, device 12 may communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of device 12 via bus 18. It should be understood that, although not shown, other hardware and / or software modules may be used in conjunction with device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0098] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the system startup memory detection method provided by the embodiment of the present invention.

[0099] Example 5

[0100] The fifth embodiment of the present invention further provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to execute any of the system startup memory detection methods provided in the above embodiments.

[0101] The computer storage medium of the embodiments of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or device.

[0102] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0103] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0104] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or device. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0105] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.

Claims

1. A system startup memory detection method, characterized in that: include: Before the final page table takes effect, the maximum value of the hypervisor's early virtual address mapping range is calculated based on the first address of the hypervisor operation; When allocating memory pages using the dynamic allocation pool, the base address of the allocated memory page is used to determine the virtual address range of the allocated memory page, and whether the virtual address range of the allocated memory page exceeds the maximum value of the early virtual address mapping range of the hypervisor; When the maximum value of the early virtual address mapping range of the Hypervisor is exceeded, an error message is output and a memory error is returned; Read the first address of the Hypervisor temporary page table from the key register of memory management; Retrieving a page table according to the first address of the hypervisor, and calculating the size of the address space continuously mapped below the first address; The step of searching a page table according to a first address of the hypervisor and calculating a size of an address space continuously mapped below the first address includes: According to the first address of the hypervisor, the index value of the first-level page table mapped by the hypervisor is calculated, the first-level page table entry is determined according to the index value of the first-level page table, and the base address of the second-level page table is obtained from the first-level page table entry; According to the first address of the hypervisor, the index value of the second-level page table mapped by the hypervisor is calculated. According to the second-level page table base address and the index value of the second-level page table, the second-level page table entry is determined. The third-level page table base address is obtained from the second-level page table entry. Calculating an index value of a third-level page table mapped by the hypervisor according to the first address of the hypervisor, determining a third-level page table entry according to the third-level page table base address and the index value of the third-level page table, and determining a size of an address space continuously mapped below the first address according to the third-level page table entry; The determining the size of the address space continuously mapped below the first address according to the third-level page table entry includes: Read the first table entry of the third-level page table, determine whether there is a valid flag according to the flag bit in the first table entry, and if there is a valid flag, mark the size of the continuously mapped address space as the initial set page space size; Read the next table entry, and determine whether there is a valid flag based on the flag bit in the next table entry. If there is a valid flag, mark the size of the continuously mapped space as twice the initial set page space size; otherwise, mark the size of the continuously mapped address space as the size of the continuously mapped address space marked by the previous table entry; Return to the step of reading the next table entry until there is no valid flag in the flag bit.

2. The method according to claim 1, characterized in that The method further comprises: According to the jailhouse Hypervisor memory layout, the size of the data used for the early initialization of the Hypervisor is calculated. It is determined whether the size of the data used for the early initialization exceeds the size of the address space continuously mapped below the first address. If it exceeds, a Hypervisor initialization failure memory error is returned.

3. The method according to claim 2, characterized in that The calculation of the data size used for early Hypervisor initialization based on the jailhouse Hypervisor memory layout includes: Based on the jailhouseHypervisor memory layout, calculate the data size occupied by the hypervisor image size, PerCPU variables, profile data, and page allocation pool usage bitmap.

4. The method according to claim 3, characterized in that The calculation of the hypervisor image size, PerCPU variables, configuration file data, and the data size occupied by the page allocation pool bitmap includes: Calculate the size of the Hypervisor image based on the compiled link symbols; Calculate the PerCPU variable size using the PerCPU variable data structure size and the maximum number of CPUs; Calculate the configuration file data size based on the parsed configuration file data structure; The page allocation pool bitmap size is calculated using the number of memory pages and the number of bits per page.

5. A system startup memory detection device, characterized in that: include: A calculation module is used to calculate the maximum value of the early virtual address mapping range of the hypervisor based on the first address of the hypervisor operation before the final page table takes effect; a detection module, configured to determine a virtual address range of the allocated memory page using a base address of the allocated memory page when allocating the memory page using the dynamic allocation pool, and to detect whether the virtual address range of the allocated memory page exceeds a maximum value of an early virtual address mapping range of the hypervisor; The output module is used to output an error message and return a memory error when the maximum value of the hypervisor's early virtual address mapping range is exceeded; The read module is used to read the first address of the Hypervisor temporary page table from the key register of memory management; An address space size calculation module is used to retrieve a page table according to a first address of the hypervisor and calculate the size of the address space continuously mapped below the first address; The calculation module includes: The second-level page table base address obtaining unit is used to calculate the index value of the first-level page table mapped by the hypervisor according to the first address of the hypervisor operation, determine the first-level page table entry according to the index value of the first-level page table, and obtain the second-level page table base address from the first-level page table entry; A third-level page table base address obtaining unit is used to calculate the index value of the second-level page table mapped by the hypervisor according to the first address of the hypervisor operation, determine the second-level page table entry according to the second-level page table base address and the index value of the second-level page table, and obtain the third-level page table base address from the second-level page table entry; a continuously mapped address space size obtaining unit, configured to calculate an index value of a third-level page table mapped by the hypervisor based on the first address at which the hypervisor is running, determine a third-level page table entry based on the third-level page table base address and the index value of the third-level page table, and determine the size of the continuously mapped address space below the first address based on the third-level page table entry; The unit for obtaining the size of the continuously mapped address space includes: a first determination subunit, configured to read a first table entry of the third-level page table, determine whether a valid flag exists according to a flag bit in the first table entry, and if a valid flag exists, mark the size of the continuously mapped address space as the initial set page space size; a second judgment subunit, configured to read the next table entry, and determine whether a valid flag is present according to a flag bit in the next table entry; if a valid flag is present, marking the size of the continuously mapped address space as twice the initial set page space size; otherwise, marking the size of the continuously mapped address space as the size of the continuously mapped address space marked by the previous table entry; The return subunit is used to return to the step of reading the next table entry until there is no valid flag in the flag bit.

6. A device configured with a JailhouseHypervisor, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the system startup memory detection method as described in any one of claims 1 to 4.

7. A storage medium containing computer-executable instructions, characterized in that: The computer executable instructions, when executed by a computer processor, are used to execute the system startup memory detection method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method and device for accessing memory

    CN118427123A

  • RDP graphic rendering instruction stream high-risk operation real-time blocking method under Loongson architecture

    CN120085958A