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

@ -546,6 +546,7 @@ int sockbind_in(struct socket*, uint addr, ushort port);
int sockconnect_in(struct socket*, uint addr, ushort port);
int sock_domain(struct socket*);
int sock_peercred(struct socket*, int*, uint*, uint*);
int sock_passcred(struct socket*);
// Socket options. The syscall layer does the user-memory marshalling and these
// do the work, because struct socket's fields live in kernel/net/unix.c and the
// syscall layer deliberately cannot see them.
@ -733,6 +734,7 @@ int net_eth_detach(struct device *);
int net_detach(struct device *);
int net_attach_late(struct device *);
int net_eth_poll(void);
void net_eth_link_check(void);
int net_eth_count(void);
void net_eth_counts(int i, uint64 *rx, uint64 *tx);
struct netif *net_eth_netif(int i);
@ -805,6 +807,8 @@ void inotify_file(struct file *f, uint32 mask);
uint32 inotify_cookie(void);
int ev_fionread(struct evobj *o);
int pipe_avail(struct pipe *p);
int vm_fault(addr_t va);
pte_t* walkpte(pml4e_t *pgdir, const void *va);
int path_identity(char *path, int follow, int onlydir, uint *dev, uint64 *inum);
int memfd_rw(int id, int user, uint64 buf, uint64 off, int n, int writing);
void shm_detach(int id);

View file

@ -92,12 +92,10 @@
// leaves `chvt N` as the only way to switch, which is a legitimate choice on
// a machine whose host takes everything.
//
// The default is AltGr+F1..F6, and the "AltGr wants it" line above needs
// reading carefully: what a Polish layout wants is AltGr+*letter*. AltGr with
// a function key produces nothing on any layout, no window manager binds it,
// and no application asks for it. Right Alt being a separate modifier bit
// here is what makes the distinction expressible at all -- it used to share
// ALT, which is harmless for typing and useless for this.
// The default is Ctrl+Alt+F1..F12: the keys X switches with, so the console
// and the desktop answer the same chord. It used to be AltGr+F-key, which
// nothing else claims -- Right Alt being a separate modifier bit here is what
// makes that expressible, and `chvt -c altgr+F` still sets it.
#define KBD_VT_SWITCH (KBD_SPECIAL + 0x20)
// Previous / next terminal, on the same modifiers as the chord above. The

View file

@ -26,10 +26,10 @@
#include "core/param.h"
#include "uapi/posix.h"
// Six, and Linux's numbering: /dev/tty1 through /dev/tty6, reached with
// Alt+1..Alt+6. A seventh is deliberately not bound -- that is where a
// display server goes, and Schcom will want it.
#define NVT 6
// Twelve, one per function key, and Linux's numbering: /dev/tty1 through
// /dev/tty12, reached with Ctrl+Alt+F1..F12 (and plain Alt on the text
// console). The key codes leave room for sixteen; see KBD_VT_SWITCH.
#define NVT 12
// A cell.
//

View file

@ -349,6 +349,7 @@ struct socket {
int o_keepalive;
int o_broadcast;
int o_nodelay;
int o_passcred; // SO_PASSCRED: SCM_CREDENTIALS on every recvmsg
// Descriptors sent to this socket and not yet received. They live on the
// *receiving* side, next to the bytes they were sent with, because that is

View file

@ -432,6 +432,7 @@ struct statfs {
#define MAP_PRIVATE 0x02
#define MAP_FIXED 0x10
#define MAP_ANONYMOUS 0x20
#define MAP_NORESERVE 0x4000
// waitpid() options. The kernel tests `options & 1`; this is that bit, named.
#define WNOHANG 0x001