Page table generation method, device, system and related equipment
By obtaining users and fixed constraints, building page table description information and initial structure, and building page table pointing relationships step by step, solving the problem that the existing technology cannot meet the needs of different verification scenarios, and realizing the generation of page tables that meet the needs.
Patent Information
- Application Number
- CN202111525577.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2041-12-14
AI Technical Summary
The existing page table generation method cannot meet the verification needs of different verification scenarios, resulting in the inability to effectively generate page tables that meet the needs during the logical verification process.
By obtaining user constraints and fixed constraints, the page table description information and the initial page table structure are determined, and the page table orientation relationship is constructed step by step from high to low in the initial page table structure to form the target page table.
It realizes the generation of page tables that meet the needs according to different verification needs, which meets the verification needs of different verification scenarios during the verification process.
Smart Images

Figure CN114238174B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of chip technology, and particularly to a page table generation method, apparatus, system and related devices. Background Art
[0002] Logic verification is a key step in the front-end design process of digital chips, usually implemented using a verification platform. Specifically, the verification platform can simulate the actual operating environment of the chip design and verify the correctness of the chip design function.
[0003] When performing logic verification in memory management, it is usually necessary to verify corresponding address conversion, memory reading and other processes based on an existing page table, which is usually generated by a page table generator based on its internal inherent constraints. With the application of technologies such as multi-level paging substitution and virtualization, the page tables generated by existing page table generation methods can no longer meet the verification requirements of different verification scenarios during the verification process.
[0004] Therefore, how to generate a page table that meets the verification requirements has become an urgent problem to be solved by those skilled in the art. Summary of the Invention
[0005] In view of this, the embodiments of the present invention provide a page table generation method, apparatus, system and related devices, which can meet the verification requirements of different verification scenarios during the verification process.
[0006] To achieve the above object, the embodiments of the present invention provide the following technical solutions.
[0007] The embodiments of the present invention provide a page table generation method, including:
[0008] Obtaining user constraints for generating a page table, where the user constraints are constraint information obtained based on user request parameters;
[0009] Based on the user constraints, determining page table description information for generating a page table and an initial page table structure that conforms to the page table description information;
[0010] Obtaining fixed constraints for generating a page table, where the fixed constraints are constraint information preset in the page table generator;
[0011] Based on the fixed constraints, updating the page table description information and the initial page table structure;
[0012] According to the page table description information, in the initial page table structure, constructing a page table pointing relationship corresponding to each level of the page table level by level from high to low to form a target page table.
[0013] Optionally, the obtaining user constraints for generating a page table includes:
[0014] Obtain a page table generation request of the user, where the page table generation request includes request parameters for generating a page table;
[0015] Determine user constraints according to the request parameters.
[0016] Optionally, the step of constructing the page table pointing relationship corresponding to each level of the page table in the initial page table structure from high to low according to the page table description information to form a target page table includes:
[0017] Configure the control and status register of the initial page table structure so that the control and status register points to the highest-level page table of the initial page table structure;
[0018] Obtain a virtual address based on the page table description information;
[0019] According to the page table description information, starting from the highest-level page table of the initial page table structure, construct the page table pointing relationship corresponding to the virtual address in the page table at this level until the lowest-level page table of the initial page table structure.
[0020] Optionally, the step of constructing the page table pointing relationship corresponding to the virtual address in the page table at this level includes:
[0021] Query whether there is a page table entry corresponding to the virtual address in the page table at this level;
[0022] If not, create a page table entry corresponding to the virtual address and write the page table entry to a preset storage location.
[0023] Optionally, the step of constructing the page table pointing relationship corresponding to the virtual address in the page table at this level further includes:
[0024] If there is a page table entry corresponding to the virtual address in the page table at this level, update the page table entry corresponding to the virtual address according to a preset update strategy;
[0025] Wherein, the update strategy is: update based on the existing page table entry, or execute the step of creating the page table entry corresponding to the virtual address and writing the page table entry to a preset storage location to update the page table entry.
[0026] Optionally, after obtaining the virtual address based on the page table description information and before constructing the page table pointing relationship corresponding to the virtual address in the page table at this level from the highest-level page table of the initial page table structure according to the page table description information, it further includes:
[0027] Determine whether there is an address conflict for the virtual address;
[0028] If there is an address conflict, execute the step of obtaining the virtual address based on the page table description information again;
[0029] If not, execute the step of constructing the page table pointing relationship corresponding to the virtual address in the current-level page table starting from the highest-level page table of the initial page table structure according to the page table description information.
[0030] Optionally, after obtaining the virtual address based on the page table description information and before constructing the page table pointing relationship corresponding to the virtual address in the current-level page table starting from the highest-level page table of the initial page table structure according to the page table description information, it further includes:
[0031] Determine whether the virtual address itself and its attached attributes conform to the constraints in the page table description information;
[0032] If not, execute the step of obtaining the virtual address based on the page table description information again;
[0033] If so, execute the step of constructing the page table pointing relationship corresponding to the virtual address in the current-level page table starting from the highest-level page table of the initial page table structure according to the page table description information.
[0034] Optionally, when the current-level page table is the lowest-level page table, in the step of creating the page table entry corresponding to the virtual address, specifically, determine the physical address pointed to by the page table entry and create the page table entry based on the information of the physical address.
[0035] Optionally, in the step of constructing the page table pointing relationship corresponding to the virtual address in the current-level page table, if the page table description information includes exception test information and the exception test information indicates that an exception occurs in the current-level page table, after creating the page table entry corresponding to the virtual address and before writing the page table entry to a preset storage location, it further includes:
[0036] Modify the page table entry according to the exception type in the exception test information to inject an exception.
[0037] Optionally, in the step of constructing the page table pointing relationship corresponding to the virtual address in the current-level page table starting from the highest-level page table of the initial page table structure until the lowest-level page table of the initial page table structure, after creating the page table entry corresponding to the virtual address and writing the page table entry to a preset storage location, it further includes:
[0038] Judge whether the current-level page table is the lowest-level page table;
[0039] If not, enter the next-level page table and execute the step of querying whether there is a page table entry corresponding to the virtual address in the current-level page table. If so, return the created target page table to the user.
[0040] Optionally, the physical address pointed to by the page table entry is a virtual machine physical address. After creating the page table entry corresponding to the virtual address and writing the page table entry to a preset storage location, the method further includes:
[0041] Generating a host page table, where the page table entries in the host page table are used to construct a pointing relationship from the virtual machine physical address to the system physical address.
[0042] Optionally, the initial page table structure at least includes the highest-level page table of the target page table.
[0043] Optionally, in the step of determining the initial page table structure that conforms to the page table description information, it includes: randomizing the data in the initial page table structure within the range defined by the page table description information.
[0044] Optionally, in the step of updating the initial page table structure, it includes: randomizing the data in the initial page table structure within the range defined by the updated page table description information.
[0045] Optionally, the user constraints include one or more of the following constraints:
[0046] Attribute constraint, used to determine the attribute of the storage page pointed to by the physical address in the page table;
[0047] Address conflict constraint, used to determine whether there is an address conflict in the addresses in the page table;
[0048] Address range constraint, used to specify that the address range in the page table is within a preset range;
[0049] Address size constraint, used to specify the address size;
[0050] Same address space type constraint, used to specify whether the address space type of the same address is allowed to change;
[0051] Fault constraint, used to determine whether there is a page fault in the page table.
[0052] An embodiment of the present invention further provides a page table generation device, including:
[0053] A user constraint acquisition module, configured to acquire user constraints for generating a page table, where the user constraints are constraint information obtained based on user request parameters;
[0054] An initial processing module, configured to determine, based on the user constraints, page table description information for generating a page table and an initial page table structure that conforms to the page table description information;
[0055] A fixed constraint acquisition module, configured to acquire fixed constraints for generating a page table, where the fixed constraints are constraint information preset in the page table generator;
[0056] An update processing module, configured to update the page table description information and the initial page table structure based on the fixed constraint;
[0057] A pointing relationship construction module, configured to construct a page table pointing relationship corresponding to each level of the page table step by step from high to low in the initial page table structure according to the page table description information, so as to form a target page table.
[0058] An embodiment of the present invention further provides a page table generator, which is configured to execute the page table generation method provided by the embodiment of the present invention.
[0059] An embodiment of the present invention further provides a chip verification system, which is configured to execute the page table generation method provided by the embodiment of the present invention.
[0060] An embodiment of the present invention further provides a computer device, including: at least one memory and at least one processor; the memory stores one or more computer-executable instructions, and the processor calls the one or more computer-executable instructions to execute the page table generation method provided by the embodiment of the present invention.
[0061] An embodiment of the present invention further provides a storage medium, characterized in that the storage medium stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the page table generation method provided by the embodiment of the present invention.
[0062] An embodiment of the present invention provides a page table generation method, device, system and related device. The method includes: obtaining a user constraint for generating a page table, where the user constraint is constraint information obtained based on user request parameters; determining page table description information for generating a page table and an initial page table structure that conforms to the page table description information based on the user constraint; obtaining a fixed constraint for generating a page table, where the fixed constraint is preset constraint information in the page table generator; updating the page table description information and the initial page table structure based on the fixed constraint; and constructing a page table pointing relationship corresponding to each level of the page table step by step from high to low in the initial page table structure according to the page table description information, so as to form a target page table.
[0063] It can be seen that in the page table generation method in the embodiment of the present invention, the page table description information and the initial page table structure are formed based on the user constraint and the fixed constraint, and then the target page table is constructed based on the page table description information and the initial page table structure, so that the user can put forward different user requests based on different verification requirements, and then form different user constraints, and construct the corresponding target page table to meet the verification requirements in different verification scenarios during the verification process. Description of the Drawings
[0064] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to the provided drawings.
[0065] Figure 1 Schematic diagram of a multi-level page table structure for virtual address to physical address conversion of memory pages provided by an embodiment of the present invention;
[0066] Figure 2 Optional structural block diagram of a page table generator provided by an embodiment of the present invention;
[0067] Figure 3 Optional flowchart of a page table generation method provided by an embodiment of the present invention;
[0068] Figure 4 Optional flowchart of step S10 provided by an embodiment of the present invention;
[0069] Figure 5 Optional flowchart of step S14 provided by an embodiment of the present invention;
[0070] Figure 6 Optional flowchart of step S142 provided by an embodiment of the present invention;
[0071] Figure 7 Optional block diagram of a page table generation device provided by an embodiment of the present invention. Detailed implementation manners
[0072] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.
[0073] Based on the description in the background technology, when performing logical verification in memory management, it is usually necessary to verify corresponding processes such as address conversion and memory reading based on the existing page table, and this page table is usually generated by a page table generator based on its internal inherent logic.
[0074] However, with the application of technologies such as multi-level page replacement and virtualization, the logical verification in memory management is based on different requirements and needs to be implemented with page tables that meet the corresponding requirements. For example, making the attributes of the physical addresses pointed to by the page table match the verification requirements, or setting address conflicts in the page table, etc. However, the page tables generated by existing inherent constraints are only in a fixed format and obviously cannot meet the verification requirements in different verification scenarios during the verification process.
[0075] Based on this, the embodiments of the present invention provide a page table generation method, device, system and related equipment. The method includes: obtaining user constraints for generating a page table, where the user constraints are constraint information obtained based on the user's request parameters; determining page table description information for generating a page table and an initial page table structure that conforms to the page table description information based on the user constraints; obtaining fixed constraints for generating a page table, where the fixed constraints are constraint information preset in the page table generator; updating the page table description information and the initial page table structure based on the fixed constraints; and constructing a page table pointing relationship corresponding to each level of the page table from high to low in the initial page table structure according to the page table description information to form a target page table.
[0076] It can be seen that the page table generation method in the embodiments of the present invention forms page table description information and an initial page table structure based on user constraints and fixed constraints, and then constructs a target page table based on the page table description information and the initial page table structure, so that users can put forward different user requests based on different verification requirements, and then form different user constraints, and construct corresponding target page tables to meet the verification requirements in different verification scenarios during the verification process.
[0077] In an optional example, to understand the structure of a multi-level page table and its corresponding address conversion method, Figure 1 A schematic diagram of a multi-level page table structure for virtual address to physical address conversion of a memory page is shown.
[0078] Among them, the virtual address can be understood as the address for conversion, the physical address can be understood as the actual address of the memory page, and the page table is used to store the address pointing relationship from the virtual address to the physical address to implement the conversion from the virtual address to the physical address. The page table can be a multi-level page table. For Figure 1 example, the page table includes a first-level page table and multiple second-level page tables. The first-level page table is the highest-level page table and contains multiple page table entries. Among them, one page table entry corresponds to the next-level page table (i.e., the second-level page table in this example).
[0079] In this example, the physical address of a memory page is described by a 32-bit address, and the CSR (Control and Status Register) can be used to record the page address of the highest-level page table (i.e., the first-level page table in this example), so as to find the highest-level page table through this page address;
[0080] In a given virtual address, take its bits 20 to 31 as the offset, find the page table entry it points to in the first-level page table, and this page table entry is used to indicate the page address where its corresponding second-level page table is located, so as to determine the second-level page table corresponding to this page table entry according to this page address;
[0081] Take bits 12 to 19 of the virtual address as the offset, find the page table entry it points to in the second-level page table, and this page table entry is used to indicate bits 12 to 31 of its corresponding physical address;
[0082] Take bits 0 to 12 of the virtual address as bits 0 to 12 of the physical address to obtain the complete physical address.
[0083] When performing logical verification in memory management, when verifying processes such as corresponding address conversion and memory reading based on the existing page table, the page table generated by the page table generator based on its internal fixed constraints usually cannot be flexibly set for different test scenarios.
[0084] In the embodiments of the present invention, a page table generation method, device, system and related equipment are provided to correspondingly generate multi-level page tables that meet the verification requirements based on different verification requirements.
[0085] In an optional example, refer to Figure 2 the optional structural block diagram of the page table generator shown, as Figure 2 shown, the page table generator may include:
[0086] An initial page table structure; wherein, the initial page table structure may be a guest multi-level page table structure, a host multi-level page table structure, or a general multi-level page table structure. The initial page table structure is used to store all page table entries in the process of virtual address to physical address conversion, where the page table entries in each level of the page table are used to point to a page table in the next level.
[0087] CSR configuration information table; wherein, the CSR configuration information table is used to record the address of the highest-level page table in the multi-level page table. According to different CSR configurations, it can also be determined whether to enable simultaneous multi-threading or whether to support hardware-assisted memory virtualization. When simultaneous multi-threading is enabled, multiple target page tables need to be generated, and when hardware-assisted memory virtualization is supported, two matching target page tables need to be generated simultaneously, namely the guest page table and the host page table, and the two target page tables match each other. It should be noted that the value of CSR can be determined when the page table generator creates an object, or provided randomly, or provided by the user.
[0088] Virtual address table, virtual machine physical address table, system physical address table; these address tables are used to save the addresses applied for during the target page table generation process. Among them, the virtual machine physical address table is used to record the virtual machine physical address, the virtual machine physical address is applied in the memory virtualization process, the mapping relationship between the virtual address and the virtual machine physical address is recorded in the guest page table, and the mapping relationship between the virtual machine physical address and the system physical address is recorded in the host page table.
[0089] Address mapping table, which is used to record the address mapping relationship during the page table generation process. Each entry in the address mapping table can contain the virtual address and physical address of a storage page. At the same time, the address mapping table can also record the attachment information corresponding to this address mapping relationship, such as the attribute information of the storage page table and the constraint information it satisfies, etc.
[0090] Fixed constraint information table, which is used to record the preset fixed constraints in the page table generator, and the fixed constraints can be specified during the initialization of the page table generator.
[0091] It should be noted that the page table generator can be in the singleton mode, which is used to indicate that there is only one instance in the system to ensure the unified management of global system resources, including the physical address space, related CSR, etc. Of course, the page table generator is not limited to only the singleton mode, as long as it is ensured that the data structure of the page table generator is unique in the entire verification environment.
[0092] Based on the above page table generator, Figure 3 An optional flowchart of the page table generation method provided by the embodiment of the present invention is exemplarily shown. As Figure 3 shown, the page table generation method may include:
[0093] Step S10: Obtain user constraints for generating the page table;
[0094] Among them, the user can be understood as the verification personnel. It can be understood that based on different verification scenarios, there are different verification requirements for the page table. Based on this, the verification personnel can describe the corresponding verification requirements in the form of request parameters, and then can determine the corresponding user constraints based on the request parameters. Correspondingly, the page table that meets the user constraints generated is the page table that meets the corresponding verification requirements.
[0095] The user constraint is the constraint information obtained based on the user's request parameters, and is used to make the generated page table meet the constraint information during the subsequent process of constructing the page table.
[0096] Step S11: Based on the user constraint, determine the page table description information for generating the page table and the initial page table structure that conforms to the page table description information;
[0097] The page table description information can be understood as the conditions that need to be met during the page table generation process. When different constraint information is given in multiple aspects, such as the user constraint and the fixed constraint described in the present invention, etc., the constraint information given in different aspects can be integrated by updating the page table description information. It can be understood that during the page table generation process, the requirements of the page table description information need to be met.
[0098] The user constraint describes the user's requirements for the page table, so that the page table description information can be determined based on the user constraint. And in the user constraint, it can include both the constraint on the page table structure and the constraint on the page table entries in the page table. Therefore, the initial page table structure that conforms to the page table description information can be determined based on the constraint on the page table structure in the user constraint.
[0099] The initial page table structure can only be the framework structure of the page table. For example, when a multi-level page table needs to be formed, the initial page table structure can be a multi-level page table structure. Correspondingly, the initial page table structure can include multiple page tables at different levels. Among them, the page table entries in the highest-level page table are used to point to the next-level page table, and the page table entries in the next-level page table are used to further point to the next-next-level page table, while the page table entries in the lowest-level page table are used to point to the address range of the specific physical address. It should be noted that this physical address can be the actual host physical address or the guest physical address, and the present invention does not make specific limitations here.
[0100] It can be understood that the initial page table structure may only include the initial architecture of the page table, or may include both the initial architecture of the page table and partial / all page table entry information, which is specifically determined by the page table description information determined by user constraints. For example, when there is a corresponding virtual address range in the user constraints, the page table entries in the highest-level page table of the initial page table structure can be formed based on this virtual address range (i.e., making the corresponding virtual address range correspond to the page table entries); when there is a corresponding physical address range in the user constraints, the page table entries in the lowest-level page table of the initial page table structure can be formed based on this physical address range (i.e., making the page table entries correspond to the corresponding physical address range). In an alternative implementation, the initial page table structure at least includes the highest-level page table for generating the target page table.
[0101] It should be noted that when determining the initial page table structure that conforms to the page table description information, the data in the initial page table structure can be randomized within the range defined by the page table description information (which is the user constraint in this step), so as to improve the randomness of the generated target page table. The randomization can be performed once or multiple times to further improve the randomness of the target page table.
[0102] Among them, during the randomization process, the address can be randomized based on the address information in multiple address tables in the page table generator. And during the randomization process, the parameter data corresponding to the initial page table structure can also be determined based on the constraints on the page table structure in the page table description information, such as CSR configuration information, etc. The CSR configuration information can be stored in the CSR configuration information table of the page table generator.
[0103] Step S12: Obtain the fixed constraints for generating the page table, where the fixed constraints are the constraint information preset in the page table generator;
[0104] During the process of generating the target page table, fixed constraints can be preset in the page table generator. These fixed constraints can be constraints that are inevitably generated based on the internal settings of the device, or constraints that are necessarily required based on the preset page table generation rules. At the same time, they can also be general constraints predefined by the user based on the preset scenario. For example, the physical address range constraint used to define the optional physical address range. This constraint can define the maximum physical address range of the device as the optional physical address range. Correspondingly, in the user constraints, a certain sub-range within this maximum physical address range can be constrained as the physical address range constraint based on specific verification requirements; or, the uniqueness of the virtual address or physical address can be constrained, and the attributes of the same address (i.e., whether different physical address attributes are allowed for the same physical address) can be constrained; or, when a series of target page tables with the same characteristics need to be generated for the same verification scenario, the corresponding same characteristics can be predefined as fixed constraints in the page table generator, such as whether page faults are allowed to be generated.
[0105] It can be understood that the fixed constraints, as the preset constraints in the page table generator, are used to define the basic conditions for page table generation, while the user constraints, as the information reflecting different verification requirements, are used to define the specific conditions for page table generation. Among them, only based on the fixed constraints, a page table with a fixed format as described in the background art can be generated, and the page table generated by adding user constraints is the target page table that meets the corresponding verification requirements.
[0106] Step S13: Update the page table description information and the initial page table structure based on the fixed constraints;
[0107] Based on the obtained fixed constraints, update the page table description information, so as to integrate the user constraints and the fixed constraints.
[0108] Specifically, the update of the page table description information is used to further narrow the constraints for generating the page table. For example, in the page table description information, if the original virtual address range is larger than the virtual address range in the fixed constraints, then update the virtual address range to the virtual address range in the fixed constraints. Correspondingly, if the original virtual address range is smaller than the virtual address range in the fixed constraints, then update the virtual address range to the original virtual address range.
[0109] It can be understood that the page table description information updated based on the fixed constraints can include the attributes of each page table entry after user specification or randomization, so as to generate the target page table based on this page table description information.
[0110] Similarly, while updating the page table description information, the initial page table structure should also be updated. Among them, when updating the initial page table structure that conforms to the page table description information, the data in the initial page table structure can be randomized within the range defined by the updated page table description information, thereby improving the randomness of the generated target page table.
[0111] Step S14: According to the page table description information, in the initial page table structure, construct the page table pointing relationships corresponding to each level of the page table step by step from high to low to form a target page table;
[0112] After determining the page table description information and the initial page table structure, in the initial page table structure, the page table pointing relationships corresponding to each level of the page table can be constructed step by step from high to low, so as to determine the pointing relationships of the page table entries in each level of the page table and form a target page table.
[0113] Among them, based on the constraint information including user constraints and fixed constraints in the page table description information, the target page table generated according to the page table description information can be understood as the page table that meets the foregoing verification requirements. Similarly, when constructing the page table pointing relationships of each level of the page table, data randomization should also be performed within the constraint range of the page table description information, thereby improving the randomness of the generated target page table.
[0114] It can be seen that the page table generation method in the embodiment of the present invention forms the page table description information and the initial page table structure based on user constraints and fixed constraints, and then constructs a target page table based on the page table description information and the initial page table structure, so that the user can put forward different user requests based on different verification requirements, and then form different user constraints, and then construct the corresponding target page table, thereby meeting the verification requirements in different verification scenarios during the verification process.
[0115] In an alternative implementation, the user constraints in step S10 can be obtained based on the user's page table generation request. Specifically, Figure 4 An exemplary optional flowchart of step S10 provided by the embodiment of the present invention is shown. Step S10 may include:
[0116] Step S101: Obtain the user's page table generation request, where the page table generation request includes request parameters for generating a page table;
[0117] The page table generation request may be a request issued by the user for generating a page table. In this page table generation request, request parameters for generating a page table may be included, and the request parameters may be input by the user and used to describe the corresponding verification requirements.
[0118] Step S102: Determine user constraints according to the request parameters.
[0119] After obtaining the page table generation request, specific user constraints can be determined based on the request parameters in the page table generation request. Specifically, the corresponding user constraints can be determined by parsing the request parameters.
[0120] In an optional example, the user constraints may include one or more of the following constraints:
[0121] Attribute constraint, used to determine the attributes of the storage page pointed to by the physical address in the page table;
[0122] Address conflict constraint, used to determine whether there is an address conflict in the addresses in the page table; (In an optional example, the address conflict constraint may include different configurations, for example, allowing address conflicts, not allowing address conflicts, or only allowing address conflicts within the same thread)
[0123] Address range constraint, used to specify that the address range in the page table is within a preset range;
[0124] Address size constraint, used to specify the address size;
[0125] Spatial type constraint for the same address, used to specify whether the address space type (such as peripheral space, main memory space) of the same address is allowed to change;
[0126] Fault constraint, used to determine whether there are page faults in the page table (for example, page fault, reserved bit fault (normally, the reserved bit should be 0)).
[0127] Among them, the attributes of the storage page may include:
[0128] The memory type to which the storage page belongs, for example, whether it is a cache, whether it is in-order (that is, whether multiple instructions accessing this page must be executed in the order in the software program);
[0129] The access permission of the storage page, for example, whether read / write / execute is allowed;
[0130] Whether the storage page exists;
[0131] The address space type of the storage page, for example, peripheral space, main memory space;
[0132] Whether the storage page contains a fault;
[0133] The size of the storage page.
[0134] It can be understood that the request parameters can be part or all of the addresses or attribute values in the page table entries, and the user constraints further determined based on the request parameters can obtain an initial page table structure with higher randomness after one or more randomizations.
[0135] In an optional example, based on the constraints on faults or conflicts in the user constraints, the page table description information may further include exception test information. The exception test information may mark the page table level where an exception needs to occur and the exception type. During the process of generating the target page table, based on the exception test information, when creating or updating the page table entries at the corresponding level, the information in the page table entries can be modified according to the exception type to complete the generation or injection of the exception.
[0136] In an optional implementation, in step S14, the page table pointing relationship in the multi-level page table can be constructed step by step from high to low based on the virtual address in the page table description information. Specifically, Figure 5 An exemplary optional flowchart of step S14 provided by an embodiment of the present invention is shown. Step S14 may include:
[0137] Step S140: Configure the CSR of the initial page table structure so that the control and status register points to the highest-level page table of the initial page table structure;
[0138] It can be understood that the CSR is used to point to the page address of the highest-level page table of the initial page table structure, so that in the subsequent construction process of the page table entry pointing relationship, it all starts from the highest-level page table of the initial page table structure.
[0139] Step S141: Based on the page table description information, obtain the virtual address;
[0140] Among them, in the page table description information, there is a virtual address range corresponding to the page table. Obtaining the virtual address can be randomly extracted from the virtual address range corresponding to the page table, or sequentially extracted from the virtual address range corresponding to the page table, or alternatively, a virtual address given by the user can also be obtained.
[0141] Among them, after obtaining the virtual address, it is necessary to determine whether there is an address conflict for the virtual address. Specifically, the virtual address table can be queried to check whether the obtained virtual address already exists. If it already exists, there is an address conflict, and step S141 is executed again to obtain a new virtual address. If not, there is no address conflict, and step S142 is executed;
[0142] In an optional example, it can also be determined simultaneously whether the virtual address itself and its attached attributes meet the constraints in the page table description information. If they meet, step S142 is executed. If not, step S141 is executed again to obtain a new virtual address.
[0143] Step S142: According to the page table description information, starting from the highest-level page table of the initial page table structure, construct the page table pointing relationship corresponding to the virtual address in the page table at this level until the lowest-level page table of the initial page table structure.
[0144] After determining the virtual address, the page table entries can be constructed starting from the highest-level page table pointed to by the virtual address. After the construction is completed, the page table entries of the next-level page table pointed to by the page table entries are further constructed until the lowest-level page table of the initial page table structure, thereby forming the final target page table.
[0145] It should be noted that during the construction process of the page table pointing relationship, it should be executed according to the page table description information, so that the constructed target page table conforms to the constraint information in the page table description information.
[0146] In an optional example, referring to Figure 6 the optional flowchart of step S142 shown, the process of constructing the page table pointing relationship corresponding to the virtual address in the page table at a certain level in step S142 may specifically include:
[0147] Step S21: Query whether there is a page table entry corresponding to the virtual address in the page table at this level;
[0148] It should be noted that the page table entry corresponding to the virtual address refers to the page table entry of the page table at this level determined based on the pointing relationship of the virtual address. Among them, when the page table at this level is the highest-level page table, the page table entry corresponding to the virtual address is the page table entry pointed to by the virtual address; when the page table at this level is a page table at other levels, the page table entry corresponding to the virtual address is the page table entry of the upper-level page table determined based on the virtual address and the page table entry pointed to by the address information of the virtual address.
[0149] In the initial page table structure determined based on the page table description information, there may or may not be a corresponding page table entry. Therefore, in this step, the page table entries in the page table at this level are queried to determine whether there is a page table entry corresponding to the virtual address. When there is no corresponding page table entry, step S22 is executed; when there is a corresponding page table entry, step S23 is executed.
[0150] Step S22: Create a page table entry corresponding to the virtual address and write the page table entry to a preset storage location.
[0151] Specifically, the creation of the page table entry can be performed based on the constraints on the page table entry in the page table description information.
[0152] In an optional example, when creating a page table entry, the page table entry can be created based on the information of the next-level page table. When there is a next-level page table, based on the corresponding constraints, the corresponding next-level page table is determined as the next-level page table pointed to by the page table entry. When there is no next-level page table, a next-level page table can also be created based on the corresponding constraints, and this next-level page table is used as the next-level page table pointed to by the page table entry.
[0153] It can be understood that the created page table entry should conform to a preset page table entry format.
[0154] In another optional example, when the current-level page table is the lowest-level page table, the physical address pointed to by the page table entry is determined, and the page table entry is created based on the information of this physical address. Among them, the physical address pointed to by the page table entry can be determined based on the constraint information in the page table description information.
[0155] It should be noted that when determining the physical address pointed to by the page table entry, it is also possible to query whether this physical address conflicts with the physical addresses pointed to by existing page table entries (for example, query whether this physical address already exists through the virtual machine physical address table or the system physical address table. If it exists, there is a conflict). If there is a conflict, it is possible to determine whether to allow the conflict based on the page table description information. If allowed, the page table entry is created based on the information of this physical address. If not allowed, a new physical address is determined again for the page table entry, and the page table entry is created based on the information of this physical address; if there is no conflict, the page table entry is created based on the information of this physical address.
[0156] It should be further noted that the page table description information includes exception test information, and the exception test information indicates the situations where exceptions occur in the current-level page table. After generating the page table entry, the page table entry can be modified according to the exception type in the exception test information, so as to inject exceptions into the current-level page table.
[0157] Moreover, the preset address information is further recorded in the page table description information. Then, based on the fact that the preset address information is recorded in the page table description information, the page table entry is written to the storage location corresponding to this preset address information.
[0158] Among them, it can be understood that the preset storage location is a location pre-divided for storing the target page table, and page tables at different levels, as well as different page tables at the same level, all have preset storage locations, so that the page table entries in the page table reflect the pointing relationship between multi-level page tables based on the preset storage locations.
[0159] It should be noted that since the target page table generated according to the embodiments of the present invention is applied to the verification environment, the preset storage location described in this step can be the main memory in the verification environment.
[0160] Step S23: Update the page table entry corresponding to the virtual address according to a preset update policy.
[0161] When there is a page table entry corresponding to the virtual address, a corresponding update policy can be preset, so as to direct the update of the page table entry based on the update policy.
[0162] Among them, the update policy can be: update based on the existing page table entry, or execute step S22 to update the page table entry.
[0163] When a new page table entry needs to be created for update, the creation of the page table entry can refer to the execution process of step S22, and the created page table entry is written to a preset storage location.
[0164] In an optional example, continue to refer to Figure 6 , after step S22 or step S23, it can be further determined whether to create the next-level page table. Specifically, the following steps are executed:
[0165] Step S24: Determine whether the current-level page table is the lowest-level page table;
[0166] If so, it indicates that the target page table has been created, and step S25 is executed. If not, enter the next-level page table and continue to execute step S21 based on the virtual address.
[0167] Step S25: Return the created target page table to the user.
[0168] In the above example, a certain level of page table can be any level in the multi-level page table. Among them, when creating the page table entry of the lowest-level page table, the created page table entry should correspond to the physical address in the page table description information, so that based on this target page table, the mapping relationship between the virtual address and the physical address can be obtained. Further, the mapping relationship between the virtual address and the physical address can be recorded in the address mapping table of the page table generator.
[0169] It can be understood that based on the different types of page tables to be generated, the physical address corresponding to the created page table entry can be the virtual machine physical address or the system physical address. The physical address corresponding to the created page table entry can be further recorded in the corresponding address table. For example, when the physical address corresponding to the created page table entry is the virtual machine physical address, the corresponding physical address is recorded in the virtual machine physical address table; when the physical address corresponding to the created page table entry is the system physical address, the corresponding physical address is recorded in the system physical address table.
[0170] Among them, in the lowest-level page table, if the physical address corresponding to the created page table entry is a virtual machine physical address, the generated target page table is a guest page table. Correspondingly, a matching host page table should also be generated. In an optional example, after step S22 or step S23, the following is further included:
[0171] Step S26: Generate a host page table, and the page table entries in the host page table are used to construct the pointing relationship from the virtual machine physical address to the system physical address.
[0172] It can be understood that when creating page table entries or updating page table entries based on a preset update policy, a situation that does not conform to the page table description information may occur. At this time, the page table description information can be modified, and at the end of the page table generation method process, the page table description information is returned to the user.
[0173] It can be seen that the page table generation method in the embodiments of the present invention forms page table description information and an initial page table structure based on user constraints and fixed constraints, and then constructs a target page table based on the page table description information and the initial page table structure, so that the user can propose different user requests based on different verification requirements, and then form different user constraints, and then construct the corresponding target page table, and then can meet the verification requirements in different verification scenarios during the verification process.
[0174] It can be understood that the page table generation method can enable the user to control the generation of page table entries at each level, support fine-grained testing, and can also update existing page tables, including the attributes of existing page tables and injecting faults, etc., so as to meet the verification requirements in different verification scenarios.
[0175] Next, the page table generation device provided by the embodiments of the present invention is introduced. The device content described below can be considered as a chip verification device or a computer device, which is a functional module set up to implement the page table generation method provided by the embodiments of the present invention. The device content described below can be correspondingly referred to the method content described above.
[0176] Figure 7 The optional block diagram of the page table generation device provided by the embodiments of the present invention is shown. As Figure 7 shown, the device may include:
[0177] A user constraint acquisition module 200, configured to acquire user constraints for generating a page table, where the user constraints are constraint information acquired based on user request parameters;
[0178] An initial processing module 210, configured to determine page table description information for generating a page table and an initial page table structure that conforms to the page table description information based on the user constraints;
[0179] A fixed constraint acquisition module 220, configured to acquire fixed constraints for generating a page table, where the fixed constraints are constraint information preset in a page table generator;
[0180] An update processing module 230, configured to update the page table description information and the initial page table structure based on the fixed constraints;
[0181] A pointing relationship construction module 240, configured to construct a page table pointing relationship corresponding to each level of the page table step by step from high to low in the initial page table structure according to the page table description information, so as to form a target page table.
[0182] Optionally, the user constraint acquisition module 200 is configured to acquire user constraints for generating a page table, including:
[0183] Acquire a page table generation request of a user, where the page table generation request includes request parameters for generating a page table;
[0184] Determine user constraints according to the request parameters.
[0185] Optionally, the pointing relationship construction module 240 is configured to construct a page table pointing relationship corresponding to each level of the page table step by step from high to low in the initial page table structure according to the page table description information, so as to form a target page table, including:
[0186] Configure the control and status register of the initial page table structure to make the control and status register point to the highest-level page table of the initial page table structure;
[0187] Acquire a virtual address based on the page table description information;
[0188] According to the page table description information, starting from the highest-level page table of the initial page table structure, construct the page table pointing relationship corresponding to the virtual address in the current-level page table until the lowest-level page table of the initial page table structure.
[0189] Optionally, the pointing relationship construction module 240 is configured to construct the page table pointing relationship corresponding to the virtual address in the current-level page table, including:
[0190] Query whether there is a page table entry corresponding to the virtual address in the current-level page table;
[0191] If not, create a page table entry corresponding to the virtual address and write the page table entry to a preset storage location.
[0192] Optionally, the pointing relationship construction module 240 is configured to construct the page table pointing relationship corresponding to the virtual address in the current-level page table, further including:
[0193] If there is a page table entry corresponding to the virtual address in the current-level page table, update the page table entry corresponding to the virtual address according to a preset update policy;
[0194] Among them, the update policy is: update based on the existing page table entry, or, execute the step of creating the page table entry corresponding to the virtual address and writing the page table entry to a preset storage location to update the page table entry.
[0195] Optionally, the pointing relationship construction module 240 is further configured to:
[0196] Determine whether there is an address conflict for the virtual address;
[0197] If there is an address conflict, execute again the step of obtaining the virtual address based on the page table description information;
[0198] If not, execute the step of constructing the page table pointing relationship corresponding to the virtual address in the current-level page table starting from the highest-level page table of the initial page table structure according to the page table description information.
[0199] Optionally, the pointing relationship construction module 240 is further configured to:
[0200] Determine whether the virtual address itself and its additional attributes conform to the constraints in the page table description information;
[0201] If not, execute again the step of obtaining the virtual address based on the page table description information;
[0202] If so, execute the step of constructing the page table pointing relationship corresponding to the virtual address in the current-level page table starting from the highest-level page table of the initial page table structure according to the page table description information.
[0203] Optionally, the current-level page table is the lowest-level page table, and the pointing relationship construction module 240 is used to create a page table entry corresponding to the virtual address. Specifically, determine the physical address pointed to by the page table entry, and create the page table entry based on the information of the physical address.
[0204] Optionally, the pointing relationship construction module 240 is further configured to:
[0205] Modify the page table entry according to the exception type in the exception test information to inject an exception.
[0206] Optionally, the pointing relationship construction module 240 is further configured to:
[0207] Judge whether the current-level page table is the lowest-level page table;
[0208] If not, enter the next-level page table and execute the step of querying whether there is a page table entry corresponding to the virtual address in the current-level page table. If so, return the created target page table to the user.
[0209] Optionally, the physical address pointed to by the page table entry is the virtual machine physical address. The pointing relationship construction module 240 is further configured to:
[0210] Generate a host page table, and the page table entries in the host page table are used to construct the pointing relationship from the virtual machine physical address to the system physical address.
[0211] Optionally, the initial page table structure at least includes the highest-level page table of the target page table.
[0212] Optionally, the initial processing module 210 is configured to determine an initial page table structure that meets the page table description information, including: randomizing the data in the initial page table structure within the range defined by the page table description information.
[0213] Optionally, the update processing module 230 is configured to update the initial page table structure, including: randomizing the data in the initial page table structure within the range defined by the updated page table description information.
[0214] Optionally, the user constraints include one or more of the following constraints:
[0215] Attribute constraint, used to determine the attribute of the storage page pointed to by the physical address in the page table;
[0216] Address conflict constraint, used to determine whether there is an address conflict in the addresses in the page table;
[0217] Address range constraint, used to specify that the address range in the page table is within a preset range;
[0218] Address size constraint, used to specify the address size;
[0219] Same-address space type constraint, used to specify whether the address space type of the same address is allowed to change;
[0220] Fault constraint, used to determine whether there is a page fault in the page table.
[0221] An embodiment of the present invention further provides a page table generator. In some embodiments, the page table generator can be configured to execute the page table generation method provided by the embodiment of the present invention.
[0222] An embodiment of the present invention further provides a chip verification system. In some embodiments, the chip verification system can be configured to execute the page table generation method provided by the embodiment of the present invention.
[0223] An embodiment of the present invention further provides a computer device, which may include: at least one memory and at least one processor; the memory stores one or more computer-executable instructions, and the processor invokes the one or more computer-executable instructions to execute the page table generation method provided by the embodiment of the present invention.
[0224] An embodiment of the present invention provides a storage medium, which stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the above-mentioned page table generation method.
[0225] The above describes multiple embodiment solutions provided by the embodiments of the present invention. The optional methods introduced in each embodiment solution can be combined and cross-referenced with each other without conflict, so as to extend a variety of possible embodiment solutions, all of which can be considered as the embodiment solutions disclosed and made public by the embodiments of the present invention.
[0226] Although the embodiments of the present invention are disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention should be subject to the scope defined by the claims.
Claims
1. A page table generation method, characterized in that, Applied to a page table generator, including: Obtain user constraints for generating a page table, where the user constraints are constraint information obtained based on the user's request parameters; Based on the user constraints, determine page table description information for generating a page table and an initial page table structure that conforms to the page table description information, where the page table description information is the conditions that need to be satisfied during the page table generation process; Obtain fixed constraints for generating a page table, where the fixed constraints are constraint information preset in the page table generator; Based on the fixed constraints, update the page table description information and the initial page table structure; According to the page table description information, in the initial page table structure, hierarchically construct the page table pointing relationships corresponding to each level of the page table from high to low to form a target page table.
2. The method according to claim 1, wherein The obtaining of the user constraints for generating a page table includes: Obtain the user's page table generation request, where the page table generation request includes request parameters for generating a page table; Determine user constraints according to the request parameters.
3. The method according to claim 1, characterized in that, The hierarchically constructing the page table pointing relationships corresponding to each level of the page table from high to low in the initial page table structure according to the page table description information to form a target page table includes: Configure the control and status register of the initial page table structure to make the control and status register point to the highest-level page table of the initial page table structure; Based on the page table description information, obtain a virtual address; According to the page table description information, starting from the highest-level page table of the initial page table structure, construct the page table pointing relationship corresponding to the virtual address in the current-level page table until the lowest-level page table of the initial page table structure.
4. The method according to claim 3, wherein The constructing of the page table pointing relationship corresponding to the virtual address in the current-level page table includes: Query whether there is a page table entry corresponding to the virtual address in the current-level page table; If not, create a page table entry corresponding to the virtual address and write the page table entry to a preset storage location.
5. The method according to claim 4, characterized in that The constructing of the page table pointing relationship corresponding to the virtual address in the current-level page table further includes: If there is a page table entry corresponding to the virtual address in the current-level page table, update the page table entry corresponding to the virtual address according to a preset update policy; Wherein, the update policy is: update based on the existing page table entry, or, execute the step of creating a page table entry corresponding to the virtual address and writing the page table entry to a preset storage location to update the page table entry.
6. The method according to claim 3, wherein After obtaining the virtual address based on the page table description information and before hierarchically constructing the page table pointing relationship corresponding to the virtual address in the current-level page table from the highest-level page table of the initial page table structure according to the page table description information, further includes: Determine whether there is an address conflict for the virtual address; If there is an address conflict, execute the step of obtaining the virtual address based on the page table description information again; If not, execute the step of hierarchically constructing the page table pointing relationship corresponding to the virtual address in the current-level page table from the highest-level page table of the initial page table structure according to the page table description information.
7. The method according to claim 3, characterized in that, After obtaining the virtual address based on the page table description information, before constructing the page table pointer relationship corresponding to the virtual address in the current-level page table starting from the highest-level page table of the initial page table structure according to the page table description information, it further includes: Determine whether the virtual address itself and its attached attributes comply with the constraints in the page table description information; If not, execute again the step of obtaining the virtual address based on the page table description information; If it complies, execute the step of constructing the page table pointer relationship corresponding to the virtual address in the current-level page table starting from the highest-level page table of the initial page table structure according to the page table description information.
8. The method according to claim 4 or 5, characterized in that, When the current-level page table is the lowest-level page table, the step of creating a page table entry corresponding to the virtual address is specifically to determine the physical address pointed to by the page table entry and create the page table entry based on the information of the physical address.
9. The method according to claim 4 or 5, characterized in that, If the page table description information includes exception test information and the exception test information indicates that an exception occurs in the current-level page table, then after creating the page table entry corresponding to the virtual address and before writing the page table entry to a preset storage location, it further includes: Modify the page table entry according to the exception type in the exception test information to inject an exception.
10. The method according to claim 4 or 5, characterized in that, After creating the page table entry corresponding to the virtual address and writing the page table entry to a preset storage location, it further includes: Judge whether the current-level page table is the lowest-level page table; If not, enter the next-level page table and execute the step of querying whether there is a page table entry corresponding to the virtual address in the current-level page table. If so, return the created target page table to the user.
11. The method according to claim 8, characterized in that, The physical address pointed to by the page table entry is the virtual machine physical address. After creating the page table entry corresponding to the virtual address and writing the page table entry to a preset storage location, it further includes: Generate a host page table, and the page table entries in the host page table are used to construct the pointer relationship from the virtual machine physical address to the system physical address.
12. The method according to claim 3, wherein The initial page table structure includes at least the highest-level page table of the target page table.
13. The method according to claim 3, characterized in that, In the step of determining the initial page table structure that complies with the page table description information, it includes: randomizing the data in the initial page table structure within the range defined by the page table description information.
14. The method according to claim 3, wherein In the step of updating the initial page table structure, it includes: randomizing the data in the initial page table structure within the range defined by the updated page table description information.
15. The method according to claim 1, wherein The user constraints include one or more of the following constraints: Attribute constraint, used to determine the attributes of the storage page pointed to by the physical address in the page table; Address conflict constraint, used to determine whether there is an address conflict in the addresses in the page table; Address range constraint, used to specify that the address range in the page table is within a preset range; Address size constraint, used to specify the address size; Same address space type constraint, used to specify whether the address space type of the same address is allowed to change; Fault constraint, used to determine whether there is a page fault in the page table.
16. A page table generation device, characterized in that, It includes: A user constraint acquisition module, used to acquire user constraints for generating a page table, and the user constraints are constraint information obtained based on the user's request parameters; An initial processing module, configured to determine page table description information for generating a page table and an initial page table structure that conforms to the page table description information based on the user constraints, where the page table description information is the conditions that need to be satisfied during the page table generation process; A fixed constraint acquisition module, configured to acquire fixed constraints for generating a page table, where the fixed constraints are preset constraint information in the page table generator; An update processing module, configured to update the page table description information and the initial page table structure based on the fixed constraints; A pointing relationship construction module, configured to construct a page table pointing relationship corresponding to each level of the page table step by step from high to low in the initial page table structure according to the page table description information to form a target page table.
17. A page table generator, characterized in that, The page table generator is configured to execute the page table generation method according to any one of claims 1-15.
18. A chip verification system, characterized in that, The chip verification system is configured to execute the page table generation method according to any one of claims 1-15.
19. A computer device, characterized in that, Comprising: At least one memory and at least one processor; The memory stores one or more computer-executable instructions, and the processor invokes the one or more computer-executable instructions to execute the page table generation method according to any one of claims 1-15.
20. A storage medium, characterized in that, The storage medium stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the page table generation method according to any one of claims 1-15.
Citation Information
Patent Citations
Method, system and device for improving reading accuracy of flash memory
CN110232002A
File page table management technique
WO2019127135A1