riscv: resolve most warnings from sparse
Subsystems (3)
v3 cover riscv: resolve most warnings from sparse
Resolve most warnings from the 'sparse' static analysis tool for the arch/riscv codebase. This makes life easier for us as maintainers, and makes it easier for developers to use static analysis tools on their own changes.
This third version drops the patch that adds one of the __riscv_cmodel* preprocessor definitions, and uses __visible for C functions called only by assembly code - both based on some guidance from Luc Van Oostenryck.
This patch series incorporates some changes based on feedback from Christoph Hellwig <[email protected]> and Luc Van Oostenryck <[email protected]>.
Applies on the current riscv fixes branch that is based on v5.4-rc3.
- Paul
Paul Walmsley (8):
riscv: add prototypes for assembly language functions from entry.S
riscv: add prototypes for assembly language functions from head.S
riscv: init: merge split string literals in preprocessor directive
riscv: add missing prototypes
riscv: mark some code and data as file-static
riscv: add missing header file includes
riscv: fp: add missing __user pointer annotations
riscv: for C functions called only from assembly, mark with __visible
Kernel object size difference:
text data bss dec hex filename
6664246 2136664 312608 9113518 8b0fae vmlinux.rv64.orig
6664178 2136632 312608 9113418 8b0f4a vmlinux.rv64.patched
6444536 1797560 255184 8497280 81a880 vmlinux.rv32.orig
6444492 1797536 255184 8497212 81a83c vmlinux.rv32.patched
arch/riscv/include/asm/irq.h | 6 ++++++ arch/riscv/include/asm/pgtable.h | 2 ++ arch/riscv/include/asm/processor.h | 4 ++++ arch/riscv/include/asm/ptrace.h | 2 ++ arch/riscv/include/asm/smp.h | 2 ++ arch/riscv/include/asm/switch_to.h | 1 + arch/riscv/kernel/cpufeature.c | 1 + arch/riscv/kernel/entry.h | 29 +++++++++++++++++++++++++++++ arch/riscv/kernel/head.h | 21 +++++++++++++++++++++ arch/riscv/kernel/module-sections.c | 1 + arch/riscv/kernel/process.c | 2 ++ arch/riscv/kernel/ptrace.c | 4 ++-- arch/riscv/kernel/reset.c | 1 + arch/riscv/kernel/setup.c | 2 ++ arch/riscv/kernel/signal.c | 6 ++++-- arch/riscv/kernel/smp.c | 2 ++ arch/riscv/kernel/smpboot.c | 3 +++ arch/riscv/kernel/stacktrace.c | 6 ++++-- arch/riscv/kernel/syscall_table.c | 1 + arch/riscv/kernel/time.c | 1 + arch/riscv/kernel/traps.c | 2 ++ arch/riscv/kernel/vdso.c | 3 ++- arch/riscv/mm/context.c | 1 + arch/riscv/mm/fault.c | 2 ++ arch/riscv/mm/init.c | 17 ++++++++++------- arch/riscv/mm/sifive_l2_cache.c | 2 +- 26 files changed, 109 insertions(+), 15 deletions(-) create mode 100644 arch/riscv/kernel/entry.h create mode 100644 arch/riscv/kernel/head.h
Signature · 1 line
2.23.0
PATCH v3 1/8 riscv: add prototypes for assembly language functions from entry.S
Add prototypes for assembly language functions defined in entry.S, and include these prototypes into C source files that call those functions.
This patch resolves the following warnings from sparse:
arch/riscv/kernel/signal.c:32:53: warning: incorrect type in initializer (different address spaces) arch/riscv/kernel/signal.c:45:23: warning: incorrect type in initializer (different address spaces) arch/riscv/kernel/signal.c:59:53: warning: incorrect type in initializer (different address spaces) arch/riscv/kernel/signal.c:69:23: warning: incorrect type in initializer (different address spaces) arch/riscv/kernel/signal.c:89:48: warning: incorrect type in argument 2 (different address spaces) arch/riscv/kernel/signal.c:142:45: warning: incorrect type in argument 2 (different address spaces) arch/riscv/kernel/signal.c:295:17: warning: symbol 'do_notify_resume' was not declared. Should it be static? arch/riscv/kernel/traps.c:91:1: warning: symbol 'do_trap_unknown' was not declared. Should it be static? arch/riscv/kernel/traps.c:93:1: warning: symbol 'do_trap_insn_misaligned' was not declared. Should it be static? arch/riscv/kernel/traps.c:95:1: warning: symbol 'do_trap_insn_fault' was not declared. Should it be static? arch/riscv/kernel/traps.c:97:1: warning: symbol 'do_trap_insn_illegal' was not declared. Should it be static? arch/riscv/kernel/traps.c:99:1: warning: symbol 'do_trap_load_misaligned' was not declared. Should it be static? arch/riscv/kernel/traps.c:101:1: warning: symbol 'do_trap_load_fault' was not declared. Should it be static? arch/riscv/kernel/traps.c:103:1: warning: symbol 'do_trap_store_misaligned' was not declared. Should it be static? arch/riscv/kernel/traps.c:105:1: warning: symbol 'do_trap_store_fault' was not declared. Should it be static? arch/riscv/kernel/traps.c:107:1: warning: symbol 'do_trap_ecall_u' was not declared. Should it be static? arch/riscv/kernel/traps.c:109:1: warning: symbol 'do_trap_ecall_s' was not declared. Should it be static? arch/riscv/kernel/traps.c:111:1: warning: symbol 'do_trap_ecall_m' was not declared. Should it be static? arch/riscv/kernel/traps.c:125:17: warning: symbol 'do_trap_break' was not declared. Should it be static? arch/riscv/kernel/traps.c:163:13: warning: symbol 'trap_init' was not declared. Should it be static?
This change should have no functional impact.
--- arch/riscv/kernel/entry.h | 29 +++++++++++++++++++++++++++++ arch/riscv/kernel/signal.c | 2 ++ arch/riscv/kernel/traps.c | 2 ++ 3 files changed, 33 insertions(+) create mode 100644 arch/riscv/kernel/entry.h
arch/riscv/kernel/entry.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2019 SiFive, Inc. +*/ +#ifndef __ASM_ENTRY_H +#define __ASM_ENTRY_H + +#include <linux/linkage.h> +#include <linux/init.h> + +asmlinkage void do_trap_unknown(struct pt_regs *regs); +asmlinkage void do_trap_insn_misaligned(struct pt_regs *regs); +asmlinkage void do_trap_insn_fault(struct pt_regs *regs); +asmlinkage void do_trap_insn_illegal(struct pt_regs *regs); +asmlinkage void do_trap_load_misaligned(struct pt_regs *regs); +asmlinkage void do_trap_load_fault(struct pt_regs *regs); +asmlinkage void do_trap_store_misaligned(struct pt_regs *regs); +asmlinkage void do_trap_store_fault(struct pt_regs *regs); +asmlinkage void do_trap_ecall_u(struct pt_regs *regs); +asmlinkage void do_trap_ecall_s(struct pt_regs *regs); +asmlinkage void do_trap_ecall_m(struct pt_regs *regs); +asmlinkage void do_trap_break(struct pt_regs *regs); + +asmlinkage void do_notify_resume(struct pt_regs *regs, +unsigned long thread_info_flags); + +void __init trap_init (void ); + +#endif /* __ASM__H */
arch/riscv/kernel/signal.c +2 -0
@@ -17,6 +17,8 @@#include <asm/switch_to.h> #include <asm/csr.h> +#include "entry.h" +#define DEBUG_SIG 0struct rt_sigframe {
arch/riscv/kernel/traps.c +2 -0
@@ -19,6 +19,8 @@#include <asm/ptrace.h> #include <asm/csr.h> +#include "entry.h" +int show_unhandled_signals =1 ; extern asmlinkage void handle_exception(void);
Signature · 7 lines
2.23.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v3 1/8] riscv: add prototypes for assembly language functions from entry.S
Quoted 7 lines · Paul Walmsley
Add prototypes for assembly language functions defined in
entry.S, and include these prototypes into C source files that call those functions.This patch resolves the following warnings from sparse:
arch/riscv/kernel/signal.c:32:53: warning: incorrect type in initializer (different address spaces)
I don't see how adding prototypes will fix an address space warning.
arch/riscv/kernel/entry.h line 22
Quoted 12 lines
arch/riscv/kernel/entry.h new file +12
-0+asmlinkage void do_trap_unknown(struct pt_regs *regs); +asmlinkage void do_trap_insn_misaligned(struct pt_regs *regs); +asmlinkage void do_trap_insn_fault(struct pt_regs *regs); +asmlinkage void do_trap_insn_illegal(struct pt_regs *regs); +asmlinkage void do_trap_load_misaligned(struct pt_regs *regs); +asmlinkage void do_trap_load_fault(struct pt_regs *regs); +asmlinkage void do_trap_store_misaligned(struct pt_regs *regs); +asmlinkage void do_trap_store_fault(struct pt_regs *regs); +asmlinkage void do_trap_ecall_u(struct pt_regs *regs); +asmlinkage void do_trap_ecall_s(struct pt_regs *regs); +asmlinkage void do_trap_ecall_m(struct pt_regs *regs); +asmlinkage void do_trap_break(struct pt_regs *regs);
All these are not defined in entry.S, but called from entry.S.
And as Luc pointed out last time the easiest way to fix the sparse warnings is to add __visible to the definitions of those functions.
Re: [PATCH v3 1/8] riscv: add prototypes for assembly language functions from entry.S
Quoted 10 lines · Christoph Hellwig
Quoted 7 lines · Paul Walmsley
Add prototypes for assembly language functions defined in
entry.S, and include these prototypes into C source files that call those functions.This patch resolves the following warnings from sparse:
arch/riscv/kernel/signal.c:32:53: warning: incorrect type in initializer (different address spaces)I don't see how adding prototypes will fix an address space warning.
You're right - that was a cut-and-paste error on my part.
[ ... ]
Quoted 1 line
All these are not defined in
entry.S, but called fromentry.S.
Indeed. After reviewing this patch closely, I've just dropped it, and used __visible for just about everything. All that is reflected in the v4 series.
Thanks for the review.
- Paul
PATCH v3 2/8 riscv: add prototypes for assembly language functions from head.S
In reply to Paul WalmsleyAdd prototypes for assembly language functions defined in head.S, and include these prototypes into C source files that call those functions.
This patch resolves the following warnings from sparse:
arch/riscv/kernel/setup.c:39:10: warning: symbol 'hart_lottery' was not declared. Should it be static? arch/riscv/kernel/setup.c:42:13: warning: symbol 'parse_dtb' was not declared. Should it be static? arch/riscv/kernel/smpboot.c:33:6: warning: symbol '__cpu_up_stack_pointer' was not declared. Should it be static? arch/riscv/kernel/smpboot.c:34:6: warning: symbol '__cpu_up_task_pointer' was not declared. Should it be static? arch/riscv/kernel/smpboot.c:133:24: warning: symbol 'smp_callin' was not declared. Should it be static? arch/riscv/mm/fault.c:25:17: warning: symbol 'do_page_fault' was not declared. Should it be static?
This change should have no functional impact.
--- arch/riscv/kernel/head.h | 21 +++++++++++++++++++++ arch/riscv/kernel/setup.c | 2 ++ arch/riscv/kernel/smpboot.c | 2 ++ arch/riscv/mm/fault.c | 2 ++ arch/riscv/mm/init.c | 2 ++ 5 files changed, 29 insertions(+) create mode 100644 arch/riscv/kernel/head.h
arch/riscv/kernel/head.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2019 SiFive, Inc. +*/ +#ifndef __ASM_HEAD_H +#define __ASM_HEAD_H + +#include <linux/linkage.h> +#include <linux/init.h> + +extern atomic_t hart_lottery; + +asmlinkage void do_page_fault(struct pt_regs *regs); +asmlinkage void __init setup_vm(uintptr_t dtb_pa); + +extern void *__cpu_up_stack_pointer[]; +extern void *__cpu_up_task_pointer[]; + +void __init parse_dtb (void ); + +#endif /* __ASM_HEAD_H */
arch/riscv/kernel/setup.c +2 -0
@@ -24,6 +24,8 @@#include <asm/tlbflush.h> #include <asm/thread_info.h> +#include "head.h" +#ifdef CONFIG_DUMMY_CONSOLE struct screen_info screen_info = { .orig_video_lines = 30,
arch/riscv/kernel/smpboot.c +2 -0
@@ -30,6 +30,8 @@#include <asm/sections.h> #include <asm/sbi.h> +#include "head.h" +void *__cpu_up_stack_pointer[NR_CPUS ];void *__cpu_up_task_pointer[NR_CPUS ];static DECLARE_COMPLETION (cpu_running);
arch/riscv/mm/fault.c +2 -0
@@ -18,6 +18,8 @@#include <asm/ptrace.h> #include <asm/tlbflush.h> +#include "../kernel/head.h" +/* * This routine handles page faults. It determines the address and the * problem, and then passes it off to one of the appropriate routines.
arch/riscv/mm/init.c +2 -0
@@ -19,6 +19,8 @@#include <asm/pgtable.h> #include <asm/io.h> +#include "../kernel/head.h" + unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;EXPORT_SYMBOL (empty_zero_page);
Signature · 7 lines
2.23.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v3 3/8 riscv: init: merge split string literals in preprocessor directive
In reply to Paul Walmsleysparse complains loudly when string literals associated with preprocessor directives are split into multiple, separately quoted strings across different lines:
arch/riscv/mm/init.c:341:9: error: Expected ; at the end of type declaration arch/riscv/mm/init.c:341:9: error: got "not use absolute addressing." arch/riscv/mm/init.c:358:9: error: Trying to use reserved word 'do' as identifier arch/riscv/mm/init.c:358:9: error: Expected ; at end of declaration [ ... ]
Existing Linux practice is simply to use a single long line. So, fix by concatenating the strings.
This patch should have no functional impact.
--- arch/riscv/mm/init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/riscv/mm/init.c +1 -2
@@ -339,8 +339,7 @@ static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size)*/ #ifndef __riscv_cmodel_medany -#error "setup_vm() is called from head.S before relocate so it should " -"not use absolute addressing." +#error "setup_vm() is called from head.S before relocate so it should not use absolute addressing."#endif asmlinkage void __init setup_vm(uintptr_t dtb_pa)
Signature · 7 lines
2.23.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v3 3/8] riscv: init: merge split string literals in preprocessor directive
Looks good,
PATCH v3 4/8 riscv: add missing prototypes
In reply to Paul Walmsleysparse identifies these missing prototypes when building arch/riscv:
arch/riscv/kernel/cpu.c:149:29: warning: symbol 'cpuinfo_op' was not declared. Should it be static? arch/riscv/kernel/irq.c:27:29: warning: symbol 'do_IRQ' was not declared. Should it be static? arch/riscv/kernel/irq.c:57:13: warning: symbol 'init_IRQ' was not declared. Should it be static? arch/riscv/kernel/syscall_table.c:15:6: warning: symbol 'sys_call_table' was not declared. Should it be static? arch/riscv/kernel/time.c:15:13: warning: symbol 'time_init' was not declared. Should it be static? arch/riscv/kernel/smpboot.c:135:24: warning: symbol 'smp_callin' was not declared. Should it be static? arch/riscv/kernel/smp.c:72:5: warning: symbol 'setup_profiling_timer' was not declared. Should it be static? arch/riscv/mm/init.c:151:7: warning: symbol 'trampoline_pg_dir' was not declared. Should it be static? arch/riscv/mm/init.c:157:7: warning: symbol 'early_pg_dir' was not declared. Should it be static? arch/riscv/kernel/process.c:32:6: warning: symbol 'show_regs' was not declared. Should it be static?
Fix by adding the missing prototypes to the appropriate header files.
This change should have no functional impact.
--- arch/riscv/include/asm/irq.h | 3 +++ arch/riscv/include/asm/pgtable.h | 2 ++ arch/riscv/include/asm/processor.h | 4 ++++ arch/riscv/include/asm/ptrace.h | 2 ++ arch/riscv/include/asm/smp.h | 2 ++ 5 files changed, 13 insertions(+)
arch/riscv/include/asm/irq.h +3 -0
@@ -12,6 +12,9 @@void riscv_timer_interrupt (void );void riscv_software_interrupt (void ); +asmlinkage void do_IRQ(struct pt_regs *regs); +void __init init_IRQ (void ); +#include <asm-generic/irq.h> #endif /* _ASM_RISCV_IRQ_H */
arch/riscv/include/asm/pgtable.h +2 -0
@@ -61,6 +61,8 @@#define PAGE_TABLE __pgprot(_PAGE_TABLE) +extern pgd_t trampoline_pg_dir[]; +extern pgd_t early_pg_dir[];extern pgd_t swapper_pg_dir[];/* MAP_PRIVATE permissions: xwr (copy-on-write) */
arch/riscv/include/asm/processor.h +4 -0
@@ -78,6 +78,10 @@ int riscv_of_processor_hartid(struct device_node *node);extern void riscv_fill_hwcap (void ); +extern const struct seq_operations cpuinfo_op; + +void time_init (void ); +#endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_PROCESSOR_H */
arch/riscv/include/asm/ptrace.h +2 -0
@@ -101,6 +101,8 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)return regs->a0; } +void show_regs (struct pt_regs *regs); +#endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_PTRACE_H */
arch/riscv/include/asm/smp.h +2 -0
@@ -15,6 +15,8 @@struct seq_file ;extern unsigned long boot_cpu_hartid; +asmlinkage void __init smp_callin(void); +#ifdef CONFIG_SMP /* * Mapping between linux logical cpu index and hartid.
Signature · 1 line
2.23.0
Re: [PATCH v3 4/8] riscv: add missing prototypes
arch/riscv/include/asm/irq.h line 15
Quoted 10 lines · Paul Walmsley
arch/riscv/include/asm/irq.h +1
-0@@ -12,6 +12,9 @@void riscv_timer_interrupt (void );void riscv_software_interrupt (void ); +asmlinkage void do_IRQ(struct pt_regs *regs);
This is another __visible candidate.
arch/riscv/include/asm/irq.h line 16
Quoted 1 line
arch/riscv/include/asm/irq.h +1
-0+void __init init_IRQ (void );
This one is called by the core kernel. Please instead lift the extern in init/main.c to include/linux/irq.h or some other suitable header insted of working around the issue in arch code.
arch/riscv/include/asm/processor.h int riscv_of_processor_hartid(struct device_node *node); · line 81
Quoted 8 lines
index
f539149d04c2..ab56435de629100644arch/riscv/include/asm/processor.h +1
-0@@ -78,6 +78,10 @@ int riscv_of_processor_hartid(struct device_node *node);extern void riscv_fill_hwcap (void ); +extern const struct seq_operations cpuinfo_op;
Another generic issue, Ben Dooks has started looking into it already.
arch/riscv/include/asm/processor.h int riscv_of_processor_hartid(struct device_node *node); · line 83
Quoted 2 lines
arch/riscv/include/asm/processor.h +2
-0+ +void time_init (void );
And another one that needs to be solved globally and not worked around in the architecture.
arch/riscv/include/asm/ptrace.h static inline unsigned long regs_return_value(struct pt_regs *regs) · line 104
Quoted 9 lines
arch/riscv/include/asm/ptrace.h +1
-0@@ -101,6 +101,8 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)return regs->a0; } +void show_regs (struct pt_regs *regs);
Again, this needs to go into a common header, no arch code.
arch/riscv/include/asm/smp.h line 18
Quoted 13 lines
arch/riscv/include/asm/ptrace.h +1
-0+#endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_PTRACE_H */ arch/riscv/include/asm/smp.h +1
-0@@ -15,6 +15,8 @@struct seq_file ;extern unsigned long boot_cpu_hartid; +asmlinkage void __init smp_callin(void);
One more __visible candidate.
PATCH v3 5/8 riscv: mark some code and data as file-static
In reply to Paul WalmsleySeveral functions and arrays which are only used in the files in which they are declared are missing "static" qualifiers. Warnings for these symbols are reported by sparse:
arch/riscv/kernel/stacktrace.c:22:14: warning: symbol 'walk_stackframe' was not declared. Should it be static? arch/riscv/kernel/vdso.c:28:18: warning: symbol 'vdso_data' was not declared. Should it be static? arch/riscv/mm/init.c:42:6: warning: symbol 'setup_zero_page' was not declared. Should it be static? arch/riscv/mm/init.c:152:7: warning: symbol 'fixmap_pte' was not declared. Should it be static? arch/riscv/mm/init.c:211:7: warning: symbol 'trampoline_pmd' was not declared. Should it be static? arch/riscv/mm/init.c:212:7: warning: symbol 'fixmap_pmd' was not declared. Should it be static? arch/riscv/mm/init.c:219:7: warning: symbol 'early_pmd' was not declared. Should it be static? arch/riscv/mm/sifive_l2_cache.c:145:12: warning: symbol 'sifive_l2_init' was not declared. Should it be static?
Resolve these warnings by marking them as static.
--- arch/riscv/kernel/stacktrace.c | 6 ++++-- arch/riscv/kernel/vdso.c | 2 +- arch/riscv/mm/init.c | 12 +++++++----- arch/riscv/mm/sifive_l2_cache.c | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-)
arch/riscv/kernel/stacktrace.c +4 -2
@@ -19,8 +19,10 @@ struct stackframe {unsigned long ra; }; -void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, -bool (*fn)(unsigned long ,void *),void *arg) +static void notrace walk_stackframe(struct task_struct *task, +struct pt_regs *regs, +bool (*fn)(unsigned long ,void *), +void *arg) {unsigned long fp, sp, pc;
arch/riscv/kernel/vdso.c +1 -1
@@ -25,7 +25,7 @@ static union {struct vdso_data data;u8 page[PAGE_SIZE ]; }vdso_data_store __page_aligned_data; -struct vdso_data *vdso_data = &vdso_data_store.data; +static struct vdso_data *vdso_data = &vdso_data_store.data;static int __init vdso_init (void ) {
arch/riscv/mm/init.c +7 -5
@@ -40,7 +40,7 @@ static void __init zone_sizes_init(void)free_area_init_nodes (max_zone_pfns); } -void setup_zero_page (void ) +static void setup_zero_page (void ) {memset ((void *)empty_zero_page,0 ,PAGE_SIZE ); }
@@ -150,7 +150,7 @@ EXPORT_SYMBOL(pfn_base);void *dtb_early_va; pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss; -pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss; +static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss;static bool mmu_enabled;#define MAX_EARLY_MAPPING_SIZE SZ_128M
@@ -209,15 +209,17 @@ static void __init create_pte_mapping(pte_t *ptep,#ifndef __PAGETABLE_PMD_FOLDED -pmd_t trampoline_pmd[PTRS_PER_PMD] __page_aligned_bss; -pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss; +static pmd_t trampoline_pmd[PTRS_PER_PMD] __page_aligned_bss; +static pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss;#if MAX_EARLY_MAPPING_SIZE <PGDIR_SIZE #define NUM_EARLY_PMDS 1UL#else #define NUM_EARLY_PMDS (1UL + MAX_EARLY_MAPPING_SIZE / PGDIR_SIZE)#endif -pmd_t early_pmd[PTRS_PER_PMD *NUM_EARLY_PMDS ]__initdata __aligned(PAGE_SIZE) ; + +#define NUM_EARLY_PMDS_PTRS (PTRS_PER_PMD * NUM_EARLY_PMDS) +static pmd_t early_pmd[NUM_EARLY_PMDS_PTRS ]__initdata __aligned(PAGE_SIZE) ;static pmd_t *__init get_pmd_virt (phys_addr_t pa) {
arch/riscv/mm/sifive_l2_cache.c +1 -1
@@ -142,7 +142,7 @@ static irqreturn_t l2_int_handler(int irq, void *device)return IRQ_HANDLED ; } -int __init sifive_l2_init (void ) +static int __init sifive_l2_init (void ) {struct device_node *np;struct resource res;
Signature · 1 line
2.23.0
Re: [PATCH v3 5/8] riscv: mark some code and data as file-static
Looks good,
Re: [PATCH v3 5/8] riscv: mark some code and data as file-static
In reply to Paul WalmsleyPaul Walmsley <[email protected]> 於 2019年10月19日 週六 下午3:58寫道:
Quoted 29 lines
Several functions and arrays which are only used in the files in which they are declared are missing "static" qualifiers. Warnings for these symbols are reported by sparse:
arch/riscv/kernel/stacktrace.c:22:14: warning: symbol 'walk_stackframe' was not declared. Should it be static?arch/riscv/kernel/vdso.c:28:18: warning: symbol 'vdso_data' was not declared. Should it be static?arch/riscv/mm/init.c:42:6: warning: symbol 'setup_zero_page' was not declared. Should it be static?arch/riscv/mm/init.c:152:7: warning: symbol 'fixmap_pte' was not declared. Should it be static?arch/riscv/mm/init.c:211:7: warning: symbol 'trampoline_pmd' was not declared. Should it be static?arch/riscv/mm/init.c:212:7: warning: symbol 'fixmap_pmd' was not declared. Should it be static?arch/riscv/mm/init.c:219:7: warning: symbol 'early_pmd' was not declared. Should it be static?arch/riscv/mm/sifive_l2_cache.c:145:12: warning: symbol 'sifive_l2_init' was not declared. Should it be static?Resolve these warnings by marking them as static.
Signed-off-by Paul Walmsley <[email protected]>--- arch/riscv/kernel/stacktrace.c | 6 ++++-- arch/riscv/kernel/vdso.c | 2 +- arch/riscv/mm/init.c | 12 +++++++----- arch/riscv/mm/sifive_l2_cache.c | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-)arch/riscv/kernel/stacktrace.c +0
-0
arch/riscv/kernel/stacktrace.c struct stackframe { · line 25
Quoted 9 lines
arch/riscv/kernel/stacktrace.c +4
-2@@ -19,8 +19,10 @@ struct stackframe {unsigned long ra; }; -void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, -bool (*fn)(unsigned long ,void *),void *arg) +static void notrace walk_stackframe(struct task_struct *task, +struct pt_regs *regs, +bool (*fn)(unsigned long ,void *), +void *arg)
I think walk_stackframe() could not be static because it will be used in perf_callchain.c.
Re: [PATCH v3 5/8] riscv: mark some code and data as file-static
Quoted 7 lines · Greentime Hu
Paul Walmsley <[email protected]> 於 2019年10月19日 週六 下午3:58寫道:
Quoted 6 lines
Several functions and arrays which are only used in the files in which they are declared are missing "static" qualifiers. Warnings for these symbols are reported by sparse:
arch/riscv/kernel/stacktrace.c:22:14: warning: symbol 'walk_stackframe' was not declared. Should it be static?
[ ... ]
Quoted 2 lines
I think
walk_stackframe()could not be static because it will be used inperf_callchain.c.
Thanks Greentime - will update the patch.
- Paul
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v3 6/8 riscv: add missing header file includes
In reply to Paul Walmsleysparse identifies several missing prototypes caused by missing preprocessor include directives:
arch/riscv/kernel/cpufeature.c:16:6: warning: symbol 'has_fpu' was not declared. Should it be static? arch/riscv/kernel/process.c:26:6: warning: symbol 'arch_cpu_idle' was not declared. Should it be static? arch/riscv/kernel/process.c:93:5: warning: symbol 'arch_dup_task_struct' was not declared. Should it be static? arch/riscv/kernel/reset.c:15:6: warning: symbol 'pm_power_off' was not declared. Should it be static? arch/riscv/kernel/syscall_table.c:15:6: warning: symbol 'sys_call_table' was not declared. Should it be static? arch/riscv/kernel/time.c:14:13: warning: symbol 'time_init' was not declared. Should it be static? arch/riscv/kernel/vdso.c:54:5: warning: symbol 'arch_setup_additional_pages' was not declared. Should it be static? arch/riscv/kernel/smpboot.c:134:24: warning: symbol 'smp_callin' was not declared. Should it be static? arch/riscv/kernel/smp.c:64:6: warning: symbol 'arch_match_cpu_phys_id' was not declared. Should it be static? arch/riscv/kernel/smp.c:70:5: warning: symbol 'setup_profiling_timer' was not declared. Should it be static? arch/riscv/kernel/module-sections.c:89:5: warning: symbol 'module_frob_arch_sections' was not declared. Should it be static? arch/riscv/mm/context.c:42:6: warning: symbol 'switch_mm' was not declared. Should it be static?
Fix by including the appropriate header files in the appropriate source files.
This patch should have no functional impact.
--- arch/riscv/include/asm/irq.h | 3 +++ arch/riscv/include/asm/switch_to.h | 1 + arch/riscv/kernel/cpufeature.c | 1 + arch/riscv/kernel/module-sections.c | 1 + arch/riscv/kernel/process.c | 2 ++ arch/riscv/kernel/reset.c | 1 + arch/riscv/kernel/smp.c | 2 ++ arch/riscv/kernel/smpboot.c | 1 + arch/riscv/kernel/syscall_table.c | 1 + arch/riscv/kernel/time.c | 1 + arch/riscv/kernel/vdso.c | 1 + arch/riscv/mm/context.c | 1 + 12 files changed, 16 insertions(+)
arch/riscv/include/asm/irq.h +3 -0
@@ -7,6 +7,9 @@#ifndef _ASM_RISCV_IRQ_H#define _ASM_RISCV_IRQ_H +#include <linux/interrupt.h> +#include <linux/linkage.h> +#define NR_IRQS 0void riscv_timer_interrupt (void );
arch/riscv/include/asm/switch_to.h +1 -0
@@ -6,6 +6,7 @@#ifndef _ASM_RISCV_SWITCH_TO_H#define _ASM_RISCV_SWITCH_TO_H +#include <linux/sched/task_stack.h> #include <asm/processor.h> #include <asm/ptrace.h> #include <asm/csr.h>
arch/riscv/kernel/cpufeature.c +1 -0
@@ -10,6 +10,7 @@#include <asm/processor.h> #include <asm/hwcap.h> #include <asm/smp.h> +#include <asm/switch_to.h> unsigned long elf_hwcap__read_mostly ;#ifdef CONFIG_FPU
arch/riscv/kernel/module-sections.c +1 -0
@@ -8,6 +8,7 @@#include <linux/elf.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/moduleloader.h> unsigned long module_emit_got_entry (struct module *mod,unsigned long val) {
arch/riscv/kernel/process.c +2 -0
@@ -7,6 +7,7 @@* Copyright (C) 2017 SiFive */ +#include <linux/cpu.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/sched/task_stack.h>
@@ -19,6 +20,7 @@#include <asm/csr.h> #include <asm/string.h> #include <asm/switch_to.h> +#include <asm/thread_info.h> extern asmlinkage void ret_from_fork(void); extern asmlinkage void ret_from_kernel_thread(void);
arch/riscv/kernel/reset.c +1 -0
@@ -4,6 +4,7 @@*/ #include <linux/reboot.h> +#include <linux/pm.h> #include <asm/sbi.h> static void default_power_off (void )
arch/riscv/kernel/smp.c +2 -0
@@ -8,7 +8,9 @@* Copyright (C) 2017 SiFive */ +#include <linux/cpu.h> #include <linux/interrupt.h> +#include <linux/profile.h> #include <linux/smp.h> #include <linux/sched.h> #include <linux/seq_file.h>
arch/riscv/kernel/smpboot.c +1 -0
@@ -29,6 +29,7 @@#include <asm/tlbflush.h> #include <asm/sections.h> #include <asm/sbi.h> +#include <asm/smp.h> #include "head.h"
arch/riscv/kernel/syscall_table.c +1 -0
@@ -8,6 +8,7 @@#include <linux/syscalls.h> #include <asm-generic/syscalls.h> #include <asm/vdso.h> +#include <asm/syscall.h> #undef __SYSCALL#define __SYSCALL (nr, call) [nr] = (call),
arch/riscv/kernel/time.c +1 -0
@@ -7,6 +7,7 @@#include <linux/clocksource.h> #include <linux/delay.h> #include <asm/sbi.h> +#include <asm/processor.h> unsigned long riscv_timebase;EXPORT_SYMBOL_GPL (riscv_timebase);
arch/riscv/kernel/vdso.c +1 -0
@@ -6,6 +6,7 @@* Copyright (C) 2015 Regents of the University of California */ +#include <linux/elf.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/binfmts.h>
arch/riscv/mm/context.c +1 -0
@@ -7,6 +7,7 @@#include <linux/mm.h> #include <asm/tlbflush.h> #include <asm/cacheflush.h> +#include <asm/mmu_context.h> /* * When necessary, performs a deferred icache flush for the given MM context,
Signature · 7 lines
2.23.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v3 6/8] riscv: add missing header file includes
Looks good,
PATCH v3 7/8 riscv: fp: add missing __user pointer annotations
In reply to Paul WalmsleyThe __user annotations were removed from the {save,restore}_fp_state() function signatures by commit 007f5c358957 ("Refactor FPU code in signal setup/return procedures"), but should be present, and sparse warns when they are not applied. Add them back in.
This change should have no functional impact.
--- arch/riscv/kernel/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/signal.c +2 -2
@@ -28,7 +28,7 @@ struct rt_sigframe {#ifdef CONFIG_FPU static long restore_fp_state (struct pt_regs *regs, -union __riscv_fp_state *sc_fpregs) +union __riscv_fp_state __user *sc_fpregs) {long err;struct __riscv_d_ext_state __user *state = &sc_fpregs->d;
@@ -55,7 +55,7 @@ static long restore_fp_state(struct pt_regs *regs, }static long save_fp_state (struct pt_regs *regs, -union __riscv_fp_state *sc_fpregs) +union __riscv_fp_state __user *sc_fpregs) {long err;struct __riscv_d_ext_state __user *state = &sc_fpregs->d;
Signature · 1 line
2.23.0
Re: [PATCH v3 7/8] riscv: fp: add missing __user pointer annotations
Looks good,
PATCH v3 8/8 riscv: for C functions called only from assembly, mark with __visible
In reply to Paul WalmsleyRather than adding prototypes for C functions called only by assembly code, mark them as __visible. This avoids adding prototypes that will never be used by the callers. Resolves the following sparse warnings:
arch/riscv/kernel/ptrace.c:151:6: warning: symbol 'do_syscall_trace_enter' was not declared. Should it be static? arch/riscv/kernel/ptrace.c:175:6: warning: symbol 'do_syscall_trace_exit' was not declared. Should it be static?
Based on a suggestion from Luc Van Oostenryck.
--- arch/riscv/kernel/ptrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/ptrace.c +2 -2
@@ -148,7 +148,7 @@ long arch_ptrace(struct task_struct *child, long request,* Allows PTRACE_SYSCALL to work. These are called from entry.S in * {handle,ret_from}_syscall. */ -void do_syscall_trace_enter (struct pt_regs *regs) +__visible void do_syscall_trace_enter(struct pt_regs *regs) {if (test_thread_flag (TIF_SYSCALL_TRACE ))if (tracehook_report_syscall_entry (regs))
@@ -172,7 +172,7 @@ void do_syscall_trace_enter(struct pt_regs *regs)audit_syscall_entry (regs->a7, regs->a0, regs->a1, regs->a2, regs->a3); } -void do_syscall_trace_exit (struct pt_regs *regs) +__visible void do_syscall_trace_exit(struct pt_regs *regs) {audit_syscall_exit (regs);
Signature · 1 line
2.23.0
Re: [PATCH v3 8/8] riscv: for C functions called only from assembly, mark with __visible
Quoted 11 lines · Paul Walmsley
Rather than adding prototypes for C functions called only by assembly code, mark them as
__visible. This avoids adding prototypes that will never be used by the callers. Resolves the following sparse warnings:
arch/riscv/kernel/ptrace.c:151:6: warning: symbol 'do_syscall_trace_enter' was not declared. Should it be static?arch/riscv/kernel/ptrace.c:175:6: warning: symbol 'do_syscall_trace_exit' was not declared. Should it be static?Based on a suggestion from Luc Van Oostenryck.
Signed-off-by Paul Walmsley <[email protected]>Cc Luc Van Oostenryck <[email protected]>
Looks good,