Date: Sat, 12 Apr 2008 16:53:07 -0700 (PDT) From: Matthew Dillon <dillon@apollo.backplane.com> To: "Kip Macy" <kip.macy@gmail.com> Cc: hackers@freebsd.org, Jonathan Chen <jon@freebsd.org> Subject: Re: mlock & COW Message-ID: <200804122353.m3CNr7sR066379@apollo.backplane.com> References: <20080309212441.GA56523@porthos.spock.org> <200804122156.m3CLuot5065753@apollo.backplane.com> <b1fa29170804121533q792b6491u106794ce722e78e3@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
:> vm_map_lookup() line 3161 and line 3297 (FreeBSD current). Commenting
:> those out will allow the COW on the user-wired page:
:>
:> if ((entry->eflags & MAP_ENTRY_USER_WIRED) &&
:> (entry->eflags & MAP_ENTRY_COW) &&
:> (fault_type & VM_PROT_WRITE) &&
:> (fault_typea & VM_PROT_OVERRIDE_WRITE) == 0) {
:> RETURN(KERN_PROTECTION_FAILURE);
:> }
Ok, never mind on commenting out that code in vm_map_lookup(),
it won't work. In fact, it will crash the machine even faster.
It's messy both ways, but marginally less messy if you do it in the
vm_fault() code.
The problem with fixing it in the fault code is that the vm_fault()
routine is called by the wiring and unwiring code and also by code which
undoes failed wirings (where the entry flags do not reflect what the
caller wants vm_fault() to do), so vm_fault() can't just check the entry
flags and automatically user-wire.
To do it without rewriting the whole mess (and rewriting is not a bad
idea), the platform trap code needs to call vm_fault() with a new
flag VM_FAULT_AUTOWIRE, then vm_map_lookup() needs to set the contents
of &fs.wired whether it succeeds or fails, then vm_fault(), upon
seeing result == KERN_PROTECTION_FAILURE, must check whether
VM_FAULT_AUTOWIRE was specified and if so check fs.wired to see if the
mapping failed due to incompatible protections on a user wired
mapping, and THEN it can set VM_FAULT_USER_WIRE in fault_flags and
continue normally.
And on top of all of that I'm still not sure whether the originally
underlying read-only paged that was COW'd will be properly unwired.
As I said, messy.
-Matt
Matthew Dillon
<dillon@backplane.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200804122353.m3CNr7sR066379>
