Skip to content

Commit 07ebd38

Browse files
committed
Merge tag 'riscv-for-linus-5.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - Fixes for a handful of KASAN-related crashes. - A fix to avoid a crash during boot for SPARSEMEM && !SPARSEMEM_VMEMMAP configurations. - A fix to stop reporting some incorrect errors under DEBUG_VIRTUAL. - A fix for the K210's device tree to properly populate the interrupt map, so hart1 will get interrupts again. * tag 'riscv-for-linus-5.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: dts: k210: fix broken IRQs on hart1 riscv: Fix kasan pud population riscv: Move high_memory initialization to setup_bootmem riscv: Fix config KASAN && DEBUG_VIRTUAL riscv: Fix DEBUG_VIRTUAL false warnings riscv: Fix config KASAN && SPARSEMEM && !SPARSE_VMEMMAP riscv: Fix is_linear_mapping with recent move of KASAN region
2 parents 3f509f5 + 74583f1 commit 07ebd38

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

arch/riscv/boot/dts/canaan/k210.dtsi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@
113113
compatible = "canaan,k210-plic", "sifive,plic-1.0.0";
114114
reg = <0xC000000 0x4000000>;
115115
interrupt-controller;
116-
interrupts-extended = <&cpu0_intc 11>, <&cpu1_intc 11>;
116+
interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>,
117+
<&cpu1_intc 11>, <&cpu1_intc 9>;
117118
riscv,ndev = <65>;
118119
};
119120

arch/riscv/include/asm/page.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ extern phys_addr_t phys_ram_base;
119119
((x) >= kernel_map.virt_addr && (x) < (kernel_map.virt_addr + kernel_map.size))
120120

121121
#define is_linear_mapping(x) \
122-
((x) >= PAGE_OFFSET && (!IS_ENABLED(CONFIG_64BIT) || (x) < kernel_map.virt_addr))
122+
((x) >= PAGE_OFFSET && (!IS_ENABLED(CONFIG_64BIT) || (x) < PAGE_OFFSET + KERN_VIRT_SIZE))
123123

124124
#define linear_mapping_pa_to_va(x) ((void *)((unsigned long)(x) + kernel_map.va_pa_offset))
125125
#define kernel_mapping_pa_to_va(y) ({ \

arch/riscv/include/asm/pgtable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#ifndef CONFIG_MMU
1515
#define KERNEL_LINK_ADDR PAGE_OFFSET
16+
#define KERN_VIRT_SIZE (UL(-1))
1617
#else
1718

1819
#define ADDRESS_SPACE_END (UL(-1))

arch/riscv/mm/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ obj-$(CONFIG_KASAN) += kasan_init.o
2424
ifdef CONFIG_KASAN
2525
KASAN_SANITIZE_kasan_init.o := n
2626
KASAN_SANITIZE_init.o := n
27+
ifdef CONFIG_DEBUG_VIRTUAL
28+
KASAN_SANITIZE_physaddr.o := n
29+
endif
2730
endif
2831

2932
obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o

arch/riscv/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ void __init mem_init(void)
125125
else
126126
swiotlb_force = SWIOTLB_NO_FORCE;
127127
#endif
128-
high_memory = (void *)(__va(PFN_PHYS(max_low_pfn)));
129128
memblock_free_all();
130129

131130
print_vm_layout();
@@ -195,6 +194,7 @@ static void __init setup_bootmem(void)
195194

196195
min_low_pfn = PFN_UP(phys_ram_base);
197196
max_low_pfn = max_pfn = PFN_DOWN(phys_ram_end);
197+
high_memory = (void *)(__va(PFN_PHYS(max_low_pfn)));
198198

199199
dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn));
200200
set_max_mapnr(max_low_pfn - ARCH_PFN_OFFSET);

arch/riscv/mm/kasan_init.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ static void __init kasan_populate_pud(pgd_t *pgd,
113113
base_pud = pt_ops.get_pud_virt(pfn_to_phys(_pgd_pfn(*pgd)));
114114
} else {
115115
base_pud = (pud_t *)pgd_page_vaddr(*pgd);
116-
if (base_pud == lm_alias(kasan_early_shadow_pud))
116+
if (base_pud == lm_alias(kasan_early_shadow_pud)) {
117117
base_pud = memblock_alloc(PTRS_PER_PUD * sizeof(pud_t), PAGE_SIZE);
118+
memcpy(base_pud, (void *)kasan_early_shadow_pud,
119+
sizeof(pud_t) * PTRS_PER_PUD);
120+
}
118121
}
119122

120123
pudp = base_pud + pud_index(vaddr);
@@ -202,8 +205,7 @@ asmlinkage void __init kasan_early_init(void)
202205

203206
for (i = 0; i < PTRS_PER_PTE; ++i)
204207
set_pte(kasan_early_shadow_pte + i,
205-
mk_pte(virt_to_page(kasan_early_shadow_page),
206-
PAGE_KERNEL));
208+
pfn_pte(virt_to_pfn(kasan_early_shadow_page), PAGE_KERNEL));
207209

208210
for (i = 0; i < PTRS_PER_PMD; ++i)
209211
set_pmd(kasan_early_shadow_pmd + i,

arch/riscv/mm/physaddr.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88

99
phys_addr_t __virt_to_phys(unsigned long x)
1010
{
11-
phys_addr_t y = x - PAGE_OFFSET;
12-
1311
/*
1412
* Boundary checking aginst the kernel linear mapping space.
1513
*/
16-
WARN(y >= KERN_VIRT_SIZE,
14+
WARN(!is_linear_mapping(x) && !is_kernel_mapping(x),
1715
"virt_to_phys used for non-linear address: %pK (%pS)\n",
1816
(void *)x, (void *)x);
1917

0 commit comments

Comments
 (0)