Skip to content

Commit b2fa47e

Browse files
author
Martin Schwidefsky
committed
[S390] refactor page table functions for better pgste support
Rework the architecture page table functions to access the bits in the page table extension array (pgste). There are a number of changes: 1) Fix missing pgste update if the attach_count for the mm is <= 1. 2) For every operation that affects the invalid bit in the pte or the rcp byte in the pgste the pcl lock needs to be acquired. The function pgste_get_lock gets the pcl lock and returns the current pgste value for a pte pointer. The function pgste_set_unlock stores the pgste and releases the lock. Between these two calls the bits in the pgste can be shuffled. 3) Define two software bits in the pte _PAGE_SWR and _PAGE_SWC to avoid calling SetPageDirty and SetPageReferenced from pgtable.h. If the host reference backup bit or the host change backup bit has been set the dirty/referenced state is transfered to the pte. The common code will pick up the state from the pte. 4) Add ptep_modify_prot_start and ptep_modify_prot_commit for mprotect. 5) Remove pgd_populate_kernel, pud_populate_kernel, pmd_populate_kernel pgd_clear_kernel, pud_clear_kernel, pmd_clear_kernel and ptep_invalidate. 6) Rename kvm_s390_test_and_clear_page_dirty to ptep_test_and_clear_user_dirty and add ptep_test_and_clear_user_young. 7) Define mm_exclusive() and mm_has_pgste() helper to improve readability. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 2d42552 commit b2fa47e

7 files changed

Lines changed: 331 additions & 233 deletions

File tree

‎arch/s390/include/asm/mmu.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ typedef struct {
99
unsigned long asce_bits;
1010
unsigned long asce_limit;
1111
unsigned long vdso_base;
12-
int has_pgste; /* The mmu context has extended page tables */
13-
int alloc_pgste; /* cloned contexts will have extended page tables */
12+
/* Cloned contexts will be created with extended page tables. */
13+
unsigned int alloc_pgste:1;
14+
/* The mmu context has extended page tables. */
15+
unsigned int has_pgste:1;
1416
} mm_context_t;
1517

1618
#define INIT_MM_CONTEXT(name) \

‎arch/s390/include/asm/page.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,24 @@ static inline void copy_page(void *to, void *from)
9090
*/
9191

9292
typedef struct { unsigned long pgprot; } pgprot_t;
93+
typedef struct { unsigned long pgste; } pgste_t;
9394
typedef struct { unsigned long pte; } pte_t;
9495
typedef struct { unsigned long pmd; } pmd_t;
9596
typedef struct { unsigned long pud; } pud_t;
9697
typedef struct { unsigned long pgd; } pgd_t;
9798
typedef pte_t *pgtable_t;
9899

99100
#define pgprot_val(x) ((x).pgprot)
101+
#define pgste_val(x) ((x).pgste)
100102
#define pte_val(x) ((x).pte)
101103
#define pmd_val(x) ((x).pmd)
102104
#define pud_val(x) ((x).pud)
103105
#define pgd_val(x) ((x).pgd)
104106

107+
#define __pgste(x) ((pgste_t) { (x) } )
105108
#define __pte(x) ((pte_t) { (x) } )
106109
#define __pmd(x) ((pmd_t) { (x) } )
110+
#define __pud(x) ((pud_t) { (x) } )
107111
#define __pgd(x) ((pgd_t) { (x) } )
108112
#define __pgprot(x) ((pgprot_t) { (x) } )
109113

‎arch/s390/include/asm/pgalloc.h‎

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ static inline unsigned long pgd_entry_type(struct mm_struct *mm)
6565
#define pmd_free(mm, x) do { } while (0)
6666

6767
#define pgd_populate(mm, pgd, pud) BUG()
68-
#define pgd_populate_kernel(mm, pgd, pud) BUG()
69-
7068
#define pud_populate(mm, pud, pmd) BUG()
71-
#define pud_populate_kernel(mm, pud, pmd) BUG()
7269

7370
#else /* __s390x__ */
7471

@@ -102,26 +99,14 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr)
10299
}
103100
#define pmd_free(mm, pmd) crst_table_free(mm, (unsigned long *) pmd)
104101

105-
static inline void pgd_populate_kernel(struct mm_struct *mm,
106-
pgd_t *pgd, pud_t *pud)
107-
{
108-
pgd_val(*pgd) = _REGION2_ENTRY | __pa(pud);
109-
}
110-
111102
static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
112103
{
113-
pgd_populate_kernel(mm, pgd, pud);
114-
}
115-
116-
static inline void pud_populate_kernel(struct mm_struct *mm,
117-
pud_t *pud, pmd_t *pmd)
118-
{
119-
pud_val(*pud) = _REGION3_ENTRY | __pa(pmd);
104+
pgd_val(*pgd) = _REGION2_ENTRY | __pa(pud);
120105
}
121106

122107
static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
123108
{
124-
pud_populate_kernel(mm, pud, pmd);
109+
pud_val(*pud) = _REGION3_ENTRY | __pa(pmd);
125110
}
126111

127112
#endif /* __s390x__ */
@@ -134,18 +119,14 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
134119
}
135120
#define pgd_free(mm, pgd) crst_table_free(mm, (unsigned long *) pgd)
136121

137-
static inline void pmd_populate_kernel(struct mm_struct *mm,
138-
pmd_t *pmd, pte_t *pte)
139-
{
140-
pmd_val(*pmd) = _SEGMENT_ENTRY + __pa(pte);
141-
}
142-
143122
static inline void pmd_populate(struct mm_struct *mm,
144123
pmd_t *pmd, pgtable_t pte)
145124
{
146-
pmd_populate_kernel(mm, pmd, pte);
125+
pmd_val(*pmd) = _SEGMENT_ENTRY + __pa(pte);
147126
}
148127

128+
#define pmd_populate_kernel(mm, pmd, pte) pmd_populate(mm, pmd, pte)
129+
149130
#define pmd_pgtable(pmd) \
150131
(pgtable_t)(pmd_val(pmd) & -sizeof(pte_t)*PTRS_PER_PTE)
151132

0 commit comments

Comments
 (0)