s390/cmma: move arch_set_page_dat() to header file

In order to be usable for early boot code move the simple
arch_set_page_dat() function to header file, and add its counter-part
arch_set_page_nodat(). Also change the parameters, and the function name
slightly.

This is required since there aren't any struct pages available in early
boot code, and renaming of functions is done to make sure that all users
are converted to the new API.

Instead of a pointer to a struct page a virtual address is passed, and
instead of an order the number of pages for which the page state needs be
set.

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
This commit is contained in:
Heiko Carstens 2023-10-27 14:12:38 +02:00 committed by Vasily Gorbik
parent a3e89e20fe
commit 65d37f163a
6 changed files with 28 additions and 16 deletions

View File

@ -60,4 +60,21 @@ static inline void __set_page_stable_nodat(void *addr, unsigned long num_pages)
__set_page_state(addr, num_pages, ESSA_SET_STABLE_NODAT);
}
static inline void __arch_set_page_nodat(void *addr, unsigned long num_pages)
{
if (!cmma_flag)
return;
if (cmma_flag < 2)
__set_page_stable_dat(addr, num_pages);
else
__set_page_stable_nodat(addr, num_pages);
}
static inline void __arch_set_page_dat(void *addr, unsigned long num_pages)
{
if (!cmma_flag)
return;
__set_page_stable_dat(addr, num_pages);
}
#endif

View File

@ -164,7 +164,6 @@ static inline int page_reset_referenced(unsigned long addr)
struct page;
void arch_free_page(struct page *page, int order);
void arch_alloc_page(struct page *page, int order);
void arch_set_page_dat(struct page *page, int order);
static inline int devmem_is_allowed(unsigned long pfn)
{

View File

@ -18,7 +18,7 @@
#include <linux/ksm.h>
#include <linux/mman.h>
#include <linux/pgtable.h>
#include <asm/page-states.h>
#include <asm/pgalloc.h>
#include <asm/gmap.h>
#include <asm/page.h>
@ -33,7 +33,7 @@ static struct page *gmap_alloc_crst(void)
page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
if (!page)
return NULL;
arch_set_page_dat(page, CRST_ALLOC_ORDER);
__arch_set_page_dat(page_to_virt(page), 1UL << CRST_ALLOC_ORDER);
return page;
}

View File

@ -153,10 +153,3 @@ void arch_alloc_page(struct page *page, int order)
else
__set_page_stable_nodat(page_to_virt(page), 1UL << order);
}
void arch_set_page_dat(struct page *page, int order)
{
if (!cmma_flag)
return;
__set_page_stable_dat(page_to_virt(page), 1UL << order);
}

View File

@ -10,6 +10,7 @@
#include <linux/slab.h>
#include <linux/mm.h>
#include <asm/mmu_context.h>
#include <asm/page-states.h>
#include <asm/pgalloc.h>
#include <asm/gmap.h>
#include <asm/tlb.h>
@ -43,11 +44,13 @@ __initcall(page_table_register_sysctl);
unsigned long *crst_table_alloc(struct mm_struct *mm)
{
struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL, CRST_ALLOC_ORDER);
unsigned long *table;
if (!ptdesc)
return NULL;
arch_set_page_dat(ptdesc_page(ptdesc), CRST_ALLOC_ORDER);
return (unsigned long *) ptdesc_to_virt(ptdesc);
table = ptdesc_to_virt(ptdesc);
__arch_set_page_dat(table, 1UL << CRST_ALLOC_ORDER);
return table;
}
void crst_table_free(struct mm_struct *mm, unsigned long *table)
@ -145,7 +148,7 @@ struct page *page_table_alloc_pgste(struct mm_struct *mm)
ptdesc = pagetable_alloc(GFP_KERNEL, 0);
if (ptdesc) {
table = (u64 *)ptdesc_to_virt(ptdesc);
arch_set_page_dat(virt_to_page(table), 0);
__arch_set_page_dat(table, 1);
memset64(table, _PAGE_INVALID, PTRS_PER_PTE);
memset64(table + PTRS_PER_PTE, 0, PTRS_PER_PTE);
}
@ -285,9 +288,9 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
pagetable_free(ptdesc);
return NULL;
}
arch_set_page_dat(ptdesc_page(ptdesc), 0);
/* Initialize page table */
table = (unsigned long *) ptdesc_to_virt(ptdesc);
table = ptdesc_to_virt(ptdesc);
__arch_set_page_dat(table, 1);
if (mm_alloc_pgste(mm)) {
/* Return 4K page table with PGSTEs */
INIT_LIST_HEAD(&ptdesc->pt_list);

View File

@ -51,7 +51,7 @@ void *vmem_crst_alloc(unsigned long val)
return NULL;
crst_table_init(table, val);
if (slab_is_available())
arch_set_page_dat(virt_to_page(table), CRST_ALLOC_ORDER);
__arch_set_page_dat(table, 1UL << CRST_ALLOC_ORDER);
return table;
}