|
| 1 | +powerpc/64: Fix the definition of the fixmap area |
| 2 | + |
| 3 | +jira LE-1907 |
| 4 | +cve CVE-2021-47018 |
| 5 | +Rebuild_History Non-Buildable kernel-4.18.0-553.16.1.el8_10 |
| 6 | +commit-author Christophe Leroy < [email protected]> |
| 7 | +commit 9ccba66d4d2aff9a3909aa77d57ea8b7cc166f3c |
| 8 | +Empty-Commit: Cherry-Pick Conflicts during history rebuild. |
| 9 | +Will be included in final tarball splat. Ref for failed cherry-pick at: |
| 10 | +ciq/ciq_backports/kernel-4.18.0-553.16.1.el8_10/9ccba66d.failed |
| 11 | + |
| 12 | +At the time being, the fixmap area is defined at the top of |
| 13 | +the address space or just below KASAN. |
| 14 | + |
| 15 | +This definition is not valid for PPC64. |
| 16 | + |
| 17 | +For PPC64, use the top of the I/O space. |
| 18 | + |
| 19 | +Because of circular dependencies, it is not possible to include |
| 20 | +asm/fixmap.h in asm/book3s/64/pgtable.h , so define a fixed size |
| 21 | +AREA at the top of the I/O space for fixmap and ensure during |
| 22 | +build that the size is big enough. |
| 23 | + |
| 24 | +Fixes: 265c3491c4bc ("powerpc: Add support for GENERIC_EARLY_IOREMAP") |
| 25 | + Signed-off-by: Christophe Leroy < [email protected]> |
| 26 | + Signed-off-by: Michael Ellerman < [email protected]> |
| 27 | +Link: https://lore.kernel.org/r/0d51620eacf036d683d1a3c41328f69adb601dc0.1618925560.git.christophe.leroy@csgroup.eu |
| 28 | + |
| 29 | +(cherry picked from commit 9ccba66d4d2aff9a3909aa77d57ea8b7cc166f3c) |
| 30 | + Signed-off-by: Jonathan Maple < [email protected]> |
| 31 | + |
| 32 | +# Conflicts: |
| 33 | +# arch/powerpc/include/asm/book3s/64/pgtable.h |
| 34 | +# arch/powerpc/include/asm/fixmap.h |
| 35 | +# arch/powerpc/include/asm/nohash/64/pgtable.h |
| 36 | +diff --cc arch/powerpc/include/asm/book3s/64/pgtable.h |
| 37 | +index f0de9261e117,a666d561b44d..000000000000 |
| 38 | +--- a/arch/powerpc/include/asm/book3s/64/pgtable.h |
| 39 | ++++ b/arch/powerpc/include/asm/book3s/64/pgtable.h |
| 40 | +@@@ -347,7 -324,9 +348,13 @@@ extern unsigned long pci_io_base |
| 41 | + #define PHB_IO_BASE (ISA_IO_END) |
| 42 | + #define PHB_IO_END (KERN_IO_START + FULL_IO_SIZE) |
| 43 | + #define IOREMAP_BASE (PHB_IO_END) |
| 44 | +++<<<<<<< HEAD |
| 45 | + +#define IOREMAP_END (KERN_IO_END) |
| 46 | +++======= |
| 47 | ++ #define IOREMAP_START (ioremap_bot) |
| 48 | ++ #define IOREMAP_END (KERN_IO_END - FIXADDR_SIZE) |
| 49 | ++ #define FIXADDR_SIZE SZ_32M |
| 50 | +++>>>>>>> 9ccba66d4d2a (powerpc/64: Fix the definition of the fixmap area) |
| 51 | + |
| 52 | + /* Advertise special mapping type for AGP */ |
| 53 | + #define HAVE_PAGE_AGP |
| 54 | +diff --cc arch/powerpc/include/asm/fixmap.h |
| 55 | +index 9c7927a7c5c4,947b5b9c4424..000000000000 |
| 56 | +--- a/arch/powerpc/include/asm/fixmap.h |
| 57 | ++++ b/arch/powerpc/include/asm/fixmap.h |
| 58 | +@@@ -23,7 -23,17 +23,21 @@@ |
| 59 | + #include <asm/kmap_size.h> |
| 60 | + #endif |
| 61 | + |
| 62 | +++<<<<<<< HEAD |
| 63 | + +#define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE)) |
| 64 | +++======= |
| 65 | ++ #ifdef CONFIG_PPC64 |
| 66 | ++ #define FIXADDR_TOP (IOREMAP_END + FIXADDR_SIZE) |
| 67 | ++ #else |
| 68 | ++ #define FIXADDR_SIZE 0 |
| 69 | ++ #ifdef CONFIG_KASAN |
| 70 | ++ #include <asm/kasan.h> |
| 71 | ++ #define FIXADDR_TOP (KASAN_SHADOW_START - PAGE_SIZE) |
| 72 | ++ #else |
| 73 | ++ #define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE)) |
| 74 | ++ #endif |
| 75 | ++ #endif |
| 76 | +++>>>>>>> 9ccba66d4d2a (powerpc/64: Fix the definition of the fixmap area) |
| 77 | + |
| 78 | + /* |
| 79 | + * Here we define all the compile-time 'special' virtual |
| 80 | +@@@ -45,9 -55,10 +59,10 @@@ |
| 81 | + */ |
| 82 | + enum fixed_addresses { |
| 83 | + FIX_HOLE, |
| 84 | ++ #ifdef CONFIG_PPC32 |
| 85 | + /* reserve the top 128K for early debugging purposes */ |
| 86 | + FIX_EARLY_DEBUG_TOP = FIX_HOLE, |
| 87 | + - FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+(ALIGN(SZ_128K, PAGE_SIZE)/PAGE_SIZE)-1, |
| 88 | + + FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+((128*1024)/PAGE_SIZE)-1, |
| 89 | + #ifdef CONFIG_HIGHMEM |
| 90 | + FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ |
| 91 | + FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_MAX_IDX * NR_CPUS) - 1, |
| 92 | +@@@ -58,8 -69,24 +73,20 @@@ |
| 93 | + FIX_IMMR_START, |
| 94 | + FIX_IMMR_BASE = __ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1) - 1 + |
| 95 | + FIX_IMMR_SIZE, |
| 96 | + -#endif |
| 97 | + -#ifdef CONFIG_PPC_83xx |
| 98 | + - /* For IMMR we need an aligned 2M area */ |
| 99 | + -#define FIX_IMMR_SIZE (SZ_2M / PAGE_SIZE) |
| 100 | + - FIX_IMMR_START, |
| 101 | + - FIX_IMMR_BASE = __ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1) - 1 + |
| 102 | + - FIX_IMMR_SIZE, |
| 103 | + #endif |
| 104 | + /* FIX_PCIE_MCFG, */ |
| 105 | +++<<<<<<< HEAD |
| 106 | +++======= |
| 107 | ++ #endif /* CONFIG_PPC32 */ |
| 108 | ++ __end_of_permanent_fixed_addresses, |
| 109 | ++ |
| 110 | ++ #define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) |
| 111 | ++ #define FIX_BTMAPS_SLOTS 16 |
| 112 | ++ #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) |
| 113 | ++ |
| 114 | ++ FIX_BTMAP_END = __end_of_permanent_fixed_addresses, |
| 115 | ++ FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1, |
| 116 | +++>>>>>>> 9ccba66d4d2a (powerpc/64: Fix the definition of the fixmap area) |
| 117 | + __end_of_fixed_addresses |
| 118 | + }; |
| 119 | + |
| 120 | +@@@ -73,8 -105,17 +100,19 @@@ |
| 121 | + static inline void __set_fixmap(enum fixed_addresses idx, |
| 122 | + phys_addr_t phys, pgprot_t flags) |
| 123 | + { |
| 124 | +++<<<<<<< HEAD |
| 125 | + + map_kernel_page(fix_to_virt(idx), phys, flags); |
| 126 | +++======= |
| 127 | ++ BUILD_BUG_ON(IS_ENABLED(CONFIG_PPC64) && __FIXADDR_SIZE > FIXADDR_SIZE); |
| 128 | ++ |
| 129 | ++ if (__builtin_constant_p(idx)) |
| 130 | ++ BUILD_BUG_ON(idx >= __end_of_fixed_addresses); |
| 131 | ++ else if (WARN_ON(idx >= __end_of_fixed_addresses)) |
| 132 | ++ return; |
| 133 | ++ |
| 134 | ++ map_kernel_page(__fix_to_virt(idx), phys, flags); |
| 135 | +++>>>>>>> 9ccba66d4d2a (powerpc/64: Fix the definition of the fixmap area) |
| 136 | + } |
| 137 | + |
| 138 | + -#define __early_set_fixmap __set_fixmap |
| 139 | + - |
| 140 | + #endif /* !__ASSEMBLY__ */ |
| 141 | + #endif |
| 142 | +diff --cc arch/powerpc/include/asm/nohash/64/pgtable.h |
| 143 | +index 000f7255792a,57cd3892bfe0..000000000000 |
| 144 | +--- a/arch/powerpc/include/asm/nohash/64/pgtable.h |
| 145 | ++++ b/arch/powerpc/include/asm/nohash/64/pgtable.h |
| 146 | +@@@ -3,15 -3,14 +3,17 @@@ |
| 147 | + #define _ASM_POWERPC_NOHASH_64_PGTABLE_H |
| 148 | + /* |
| 149 | + * This file contains the functions and defines necessary to modify and use |
| 150 | + - * the ppc64 non-hashed page table. |
| 151 | + + * the ppc64 hashed page table. |
| 152 | + */ |
| 153 | + |
| 154 | ++ #include <linux/sizes.h> |
| 155 | ++ |
| 156 | + #include <asm/nohash/64/pgtable-4k.h> |
| 157 | + #include <asm/barrier.h> |
| 158 | + -#include <asm/asm-const.h> |
| 159 | + + |
| 160 | + +#ifdef CONFIG_PPC_64K_PAGES |
| 161 | + +#error "Page size not supported" |
| 162 | + +#endif |
| 163 | + |
| 164 | + #define FIRST_USER_ADDRESS 0UL |
| 165 | + |
| 166 | +@@@ -60,7 -55,9 +62,13 @@@ |
| 167 | + #define PHB_IO_BASE (ISA_IO_END) |
| 168 | + #define PHB_IO_END (KERN_IO_START + FULL_IO_SIZE) |
| 169 | + #define IOREMAP_BASE (PHB_IO_END) |
| 170 | +++<<<<<<< HEAD |
| 171 | + +#define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE) |
| 172 | +++======= |
| 173 | ++ #define IOREMAP_START (ioremap_bot) |
| 174 | ++ #define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE - FIXADDR_SIZE) |
| 175 | ++ #define FIXADDR_SIZE SZ_32M |
| 176 | +++>>>>>>> 9ccba66d4d2a (powerpc/64: Fix the definition of the fixmap area) |
| 177 | + |
| 178 | + |
| 179 | + /* |
| 180 | +* Unmerged path arch/powerpc/include/asm/book3s/64/pgtable.h |
| 181 | +* Unmerged path arch/powerpc/include/asm/fixmap.h |
| 182 | +* Unmerged path arch/powerpc/include/asm/nohash/64/pgtable.h |
0 commit comments