This invention relates generally to computers, and more particularly to computer memory address translation.
A computer processor accesses system memory to retrieve or store data within the system memory. Specifically, the processor uses the physical address of data in the memory to identify and access the data. However, the physical address where data is stored in the memory is not the address that the processor uses to index the data during internal manipulations. Rather, the processor assigns a virtual address to data being processed according to program instructions. Thus, memory accesses often require the translation of virtual addresses into physical addresses.
Many processors use virtual or demand-paged memory schemes, where sections of an execution environment of a program are mapped into physical memory as needed. Virtual memory schemes allow the use of physical memory much smaller in size than the virtual address space of the processor and also provide a mechanism for memory protection so that multiple programs sharing the same physical memory do not adversely interfere with each other.
In a virtual memory scheme, the virtual and physical address spaces are divided into blocks of contiguous addresses, so that virtual and physical addresses belong to at most one block. The blocks can be of a constant size or can have variable sizes as dictated by system and/or program execution requirements.
These blocks are customarily referred to as pages if they are of a constant or fixed size. If variable sized blocks are used, the blocks are referred to as segments. Thus, the virtual address space may be divided into either segments or pages. A typical page size may be approximately 4 kilobytes.
Various embodiments are illustrated by way of example and not by way of limitation in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that references to “an,” “one,” or “various” embodiments in this disclosure are not necessarily to the same embodiment, and such references mean at least one.
Various embodiments disclosed herein implement an efficient address translation scheme that yields a translated address, a memory type for the translated address, and a fault bit for the translation. In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the various embodiments. It will be apparent, however, to one skilled in the art that the embodiments may be practiced without some of these specific details. For example, various signals, layout patterns and logical circuits may be modified according to the teachings of the various embodiments.
The following description and the accompanying drawings provide examples for the purposes of illustration. However, these examples should not be construed in a limiting sense as they are not intended to provide an exhaustive list of all possible implementations. In other instances, well-known structures and devices are omitted or simplified in order to avoid obscuring the details of the various embodiments.
Referring now to
The memory type can be stored in multiple data structures and accessed as necessary. Among other data, the memory type indicates whether any translation should occur for physical addresses from a given address range and whether accesses to a given address range should cause a fault. In various embodiments, an offset bit in the memory type indicates whether translation should occur. If no translation should occur, then the translated address is the same as the physical address. If translation is permitted to occur, the matching and combining functions described below are performed.
At block 10 of
Disjoint segments are desirable because each address only belongs to one segment. This eliminates the need for conflict resolution, which is necessary when two different mappings are produced by an address that belongs to two overlapping segments.
Assuming the memory type for the first address indicates that translation should occur, an interim base value is computed from a base value associated with the first address at block 12. The interim first address and the interim base value are compared at block 14. At decision block 16, it is determined whether the first address should be translated.
The decision at block 16 is based on whether the interim first address and the interim base value “match,” as shown by the comparison carried out at block 14. If the interim first address and the interim base value match, the first address can be translated. The match function is performed to verify that a valid translation exists for the first address.
In various embodiments, the following equation is used to determine whether the interim first address and the interim base value match:
(Address&Mask)=(Base&Mask) Equation 1
The left side of the equation represents the interim first address, and the right side of the equation represents the interim base value. Specifically, a Mask value associated with the first address is separately applied (e.g., with a logical AND function) to both the first address and the base value.
Every bit position specified by Mask is retained for comparison. For example, if the Mask value is 11110000, then the four most significant bits of the first address (e.g., the interim first address once the Mask is applied) would be retained for comparison with the interim base value (e.g., the four most significant bits of the base value).
If the values on each side of the equation are equivalent, then the interim first address and the interim base value match. If not, there is not a valid translation for the first address.
It is worth noting that other matching mechanisms can be used. For example, a range check can be used to determine whether a first address can be validly translated.
Regardless of the matching mechanism used, if there is a match and the memory type indicates that an offset should be applied, the first address is “combined” with an offset value to obtain a second address (e.g., translated address) at block 20. If there is no match, a fault alert is issued at block 18. The respective actions taken at block 20 and block 18 will be discussed in turn.
If a match occurs, the combining function of block 20 in one embodiment is a bitwise logical operation similar to the matching equation (e.g., Equation 1) described above. Specifically, the following equation is used to translate the first address, Address1, to obtain the second address, Address2:
Address2=(Address1&˜Mask)|(Offset&Mask) Equation 2
The “&” represents the logical AND function, and the “|” represents the logical OR function. The “˜” represents the inverse of the value immediately following.
Thus, the Offset bits specified by Mask will replace the Address1 bits specified to be replaced by ˜Mask. For example, if Address1 is AAAAAAAA, Offset is TTTTTTTT, and Mask is 11110000, then Address2 will be TTTTAAAA. This result is due to the fact that Mask specified that the four most significant bits of Offset should replace the four most significant bits of Address1, and ˜Mask specified that the four least significant bits of Address1 should be retained.
In other embodiments, the combining function of block 20 is accomplished by adding the offset value to the first address to obtain the second address.
Various embodiments further include determination of the memory type of the translated address. This determination process is conducted either concurrently with translation or after the translation is complete. In one embodiment, the memory type for the translated address is associated with the base value that matched the physical address.
Focusing now on block 18, a fault alert is issued to indicate that no mapping exists for the physical address. Typically, no mapping will exist for a physical address if the guest operating system attempts to access a region of memory that does not have a device or address that should respond to such an access attempt.
The fault alert can also entail a notification that an attempt has been made to access a particular segment (e.g., the segment to which the physical address belongs). For example, such a notification can be issued upon the detection of whether a fault bit has been set for the particular segment. Depending on the embodiment, the fault bit can be set in one or more values. In one embodiment, the fault bit is set in the memory type associated with the base value that matched the physical address to be translated.
For example, when a physical address bit matches, the matched bit is combined with the appropriate bit from the offset value, as previously described, to obtain a translated bit. The translated bit is combined with all of the other properly matched and translated bits to form the translated address.
In an embodiment, computer system 22 includes memory 42, at least a portion of which is divided into a plurality of segments, comparison logic circuitry coupled to the memory, and combination logic circuitry coupled to the comparison logic circuitry and to the memory. Although not shown in
This matching operation is carried out on a bit-by-bit basis and may be carried out in parallel. Once the matching operation is carried out for every bit (e.g., BitMatch[i] determined for all values of i), an overall match, MatchN, is determined, as shown in
The translated address is calculated by OR gate 34. Pass gate 36 will only allow the signal from OR gate 34 to pass as the translated address if MatchN (from
Translation unit 50 also includes table 54 of variable range MTRRs. The variable range MTRRs define the memory type for a number of variable size ranges. The ranges are defined by a base value and a mask value. Each range is also associated with a valid bit, a memory type (which can include a fault bit and an offset bit, the offset bit to indicate whether or not to translate), and an offset value. These values are used, as described above, to determine whether to translate a first address and, if necessary, to translate the first address.
Fault detection logic 56 represents fault detection circuitry coupled to comparison logic circuitry (the logical representation of which is shown in
MTRRdefType register 58 controls the operation of translation unit 50. Specifically, MTRRdefType register 58 has an enable field (“E”) that controls whether the MTRRs, both fixed and variable, are active. The fixed enable field (“FE”) of MTRRdefType register 58 controls whether the fixed range registers are enabled. Thus, when the enable field indicates that the MTRRs are active, translation can occur. If the MTRRs are inactive, the memory type specified by the Type field from MTRRdefType register 58 is used.
Thus, translation unit 50 takes an Input Physical Address (e.g., first address) and translates the address, if necessary, and outputs the Final Physical Address (e.g., second address), the memory type for the Final Physical Address, and a Fault Bit. Multiplexer 60 outputs a memory type from either table 52 of fixed range MTRRs, table 54 of variable range MTRRs, or from MTRRdefType register 58.
Multiplexer 62 outputs an address based on whether the offset bit is set. If the offset bit indicates that no translation should occur, the Final Physical Address will be the same as the Input Physical Address. If the offset bit indicates that the address should be translated, the translated address obtained from table 54 of variable range MTRRs (e.g., via matching and combining described above) will be the Final Physical Address.
It is to be understood that even though numerous characteristics and advantages of various embodiments have been set forth in the foregoing description, together with details of structure and function, this disclosure is illustrative only. Changes may be made in detail, especially matters of structure and management of parts, without departing from the scope of the various embodiments as expressed by the broad general meaning of the terms of the appended claims.
Number | Name | Date | Kind |
---|---|---|---|
3996449 | Attanasio | Dec 1976 | A |
4084225 | Anderson et al. | Apr 1978 | A |
4247905 | Yoshida et al. | Jan 1981 | A |
4347565 | Kaneda et al. | Aug 1982 | A |
4430709 | Schleupen | Feb 1984 | A |
4802084 | Ikegaya | Jan 1989 | A |
4975836 | Hirosawa | Dec 1990 | A |
5187802 | Inoue | Feb 1993 | A |
5230069 | Brelsford et al. | Jul 1993 | A |
5295251 | Wakui | Mar 1994 | A |
5319760 | Mason et al. | Jun 1994 | A |
5361375 | Ogi | Nov 1994 | A |
5437033 | Inoue et al. | Jul 1995 | A |
5469557 | Salt | Nov 1995 | A |
5506975 | Onodera | Apr 1996 | A |
5511217 | Nakajima et al. | Apr 1996 | A |
5522075 | Robinson et al. | May 1996 | A |
5555385 | Osisek | Sep 1996 | A |
5555414 | Hough | Sep 1996 | A |
5561814 | Glew et al. | Oct 1996 | A |
5564040 | Kubala | Oct 1996 | A |
5574936 | Ryba | Nov 1996 | A |
5737604 | Miller et al. | Apr 1998 | A |
5778407 | Glew et al. | Jul 1998 | A |
5819061 | Glassen et al. | Oct 1998 | A |
5854913 | Goetz et al. | Dec 1998 | A |
5956408 | Arnold | Sep 1999 | A |
5978475 | Schneier | Nov 1999 | A |
6044478 | Green | Mar 2000 | A |
6075938 | Bugnion et al. | Jun 2000 | A |
6088262 | Nasu | Jul 2000 | A |
6093213 | Favor | Jul 2000 | A |
6173417 | Merrill | Jan 2001 | B1 |
6175924 | Arnold | Jan 2001 | B1 |
6182089 | Ganapathy et al. | Jan 2001 | B1 |
6188257 | Buer | Feb 2001 | B1 |
6272637 | Little et al. | Aug 2001 | B1 |
6275933 | Fine | Aug 2001 | B1 |
6282650 | Davis | Aug 2001 | B1 |
6314409 | Schneck et al. | Nov 2001 | B1 |
6374317 | Ajanovic et al. | Apr 2002 | B1 |
6378068 | Foster | Apr 2002 | B1 |
6397242 | Devine et al. | May 2002 | B1 |
6625715 | Mathews | Sep 2003 | B1 |
6681311 | Gaskins et al. | Jan 2004 | B1 |
Number | Date | Country |
---|---|---|
4217444 | Dec 1992 | DE |
0473913 | Mar 1992 | EP |
0 549 931 | Jul 1993 | EP |
0 892 521 | Jan 1999 | EP |
0 961 193 | Dec 1999 | EP |
0 965 902 | Dec 1999 | EP |
1 055 989 | Nov 2000 | EP |
1 056 014 | Nov 2000 | EP |
1 085 396 | Mar 2001 | EP |
1 271 277 | Jan 2003 | EP |
02000076139 | Mar 2000 | JP |
WO 9524696 | Sep 1995 | WO |
WO 9812620 | Mar 1998 | WO |
WO 9918511 | Apr 1999 | WO |
WO 9918511 | Apr 1999 | WO |
WO 9965579 | Dec 1999 | WO |
WO 9965579 | Dec 1999 | WO |
WO 0021238 | Apr 2000 | WO |
WO 0163994 | Aug 2001 | WO |
WO 01 75564 | Oct 2001 | WO |
WO 0201794 | Jan 2002 | WO |
WO 02 17555 | Feb 2002 | WO |
WO 02060121 | Aug 2002 | WO |
WO 02 086684 | Oct 2002 | WO |
WO 03058412 | Jul 2003 | WO |
Number | Date | Country | |
---|---|---|---|
20030163662 A1 | Aug 2003 | US |