HomeFreeBSD

memfd_create: simplify HUGETLB support a little bit

Description

memfd_create: simplify HUGETLB support a little bit

This also fixes a minor issue that was missed in the initial review; the
layout of the MFD_HUGE_* flags is actually not 1:1 bit:flag -- it instead
borrowed the Linux convention of how this is laid out since it was
originally implemented on Linux, the top 6 bits represent the shift required
for the requested page size.

This allows us to remove the flag <-> pgsize mapping table and simplify the
logic just prior to validation of the requested page size.

While we're here, fix two small nits:

  • HUGETLB memfd shouldn't exhibit the SHM_GROW_ON_WRITE behavior. We can only grow largepage shm by appropriately aligned (i.e. requested pagesize) sizes, so it can't work in the typical/sane fashion. Furthermore, Linux does the same, so let's be compatible.
  • We don't allow MFD_HUGETLB without specifying a pagesize, so no need to check for that later.

Reviewed by: kib (slightly earlier version)

Details

Provenance
kevansAuthored on
Parents
rS365623: Don't clear reserved bits per RealTek
Branches
Unknown
Tags
Unknown