Skip to content

Commit 1954da4

Browse files
hcahcaVasily Gorbik
authored andcommitted
s390/mm: add missing arch_set_page_dat() call to gmap allocations
If the cmma no-dat feature is available all pages that are not used for dynamic address translation are marked as "no-dat" with the ESSA instruction. This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. This also means that pages which are used for dynamic address translation must not be marked as "no-dat", since the hypervisor may then incorrectly not purge guest TLB entries. Region, segment, and page tables allocated within the gmap code are incorrectly marked as "no-dat", since an explicit call to arch_set_page_dat() is missing, which would remove the "no-dat" mark. In order to fix this add a new gmap_alloc_crst() function which should be used to allocate region and segment tables, and which also calls arch_set_page_dat(). Also add the arch_set_page_dat() call to page_table_alloc_pgste(). Cc: <[email protected]> Reviewed-by: Claudio Imbrenda <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 09cda0a commit 1954da4

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

arch/s390/mm/gmap.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,22 @@
2121

2222
#include <asm/pgalloc.h>
2323
#include <asm/gmap.h>
24+
#include <asm/page.h>
2425
#include <asm/tlb.h>
2526

2627
#define GMAP_SHADOW_FAKE_TABLE 1ULL
2728

29+
static struct page *gmap_alloc_crst(void)
30+
{
31+
struct page *page;
32+
33+
page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
34+
if (!page)
35+
return NULL;
36+
arch_set_page_dat(page, CRST_ALLOC_ORDER);
37+
return page;
38+
}
39+
2840
/**
2941
* gmap_alloc - allocate and initialize a guest address space
3042
* @limit: maximum address of the gmap address space
@@ -67,7 +79,7 @@ static struct gmap *gmap_alloc(unsigned long limit)
6779
spin_lock_init(&gmap->guest_table_lock);
6880
spin_lock_init(&gmap->shadow_lock);
6981
refcount_set(&gmap->ref_count, 1);
70-
page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
82+
page = gmap_alloc_crst();
7183
if (!page)
7284
goto out_free;
7385
page->index = 0;
@@ -308,7 +320,7 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,
308320
unsigned long *new;
309321

310322
/* since we dont free the gmap table until gmap_free we can unlock */
311-
page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
323+
page = gmap_alloc_crst();
312324
if (!page)
313325
return -ENOMEM;
314326
new = page_to_virt(page);
@@ -1759,7 +1771,7 @@ int gmap_shadow_r2t(struct gmap *sg, unsigned long saddr, unsigned long r2t,
17591771

17601772
BUG_ON(!gmap_is_shadow(sg));
17611773
/* Allocate a shadow region second table */
1762-
page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
1774+
page = gmap_alloc_crst();
17631775
if (!page)
17641776
return -ENOMEM;
17651777
page->index = r2t & _REGION_ENTRY_ORIGIN;
@@ -1843,7 +1855,7 @@ int gmap_shadow_r3t(struct gmap *sg, unsigned long saddr, unsigned long r3t,
18431855

18441856
BUG_ON(!gmap_is_shadow(sg));
18451857
/* Allocate a shadow region second table */
1846-
page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
1858+
page = gmap_alloc_crst();
18471859
if (!page)
18481860
return -ENOMEM;
18491861
page->index = r3t & _REGION_ENTRY_ORIGIN;
@@ -1927,7 +1939,7 @@ int gmap_shadow_sgt(struct gmap *sg, unsigned long saddr, unsigned long sgt,
19271939

19281940
BUG_ON(!gmap_is_shadow(sg) || (sgt & _REGION3_ENTRY_LARGE));
19291941
/* Allocate a shadow segment table */
1930-
page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
1942+
page = gmap_alloc_crst();
19311943
if (!page)
19321944
return -ENOMEM;
19331945
page->index = sgt & _REGION_ENTRY_ORIGIN;
@@ -2855,7 +2867,7 @@ int s390_replace_asce(struct gmap *gmap)
28552867
if ((gmap->asce & _ASCE_TYPE_MASK) == _ASCE_TYPE_SEGMENT)
28562868
return -EINVAL;
28572869

2858-
page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
2870+
page = gmap_alloc_crst();
28592871
if (!page)
28602872
return -ENOMEM;
28612873
page->index = 0;

arch/s390/mm/pgalloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ struct page *page_table_alloc_pgste(struct mm_struct *mm)
146146
ptdesc = pagetable_alloc(GFP_KERNEL, 0);
147147
if (ptdesc) {
148148
table = (u64 *)ptdesc_to_virt(ptdesc);
149+
arch_set_page_dat(virt_to_page(table), 0);
149150
memset64(table, _PAGE_INVALID, PTRS_PER_PTE);
150151
memset64(table + PTRS_PER_PTE, 0, PTRS_PER_PTE);
151152
}

0 commit comments

Comments
 (0)