Question

Page 81 of the following R4000 documentation: http://www.scribd.com/doc/53181649/70/EntryLo0-2-and-EntryLo1-3-Registers

Shows one global bit in each TLB entry (which makes sense). If the global bit is set in the TLB entry, then the ASID is ignored during lookup.

However, on the following page, the EntryHi register has a reserved (0) field in place of the TLB entry's global bit (as mentioned in the header on page 82). In its place, there are two global bits, one in each EntryLo{0,1} register.

Several sources (including "See MIPS Run") suggest that, when writing a TLB entry using the TLBW instruction, if the EntryLo0 (G) and EntryLo1 (G) bits are not identical, "bad things will happen." Other sources, such as a forum post on linux-mips.org, (http://www.linux-mips.org/archives/linux-mips/2003-04/msg00226.html) suggest that "in other words, writing a TLB entry with only one of the G bits in the EntryLo{0,1} register pair set will result in a TLB entry with the G bit cleared." (Which, in and of itself, is unclear what exactly will happen -- "something bad", or a TLB entry with its G bit clear).

What is the reason for two global bits, then? Is it in place for legacy support, or am I missing out on something?

Was it helpful?

Solution

The answer to this can be found in MIPS® Architecture For Programmers Volume III: The MIPS32® and microMIPS32™ Privileged Resource Architecture, available at mips.com (registration required). According to Table 9.5 in that document the G bit means:

Global bit. On a TLB write, the logical AND of the G bits from both EntryLo0 and EntryLo1 becomes the G bit in the TLB entry. If the TLB entry G bit is a one, ASID comparisons are ignored during TLB matches. On a read from a TLB entry, the G bits of both EntryLo0 and EntryLo1 reflect the state of the TLB G bit.

In other words if you want the G bit to be set, you must set it in both EntryHi and EntryLo registers. The G bit will not be set if EntryHi and EntryLo disagree.

Why was it done this way? It's as good a way as any, and it's a little easier on the system programmer's memory than the alternatives.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top