Skip to content

Commit 728b0e2

Browse files
author
Claudio Imbrenda
committed
KVM: S390: Remove PGSTE code from linux/s390 mm
Remove the PGSTE config option. Remove all code from linux/s390 mm that involves PGSTEs. Acked-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
1 parent cec3858 commit 728b0e2

11 files changed

Lines changed: 15 additions & 1021 deletions

File tree

arch/s390/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ config GENERIC_BUG_RELATIVE_POINTERS
3232
config GENERIC_LOCKBREAK
3333
def_bool y if PREEMPTION
3434

35-
config PGSTE
36-
def_bool n
37-
3835
config AUDIT_ARCH
3936
def_bool y
4037

arch/s390/include/asm/hugetlb.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
3737
return __huge_ptep_get_and_clear(mm, addr, ptep);
3838
}
3939

40-
static inline void arch_clear_hugetlb_flags(struct folio *folio)
41-
{
42-
clear_bit(PG_arch_1, &folio->flags.f);
43-
}
44-
#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags
45-
4640
#define __HAVE_ARCH_HUGE_PTE_CLEAR
4741
static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
4842
pte_t *ptep, unsigned long sz)

arch/s390/include/asm/mmu.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,11 @@ typedef struct {
1818
unsigned long vdso_base;
1919
/* The mmu context belongs to a secure guest. */
2020
atomic_t protected_count;
21-
/*
22-
* The following bitfields need a down_write on the mm
23-
* semaphore when they are written to. As they are only
24-
* written once, they can be read without a lock.
25-
*/
26-
/* The mmu context uses extended page tables. */
27-
unsigned int has_pgste:1;
28-
/* The mmu context uses storage keys. */
29-
unsigned int uses_skeys:1;
30-
/* The mmu context uses CMM. */
31-
unsigned int uses_cmm:1;
3221
/*
3322
* The mmu context allows COW-sharing of memory pages (KSM, zeropage).
3423
* Note that COW-sharing during fork() is currently always allowed.
3524
*/
3625
unsigned int allow_cow_sharing:1;
37-
/* The gmaps associated with this context are allowed to use huge pages. */
38-
unsigned int allow_gmap_hpage_1m:1;
3926
} mm_context_t;
4027

4128
#define INIT_MM_CONTEXT(name) \

arch/s390/include/asm/page.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ static inline void copy_page(void *to, void *from)
7878
#ifdef STRICT_MM_TYPECHECKS
7979

8080
typedef struct { unsigned long pgprot; } pgprot_t;
81-
typedef struct { unsigned long pgste; } pgste_t;
8281
typedef struct { unsigned long pte; } pte_t;
8382
typedef struct { unsigned long pmd; } pmd_t;
8483
typedef struct { unsigned long pud; } pud_t;
@@ -94,7 +93,6 @@ static __always_inline unsigned long name ## _val(name ## _t name) \
9493
#else /* STRICT_MM_TYPECHECKS */
9594

9695
typedef unsigned long pgprot_t;
97-
typedef unsigned long pgste_t;
9896
typedef unsigned long pte_t;
9997
typedef unsigned long pmd_t;
10098
typedef unsigned long pud_t;
@@ -110,7 +108,6 @@ static __always_inline unsigned long name ## _val(name ## _t name) \
110108
#endif /* STRICT_MM_TYPECHECKS */
111109

112110
DEFINE_PGVAL_FUNC(pgprot)
113-
DEFINE_PGVAL_FUNC(pgste)
114111
DEFINE_PGVAL_FUNC(pte)
115112
DEFINE_PGVAL_FUNC(pmd)
116113
DEFINE_PGVAL_FUNC(pud)
@@ -120,7 +117,6 @@ DEFINE_PGVAL_FUNC(pgd)
120117
typedef pte_t *pgtable_t;
121118

122119
#define __pgprot(x) ((pgprot_t) { (x) } )
123-
#define __pgste(x) ((pgste_t) { (x) } )
124120
#define __pte(x) ((pte_t) { (x) } )
125121
#define __pmd(x) ((pmd_t) { (x) } )
126122
#define __pud(x) ((pud_t) { (x) } )

arch/s390/include/asm/pgalloc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ unsigned long *page_table_alloc_noprof(struct mm_struct *);
2727
#define page_table_alloc(...) alloc_hooks(page_table_alloc_noprof(__VA_ARGS__))
2828
void page_table_free(struct mm_struct *, unsigned long *);
2929

30-
struct ptdesc *page_table_alloc_pgste_noprof(struct mm_struct *mm);
31-
#define page_table_alloc_pgste(...) alloc_hooks(page_table_alloc_pgste_noprof(__VA_ARGS__))
32-
void page_table_free_pgste(struct ptdesc *ptdesc);
33-
3430
static inline void crst_table_init(unsigned long *crst, unsigned long entry)
3531
{
3632
memset64((u64 *)crst, entry, _CRST_ENTRIES);

arch/s390/include/asm/pgtable.h

Lines changed: 7 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -413,28 +413,6 @@ void setup_protection_map(void);
413413
* SW-bits: y young, d dirty, r read, w write
414414
*/
415415

416-
/* Page status table bits for virtualization */
417-
#define PGSTE_ACC_BITS 0xf000000000000000UL
418-
#define PGSTE_FP_BIT 0x0800000000000000UL
419-
#define PGSTE_PCL_BIT 0x0080000000000000UL
420-
#define PGSTE_HR_BIT 0x0040000000000000UL
421-
#define PGSTE_HC_BIT 0x0020000000000000UL
422-
#define PGSTE_GR_BIT 0x0004000000000000UL
423-
#define PGSTE_GC_BIT 0x0002000000000000UL
424-
#define PGSTE_ST2_MASK 0x0000ffff00000000UL
425-
#define PGSTE_UC_BIT 0x0000000000008000UL /* user dirty (migration) */
426-
#define PGSTE_IN_BIT 0x0000000000004000UL /* IPTE notify bit */
427-
#define PGSTE_VSIE_BIT 0x0000000000002000UL /* ref'd in a shadow table */
428-
429-
/* Guest Page State used for virtualization */
430-
#define _PGSTE_GPS_ZERO 0x0000000080000000UL
431-
#define _PGSTE_GPS_NODAT 0x0000000040000000UL
432-
#define _PGSTE_GPS_USAGE_MASK 0x0000000003000000UL
433-
#define _PGSTE_GPS_USAGE_STABLE 0x0000000000000000UL
434-
#define _PGSTE_GPS_USAGE_UNUSED 0x0000000001000000UL
435-
#define _PGSTE_GPS_USAGE_POT_VOLATILE 0x0000000002000000UL
436-
#define _PGSTE_GPS_USAGE_VOLATILE _PGSTE_GPS_USAGE_MASK
437-
438416
/*
439417
* A user page table pointer has the space-switch-event bit, the
440418
* private-space-control bit and the storage-alteration-event-control
@@ -566,15 +544,6 @@ static inline bool mm_pmd_folded(struct mm_struct *mm)
566544
}
567545
#define mm_pmd_folded(mm) mm_pmd_folded(mm)
568546

569-
static inline int mm_has_pgste(struct mm_struct *mm)
570-
{
571-
#ifdef CONFIG_PGSTE
572-
if (unlikely(mm->context.has_pgste))
573-
return 1;
574-
#endif
575-
return 0;
576-
}
577-
578547
static inline int mm_is_protected(struct mm_struct *mm)
579548
{
580549
#if IS_ENABLED(CONFIG_KVM)
@@ -584,16 +553,6 @@ static inline int mm_is_protected(struct mm_struct *mm)
584553
return 0;
585554
}
586555

587-
static inline pgste_t clear_pgste_bit(pgste_t pgste, unsigned long mask)
588-
{
589-
return __pgste(pgste_val(pgste) & ~mask);
590-
}
591-
592-
static inline pgste_t set_pgste_bit(pgste_t pgste, unsigned long mask)
593-
{
594-
return __pgste(pgste_val(pgste) | mask);
595-
}
596-
597556
static inline pte_t clear_pte_bit(pte_t pte, pgprot_t prot)
598557
{
599558
return __pte(pte_val(pte) & ~pgprot_val(prot));
@@ -639,15 +598,6 @@ static inline int mm_forbids_zeropage(struct mm_struct *mm)
639598
return 0;
640599
}
641600

642-
static inline int mm_uses_skeys(struct mm_struct *mm)
643-
{
644-
#ifdef CONFIG_PGSTE
645-
if (mm->context.uses_skeys)
646-
return 1;
647-
#endif
648-
return 0;
649-
}
650-
651601
/**
652602
* cspg() - Compare and Swap and Purge (CSPG)
653603
* @ptr: Pointer to the value to be exchanged
@@ -1356,45 +1306,13 @@ static inline int ptep_set_access_flags(struct vm_area_struct *vma,
13561306
{
13571307
if (pte_same(*ptep, entry))
13581308
return 0;
1359-
if (cpu_has_rdp() && !mm_has_pgste(vma->vm_mm) && pte_allow_rdp(*ptep, entry))
1309+
if (cpu_has_rdp() && pte_allow_rdp(*ptep, entry))
13601310
ptep_reset_dat_prot(vma->vm_mm, addr, ptep, entry);
13611311
else
13621312
ptep_xchg_direct(vma->vm_mm, addr, ptep, entry);
13631313
return 1;
13641314
}
13651315

1366-
/*
1367-
* Additional functions to handle KVM guest page tables
1368-
*/
1369-
void ptep_set_pte_at(struct mm_struct *mm, unsigned long addr,
1370-
pte_t *ptep, pte_t entry);
1371-
void ptep_set_notify(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
1372-
int ptep_force_prot(struct mm_struct *mm, unsigned long gaddr,
1373-
pte_t *ptep, int prot, unsigned long bit);
1374-
void ptep_zap_unused(struct mm_struct *mm, unsigned long addr,
1375-
pte_t *ptep , int reset);
1376-
void ptep_zap_key(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
1377-
int ptep_shadow_pte(struct mm_struct *mm, unsigned long saddr,
1378-
pte_t *sptep, pte_t *tptep, pte_t pte);
1379-
void ptep_unshadow_pte(struct mm_struct *mm, unsigned long saddr, pte_t *ptep);
1380-
1381-
bool ptep_test_and_clear_uc(struct mm_struct *mm, unsigned long address,
1382-
pte_t *ptep);
1383-
int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
1384-
unsigned char key, bool nq);
1385-
int cond_set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
1386-
unsigned char key, unsigned char *oldkey,
1387-
bool nq, bool mr, bool mc);
1388-
int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr);
1389-
int get_guest_storage_key(struct mm_struct *mm, unsigned long addr,
1390-
unsigned char *key);
1391-
1392-
int set_pgste_bits(struct mm_struct *mm, unsigned long addr,
1393-
unsigned long bits, unsigned long value);
1394-
int get_pgste(struct mm_struct *mm, unsigned long hva, unsigned long *pgstep);
1395-
int pgste_perform_essa(struct mm_struct *mm, unsigned long hva, int orc,
1396-
unsigned long *oldpte, unsigned long *oldpgste);
1397-
13981316
#define pgprot_writecombine pgprot_writecombine
13991317
pgprot_t pgprot_writecombine(pgprot_t prot);
14001318

@@ -1409,23 +1327,12 @@ static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
14091327
{
14101328
if (pte_present(entry))
14111329
entry = clear_pte_bit(entry, __pgprot(_PAGE_UNUSED));
1412-
if (mm_has_pgste(mm)) {
1413-
for (;;) {
1414-
ptep_set_pte_at(mm, addr, ptep, entry);
1415-
if (--nr == 0)
1416-
break;
1417-
ptep++;
1418-
entry = __pte(pte_val(entry) + PAGE_SIZE);
1419-
addr += PAGE_SIZE;
1420-
}
1421-
} else {
1422-
for (;;) {
1423-
set_pte(ptep, entry);
1424-
if (--nr == 0)
1425-
break;
1426-
ptep++;
1427-
entry = __pte(pte_val(entry) + PAGE_SIZE);
1428-
}
1330+
for (;;) {
1331+
set_pte(ptep, entry);
1332+
if (--nr == 0)
1333+
break;
1334+
ptep++;
1335+
entry = __pte(pte_val(entry) + PAGE_SIZE);
14291336
}
14301337
}
14311338
#define set_ptes set_ptes
@@ -2026,18 +1933,4 @@ extern pte_t *vmem_get_alloc_pte(unsigned long addr, bool alloc);
20261933
#define pmd_pgtable(pmd) \
20271934
((pgtable_t)__va(pmd_val(pmd) & -sizeof(pte_t)*PTRS_PER_PTE))
20281935

2029-
static inline unsigned long gmap_pgste_get_pgt_addr(unsigned long *pgt)
2030-
{
2031-
unsigned long *pgstes, res;
2032-
2033-
pgstes = pgt + _PAGE_ENTRIES;
2034-
2035-
res = (pgstes[0] & PGSTE_ST2_MASK) << 16;
2036-
res |= pgstes[1] & PGSTE_ST2_MASK;
2037-
res |= (pgstes[2] & PGSTE_ST2_MASK) >> 16;
2038-
res |= (pgstes[3] & PGSTE_ST2_MASK) >> 32;
2039-
2040-
return res;
2041-
}
2042-
20431936
#endif /* _S390_PAGE_H */

arch/s390/kvm/dat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ union pte {
108108
#define _PAGE_SD 0x002
109109

110110
/* Needed as macro to perform atomic operations */
111+
#define PGSTE_PCL_BIT 0x0080000000000000UL /* PCL lock, HW bit */
111112
#define PGSTE_CMMA_D_BIT 0x0000000000008000UL /* CMMA dirty soft-bit */
112113

113114
enum pgste_gps_usage {

arch/s390/mm/hugetlbpage.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,29 +135,6 @@ static inline pte_t __rste_to_pte(unsigned long rste)
135135
return __pte(pteval);
136136
}
137137

138-
static void clear_huge_pte_skeys(struct mm_struct *mm, unsigned long rste)
139-
{
140-
struct folio *folio;
141-
unsigned long size, paddr;
142-
143-
if (!mm_uses_skeys(mm) ||
144-
rste & _SEGMENT_ENTRY_INVALID)
145-
return;
146-
147-
if ((rste & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3) {
148-
folio = page_folio(pud_page(__pud(rste)));
149-
size = PUD_SIZE;
150-
paddr = rste & PUD_MASK;
151-
} else {
152-
folio = page_folio(pmd_page(__pmd(rste)));
153-
size = PMD_SIZE;
154-
paddr = rste & PMD_MASK;
155-
}
156-
157-
if (!test_and_set_bit(PG_arch_1, &folio->flags.f))
158-
__storage_key_init_range(paddr, paddr + size);
159-
}
160-
161138
void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
162139
pte_t *ptep, pte_t pte)
163140
{
@@ -173,7 +150,6 @@ void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
173150
} else if (likely(pte_present(pte)))
174151
rste |= _SEGMENT_ENTRY_LARGE;
175152

176-
clear_huge_pte_skeys(mm, rste);
177153
set_pte(ptep, __pte(rste));
178154
}
179155

arch/s390/mm/pgalloc.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,6 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end)
114114
return -ENOMEM;
115115
}
116116

117-
#ifdef CONFIG_PGSTE
118-
119-
struct ptdesc *page_table_alloc_pgste_noprof(struct mm_struct *mm)
120-
{
121-
struct ptdesc *ptdesc;
122-
u64 *table;
123-
124-
ptdesc = pagetable_alloc_noprof(GFP_KERNEL_ACCOUNT, 0);
125-
if (ptdesc) {
126-
table = (u64 *)ptdesc_address(ptdesc);
127-
__arch_set_page_dat(table, 1);
128-
memset64(table, _PAGE_INVALID, PTRS_PER_PTE);
129-
memset64(table + PTRS_PER_PTE, 0, PTRS_PER_PTE);
130-
}
131-
return ptdesc;
132-
}
133-
134-
void page_table_free_pgste(struct ptdesc *ptdesc)
135-
{
136-
pagetable_free(ptdesc);
137-
}
138-
139-
#endif /* CONFIG_PGSTE */
140-
141117
unsigned long *page_table_alloc_noprof(struct mm_struct *mm)
142118
{
143119
gfp_t gfp = GFP_KERNEL_ACCOUNT;

0 commit comments

Comments
 (0)