Blob Blame History Raw
From: Heiko Carstens <hca@linux.ibm.com>
Date: Tue, 17 Oct 2023 21:07:04 +0200
Subject: s390/mm: add missing arch_set_page_dat() call to vmem_crst_alloc()
Git-commit: 09cda0a400519b1541591c506e54c9c48e3101bf
Patch-mainline: v6.7-rc1
References: LTC#203996 bsc#1217087

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 and segment tables allocated via vmem_crst_alloc() are incorrectly
marked as "no-dat", as soon as slab_is_available() returns true.

Such tables are allocated e.g. when kernel page tables are split, memory is
hotplugged, or a DCSS segment is loaded.

Fix this by adding the missing arch_set_page_dat() call.

Cc: <stable@vger.kernel.org>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Acked-by: Miroslav Franc <mfranc@suse.cz>
---
 arch/s390/mm/vmem.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -11,6 +11,7 @@
 #include <linux/hugetlb.h>
 #include <linux/slab.h>
 #include <linux/memblock.h>
+#include <asm/page-states.h>
 #include <asm/cacheflush.h>
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
@@ -33,8 +34,12 @@ static void __ref *vmem_alloc_pages(unsi
 {
 	unsigned long size = PAGE_SIZE << order;
 
-	if (slab_is_available())
-		return (void *)__get_free_pages(GFP_KERNEL, order);
+	if (slab_is_available()) {
+		void *table = (void *)__get_free_pages(GFP_KERNEL, order);
+
+		arch_set_page_dat(virt_to_page(table), order);
+		return table;
+	}
 	return (void *) memblock_alloc(size, size);
 }