blob: 0130d0379edd179e8b06dbd459066b8606517676 [file] [log] [blame]
Gerald Schaefer53492b12008-04-30 13:38:46 +02001/*
2 * IBM System z Huge TLB Page Support for Kernel.
3 *
4 * Copyright IBM Corp. 2008
5 * Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com>
6 */
7
8#ifndef _ASM_S390_HUGETLB_H
9#define _ASM_S390_HUGETLB_H
10
11#include <asm/page.h>
12#include <asm/pgtable.h>
13
14
15#define is_hugepage_only_range(mm, addr, len) 0
16#define hugetlb_free_pgd_range free_pgd_range
17
18void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
19 pte_t *ptep, pte_t pte);
Martin Schwidefskye5098612013-07-23 20:57:57 +020020pte_t huge_ptep_get(pte_t *ptep);
21pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
22 unsigned long addr, pte_t *ptep);
Gerald Schaefer53492b12008-04-30 13:38:46 +020023
24/*
25 * If the arch doesn't supply something else, assume that hugepage
26 * size aligned regions are ok without further preparation.
27 */
Andi Kleena5516432008-07-23 21:27:41 -070028static inline int prepare_hugepage_range(struct file *file,
29 unsigned long addr, unsigned long len)
Gerald Schaefer53492b12008-04-30 13:38:46 +020030{
31 if (len & ~HPAGE_MASK)
32 return -EINVAL;
33 if (addr & ~HPAGE_MASK)
34 return -EINVAL;
35 return 0;
36}
37
Will Deacon5d3a5512012-10-08 16:29:32 -070038#define arch_clear_hugepage_flags(page) do { } while (0)
Gerald Schaefer53492b12008-04-30 13:38:46 +020039
Martin Schwidefskye5098612013-07-23 20:57:57 +020040static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
41 pte_t *ptep)
Gerald Schaefer53492b12008-04-30 13:38:46 +020042{
Martin Schwidefskye5098612013-07-23 20:57:57 +020043 pte_val(*ptep) = _SEGMENT_ENTRY_EMPTY;
Gerald Schaefer53492b12008-04-30 13:38:46 +020044}
45
Gerald Schaefer53492b12008-04-30 13:38:46 +020046static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
47 unsigned long address, pte_t *ptep)
48{
Martin Schwidefskye5098612013-07-23 20:57:57 +020049 huge_ptep_get_and_clear(vma->vm_mm, address, ptep);
50}
51
52static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
53 unsigned long addr, pte_t *ptep,
54 pte_t pte, int dirty)
55{
56 int changed = !pte_same(huge_ptep_get(ptep), pte);
57 if (changed) {
58 huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
59 set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
60 }
61 return changed;
62}
63
64static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
65 unsigned long addr, pte_t *ptep)
66{
67 pte_t pte = huge_ptep_get_and_clear(mm, addr, ptep);
68 set_huge_pte_at(mm, addr, ptep, pte_wrprotect(pte));
Gerald Schaefer53492b12008-04-30 13:38:46 +020069}
70
Gerald Schaefer106c9922013-04-29 15:07:23 -070071static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot)
72{
Martin Schwidefskye5098612013-07-23 20:57:57 +020073 return mk_pte(page, pgprot);
74}
Gerald Schaefer106c9922013-04-29 15:07:23 -070075
Martin Schwidefskye5098612013-07-23 20:57:57 +020076static inline int huge_pte_none(pte_t pte)
77{
78 return pte_none(pte);
Gerald Schaefer106c9922013-04-29 15:07:23 -070079}
80
81static inline int huge_pte_write(pte_t pte)
82{
Martin Schwidefskye5098612013-07-23 20:57:57 +020083 return pte_write(pte);
Gerald Schaefer106c9922013-04-29 15:07:23 -070084}
85
86static inline int huge_pte_dirty(pte_t pte)
87{
Martin Schwidefskye5098612013-07-23 20:57:57 +020088 return pte_dirty(pte);
Gerald Schaefer106c9922013-04-29 15:07:23 -070089}
90
91static inline pte_t huge_pte_mkwrite(pte_t pte)
92{
Martin Schwidefskye5098612013-07-23 20:57:57 +020093 return pte_mkwrite(pte);
Gerald Schaefer106c9922013-04-29 15:07:23 -070094}
95
96static inline pte_t huge_pte_mkdirty(pte_t pte)
97{
Martin Schwidefskye5098612013-07-23 20:57:57 +020098 return pte_mkdirty(pte);
99}
100
101static inline pte_t huge_pte_wrprotect(pte_t pte)
102{
103 return pte_wrprotect(pte);
Gerald Schaefer106c9922013-04-29 15:07:23 -0700104}
105
106static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot)
107{
Martin Schwidefskye5098612013-07-23 20:57:57 +0200108 return pte_modify(pte, newprot);
Gerald Schaefer106c9922013-04-29 15:07:23 -0700109}
110
Gerald Schaefer53492b12008-04-30 13:38:46 +0200111#endif /* _ASM_S390_HUGETLB_H */