Skip to content

Commit 5321d1b

Browse files
committed
Merge tag 'riscv-for-linus-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - A build warning fix for BUILTIN_DTB=y - Hibernation support is hidden behind NONPORTABLE, as it depends on some undocumented early boot behavior and breaks on most platforms - A fix for relocatable kernels on systems with early boot errata - A fix to properly handle perf callchains for kernel tracepoints - A pair of fixes for NAPOT to avoid inconsistencies between PTEs and handle hardware that sets arbitrary A/D bits * tag 'riscv-for-linus-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Implement missing huge_ptep_get riscv: Fix huge_ptep_set_wrprotect when PTE is a NAPOT riscv: perf: Fix callchain parse error with kernel tracepoint events riscv: Fix relocatable kernels with early alternatives using -fno-pie RISC-V: mark hibernation as nonportable riscv: Fix unused variable warning when BUILTIN_DTB is set
2 parents a746ca6 + 6966d79 commit 5321d1b

File tree

7 files changed

+52
-3
lines changed

7 files changed

+52
-3
lines changed

arch/riscv/Kconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,11 @@ menu "Power management options"
799799

800800
source "kernel/power/Kconfig"
801801

802+
# Hibernation is only possible on systems where the SBI implementation has
803+
# marked its reserved memory as not accessible from, or does not run
804+
# from the same memory as, Linux
802805
config ARCH_HIBERNATION_POSSIBLE
803-
def_bool y
806+
def_bool NONPORTABLE
804807

805808
config ARCH_HIBERNATION_HEADER
806809
def_bool HIBERNATION

arch/riscv/errata/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
ifdef CONFIG_RELOCATABLE
2+
KBUILD_CFLAGS += -fno-pie
3+
endif
4+
15
obj-$(CONFIG_ERRATA_SIFIVE) += sifive/
26
obj-$(CONFIG_ERRATA_THEAD) += thead/

arch/riscv/include/asm/hugetlb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
3636
unsigned long addr, pte_t *ptep,
3737
pte_t pte, int dirty);
3838

39+
#define __HAVE_ARCH_HUGE_PTEP_GET
40+
pte_t huge_ptep_get(pte_t *ptep);
41+
3942
pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags);
4043
#define arch_make_huge_pte arch_make_huge_pte
4144

arch/riscv/include/asm/perf_event.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@
1010

1111
#include <linux/perf_event.h>
1212
#define perf_arch_bpf_user_pt_regs(regs) (struct user_regs_struct *)regs
13+
14+
#define perf_arch_fetch_caller_regs(regs, __ip) { \
15+
(regs)->epc = (__ip); \
16+
(regs)->s0 = (unsigned long) __builtin_frame_address(0); \
17+
(regs)->sp = current_stack_pointer; \
18+
(regs)->status = SR_PP; \
19+
}
1320
#endif /* _ASM_RISCV_PERF_EVENT_H */

arch/riscv/kernel/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ ifdef CONFIG_FTRACE
2323
CFLAGS_REMOVE_alternative.o = $(CC_FLAGS_FTRACE)
2424
CFLAGS_REMOVE_cpufeature.o = $(CC_FLAGS_FTRACE)
2525
endif
26+
ifdef CONFIG_RELOCATABLE
27+
CFLAGS_alternative.o += -fno-pie
28+
CFLAGS_cpufeature.o += -fno-pie
29+
endif
2630
ifdef CONFIG_KASAN
2731
KASAN_SANITIZE_alternative.o := n
2832
KASAN_SANITIZE_cpufeature.o := n

arch/riscv/mm/hugetlbpage.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@
33
#include <linux/err.h>
44

55
#ifdef CONFIG_RISCV_ISA_SVNAPOT
6+
pte_t huge_ptep_get(pte_t *ptep)
7+
{
8+
unsigned long pte_num;
9+
int i;
10+
pte_t orig_pte = ptep_get(ptep);
11+
12+
if (!pte_present(orig_pte) || !pte_napot(orig_pte))
13+
return orig_pte;
14+
15+
pte_num = napot_pte_num(napot_cont_order(orig_pte));
16+
17+
for (i = 0; i < pte_num; i++, ptep++) {
18+
pte_t pte = ptep_get(ptep);
19+
20+
if (pte_dirty(pte))
21+
orig_pte = pte_mkdirty(orig_pte);
22+
23+
if (pte_young(pte))
24+
orig_pte = pte_mkyoung(orig_pte);
25+
}
26+
27+
return orig_pte;
28+
}
29+
630
pte_t *huge_pte_alloc(struct mm_struct *mm,
731
struct vm_area_struct *vma,
832
unsigned long addr,
@@ -218,6 +242,7 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm,
218242
{
219243
pte_t pte = ptep_get(ptep);
220244
unsigned long order;
245+
pte_t orig_pte;
221246
int i, pte_num;
222247

223248
if (!pte_napot(pte)) {
@@ -228,9 +253,12 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm,
228253
order = napot_cont_order(pte);
229254
pte_num = napot_pte_num(order);
230255
ptep = huge_pte_offset(mm, addr, napot_cont_size(order));
256+
orig_pte = get_clear_contig_flush(mm, addr, ptep, pte_num);
257+
258+
orig_pte = pte_wrprotect(orig_pte);
231259

232260
for (i = 0; i < pte_num; i++, addr += PAGE_SIZE, ptep++)
233-
ptep_set_wrprotect(mm, addr, ptep);
261+
set_pte_at(mm, addr, ptep, orig_pte);
234262
}
235263

236264
pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,

arch/riscv/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,9 +922,9 @@ static void __init create_kernel_page_table(pgd_t *pgdir, bool early)
922922
static void __init create_fdt_early_page_table(uintptr_t fix_fdt_va,
923923
uintptr_t dtb_pa)
924924
{
925+
#ifndef CONFIG_BUILTIN_DTB
925926
uintptr_t pa = dtb_pa & ~(PMD_SIZE - 1);
926927

927-
#ifndef CONFIG_BUILTIN_DTB
928928
/* Make sure the fdt fixmap address is always aligned on PMD size */
929929
BUILD_BUG_ON(FIX_FDT % (PMD_SIZE / PAGE_SIZE));
930930

0 commit comments

Comments
 (0)