The patch titled Subject: x86/mm: introduce __set_memory_prot() has been added to the -mm tree. Its filename is x86-mm-introduce-__set_memory_prot.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/x86-mm-introduce-__set_memory_prot.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/x86-mm-introduce-__set_memory_prot.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: Logan Gunthorpe <logang@xxxxxxxxxxxx> Subject: x86/mm: introduce __set_memory_prot() For use in the 32bit arch_add_memory() to set the pgprot type of the memory to add. Link: http://lkml.kernel.org/r/20200306170846.9333-5-logang@xxxxxxxxxxxx Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx> Reviewed-by: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Borislav Petkov <bp@xxxxxxxxx> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> Cc: Andy Lutomirski <luto@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Eric Badger <ebadger@xxxxxxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Paul Mackerras <paulus@xxxxxxxxx> Cc: Will Deacon <will@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/x86/include/asm/set_memory.h | 1 + arch/x86/mm/pat/set_memory.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) --- a/arch/x86/include/asm/set_memory.h~x86-mm-introduce-__set_memory_prot +++ a/arch/x86/include/asm/set_memory.h @@ -34,6 +34,7 @@ * The caller is required to take care of these. */ +int __set_memory_prot(unsigned long addr, int numpages, pgprot_t prot); int _set_memory_uc(unsigned long addr, int numpages); int _set_memory_wc(unsigned long addr, int numpages); int _set_memory_wt(unsigned long addr, int numpages); --- a/arch/x86/mm/pat/set_memory.c~x86-mm-introduce-__set_memory_prot +++ a/arch/x86/mm/pat/set_memory.c @@ -1792,6 +1792,19 @@ static inline int cpa_clear_pages_array( CPA_PAGES_ARRAY, pages); } +/* + * _set_memory_prot is an internal helper for callers that have been passed + * a pgprot_t value from upper layers and a reservation has already been taken. + * If you want to set the pgprot to a specific page protocol, use the + * set_memory_xx() functions. + */ +int __set_memory_prot(unsigned long addr, int numpages, pgprot_t prot) +{ + return change_page_attr_set_clr(&addr, numpages, prot, + __pgprot(~pgprot_val(prot)), 0, 0, + NULL); +} + int _set_memory_uc(unsigned long addr, int numpages) { /* _ Patches currently in -mm which might be from logang@xxxxxxxxxxxx are mm-memory_hotplug-drop-the-flags-field-from-struct-mhp_restrictions.patch mm-memory_hotplug-rename-mhp_restrictions-to-mhp_params.patch x86-mm-thread-pgprot_t-through-init_memory_mapping.patch x86-mm-introduce-__set_memory_prot.patch powerpc-mm-thread-pgprot_t-through-create_section_mapping.patch mm-memory_hotplug-add-pgprot_t-to-mhp_params.patch mm-memremap-set-caching-mode-for-pci-p2pdma-memory-to-wc.patch