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

@ -1030,7 +1030,7 @@ SYSCALL_DEFINE(recvmsg)
struct file *file;
struct msghdr m;
struct file *fs[SCM_MAXFD];
char cbuf[CMSG_SPACE(SCM_MAXFD * sizeof(int))];
char cbuf[CMSG_SPACE(SCM_MAXFD * sizeof(int)) + CMSG_SPACE(12)];
int ufd[SCM_MAXFD];
addr_t umsg;
uint64 i, clen = 0;
@ -1141,6 +1141,35 @@ SYSCALL_DEFINE(recvmsg)
}
}
// SO_PASSCRED: who sent it, after any descriptors. On a connected Unix
// socket that is always the peer, so its recorded credentials are the
// answer. WebKit sets the option on its IPC sockets and aborts if it is
// refused.
if (sock_passcred(s) && got > 0) {
struct { int pid; uint uid, gid; } cr;
uint64 off = clen ? CMSG_SPACE(clen - CMSG_LEN(0)) : 0;
if (sock_peercred(s, &cr.pid, &cr.uid, &cr.gid) == 0) {
if (m.msg_control && off + CMSG_LEN(sizeof(cr)) <= m.msg_controllen) {
struct cmsghdr c;
char tmp[CMSG_SPACE(sizeof(cr))];
memset(tmp, 0, sizeof(tmp));
c.cmsg_len = CMSG_LEN(sizeof(cr));
c.cmsg_level = SOL_SOCKET;
c.cmsg_type = 2; // SCM_CREDENTIALS
memmove(tmp, &c, sizeof(c));
memmove(CMSG_DATA((struct cmsghdr *)tmp), &cr, sizeof(cr));
uint64 n2 = CMSG_SPACE(sizeof(cr));
if (off + n2 > m.msg_controllen)
n2 = CMSG_LEN(sizeof(cr));
if (copy_to_user((addr_t)m.msg_control + off, tmp, n2) < 0)
return -EFAULT;
clen = off + n2;
} else {
mflags |= MSG_CTRUNC;
}
}
}
// The address, for the family that has one. Same rule as recvfrom: a Unix
// socket reports a length of zero rather than a sockaddr full of nothing.
if (m.msg_name) {