The Bit That Survives the Context Switch
matters at ISA because the G bit is bit 5 of the Sv39 leaf page-table entry, defined by the privileged architecture, and the verified decision procedure is the specification's own contract: a global entry's translation applies without consulting the ASID, and an sfence.vma that names one ASID must leave global entries cached. The module's walks under ASIDs 1, 2, and 9 checked exactly that shape: global equals 1, the address-space ID never consulted.
not at Microarch because the verified property is the contract's decision procedure, identical on every conforming implementation: the 196.216 ns per lookup figure is the host model's linear scan over 256 slots, an artifact of the model, and no hardware TLB, pipeline, or cache behavior was measured or asserted.
not at Firmware because the G contract runs between the hart and the page tables, and nothing in the verified behavior depends on firmware: marking mappings global and choosing address-space IDs is the kernel's work, and the property holds identically however the firmware beneath it behaves.
matters at Kernel because the kernel is the layer that names address spaces: it picks the ASIDs, decides whether its own mappings are marked global, and issues the address-space-scoped fences on context switch. The module's boundary check makes this concrete, because xv6 never sets a G bit and builds every satp with ASID 0, so its kernel never asks the question this bit answers.
not at Algorithm because the lookup predicate is not a portable mechanism: the claim has no meaning on a machine without a G bit in its page-table entries, and the module proved the architecture's rule as written, not a software technique that travels.
Take virtual page number 0x12345, mapped with its page-table G bit set. Walk it under address-space IDs 1, 2, and 9: all three land on the same physical address, (0xABCDE shifted left by 12) plus the 0x678 offset, and every walk reports global equals 1. The address-space ID is never consulted. Now the contrast: the same virtual page number with G clear under ASID 1 lands on a page built from 0x11111, and under ASID 2 on a page built from 0x22222. Same number, different pages, because without the G bit the address-space name is part of the key.
Here is the cost it removes. The kernel is mapped at the same virtual addresses in every process, and every context switch loads a new satp register carrying a new ASID. A full TLB flush on every switch would throw away the kernel's translations too, and each one costs three page-table memory reads to rebuild, while the TLB holds only dozens to hundreds of entries. The alternatives are flushing everything every time or storing the kernel's mappings once per address space, the same entry wearing N name tags. The G bit says: this mapping exists in all address spaces, store it once, and when the fence names a single ASID, leave it alone.
The privileged specification says it plainer than I can. "Global mappings were devised to reduce the cost of context switches." And then the sentence that carries the whole contract: "failing to mark a global mapping as global merely reduces performance, whereas marking a nonglobal mapping as global is an error." G is a performance promise, not a correctness one, and lying in the wrong direction breaks isolation, because one process would start reaching another's pages through a shared cache entry.
The entire rule fits in one line of the test bench, taken verbatim from the lookup it verified:
if (e->valid && e->vpn == vpn && (e->global || e->asid == asid)) {
r.hit = 1;
r.pa = e->pa;
return r;
}
Global entries skip the ASID check entirely; non-global entries match only on an ID match. The module proved the decision procedure, not silicon: 201,850 checks against an independently written spec table, zero mismatches, with the full result stream checksumming identically under -O0, -O2, and ASan plus UBSan. The rule held for 4K pages, 2M megapages, and 1G gigapages alike, and a branch entry's G bit was correctly ignored, because only the leaf's G decides. Two honest boundaries: the spec's own wording forks on whether a non-leaf G implies globality below it, so the lab tested the leaf-only reading and named the other as an open question. And the boundary I like best: xv6 sets no G bits and builds every satp with ASID 0, so the kernel I study never asks this question. One sentence to carry away: a translation is either named by its address space or it belongs to all of them, and one bit in the page table is the entire difference.
Code: lab/147-pte-global-bit