mrd wrote:
i'm not sure what system-level page cow has to do w/ this, i suppose you're forking a system-level process? anyway, there's no reason why you can't COW system pages as well. you can write-protect supervisor pages on x86.
Hm, looking back at the manual
4.11.3. Page Type
The page-level protection mechanism recognizes two page types:
- Read-only access (R/W flag is 0).
- Read/write access (R/W flag is 1).
When the processor is in supervisor mode and the WP flag in register CR0 is clear (its state following reset initialization), all pages are both readable and writable (write-protection is ignored).
The P6 family, Pentium, and Intel486 processors allow user-mode pages to be write-protected against supervisor-mode access. Setting the WP flag in register CR0 to 1 enables supervisormode sensitivity to user-mode, write-protected pages. This supervisor write-protect feature is useful for implementing a copy-on-write strategy used by some operating systems, such as UNIX* (...)
but further i have (in table 4-2) ...
PDE={Supervisor,Read-Only}, PTE={Supervisor Read-Only} => Supervisor Read/Write* (If the WP flag of CR0 is set, the access type is determined by the R/W flags of the page-directory and page-table entries).
i had cached in /dev/brain that PxE.R/W bit was ignored when PxE.U/S was cleared (supervisor mode), but i admit i haven't tried to catch a #PF due to a supervisor write-protected page, iirc, and certainly not with the CR0.WP flag set ...)
The relation with the 'new process' stuff is that i have some per-process state (like the list of vaddr areas, for instance) that should be cow'd when a process is forked, but that shouldn't be accessible by the user-level software ... Note that i could be nasty and set it with PTE.US=User and PTE.RW=Read-only until a page fault is caught (and hiding it from usermode through segments) and revert it to PTE.US=Supervisor after i generated the local copy of it
-- but i'd prefer avoiding such horrors ...