2e409b
commit 28fa7bd09013455b5ddc020dea4706278cda0d65
2e409b
Author: Dave Anderson <anderson@redhat.com>
2e409b
Date:   Tue Jun 19 16:31:54 2018 -0400
2e409b
2e409b
    Fix for PPC64 kernel virtual address translation in Linux 4.17 and
2e409b
    later kernels with commit c2b4d8b7417a59b7f9a52d0d8402f5257cbbd398,
2e409b
    titled "powerpc/mm/hash64: Increase the VA range", in which the
2e409b
    maximum virtual address value has been increased to 4PB.  Without
2e409b
    the patch, the translation/access of high vmalloc space addresses
2e409b
    fails; for example, the "kmem -[sS]" option fails the translation
2e409b
    of per-cpu kmem_cache_cpu addresses located in vmalloc space, with
2e409b
    the error messages "kmem: invalid kernel virtual address: <address>
2e409b
    type: kmem_cache_cpu.freelist" and "kmem: invalid kernel virtual
2e409b
    address: <address>  type: kmem_cache_cpu.page", and the "vtop"
2e409b
    command shows the addresses as "(not mapped)".
2e409b
    (hbathini@linux.ibm.com)
2e409b
2e409b
diff --git a/defs.h b/defs.h
2e409b
index 6e6f6be..e6e3850 100644
2e409b
--- a/defs.h
2e409b
+++ b/defs.h
2e409b
@@ -3978,6 +3978,7 @@ struct efi_memory_desc_t {
2e409b
 #define PMD_INDEX_SIZE_L4_64K_4_12 10
2e409b
 #define PUD_INDEX_SIZE_L4_64K_4_12 7
2e409b
 #define PGD_INDEX_SIZE_L4_64K_4_12 8
2e409b
+#define PUD_INDEX_SIZE_L4_64K_4_17 10
2e409b
 #define PTE_INDEX_SIZE_RADIX_64K  5
2e409b
 #define PMD_INDEX_SIZE_RADIX_64K  9
2e409b
 #define PUD_INDEX_SIZE_RADIX_64K  9
2e409b
diff --git a/ppc64.c b/ppc64.c
2e409b
index 0dd8a2a..f5d0dac 100644
2e409b
--- a/ppc64.c
2e409b
+++ b/ppc64.c
2e409b
@@ -451,7 +451,10 @@ ppc64_init(int when)
2e409b
 
2e409b
 					if (THIS_KERNEL_VERSION >= LINUX(4,12,0)) {
2e409b
 						m->l2_index_size = PMD_INDEX_SIZE_L4_64K_4_12;
2e409b
-						m->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_12;
2e409b
+						if (THIS_KERNEL_VERSION >= LINUX(4,17,0))
2e409b
+							m->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_17;
2e409b
+						else
2e409b
+							m->l3_index_size = PUD_INDEX_SIZE_L4_64K_4_12;
2e409b
 						m->l4_index_size = PGD_INDEX_SIZE_L4_64K_4_12;
2e409b
 					} else {
2e409b
 						m->l2_index_size = PMD_INDEX_SIZE_L4_64K_4_6;