aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/Makefile12
-rw-r--r--arch/powerpc/kernel/btext.c16
-rw-r--r--arch/powerpc/kernel/cacheinfo.c2
-rw-r--r--arch/powerpc/kernel/cpu_setup_6xx.S2
-rw-r--r--arch/powerpc/kernel/cpu_setup_fsl_booke.S2
-rw-r--r--arch/powerpc/kernel/cputable.c10
-rw-r--r--arch/powerpc/kernel/dma-iommu.c2
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c6
-rw-r--r--arch/powerpc/kernel/dma.c31
-rw-r--r--arch/powerpc/kernel/eeh.c20
-rw-r--r--arch/powerpc/kernel/eeh_driver.c2
-rw-r--r--arch/powerpc/kernel/eeh_event.c9
-rw-r--r--arch/powerpc/kernel/entry_32.S10
-rw-r--r--arch/powerpc/kernel/entry_64.S16
-rw-r--r--arch/powerpc/kernel/exceptions-64e.S26
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S2
-rw-r--r--arch/powerpc/kernel/fadump.c154
-rw-r--r--arch/powerpc/kernel/head_32.S20
-rw-r--r--arch/powerpc/kernel/head_44x.S11
-rw-r--r--arch/powerpc/kernel/head_8xx.S369
-rw-r--r--arch/powerpc/kernel/head_booke.h6
-rw-r--r--arch/powerpc/kernel/head_fsl_booke.S15
-rw-r--r--arch/powerpc/kernel/iommu.c69
-rw-r--r--arch/powerpc/kernel/isa-bridge.c3
-rw-r--r--arch/powerpc/kernel/legacy_serial.c10
-rw-r--r--arch/powerpc/kernel/misc_32.S4
-rw-r--r--arch/powerpc/kernel/nvram_64.c1
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c11
-rw-r--r--arch/powerpc/kernel/pmc.c2
-rw-r--r--arch/powerpc/kernel/prom.c10
-rw-r--r--arch/powerpc/kernel/ptrace.c54
-rw-r--r--arch/powerpc/kernel/security.c29
-rw-r--r--arch/powerpc/kernel/setup-common.c7
-rw-r--r--arch/powerpc/kernel/setup_32.c6
-rw-r--r--arch/powerpc/kernel/signal_32.c50
-rw-r--r--arch/powerpc/kernel/signal_64.c71
-rw-r--r--arch/powerpc/kernel/syscalls/Makefile63
-rw-r--r--arch/powerpc/kernel/syscalls/syscall.tbl427
-rw-r--r--arch/powerpc/kernel/syscalls/syscallhdr.sh37
-rw-r--r--arch/powerpc/kernel/syscalls/syscalltbl.sh36
-rw-r--r--arch/powerpc/kernel/sysfs.c2
-rw-r--r--arch/powerpc/kernel/systbl.S40
-rw-r--r--arch/powerpc/kernel/systbl_chk.c60
-rw-r--r--arch/powerpc/kernel/trace/ftrace.c2
-rw-r--r--arch/powerpc/kernel/traps.c3
-rw-r--r--arch/powerpc/kernel/vdso.c7
-rw-r--r--arch/powerpc/kernel/vmlinux.lds.S18
47 files changed, 1177 insertions, 588 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 53d4b8d5b54d..cb7f0bb9ee71 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -69,7 +69,7 @@ obj-$(CONFIG_FA_DUMP) += fadump.o
69ifdef CONFIG_PPC32 69ifdef CONFIG_PPC32
70obj-$(CONFIG_E500) += idle_e500.o 70obj-$(CONFIG_E500) += idle_e500.o
71endif 71endif
72obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o 72obj-$(CONFIG_PPC_BOOK3S_32) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
73obj-$(CONFIG_TAU) += tau_6xx.o 73obj-$(CONFIG_TAU) += tau_6xx.o
74obj-$(CONFIG_HIBERNATION) += swsusp.o suspend.o 74obj-$(CONFIG_HIBERNATION) += swsusp.o suspend.o
75ifdef CONFIG_FSL_BOOKE 75ifdef CONFIG_FSL_BOOKE
@@ -160,16 +160,6 @@ extra-$(CONFIG_ALTIVEC) += vector.o
160extra-$(CONFIG_PPC64) += entry_64.o 160extra-$(CONFIG_PPC64) += entry_64.o
161extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init.o 161extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init.o
162 162
163extra-y += systbl_chk.i
164$(obj)/systbl.o: systbl_chk
165
166quiet_cmd_systbl_chk = CALL $<
167 cmd_systbl_chk = $(CONFIG_SHELL) $< $(obj)/systbl_chk.i
168
169PHONY += systbl_chk
170systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i
171 $(call cmd,systbl_chk)
172
173ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE 163ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE
174$(obj)/built-in.a: prom_init_check 164$(obj)/built-in.a: prom_init_check
175 165
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index b4241ed1456e..6dfceaa820e4 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -232,20 +232,12 @@ static int btext_initialize(struct device_node *np)
232 232
233int __init btext_find_display(int allow_nonstdout) 233int __init btext_find_display(int allow_nonstdout)
234{ 234{
235 const char *name; 235 struct device_node *np = of_stdout;
236 struct device_node *np = NULL;
237 int rc = -ENODEV; 236 int rc = -ENODEV;
238 237
239 name = of_get_property(of_chosen, "linux,stdout-path", NULL); 238 if (!of_node_is_type(np, "display")) {
240 if (name != NULL) { 239 printk("boot stdout isn't a display !\n");
241 np = of_find_node_by_path(name); 240 np = NULL;
242 if (np != NULL) {
243 if (strcmp(np->type, "display") != 0) {
244 printk("boot stdout isn't a display !\n");
245 of_node_put(np);
246 np = NULL;
247 }
248 }
249 } 241 }
250 if (np) 242 if (np)
251 rc = btext_initialize(np); 243 rc = btext_initialize(np);
diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index be57bd07596d..53102764fd2f 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -428,7 +428,7 @@ static void link_cache_lists(struct cache *smaller, struct cache *bigger)
428static void do_subsidiary_caches_debugcheck(struct cache *cache) 428static void do_subsidiary_caches_debugcheck(struct cache *cache)
429{ 429{
430 WARN_ON_ONCE(cache->level != 1); 430 WARN_ON_ONCE(cache->level != 1);
431 WARN_ON_ONCE(strcmp(cache->ofnode->type, "cpu")); 431 WARN_ON_ONCE(!of_node_is_type(cache->ofnode, "cpu"));
432} 432}
433 433
434static void do_subsidiary_caches(struct cache *cache) 434static void do_subsidiary_caches(struct cache *cache)
diff --git a/arch/powerpc/kernel/cpu_setup_6xx.S b/arch/powerpc/kernel/cpu_setup_6xx.S
index fa3c2c91290c..8c069e96c478 100644
--- a/arch/powerpc/kernel/cpu_setup_6xx.S
+++ b/arch/powerpc/kernel/cpu_setup_6xx.S
@@ -326,7 +326,7 @@ _GLOBAL(__save_cpu_setup)
326 lis r5,cpu_state_storage@h 326 lis r5,cpu_state_storage@h
327 ori r5,r5,cpu_state_storage@l 327 ori r5,r5,cpu_state_storage@l
328 328
329 /* Save HID0 (common to all CONFIG_6xx cpus) */ 329 /* Save HID0 (common to all CONFIG_PPC_BOOK3S_32 cpus) */
330 mfspr r3,SPRN_HID0 330 mfspr r3,SPRN_HID0
331 stw r3,CS_HID0(r5) 331 stw r3,CS_HID0(r5)
332 332
diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 8d142e5d84cd..5fbc890d1094 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -17,7 +17,7 @@
17#include <asm/processor.h> 17#include <asm/processor.h>
18#include <asm/cputable.h> 18#include <asm/cputable.h>
19#include <asm/ppc_asm.h> 19#include <asm/ppc_asm.h>
20#include <asm/mmu-book3e.h> 20#include <asm/nohash/mmu-book3e.h>
21#include <asm/asm-offsets.h> 21#include <asm/asm-offsets.h>
22#include <asm/mpc85xx.h> 22#include <asm/mpc85xx.h>
23 23
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 2da01340c84c..1eab54bc6ee9 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -1141,6 +1141,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
1141 .machine_check = machine_check_generic, 1141 .machine_check = machine_check_generic,
1142 .platform = "ppc603", 1142 .platform = "ppc603",
1143 }, 1143 },
1144#ifdef CONFIG_PPC_83xx
1144 { /* e300c1 (a 603e core, plus some) on 83xx */ 1145 { /* e300c1 (a 603e core, plus some) on 83xx */
1145 .pvr_mask = 0x7fff0000, 1146 .pvr_mask = 0x7fff0000,
1146 .pvr_value = 0x00830000, 1147 .pvr_value = 0x00830000,
@@ -1151,7 +1152,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
1151 .icache_bsize = 32, 1152 .icache_bsize = 32,
1152 .dcache_bsize = 32, 1153 .dcache_bsize = 32,
1153 .cpu_setup = __setup_cpu_603, 1154 .cpu_setup = __setup_cpu_603,
1154 .machine_check = machine_check_generic, 1155 .machine_check = machine_check_83xx,
1155 .platform = "ppc603", 1156 .platform = "ppc603",
1156 }, 1157 },
1157 { /* e300c2 (an e300c1 core, plus some, minus FPU) on 83xx */ 1158 { /* e300c2 (an e300c1 core, plus some, minus FPU) on 83xx */
@@ -1165,7 +1166,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
1165 .icache_bsize = 32, 1166 .icache_bsize = 32,
1166 .dcache_bsize = 32, 1167 .dcache_bsize = 32,
1167 .cpu_setup = __setup_cpu_603, 1168 .cpu_setup = __setup_cpu_603,
1168 .machine_check = machine_check_generic, 1169 .machine_check = machine_check_83xx,
1169 .platform = "ppc603", 1170 .platform = "ppc603",
1170 }, 1171 },
1171 { /* e300c3 (e300c1, plus one IU, half cache size) on 83xx */ 1172 { /* e300c3 (e300c1, plus one IU, half cache size) on 83xx */
@@ -1179,7 +1180,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
1179 .icache_bsize = 32, 1180 .icache_bsize = 32,
1180 .dcache_bsize = 32, 1181 .dcache_bsize = 32,
1181 .cpu_setup = __setup_cpu_603, 1182 .cpu_setup = __setup_cpu_603,
1182 .machine_check = machine_check_generic, 1183 .machine_check = machine_check_83xx,
1183 .num_pmcs = 4, 1184 .num_pmcs = 4,
1184 .oprofile_cpu_type = "ppc/e300", 1185 .oprofile_cpu_type = "ppc/e300",
1185 .oprofile_type = PPC_OPROFILE_FSL_EMB, 1186 .oprofile_type = PPC_OPROFILE_FSL_EMB,
@@ -1196,12 +1197,13 @@ static struct cpu_spec __initdata cpu_specs[] = {
1196 .icache_bsize = 32, 1197 .icache_bsize = 32,
1197 .dcache_bsize = 32, 1198 .dcache_bsize = 32,
1198 .cpu_setup = __setup_cpu_603, 1199 .cpu_setup = __setup_cpu_603,
1199 .machine_check = machine_check_generic, 1200 .machine_check = machine_check_83xx,
1200 .num_pmcs = 4, 1201 .num_pmcs = 4,
1201 .oprofile_cpu_type = "ppc/e300", 1202 .oprofile_cpu_type = "ppc/e300",
1202 .oprofile_type = PPC_OPROFILE_FSL_EMB, 1203 .oprofile_type = PPC_OPROFILE_FSL_EMB,
1203 .platform = "ppc603", 1204 .platform = "ppc603",
1204 }, 1205 },
1206#endif
1205 { /* default match, we assume split I/D cache & TB (non-601)... */ 1207 { /* default match, we assume split I/D cache & TB (non-601)... */
1206 .pvr_mask = 0x00000000, 1208 .pvr_mask = 0x00000000,
1207 .pvr_value = 0x00000000, 1209 .pvr_value = 0x00000000,
diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index f9fe2080ceb9..2ca6cfaebf65 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -6,7 +6,6 @@
6 * busses using the iommu infrastructure 6 * busses using the iommu infrastructure
7 */ 7 */
8 8
9#include <linux/export.h>
10#include <asm/iommu.h> 9#include <asm/iommu.h>
11 10
12/* 11/*
@@ -123,4 +122,3 @@ struct dma_map_ops dma_iommu_ops = {
123 .get_required_mask = dma_iommu_get_required_mask, 122 .get_required_mask = dma_iommu_get_required_mask,
124 .mapping_error = dma_iommu_mapping_error, 123 .mapping_error = dma_iommu_mapping_error,
125}; 124};
126EXPORT_SYMBOL(dma_iommu_ops);
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index 5fc335f4d9cd..678811abccfc 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -108,12 +108,8 @@ int __init swiotlb_setup_bus_notifier(void)
108 108
109void __init swiotlb_detect_4g(void) 109void __init swiotlb_detect_4g(void)
110{ 110{
111 if ((memblock_end_of_DRAM() - 1) > 0xffffffff) { 111 if ((memblock_end_of_DRAM() - 1) > 0xffffffff)
112 ppc_swiotlb_enable = 1; 112 ppc_swiotlb_enable = 1;
113#ifdef CONFIG_ZONE_DMA32
114 limit_zone_pfn(ZONE_DMA32, (1ULL << 32) >> PAGE_SHIFT);
115#endif
116 }
117} 113}
118 114
119static int __init check_swiotlb_enabled(void) 115static int __init check_swiotlb_enabled(void)
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index dbfc7056d7df..b1903ebb2e9c 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -50,7 +50,8 @@ static int dma_nommu_dma_supported(struct device *dev, u64 mask)
50 return 1; 50 return 1;
51 51
52#ifdef CONFIG_FSL_SOC 52#ifdef CONFIG_FSL_SOC
53 /* Freescale gets another chance via ZONE_DMA/ZONE_DMA32, however 53 /*
54 * Freescale gets another chance via ZONE_DMA, however
54 * that will have to be refined if/when they support iommus 55 * that will have to be refined if/when they support iommus
55 */ 56 */
56 return 1; 57 return 1;
@@ -62,18 +63,12 @@ static int dma_nommu_dma_supported(struct device *dev, u64 mask)
62#endif 63#endif
63} 64}
64 65
66#ifndef CONFIG_NOT_COHERENT_CACHE
65void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, 67void *__dma_nommu_alloc_coherent(struct device *dev, size_t size,
66 dma_addr_t *dma_handle, gfp_t flag, 68 dma_addr_t *dma_handle, gfp_t flag,
67 unsigned long attrs) 69 unsigned long attrs)
68{ 70{
69 void *ret; 71 void *ret;
70#ifdef CONFIG_NOT_COHERENT_CACHE
71 ret = __dma_alloc_coherent(dev, size, dma_handle, flag);
72 if (ret == NULL)
73 return NULL;
74 *dma_handle += get_dma_offset(dev);
75 return ret;
76#else
77 struct page *page; 72 struct page *page;
78 int node = dev_to_node(dev); 73 int node = dev_to_node(dev);
79#ifdef CONFIG_FSL_SOC 74#ifdef CONFIG_FSL_SOC
@@ -94,13 +89,10 @@ void *__dma_nommu_alloc_coherent(struct device *dev, size_t size,
94 } 89 }
95 90
96 switch (zone) { 91 switch (zone) {
92#ifdef CONFIG_ZONE_DMA
97 case ZONE_DMA: 93 case ZONE_DMA:
98 flag |= GFP_DMA; 94 flag |= GFP_DMA;
99 break; 95 break;
100#ifdef CONFIG_ZONE_DMA32
101 case ZONE_DMA32:
102 flag |= GFP_DMA32;
103 break;
104#endif 96#endif
105 }; 97 };
106#endif /* CONFIG_FSL_SOC */ 98#endif /* CONFIG_FSL_SOC */
@@ -113,19 +105,15 @@ void *__dma_nommu_alloc_coherent(struct device *dev, size_t size,
113 *dma_handle = __pa(ret) + get_dma_offset(dev); 105 *dma_handle = __pa(ret) + get_dma_offset(dev);
114 106
115 return ret; 107 return ret;
116#endif
117} 108}
118 109
119void __dma_nommu_free_coherent(struct device *dev, size_t size, 110void __dma_nommu_free_coherent(struct device *dev, size_t size,
120 void *vaddr, dma_addr_t dma_handle, 111 void *vaddr, dma_addr_t dma_handle,
121 unsigned long attrs) 112 unsigned long attrs)
122{ 113{
123#ifdef CONFIG_NOT_COHERENT_CACHE
124 __dma_free_coherent(size, vaddr);
125#else
126 free_pages((unsigned long)vaddr, get_order(size)); 114 free_pages((unsigned long)vaddr, get_order(size));
127#endif
128} 115}
116#endif /* !CONFIG_NOT_COHERENT_CACHE */
129 117
130static void *dma_nommu_alloc_coherent(struct device *dev, size_t size, 118static void *dma_nommu_alloc_coherent(struct device *dev, size_t size,
131 dma_addr_t *dma_handle, gfp_t flag, 119 dma_addr_t *dma_handle, gfp_t flag,
@@ -210,10 +198,15 @@ static int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl,
210 return nents; 198 return nents;
211} 199}
212 200
213static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sg, 201static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sgl,
214 int nents, enum dma_data_direction direction, 202 int nents, enum dma_data_direction direction,
215 unsigned long attrs) 203 unsigned long attrs)
216{ 204{
205 struct scatterlist *sg;
206 int i;
207
208 for_each_sg(sgl, sg, nents, i)
209 __dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
217} 210}
218 211
219static u64 dma_nommu_get_required_mask(struct device *dev) 212static u64 dma_nommu_get_required_mask(struct device *dev)
@@ -247,6 +240,8 @@ static inline void dma_nommu_unmap_page(struct device *dev,
247 enum dma_data_direction direction, 240 enum dma_data_direction direction,
248 unsigned long attrs) 241 unsigned long attrs)
249{ 242{
243 if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
244 __dma_sync(bus_to_virt(dma_address), size, direction);
250} 245}
251 246
252#ifdef CONFIG_NOT_COHERENT_CACHE 247#ifdef CONFIG_NOT_COHERENT_CACHE
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 6cae6b56ffd6..3230137469ab 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1808,10 +1808,10 @@ static int eeh_freeze_dbgfs_get(void *data, u64 *val)
1808 return 0; 1808 return 0;
1809} 1809}
1810 1810
1811DEFINE_SIMPLE_ATTRIBUTE(eeh_enable_dbgfs_ops, eeh_enable_dbgfs_get, 1811DEFINE_DEBUGFS_ATTRIBUTE(eeh_enable_dbgfs_ops, eeh_enable_dbgfs_get,
1812 eeh_enable_dbgfs_set, "0x%llx\n"); 1812 eeh_enable_dbgfs_set, "0x%llx\n");
1813DEFINE_SIMPLE_ATTRIBUTE(eeh_freeze_dbgfs_ops, eeh_freeze_dbgfs_get, 1813DEFINE_DEBUGFS_ATTRIBUTE(eeh_freeze_dbgfs_ops, eeh_freeze_dbgfs_get,
1814 eeh_freeze_dbgfs_set, "0x%llx\n"); 1814 eeh_freeze_dbgfs_set, "0x%llx\n");
1815#endif 1815#endif
1816 1816
1817static int __init eeh_init_proc(void) 1817static int __init eeh_init_proc(void)
@@ -1819,12 +1819,12 @@ static int __init eeh_init_proc(void)
1819 if (machine_is(pseries) || machine_is(powernv)) { 1819 if (machine_is(pseries) || machine_is(powernv)) {
1820 proc_create_single("powerpc/eeh", 0, NULL, proc_eeh_show); 1820 proc_create_single("powerpc/eeh", 0, NULL, proc_eeh_show);
1821#ifdef CONFIG_DEBUG_FS 1821#ifdef CONFIG_DEBUG_FS
1822 debugfs_create_file("eeh_enable", 0600, 1822 debugfs_create_file_unsafe("eeh_enable", 0600,
1823 powerpc_debugfs_root, NULL, 1823 powerpc_debugfs_root, NULL,
1824 &eeh_enable_dbgfs_ops); 1824 &eeh_enable_dbgfs_ops);
1825 debugfs_create_file("eeh_max_freezes", 0600, 1825 debugfs_create_file_unsafe("eeh_max_freezes", 0600,
1826 powerpc_debugfs_root, NULL, 1826 powerpc_debugfs_root, NULL,
1827 &eeh_freeze_dbgfs_ops); 1827 &eeh_freeze_dbgfs_ops);
1828#endif 1828#endif
1829 } 1829 }
1830 1830
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index 9446248eb6b8..99eab7bc7edc 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -60,7 +60,7 @@ static int eeh_result_priority(enum pci_ers_result result)
60 } 60 }
61}; 61};
62 62
63const char *pci_ers_result_name(enum pci_ers_result result) 63static const char *pci_ers_result_name(enum pci_ers_result result)
64{ 64{
65 switch (result) { 65 switch (result) {
66 case PCI_ERS_RESULT_NONE: 66 case PCI_ERS_RESULT_NONE:
diff --git a/arch/powerpc/kernel/eeh_event.c b/arch/powerpc/kernel/eeh_event.c
index 61c9356bf9c9..227e57f980df 100644
--- a/arch/powerpc/kernel/eeh_event.c
+++ b/arch/powerpc/kernel/eeh_event.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37static DEFINE_SPINLOCK(eeh_eventlist_lock); 37static DEFINE_SPINLOCK(eeh_eventlist_lock);
38static struct semaphore eeh_eventlist_sem; 38static DECLARE_COMPLETION(eeh_eventlist_event);
39static LIST_HEAD(eeh_eventlist); 39static LIST_HEAD(eeh_eventlist);
40 40
41/** 41/**
@@ -55,7 +55,7 @@ static int eeh_event_handler(void * dummy)
55 struct eeh_pe *pe; 55 struct eeh_pe *pe;
56 56
57 while (!kthread_should_stop()) { 57 while (!kthread_should_stop()) {
58 if (down_interruptible(&eeh_eventlist_sem)) 58 if (wait_for_completion_interruptible(&eeh_eventlist_event))
59 break; 59 break;
60 60
61 /* Fetch EEH event from the queue */ 61 /* Fetch EEH event from the queue */
@@ -102,9 +102,6 @@ int eeh_event_init(void)
102 struct task_struct *t; 102 struct task_struct *t;
103 int ret = 0; 103 int ret = 0;
104 104
105 /* Initialize semaphore */
106 sema_init(&eeh_eventlist_sem, 0);
107
108 t = kthread_run(eeh_event_handler, NULL, "eehd"); 105 t = kthread_run(eeh_event_handler, NULL, "eehd");
109 if (IS_ERR(t)) { 106 if (IS_ERR(t)) {
110 ret = PTR_ERR(t); 107 ret = PTR_ERR(t);
@@ -142,7 +139,7 @@ int eeh_send_failure_event(struct eeh_pe *pe)
142 spin_unlock_irqrestore(&eeh_eventlist_lock, flags); 139 spin_unlock_irqrestore(&eeh_eventlist_lock, flags);
143 140
144 /* For EEH deamon to knick in */ 141 /* For EEH deamon to knick in */
145 up(&eeh_eventlist_sem); 142 complete(&eeh_eventlist_event);
146 143
147 return 0; 144 return 0;
148} 145}
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 77decded1175..0768dfd8a64e 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -200,14 +200,14 @@ transfer_to_handler:
200 cmplw r1,r9 /* if r1 <= ksp_limit */ 200 cmplw r1,r9 /* if r1 <= ksp_limit */
201 ble- stack_ovf /* then the kernel stack overflowed */ 201 ble- stack_ovf /* then the kernel stack overflowed */
2025: 2025:
203#if defined(CONFIG_6xx) || defined(CONFIG_E500) 203#if defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_E500)
204 CURRENT_THREAD_INFO(r9, r1) 204 CURRENT_THREAD_INFO(r9, r1)
205 tophys(r9,r9) /* check local flags */ 205 tophys(r9,r9) /* check local flags */
206 lwz r12,TI_LOCAL_FLAGS(r9) 206 lwz r12,TI_LOCAL_FLAGS(r9)
207 mtcrf 0x01,r12 207 mtcrf 0x01,r12
208 bt- 31-TLF_NAPPING,4f 208 bt- 31-TLF_NAPPING,4f
209 bt- 31-TLF_SLEEPING,7f 209 bt- 31-TLF_SLEEPING,7f
210#endif /* CONFIG_6xx || CONFIG_E500 */ 210#endif /* CONFIG_PPC_BOOK3S_32 || CONFIG_E500 */
211 .globl transfer_to_handler_cont 211 .globl transfer_to_handler_cont
212transfer_to_handler_cont: 212transfer_to_handler_cont:
2133: 2133:
@@ -273,7 +273,7 @@ reenable_mmu: /* re-enable mmu so we can */
273 RFI /* jump to handler, enable MMU */ 273 RFI /* jump to handler, enable MMU */
274#endif /* CONFIG_TRACE_IRQFLAGS */ 274#endif /* CONFIG_TRACE_IRQFLAGS */
275 275
276#if defined (CONFIG_6xx) || defined(CONFIG_E500) 276#if defined (CONFIG_PPC_BOOK3S_32) || defined(CONFIG_E500)
2774: rlwinm r12,r12,0,~_TLF_NAPPING 2774: rlwinm r12,r12,0,~_TLF_NAPPING
278 stw r12,TI_LOCAL_FLAGS(r9) 278 stw r12,TI_LOCAL_FLAGS(r9)
279 b power_save_ppc32_restore 279 b power_save_ppc32_restore
@@ -612,7 +612,7 @@ ppc_swapcontext:
612handle_page_fault: 612handle_page_fault:
613 stw r4,_DAR(r1) 613 stw r4,_DAR(r1)
614 addi r3,r1,STACK_FRAME_OVERHEAD 614 addi r3,r1,STACK_FRAME_OVERHEAD
615#ifdef CONFIG_6xx 615#ifdef CONFIG_PPC_BOOK3S_32
616 andis. r0,r5,DSISR_DABRMATCH@h 616 andis. r0,r5,DSISR_DABRMATCH@h
617 bne- handle_dabr_fault 617 bne- handle_dabr_fault
618#endif 618#endif
@@ -629,7 +629,7 @@ handle_page_fault:
629 bl bad_page_fault 629 bl bad_page_fault
630 b ret_from_except_full 630 b ret_from_except_full
631 631
632#ifdef CONFIG_6xx 632#ifdef CONFIG_PPC_BOOK3S_32
633 /* We have a data breakpoint exception - handle it */ 633 /* We have a data breakpoint exception - handle it */
634handle_dabr_fault: 634handle_dabr_fault:
635 SAVE_NVGPRS(r1) 635 SAVE_NVGPRS(r1)
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 7b1693adff2a..435927f549c4 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -54,6 +54,9 @@
54SYS_CALL_TABLE: 54SYS_CALL_TABLE:
55 .tc sys_call_table[TC],sys_call_table 55 .tc sys_call_table[TC],sys_call_table
56 56
57COMPAT_SYS_CALL_TABLE:
58 .tc compat_sys_call_table[TC],compat_sys_call_table
59
57/* This value is used to mark exception frames on the stack. */ 60/* This value is used to mark exception frames on the stack. */
58exception_marker: 61exception_marker:
59 .tc ID_EXC_MARKER[TC],STACK_FRAME_REGS_MARKER 62 .tc ID_EXC_MARKER[TC],STACK_FRAME_REGS_MARKER
@@ -80,6 +83,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_TM)
80 std r0,GPR0(r1) 83 std r0,GPR0(r1)
81 std r10,GPR1(r1) 84 std r10,GPR1(r1)
82 beq 2f /* if from kernel mode */ 85 beq 2f /* if from kernel mode */
86#ifdef CONFIG_PPC_FSL_BOOK3E
87START_BTB_FLUSH_SECTION
88 BTB_FLUSH(r10)
89END_BTB_FLUSH_SECTION
90#endif
83 ACCOUNT_CPU_USER_ENTRY(r13, r10, r11) 91 ACCOUNT_CPU_USER_ENTRY(r13, r10, r11)
842: std r2,GPR2(r1) 922: std r2,GPR2(r1)
85 std r3,GPR3(r1) 93 std r3,GPR3(r1)
@@ -173,7 +181,7 @@ system_call: /* label this so stack traces look sane */
173 ld r11,SYS_CALL_TABLE@toc(2) 181 ld r11,SYS_CALL_TABLE@toc(2)
174 andis. r10,r10,_TIF_32BIT@h 182 andis. r10,r10,_TIF_32BIT@h
175 beq 15f 183 beq 15f
176 addi r11,r11,8 /* use 32-bit syscall entries */ 184 ld r11,COMPAT_SYS_CALL_TABLE@toc(2)
177 clrldi r3,r3,32 185 clrldi r3,r3,32
178 clrldi r4,r4,32 186 clrldi r4,r4,32
179 clrldi r5,r5,32 187 clrldi r5,r5,32
@@ -181,7 +189,7 @@ system_call: /* label this so stack traces look sane */
181 clrldi r7,r7,32 189 clrldi r7,r7,32
182 clrldi r8,r8,32 190 clrldi r8,r8,32
18315: 19115:
184 slwi r0,r0,4 192 slwi r0,r0,3
185 193
186 barrier_nospec_asm 194 barrier_nospec_asm
187 /* 195 /*
@@ -286,6 +294,10 @@ BEGIN_FTR_SECTION
286 HMT_MEDIUM_LOW 294 HMT_MEDIUM_LOW
287END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) 295END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
288 296
297#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
298 std r8, PACATMSCRATCH(r13)
299#endif
300
289 ld r13,GPR13(r1) /* only restore r13 if returning to usermode */ 301 ld r13,GPR13(r1) /* only restore r13 if returning to usermode */
290 ld r2,GPR2(r1) 302 ld r2,GPR2(r1)
291 ld r1,GPR1(r1) 303 ld r1,GPR1(r1)
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index 6d6e144a28ce..afb638778f44 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -296,7 +296,8 @@ ret_from_mc_except:
296 andi. r10,r11,MSR_PR; /* save stack pointer */ \ 296 andi. r10,r11,MSR_PR; /* save stack pointer */ \
297 beq 1f; /* branch around if supervisor */ \ 297 beq 1f; /* branch around if supervisor */ \
298 ld r1,PACAKSAVE(r13); /* get kernel stack coming from usr */\ 298 ld r1,PACAKSAVE(r13); /* get kernel stack coming from usr */\
2991: cmpdi cr1,r1,0; /* check if SP makes sense */ \ 2991: type##_BTB_FLUSH \
300 cmpdi cr1,r1,0; /* check if SP makes sense */ \
300 bge- cr1,exc_##n##_bad_stack;/* bad stack (TODO: out of line) */ \ 301 bge- cr1,exc_##n##_bad_stack;/* bad stack (TODO: out of line) */ \
301 mfspr r10,SPRN_##type##_SRR0; /* read SRR0 before touching stack */ 302 mfspr r10,SPRN_##type##_SRR0; /* read SRR0 before touching stack */
302 303
@@ -328,6 +329,29 @@ ret_from_mc_except:
328#define SPRN_MC_SRR0 SPRN_MCSRR0 329#define SPRN_MC_SRR0 SPRN_MCSRR0
329#define SPRN_MC_SRR1 SPRN_MCSRR1 330#define SPRN_MC_SRR1 SPRN_MCSRR1
330 331
332#ifdef CONFIG_PPC_FSL_BOOK3E
333#define GEN_BTB_FLUSH \
334 START_BTB_FLUSH_SECTION \
335 beq 1f; \
336 BTB_FLUSH(r10) \
337 1: \
338 END_BTB_FLUSH_SECTION
339
340#define CRIT_BTB_FLUSH \
341 START_BTB_FLUSH_SECTION \
342 BTB_FLUSH(r10) \
343 END_BTB_FLUSH_SECTION
344
345#define DBG_BTB_FLUSH CRIT_BTB_FLUSH
346#define MC_BTB_FLUSH CRIT_BTB_FLUSH
347#define GDBELL_BTB_FLUSH GEN_BTB_FLUSH
348#else
349#define GEN_BTB_FLUSH
350#define CRIT_BTB_FLUSH
351#define DBG_BTB_FLUSH
352#define GDBELL_BTB_FLUSH
353#endif
354
331#define NORMAL_EXCEPTION_PROLOG(n, intnum, addition) \ 355#define NORMAL_EXCEPTION_PROLOG(n, intnum, addition) \
332 EXCEPTION_PROLOG(n, intnum, GEN, addition##_GEN(n)) 356 EXCEPTION_PROLOG(n, intnum, GEN, addition##_GEN(n))
333 357
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index db2691ff4c0b..9e253ce27e08 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1040,7 +1040,7 @@ TRAMP_REAL_BEGIN(hmi_exception_early)
1040 EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN) 1040 EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
1041 EXCEPTION_PROLOG_COMMON_3(0xe60) 1041 EXCEPTION_PROLOG_COMMON_3(0xe60)
1042 addi r3,r1,STACK_FRAME_OVERHEAD 1042 addi r3,r1,STACK_FRAME_OVERHEAD
1043 BRANCH_LINK_TO_FAR(hmi_exception_realmode) /* Function call ABI */ 1043 BRANCH_LINK_TO_FAR(DOTSYM(hmi_exception_realmode)) /* Function call ABI */
1044 cmpdi cr0,r3,0 1044 cmpdi cr0,r3,0
1045 1045
1046 /* Windup the stack. */ 1046 /* Windup the stack. */
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 761b28b1427d..45a8d0be1c96 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -35,6 +35,7 @@
35#include <linux/kobject.h> 35#include <linux/kobject.h>
36#include <linux/sysfs.h> 36#include <linux/sysfs.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/cma.h>
38 39
39#include <asm/debugfs.h> 40#include <asm/debugfs.h>
40#include <asm/page.h> 41#include <asm/page.h>
@@ -46,6 +47,9 @@
46static struct fw_dump fw_dump; 47static struct fw_dump fw_dump;
47static struct fadump_mem_struct fdm; 48static struct fadump_mem_struct fdm;
48static const struct fadump_mem_struct *fdm_active; 49static const struct fadump_mem_struct *fdm_active;
50#ifdef CONFIG_CMA
51static struct cma *fadump_cma;
52#endif
49 53
50static DEFINE_MUTEX(fadump_mutex); 54static DEFINE_MUTEX(fadump_mutex);
51struct fad_crash_memory_ranges *crash_memory_ranges; 55struct fad_crash_memory_ranges *crash_memory_ranges;
@@ -53,6 +57,67 @@ int crash_memory_ranges_size;
53int crash_mem_ranges; 57int crash_mem_ranges;
54int max_crash_mem_ranges; 58int max_crash_mem_ranges;
55 59
60#ifdef CONFIG_CMA
61/*
62 * fadump_cma_init() - Initialize CMA area from a fadump reserved memory
63 *
64 * This function initializes CMA area from fadump reserved memory.
65 * The total size of fadump reserved memory covers for boot memory size
66 * + cpu data size + hpte size and metadata.
67 * Initialize only the area equivalent to boot memory size for CMA use.
68 * The reamining portion of fadump reserved memory will be not given
69 * to CMA and pages for thoes will stay reserved. boot memory size is
70 * aligned per CMA requirement to satisy cma_init_reserved_mem() call.
71 * But for some reason even if it fails we still have the memory reservation
72 * with us and we can still continue doing fadump.
73 */
74int __init fadump_cma_init(void)
75{
76 unsigned long long base, size;
77 int rc;
78
79 if (!fw_dump.fadump_enabled)
80 return 0;
81
82 /*
83 * Do not use CMA if user has provided fadump=nocma kernel parameter.
84 * Return 1 to continue with fadump old behaviour.
85 */
86 if (fw_dump.nocma)
87 return 1;
88
89 base = fw_dump.reserve_dump_area_start;
90 size = fw_dump.boot_memory_size;
91
92 if (!size)
93 return 0;
94
95 rc = cma_init_reserved_mem(base, size, 0, "fadump_cma", &fadump_cma);
96 if (rc) {
97 pr_err("Failed to init cma area for firmware-assisted dump,%d\n", rc);
98 /*
99 * Though the CMA init has failed we still have memory
100 * reservation with us. The reserved memory will be
101 * blocked from production system usage. Hence return 1,
102 * so that we can continue with fadump.
103 */
104 return 1;
105 }
106
107 /*
108 * So we now have successfully initialized cma area for fadump.
109 */
110 pr_info("Initialized 0x%lx bytes cma area at %ldMB from 0x%lx "
111 "bytes of memory reserved for firmware-assisted dump\n",
112 cma_get_size(fadump_cma),
113 (unsigned long)cma_get_base(fadump_cma) >> 20,
114 fw_dump.reserve_dump_area_size);
115 return 1;
116}
117#else
118static int __init fadump_cma_init(void) { return 1; }
119#endif /* CONFIG_CMA */
120
56/* Scan the Firmware Assisted dump configuration details. */ 121/* Scan the Firmware Assisted dump configuration details. */
57int __init early_init_dt_scan_fw_dump(unsigned long node, 122int __init early_init_dt_scan_fw_dump(unsigned long node,
58 const char *uname, int depth, void *data) 123 const char *uname, int depth, void *data)
@@ -118,13 +183,19 @@ int __init early_init_dt_scan_fw_dump(unsigned long node,
118 183
119/* 184/*
120 * If fadump is registered, check if the memory provided 185 * If fadump is registered, check if the memory provided
121 * falls within boot memory area. 186 * falls within boot memory area and reserved memory area.
122 */ 187 */
123int is_fadump_boot_memory_area(u64 addr, ulong size) 188int is_fadump_memory_area(u64 addr, ulong size)
124{ 189{
190 u64 d_start = fw_dump.reserve_dump_area_start;
191 u64 d_end = d_start + fw_dump.reserve_dump_area_size;
192
125 if (!fw_dump.dump_registered) 193 if (!fw_dump.dump_registered)
126 return 0; 194 return 0;
127 195
196 if (((addr + size) > d_start) && (addr <= d_end))
197 return 1;
198
128 return (addr + size) > RMA_START && addr <= fw_dump.boot_memory_size; 199 return (addr + size) > RMA_START && addr <= fw_dump.boot_memory_size;
129} 200}
130 201
@@ -172,6 +243,35 @@ static int is_boot_memory_area_contiguous(void)
172 return ret; 243 return ret;
173} 244}
174 245
246/*
247 * Returns true, if there are no holes in reserved memory area,
248 * false otherwise.
249 */
250static bool is_reserved_memory_area_contiguous(void)
251{
252 struct memblock_region *reg;
253 unsigned long start, end;
254 unsigned long d_start = fw_dump.reserve_dump_area_start;
255 unsigned long d_end = d_start + fw_dump.reserve_dump_area_size;
256
257 for_each_memblock(memory, reg) {
258 start = max(d_start, (unsigned long)reg->base);
259 end = min(d_end, (unsigned long)(reg->base + reg->size));
260 if (d_start < end) {
261 /* Memory hole from d_start to start */
262 if (start > d_start)
263 break;
264
265 if (end == d_end)
266 return true;
267
268 d_start = end + 1;
269 }
270 }
271
272 return false;
273}
274
175/* Print firmware assisted dump configurations for debugging purpose. */ 275/* Print firmware assisted dump configurations for debugging purpose. */
176static void fadump_show_config(void) 276static void fadump_show_config(void)
177{ 277{
@@ -378,8 +478,15 @@ int __init fadump_reserve_mem(void)
378 */ 478 */
379 if (fdm_active) 479 if (fdm_active)
380 fw_dump.boot_memory_size = be64_to_cpu(fdm_active->rmr_region.source_len); 480 fw_dump.boot_memory_size = be64_to_cpu(fdm_active->rmr_region.source_len);
381 else 481 else {
382 fw_dump.boot_memory_size = fadump_calculate_reserve_size(); 482 fw_dump.boot_memory_size = fadump_calculate_reserve_size();
483#ifdef CONFIG_CMA
484 if (!fw_dump.nocma)
485 fw_dump.boot_memory_size =
486 ALIGN(fw_dump.boot_memory_size,
487 FADUMP_CMA_ALIGNMENT);
488#endif
489 }
383 490
384 /* 491 /*
385 * Calculate the memory boundary. 492 * Calculate the memory boundary.
@@ -426,8 +533,9 @@ int __init fadump_reserve_mem(void)
426 fw_dump.fadumphdr_addr = 533 fw_dump.fadumphdr_addr =
427 be64_to_cpu(fdm_active->rmr_region.destination_address) + 534 be64_to_cpu(fdm_active->rmr_region.destination_address) +
428 be64_to_cpu(fdm_active->rmr_region.source_len); 535 be64_to_cpu(fdm_active->rmr_region.source_len);
429 pr_debug("fadumphdr_addr = %p\n", 536 pr_debug("fadumphdr_addr = %pa\n", &fw_dump.fadumphdr_addr);
430 (void *) fw_dump.fadumphdr_addr); 537 fw_dump.reserve_dump_area_start = base;
538 fw_dump.reserve_dump_area_size = size;
431 } else { 539 } else {
432 size = get_fadump_area_size(); 540 size = get_fadump_area_size();
433 541
@@ -455,10 +563,11 @@ int __init fadump_reserve_mem(void)
455 (unsigned long)(size >> 20), 563 (unsigned long)(size >> 20),
456 (unsigned long)(base >> 20), 564 (unsigned long)(base >> 20),
457 (unsigned long)(memblock_phys_mem_size() >> 20)); 565 (unsigned long)(memblock_phys_mem_size() >> 20));
458 }
459 566
460 fw_dump.reserve_dump_area_start = base; 567 fw_dump.reserve_dump_area_start = base;
461 fw_dump.reserve_dump_area_size = size; 568 fw_dump.reserve_dump_area_size = size;
569 return fadump_cma_init();
570 }
462 return 1; 571 return 1;
463} 572}
464 573
@@ -477,6 +586,10 @@ static int __init early_fadump_param(char *p)
477 fw_dump.fadump_enabled = 1; 586 fw_dump.fadump_enabled = 1;
478 else if (strncmp(p, "off", 3) == 0) 587 else if (strncmp(p, "off", 3) == 0)
479 fw_dump.fadump_enabled = 0; 588 fw_dump.fadump_enabled = 0;
589 else if (strncmp(p, "nocma", 5) == 0) {
590 fw_dump.fadump_enabled = 1;
591 fw_dump.nocma = 1;
592 }
480 593
481 return 0; 594 return 0;
482} 595}
@@ -525,8 +638,10 @@ static int register_fw_dump(struct fadump_mem_struct *fdm)
525 break; 638 break;
526 case -3: 639 case -3:
527 if (!is_boot_memory_area_contiguous()) 640 if (!is_boot_memory_area_contiguous())
528 pr_err("Can't have holes in boot memory area while " 641 pr_err("Can't have holes in boot memory area while registering fadump\n");
529 "registering fadump\n"); 642 else if (!is_reserved_memory_area_contiguous())
643 pr_err("Can't have holes in reserved memory area while"
644 " registering fadump\n");
530 645
531 printk(KERN_ERR "Failed to register firmware-assisted kernel" 646 printk(KERN_ERR "Failed to register firmware-assisted kernel"
532 " dump. Parameter Error(%d).\n", rc); 647 " dump. Parameter Error(%d).\n", rc);
@@ -1229,7 +1344,7 @@ static int fadump_unregister_dump(struct fadump_mem_struct *fdm)
1229 return 0; 1344 return 0;
1230} 1345}
1231 1346
1232static int fadump_invalidate_dump(struct fadump_mem_struct *fdm) 1347static int fadump_invalidate_dump(const struct fadump_mem_struct *fdm)
1233{ 1348{
1234 int rc = 0; 1349 int rc = 0;
1235 unsigned int wait_time; 1350 unsigned int wait_time;
@@ -1260,9 +1375,8 @@ void fadump_cleanup(void)
1260{ 1375{
1261 /* Invalidate the registration only if dump is active. */ 1376 /* Invalidate the registration only if dump is active. */
1262 if (fw_dump.dump_active) { 1377 if (fw_dump.dump_active) {
1263 init_fadump_mem_struct(&fdm, 1378 /* pass the same memory dump structure provided by platform */
1264 be64_to_cpu(fdm_active->cpu_state_data.destination_address)); 1379 fadump_invalidate_dump(fdm_active);
1265 fadump_invalidate_dump(&fdm);
1266 } else if (fw_dump.dump_registered) { 1380 } else if (fw_dump.dump_registered) {
1267 /* Un-register Firmware-assisted dump if it was registered. */ 1381 /* Un-register Firmware-assisted dump if it was registered. */
1268 fadump_unregister_dump(&fdm); 1382 fadump_unregister_dump(&fdm);
@@ -1531,17 +1645,7 @@ static struct kobj_attribute fadump_register_attr = __ATTR(fadump_registered,
1531 0644, fadump_register_show, 1645 0644, fadump_register_show,
1532 fadump_register_store); 1646 fadump_register_store);
1533 1647
1534static int fadump_region_open(struct inode *inode, struct file *file) 1648DEFINE_SHOW_ATTRIBUTE(fadump_region);
1535{
1536 return single_open(file, fadump_region_show, inode->i_private);
1537}
1538
1539static const struct file_operations fadump_region_fops = {
1540 .open = fadump_region_open,
1541 .read = seq_read,
1542 .llseek = seq_lseek,
1543 .release = single_release,
1544};
1545 1649
1546static void fadump_init_files(void) 1650static void fadump_init_files(void)
1547{ 1651{
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index 61ca27929355..05b08db3901d 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -176,10 +176,10 @@ __after_mmu_off:
176 bl reloc_offset 176 bl reloc_offset
177 li r24,0 /* cpu# */ 177 li r24,0 /* cpu# */
178 bl call_setup_cpu /* Call setup_cpu for this CPU */ 178 bl call_setup_cpu /* Call setup_cpu for this CPU */
179#ifdef CONFIG_6xx 179#ifdef CONFIG_PPC_BOOK3S_32
180 bl reloc_offset 180 bl reloc_offset
181 bl init_idle_6xx 181 bl init_idle_6xx
182#endif /* CONFIG_6xx */ 182#endif /* CONFIG_PPC_BOOK3S_32 */
183 183
184 184
185/* 185/*
@@ -393,7 +393,9 @@ DataAccess:
393 bne 1f /* if not, try to put a PTE */ 393 bne 1f /* if not, try to put a PTE */
394 mfspr r4,SPRN_DAR /* into the hash table */ 394 mfspr r4,SPRN_DAR /* into the hash table */
395 rlwinm r3,r10,32-15,21,21 /* DSISR_STORE -> _PAGE_RW */ 395 rlwinm r3,r10,32-15,21,21 /* DSISR_STORE -> _PAGE_RW */
396BEGIN_MMU_FTR_SECTION
396 bl hash_page 397 bl hash_page
398END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE)
3971: lwz r5,_DSISR(r11) /* get DSISR value */ 3991: lwz r5,_DSISR(r11) /* get DSISR value */
398 mfspr r4,SPRN_DAR 400 mfspr r4,SPRN_DAR
399 EXC_XFER_LITE(0x300, handle_page_fault) 401 EXC_XFER_LITE(0x300, handle_page_fault)
@@ -408,7 +410,9 @@ InstructionAccess:
408 beq 1f /* if so, try to put a PTE */ 410 beq 1f /* if so, try to put a PTE */
409 li r3,0 /* into the hash table */ 411 li r3,0 /* into the hash table */
410 mr r4,r12 /* SRR0 is fault address */ 412 mr r4,r12 /* SRR0 is fault address */
413BEGIN_MMU_FTR_SECTION
411 bl hash_page 414 bl hash_page
415END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE)
4121: mr r4,r12 4161: mr r4,r12
413 andis. r5,r9,DSISR_SRR1_MATCH_32S@h /* Filter relevant SRR1 bits */ 417 andis. r5,r9,DSISR_SRR1_MATCH_32S@h /* Filter relevant SRR1 bits */
414 EXC_XFER_LITE(0x400, handle_page_fault) 418 EXC_XFER_LITE(0x400, handle_page_fault)
@@ -499,7 +503,7 @@ InstructionTLBMiss:
499 lis r1,PAGE_OFFSET@h /* check if kernel address */ 503 lis r1,PAGE_OFFSET@h /* check if kernel address */
500 cmplw 0,r1,r3 504 cmplw 0,r1,r3
501 mfspr r2,SPRN_SPRG_THREAD 505 mfspr r2,SPRN_SPRG_THREAD
502 li r1,_PAGE_USER|_PAGE_PRESENT /* low addresses tested as user */ 506 li r1,_PAGE_USER|_PAGE_PRESENT|_PAGE_EXEC /* low addresses tested as user */
503 lwz r2,PGDIR(r2) 507 lwz r2,PGDIR(r2)
504 bge- 112f 508 bge- 112f
505 mfspr r2,SPRN_SRR1 /* and MSR_PR bit from SRR1 */ 509 mfspr r2,SPRN_SRR1 /* and MSR_PR bit from SRR1 */
@@ -836,10 +840,10 @@ __secondary_start:
836 lis r3,-KERNELBASE@h 840 lis r3,-KERNELBASE@h
837 mr r4,r24 841 mr r4,r24
838 bl call_setup_cpu /* Call setup_cpu for this CPU */ 842 bl call_setup_cpu /* Call setup_cpu for this CPU */
839#ifdef CONFIG_6xx 843#ifdef CONFIG_PPC_BOOK3S_32
840 lis r3,-KERNELBASE@h 844 lis r3,-KERNELBASE@h
841 bl init_idle_6xx 845 bl init_idle_6xx
842#endif /* CONFIG_6xx */ 846#endif /* CONFIG_PPC_BOOK3S_32 */
843 847
844 /* get current_thread_info and current */ 848 /* get current_thread_info and current */
845 lis r1,secondary_ti@ha 849 lis r1,secondary_ti@ha
@@ -880,14 +884,14 @@ __secondary_start:
880 884
881/* 885/*
882 * Those generic dummy functions are kept for CPUs not 886 * Those generic dummy functions are kept for CPUs not
883 * included in CONFIG_6xx 887 * included in CONFIG_PPC_BOOK3S_32
884 */ 888 */
885#if !defined(CONFIG_6xx) 889#if !defined(CONFIG_PPC_BOOK3S_32)
886_ENTRY(__save_cpu_setup) 890_ENTRY(__save_cpu_setup)
887 blr 891 blr
888_ENTRY(__restore_cpu_setup) 892_ENTRY(__restore_cpu_setup)
889 blr 893 blr
890#endif /* !defined(CONFIG_6xx) */ 894#endif /* !defined(CONFIG_PPC_BOOK3S_32) */
891 895
892 896
893/* 897/*
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 37e4a7cf0065..bf23c19c92d6 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -40,6 +40,7 @@
40#include <asm/ptrace.h> 40#include <asm/ptrace.h>
41#include <asm/synch.h> 41#include <asm/synch.h>
42#include <asm/export.h> 42#include <asm/export.h>
43#include <asm/code-patching-asm.h>
43#include "head_booke.h" 44#include "head_booke.h"
44 45
45 46
@@ -382,10 +383,9 @@ interrupt_base:
382 /* Increment, rollover, and store TLB index */ 383 /* Increment, rollover, and store TLB index */
383 addi r13,r13,1 384 addi r13,r13,1
384 385
386 patch_site 0f, patch__tlb_44x_hwater_D
385 /* Compare with watermark (instruction gets patched) */ 387 /* Compare with watermark (instruction gets patched) */
386 .globl tlb_44x_patch_hwater_D 3880: cmpwi 0,r13,1 /* reserve entries */
387tlb_44x_patch_hwater_D:
388 cmpwi 0,r13,1 /* reserve entries */
389 ble 5f 389 ble 5f
390 li r13,0 390 li r13,0
3915: 3915:
@@ -478,10 +478,9 @@ tlb_44x_patch_hwater_D:
478 /* Increment, rollover, and store TLB index */ 478 /* Increment, rollover, and store TLB index */
479 addi r13,r13,1 479 addi r13,r13,1
480 480
481 patch_site 0f, patch__tlb_44x_hwater_I
481 /* Compare with watermark (instruction gets patched) */ 482 /* Compare with watermark (instruction gets patched) */
482 .globl tlb_44x_patch_hwater_I 4830: cmpwi 0,r13,1 /* reserve entries */
483tlb_44x_patch_hwater_I:
484 cmpwi 0,r13,1 /* reserve entries */
485 ble 5f 484 ble 5f
486 li r13,0 485 li r13,0
4875: 4865:
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 3b67b9533c82..57deb1e9ffea 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -106,6 +106,23 @@ turn_on_mmu:
106 mtspr SPRN_SRR0,r0 106 mtspr SPRN_SRR0,r0
107 rfi /* enables MMU */ 107 rfi /* enables MMU */
108 108
109
110#ifdef CONFIG_PERF_EVENTS
111 .align 4
112
113 .globl itlb_miss_counter
114itlb_miss_counter:
115 .space 4
116
117 .globl dtlb_miss_counter
118dtlb_miss_counter:
119 .space 4
120
121 .globl instruction_counter
122instruction_counter:
123 .space 4
124#endif
125
109/* 126/*
110 * Exception entry code. This code runs with address translation 127 * Exception entry code. This code runs with address translation
111 * turned off, i.e. using physical addresses. 128 * turned off, i.e. using physical addresses.
@@ -149,6 +166,9 @@ turn_on_mmu:
149 li r10,MSR_KERNEL & ~(MSR_IR|MSR_DR); /* can take exceptions */ \ 166 li r10,MSR_KERNEL & ~(MSR_IR|MSR_DR); /* can take exceptions */ \
150 mtmsr r10; \ 167 mtmsr r10; \
151 stw r0,GPR0(r11); \ 168 stw r0,GPR0(r11); \
169 lis r10, STACK_FRAME_REGS_MARKER@ha; /* exception frame marker */ \
170 addi r10, r10, STACK_FRAME_REGS_MARKER@l; \
171 stw r10, 8(r11); \
152 SAVE_4GPRS(3, r11); \ 172 SAVE_4GPRS(3, r11); \
153 SAVE_2GPRS(7, r11) 173 SAVE_2GPRS(7, r11)
154 174
@@ -275,7 +295,7 @@ SystemCall:
275 . = 0x1100 295 . = 0x1100
276/* 296/*
277 * For the MPC8xx, this is a software tablewalk to load the instruction 297 * For the MPC8xx, this is a software tablewalk to load the instruction
278 * TLB. The task switch loads the M_TW register with the pointer to the first 298 * TLB. The task switch loads the M_TWB register with the pointer to the first
279 * level table. 299 * level table.
280 * If we discover there is no second level table (value is zero) or if there 300 * If we discover there is no second level table (value is zero) or if there
281 * is an invalid pte, we load that into the TLB, which causes another fault 301 * is an invalid pte, we load that into the TLB, which causes another fault
@@ -285,186 +305,154 @@ SystemCall:
285 */ 305 */
286 306
287#ifdef CONFIG_8xx_CPU15 307#ifdef CONFIG_8xx_CPU15
288#define INVALIDATE_ADJACENT_PAGES_CPU15(tmp, addr) \ 308#define INVALIDATE_ADJACENT_PAGES_CPU15(addr) \
289 addi tmp, addr, PAGE_SIZE; \ 309 addi addr, addr, PAGE_SIZE; \
290 tlbie tmp; \ 310 tlbie addr; \
291 addi tmp, addr, -PAGE_SIZE; \ 311 addi addr, addr, -(PAGE_SIZE << 1); \
292 tlbie tmp 312 tlbie addr; \
313 addi addr, addr, PAGE_SIZE
293#else 314#else
294#define INVALIDATE_ADJACENT_PAGES_CPU15(tmp, addr) 315#define INVALIDATE_ADJACENT_PAGES_CPU15(addr)
295#endif 316#endif
296 317
297InstructionTLBMiss: 318InstructionTLBMiss:
298 mtspr SPRN_SPRG_SCRATCH0, r10 319 mtspr SPRN_SPRG_SCRATCH0, r10
320#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP)
299 mtspr SPRN_SPRG_SCRATCH1, r11 321 mtspr SPRN_SPRG_SCRATCH1, r11
300#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_HUGETLB_PAGE)
301 mtspr SPRN_SPRG_SCRATCH2, r12
302#endif 322#endif
303 323
304 /* If we are faulting a kernel address, we have to use the 324 /* If we are faulting a kernel address, we have to use the
305 * kernel page tables. 325 * kernel page tables.
306 */ 326 */
307 mfspr r10, SPRN_SRR0 /* Get effective address of fault */ 327 mfspr r10, SPRN_SRR0 /* Get effective address of fault */
308 INVALIDATE_ADJACENT_PAGES_CPU15(r11, r10) 328 INVALIDATE_ADJACENT_PAGES_CPU15(r10)
329 mtspr SPRN_MD_EPN, r10
309 /* Only modules will cause ITLB Misses as we always 330 /* Only modules will cause ITLB Misses as we always
310 * pin the first 8MB of kernel memory */ 331 * pin the first 8MB of kernel memory */
311#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_HUGETLB_PAGE)
312 mfcr r12
313#endif
314#ifdef ITLB_MISS_KERNEL 332#ifdef ITLB_MISS_KERNEL
333 mfcr r11
315#if defined(SIMPLE_KERNEL_ADDRESS) && defined(CONFIG_PIN_TLB_TEXT) 334#if defined(SIMPLE_KERNEL_ADDRESS) && defined(CONFIG_PIN_TLB_TEXT)
316 andis. r11, r10, 0x8000 /* Address >= 0x80000000 */ 335 cmpi cr0, r10, 0 /* Address >= 0x80000000 */
317#else 336#else
318 rlwinm r11, r10, 16, 0xfff8 337 rlwinm r10, r10, 16, 0xfff8
319 cmpli cr0, r11, PAGE_OFFSET@h 338 cmpli cr0, r10, PAGE_OFFSET@h
320#ifndef CONFIG_PIN_TLB_TEXT 339#ifndef CONFIG_PIN_TLB_TEXT
321 /* It is assumed that kernel code fits into the first 8M page */ 340 /* It is assumed that kernel code fits into the first 8M page */
3220: cmpli cr7, r11, (PAGE_OFFSET + 0x0800000)@h 3410: cmpli cr7, r10, (PAGE_OFFSET + 0x0800000)@h
323 patch_site 0b, patch__itlbmiss_linmem_top 342 patch_site 0b, patch__itlbmiss_linmem_top
324#endif 343#endif
325#endif 344#endif
326#endif 345#endif
327 mfspr r11, SPRN_M_TW /* Get level 1 table */ 346 mfspr r10, SPRN_M_TWB /* Get level 1 table */
328#ifdef ITLB_MISS_KERNEL 347#ifdef ITLB_MISS_KERNEL
329#if defined(SIMPLE_KERNEL_ADDRESS) && defined(CONFIG_PIN_TLB_TEXT) 348#if defined(SIMPLE_KERNEL_ADDRESS) && defined(CONFIG_PIN_TLB_TEXT)
330 beq+ 3f 349 bge+ 3f
331#else 350#else
332 blt+ 3f 351 blt+ 3f
333#endif 352#endif
334#ifndef CONFIG_PIN_TLB_TEXT 353#ifndef CONFIG_PIN_TLB_TEXT
335 blt cr7, ITLBMissLinear 354 blt cr7, ITLBMissLinear
336#endif 355#endif
337 lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha 356 rlwinm r10, r10, 0, 20, 31
357 oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha
3383: 3583:
339#endif 359#endif
340 /* Insert level 1 index */ 360 lwz r10, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */
341 rlwimi r11, r10, 32 - ((PAGE_SHIFT - 2) << 1), (PAGE_SHIFT - 2) << 1, 29 361 mtspr SPRN_MI_TWC, r10 /* Set segment attributes */
342 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r11) /* Get the level 1 entry */
343 362
344 /* Extract level 2 index */ 363 mtspr SPRN_MD_TWC, r10
345 rlwinm r10, r10, 32 - (PAGE_SHIFT - 2), 32 - PAGE_SHIFT, 29 364 mfspr r10, SPRN_MD_TWC
346#ifdef CONFIG_HUGETLB_PAGE
347 mtcr r11
348 bt- 28, 10f /* bit 28 = Large page (8M) */
349 bt- 29, 20f /* bit 29 = Large page (8M or 512k) */
350#endif
351 rlwimi r10, r11, 0, 0, 32 - PAGE_SHIFT - 1 /* Add level 2 base */
352 lwz r10, 0(r10) /* Get the pte */ 365 lwz r10, 0(r10) /* Get the pte */
3534: 366#ifdef ITLB_MISS_KERNEL
354#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_HUGETLB_PAGE) 367 mtcr r11
355 mtcr r12
356#endif 368#endif
357 /* Load the MI_TWC with the attributes for this "segment." */
358 mtspr SPRN_MI_TWC, r11 /* Set segment attributes */
359
360#ifdef CONFIG_SWAP 369#ifdef CONFIG_SWAP
361 rlwinm r11, r10, 32-5, _PAGE_PRESENT 370 rlwinm r11, r10, 32-5, _PAGE_PRESENT
362 and r11, r11, r10 371 and r11, r11, r10
363 rlwimi r10, r11, 0, _PAGE_PRESENT 372 rlwimi r10, r11, 0, _PAGE_PRESENT
364#endif 373#endif
365 li r11, RPN_PATTERN | 0x200
366 /* The Linux PTE won't go exactly into the MMU TLB. 374 /* The Linux PTE won't go exactly into the MMU TLB.
367 * Software indicator bits 20 and 23 must be clear. 375 * Software indicator bits 20 and 23 must be clear.
368 * Software indicator bits 22, 24, 25, 26, and 27 must be 376 * Software indicator bits 22, 24, 25, 26, and 27 must be
369 * set. All other Linux PTE bits control the behavior 377 * set. All other Linux PTE bits control the behavior
370 * of the MMU. 378 * of the MMU.
371 */ 379 */
372 rlwimi r11, r10, 4, 0x0400 /* Copy _PAGE_EXEC into bit 21 */ 380 rlwimi r10, r10, 0, 0x0f00 /* Clear bits 20-23 */
373 rlwimi r10, r11, 0, 0x0ff0 /* Set 22, 24-27, clear 20,23 */ 381 rlwimi r10, r10, 4, 0x0400 /* Copy _PAGE_EXEC into bit 21 */
382 ori r10, r10, RPN_PATTERN | 0x200 /* Set 22 and 24-27 */
374 mtspr SPRN_MI_RPN, r10 /* Update TLB entry */ 383 mtspr SPRN_MI_RPN, r10 /* Update TLB entry */
375 384
376 /* Restore registers */ 385 /* Restore registers */
3770: mfspr r10, SPRN_SPRG_SCRATCH0 3860: mfspr r10, SPRN_SPRG_SCRATCH0
387#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP)
378 mfspr r11, SPRN_SPRG_SCRATCH1 388 mfspr r11, SPRN_SPRG_SCRATCH1
379#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_HUGETLB_PAGE)
380 mfspr r12, SPRN_SPRG_SCRATCH2
381#endif 389#endif
382 rfi 390 rfi
383 patch_site 0b, patch__itlbmiss_exit_1 391 patch_site 0b, patch__itlbmiss_exit_1
384 392
385#ifdef CONFIG_PERF_EVENTS 393#ifdef CONFIG_PERF_EVENTS
386 patch_site 0f, patch__itlbmiss_perf 394 patch_site 0f, patch__itlbmiss_perf
3870: lis r10, (itlb_miss_counter - PAGE_OFFSET)@ha 3950: lwz r10, (itlb_miss_counter - PAGE_OFFSET)@l(0)
388 lwz r11, (itlb_miss_counter - PAGE_OFFSET)@l(r10) 396 addi r10, r10, 1
389 addi r11, r11, 1 397 stw r10, (itlb_miss_counter - PAGE_OFFSET)@l(0)
390 stw r11, (itlb_miss_counter - PAGE_OFFSET)@l(r10)
391#endif
392 mfspr r10, SPRN_SPRG_SCRATCH0 398 mfspr r10, SPRN_SPRG_SCRATCH0
399#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP)
393 mfspr r11, SPRN_SPRG_SCRATCH1 400 mfspr r11, SPRN_SPRG_SCRATCH1
394#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_HUGETLB_PAGE)
395 mfspr r12, SPRN_SPRG_SCRATCH2
396#endif 401#endif
397 rfi 402 rfi
398
399#ifdef CONFIG_HUGETLB_PAGE
40010: /* 8M pages */
401#ifdef CONFIG_PPC_16K_PAGES
402 /* Extract level 2 index */
403 rlwinm r10, r10, 32 - (PAGE_SHIFT_8M - PAGE_SHIFT), 32 + PAGE_SHIFT_8M - (PAGE_SHIFT << 1), 29
404 /* Add level 2 base */
405 rlwimi r10, r11, 0, 0, 32 + PAGE_SHIFT_8M - (PAGE_SHIFT << 1) - 1
406#else
407 /* Level 2 base */
408 rlwinm r10, r11, 0, ~HUGEPD_SHIFT_MASK
409#endif 403#endif
410 lwz r10, 0(r10) /* Get the pte */
411 b 4b
412 404
41320: /* 512k pages */ 405#ifndef CONFIG_PIN_TLB_TEXT
414 /* Extract level 2 index */ 406ITLBMissLinear:
415 rlwinm r10, r10, 32 - (PAGE_SHIFT_512K - PAGE_SHIFT), 32 + PAGE_SHIFT_512K - (PAGE_SHIFT << 1), 29 407 mtcr r11
416 /* Add level 2 base */ 408 /* Set 8M byte page and mark it valid */
417 rlwimi r10, r11, 0, 0, 32 + PAGE_SHIFT_512K - (PAGE_SHIFT << 1) - 1 409 li r11, MI_PS8MEG | MI_SVALID
418 lwz r10, 0(r10) /* Get the pte */ 410 mtspr SPRN_MI_TWC, r11
419 b 4b 411 rlwinm r10, r10, 20, 0x0f800000 /* 8xx supports max 256Mb RAM */
412 ori r10, r10, 0xf0 | MI_SPS16K | _PAGE_SH | _PAGE_DIRTY | \
413 _PAGE_PRESENT
414 mtspr SPRN_MI_RPN, r10 /* Update TLB entry */
415
4160: mfspr r10, SPRN_SPRG_SCRATCH0
417 mfspr r11, SPRN_SPRG_SCRATCH1
418 rfi
419 patch_site 0b, patch__itlbmiss_exit_2
420#endif 420#endif
421 421
422 . = 0x1200 422 . = 0x1200
423DataStoreTLBMiss: 423DataStoreTLBMiss:
424 mtspr SPRN_SPRG_SCRATCH0, r10 424 mtspr SPRN_SPRG_SCRATCH0, r10
425 mtspr SPRN_SPRG_SCRATCH1, r11 425 mtspr SPRN_SPRG_SCRATCH1, r11
426 mtspr SPRN_SPRG_SCRATCH2, r12 426 mfcr r11
427 mfcr r12
428 427
429 /* If we are faulting a kernel address, we have to use the 428 /* If we are faulting a kernel address, we have to use the
430 * kernel page tables. 429 * kernel page tables.
431 */ 430 */
432 mfspr r10, SPRN_MD_EPN 431 mfspr r10, SPRN_MD_EPN
433 rlwinm r11, r10, 16, 0xfff8 432 rlwinm r10, r10, 16, 0xfff8
434 cmpli cr0, r11, PAGE_OFFSET@h 433 cmpli cr0, r10, PAGE_OFFSET@h
435 mfspr r11, SPRN_M_TW /* Get level 1 table */
436 blt+ 3f
437 rlwinm r11, r10, 16, 0xfff8
438#ifndef CONFIG_PIN_TLB_IMMR 434#ifndef CONFIG_PIN_TLB_IMMR
439 cmpli cr0, r11, VIRT_IMMR_BASE@h 435 cmpli cr6, r10, VIRT_IMMR_BASE@h
440#endif 436#endif
4410: cmpli cr7, r11, (PAGE_OFFSET + 0x1800000)@h 4370: cmpli cr7, r10, (PAGE_OFFSET + 0x1800000)@h
442 patch_site 0b, patch__dtlbmiss_linmem_top 438 patch_site 0b, patch__dtlbmiss_linmem_top
439
440 mfspr r10, SPRN_M_TWB /* Get level 1 table */
441 blt+ 3f
443#ifndef CONFIG_PIN_TLB_IMMR 442#ifndef CONFIG_PIN_TLB_IMMR
4440: beq- DTLBMissIMMR 4430: beq- cr6, DTLBMissIMMR
445 patch_site 0b, patch__dtlbmiss_immr_jmp 444 patch_site 0b, patch__dtlbmiss_immr_jmp
446#endif 445#endif
447 blt cr7, DTLBMissLinear 446 blt cr7, DTLBMissLinear
448 lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha 447 rlwinm r10, r10, 0, 20, 31
448 oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha
4493: 4493:
450
451 /* Insert level 1 index */
452 rlwimi r11, r10, 32 - ((PAGE_SHIFT - 2) << 1), (PAGE_SHIFT - 2) << 1, 29
453 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r11) /* Get the level 1 entry */
454
455 /* We have a pte table, so load fetch the pte from the table.
456 */
457 /* Extract level 2 index */
458 rlwinm r10, r10, 32 - (PAGE_SHIFT - 2), 32 - PAGE_SHIFT, 29
459#ifdef CONFIG_HUGETLB_PAGE
460 mtcr r11 450 mtcr r11
461 bt- 28, 10f /* bit 28 = Large page (8M) */ 451 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */
462 bt- 29, 20f /* bit 29 = Large page (8M or 512k) */ 452
463#endif 453 mtspr SPRN_MD_TWC, r11
464 rlwimi r10, r11, 0, 0, 32 - PAGE_SHIFT - 1 /* Add level 2 base */ 454 mfspr r10, SPRN_MD_TWC
465 lwz r10, 0(r10) /* Get the pte */ 455 lwz r10, 0(r10) /* Get the pte */
4664:
467 mtcr r12
468 456
469 /* Insert the Guarded flag into the TWC from the Linux PTE. 457 /* Insert the Guarded flag into the TWC from the Linux PTE.
470 * It is bit 27 of both the Linux PTE and the TWC (at least 458 * It is bit 27 of both the Linux PTE and the TWC (at least
@@ -503,44 +491,55 @@ DataStoreTLBMiss:
503 491
5040: mfspr r10, SPRN_SPRG_SCRATCH0 4920: mfspr r10, SPRN_SPRG_SCRATCH0
505 mfspr r11, SPRN_SPRG_SCRATCH1 493 mfspr r11, SPRN_SPRG_SCRATCH1
506 mfspr r12, SPRN_SPRG_SCRATCH2
507 rfi 494 rfi
508 patch_site 0b, patch__dtlbmiss_exit_1 495 patch_site 0b, patch__dtlbmiss_exit_1
509 496
510#ifdef CONFIG_PERF_EVENTS 497#ifdef CONFIG_PERF_EVENTS
511 patch_site 0f, patch__dtlbmiss_perf 498 patch_site 0f, patch__dtlbmiss_perf
5120: lis r10, (dtlb_miss_counter - PAGE_OFFSET)@ha 4990: lwz r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0)
513 lwz r11, (dtlb_miss_counter - PAGE_OFFSET)@l(r10) 500 addi r10, r10, 1
514 addi r11, r11, 1 501 stw r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0)
515 stw r11, (dtlb_miss_counter - PAGE_OFFSET)@l(r10)
516#endif
517 mfspr r10, SPRN_SPRG_SCRATCH0 502 mfspr r10, SPRN_SPRG_SCRATCH0
518 mfspr r11, SPRN_SPRG_SCRATCH1 503 mfspr r11, SPRN_SPRG_SCRATCH1
519 mfspr r12, SPRN_SPRG_SCRATCH2
520 rfi 504 rfi
521
522#ifdef CONFIG_HUGETLB_PAGE
52310: /* 8M pages */
524 /* Extract level 2 index */
525#ifdef CONFIG_PPC_16K_PAGES
526 rlwinm r10, r10, 32 - (PAGE_SHIFT_8M - PAGE_SHIFT), 32 + PAGE_SHIFT_8M - (PAGE_SHIFT << 1), 29
527 /* Add level 2 base */
528 rlwimi r10, r11, 0, 0, 32 + PAGE_SHIFT_8M - (PAGE_SHIFT << 1) - 1
529#else
530 /* Level 2 base */
531 rlwinm r10, r11, 0, ~HUGEPD_SHIFT_MASK
532#endif 505#endif
533 lwz r10, 0(r10) /* Get the pte */
534 b 4b
535 506
53620: /* 512k pages */ 507DTLBMissIMMR:
537 /* Extract level 2 index */ 508 mtcr r11
538 rlwinm r10, r10, 32 - (PAGE_SHIFT_512K - PAGE_SHIFT), 32 + PAGE_SHIFT_512K - (PAGE_SHIFT << 1), 29 509 /* Set 512k byte guarded page and mark it valid */
539 /* Add level 2 base */ 510 li r10, MD_PS512K | MD_GUARDED | MD_SVALID
540 rlwimi r10, r11, 0, 0, 32 + PAGE_SHIFT_512K - (PAGE_SHIFT << 1) - 1 511 mtspr SPRN_MD_TWC, r10
541 lwz r10, 0(r10) /* Get the pte */ 512 mfspr r10, SPRN_IMMR /* Get current IMMR */
542 b 4b 513 rlwinm r10, r10, 0, 0xfff80000 /* Get 512 kbytes boundary */
543#endif 514 ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SH | _PAGE_DIRTY | \
515 _PAGE_PRESENT | _PAGE_NO_CACHE
516 mtspr SPRN_MD_RPN, r10 /* Update TLB entry */
517
518 li r11, RPN_PATTERN
519 mtspr SPRN_DAR, r11 /* Tag DAR */
520
5210: mfspr r10, SPRN_SPRG_SCRATCH0
522 mfspr r11, SPRN_SPRG_SCRATCH1
523 rfi
524 patch_site 0b, patch__dtlbmiss_exit_2
525
526DTLBMissLinear:
527 mtcr r11
528 /* Set 8M byte page and mark it valid */
529 li r11, MD_PS8MEG | MD_SVALID
530 mtspr SPRN_MD_TWC, r11
531 rlwinm r10, r10, 20, 0x0f800000 /* 8xx supports max 256Mb RAM */
532 ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SH | _PAGE_DIRTY | \
533 _PAGE_PRESENT
534 mtspr SPRN_MD_RPN, r10 /* Update TLB entry */
535
536 li r11, RPN_PATTERN
537 mtspr SPRN_DAR, r11 /* Tag DAR */
538
5390: mfspr r10, SPRN_SPRG_SCRATCH0
540 mfspr r11, SPRN_SPRG_SCRATCH1
541 rfi
542 patch_site 0b, patch__dtlbmiss_exit_3
544 543
545/* This is an instruction TLB error on the MPC8xx. This could be due 544/* This is an instruction TLB error on the MPC8xx. This could be due
546 * to many reasons, such as executing guarded memory or illegal instruction 545 * to many reasons, such as executing guarded memory or illegal instruction
@@ -625,16 +624,13 @@ DataBreakpoint:
625 . = 0x1d00 624 . = 0x1d00
626InstructionBreakpoint: 625InstructionBreakpoint:
627 mtspr SPRN_SPRG_SCRATCH0, r10 626 mtspr SPRN_SPRG_SCRATCH0, r10
628 mtspr SPRN_SPRG_SCRATCH1, r11 627 lwz r10, (instruction_counter - PAGE_OFFSET)@l(0)
629 lis r10, (instruction_counter - PAGE_OFFSET)@ha 628 addi r10, r10, -1
630 lwz r11, (instruction_counter - PAGE_OFFSET)@l(r10) 629 stw r10, (instruction_counter - PAGE_OFFSET)@l(0)
631 addi r11, r11, -1
632 stw r11, (instruction_counter - PAGE_OFFSET)@l(r10)
633 lis r10, 0xffff 630 lis r10, 0xffff
634 ori r10, r10, 0x01 631 ori r10, r10, 0x01
635 mtspr SPRN_COUNTA, r10 632 mtspr SPRN_COUNTA, r10
636 mfspr r10, SPRN_SPRG_SCRATCH0 633 mfspr r10, SPRN_SPRG_SCRATCH0
637 mfspr r11, SPRN_SPRG_SCRATCH1
638 rfi 634 rfi
639#else 635#else
640 EXCEPTION(0x1d00, Trap_1d, unknown_exception, EXC_XFER_EE) 636 EXCEPTION(0x1d00, Trap_1d, unknown_exception, EXC_XFER_EE)
@@ -644,67 +640,6 @@ InstructionBreakpoint:
644 640
645 . = 0x2000 641 . = 0x2000
646 642
647/*
648 * Bottom part of DataStoreTLBMiss handlers for IMMR area and linear RAM.
649 * not enough space in the DataStoreTLBMiss area.
650 */
651DTLBMissIMMR:
652 mtcr r12
653 /* Set 512k byte guarded page and mark it valid */
654 li r10, MD_PS512K | MD_GUARDED | MD_SVALID
655 mtspr SPRN_MD_TWC, r10
656 mfspr r10, SPRN_IMMR /* Get current IMMR */
657 rlwinm r10, r10, 0, 0xfff80000 /* Get 512 kbytes boundary */
658 ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SH | _PAGE_DIRTY | \
659 _PAGE_PRESENT | _PAGE_NO_CACHE
660 mtspr SPRN_MD_RPN, r10 /* Update TLB entry */
661
662 li r11, RPN_PATTERN
663 mtspr SPRN_DAR, r11 /* Tag DAR */
664
6650: mfspr r10, SPRN_SPRG_SCRATCH0
666 mfspr r11, SPRN_SPRG_SCRATCH1
667 mfspr r12, SPRN_SPRG_SCRATCH2
668 rfi
669 patch_site 0b, patch__dtlbmiss_exit_2
670
671DTLBMissLinear:
672 mtcr r12
673 /* Set 8M byte page and mark it valid */
674 li r11, MD_PS8MEG | MD_SVALID
675 mtspr SPRN_MD_TWC, r11
676 rlwinm r10, r10, 0, 0x0f800000 /* 8xx supports max 256Mb RAM */
677 ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SH | _PAGE_DIRTY | \
678 _PAGE_PRESENT
679 mtspr SPRN_MD_RPN, r10 /* Update TLB entry */
680
681 li r11, RPN_PATTERN
682 mtspr SPRN_DAR, r11 /* Tag DAR */
683
6840: mfspr r10, SPRN_SPRG_SCRATCH0
685 mfspr r11, SPRN_SPRG_SCRATCH1
686 mfspr r12, SPRN_SPRG_SCRATCH2
687 rfi
688 patch_site 0b, patch__dtlbmiss_exit_3
689
690#ifndef CONFIG_PIN_TLB_TEXT
691ITLBMissLinear:
692 mtcr r12
693 /* Set 8M byte page and mark it valid */
694 li r11, MI_PS8MEG | MI_SVALID
695 mtspr SPRN_MI_TWC, r11
696 rlwinm r10, r10, 0, 0x0f800000 /* 8xx supports max 256Mb RAM */
697 ori r10, r10, 0xf0 | MI_SPS16K | _PAGE_SH | _PAGE_DIRTY | \
698 _PAGE_PRESENT
699 mtspr SPRN_MI_RPN, r10 /* Update TLB entry */
700
7010: mfspr r10, SPRN_SPRG_SCRATCH0
702 mfspr r11, SPRN_SPRG_SCRATCH1
703 mfspr r12, SPRN_SPRG_SCRATCH2
704 rfi
705 patch_site 0b, patch__itlbmiss_exit_2
706#endif
707
708/* This is the procedure to calculate the data EA for buggy dcbx,dcbi instructions 643/* This is the procedure to calculate the data EA for buggy dcbx,dcbi instructions
709 * by decoding the registers used by the dcbx instruction and adding them. 644 * by decoding the registers used by the dcbx instruction and adding them.
710 * DAR is set to the calculated address. 645 * DAR is set to the calculated address.
@@ -712,12 +647,13 @@ ITLBMissLinear:
712 /* define if you don't want to use self modifying code */ 647 /* define if you don't want to use self modifying code */
713#define NO_SELF_MODIFYING_CODE 648#define NO_SELF_MODIFYING_CODE
714FixupDAR:/* Entry point for dcbx workaround. */ 649FixupDAR:/* Entry point for dcbx workaround. */
715 mtspr SPRN_SPRG_SCRATCH2, r10 650 mtspr SPRN_M_TW, r10
716 /* fetch instruction from memory. */ 651 /* fetch instruction from memory. */
717 mfspr r10, SPRN_SRR0 652 mfspr r10, SPRN_SRR0
653 mtspr SPRN_MD_EPN, r10
718 rlwinm r11, r10, 16, 0xfff8 654 rlwinm r11, r10, 16, 0xfff8
719 cmpli cr0, r11, PAGE_OFFSET@h 655 cmpli cr0, r11, PAGE_OFFSET@h
720 mfspr r11, SPRN_M_TW /* Get level 1 table */ 656 mfspr r11, SPRN_M_TWB /* Get level 1 table */
721 blt+ 3f 657 blt+ 3f
722 rlwinm r11, r10, 16, 0xfff8 658 rlwinm r11, r10, 16, 0xfff8
723 659
@@ -727,17 +663,17 @@ FixupDAR:/* Entry point for dcbx workaround. */
727 /* create physical page address from effective address */ 663 /* create physical page address from effective address */
728 tophys(r11, r10) 664 tophys(r11, r10)
729 blt- cr7, 201f 665 blt- cr7, 201f
730 lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha 666 mfspr r11, SPRN_M_TWB /* Get level 1 table */
731 /* Insert level 1 index */ 667 rlwinm r11, r11, 0, 20, 31
7323: rlwimi r11, r10, 32 - ((PAGE_SHIFT - 2) << 1), (PAGE_SHIFT - 2) << 1, 29 668 oris r11, r11, (swapper_pg_dir - PAGE_OFFSET)@ha
6693:
733 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r11) /* Get the level 1 entry */ 670 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r11) /* Get the level 1 entry */
671 mtspr SPRN_MD_TWC, r11
734 mtcr r11 672 mtcr r11
673 mfspr r11, SPRN_MD_TWC
674 lwz r11, 0(r11) /* Get the pte */
735 bt 28,200f /* bit 28 = Large page (8M) */ 675 bt 28,200f /* bit 28 = Large page (8M) */
736 bt 29,202f /* bit 29 = Large page (8M or 512K) */ 676 bt 29,202f /* bit 29 = Large page (8M or 512K) */
737 rlwinm r11, r11,0,0,19 /* Extract page descriptor page address */
738 /* Insert level 2 index */
739 rlwimi r11, r10, 32 - (PAGE_SHIFT - 2), 32 - PAGE_SHIFT, 29
740 lwz r11, 0(r11) /* Get the pte */
741 /* concat physical page address(r11) and page offset(r10) */ 677 /* concat physical page address(r11) and page offset(r10) */
742 rlwimi r11, r10, 0, 32 - PAGE_SHIFT, 31 678 rlwimi r11, r10, 0, 32 - PAGE_SHIFT, 31
743201: lwz r11,0(r11) 679201: lwz r11,0(r11)
@@ -756,26 +692,15 @@ FixupDAR:/* Entry point for dcbx workaround. */
756 beq+ 142f 692 beq+ 142f
757 cmpwi cr0, r10, 1964 /* Is icbi? */ 693 cmpwi cr0, r10, 1964 /* Is icbi? */
758 beq+ 142f 694 beq+ 142f
759141: mfspr r10,SPRN_SPRG_SCRATCH2 695141: mfspr r10,SPRN_M_TW
760 b DARFixed /* Nope, go back to normal TLB processing */ 696 b DARFixed /* Nope, go back to normal TLB processing */
761 697
762 /* concat physical page address(r11) and page offset(r10) */
763200: 698200:
764#ifdef CONFIG_PPC_16K_PAGES
765 rlwinm r11, r11, 0, 0, 32 + PAGE_SHIFT_8M - (PAGE_SHIFT << 1) - 1
766 rlwimi r11, r10, 32 - (PAGE_SHIFT_8M - 2), 32 + PAGE_SHIFT_8M - (PAGE_SHIFT << 1), 29
767#else
768 rlwinm r11, r10, 0, ~HUGEPD_SHIFT_MASK
769#endif
770 lwz r11, 0(r11) /* Get the pte */
771 /* concat physical page address(r11) and page offset(r10) */ 699 /* concat physical page address(r11) and page offset(r10) */
772 rlwimi r11, r10, 0, 32 - PAGE_SHIFT_8M, 31 700 rlwimi r11, r10, 0, 32 - PAGE_SHIFT_8M, 31
773 b 201b 701 b 201b
774 702
775202: 703202:
776 rlwinm r11, r11, 0, 0, 32 + PAGE_SHIFT_512K - (PAGE_SHIFT << 1) - 1
777 rlwimi r11, r10, 32 - (PAGE_SHIFT_512K - 2), 32 + PAGE_SHIFT_512K - (PAGE_SHIFT << 1), 29
778 lwz r11, 0(r11) /* Get the pte */
779 /* concat physical page address(r11) and page offset(r10) */ 704 /* concat physical page address(r11) and page offset(r10) */
780 rlwimi r11, r10, 0, 32 - PAGE_SHIFT_512K, 31 705 rlwimi r11, r10, 0, 32 - PAGE_SHIFT_512K, 31
781 b 201b 706 b 201b
@@ -802,7 +727,7 @@ modified_instr:
802 bne+ 143f 727 bne+ 143f
803 subf r10,r0,r10 /* r10=r10-r0, only if reg RA is r0 */ 728 subf r10,r0,r10 /* r10=r10-r0, only if reg RA is r0 */
804143: mtdar r10 /* store faulting EA in DAR */ 729143: mtdar r10 /* store faulting EA in DAR */
805 mfspr r10,SPRN_SPRG_SCRATCH2 730 mfspr r10,SPRN_M_TW
806 b DARFixed /* Go back to normal TLB handling */ 731 b DARFixed /* Go back to normal TLB handling */
807#else 732#else
808 mfctr r10 733 mfctr r10
@@ -856,7 +781,7 @@ modified_instr:
856 mfdar r11 781 mfdar r11
857 mtctr r11 /* restore ctr reg from DAR */ 782 mtctr r11 /* restore ctr reg from DAR */
858 mtdar r10 /* save fault EA to DAR */ 783 mtdar r10 /* save fault EA to DAR */
859 mfspr r10,SPRN_SPRG_SCRATCH2 784 mfspr r10,SPRN_M_TW
860 b DARFixed /* Go back to normal TLB handling */ 785 b DARFixed /* Go back to normal TLB handling */
861 786
862 /* special handling for r10,r11 since these are modified already */ 787 /* special handling for r10,r11 since these are modified already */
@@ -891,7 +816,7 @@ start_here:
891 816
892 lis r6, swapper_pg_dir@ha 817 lis r6, swapper_pg_dir@ha
893 tophys(r6,r6) 818 tophys(r6,r6)
894 mtspr SPRN_M_TW, r6 819 mtspr SPRN_M_TWB, r6
895 820
896 bl early_init /* We have to do this with MMU on */ 821 bl early_init /* We have to do this with MMU on */
897 822
@@ -1065,17 +990,3 @@ swapper_pg_dir:
1065 */ 990 */
1066abatron_pteptrs: 991abatron_pteptrs:
1067 .space 8 992 .space 8
1068
1069#ifdef CONFIG_PERF_EVENTS
1070 .globl itlb_miss_counter
1071itlb_miss_counter:
1072 .space 4
1073
1074 .globl dtlb_miss_counter
1075dtlb_miss_counter:
1076 .space 4
1077
1078 .globl instruction_counter
1079instruction_counter:
1080 .space 4
1081#endif
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index d0862a100d29..15ac51072eb3 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -43,6 +43,9 @@
43 andi. r11, r11, MSR_PR; /* check whether user or kernel */\ 43 andi. r11, r11, MSR_PR; /* check whether user or kernel */\
44 mr r11, r1; \ 44 mr r11, r1; \
45 beq 1f; \ 45 beq 1f; \
46START_BTB_FLUSH_SECTION \
47 BTB_FLUSH(r11) \
48END_BTB_FLUSH_SECTION \
46 /* if from user, start at top of this thread's kernel stack */ \ 49 /* if from user, start at top of this thread's kernel stack */ \
47 lwz r11, THREAD_INFO-THREAD(r10); \ 50 lwz r11, THREAD_INFO-THREAD(r10); \
48 ALLOC_STACK_FRAME(r11, THREAD_SIZE); \ 51 ALLOC_STACK_FRAME(r11, THREAD_SIZE); \
@@ -128,6 +131,9 @@
128 stw r9,_CCR(r8); /* save CR on stack */\ 131 stw r9,_CCR(r8); /* save CR on stack */\
129 mfspr r11,exc_level_srr1; /* check whether user or kernel */\ 132 mfspr r11,exc_level_srr1; /* check whether user or kernel */\
130 DO_KVM BOOKE_INTERRUPT_##intno exc_level_srr1; \ 133 DO_KVM BOOKE_INTERRUPT_##intno exc_level_srr1; \
134START_BTB_FLUSH_SECTION \
135 BTB_FLUSH(r10) \
136END_BTB_FLUSH_SECTION \
131 andi. r11,r11,MSR_PR; \ 137 andi. r11,r11,MSR_PR; \
132 mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\ 138 mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\
133 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\ 139 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index e2750b856c8f..2386ce2a9c6e 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -453,6 +453,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
453 mfcr r13 453 mfcr r13
454 stw r13, THREAD_NORMSAVE(3)(r10) 454 stw r13, THREAD_NORMSAVE(3)(r10)
455 DO_KVM BOOKE_INTERRUPT_DTLB_MISS SPRN_SRR1 455 DO_KVM BOOKE_INTERRUPT_DTLB_MISS SPRN_SRR1
456START_BTB_FLUSH_SECTION
457 mfspr r11, SPRN_SRR1
458 andi. r10,r11,MSR_PR
459 beq 1f
460 BTB_FLUSH(r10)
4611:
462END_BTB_FLUSH_SECTION
456 mfspr r10, SPRN_DEAR /* Get faulting address */ 463 mfspr r10, SPRN_DEAR /* Get faulting address */
457 464
458 /* If we are faulting a kernel address, we have to use the 465 /* If we are faulting a kernel address, we have to use the
@@ -547,6 +554,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
547 mfcr r13 554 mfcr r13
548 stw r13, THREAD_NORMSAVE(3)(r10) 555 stw r13, THREAD_NORMSAVE(3)(r10)
549 DO_KVM BOOKE_INTERRUPT_ITLB_MISS SPRN_SRR1 556 DO_KVM BOOKE_INTERRUPT_ITLB_MISS SPRN_SRR1
557START_BTB_FLUSH_SECTION
558 mfspr r11, SPRN_SRR1
559 andi. r10,r11,MSR_PR
560 beq 1f
561 BTB_FLUSH(r10)
5621:
563END_BTB_FLUSH_SECTION
564
550 mfspr r10, SPRN_SRR0 /* Get faulting address */ 565 mfspr r10, SPRN_SRR0 /* Get faulting address */
551 566
552 /* If we are faulting a kernel address, we have to use the 567 /* If we are faulting a kernel address, we have to use the
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index f0dc680e659a..9d5d109f15c0 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -47,6 +47,7 @@
47#include <asm/fadump.h> 47#include <asm/fadump.h>
48#include <asm/vio.h> 48#include <asm/vio.h>
49#include <asm/tce.h> 49#include <asm/tce.h>
50#include <asm/mmu_context.h>
50 51
51#define DBG(...) 52#define DBG(...)
52 53
@@ -993,15 +994,19 @@ int iommu_tce_check_gpa(unsigned long page_shift, unsigned long gpa)
993} 994}
994EXPORT_SYMBOL_GPL(iommu_tce_check_gpa); 995EXPORT_SYMBOL_GPL(iommu_tce_check_gpa);
995 996
996long iommu_tce_xchg(struct iommu_table *tbl, unsigned long entry, 997long iommu_tce_xchg(struct mm_struct *mm, struct iommu_table *tbl,
997 unsigned long *hpa, enum dma_data_direction *direction) 998 unsigned long entry, unsigned long *hpa,
999 enum dma_data_direction *direction)
998{ 1000{
999 long ret; 1001 long ret;
1002 unsigned long size = 0;
1000 1003
1001 ret = tbl->it_ops->exchange(tbl, entry, hpa, direction); 1004 ret = tbl->it_ops->exchange(tbl, entry, hpa, direction);
1002 1005
1003 if (!ret && ((*direction == DMA_FROM_DEVICE) || 1006 if (!ret && ((*direction == DMA_FROM_DEVICE) ||
1004 (*direction == DMA_BIDIRECTIONAL))) 1007 (*direction == DMA_BIDIRECTIONAL)) &&
1008 !mm_iommu_is_devmem(mm, *hpa, tbl->it_page_shift,
1009 &size))
1005 SetPageDirty(pfn_to_page(*hpa >> PAGE_SHIFT)); 1010 SetPageDirty(pfn_to_page(*hpa >> PAGE_SHIFT));
1006 1011
1007 /* if (unlikely(ret)) 1012 /* if (unlikely(ret))
@@ -1073,11 +1078,8 @@ void iommu_release_ownership(struct iommu_table *tbl)
1073} 1078}
1074EXPORT_SYMBOL_GPL(iommu_release_ownership); 1079EXPORT_SYMBOL_GPL(iommu_release_ownership);
1075 1080
1076int iommu_add_device(struct device *dev) 1081int iommu_add_device(struct iommu_table_group *table_group, struct device *dev)
1077{ 1082{
1078 struct iommu_table *tbl;
1079 struct iommu_table_group_link *tgl;
1080
1081 /* 1083 /*
1082 * The sysfs entries should be populated before 1084 * The sysfs entries should be populated before
1083 * binding IOMMU group. If sysfs entries isn't 1085 * binding IOMMU group. If sysfs entries isn't
@@ -1093,32 +1095,10 @@ int iommu_add_device(struct device *dev)
1093 return -EBUSY; 1095 return -EBUSY;
1094 } 1096 }
1095 1097
1096 tbl = get_iommu_table_base(dev);
1097 if (!tbl) {
1098 pr_debug("%s: Skipping device %s with no tbl\n",
1099 __func__, dev_name(dev));
1100 return 0;
1101 }
1102
1103 tgl = list_first_entry_or_null(&tbl->it_group_list,
1104 struct iommu_table_group_link, next);
1105 if (!tgl) {
1106 pr_debug("%s: Skipping device %s with no group\n",
1107 __func__, dev_name(dev));
1108 return 0;
1109 }
1110 pr_debug("%s: Adding %s to iommu group %d\n", 1098 pr_debug("%s: Adding %s to iommu group %d\n",
1111 __func__, dev_name(dev), 1099 __func__, dev_name(dev), iommu_group_id(table_group->group));
1112 iommu_group_id(tgl->table_group->group));
1113
1114 if (PAGE_SIZE < IOMMU_PAGE_SIZE(tbl)) {
1115 pr_err("%s: Invalid IOMMU page size %lx (%lx) on %s\n",
1116 __func__, IOMMU_PAGE_SIZE(tbl),
1117 PAGE_SIZE, dev_name(dev));
1118 return -EINVAL;
1119 }
1120 1100
1121 return iommu_group_add_device(tgl->table_group->group, dev); 1101 return iommu_group_add_device(table_group->group, dev);
1122} 1102}
1123EXPORT_SYMBOL_GPL(iommu_add_device); 1103EXPORT_SYMBOL_GPL(iommu_add_device);
1124 1104
@@ -1138,31 +1118,4 @@ void iommu_del_device(struct device *dev)
1138 iommu_group_remove_device(dev); 1118 iommu_group_remove_device(dev);
1139} 1119}
1140EXPORT_SYMBOL_GPL(iommu_del_device); 1120EXPORT_SYMBOL_GPL(iommu_del_device);
1141
1142static int tce_iommu_bus_notifier(struct notifier_block *nb,
1143 unsigned long action, void *data)
1144{
1145 struct device *dev = data;
1146
1147 switch (action) {
1148 case BUS_NOTIFY_ADD_DEVICE:
1149 return iommu_add_device(dev);
1150 case BUS_NOTIFY_DEL_DEVICE:
1151 if (dev->iommu_group)
1152 iommu_del_device(dev);
1153 return 0;
1154 default:
1155 return 0;
1156 }
1157}
1158
1159static struct notifier_block tce_iommu_bus_nb = {
1160 .notifier_call = tce_iommu_bus_notifier,
1161};
1162
1163int __init tce_iommu_bus_notifier_init(void)
1164{
1165 bus_register_notifier(&pci_bus_type, &tce_iommu_bus_nb);
1166 return 0;
1167}
1168#endif /* CONFIG_IOMMU_API */ 1121#endif /* CONFIG_IOMMU_API */
diff --git a/arch/powerpc/kernel/isa-bridge.c b/arch/powerpc/kernel/isa-bridge.c
index fda3ae48480c..0e7099da4f25 100644
--- a/arch/powerpc/kernel/isa-bridge.c
+++ b/arch/powerpc/kernel/isa-bridge.c
@@ -327,8 +327,7 @@ static int isa_bridge_notify(struct notifier_block *nb, unsigned long action,
327 /* Check if we have no ISA device, and this happens to be one, 327 /* Check if we have no ISA device, and this happens to be one,
328 * register it as such if it has an OF device 328 * register it as such if it has an OF device
329 */ 329 */
330 if (!isa_bridge_devnode && devnode && devnode->type && 330 if (!isa_bridge_devnode && of_node_is_type(devnode, "isa"))
331 !strcmp(devnode->type, "isa"))
332 isa_bridge_find_late(pdev, devnode); 331 isa_bridge_find_late(pdev, devnode);
333 332
334 return 0; 333 return 0;
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 5b9dce17f0c9..7cea5978f21f 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -192,7 +192,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
192 /* Add port, irq will be dealt with later. We passed a translated 192 /* Add port, irq will be dealt with later. We passed a translated
193 * IO port value. It will be fixed up later along with the irq 193 * IO port value. It will be fixed up later along with the irq
194 */ 194 */
195 if (tsi && !strcmp(tsi->type, "tsi-bridge")) 195 if (of_node_is_type(tsi, "tsi-bridge"))
196 return add_legacy_port(np, -1, UPIO_TSI, addr, addr, 196 return add_legacy_port(np, -1, UPIO_TSI, addr, addr,
197 0, legacy_port_flags, 0); 197 0, legacy_port_flags, 0);
198 else 198 else
@@ -400,8 +400,7 @@ void __init find_legacy_serial_ports(void)
400 /* Next, fill our array with ISA ports */ 400 /* Next, fill our array with ISA ports */
401 for_each_node_by_type(np, "serial") { 401 for_each_node_by_type(np, "serial") {
402 struct device_node *isa = of_get_parent(np); 402 struct device_node *isa = of_get_parent(np);
403 if (isa && (!strcmp(isa->name, "isa") || 403 if (of_node_name_eq(isa, "isa") || of_node_name_eq(isa, "lpc")) {
404 !strcmp(isa->name, "lpc"))) {
405 if (of_device_is_available(np)) { 404 if (of_device_is_available(np)) {
406 index = add_legacy_isa_port(np, isa); 405 index = add_legacy_isa_port(np, isa);
407 if (index >= 0 && np == stdout) 406 if (index >= 0 && np == stdout)
@@ -415,11 +414,12 @@ void __init find_legacy_serial_ports(void)
415 /* Next, try to locate PCI ports */ 414 /* Next, try to locate PCI ports */
416 for (np = NULL; (np = of_find_all_nodes(np));) { 415 for (np = NULL; (np = of_find_all_nodes(np));) {
417 struct device_node *pci, *parent = of_get_parent(np); 416 struct device_node *pci, *parent = of_get_parent(np);
418 if (parent && !strcmp(parent->name, "isa")) { 417 if (of_node_name_eq(parent, "isa")) {
419 of_node_put(parent); 418 of_node_put(parent);
420 continue; 419 continue;
421 } 420 }
422 if (strcmp(np->name, "serial") && strcmp(np->type, "serial")) { 421 if (!of_node_name_eq(np, "serial") &&
422 !of_node_is_type(np, "serial")) {
423 of_node_put(parent); 423 of_node_put(parent);
424 continue; 424 continue;
425 } 425 }
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 695b24a2d954..57d2ffb2d45c 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -153,7 +153,7 @@ _GLOBAL(call_setup_cpu)
153 mtctr r5 153 mtctr r5
154 bctr 154 bctr
155 155
156#if defined(CONFIG_CPU_FREQ_PMAC) && defined(CONFIG_6xx) 156#if defined(CONFIG_CPU_FREQ_PMAC) && defined(CONFIG_PPC_BOOK3S_32)
157 157
158/* This gets called by via-pmu.c to switch the PLL selection 158/* This gets called by via-pmu.c to switch the PLL selection
159 * on 750fx CPU. This function should really be moved to some 159 * on 750fx CPU. This function should really be moved to some
@@ -223,7 +223,7 @@ _GLOBAL(low_choose_7447a_dfs)
223 mtmsr r7 223 mtmsr r7
224 blr 224 blr
225 225
226#endif /* CONFIG_CPU_FREQ_PMAC && CONFIG_6xx */ 226#endif /* CONFIG_CPU_FREQ_PMAC && CONFIG_PPC_BOOK3S_32 */
227 227
228/* 228/*
229 * complement mask on the msr then "or" some values on. 229 * complement mask on the msr then "or" some values on.
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 22e9d281324d..06e2eda2430e 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -809,6 +809,7 @@ static long dev_nvram_ioctl(struct file *file, unsigned int cmd,
809#ifdef CONFIG_PPC_PMAC 809#ifdef CONFIG_PPC_PMAC
810 case OBSOLETE_PMAC_NVRAM_GET_OFFSET: 810 case OBSOLETE_PMAC_NVRAM_GET_OFFSET:
811 printk(KERN_WARNING "nvram: Using obsolete PMAC_NVRAM_GET_OFFSET ioctl\n"); 811 printk(KERN_WARNING "nvram: Using obsolete PMAC_NVRAM_GET_OFFSET ioctl\n");
812 /* fall through */
812 case IOC_NVRAM_GET_OFFSET: { 813 case IOC_NVRAM_GET_OFFSET: {
813 int part, offset; 814 int part, offset;
814 815
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 98f04725def7..24191ea2d9a7 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -125,16 +125,13 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
125 struct pci_bus *bus, int devfn) 125 struct pci_bus *bus, int devfn)
126{ 126{
127 struct pci_dev *dev; 127 struct pci_dev *dev;
128 const char *type;
129 128
130 dev = pci_alloc_dev(bus); 129 dev = pci_alloc_dev(bus);
131 if (!dev) 130 if (!dev)
132 return NULL; 131 return NULL;
133 type = of_get_property(node, "device_type", NULL);
134 if (type == NULL)
135 type = "";
136 132
137 pr_debug(" create device, devfn: %x, type: %s\n", devfn, type); 133 pr_debug(" create device, devfn: %x, type: %s\n", devfn,
134 of_node_get_device_type(node));
138 135
139 dev->dev.of_node = of_node_get(node); 136 dev->dev.of_node = of_node_get(node);
140 dev->dev.parent = bus->bridge; 137 dev->dev.parent = bus->bridge;
@@ -167,12 +164,12 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
167 /* Early fixups, before probing the BARs */ 164 /* Early fixups, before probing the BARs */
168 pci_fixup_device(pci_fixup_early, dev); 165 pci_fixup_device(pci_fixup_early, dev);
169 166
170 if (!strcmp(type, "pci") || !strcmp(type, "pciex")) { 167 if (of_node_is_type(node, "pci") || of_node_is_type(node, "pciex")) {
171 /* a PCI-PCI bridge */ 168 /* a PCI-PCI bridge */
172 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE; 169 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
173 dev->rom_base_reg = PCI_ROM_ADDRESS1; 170 dev->rom_base_reg = PCI_ROM_ADDRESS1;
174 set_pcie_hotplug_bridge(dev); 171 set_pcie_hotplug_bridge(dev);
175 } else if (!strcmp(type, "cardbus")) { 172 } else if (of_node_is_type(node, "cardbus")) {
176 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS; 173 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
177 } else { 174 } else {
178 dev->hdr_type = PCI_HEADER_TYPE_NORMAL; 175 dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
diff --git a/arch/powerpc/kernel/pmc.c b/arch/powerpc/kernel/pmc.c
index 58eaa3ddf7b9..2de71faca911 100644
--- a/arch/powerpc/kernel/pmc.c
+++ b/arch/powerpc/kernel/pmc.c
@@ -29,7 +29,7 @@ static void dummy_perf(struct pt_regs *regs)
29{ 29{
30#if defined(CONFIG_FSL_EMB_PERFMON) 30#if defined(CONFIG_FSL_EMB_PERFMON)
31 mtpmr(PMRN_PMGC0, mfpmr(PMRN_PMGC0) & ~PMGC0_PMIE); 31 mtpmr(PMRN_PMGC0, mfpmr(PMRN_PMGC0) & ~PMGC0_PMIE);
32#elif defined(CONFIG_PPC64) || defined(CONFIG_6xx) 32#elif defined(CONFIG_PPC64) || defined(CONFIG_PPC_BOOK3S_32)
33 if (cur_cpu_spec->pmc_type == PPC_PMC_IBM) 33 if (cur_cpu_spec->pmc_type == PPC_PMC_IBM)
34 mtspr(SPRN_MMCR0, mfspr(SPRN_MMCR0) & ~(MMCR0_PMXE|MMCR0_PMAO)); 34 mtspr(SPRN_MMCR0, mfspr(SPRN_MMCR0) & ~(MMCR0_PMXE|MMCR0_PMAO));
35#else 35#else
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index fe758cedb93f..4181ec715f88 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -124,12 +124,12 @@ static void __init move_device_tree(void)
124 size = fdt_totalsize(initial_boot_params); 124 size = fdt_totalsize(initial_boot_params);
125 125
126 if ((memory_limit && (start + size) > PHYSICAL_START + memory_limit) || 126 if ((memory_limit && (start + size) > PHYSICAL_START + memory_limit) ||
127 overlaps_crashkernel(start, size) || 127 !memblock_is_memory(start + size - 1) ||
128 overlaps_initrd(start, size)) { 128 overlaps_crashkernel(start, size) || overlaps_initrd(start, size)) {
129 p = __va(memblock_phys_alloc(size, PAGE_SIZE)); 129 p = __va(memblock_phys_alloc(size, PAGE_SIZE));
130 memcpy(p, initial_boot_params, size); 130 memcpy(p, initial_boot_params, size);
131 initial_boot_params = p; 131 initial_boot_params = p;
132 DBG("Moved device tree to 0x%p\n", p); 132 DBG("Moved device tree to 0x%px\n", p);
133 } 133 }
134 134
135 DBG("<- move_device_tree\n"); 135 DBG("<- move_device_tree\n");
@@ -689,7 +689,7 @@ void __init early_init_devtree(void *params)
689{ 689{
690 phys_addr_t limit; 690 phys_addr_t limit;
691 691
692 DBG(" -> early_init_devtree(%p)\n", params); 692 DBG(" -> early_init_devtree(%px)\n", params);
693 693
694 /* Too early to BUG_ON(), do it by hand */ 694 /* Too early to BUG_ON(), do it by hand */
695 if (!early_init_dt_verify(params)) 695 if (!early_init_dt_verify(params))
@@ -749,7 +749,7 @@ void __init early_init_devtree(void *params)
749 memblock_allow_resize(); 749 memblock_allow_resize();
750 memblock_dump_all(); 750 memblock_dump_all();
751 751
752 DBG("Phys. mem: %llx\n", memblock_phys_mem_size()); 752 DBG("Phys. mem: %llx\n", (unsigned long long)memblock_phys_mem_size());
753 753
754 /* We may need to relocate the flat tree, do it now. 754 /* We may need to relocate the flat tree, do it now.
755 * FIXME .. and the initrd too? */ 755 * FIXME .. and the initrd too? */
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 714c3480c52d..cdd5d1d3ae41 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -3263,32 +3263,40 @@ static inline int do_seccomp(struct pt_regs *regs) { return 0; }
3263 */ 3263 */
3264long do_syscall_trace_enter(struct pt_regs *regs) 3264long do_syscall_trace_enter(struct pt_regs *regs)
3265{ 3265{
3266 u32 flags;
3267
3266 user_exit(); 3268 user_exit();
3267 3269
3268 if (test_thread_flag(TIF_SYSCALL_EMU)) { 3270 flags = READ_ONCE(current_thread_info()->flags) &
3269 /* 3271 (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE);
3270 * A nonzero return code from tracehook_report_syscall_entry()
3271 * tells us to prevent the syscall execution, but we are not
3272 * going to execute it anyway.
3273 *
3274 * Returning -1 will skip the syscall execution. We want to
3275 * avoid clobbering any register also, thus, not 'gotoing'
3276 * skip label.
3277 */
3278 if (tracehook_report_syscall_entry(regs))
3279 ;
3280 return -1;
3281 }
3282 3272
3283 /* 3273 if (flags) {
3284 * The tracer may decide to abort the syscall, if so tracehook 3274 int rc = tracehook_report_syscall_entry(regs);
3285 * will return !0. Note that the tracer may also just change 3275
3286 * regs->gpr[0] to an invalid syscall number, that is handled 3276 if (unlikely(flags & _TIF_SYSCALL_EMU)) {
3287 * below on the exit path. 3277 /*
3288 */ 3278 * A nonzero return code from
3289 if (test_thread_flag(TIF_SYSCALL_TRACE) && 3279 * tracehook_report_syscall_entry() tells us to prevent
3290 tracehook_report_syscall_entry(regs)) 3280 * the syscall execution, but we are not going to
3291 goto skip; 3281 * execute it anyway.
3282 *
3283 * Returning -1 will skip the syscall execution. We want
3284 * to avoid clobbering any registers, so we don't goto
3285 * the skip label below.
3286 */
3287 return -1;
3288 }
3289
3290 if (rc) {
3291 /*
3292 * The tracer decided to abort the syscall. Note that
3293 * the tracer may also just change regs->gpr[0] to an
3294 * invalid syscall number, that is handled below on the
3295 * exit path.
3296 */
3297 goto skip;
3298 }
3299 }
3292 3300
3293 /* Run seccomp after ptrace; allow it to set gpr[3]. */ 3301 /* Run seccomp after ptrace; allow it to set gpr[3]. */
3294 if (do_seccomp(regs)) 3302 if (do_seccomp(regs))
diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
index f6f469fc4073..9b8631533e02 100644
--- a/arch/powerpc/kernel/security.c
+++ b/arch/powerpc/kernel/security.c
@@ -4,6 +4,7 @@
4// 4//
5// Copyright 2018, Michael Ellerman, IBM Corporation. 5// Copyright 2018, Michael Ellerman, IBM Corporation.
6 6
7#include <linux/cpu.h>
7#include <linux/kernel.h> 8#include <linux/kernel.h>
8#include <linux/device.h> 9#include <linux/device.h>
9#include <linux/seq_buf.h> 10#include <linux/seq_buf.h>
@@ -22,10 +23,14 @@ enum count_cache_flush_type {
22 COUNT_CACHE_FLUSH_SW = 0x2, 23 COUNT_CACHE_FLUSH_SW = 0x2,
23 COUNT_CACHE_FLUSH_HW = 0x4, 24 COUNT_CACHE_FLUSH_HW = 0x4,
24}; 25};
25static enum count_cache_flush_type count_cache_flush_type; 26static enum count_cache_flush_type count_cache_flush_type = COUNT_CACHE_FLUSH_NONE;
26 27
27bool barrier_nospec_enabled; 28bool barrier_nospec_enabled;
28static bool no_nospec; 29static bool no_nospec;
30static bool btb_flush_enabled;
31#ifdef CONFIG_PPC_FSL_BOOK3E
32static bool no_spectrev2;
33#endif
29 34
30static void enable_barrier_nospec(bool enable) 35static void enable_barrier_nospec(bool enable)
31{ 36{
@@ -101,6 +106,23 @@ static __init int barrier_nospec_debugfs_init(void)
101device_initcall(barrier_nospec_debugfs_init); 106device_initcall(barrier_nospec_debugfs_init);
102#endif /* CONFIG_DEBUG_FS */ 107#endif /* CONFIG_DEBUG_FS */
103 108
109#ifdef CONFIG_PPC_FSL_BOOK3E
110static int __init handle_nospectre_v2(char *p)
111{
112 no_spectrev2 = true;
113
114 return 0;
115}
116early_param("nospectre_v2", handle_nospectre_v2);
117void setup_spectre_v2(void)
118{
119 if (no_spectrev2)
120 do_btb_flush_fixups();
121 else
122 btb_flush_enabled = true;
123}
124#endif /* CONFIG_PPC_FSL_BOOK3E */
125
104#ifdef CONFIG_PPC_BOOK3S_64 126#ifdef CONFIG_PPC_BOOK3S_64
105ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, char *buf) 127ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, char *buf)
106{ 128{
@@ -191,8 +213,11 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
191 213
192 if (count_cache_flush_type == COUNT_CACHE_FLUSH_HW) 214 if (count_cache_flush_type == COUNT_CACHE_FLUSH_HW)
193 seq_buf_printf(&s, "(hardware accelerated)"); 215 seq_buf_printf(&s, "(hardware accelerated)");
194 } else 216 } else if (btb_flush_enabled) {
217 seq_buf_printf(&s, "Mitigation: Branch predictor state flush");
218 } else {
195 seq_buf_printf(&s, "Vulnerable"); 219 seq_buf_printf(&s, "Vulnerable");
220 }
196 221
197 seq_buf_printf(&s, "\n"); 222 seq_buf_printf(&s, "\n");
198 223
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 93ee3703b42f..ca00fbb97cf8 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -687,7 +687,7 @@ int check_legacy_ioport(unsigned long base_port)
687 return ret; 687 return ret;
688 parent = of_get_parent(np); 688 parent = of_get_parent(np);
689 if (parent) { 689 if (parent) {
690 if (strcmp(parent->type, "isa") == 0) 690 if (of_node_is_type(parent, "isa"))
691 ret = 0; 691 ret = 0;
692 of_node_put(parent); 692 of_node_put(parent);
693 } 693 }
@@ -800,7 +800,7 @@ static __init void print_system_info(void)
800#ifdef CONFIG_PPC_BOOK3S_64 800#ifdef CONFIG_PPC_BOOK3S_64
801 pr_info("ppc64_pft_size = 0x%llx\n", ppc64_pft_size); 801 pr_info("ppc64_pft_size = 0x%llx\n", ppc64_pft_size);
802#endif 802#endif
803#ifdef CONFIG_PPC_STD_MMU_32 803#ifdef CONFIG_PPC_BOOK3S_32
804 pr_info("Hash_size = 0x%lx\n", Hash_size); 804 pr_info("Hash_size = 0x%lx\n", Hash_size);
805#endif 805#endif
806 pr_info("phys_mem_size = 0x%llx\n", 806 pr_info("phys_mem_size = 0x%llx\n",
@@ -830,7 +830,7 @@ static __init void print_system_info(void)
830 if (htab_hash_mask) 830 if (htab_hash_mask)
831 pr_info("htab_hash_mask = 0x%lx\n", htab_hash_mask); 831 pr_info("htab_hash_mask = 0x%lx\n", htab_hash_mask);
832#endif 832#endif
833#ifdef CONFIG_PPC_STD_MMU_32 833#ifdef CONFIG_PPC_BOOK3S_32
834 if (Hash) 834 if (Hash)
835 pr_info("Hash = 0x%p\n", Hash); 835 pr_info("Hash = 0x%p\n", Hash);
836 if (Hash_mask) 836 if (Hash_mask)
@@ -974,6 +974,7 @@ void __init setup_arch(char **cmdline_p)
974 ppc_md.setup_arch(); 974 ppc_md.setup_arch();
975 975
976 setup_barrier_nospec(); 976 setup_barrier_nospec();
977 setup_spectre_v2();
977 978
978 paging_init(); 979 paging_init();
979 980
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 81909600013a..947f904688b0 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -59,7 +59,6 @@ unsigned long ISA_DMA_THRESHOLD;
59unsigned int DMA_MODE_READ; 59unsigned int DMA_MODE_READ;
60unsigned int DMA_MODE_WRITE; 60unsigned int DMA_MODE_WRITE;
61 61
62EXPORT_SYMBOL(ISA_DMA_THRESHOLD);
63EXPORT_SYMBOL(DMA_MODE_READ); 62EXPORT_SYMBOL(DMA_MODE_READ);
64EXPORT_SYMBOL(DMA_MODE_WRITE); 63EXPORT_SYMBOL(DMA_MODE_WRITE);
65 64
@@ -101,8 +100,7 @@ notrace unsigned long __init early_init(unsigned long dt_ptr)
101 */ 100 */
102notrace void __init machine_init(u64 dt_ptr) 101notrace void __init machine_init(u64 dt_ptr)
103{ 102{
104 unsigned int *addr = (unsigned int *)((unsigned long)&patch__memset_nocache + 103 unsigned int *addr = (unsigned int *)patch_site_addr(&patch__memset_nocache);
105 patch__memset_nocache);
106 unsigned long insn; 104 unsigned long insn;
107 105
108 /* Configure static keys first, now that we're relocated. */ 106 /* Configure static keys first, now that we're relocated. */
@@ -240,7 +238,7 @@ void __init exc_lvl_early_init(void)
240 238
241void __init setup_power_save(void) 239void __init setup_power_save(void)
242{ 240{
243#ifdef CONFIG_6xx 241#ifdef CONFIG_PPC_BOOK3S_32
244 if (cpu_has_feature(CPU_FTR_CAN_DOZE) || 242 if (cpu_has_feature(CPU_FTR_CAN_DOZE) ||
245 cpu_has_feature(CPU_FTR_CAN_NAP)) 243 cpu_has_feature(CPU_FTR_CAN_NAP))
246 ppc_md.power_save = ppc6xx_idle; 244 ppc_md.power_save = ppc6xx_idle;
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index e6474a45cef5..2d47cc79e5b3 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -470,9 +470,9 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame,
470 return 1; 470 return 1;
471 471
472 if (sigret) { 472 if (sigret) {
473 /* Set up the sigreturn trampoline: li r0,sigret; sc */ 473 /* Set up the sigreturn trampoline: li 0,sigret; sc */
474 if (__put_user(0x38000000UL + sigret, &frame->tramp[0]) 474 if (__put_user(PPC_INST_ADDI + sigret, &frame->tramp[0])
475 || __put_user(0x44000002UL, &frame->tramp[1])) 475 || __put_user(PPC_INST_SC, &frame->tramp[1]))
476 return 1; 476 return 1;
477 flush_icache_range((unsigned long) &frame->tramp[0], 477 flush_icache_range((unsigned long) &frame->tramp[0],
478 (unsigned long) &frame->tramp[2]); 478 (unsigned long) &frame->tramp[2]);
@@ -619,9 +619,9 @@ static int save_tm_user_regs(struct pt_regs *regs,
619 if (__put_user(msr, &frame->mc_gregs[PT_MSR])) 619 if (__put_user(msr, &frame->mc_gregs[PT_MSR]))
620 return 1; 620 return 1;
621 if (sigret) { 621 if (sigret) {
622 /* Set up the sigreturn trampoline: li r0,sigret; sc */ 622 /* Set up the sigreturn trampoline: li 0,sigret; sc */
623 if (__put_user(0x38000000UL + sigret, &frame->tramp[0]) 623 if (__put_user(PPC_INST_ADDI + sigret, &frame->tramp[0])
624 || __put_user(0x44000002UL, &frame->tramp[1])) 624 || __put_user(PPC_INST_SC, &frame->tramp[1]))
625 return 1; 625 return 1;
626 flush_icache_range((unsigned long) &frame->tramp[0], 626 flush_icache_range((unsigned long) &frame->tramp[0],
627 (unsigned long) &frame->tramp[2]); 627 (unsigned long) &frame->tramp[2]);
@@ -848,7 +848,23 @@ static long restore_tm_user_regs(struct pt_regs *regs,
848 /* If TM bits are set to the reserved value, it's an invalid context */ 848 /* If TM bits are set to the reserved value, it's an invalid context */
849 if (MSR_TM_RESV(msr_hi)) 849 if (MSR_TM_RESV(msr_hi))
850 return 1; 850 return 1;
851 /* Pull in the MSR TM bits from the user context */ 851
852 /*
853 * Disabling preemption, since it is unsafe to be preempted
854 * with MSR[TS] set without recheckpointing.
855 */
856 preempt_disable();
857
858 /*
859 * CAUTION:
860 * After regs->MSR[TS] being updated, make sure that get_user(),
861 * put_user() or similar functions are *not* called. These
862 * functions can generate page faults which will cause the process
863 * to be de-scheduled with MSR[TS] set but without calling
864 * tm_recheckpoint(). This can cause a bug.
865 *
866 * Pull in the MSR TM bits from the user context
867 */
852 regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr_hi & MSR_TS_MASK); 868 regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr_hi & MSR_TS_MASK);
853 /* Now, recheckpoint. This loads up all of the checkpointed (older) 869 /* Now, recheckpoint. This loads up all of the checkpointed (older)
854 * registers, including FP and V[S]Rs. After recheckpointing, the 870 * registers, including FP and V[S]Rs. After recheckpointing, the
@@ -873,6 +889,8 @@ static long restore_tm_user_regs(struct pt_regs *regs,
873 } 889 }
874#endif 890#endif
875 891
892 preempt_enable();
893
876 return 0; 894 return 0;
877} 895}
878#endif 896#endif
@@ -1140,11 +1158,11 @@ SYSCALL_DEFINE0(rt_sigreturn)
1140{ 1158{
1141 struct rt_sigframe __user *rt_sf; 1159 struct rt_sigframe __user *rt_sf;
1142 struct pt_regs *regs = current_pt_regs(); 1160 struct pt_regs *regs = current_pt_regs();
1161 int tm_restore = 0;
1143#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1162#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1144 struct ucontext __user *uc_transact; 1163 struct ucontext __user *uc_transact;
1145 unsigned long msr_hi; 1164 unsigned long msr_hi;
1146 unsigned long tmp; 1165 unsigned long tmp;
1147 int tm_restore = 0;
1148#endif 1166#endif
1149 /* Always make any pending restarted system calls return -EINTR */ 1167 /* Always make any pending restarted system calls return -EINTR */
1150 current->restart_block.fn = do_no_restart_syscall; 1168 current->restart_block.fn = do_no_restart_syscall;
@@ -1192,11 +1210,19 @@ SYSCALL_DEFINE0(rt_sigreturn)
1192 goto bad; 1210 goto bad;
1193 } 1211 }
1194 } 1212 }
1195 if (!tm_restore) 1213 if (!tm_restore) {
1196 /* Fall through, for non-TM restore */ 1214 /*
1215 * Unset regs->msr because ucontext MSR TS is not
1216 * set, and recheckpoint was not called. This avoid
1217 * hitting a TM Bad thing at RFID
1218 */
1219 regs->msr &= ~MSR_TS_MASK;
1220 }
1221 /* Fall through, for non-TM restore */
1197#endif 1222#endif
1198 if (do_setcontext(&rt_sf->uc, regs, 1)) 1223 if (!tm_restore)
1199 goto bad; 1224 if (do_setcontext(&rt_sf->uc, regs, 1))
1225 goto bad;
1200 1226
1201 /* 1227 /*
1202 * It's not clear whether or why it is desirable to save the 1228 * It's not clear whether or why it is desirable to save the
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 83d51bf586c7..0935fe6c282a 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -467,20 +467,6 @@ static long restore_tm_sigcontexts(struct task_struct *tsk,
467 if (MSR_TM_RESV(msr)) 467 if (MSR_TM_RESV(msr))
468 return -EINVAL; 468 return -EINVAL;
469 469
470 /* pull in MSR TS bits from user context */
471 regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr & MSR_TS_MASK);
472
473 /*
474 * Ensure that TM is enabled in regs->msr before we leave the signal
475 * handler. It could be the case that (a) user disabled the TM bit
476 * through the manipulation of the MSR bits in uc_mcontext or (b) the
477 * TM bit was disabled because a sufficient number of context switches
478 * happened whilst in the signal handler and load_tm overflowed,
479 * disabling the TM bit. In either case we can end up with an illegal
480 * TM state leading to a TM Bad Thing when we return to userspace.
481 */
482 regs->msr |= MSR_TM;
483
484 /* pull in MSR LE from user context */ 470 /* pull in MSR LE from user context */
485 regs->msr = (regs->msr & ~MSR_LE) | (msr & MSR_LE); 471 regs->msr = (regs->msr & ~MSR_LE) | (msr & MSR_LE);
486 472
@@ -572,6 +558,34 @@ static long restore_tm_sigcontexts(struct task_struct *tsk,
572 tm_enable(); 558 tm_enable();
573 /* Make sure the transaction is marked as failed */ 559 /* Make sure the transaction is marked as failed */
574 tsk->thread.tm_texasr |= TEXASR_FS; 560 tsk->thread.tm_texasr |= TEXASR_FS;
561
562 /*
563 * Disabling preemption, since it is unsafe to be preempted
564 * with MSR[TS] set without recheckpointing.
565 */
566 preempt_disable();
567
568 /* pull in MSR TS bits from user context */
569 regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr & MSR_TS_MASK);
570
571 /*
572 * Ensure that TM is enabled in regs->msr before we leave the signal
573 * handler. It could be the case that (a) user disabled the TM bit
574 * through the manipulation of the MSR bits in uc_mcontext or (b) the
575 * TM bit was disabled because a sufficient number of context switches
576 * happened whilst in the signal handler and load_tm overflowed,
577 * disabling the TM bit. In either case we can end up with an illegal
578 * TM state leading to a TM Bad Thing when we return to userspace.
579 *
580 * CAUTION:
581 * After regs->MSR[TS] being updated, make sure that get_user(),
582 * put_user() or similar functions are *not* called. These
583 * functions can generate page faults which will cause the process
584 * to be de-scheduled with MSR[TS] set but without calling
585 * tm_recheckpoint(). This can cause a bug.
586 */
587 regs->msr |= MSR_TM;
588
575 /* This loads the checkpointed FP/VEC state, if used */ 589 /* This loads the checkpointed FP/VEC state, if used */
576 tm_recheckpoint(&tsk->thread); 590 tm_recheckpoint(&tsk->thread);
577 591
@@ -585,6 +599,8 @@ static long restore_tm_sigcontexts(struct task_struct *tsk,
585 regs->msr |= MSR_VEC; 599 regs->msr |= MSR_VEC;
586 } 600 }
587 601
602 preempt_enable();
603
588 return err; 604 return err;
589} 605}
590#endif 606#endif
@@ -598,11 +614,12 @@ static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp)
598 long err = 0; 614 long err = 0;
599 615
600 /* addi r1, r1, __SIGNAL_FRAMESIZE # Pop the dummy stackframe */ 616 /* addi r1, r1, __SIGNAL_FRAMESIZE # Pop the dummy stackframe */
601 err |= __put_user(0x38210000UL | (__SIGNAL_FRAMESIZE & 0xffff), &tramp[0]); 617 err |= __put_user(PPC_INST_ADDI | __PPC_RT(R1) | __PPC_RA(R1) |
618 (__SIGNAL_FRAMESIZE & 0xffff), &tramp[0]);
602 /* li r0, __NR_[rt_]sigreturn| */ 619 /* li r0, __NR_[rt_]sigreturn| */
603 err |= __put_user(0x38000000UL | (syscall & 0xffff), &tramp[1]); 620 err |= __put_user(PPC_INST_ADDI | (syscall & 0xffff), &tramp[1]);
604 /* sc */ 621 /* sc */
605 err |= __put_user(0x44000002UL, &tramp[2]); 622 err |= __put_user(PPC_INST_SC, &tramp[2]);
606 623
607 /* Minimal traceback info */ 624 /* Minimal traceback info */
608 for (i=TRAMP_TRACEBACK; i < TRAMP_SIZE ;i++) 625 for (i=TRAMP_TRACEBACK; i < TRAMP_SIZE ;i++)
@@ -740,11 +757,23 @@ SYSCALL_DEFINE0(rt_sigreturn)
740 &uc_transact->uc_mcontext)) 757 &uc_transact->uc_mcontext))
741 goto badframe; 758 goto badframe;
742 } 759 }
743 else
744 /* Fall through, for non-TM restore */
745#endif 760#endif
746 if (restore_sigcontext(current, NULL, 1, &uc->uc_mcontext)) 761 /* Fall through, for non-TM restore */
747 goto badframe; 762 if (!MSR_TM_ACTIVE(msr)) {
763 /*
764 * Unset MSR[TS] on the thread regs since MSR from user
765 * context does not have MSR active, and recheckpoint was
766 * not called since restore_tm_sigcontexts() was not called
767 * also.
768 *
769 * If not unsetting it, the code can RFID to userspace with
770 * MSR[TS] set, but without CPU in the proper state,
771 * causing a TM bad thing.
772 */
773 current->thread.regs->msr &= ~MSR_TS_MASK;
774 if (restore_sigcontext(current, NULL, 1, &uc->uc_mcontext))
775 goto badframe;
776 }
748 777
749 if (restore_altstack(&uc->uc_stack)) 778 if (restore_altstack(&uc->uc_stack))
750 goto badframe; 779 goto badframe;
diff --git a/arch/powerpc/kernel/syscalls/Makefile b/arch/powerpc/kernel/syscalls/Makefile
new file mode 100644
index 000000000000..27b48954808d
--- /dev/null
+++ b/arch/powerpc/kernel/syscalls/Makefile
@@ -0,0 +1,63 @@
1# SPDX-License-Identifier: GPL-2.0
2kapi := arch/$(SRCARCH)/include/generated/asm
3uapi := arch/$(SRCARCH)/include/generated/uapi/asm
4
5_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
6 $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
7
8syscall := $(srctree)/$(src)/syscall.tbl
9syshdr := $(srctree)/$(src)/syscallhdr.sh
10systbl := $(srctree)/$(src)/syscalltbl.sh
11
12quiet_cmd_syshdr = SYSHDR $@
13 cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \
14 '$(syshdr_abis_$(basetarget))' \
15 '$(syshdr_pfx_$(basetarget))' \
16 '$(syshdr_offset_$(basetarget))'
17
18quiet_cmd_systbl = SYSTBL $@
19 cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@' \
20 '$(systbl_abis_$(basetarget))' \
21 '$(systbl_abi_$(basetarget))' \
22 '$(systbl_offset_$(basetarget))'
23
24syshdr_abis_unistd_32 := common,nospu,32
25$(uapi)/unistd_32.h: $(syscall) $(syshdr)
26 $(call if_changed,syshdr)
27
28syshdr_abis_unistd_64 := common,nospu,64
29$(uapi)/unistd_64.h: $(syscall) $(syshdr)
30 $(call if_changed,syshdr)
31
32systbl_abis_syscall_table_32 := common,nospu,32
33systbl_abi_syscall_table_32 := 32
34$(kapi)/syscall_table_32.h: $(syscall) $(systbl)
35 $(call if_changed,systbl)
36
37systbl_abis_syscall_table_64 := common,nospu,64
38systbl_abi_syscall_table_64 := 64
39$(kapi)/syscall_table_64.h: $(syscall) $(systbl)
40 $(call if_changed,systbl)
41
42systbl_abis_syscall_table_c32 := common,nospu,32
43systbl_abi_syscall_table_c32 := c32
44$(kapi)/syscall_table_c32.h: $(syscall) $(systbl)
45 $(call if_changed,systbl)
46
47systbl_abis_syscall_table_spu := common,spu
48systbl_abi_syscall_table_spu := spu
49$(kapi)/syscall_table_spu.h: $(syscall) $(systbl)
50 $(call if_changed,systbl)
51
52uapisyshdr-y += unistd_32.h unistd_64.h
53kapisyshdr-y += syscall_table_32.h \
54 syscall_table_64.h \
55 syscall_table_c32.h \
56 syscall_table_spu.h
57
58targets += $(uapisyshdr-y) $(kapisyshdr-y)
59
60PHONY += all
61all: $(addprefix $(uapi)/,$(uapisyshdr-y))
62all: $(addprefix $(kapi)/,$(kapisyshdr-y))
63 @:
diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl
new file mode 100644
index 000000000000..db3bbb8744af
--- /dev/null
+++ b/arch/powerpc/kernel/syscalls/syscall.tbl
@@ -0,0 +1,427 @@
1# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
2#
3# system call numbers and entry vectors for powerpc
4#
5# The format is:
6# <number> <abi> <name> <entry point> <compat entry point>
7#
8# The <abi> can be common, spu, nospu, 64, or 32 for this file.
9#
100 nospu restart_syscall sys_restart_syscall
111 nospu exit sys_exit
122 nospu fork ppc_fork
133 common read sys_read
144 common write sys_write
155 common open sys_open compat_sys_open
166 common close sys_close
177 common waitpid sys_waitpid
188 common creat sys_creat
199 common link sys_link
2010 common unlink sys_unlink
2111 nospu execve sys_execve compat_sys_execve
2212 common chdir sys_chdir
2313 common time sys_time compat_sys_time
2414 common mknod sys_mknod
2515 common chmod sys_chmod
2616 common lchown sys_lchown
2717 common break sys_ni_syscall
2818 32 oldstat sys_stat sys_ni_syscall
2918 64 oldstat sys_ni_syscall
3018 spu oldstat sys_ni_syscall
3119 common lseek sys_lseek compat_sys_lseek
3220 common getpid sys_getpid
3321 nospu mount sys_mount compat_sys_mount
3422 32 umount sys_oldumount
3522 64 umount sys_ni_syscall
3622 spu umount sys_ni_syscall
3723 common setuid sys_setuid
3824 common getuid sys_getuid
3925 common stime sys_stime compat_sys_stime
4026 nospu ptrace sys_ptrace compat_sys_ptrace
4127 common alarm sys_alarm
4228 32 oldfstat sys_fstat sys_ni_syscall
4328 64 oldfstat sys_ni_syscall
4428 spu oldfstat sys_ni_syscall
4529 nospu pause sys_pause
4630 nospu utime sys_utime compat_sys_utime
4731 common stty sys_ni_syscall
4832 common gtty sys_ni_syscall
4933 common access sys_access
5034 common nice sys_nice
5135 common ftime sys_ni_syscall
5236 common sync sys_sync
5337 common kill sys_kill
5438 common rename sys_rename
5539 common mkdir sys_mkdir
5640 common rmdir sys_rmdir
5741 common dup sys_dup
5842 common pipe sys_pipe
5943 common times sys_times compat_sys_times
6044 common prof sys_ni_syscall
6145 common brk sys_brk
6246 common setgid sys_setgid
6347 common getgid sys_getgid
6448 nospu signal sys_signal
6549 common geteuid sys_geteuid
6650 common getegid sys_getegid
6751 nospu acct sys_acct
6852 nospu umount2 sys_umount
6953 common lock sys_ni_syscall
7054 common ioctl sys_ioctl compat_sys_ioctl
7155 common fcntl sys_fcntl compat_sys_fcntl
7256 common mpx sys_ni_syscall
7357 common setpgid sys_setpgid
7458 common ulimit sys_ni_syscall
7559 32 oldolduname sys_olduname
7659 64 oldolduname sys_ni_syscall
7759 spu oldolduname sys_ni_syscall
7860 common umask sys_umask
7961 common chroot sys_chroot
8062 nospu ustat sys_ustat compat_sys_ustat
8163 common dup2 sys_dup2
8264 common getppid sys_getppid
8365 common getpgrp sys_getpgrp
8466 common setsid sys_setsid
8567 32 sigaction sys_sigaction compat_sys_sigaction
8667 64 sigaction sys_ni_syscall
8767 spu sigaction sys_ni_syscall
8868 common sgetmask sys_sgetmask
8969 common ssetmask sys_ssetmask
9070 common setreuid sys_setreuid
9171 common setregid sys_setregid
9272 32 sigsuspend sys_sigsuspend
9372 64 sigsuspend sys_ni_syscall
9472 spu sigsuspend sys_ni_syscall
9573 32 sigpending sys_sigpending compat_sys_sigpending
9673 64 sigpending sys_ni_syscall
9773 spu sigpending sys_ni_syscall
9874 common sethostname sys_sethostname
9975 common setrlimit sys_setrlimit compat_sys_setrlimit
10076 32 getrlimit sys_old_getrlimit compat_sys_old_getrlimit
10176 64 getrlimit sys_ni_syscall
10276 spu getrlimit sys_ni_syscall
10377 common getrusage sys_getrusage compat_sys_getrusage
10478 common gettimeofday sys_gettimeofday compat_sys_gettimeofday
10579 common settimeofday sys_settimeofday compat_sys_settimeofday
10680 common getgroups sys_getgroups
10781 common setgroups sys_setgroups
10882 32 select ppc_select sys_ni_syscall
10982 64 select sys_ni_syscall
11082 spu select sys_ni_syscall
11183 common symlink sys_symlink
11284 32 oldlstat sys_lstat sys_ni_syscall
11384 64 oldlstat sys_ni_syscall
11484 spu oldlstat sys_ni_syscall
11585 common readlink sys_readlink
11686 nospu uselib sys_uselib
11787 nospu swapon sys_swapon
11888 nospu reboot sys_reboot
11989 32 readdir sys_old_readdir compat_sys_old_readdir
12089 64 readdir sys_ni_syscall
12189 spu readdir sys_ni_syscall
12290 common mmap sys_mmap
12391 common munmap sys_munmap
12492 common truncate sys_truncate compat_sys_truncate
12593 common ftruncate sys_ftruncate compat_sys_ftruncate
12694 common fchmod sys_fchmod
12795 common fchown sys_fchown
12896 common getpriority sys_getpriority
12997 common setpriority sys_setpriority
13098 common profil sys_ni_syscall
13199 nospu statfs sys_statfs compat_sys_statfs
132100 nospu fstatfs sys_fstatfs compat_sys_fstatfs
133101 common ioperm sys_ni_syscall
134102 common socketcall sys_socketcall compat_sys_socketcall
135103 common syslog sys_syslog
136104 common setitimer sys_setitimer compat_sys_setitimer
137105 common getitimer sys_getitimer compat_sys_getitimer
138106 common stat sys_newstat compat_sys_newstat
139107 common lstat sys_newlstat compat_sys_newlstat
140108 common fstat sys_newfstat compat_sys_newfstat
141109 32 olduname sys_uname
142109 64 olduname sys_ni_syscall
143109 spu olduname sys_ni_syscall
144110 common iopl sys_ni_syscall
145111 common vhangup sys_vhangup
146112 common idle sys_ni_syscall
147113 common vm86 sys_ni_syscall
148114 common wait4 sys_wait4 compat_sys_wait4
149115 nospu swapoff sys_swapoff
150116 common sysinfo sys_sysinfo compat_sys_sysinfo
151117 nospu ipc sys_ipc compat_sys_ipc
152118 common fsync sys_fsync
153119 32 sigreturn sys_sigreturn compat_sys_sigreturn
154119 64 sigreturn sys_ni_syscall
155119 spu sigreturn sys_ni_syscall
156120 nospu clone ppc_clone
157121 common setdomainname sys_setdomainname
158122 common uname sys_newuname
159123 common modify_ldt sys_ni_syscall
160124 common adjtimex sys_adjtimex compat_sys_adjtimex
161125 common mprotect sys_mprotect
162126 32 sigprocmask sys_sigprocmask compat_sys_sigprocmask
163126 64 sigprocmask sys_ni_syscall
164126 spu sigprocmask sys_ni_syscall
165127 common create_module sys_ni_syscall
166128 nospu init_module sys_init_module
167129 nospu delete_module sys_delete_module
168130 common get_kernel_syms sys_ni_syscall
169131 nospu quotactl sys_quotactl
170132 common getpgid sys_getpgid
171133 common fchdir sys_fchdir
172134 common bdflush sys_bdflush
173135 common sysfs sys_sysfs
174136 32 personality sys_personality ppc64_personality
175136 64 personality ppc64_personality
176136 spu personality ppc64_personality
177137 common afs_syscall sys_ni_syscall
178138 common setfsuid sys_setfsuid
179139 common setfsgid sys_setfsgid
180140 common _llseek sys_llseek
181141 common getdents sys_getdents compat_sys_getdents
182142 common _newselect sys_select compat_sys_select
183143 common flock sys_flock
184144 common msync sys_msync
185145 common readv sys_readv compat_sys_readv
186146 common writev sys_writev compat_sys_writev
187147 common getsid sys_getsid
188148 common fdatasync sys_fdatasync
189149 nospu _sysctl sys_sysctl compat_sys_sysctl
190150 common mlock sys_mlock
191151 common munlock sys_munlock
192152 common mlockall sys_mlockall
193153 common munlockall sys_munlockall
194154 common sched_setparam sys_sched_setparam
195155 common sched_getparam sys_sched_getparam
196156 common sched_setscheduler sys_sched_setscheduler
197157 common sched_getscheduler sys_sched_getscheduler
198158 common sched_yield sys_sched_yield
199159 common sched_get_priority_max sys_sched_get_priority_max
200160 common sched_get_priority_min sys_sched_get_priority_min
201161 common sched_rr_get_interval sys_sched_rr_get_interval compat_sys_sched_rr_get_interval
202162 common nanosleep sys_nanosleep compat_sys_nanosleep
203163 common mremap sys_mremap
204164 common setresuid sys_setresuid
205165 common getresuid sys_getresuid
206166 common query_module sys_ni_syscall
207167 common poll sys_poll
208168 common nfsservctl sys_ni_syscall
209169 common setresgid sys_setresgid
210170 common getresgid sys_getresgid
211171 common prctl sys_prctl
212172 nospu rt_sigreturn sys_rt_sigreturn compat_sys_rt_sigreturn
213173 nospu rt_sigaction sys_rt_sigaction compat_sys_rt_sigaction
214174 nospu rt_sigprocmask sys_rt_sigprocmask compat_sys_rt_sigprocmask
215175 nospu rt_sigpending sys_rt_sigpending compat_sys_rt_sigpending
216176 nospu rt_sigtimedwait sys_rt_sigtimedwait compat_sys_rt_sigtimedwait
217177 nospu rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo
218178 nospu rt_sigsuspend sys_rt_sigsuspend compat_sys_rt_sigsuspend
219179 common pread64 sys_pread64 compat_sys_pread64
220180 common pwrite64 sys_pwrite64 compat_sys_pwrite64
221181 common chown sys_chown
222182 common getcwd sys_getcwd
223183 common capget sys_capget
224184 common capset sys_capset
225185 nospu sigaltstack sys_sigaltstack compat_sys_sigaltstack
226186 32 sendfile sys_sendfile compat_sys_sendfile
227186 64 sendfile sys_sendfile64
228186 spu sendfile sys_sendfile64
229187 common getpmsg sys_ni_syscall
230188 common putpmsg sys_ni_syscall
231189 nospu vfork ppc_vfork
232190 common ugetrlimit sys_getrlimit compat_sys_getrlimit
233191 common readahead sys_readahead compat_sys_readahead
234192 32 mmap2 sys_mmap2 compat_sys_mmap2
235193 32 truncate64 sys_truncate64 compat_sys_truncate64
236194 32 ftruncate64 sys_ftruncate64 compat_sys_ftruncate64
237195 32 stat64 sys_stat64
238196 32 lstat64 sys_lstat64
239197 32 fstat64 sys_fstat64
240198 nospu pciconfig_read sys_pciconfig_read
241199 nospu pciconfig_write sys_pciconfig_write
242200 nospu pciconfig_iobase sys_pciconfig_iobase
243201 common multiplexer sys_ni_syscall
244202 common getdents64 sys_getdents64
245203 common pivot_root sys_pivot_root
246204 32 fcntl64 sys_fcntl64 compat_sys_fcntl64
247205 common madvise sys_madvise
248206 common mincore sys_mincore
249207 common gettid sys_gettid
250208 common tkill sys_tkill
251209 common setxattr sys_setxattr
252210 common lsetxattr sys_lsetxattr
253211 common fsetxattr sys_fsetxattr
254212 common getxattr sys_getxattr
255213 common lgetxattr sys_lgetxattr
256214 common fgetxattr sys_fgetxattr
257215 common listxattr sys_listxattr
258216 common llistxattr sys_llistxattr
259217 common flistxattr sys_flistxattr
260218 common removexattr sys_removexattr
261219 common lremovexattr sys_lremovexattr
262220 common fremovexattr sys_fremovexattr
263221 common futex sys_futex compat_sys_futex
264222 common sched_setaffinity sys_sched_setaffinity compat_sys_sched_setaffinity
265223 common sched_getaffinity sys_sched_getaffinity compat_sys_sched_getaffinity
266# 224 unused
267225 common tuxcall sys_ni_syscall
268226 32 sendfile64 sys_sendfile64 compat_sys_sendfile64
269227 common io_setup sys_io_setup compat_sys_io_setup
270228 common io_destroy sys_io_destroy
271229 common io_getevents sys_io_getevents compat_sys_io_getevents
272230 common io_submit sys_io_submit compat_sys_io_submit
273231 common io_cancel sys_io_cancel
274232 nospu set_tid_address sys_set_tid_address
275233 common fadvise64 sys_fadvise64 ppc32_fadvise64
276234 nospu exit_group sys_exit_group
277235 nospu lookup_dcookie sys_lookup_dcookie compat_sys_lookup_dcookie
278236 common epoll_create sys_epoll_create
279237 common epoll_ctl sys_epoll_ctl
280238 common epoll_wait sys_epoll_wait
281239 common remap_file_pages sys_remap_file_pages
282240 common timer_create sys_timer_create compat_sys_timer_create
283241 common timer_settime sys_timer_settime compat_sys_timer_settime
284242 common timer_gettime sys_timer_gettime compat_sys_timer_gettime
285243 common timer_getoverrun sys_timer_getoverrun
286244 common timer_delete sys_timer_delete
287245 common clock_settime sys_clock_settime compat_sys_clock_settime
288246 common clock_gettime sys_clock_gettime compat_sys_clock_gettime
289247 common clock_getres sys_clock_getres compat_sys_clock_getres
290248 common clock_nanosleep sys_clock_nanosleep compat_sys_clock_nanosleep
291249 32 swapcontext ppc_swapcontext ppc32_swapcontext
292249 64 swapcontext ppc64_swapcontext
293249 spu swapcontext sys_ni_syscall
294250 common tgkill sys_tgkill
295251 common utimes sys_utimes compat_sys_utimes
296252 common statfs64 sys_statfs64 compat_sys_statfs64
297253 common fstatfs64 sys_fstatfs64 compat_sys_fstatfs64
298254 32 fadvise64_64 ppc_fadvise64_64
299254 spu fadvise64_64 sys_ni_syscall
300255 common rtas sys_rtas
301256 32 sys_debug_setcontext sys_debug_setcontext sys_ni_syscall
302256 64 sys_debug_setcontext sys_ni_syscall
303256 spu sys_debug_setcontext sys_ni_syscall
304# 257 reserved for vserver
305258 nospu migrate_pages sys_migrate_pages compat_sys_migrate_pages
306259 nospu mbind sys_mbind compat_sys_mbind
307260 nospu get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
308261 nospu set_mempolicy sys_set_mempolicy compat_sys_set_mempolicy
309262 nospu mq_open sys_mq_open compat_sys_mq_open
310263 nospu mq_unlink sys_mq_unlink
311264 nospu mq_timedsend sys_mq_timedsend compat_sys_mq_timedsend
312265 nospu mq_timedreceive sys_mq_timedreceive compat_sys_mq_timedreceive
313266 nospu mq_notify sys_mq_notify compat_sys_mq_notify
314267 nospu mq_getsetattr sys_mq_getsetattr compat_sys_mq_getsetattr
315268 nospu kexec_load sys_kexec_load compat_sys_kexec_load
316269 nospu add_key sys_add_key
317270 nospu request_key sys_request_key
318271 nospu keyctl sys_keyctl compat_sys_keyctl
319272 nospu waitid sys_waitid compat_sys_waitid
320273 nospu ioprio_set sys_ioprio_set
321274 nospu ioprio_get sys_ioprio_get
322275 nospu inotify_init sys_inotify_init
323276 nospu inotify_add_watch sys_inotify_add_watch
324277 nospu inotify_rm_watch sys_inotify_rm_watch
325278 nospu spu_run sys_spu_run
326279 nospu spu_create sys_spu_create
327280 nospu pselect6 sys_pselect6 compat_sys_pselect6
328281 nospu ppoll sys_ppoll compat_sys_ppoll
329282 common unshare sys_unshare
330283 common splice sys_splice
331284 common tee sys_tee
332285 common vmsplice sys_vmsplice compat_sys_vmsplice
333286 common openat sys_openat compat_sys_openat
334287 common mkdirat sys_mkdirat
335288 common mknodat sys_mknodat
336289 common fchownat sys_fchownat
337290 common futimesat sys_futimesat compat_sys_futimesat
338291 32 fstatat64 sys_fstatat64
339291 64 newfstatat sys_newfstatat
340291 spu newfstatat sys_newfstatat
341292 common unlinkat sys_unlinkat
342293 common renameat sys_renameat
343294 common linkat sys_linkat
344295 common symlinkat sys_symlinkat
345296 common readlinkat sys_readlinkat
346297 common fchmodat sys_fchmodat
347298 common faccessat sys_faccessat
348299 common get_robust_list sys_get_robust_list compat_sys_get_robust_list
349300 common set_robust_list sys_set_robust_list compat_sys_set_robust_list
350301 common move_pages sys_move_pages compat_sys_move_pages
351302 common getcpu sys_getcpu
352303 nospu epoll_pwait sys_epoll_pwait compat_sys_epoll_pwait
353304 common utimensat sys_utimensat compat_sys_utimensat
354305 common signalfd sys_signalfd compat_sys_signalfd
355306 common timerfd_create sys_timerfd_create
356307 common eventfd sys_eventfd
357308 common sync_file_range2 sys_sync_file_range2 compat_sys_sync_file_range2
358309 nospu fallocate sys_fallocate compat_sys_fallocate
359310 nospu subpage_prot sys_subpage_prot
360311 common timerfd_settime sys_timerfd_settime compat_sys_timerfd_settime
361312 common timerfd_gettime sys_timerfd_gettime compat_sys_timerfd_gettime
362313 common signalfd4 sys_signalfd4 compat_sys_signalfd4
363314 common eventfd2 sys_eventfd2
364315 common epoll_create1 sys_epoll_create1
365316 common dup3 sys_dup3
366317 common pipe2 sys_pipe2
367318 nospu inotify_init1 sys_inotify_init1
368319 common perf_event_open sys_perf_event_open
369320 common preadv sys_preadv compat_sys_preadv
370321 common pwritev sys_pwritev compat_sys_pwritev
371322 nospu rt_tgsigqueueinfo sys_rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo
372323 nospu fanotify_init sys_fanotify_init
373324 nospu fanotify_mark sys_fanotify_mark compat_sys_fanotify_mark
374325 common prlimit64 sys_prlimit64
375326 common socket sys_socket
376327 common bind sys_bind
377328 common connect sys_connect
378329 common listen sys_listen
379330 common accept sys_accept
380331 common getsockname sys_getsockname
381332 common getpeername sys_getpeername
382333 common socketpair sys_socketpair
383334 common send sys_send
384335 common sendto sys_sendto
385336 common recv sys_recv compat_sys_recv
386337 common recvfrom sys_recvfrom compat_sys_recvfrom
387338 common shutdown sys_shutdown
388339 common setsockopt sys_setsockopt compat_sys_setsockopt
389340 common getsockopt sys_getsockopt compat_sys_getsockopt
390341 common sendmsg sys_sendmsg compat_sys_sendmsg
391342 common recvmsg sys_recvmsg compat_sys_recvmsg
392343 common recvmmsg sys_recvmmsg compat_sys_recvmmsg
393344 common accept4 sys_accept4
394345 common name_to_handle_at sys_name_to_handle_at
395346 common open_by_handle_at sys_open_by_handle_at compat_sys_open_by_handle_at
396347 common clock_adjtime sys_clock_adjtime compat_sys_clock_adjtime
397348 common syncfs sys_syncfs
398349 common sendmmsg sys_sendmmsg compat_sys_sendmmsg
399350 common setns sys_setns
400351 nospu process_vm_readv sys_process_vm_readv compat_sys_process_vm_readv
401352 nospu process_vm_writev sys_process_vm_writev compat_sys_process_vm_writev
402353 nospu finit_module sys_finit_module
403354 nospu kcmp sys_kcmp
404355 common sched_setattr sys_sched_setattr
405356 common sched_getattr sys_sched_getattr
406357 common renameat2 sys_renameat2
407358 common seccomp sys_seccomp
408359 common getrandom sys_getrandom
409360 common memfd_create sys_memfd_create
410361 common bpf sys_bpf
411362 nospu execveat sys_execveat compat_sys_execveat
412363 32 switch_endian sys_ni_syscall
413363 64 switch_endian ppc_switch_endian
414363 spu switch_endian sys_ni_syscall
415364 common userfaultfd sys_userfaultfd
416365 common membarrier sys_membarrier
417378 nospu mlock2 sys_mlock2
418379 nospu copy_file_range sys_copy_file_range
419380 common preadv2 sys_preadv2 compat_sys_preadv2
420381 common pwritev2 sys_pwritev2 compat_sys_pwritev2
421382 nospu kexec_file_load sys_kexec_file_load
422383 nospu statx sys_statx
423384 nospu pkey_alloc sys_pkey_alloc
424385 nospu pkey_free sys_pkey_free
425386 nospu pkey_mprotect sys_pkey_mprotect
426387 nospu rseq sys_rseq
427388 nospu io_pgetevents sys_io_pgetevents compat_sys_io_pgetevents
diff --git a/arch/powerpc/kernel/syscalls/syscallhdr.sh b/arch/powerpc/kernel/syscalls/syscallhdr.sh
new file mode 100644
index 000000000000..c0a9a32937f1
--- /dev/null
+++ b/arch/powerpc/kernel/syscalls/syscallhdr.sh
@@ -0,0 +1,37 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4in="$1"
5out="$2"
6my_abis=`echo "($3)" | tr ',' '|'`
7prefix="$4"
8offset="$5"
9
10fileguard=_UAPI_ASM_POWERPC_`basename "$out" | sed \
11 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
12 -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
13grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
14 printf "#ifndef %s\n" "${fileguard}"
15 printf "#define %s\n" "${fileguard}"
16 printf "\n"
17
18 nxt=0
19 while read nr abi name entry compat ; do
20 if [ -z "$offset" ]; then
21 printf "#define __NR_%s%s\t%s\n" \
22 "${prefix}" "${name}" "${nr}"
23 else
24 printf "#define __NR_%s%s\t(%s + %s)\n" \
25 "${prefix}" "${name}" "${offset}" "${nr}"
26 fi
27 nxt=$((nr+1))
28 done
29
30 printf "\n"
31 printf "#ifdef __KERNEL__\n"
32 printf "#define __NR_syscalls\t%s\n" "${nxt}"
33 printf "#endif\n"
34 printf "\n"
35 printf "#endif /* %s */" "${fileguard}"
36 printf "\n"
37) > "$out"
diff --git a/arch/powerpc/kernel/syscalls/syscalltbl.sh b/arch/powerpc/kernel/syscalls/syscalltbl.sh
new file mode 100644
index 000000000000..fd620490a542
--- /dev/null
+++ b/arch/powerpc/kernel/syscalls/syscalltbl.sh
@@ -0,0 +1,36 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4in="$1"
5out="$2"
6my_abis=`echo "($3)" | tr ',' '|'`
7my_abi="$4"
8offset="$5"
9
10emit() {
11 t_nxt="$1"
12 t_nr="$2"
13 t_entry="$3"
14
15 while [ $t_nxt -lt $t_nr ]; do
16 printf "__SYSCALL(%s,sys_ni_syscall, )\n" "${t_nxt}"
17 t_nxt=$((t_nxt+1))
18 done
19 printf "__SYSCALL(%s,%s, )\n" "${t_nxt}" "${t_entry}"
20}
21
22grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
23 nxt=0
24 if [ -z "$offset" ]; then
25 offset=0
26 fi
27
28 while read nr abi name entry compat ; do
29 if [ "$my_abi" = "c32" ] && [ ! -z "$compat" ]; then
30 emit $((nxt+offset)) $((nr+offset)) $compat
31 else
32 emit $((nxt+offset)) $((nr+offset)) $entry
33 fi
34 nxt=$((nr+1))
35 done
36) > "$out"
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 755dc98a57ae..e8e93c2c7d03 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -457,7 +457,7 @@ static ssize_t __used \
457#define HAS_PPC_PMC_CLASSIC 1 457#define HAS_PPC_PMC_CLASSIC 1
458#define HAS_PPC_PMC_IBM 1 458#define HAS_PPC_PMC_IBM 1
459#define HAS_PPC_PMC_PA6T 1 459#define HAS_PPC_PMC_PA6T 1
460#elif defined(CONFIG_6xx) 460#elif defined(CONFIG_PPC_BOOK3S_32)
461#define HAS_PPC_PMC_CLASSIC 1 461#define HAS_PPC_PMC_CLASSIC 1
462#define HAS_PPC_PMC_IBM 1 462#define HAS_PPC_PMC_IBM 1
463#define HAS_PPC_PMC_G4 1 463#define HAS_PPC_PMC_G4 1
diff --git a/arch/powerpc/kernel/systbl.S b/arch/powerpc/kernel/systbl.S
index 919a32746ede..23265a28740b 100644
--- a/arch/powerpc/kernel/systbl.S
+++ b/arch/powerpc/kernel/systbl.S
@@ -16,28 +16,6 @@
16 16
17#include <asm/ppc_asm.h> 17#include <asm/ppc_asm.h>
18 18
19#ifdef CONFIG_PPC64
20#define SYSCALL(func) .8byte DOTSYM(sys_##func),DOTSYM(sys_##func)
21#define COMPAT_SYS(func) .8byte DOTSYM(sys_##func),DOTSYM(compat_sys_##func)
22#define PPC_SYS(func) .8byte DOTSYM(ppc_##func),DOTSYM(ppc_##func)
23#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(sys_ni_syscall)
24#define SYS32ONLY(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(compat_sys_##func)
25#define PPC64ONLY(func) .8byte DOTSYM(ppc_##func),DOTSYM(sys_ni_syscall)
26#define SYSX(f, f3264, f32) .8byte DOTSYM(f),DOTSYM(f3264)
27#else
28#define SYSCALL(func) .long sys_##func
29#define COMPAT_SYS(func) .long sys_##func
30#define PPC_SYS(func) .long ppc_##func
31#define OLDSYS(func) .long sys_##func
32#define SYS32ONLY(func) .long sys_##func
33#define PPC64ONLY(func) .long sys_ni_syscall
34#define SYSX(f, f3264, f32) .long f32
35#endif
36#define SYSCALL_SPU(func) SYSCALL(func)
37#define COMPAT_SYS_SPU(func) COMPAT_SYS(func)
38#define COMPAT_SPU_NEW(func) COMPAT_SYS(func)
39#define SYSX_SPU(f, f3264, f32) SYSX(f, f3264, f32)
40
41.section .rodata,"a" 19.section .rodata,"a"
42 20
43#ifdef CONFIG_PPC64 21#ifdef CONFIG_PPC64
@@ -46,5 +24,21 @@
46 24
47.globl sys_call_table 25.globl sys_call_table
48sys_call_table: 26sys_call_table:
27#ifdef CONFIG_PPC64
28#define __SYSCALL(nr, entry, nargs) .8byte DOTSYM(entry)
29#include <asm/syscall_table_64.h>
30#undef __SYSCALL
31#else
32#define __SYSCALL(nr, entry, nargs) .long entry
33#include <asm/syscall_table_32.h>
34#undef __SYSCALL
35#endif
49 36
50#include <asm/systbl.h> 37#ifdef CONFIG_COMPAT
38.globl compat_sys_call_table
39compat_sys_call_table:
40#define compat_sys_sigsuspend sys_sigsuspend
41#define __SYSCALL(nr, entry, nargs) .8byte DOTSYM(entry)
42#include <asm/syscall_table_c32.h>
43#undef __SYSCALL
44#endif
diff --git a/arch/powerpc/kernel/systbl_chk.c b/arch/powerpc/kernel/systbl_chk.c
deleted file mode 100644
index 4653258722ac..000000000000
--- a/arch/powerpc/kernel/systbl_chk.c
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * This file, when run through CPP produces a list of syscall numbers
3 * in the order of systbl.h. That way we can check for gaps and syscalls
4 * that are out of order.
5 *
6 * Unfortunately, we cannot check for the correct ordering of entries
7 * using SYSX().
8 *
9 * Copyright © IBM Corporation
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16#include <asm/unistd.h>
17
18#define SYSCALL(func) __NR_##func
19#define COMPAT_SYS(func) __NR_##func
20#define PPC_SYS(func) __NR_##func
21#ifdef CONFIG_PPC64
22#define OLDSYS(func) -1
23#define SYS32ONLY(func) -1
24#define PPC64ONLY(func) __NR_##func
25#else
26#define OLDSYS(func) __NR_old##func
27#define SYS32ONLY(func) __NR_##func
28#define PPC64ONLY(func) -1
29#endif
30#define SYSX(f, f3264, f32) -1
31
32#define SYSCALL_SPU(func) SYSCALL(func)
33#define COMPAT_SYS_SPU(func) COMPAT_SYS(func)
34#define COMPAT_SPU_NEW(func) COMPAT_SYS(_new##func)
35#define SYSX_SPU(f, f3264, f32) SYSX(f, f3264, f32)
36
37/* Just insert a marker for ni_syscalls */
38#define __NR_ni_syscall -1
39
40/*
41 * These are the known exceptions.
42 * Hopefully, there will be no more.
43 */
44#define __NR_llseek __NR__llseek
45#undef __NR_umount
46#define __NR_umount __NR_umount2
47#define __NR_old_getrlimit __NR_getrlimit
48#define __NR_newstat __NR_stat
49#define __NR_newlstat __NR_lstat
50#define __NR_newfstat __NR_fstat
51#define __NR_newuname __NR_uname
52#define __NR_sysctl __NR__sysctl
53#define __NR_olddebug_setcontext __NR_sys_debug_setcontext
54
55/* We call sys_ugetrlimit for syscall number __NR_getrlimit */
56#define getrlimit ugetrlimit
57
58START_TABLE
59#include <asm/systbl.h>
60END_TABLE NR_syscalls
diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
index b65c8a34ad6e..29746dc28df5 100644
--- a/arch/powerpc/kernel/trace/ftrace.c
+++ b/arch/powerpc/kernel/trace/ftrace.c
@@ -107,7 +107,7 @@ static int is_b_op(unsigned int op)
107 107
108static unsigned long find_bl_target(unsigned long ip, unsigned int op) 108static unsigned long find_bl_target(unsigned long ip, unsigned int op)
109{ 109{
110 static int offset; 110 int offset;
111 111
112 offset = (op & 0x03fffffc); 112 offset = (op & 0x03fffffc);
113 /* make it signed */ 113 /* make it signed */
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 9a86572db1ef..00af2c4febf4 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1434,7 +1434,8 @@ void program_check_exception(struct pt_regs *regs)
1434 goto bail; 1434 goto bail;
1435 } else { 1435 } else {
1436 printk(KERN_EMERG "Unexpected TM Bad Thing exception " 1436 printk(KERN_EMERG "Unexpected TM Bad Thing exception "
1437 "at %lx (msr 0x%lx)\n", regs->nip, regs->msr); 1437 "at %lx (msr 0x%lx) tm_scratch=%llx\n",
1438 regs->nip, regs->msr, get_paca()->tm_scratch);
1438 die("Unrecoverable exception", regs, SIGABRT); 1439 die("Unrecoverable exception", regs, SIGABRT);
1439 } 1440 }
1440 } 1441 }
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 65b3bdb99f0b..7725a9714736 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -671,15 +671,18 @@ static void __init vdso_setup_syscall_map(void)
671{ 671{
672 unsigned int i; 672 unsigned int i;
673 extern unsigned long *sys_call_table; 673 extern unsigned long *sys_call_table;
674#ifdef CONFIG_PPC64
675 extern unsigned long *compat_sys_call_table;
676#endif
674 extern unsigned long sys_ni_syscall; 677 extern unsigned long sys_ni_syscall;
675 678
676 679
677 for (i = 0; i < NR_syscalls; i++) { 680 for (i = 0; i < NR_syscalls; i++) {
678#ifdef CONFIG_PPC64 681#ifdef CONFIG_PPC64
679 if (sys_call_table[i*2] != sys_ni_syscall) 682 if (sys_call_table[i] != sys_ni_syscall)
680 vdso_data->syscall_map_64[i >> 5] |= 683 vdso_data->syscall_map_64[i >> 5] |=
681 0x80000000UL >> (i & 0x1f); 684 0x80000000UL >> (i & 0x1f);
682 if (sys_call_table[i*2+1] != sys_ni_syscall) 685 if (compat_sys_call_table[i] != sys_ni_syscall)
683 vdso_data->syscall_map_32[i >> 5] |= 686 vdso_data->syscall_map_32[i >> 5] |=
684 0x80000000UL >> (i & 0x1f); 687 0x80000000UL >> (i & 0x1f);
685#else /* CONFIG_PPC64 */ 688#else /* CONFIG_PPC64 */
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 434581bcd5b4..ad1c77f71f54 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -170,6 +170,14 @@ SECTIONS
170 } 170 }
171#endif /* CONFIG_PPC_BARRIER_NOSPEC */ 171#endif /* CONFIG_PPC_BARRIER_NOSPEC */
172 172
173#ifdef CONFIG_PPC_FSL_BOOK3E
174 . = ALIGN(8);
175 __spec_btb_flush_fixup : AT(ADDR(__spec_btb_flush_fixup) - LOAD_OFFSET) {
176 __start__btb_flush_fixup = .;
177 *(__btb_flush_fixup)
178 __stop__btb_flush_fixup = .;
179 }
180#endif
173 EXCEPTION_TABLE(0) 181 EXCEPTION_TABLE(0)
174 182
175 NOTES :kernel :notes 183 NOTES :kernel :notes
@@ -206,12 +214,6 @@ SECTIONS
206 214
207 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { 215 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
208 INIT_DATA 216 INIT_DATA
209 __vtop_table_begin = .;
210 KEEP(*(.vtop_fixup));
211 __vtop_table_end = .;
212 __ptov_table_begin = .;
213 KEEP(*(.ptov_fixup));
214 __ptov_table_end = .;
215 } 217 }
216 218
217 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { 219 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
@@ -308,6 +310,10 @@ SECTIONS
308#ifdef CONFIG_PPC32 310#ifdef CONFIG_PPC32
309 .data : AT(ADDR(.data) - LOAD_OFFSET) { 311 .data : AT(ADDR(.data) - LOAD_OFFSET) {
310 DATA_DATA 312 DATA_DATA
313#ifdef CONFIG_UBSAN
314 *(.data..Lubsan_data*)
315 *(.data..Lubsan_type*)
316#endif
311 *(.data.rel*) 317 *(.data.rel*)
312 *(SDATA_MAIN) 318 *(SDATA_MAIN)
313 *(.sdata2) 319 *(.sdata2)