Hi Andrew, This patch is not required for this version of the set, I've just been dragging it over from the previous versions. Can you please just drop it and then we'll sort out DAX vs architectures dispute unrelated to this series? Sorry for the hassle. On Wed, Mar 17, 2021 at 03:15:12PM -0700, akpm@xxxxxxxxxxxxxxxxxxxx wrote: > > The patch titled > Subject: mm: add definition of PMD_PAGE_ORDER > has been added to the -mm tree. Its filename is > mm-add-definition-of-pmd_page_order.patch > > This patch should soon appear at > https://ozlabs.org/~akpm/mmots/broken-out/mm-add-definition-of-pmd_page_order.patch > and later at > https://ozlabs.org/~akpm/mmotm/broken-out/mm-add-definition-of-pmd_page_order.patch > > Before you just go and hit "reply", please: > a) Consider who else should be cc'ed > b) Prefer to cc a suitable mailing list as well > c) Ideally: find the original patch on the mailing list and do a > reply-to-all to that, adding suitable additional cc's > > *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** > > The -mm tree is included into linux-next and is updated > there every 3-4 working days > > ------------------------------------------------------ > From: Mike Rapoport <rppt@xxxxxxxxxxxxx> > Subject: mm: add definition of PMD_PAGE_ORDER > > Patch series "mm: introduce memfd_secret system call to create "secret" memory areas", v18. > > This is an implementation of "secret" mappings backed by a file > descriptor. > > The file descriptor backing secret memory mappings is created using a > dedicated memfd_secret system call The desired protection mode for the > memory is configured using flags parameter of the system call. The mmap() > of the file descriptor created with memfd_secret() will create a "secret" > memory mapping. The pages in that mapping will be marked as not present > in the direct map and will be present only in the page table of the owning > mm. > > Although normally Linux userspace mappings are protected from other users, > such secret mappings are useful for environments where a hostile tenant is > trying to trick the kernel into giving them access to other tenants > mappings. > > Additionally, in the future the secret mappings may be used as a mean to > protect guest memory in a virtual machine host. > > For demonstration of secret memory usage we've created a userspace library > > https://git.kernel.org/pub/scm/linux/kernel/git/jejb/secret-memory-preloader.git > > that does two things: the first is act as a preloader for openssl to > redirect all the OPENSSL_malloc calls to secret memory meaning any secret > keys get automatically protected this way and the other thing it does is > expose the API to the user who needs it. We anticipate that a lot of the > use cases would be like the openssl one: many toolkits that deal with > secret keys already have special handling for the memory to try to give > them greater protection, so this would simply be pluggable into the > toolkits without any need for user application modification. > > Hiding secret memory mappings behind an anonymous file allows usage of the > page cache for tracking pages allocated for the "secret" mappings as well > as using address_space_operations for e.g. page migration callbacks. > > The anonymous file may be also used implicitly, like hugetlb files, to > implement mmap(MAP_SECRET) and use the secret memory areas with "native" > mm ABIs in the future. > > Removing of the pages from the direct map may cause its fragmentation on > architectures that use large pages to map the physical memory which > affects the system performance. However, the original Kconfig text for > CONFIG_DIRECT_GBPAGES said that gigabyte pages in the direct map "... can > improve the kernel's performance a tiny bit ..." (commit 00d1c5e05736 > ("x86: add gbpages switches")) and the recent report [1] showed that "... > although 1G mappings are a good default choice, there is no compelling > evidence that it must be the only choice". Hence, it is sufficient to > have secretmem disabled by default with the ability of a system > administrator to enable it at boot time. > > In addition, there is also a long term goal to improve management of the > direct map. > > [1] https://lore.kernel.org/linux-mm/213b4567-46ce-f116-9cdf-bbd0c884eb3c@xxxxxxxxxxxxxxx/ > > > This patch (of 9): > > The definition of PMD_PAGE_ORDER denoting the number of base pages in the > second-level leaf page is already used by DAX and maybe handy in other > cases as well. > > Several architectures already have definition of PMD_ORDER as the size of > second level page table, so to avoid conflict with these definitions use > PMD_PAGE_ORDER name and update DAX respectively. > > Link: https://lkml.kernel.org/r/20210303162209.8609-1-rppt@xxxxxxxxxx > Link: https://lkml.kernel.org/r/20210303162209.8609-2-rppt@xxxxxxxxxx > Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx> > Reviewed-by: David Hildenbrand <david@xxxxxxxxxx> > Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> > Cc: Andy Lutomirski <luto@xxxxxxxxxx> > Cc: Arnd Bergmann <arnd@xxxxxxxx> > Cc: Borislav Petkov <bp@xxxxxxxxx> > Cc: Catalin Marinas <catalin.marinas@xxxxxxx> > Cc: Christopher Lameter <cl@xxxxxxxxx> > Cc: Dan Williams <dan.j.williams@xxxxxxxxx> > Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> > Cc: Elena Reshetova <elena.reshetova@xxxxxxxxx> > Cc: "H. Peter Anvin" <hpa@xxxxxxxxx> > Cc: Ingo Molnar <mingo@xxxxxxxxxx> > Cc: James Bottomley <jejb@xxxxxxxxxxxxx> > Cc: "Kirill A. Shutemov" <kirill@xxxxxxxxxxxxx> > Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> > Cc: Mark Rutland <mark.rutland@xxxxxxx> > Cc: Michael Kerrisk <mtk.manpages@xxxxxxxxx> > Cc: Palmer Dabbelt <palmer@xxxxxxxxxxx> > Cc: Paul Walmsley <paul.walmsley@xxxxxxxxxx> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> > Cc: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx> > Cc: Roman Gushchin <guro@xxxxxx> > Cc: Shakeel Butt <shakeelb@xxxxxxxxxx> > Cc: Shuah Khan <shuah@xxxxxxxxxx> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > Cc: Tycho Andersen <tycho@xxxxxxxx> > Cc: Will Deacon <will@xxxxxxxxxx> > Cc: Hagen Paul Pfeifer <hagen@xxxxxxxx> > Cc: Palmer Dabbelt <palmerdabbelt@xxxxxxxxxx> > Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > --- > > fs/dax.c | 11 ++++------- > include/linux/pgtable.h | 3 +++ > 2 files changed, 7 insertions(+), 7 deletions(-) > > --- a/fs/dax.c~mm-add-definition-of-pmd_page_order > +++ a/fs/dax.c > @@ -49,9 +49,6 @@ static inline unsigned int pe_order(enum > #define PG_PMD_COLOUR ((PMD_SIZE >> PAGE_SHIFT) - 1) > #define PG_PMD_NR (PMD_SIZE >> PAGE_SHIFT) > > -/* The order of a PMD entry */ > -#define PMD_ORDER (PMD_SHIFT - PAGE_SHIFT) > - > static wait_queue_head_t wait_table[DAX_WAIT_TABLE_ENTRIES]; > > static int __init init_dax_wait_table(void) > @@ -98,7 +95,7 @@ static bool dax_is_locked(void *entry) > static unsigned int dax_entry_order(void *entry) > { > if (xa_to_value(entry) & DAX_PMD) > - return PMD_ORDER; > + return PMD_PAGE_ORDER; > return 0; > } > > @@ -1471,7 +1468,7 @@ static vm_fault_t dax_iomap_pmd_fault(st > { > struct vm_area_struct *vma = vmf->vma; > struct address_space *mapping = vma->vm_file->f_mapping; > - XA_STATE_ORDER(xas, &mapping->i_pages, vmf->pgoff, PMD_ORDER); > + XA_STATE_ORDER(xas, &mapping->i_pages, vmf->pgoff, PMD_PAGE_ORDER); > unsigned long pmd_addr = vmf->address & PMD_MASK; > bool write = vmf->flags & FAULT_FLAG_WRITE; > bool sync; > @@ -1530,7 +1527,7 @@ static vm_fault_t dax_iomap_pmd_fault(st > * entry is already in the array, for instance), it will return > * VM_FAULT_FALLBACK. > */ > - entry = grab_mapping_entry(&xas, mapping, PMD_ORDER); > + entry = grab_mapping_entry(&xas, mapping, PMD_PAGE_ORDER); > if (xa_is_internal(entry)) { > result = xa_to_internal(entry); > goto fallback; > @@ -1696,7 +1693,7 @@ dax_insert_pfn_mkwrite(struct vm_fault * > if (order == 0) > ret = vmf_insert_mixed_mkwrite(vmf->vma, vmf->address, pfn); > #ifdef CONFIG_FS_DAX_PMD > - else if (order == PMD_ORDER) > + else if (order == PMD_PAGE_ORDER) > ret = vmf_insert_pfn_pmd(vmf, pfn, FAULT_FLAG_WRITE); > #endif > else > --- a/include/linux/pgtable.h~mm-add-definition-of-pmd_page_order > +++ a/include/linux/pgtable.h > @@ -28,6 +28,9 @@ > #define USER_PGTABLES_CEILING 0UL > #endif > > +/* Number of base pages in a second level leaf page */ > +#define PMD_PAGE_ORDER (PMD_SHIFT - PAGE_SHIFT) > + > /* > * A page table page can be thought of an array like this: pXd_t[PTRS_PER_PxD] > * > _ > > Patches currently in -mm which might be from rppt@xxxxxxxxxxxxx are > > mm-add-definition-of-pmd_page_order.patch > mmap-make-mlock_future_check-global.patch > riscv-kconfig-make-direct-map-manipulation-options-depend-on-mmu.patch > set_memory-allow-set_direct_map__noflush-for-multiple-pages.patch > set_memory-allow-querying-whether-set_direct_map_-is-actually-enabled.patch > mm-introduce-memfd_secret-system-call-to-create-secret-memory-areas.patch > pm-hibernate-disable-when-there-are-active-secretmem-users.patch > arch-mm-wire-up-memfd_secret-system-call-where-relevant.patch > secretmem-test-add-basic-selftest-for-memfd_secret2.patch > -- Sincerely yours, Mike.