arch/s390/include/asm/pgalloc.h

Source file repositories/reference/linux-study-clean/arch/s390/include/asm/pgalloc.h

File Facts

System
Linux kernel
Corpus path
arch/s390/include/asm/pgalloc.h
Extension
.h
Size
4869 bytes
Lines
180
Domain
Architecture Layer
Bucket
arch/s390
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef _S390_PGALLOC_H
#define _S390_PGALLOC_H

#include <linux/threads.h>
#include <linux/string.h>
#include <linux/gfp.h>
#include <linux/mm.h>

#define CRST_ALLOC_ORDER 2

unsigned long *crst_table_alloc_noprof(struct mm_struct *);
#define crst_table_alloc(...)	alloc_hooks(crst_table_alloc_noprof(__VA_ARGS__))
void crst_table_free(struct mm_struct *, unsigned long *);

unsigned long *page_table_alloc_noprof(struct mm_struct *);
#define page_table_alloc(...)	alloc_hooks(page_table_alloc_noprof(__VA_ARGS__))
void page_table_free(struct mm_struct *, unsigned long *);

static inline void crst_table_init(unsigned long *crst, unsigned long entry)
{
	memset64((u64 *)crst, entry, _CRST_ENTRIES);
}

int crst_table_upgrade(struct mm_struct *mm, unsigned long limit);

static inline unsigned long check_asce_limit(struct mm_struct *mm, unsigned long addr,
					     unsigned long len)
{
	int rc;

	if (addr + len > mm->context.asce_limit &&
	    addr + len <= TASK_SIZE) {
		rc = crst_table_upgrade(mm, addr + len);
		if (rc)
			return (unsigned long) rc;
	}
	return addr;
}

static inline p4d_t *p4d_alloc_one_noprof(struct mm_struct *mm, unsigned long address)
{
	unsigned long *table = crst_table_alloc_noprof(mm);

	if (!table)
		return NULL;
	crst_table_init(table, _REGION2_ENTRY_EMPTY);
	pagetable_p4d_ctor(virt_to_ptdesc(table));

	return (p4d_t *) table;
}
#define p4d_alloc_one(...)	alloc_hooks(p4d_alloc_one_noprof(__VA_ARGS__))

static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d)
{
	if (mm_p4d_folded(mm))
		return;

	pagetable_dtor(virt_to_ptdesc(p4d));
	crst_table_free(mm, (unsigned long *) p4d);
}

static inline pud_t *pud_alloc_one_noprof(struct mm_struct *mm, unsigned long address)
{
	unsigned long *table = crst_table_alloc_noprof(mm);

	if (!table)
		return NULL;
	crst_table_init(table, _REGION3_ENTRY_EMPTY);
	pagetable_pud_ctor(virt_to_ptdesc(table));

	return (pud_t *) table;
}
#define pud_alloc_one(...)	alloc_hooks(pud_alloc_one_noprof(__VA_ARGS__))

static inline void pud_free(struct mm_struct *mm, pud_t *pud)
{
	if (mm_pud_folded(mm))
		return;

	pagetable_dtor(virt_to_ptdesc(pud));
	crst_table_free(mm, (unsigned long *) pud);
}

static inline pmd_t *pmd_alloc_one_noprof(struct mm_struct *mm, unsigned long vmaddr)
{
	unsigned long *table = crst_table_alloc_noprof(mm);

	if (!table)
		return NULL;
	crst_table_init(table, _SEGMENT_ENTRY_EMPTY);

Annotation

Implementation Notes