On 10/26/22 01:42, Alex Bennée wrote:
Not a problem with this patch but I was a little confused by PAGE_VALID
because its the one "special" flag not documented in cpu-all.h:

   /* same as PROT_xxx */
   #define PAGE_READ      0x0001
   #define PAGE_WRITE     0x0002
   #define PAGE_EXEC      0x0004
   #define PAGE_BITS      (PAGE_READ | PAGE_WRITE | PAGE_EXEC)

The above are self explanatory as they mirror the mmap flags. But what
does PAGE_VALID really mean.

It exists so that unmapped pages have flags == 0 and
mmap(..., PROT_NONE, ...) pages have flags != 0.

Perhaps a better name would have been "allocated".
You are perhaps 25 years to late to bikeshed that name.  :-)

The only place
that ever seems to clear the flag is the PPC mmu_helper code in a
response to a particular TLB operations. Should that code instead be
doing page_set_flags(PAGE_RESET)?

Heh.  ppc seems to have re-used the symbol for its own internal data structure.
Well, considering that it's got to pass on "prot" to tlb_set_page at some point, re-using those names isn't a horrible idea.

Anyway, you can see target_munmap clear PAGE_VALID here:

        page_set_flags(start, start + len, 0);

PAGE_RESET exists to distinguish mmap replacing an exiting mapping (old backing storage replaced) from mprotect (old backing storage retained, new permissions applied).


r~

Reply via email to