diff options
-rw-r--r-- | arch/riscv/Kconfig | 10 | ||||
-rw-r--r-- | arch/riscv/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/riscv/include/asm/csr.h | 14 | ||||
-rw-r--r-- | arch/riscv/include/asm/ftrace.h | 10 | ||||
-rw-r--r-- | arch/riscv/include/asm/mmu_context.h | 17 | ||||
-rw-r--r-- | arch/riscv/include/asm/tlbflush.h | 20 | ||||
-rw-r--r-- | arch/riscv/include/asm/unistd.h | 1 | ||||
-rw-r--r-- | arch/riscv/kernel/Makefile | 7 | ||||
-rw-r--r-- | arch/riscv/kernel/entry.S | 9 | ||||
-rw-r--r-- | arch/riscv/kernel/ftrace.c | 41 | ||||
-rw-r--r-- | arch/riscv/kernel/head.S | 6 | ||||
-rw-r--r-- | arch/riscv/kernel/mcount.S | 126 | ||||
-rw-r--r-- | arch/riscv/kernel/setup.c | 44 | ||||
-rw-r--r-- | arch/riscv/kernel/vdso.c | 2 | ||||
-rw-r--r-- | arch/riscv/mm/fault.c | 4 | ||||
-rw-r--r-- | arch/riscv/mm/init.c | 12 | ||||
-rw-r--r-- | include/asm-generic/audit_dir_write.h | 2 |
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 | |||
43 | config ARCH_PHYS_ADDR_T_64BIT | 44 | config ARCH_PHYS_ADDR_T_64BIT |
44 | def_bool y | 45 | def_bool y |
45 | 46 | ||
47 | config ZONE_DMA32 | ||
48 | bool | ||
49 | default y | ||
50 | |||
46 | config ARCH_DMA_ADDR_T_64BIT | 51 | config ARCH_DMA_ADDR_T_64BIT |
47 | def_bool y | 52 | def_bool y |
48 | 53 | ||
@@ -55,6 +60,9 @@ config PAGE_OFFSET | |||
55 | config STACKTRACE_SUPPORT | 60 | config STACKTRACE_SUPPORT |
56 | def_bool y | 61 | def_bool y |
57 | 62 | ||
63 | config TRACE_IRQFLAGS_SUPPORT | ||
64 | def_bool y | ||
65 | |||
58 | config RWSEM_GENERIC_SPINLOCK | 66 | config 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 | ||
111 | endchoice | 121 | endchoice |
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 | |||
12 | generic-y += exec.h | 12 | generic-y += exec.h |
13 | generic-y += fb.h | 13 | generic-y += fb.h |
14 | generic-y += fcntl.h | 14 | generic-y += fcntl.h |
15 | generic-y += ftrace.h | ||
16 | generic-y += futex.h | 15 | generic-y += futex.h |
17 | generic-y += hardirq.h | 16 | generic-y += hardirq.h |
18 | generic-y += hash.h | 17 | generic-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 | ||
42 | static inline pgd_t *current_pgdir(void) | ||
43 | { | ||
44 | return pfn_to_virt(csr_read(sptbr) & SPTBR_PPN); | ||
45 | } | ||
46 | |||
47 | static 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 | |
40 | static 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 | 61 | ||
52 | /* Flush the TLB entries of the specified mm context */ | ||
53 | static inline void flush_tlb_mm(struct mm_struct *mm) | ||
54 | { | ||
55 | flush_tlb_all(); | ||
56 | } | ||
57 | |||
58 | /* Flush a range of kernel pages */ | 62 | /* Flush a range of kernel pages */ |
59 | static inline void flush_tlb_kernel_range(unsigned long start, | 63 | static inline void flush_tlb_kernel_range(unsigned long start, |
60 | unsigned long end) | 64 | unsigned long end) |
diff --git a/arch/riscv/include/asm/unistd.h b/arch/riscv/include/asm/unistd.h index 2f704a5c4196..080fb28061de 100644 --- a/arch/riscv/include/asm/unistd.h +++ b/arch/riscv/include/asm/unistd.h | |||
@@ -11,7 +11,6 @@ | |||
11 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define __ARCH_HAVE_MMU | ||
15 | #define __ARCH_WANT_SYS_CLONE | 14 | #define __ARCH_WANT_SYS_CLONE |
16 | #include <uapi/asm/unistd.h> | 15 | #include <uapi/asm/unistd.h> |
17 | #include <uapi/asm/syscalls.h> | 16 | #include <uapi/asm/syscalls.h> |
diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index ab8baf7bd142..196f62ffc428 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile | |||
@@ -2,6 +2,11 @@ | |||
2 | # Makefile for the RISC-V Linux kernel | 2 | # Makefile for the RISC-V Linux kernel |
3 | # | 3 | # |
4 | 4 | ||
5 | ifdef CONFIG_FTRACE | ||
6 | CFLAGS_REMOVE_ftrace.o = -pg | ||
7 | CFLAGS_REMOVE_setup.o = -pg | ||
8 | endif | ||
9 | |||
5 | extra-y += head.o | 10 | extra-y += head.o |
6 | extra-y += vmlinux.lds | 11 | extra-y += vmlinux.lds |
7 | 12 | ||
@@ -29,5 +34,7 @@ CFLAGS_setup.o := -mcmodel=medany | |||
29 | obj-$(CONFIG_SMP) += smpboot.o | 34 | obj-$(CONFIG_SMP) += smpboot.o |
30 | obj-$(CONFIG_SMP) += smp.o | 35 | obj-$(CONFIG_SMP) += smp.o |
31 | obj-$(CONFIG_MODULES) += module.o | 36 | obj-$(CONFIG_MODULES) += module.o |
37 | obj-$(CONFIG_FUNCTION_TRACER) += mcount.o | ||
38 | obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o | ||
32 | 39 | ||
33 | clean: | 40 | clean: |
diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S index 7404ec222406..87fc045be51f 100644 --- a/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S | |||
@@ -78,10 +78,13 @@ _save_context: | |||
78 | REG_S x31, PT_T6(sp) | 78 | REG_S x31, PT_T6(sp) |
79 | 79 | ||
80 | /* | 80 | /* |
81 | * Disable FPU to detect illegal usage of | 81 | * Disable user-mode memory access as it should only be set in the |
82 | * floating point in kernel space | 82 | * actual user copy routines. |
83 | * | ||
84 | * Disable the FPU to detect illegal usage of floating point in kernel | ||
85 | * space. | ||
83 | */ | 86 | */ |
84 | li t0, SR_FS | 87 | li t0, SR_SUM | SR_FS |
85 | 88 | ||
86 | REG_L s0, TASK_TI_USER_SP(tp) | 89 | REG_L s0, TASK_TI_USER_SP(tp) |
87 | csrrc s1, sstatus, t0 | 90 | csrrc s1, sstatus, t0 |
diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c new file mode 100644 index 000000000000..d0de68d144cb --- /dev/null +++ b/arch/riscv/kernel/ftrace.c | |||
@@ -0,0 +1,41 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | /* | ||
3 | * Copyright (C) 2013 Linaro Limited | ||
4 | * Author: AKASHI Takahiro <takahiro.akashi@linaro.org> | ||
5 | * Copyright (C) 2017 Andes Technology Corporation | ||
6 | */ | ||
7 | |||
8 | #include <linux/ftrace.h> | ||
9 | |||
10 | /* | ||
11 | * Most of this file is copied from arm64. | ||
12 | */ | ||
13 | void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, | ||
14 | unsigned long frame_pointer) | ||
15 | { | ||
16 | unsigned long return_hooker = (unsigned long)&return_to_handler; | ||
17 | unsigned long old; | ||
18 | struct ftrace_graph_ent trace; | ||
19 | int err; | ||
20 | |||
21 | if (unlikely(atomic_read(¤t->tracing_graph_pause))) | ||
22 | return; | ||
23 | |||
24 | /* | ||
25 | * We don't suffer access faults, so no extra fault-recovery assembly | ||
26 | * is needed here. | ||
27 | */ | ||
28 | old = *parent; | ||
29 | |||
30 | trace.func = self_addr; | ||
31 | trace.depth = current->curr_ret_stack + 1; | ||
32 | |||
33 | if (!ftrace_graph_entry(&trace)) | ||
34 | return; | ||
35 | |||
36 | err = ftrace_push_return_trace(old, self_addr, &trace.depth, | ||
37 | frame_pointer, NULL); | ||
38 | if (err == -EBUSY) | ||
39 | return; | ||
40 | *parent = return_hooker; | ||
41 | } | ||
diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 78f670d70133..226eeb190f90 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S | |||
@@ -74,15 +74,15 @@ relocate: | |||
74 | sub a1, a1, a0 | 74 | sub a1, a1, a0 |
75 | add ra, ra, a1 | 75 | add ra, ra, a1 |
76 | 76 | ||
77 | /* Point stvec to virtual address of intruction after sptbr write */ | 77 | /* Point stvec to virtual address of intruction after satp write */ |
78 | la a0, 1f | 78 | la a0, 1f |
79 | add a0, a0, a1 | 79 | add a0, a0, a1 |
80 | csrw stvec, a0 | 80 | csrw stvec, a0 |
81 | 81 | ||
82 | /* Compute sptbr for kernel page tables, but don't load it yet */ | 82 | /* Compute satp for kernel page tables, but don't load it yet */ |
83 | la a2, swapper_pg_dir | 83 | la a2, swapper_pg_dir |
84 | srl a2, a2, PAGE_SHIFT | 84 | srl a2, a2, PAGE_SHIFT |
85 | li a1, SPTBR_MODE | 85 | li a1, SATP_MODE |
86 | or a2, a2, a1 | 86 | or a2, a2, a1 |
87 | 87 | ||
88 | /* | 88 | /* |
diff --git a/arch/riscv/kernel/mcount.S b/arch/riscv/kernel/mcount.S new file mode 100644 index 000000000000..c46a778627be --- /dev/null +++ b/arch/riscv/kernel/mcount.S | |||
@@ -0,0 +1,126 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | /* Copyright (C) 2017 Andes Technology Corporation */ | ||
3 | |||
4 | #include <linux/init.h> | ||
5 | #include <linux/linkage.h> | ||
6 | #include <asm/asm.h> | ||
7 | #include <asm/csr.h> | ||
8 | #include <asm/unistd.h> | ||
9 | #include <asm/thread_info.h> | ||
10 | #include <asm/asm-offsets.h> | ||
11 | #include <asm-generic/export.h> | ||
12 | #include <asm/ftrace.h> | ||
13 | |||
14 | .text | ||
15 | |||
16 | .macro SAVE_ABI_STATE | ||
17 | addi sp, sp, -16 | ||
18 | sd s0, 0(sp) | ||
19 | sd ra, 8(sp) | ||
20 | addi s0, sp, 16 | ||
21 | .endm | ||
22 | |||
23 | /* | ||
24 | * The call to ftrace_return_to_handler would overwrite the return | ||
25 | * register if a0 was not saved. | ||
26 | */ | ||
27 | .macro SAVE_RET_ABI_STATE | ||
28 | addi sp, sp, -32 | ||
29 | sd s0, 16(sp) | ||
30 | sd ra, 24(sp) | ||
31 | sd a0, 8(sp) | ||
32 | addi s0, sp, 32 | ||
33 | .endm | ||
34 | |||
35 | .macro STORE_ABI_STATE | ||
36 | ld ra, 8(sp) | ||
37 | ld s0, 0(sp) | ||
38 | addi sp, sp, 16 | ||
39 | .endm | ||
40 | |||
41 | .macro STORE_RET_ABI_STATE | ||
42 | ld ra, 24(sp) | ||
43 | ld s0, 16(sp) | ||
44 | ld a0, 8(sp) | ||
45 | addi sp, sp, 32 | ||
46 | .endm | ||
47 | |||
48 | ENTRY(ftrace_stub) | ||
49 | ret | ||
50 | ENDPROC(ftrace_stub) | ||
51 | |||
52 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | ||
53 | ENTRY(return_to_handler) | ||
54 | /* | ||
55 | * On implementing the frame point test, the ideal way is to compare the | ||
56 | * s0 (frame pointer, if enabled) on entry and the sp (stack pointer) on return. | ||
57 | * However, the psABI of variable-length-argument functions does not allow this. | ||
58 | * | ||
59 | * So alternatively we check the *old* frame pointer position, that is, the | ||
60 | * value stored in -16(s0) on entry, and the s0 on return. | ||
61 | */ | ||
62 | #ifdef HAVE_FUNCTION_GRAPH_FP_TEST | ||
63 | mv t6, s0 | ||
64 | #endif | ||
65 | SAVE_RET_ABI_STATE | ||
66 | #ifdef HAVE_FUNCTION_GRAPH_FP_TEST | ||
67 | mv a0, t6 | ||
68 | #endif | ||
69 | la t0, ftrace_return_to_handler | ||
70 | jalr t0 | ||
71 | mv a1, a0 | ||
72 | STORE_RET_ABI_STATE | ||
73 | jalr a1 | ||
74 | ENDPROC(return_to_handler) | ||
75 | EXPORT_SYMBOL(return_to_handler) | ||
76 | #endif | ||
77 | |||
78 | ENTRY(_mcount) | ||
79 | la t4, ftrace_stub | ||
80 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | ||
81 | la t0, ftrace_graph_return | ||
82 | ld t1, 0(t0) | ||
83 | bne t1, t4, do_ftrace_graph_caller | ||
84 | |||
85 | la t3, ftrace_graph_entry | ||
86 | ld t2, 0(t3) | ||
87 | la t6, ftrace_graph_entry_stub | ||
88 | bne t2, t6, do_ftrace_graph_caller | ||
89 | #endif | ||
90 | la t3, ftrace_trace_function | ||
91 | ld t5, 0(t3) | ||
92 | bne t5, t4, do_trace | ||
93 | ret | ||
94 | |||
95 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | ||
96 | /* | ||
97 | * A pseudo representation for the function graph tracer: | ||
98 | * prepare_to_return(&ra_to_caller_of_caller, ra_to_caller) | ||
99 | */ | ||
100 | do_ftrace_graph_caller: | ||
101 | addi a0, s0, -8 | ||
102 | mv a1, ra | ||
103 | #ifdef HAVE_FUNCTION_GRAPH_FP_TEST | ||
104 | ld a2, -16(s0) | ||
105 | #endif | ||
106 | SAVE_ABI_STATE | ||
107 | la t0, prepare_ftrace_return | ||
108 | jalr t0 | ||
109 | STORE_ABI_STATE | ||
110 | ret | ||
111 | #endif | ||
112 | |||
113 | /* | ||
114 | * A pseudo representation for the function tracer: | ||
115 | * (*ftrace_trace_function)(ra_to_caller, ra_to_caller_of_caller) | ||
116 | */ | ||
117 | do_trace: | ||
118 | ld a1, -8(s0) | ||
119 | mv a0, ra | ||
120 | |||
121 | SAVE_ABI_STATE | ||
122 | jalr t5 | ||
123 | STORE_ABI_STATE | ||
124 | ret | ||
125 | ENDPROC(_mcount) | ||
126 | EXPORT_SYMBOL(_mcount) | ||
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index cb7b0c63014e..09f7064e898c 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c | |||
@@ -49,10 +49,6 @@ struct screen_info screen_info = { | |||
49 | }; | 49 | }; |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #ifdef CONFIG_CMDLINE_BOOL | ||
53 | static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE; | ||
54 | #endif /* CONFIG_CMDLINE_BOOL */ | ||
55 | |||
56 | unsigned long va_pa_offset; | 52 | unsigned long va_pa_offset; |
57 | EXPORT_SYMBOL(va_pa_offset); | 53 | EXPORT_SYMBOL(va_pa_offset); |
58 | unsigned long pfn_base; | 54 | unsigned long pfn_base; |
@@ -153,25 +149,6 @@ void __init sbi_save(unsigned int hartid, void *dtb) | |||
153 | early_init_dt_scan(__va(dtb)); | 149 | early_init_dt_scan(__va(dtb)); |
154 | } | 150 | } |
155 | 151 | ||
156 | /* | ||
157 | * Allow the user to manually add a memory region (in case DTS is broken); | ||
158 | * "mem_end=nn[KkMmGg]" | ||
159 | */ | ||
160 | static int __init mem_end_override(char *p) | ||
161 | { | ||
162 | resource_size_t base, end; | ||
163 | |||
164 | if (!p) | ||
165 | return -EINVAL; | ||
166 | base = (uintptr_t) __pa(PAGE_OFFSET); | ||
167 | end = memparse(p, &p) & PMD_MASK; | ||
168 | if (end == 0) | ||
169 | return -EINVAL; | ||
170 | memblock_add(base, end - base); | ||
171 | return 0; | ||
172 | } | ||
173 | early_param("mem_end", mem_end_override); | ||
174 | |||
175 | static void __init setup_bootmem(void) | 152 | static void __init setup_bootmem(void) |
176 | { | 153 | { |
177 | struct memblock_region *reg; | 154 | struct memblock_region *reg; |
@@ -204,22 +181,19 @@ static void __init setup_bootmem(void) | |||
204 | early_init_fdt_scan_reserved_mem(); | 181 | early_init_fdt_scan_reserved_mem(); |
205 | memblock_allow_resize(); | 182 | memblock_allow_resize(); |
206 | memblock_dump_all(); | 183 | memblock_dump_all(); |
184 | |||
185 | for_each_memblock(memory, reg) { | ||
186 | unsigned long start_pfn = memblock_region_memory_base_pfn(reg); | ||
187 | unsigned long end_pfn = memblock_region_memory_end_pfn(reg); | ||
188 | |||
189 | memblock_set_node(PFN_PHYS(start_pfn), | ||
190 | PFN_PHYS(end_pfn - start_pfn), | ||
191 | &memblock.memory, 0); | ||
192 | } | ||
207 | } | 193 | } |
208 | 194 | ||
209 | void __init setup_arch(char **cmdline_p) | 195 | void __init setup_arch(char **cmdline_p) |
210 | { | 196 | { |
211 | #ifdef CONFIG_CMDLINE_BOOL | ||
212 | #ifdef CONFIG_CMDLINE_OVERRIDE | ||
213 | strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); | ||
214 | #else | ||
215 | if (builtin_cmdline[0] != '\0') { | ||
216 | /* Append bootloader command line to built-in */ | ||
217 | strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE); | ||
218 | strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE); | ||
219 | strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); | ||
220 | } | ||
221 | #endif /* CONFIG_CMDLINE_OVERRIDE */ | ||
222 | #endif /* CONFIG_CMDLINE_BOOL */ | ||
223 | *cmdline_p = boot_command_line; | 197 | *cmdline_p = boot_command_line; |
224 | 198 | ||
225 | parse_early_param(); | 199 | parse_early_param(); |
diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c index e8a178df8144..582cb153eb24 100644 --- a/arch/riscv/kernel/vdso.c +++ b/arch/riscv/kernel/vdso.c | |||
@@ -74,7 +74,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, | |||
74 | 74 | ||
75 | down_write(&mm->mmap_sem); | 75 | down_write(&mm->mmap_sem); |
76 | vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0); | 76 | vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0); |
77 | if (unlikely(IS_ERR_VALUE(vdso_base))) { | 77 | if (IS_ERR_VALUE(vdso_base)) { |
78 | ret = vdso_base; | 78 | ret = vdso_base; |
79 | goto end; | 79 | goto end; |
80 | } | 80 | } |
diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c index ceebfc29305b..148c98ca9b45 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c | |||
@@ -238,6 +238,10 @@ vmalloc_fault: | |||
238 | * Do _not_ use "tsk->active_mm->pgd" here. | 238 | * Do _not_ use "tsk->active_mm->pgd" here. |
239 | * We might be inside an interrupt in the middle | 239 | * We might be inside an interrupt in the middle |
240 | * of a task switch. | 240 | * of a task switch. |
241 | * | ||
242 | * Note: Use the old spbtr name instead of using the current | ||
243 | * satp name to support binutils 2.29 which doesn't know about | ||
244 | * the privileged ISA 1.10 yet. | ||
241 | */ | 245 | */ |
242 | index = pgd_index(addr); | 246 | index = pgd_index(addr); |
243 | pgd = (pgd_t *)pfn_to_virt(csr_read(sptbr)) + index; | 247 | pgd = (pgd_t *)pfn_to_virt(csr_read(sptbr)) + index; |
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 9f4bee5e51fd..c77df8142be2 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/initrd.h> | 17 | #include <linux/initrd.h> |
18 | #include <linux/memblock.h> | 18 | #include <linux/memblock.h> |
19 | #include <linux/swap.h> | 19 | #include <linux/swap.h> |
20 | #include <linux/sizes.h> | ||
20 | 21 | ||
21 | #include <asm/tlbflush.h> | 22 | #include <asm/tlbflush.h> |
22 | #include <asm/sections.h> | 23 | #include <asm/sections.h> |
@@ -25,11 +26,12 @@ | |||
25 | 26 | ||
26 | static void __init zone_sizes_init(void) | 27 | static void __init zone_sizes_init(void) |
27 | { | 28 | { |
28 | unsigned long zones_size[MAX_NR_ZONES]; | 29 | unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; |
29 | 30 | ||
30 | memset(zones_size, 0, sizeof(zones_size)); | 31 | max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_low_pfn)); |
31 | zones_size[ZONE_NORMAL] = max_mapnr; | 32 | max_zone_pfns[ZONE_NORMAL] = max_low_pfn; |
32 | free_area_init_node(0, zones_size, pfn_base, NULL); | 33 | |
34 | free_area_init_nodes(max_zone_pfns); | ||
33 | } | 35 | } |
34 | 36 | ||
35 | void setup_zero_page(void) | 37 | void setup_zero_page(void) |
@@ -39,8 +41,6 @@ void setup_zero_page(void) | |||
39 | 41 | ||
40 | void __init paging_init(void) | 42 | void __init paging_init(void) |
41 | { | 43 | { |
42 | init_mm.pgd = (pgd_t *)pfn_to_virt(csr_read(sptbr)); | ||
43 | |||
44 | setup_zero_page(); | 44 | setup_zero_page(); |
45 | local_flush_tlb_all(); | 45 | local_flush_tlb_all(); |
46 | zone_sizes_init(); | 46 | zone_sizes_init(); |
diff --git a/include/asm-generic/audit_dir_write.h b/include/asm-generic/audit_dir_write.h index da09fb986459..dd5a9dd7a102 100644 --- a/include/asm-generic/audit_dir_write.h +++ b/include/asm-generic/audit_dir_write.h | |||
@@ -27,7 +27,9 @@ __NR_mknod, | |||
27 | __NR_mkdirat, | 27 | __NR_mkdirat, |
28 | __NR_mknodat, | 28 | __NR_mknodat, |
29 | __NR_unlinkat, | 29 | __NR_unlinkat, |
30 | #ifdef __NR_renameat | ||
30 | __NR_renameat, | 31 | __NR_renameat, |
32 | #endif | ||
31 | __NR_linkat, | 33 | __NR_linkat, |
32 | __NR_symlinkat, | 34 | __NR_symlinkat, |
33 | #endif | 35 | #endif |