Skip to content

Commit 2a3c17e

Browse files
committed
Merge tag 'riscv-for-linus-6.5-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - Fixes for a pair of kexec_file_load() failures - A fix to ensure the direct mapping is PMD-aligned - A fix for CPU feature detection on SMP=n - The MMIO ordering fences have been strengthened to ensure ordering WRT delay() - Fixes for a pair of -Wmissing-variable-declarations warnings - A fix to avoid PUD mappings in vmap on sv39 - flush_cache_vmap() now flushes the TLB to avoid issues on systems that cache invalid mappings * tag 'riscv-for-linus-6.5-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Implement flush_cache_vmap() riscv: Do not allow vmap pud mappings for 3-level page table riscv: mm: fix 2 instances of -Wmissing-variable-declarations riscv,mmio: Fix readX()-to-delay() ordering riscv: Fix CPU feature detection with SMP disabled riscv: Start of DRAM should at least be aligned on PMD size for the direct mapping riscv/kexec: load initrd high in available memory riscv/kexec: handle R_RISCV_CALL_PLT relocation type
2 parents feb0eee + 7e38115 commit 2a3c17e

File tree

9 files changed

+35
-21
lines changed

9 files changed

+35
-21
lines changed

arch/riscv/include/asm/cacheflush.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ static inline void flush_dcache_page(struct page *page)
3737
#define flush_icache_user_page(vma, pg, addr, len) \
3838
flush_icache_mm(vma->vm_mm, 0)
3939

40+
#ifdef CONFIG_64BIT
41+
#define flush_cache_vmap(start, end) flush_tlb_kernel_range(start, end)
42+
#endif
43+
4044
#ifndef CONFIG_SMP
4145

4246
#define flush_icache_all() local_flush_icache_all()

arch/riscv/include/asm/mmio.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
101101
* Relaxed I/O memory access primitives. These follow the Device memory
102102
* ordering rules but do not guarantee any ordering relative to Normal memory
103103
* accesses. These are defined to order the indicated access (either a read or
104-
* write) with all other I/O memory accesses. Since the platform specification
105-
* defines that all I/O regions are strongly ordered on channel 2, no explicit
106-
* fences are required to enforce this ordering.
104+
* write) with all other I/O memory accesses to the same peripheral. Since the
105+
* platform specification defines that all I/O regions are strongly ordered on
106+
* channel 0, no explicit fences are required to enforce this ordering.
107107
*/
108108
/* FIXME: These are now the same as asm-generic */
109109
#define __io_rbr() do {} while (0)
@@ -125,14 +125,14 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
125125
#endif
126126

127127
/*
128-
* I/O memory access primitives. Reads are ordered relative to any
129-
* following Normal memory access. Writes are ordered relative to any prior
130-
* Normal memory access. The memory barriers here are necessary as RISC-V
128+
* I/O memory access primitives. Reads are ordered relative to any following
129+
* Normal memory read and delay() loop. Writes are ordered relative to any
130+
* prior Normal memory write. The memory barriers here are necessary as RISC-V
131131
* doesn't define any ordering between the memory space and the I/O space.
132132
*/
133133
#define __io_br() do {} while (0)
134-
#define __io_ar(v) __asm__ __volatile__ ("fence i,r" : : : "memory")
135-
#define __io_bw() __asm__ __volatile__ ("fence w,o" : : : "memory")
134+
#define __io_ar(v) ({ __asm__ __volatile__ ("fence i,ir" : : : "memory"); })
135+
#define __io_bw() ({ __asm__ __volatile__ ("fence w,o" : : : "memory"); })
136136
#define __io_aw() mmiowb_set_pending()
137137

138138
#define readb(c) ({ u8 __v; __io_br(); __v = readb_cpu(c); __io_ar(__v); __v; })

arch/riscv/include/asm/pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ extern struct pt_alloc_ops pt_ops __initdata;
188188
#define PAGE_KERNEL_IO __pgprot(_PAGE_IOREMAP)
189189

190190
extern pgd_t swapper_pg_dir[];
191+
extern pgd_t trampoline_pg_dir[];
192+
extern pgd_t early_pg_dir[];
191193

192194
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
193195
static inline int pmd_present(pmd_t pmd)

arch/riscv/include/asm/vmalloc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
55

6+
extern bool pgtable_l4_enabled, pgtable_l5_enabled;
7+
68
#define IOREMAP_MAX_ORDER (PUD_SHIFT)
79

810
#define arch_vmap_pud_supported arch_vmap_pud_supported
911
static inline bool arch_vmap_pud_supported(pgprot_t prot)
1012
{
11-
return true;
13+
return pgtable_l4_enabled || pgtable_l5_enabled;
1214
}
1315

1416
#define arch_vmap_pmd_supported arch_vmap_pmd_supported

arch/riscv/kernel/cpu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#include <asm/smp.h>
1818
#include <asm/pgtable.h>
1919

20+
bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
21+
{
22+
return phys_id == cpuid_to_hartid_map(cpu);
23+
}
24+
2025
/*
2126
* Returns the hart ID of the given device tree node, or -ENODEV if the node
2227
* isn't an enabled and valid RISC-V hart node.

arch/riscv/kernel/elf_kexec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf,
281281
kbuf.buffer = initrd;
282282
kbuf.bufsz = kbuf.memsz = initrd_len;
283283
kbuf.buf_align = PAGE_SIZE;
284-
kbuf.top_down = false;
284+
kbuf.top_down = true;
285285
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
286286
ret = kexec_add_buffer(&kbuf);
287287
if (ret)
@@ -425,6 +425,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
425425
* sym, instead of searching the whole relsec.
426426
*/
427427
case R_RISCV_PCREL_HI20:
428+
case R_RISCV_CALL_PLT:
428429
case R_RISCV_CALL:
429430
*(u64 *)loc = CLEAN_IMM(UITYPE, *(u64 *)loc) |
430431
ENCODE_UJTYPE_IMM(val - addr);

arch/riscv/kernel/smp.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ int riscv_hartid_to_cpuid(unsigned long hartid)
6161
return -ENOENT;
6262
}
6363

64-
bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
65-
{
66-
return phys_id == cpuid_to_hartid_map(cpu);
67-
}
68-
6964
static void ipi_stop(void)
7065
{
7166
set_cpu_online(smp_processor_id(), false);

arch/riscv/mm/init.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
#include <linux/kfence.h>
2727

2828
#include <asm/fixmap.h>
29-
#include <asm/tlbflush.h>
30-
#include <asm/sections.h>
31-
#include <asm/soc.h>
3229
#include <asm/io.h>
33-
#include <asm/ptdump.h>
3430
#include <asm/numa.h>
31+
#include <asm/pgtable.h>
32+
#include <asm/ptdump.h>
33+
#include <asm/sections.h>
34+
#include <asm/soc.h>
35+
#include <asm/tlbflush.h>
3536

3637
#include "../kernel/head.h"
3738

@@ -214,8 +215,13 @@ static void __init setup_bootmem(void)
214215
memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
215216

216217
phys_ram_end = memblock_end_of_DRAM();
218+
219+
/*
220+
* Make sure we align the start of the memory on a PMD boundary so that
221+
* at worst, we map the linear mapping with PMD mappings.
222+
*/
217223
if (!IS_ENABLED(CONFIG_XIP_KERNEL))
218-
phys_ram_base = memblock_start_of_DRAM();
224+
phys_ram_base = memblock_start_of_DRAM() & PMD_MASK;
219225

220226
/*
221227
* In 64-bit, any use of __va/__pa before this point is wrong as we

arch/riscv/mm/kasan_init.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* region is not and then we have to go down to the PUD level.
2323
*/
2424

25-
extern pgd_t early_pg_dir[PTRS_PER_PGD];
2625
pgd_t tmp_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
2726
p4d_t tmp_p4d[PTRS_PER_P4D] __page_aligned_bss;
2827
pud_t tmp_pud[PTRS_PER_PUD] __page_aligned_bss;

0 commit comments

Comments
 (0)