aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-02-07 14:33:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-07 14:33:08 -0500
commit413879a10b0b0eb563a23c4df896773b2d9413f9 (patch)
tree6bf6664b45b28148087fb6b50c2d20bbc8d13d19
parent0bd2afc74808389591894dd7c7c83952006a1283 (diff)
parent4889dec6c87d90619cc1e8436327b91f4bb0e467 (diff)
Merge tag 'riscv-for-linus-4.16-merge_window' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux
Pull RISC-V updates from Palmer Dabbelt: "This contains the fixes we'd like to target for the 4.16 merge window. It's not as much as I was originally hoping to do but between glibc, the chip, and FOSDEM there just wasn't enough time to get everything put together. As such, this merge window is essentially just going to be small changes. This includes mostly cleanups: - A build fix failure to the audit test cases. RISC-V doesn't have renameat because the generic syscall ABI moved to renameat2 by the time of our port. The syscall audit test cases don't understand this, so I added a trivial fix. This went through mailing list review during the 4.15 merge window, but nobody has picked it up so I think it's best to just do this here. - The removal of our command-line argument processing code. The "mem_end" stuff was broken and the rest duplicated generic device tree code. The generic code was already being called. - Some unused/redundant code has been removed, including __ARCH_HAVE_MMU, current_pgdir, and the initialization of init_mm.pgd. - SUM is disabled upon taking a trap, which means that user memory is protected during traps taking inside copy_{to,from}_user(). - The sptbr CSR has been renamed to satp in C code. We haven't changed the assembly code in order to maintain compatibility with binutils 2.29, which doesn't understand the new name. Additionally, we're adding some new features: - Basic ftrace support, thanks to Alan Kao! - Support for ZONE_DMA32. This is necessary for all the normal reasons, but also to deal with a deficiency in the Xilinx PCIe controller we're using on our FPGA-based systems. While the ZONE_DMA32 addition should be sufficient for most uses, it doesn't complete the fix for the Xilinx controller. - TLB shootdowns now only target the harts where they're necessary, instead of applying to all harts in the system. These patches have all been sitting on our linux-next branch for a while now. Due to time constraints this is all I feel comfortable submitting during the 4.16 merge window, hopefully we'll do better next time!" [ Note to self: "harts" is RISC-V speak for "hardware threads". I had to look that up. - Linus ] * tag 'riscv-for-linus-4.16-merge_window' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux: riscv: inline set_pgdir into its only caller riscv: rename sptbr to satp riscv: don't read back satp in paging_init riscv: remove the unused current_pgdir function riscv: add ZONE_DMA32 RISC-V: Limit the scope of TLB shootdowns riscv: disable SUM in the exception handler riscv: remove redundant unlikely() riscv: remove unused __ARCH_HAVE_MMU define riscv/ftrace: Add basic support RISC-V: Remove mem_end command line processing RISC-V: Remove duplicate command-line parsing logic audit: Avoid build failures on systems without renameat
-rw-r--r--arch/riscv/Kconfig10
-rw-r--r--arch/riscv/include/asm/Kbuild1
-rw-r--r--arch/riscv/include/asm/csr.h14
-rw-r--r--arch/riscv/include/asm/ftrace.h10
-rw-r--r--arch/riscv/include/asm/mmu_context.h17
-rw-r--r--arch/riscv/include/asm/tlbflush.h20
-rw-r--r--arch/riscv/include/asm/unistd.h1
-rw-r--r--arch/riscv/kernel/Makefile7
-rw-r--r--arch/riscv/kernel/entry.S9
-rw-r--r--arch/riscv/kernel/ftrace.c41
-rw-r--r--arch/riscv/kernel/head.S6
-rw-r--r--arch/riscv/kernel/mcount.S126
-rw-r--r--arch/riscv/kernel/setup.c44
-rw-r--r--arch/riscv/kernel/vdso.c2
-rw-r--r--arch/riscv/mm/fault.c4
-rw-r--r--arch/riscv/mm/init.c12
-rw-r--r--include/asm-generic/audit_dir_write.h2
17 files changed, 250 insertions, 76 deletions
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 865e14f50c14..b6722c246d9c 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -22,6 +22,7 @@ config RISCV
22 select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A 22 select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A
23 select ARCH_WANT_OPTIONAL_GPIOLIB 23 select ARCH_WANT_OPTIONAL_GPIOLIB
24 select HAVE_MEMBLOCK 24 select HAVE_MEMBLOCK
25 select HAVE_MEMBLOCK_NODE_MAP
25 select HAVE_DMA_API_DEBUG 26 select HAVE_DMA_API_DEBUG
26 select HAVE_DMA_CONTIGUOUS 27 select HAVE_DMA_CONTIGUOUS
27 select HAVE_GENERIC_DMA_COHERENT 28 select HAVE_GENERIC_DMA_COHERENT
@@ -43,6 +44,10 @@ config MMU
43config ARCH_PHYS_ADDR_T_64BIT 44config ARCH_PHYS_ADDR_T_64BIT
44 def_bool y 45 def_bool y
45 46
47config ZONE_DMA32
48 bool
49 default y
50
46config ARCH_DMA_ADDR_T_64BIT 51config ARCH_DMA_ADDR_T_64BIT
47 def_bool y 52 def_bool y
48 53
@@ -55,6 +60,9 @@ config PAGE_OFFSET
55config STACKTRACE_SUPPORT 60config STACKTRACE_SUPPORT
56 def_bool y 61 def_bool y
57 62
63config TRACE_IRQFLAGS_SUPPORT
64 def_bool y
65
58config RWSEM_GENERIC_SPINLOCK 66config RWSEM_GENERIC_SPINLOCK
59 def_bool y 67 def_bool y
60 68
@@ -107,6 +115,8 @@ config ARCH_RV64I
107 bool "RV64I" 115 bool "RV64I"
108 select CPU_SUPPORTS_64BIT_KERNEL 116 select CPU_SUPPORTS_64BIT_KERNEL
109 select 64BIT 117 select 64BIT
118 select HAVE_FUNCTION_TRACER
119 select HAVE_FUNCTION_GRAPH_TRACER
110 120
111endchoice 121endchoice
112 122
diff --git a/arch/riscv/include/asm/Kbuild b/arch/riscv/include/asm/Kbuild
index 681ac0d09314..4286a5f83876 100644
--- a/arch/riscv/include/asm/Kbuild
+++ b/arch/riscv/include/asm/Kbuild
@@ -12,7 +12,6 @@ generic-y += errno.h
12generic-y += exec.h 12generic-y += exec.h
13generic-y += fb.h 13generic-y += fb.h
14generic-y += fcntl.h 14generic-y += fcntl.h
15generic-y += ftrace.h
16generic-y += futex.h 15generic-y += futex.h
17generic-y += hardirq.h 16generic-y += hardirq.h
18generic-y += hash.h 17generic-y += hash.h
diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h
index 3c7a2c97e377..421fa3585798 100644
--- a/arch/riscv/include/asm/csr.h
+++ b/arch/riscv/include/asm/csr.h
@@ -40,15 +40,15 @@
40#define SR_SD _AC(0x8000000000000000, UL) /* FS/XS dirty */ 40#define SR_SD _AC(0x8000000000000000, UL) /* FS/XS dirty */
41#endif 41#endif
42 42
43/* SPTBR flags */ 43/* SATP flags */
44#if __riscv_xlen == 32 44#if __riscv_xlen == 32
45#define SPTBR_PPN _AC(0x003FFFFF, UL) 45#define SATP_PPN _AC(0x003FFFFF, UL)
46#define SPTBR_MODE_32 _AC(0x80000000, UL) 46#define SATP_MODE_32 _AC(0x80000000, UL)
47#define SPTBR_MODE SPTBR_MODE_32 47#define SATP_MODE SATP_MODE_32
48#else 48#else
49#define SPTBR_PPN _AC(0x00000FFFFFFFFFFF, UL) 49#define SATP_PPN _AC(0x00000FFFFFFFFFFF, UL)
50#define SPTBR_MODE_39 _AC(0x8000000000000000, UL) 50#define SATP_MODE_39 _AC(0x8000000000000000, UL)
51#define SPTBR_MODE SPTBR_MODE_39 51#define SATP_MODE SATP_MODE_39
52#endif 52#endif
53 53
54/* Interrupt Enable and Interrupt Pending flags */ 54/* Interrupt Enable and Interrupt Pending flags */
diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h
new file mode 100644
index 000000000000..66d4175eb13e
--- /dev/null
+++ b/arch/riscv/include/asm/ftrace.h
@@ -0,0 +1,10 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (C) 2017 Andes Technology Corporation */
3
4/*
5 * The graph frame test is not possible if CONFIG_FRAME_POINTER is not enabled.
6 * Check arch/riscv/kernel/mcount.S for detail.
7 */
8#if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_FRAME_POINTER)
9#define HAVE_FUNCTION_GRAPH_FP_TEST
10#endif
diff --git a/arch/riscv/include/asm/mmu_context.h b/arch/riscv/include/asm/mmu_context.h
index 97424834dce2..336d60ec5698 100644
--- a/arch/riscv/include/asm/mmu_context.h
+++ b/arch/riscv/include/asm/mmu_context.h
@@ -39,16 +39,6 @@ static inline void destroy_context(struct mm_struct *mm)
39{ 39{
40} 40}
41 41
42static inline pgd_t *current_pgdir(void)
43{
44 return pfn_to_virt(csr_read(sptbr) & SPTBR_PPN);
45}
46
47static inline void set_pgdir(pgd_t *pgd)
48{
49 csr_write(sptbr, virt_to_pfn(pgd) | SPTBR_MODE);
50}
51
52/* 42/*
53 * When necessary, performs a deferred icache flush for the given MM context, 43 * When necessary, performs a deferred icache flush for the given MM context,
54 * on the local CPU. RISC-V has no direct mechanism for instruction cache 44 * on the local CPU. RISC-V has no direct mechanism for instruction cache
@@ -93,7 +83,12 @@ static inline void switch_mm(struct mm_struct *prev,
93 cpumask_clear_cpu(cpu, mm_cpumask(prev)); 83 cpumask_clear_cpu(cpu, mm_cpumask(prev));
94 cpumask_set_cpu(cpu, mm_cpumask(next)); 84 cpumask_set_cpu(cpu, mm_cpumask(next));
95 85
96 set_pgdir(next->pgd); 86 /*
87 * Use the old spbtr name instead of using the current satp
88 * name to support binutils 2.29 which doesn't know about the
89 * privileged ISA 1.10 yet.
90 */
91 csr_write(sptbr, virt_to_pfn(next->pgd) | SATP_MODE);
97 local_flush_tlb_all(); 92 local_flush_tlb_all();
98 93
99 flush_icache_deferred(next); 94 flush_icache_deferred(next);
diff --git a/arch/riscv/include/asm/tlbflush.h b/arch/riscv/include/asm/tlbflush.h
index 7b9c24ebdf52..7b209aec355d 100644
--- a/arch/riscv/include/asm/tlbflush.h
+++ b/arch/riscv/include/asm/tlbflush.h
@@ -36,7 +36,14 @@ static inline void local_flush_tlb_page(unsigned long addr)
36 36
37#define flush_tlb_all() local_flush_tlb_all() 37#define flush_tlb_all() local_flush_tlb_all()
38#define flush_tlb_page(vma, addr) local_flush_tlb_page(addr) 38#define flush_tlb_page(vma, addr) local_flush_tlb_page(addr)
39#define flush_tlb_range(vma, start, end) local_flush_tlb_all() 39
40static inline void flush_tlb_range(struct vm_area_struct *vma,
41 unsigned long start, unsigned long end)
42{
43 local_flush_tlb_all();
44}
45
46#define flush_tlb_mm(mm) flush_tlb_all()
40 47
41#else /* CONFIG_SMP */ 48#else /* CONFIG_SMP */
42 49
@@ -45,16 +52,13 @@ static inline void local_flush_tlb_page(unsigned long addr)
45#define flush_tlb_all() sbi_remote_sfence_vma(0, 0, -1) 52#define flush_tlb_all() sbi_remote_sfence_vma(0, 0, -1)
46#define flush_tlb_page(vma, addr) flush_tlb_range(vma, addr, 0) 53#define flush_tlb_page(vma, addr) flush_tlb_range(vma, addr, 0)
47#define flush_tlb_range(vma, start, end) \ 54#define flush_tlb_range(vma, start, end) \
48 sbi_remote_sfence_vma(0, start, (end) - (start)) 55 sbi_remote_sfence_vma(mm_cpumask((vma)->vm_mm)->bits, \
56 start, (end) - (start))
57#define flush_tlb_mm(mm) \
58 sbi_remote_sfence_vma(mm_cpumask(mm)->bits, 0, -1)
49 59
50#endif /* CONFIG_SMP */ 60#endif /* CONFIG_SMP */
51