Skip to content

Commit 6995a6a

Browse files
committed
Merge tag 'riscv/for-v5.4-rc5-b' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Paul Walmsley: "Several minor fixes and cleanups for v5.4-rc5: - Three build fixes for various SPARSEMEM-related kernel configurations - Two cleanup patches for the kernel bug and breakpoint trap handler code" * tag 'riscv/for-v5.4-rc5-b' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: cleanup do_trap_break riscv: cleanup <asm/bug.h> riscv: Fix undefined reference to vmemmap_populate_basepages riscv: Fix implicit declaration of 'page_to_section' riscv: fix fs/proc/kcore.c compilation with sparsemem enabled
2 parents 5a1e843 + e8f44c5 commit 6995a6a

File tree

4 files changed

+11
-40
lines changed

4 files changed

+11
-40
lines changed

arch/riscv/include/asm/bug.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212

1313
#include <asm/asm.h>
1414

15-
#ifdef CONFIG_GENERIC_BUG
1615
#define __INSN_LENGTH_MASK _UL(0x3)
1716
#define __INSN_LENGTH_32 _UL(0x3)
1817
#define __COMPRESSED_INSN_MASK _UL(0xffff)
1918

2019
#define __BUG_INSN_32 _UL(0x00100073) /* ebreak */
2120
#define __BUG_INSN_16 _UL(0x9002) /* c.ebreak */
2221

23-
#ifndef __ASSEMBLY__
2422
typedef u32 bug_insn_t;
2523

2624
#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
@@ -43,6 +41,7 @@ typedef u32 bug_insn_t;
4341
RISCV_SHORT " %2"
4442
#endif
4543

44+
#ifdef CONFIG_GENERIC_BUG
4645
#define __BUG_FLAGS(flags) \
4746
do { \
4847
__asm__ __volatile__ ( \
@@ -58,14 +57,10 @@ do { \
5857
"i" (flags), \
5958
"i" (sizeof(struct bug_entry))); \
6059
} while (0)
61-
62-
#endif /* !__ASSEMBLY__ */
6360
#else /* CONFIG_GENERIC_BUG */
64-
#ifndef __ASSEMBLY__
6561
#define __BUG_FLAGS(flags) do { \
6662
__asm__ __volatile__ ("ebreak\n"); \
6763
} while (0)
68-
#endif /* !__ASSEMBLY__ */
6964
#endif /* CONFIG_GENERIC_BUG */
7065

7166
#define BUG() do { \
@@ -79,15 +74,10 @@ do { \
7974

8075
#include <asm-generic/bug.h>
8176

82-
#ifndef __ASSEMBLY__
83-
8477
struct pt_regs;
8578
struct task_struct;
8679

87-
extern void die(struct pt_regs *regs, const char *str);
88-
extern void do_trap(struct pt_regs *regs, int signo, int code,
89-
unsigned long addr);
90-
91-
#endif /* !__ASSEMBLY__ */
80+
void die(struct pt_regs *regs, const char *str);
81+
void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr);
9282

9383
#endif /* _ASM_RISCV_BUG_H */

arch/riscv/include/asm/pgtable.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,7 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot)
184184
return __pte((pfn << _PAGE_PFN_SHIFT) | pgprot_val(prot));
185185
}
186186

187-
static inline pte_t mk_pte(struct page *page, pgprot_t prot)
188-
{
189-
return pfn_pte(page_to_pfn(page), prot);
190-
}
187+
#define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot)
191188

192189
#define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
193190

@@ -428,9 +425,7 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
428425
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
429426
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
430427

431-
#ifdef CONFIG_FLATMEM
432428
#define kern_addr_valid(addr) (1) /* FIXME */
433-
#endif
434429

435430
extern void *dtb_early_va;
436431
extern void setup_bootmem(void);

arch/riscv/kernel/traps.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ DO_ERROR_INFO(do_trap_ecall_s,
111111
DO_ERROR_INFO(do_trap_ecall_m,
112112
SIGILL, ILL_ILLTRP, "environment call from M-mode");
113113

114-
#ifdef CONFIG_GENERIC_BUG
115114
static inline unsigned long get_break_insn_length(unsigned long pc)
116115
{
117116
bug_insn_t insn;
@@ -120,28 +119,15 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
120119
return 0;
121120
return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL);
122121
}
123-
#endif /* CONFIG_GENERIC_BUG */
124122

125123
asmlinkage void do_trap_break(struct pt_regs *regs)
126124
{
127-
if (user_mode(regs)) {
128-
force_sig_fault(SIGTRAP, TRAP_BRKPT,
129-
(void __user *)(regs->sepc));
130-
return;
131-
}
132-
#ifdef CONFIG_GENERIC_BUG
133-
{
134-
enum bug_trap_type type;
135-
136-
type = report_bug(regs->sepc, regs);
137-
if (type == BUG_TRAP_TYPE_WARN) {
138-
regs->sepc += get_break_insn_length(regs->sepc);
139-
return;
140-
}
141-
}
142-
#endif /* CONFIG_GENERIC_BUG */
143-
144-
die(regs, "Kernel BUG");
125+
if (user_mode(regs))
126+
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->sepc);
127+
else if (report_bug(regs->sepc, regs) == BUG_TRAP_TYPE_WARN)
128+
regs->sepc += get_break_insn_length(regs->sepc);
129+
else
130+
die(regs, "Kernel BUG");
145131
}
146132

147133
#ifdef CONFIG_GENERIC_BUG

arch/riscv/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ void __init paging_init(void)
458458
zone_sizes_init();
459459
}
460460

461-
#ifdef CONFIG_SPARSEMEM
461+
#ifdef CONFIG_SPARSEMEM_VMEMMAP
462462
int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
463463
struct vmem_altmap *altmap)
464464
{

0 commit comments

Comments
 (0)