The mprotect syscall acts on page granularity and that page size may
vary (e.g., largepage mappings).
Remove some text that dates to the BSD 4.4 import and is misleading.
Sponsored by: DARPA
Differential D30442
mprotect.2: Update text for largepages brooks on May 24 2021, 8:47 PM. Authored by Tags None Referenced Files
Details The mprotect syscall acts on page granularity and that page size may Remove some text that dates to the BSD 4.4 import and is misleading. Sponsored by: DARPA
Diff Detail
Event TimelineComment Actions It was completely wrong before adding largepage support, but now it is closer to being correct than not. I propose to remove the second sentence from your diff, and change 'an entire region' to 'an entire large page'. Comment Actions Maybe something like: "Page sizes many vary within a virtual address space; the granularity of page protection changes may be as large as an entire large page." That being said, I dislike these semantics. It seems to introduce the potential for protection errors and IMO we should require that addr..addr+len should cover the whole page for large pages so there is no potential confusion of intent. Comment Actions Won't we demote large pages if the protections of sub-pages differ? I don't think we (yet) have a flag to make mappings use a minimum page size (e.g. to force the use of 2MB pages and not permit demoting to 4K pages) for which the effect would then be as Brooks' new sentence describes. Comment Actions superpages != largepages. Largepages are relatively new thing, for them we guarantee that
Comment Actions If mprotect(2) can force the breakup of pages suitable for superpage mappings, then it opens a vector for a denial of performance by mapping and breaking up all the superpages held by the operating system. My take would be to fail mprotect(2) requests that would force such breakups. The application could then retry for the larger page. Comment Actions mprotect(2) changes protection of the specific mapping. The underlying physical pages cannot be 'broken' by mprotect, in the sense that they continue to be the properly aligned physically contiguous run of suitable size. Pmap module routinely breaks (demotes) superpage mapings for different reason, and trying to disable traditionally enabled user actions is wrong. Esp. because superpages are transparent and user does not have neither control nor visibility when the mapping is promoted.
Comment Actions Kostik, the implications of (3) may not be obvious to everyone, specifically, that an mprotect() that does not cover an entire explicit largepage will fail. Comment Actions I've to update the description to match what I believe is currently implemented. I've not mentioned largepages by name because I can find no documentation of them to reference. I've also attempted to improve the description of prot (that will be a separate commit).
Comment Actions For the purposes of this discussion, I think you should just go with your original proposal as it is clearly a useful step forward. Comment Actions Arg, I somehow included this review number in a ports commit message. I'll open a new one. |