Demand paging, the RTL8168H, links that come up late, and Ctrl+Alt+F1..F12

- Anonymous memory can be reserved without being backed: large mappings,
  MAP_NORESERVE and PROT_NONE are recorded and each page appears, zeroed,
  on first touch -- from trap() for the program, from uva2ka() for the
  kernel on its behalf. WebKit reserves 4 GB at start and touches a sliver;
  backing it all failed with ENOMEM and Epiphany aborted.
- r8169: the 8168G generation and later (the laptop's 8168H, XID 541) are
  taken from the firmware's out-of-band mode, get their PLL powered, the
  receive gate opened, and their PHY reached through the OCP window. The
  PHY's power-down bit is cleared; the old code kept it while restarting
  autonegotiation. Untested on the hardware so far.
- The network thread follows each device's link into lwIP. The link was
  read once at attach, 0.02 s into boot; real autonegotiation takes
  seconds, so on hardware the interface stayed down for good.
- Twelve terminals, switched with Ctrl+Alt+F1..F12 by default: the keys X
  uses, so the console and the desktop agree. AltGr+F-key is gone from
  the defaults (chvt -c altgr+F brings it back).
- SO_PASSCRED on Unix sockets, with SCM_CREDENTIALS delivered by recvmsg.
  WebKit sets it on its IPC sockets and aborted when refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
Nexoniarz 2026-10-25 11:27:48 +01:00
commit 54b25708c3
24 changed files with 4166 additions and 68 deletions

View file

@ -160,6 +160,11 @@ trap(struct trapframe *tf)
}
unexpected:
// A user page fault on anonymous memory that is reserved but not backed
// yet: the page is made and the instruction runs again. See vm_fault().
if(tf->trapno == T_PGFLT && myproc() && (tf->cs&3) == DPL_USER &&
!(tf->err & 1) && vm_fault(rcr2()) == 0)
break;
if(myproc() == 0 || (tf->cs&3) == 0){
// A kernel-mode trap ends in panic() a dozen lines down, so the console
// can be put into its panic mode *now* -- and it has to be, because the

View file

@ -1134,6 +1134,13 @@ copyuvm(pml4e_t *pgdir, uint64 sz)
return 0;
}
// The PTE for va, if its page tables exist. For vm_fault().
pte_t *
walkpte(pml4e_t *pgdir, const void *va)
{
return walkpgdir(pgdir, va, 0);
}
char*
uva2ka(pml4e_t *pgdir, char *uva)
{
@ -1142,6 +1149,11 @@ uva2ka(pml4e_t *pgdir, char *uva)
pte_t *pte;
pte = walkpgdir(pgdir, uva, 0);
// Anonymous memory not touched yet: backed now, as the program's own
// access would have done. Only for the running process's own table.
if((pte == 0 || (*pte & PTE_P) == 0) && myproc() && pgdir == myproc()->pgdir &&
vm_fault((addr_t)uva) == 0)
pte = walkpgdir(pgdir, uva, 0);
if(pte == 0 || (*pte & PTE_P) == 0)
return 0;
if((*pte & PTE_U) == 0)