- index = (virt >> I386_LPGSHIFT);
- virt += (uintptr_t)(phys & I386_LPGMASK);
- phys = ((phys & ~((uint64_t)I386_LPGMASK)) | INTEL_PTE_PS | INTEL_PTE_VALID | INTEL_PTE_WRITE);
- BootstrapPTD[index] = phys;
- invlpg(virt);
- BootstrapPTD[index + 1] = (phys + I386_LPGBYTES);
- invlpg(virt + I386_LPGBYTES);
+ default:
+ asm("cli;hlt;");
+ break;
+ }
+ if (phys < IMAGE2_AREA) {
+ // first 4Gb is all mapped,
+ // and do not expect source areas to cross 4Gb
+ return phys;
+ }
+ index = (virt >> I386_LPGSHIFT);
+ virt += (uintptr_t)(phys & I386_LPGMASK);
+ phys = ((phys & ~((uint64_t)I386_LPGMASK)) | INTEL_PTE_PS | INTEL_PTE_VALID | INTEL_PTE_WRITE);
+ if (phys == BootPTD[index]) {
+ return virt;
+ }
+ BootPTD[index] = phys;
+ invlpg(virt);
+ BootPTD[index + 1] = (phys + I386_LPGBYTES);
+ invlpg(virt + I386_LPGBYTES);