Skip to content

Commit af8d9eb

Browse files
committed
Merge tag 'riscv-for-linus-5.13-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - Build with '-mno-relax' when using LLVM's linker, which doesn't support linker relaxation. - A fix to build without SiFive's errata. - A fix to use PAs during init_resources() - A fix to avoid W+X mappings during boot. * tag 'riscv-for-linus-5.13-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: RISC-V: Fix memblock_free() usages in init_resources() riscv: skip errata_cip_453.o if CONFIG_ERRATA_SIFIVE_CIP_453 is disabled riscv: mm: Fix W+X mappings at boot riscv: Use -mno-relax when using lld linker
2 parents 9d32fa5 + 160ce36 commit af8d9eb

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

arch/riscv/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ else
3838
KBUILD_LDFLAGS += -melf32lriscv
3939
endif
4040

41+
ifeq ($(CONFIG_LD_IS_LLD),y)
42+
KBUILD_CFLAGS += -mno-relax
43+
KBUILD_AFLAGS += -mno-relax
44+
ifneq ($(LLVM_IAS),1)
45+
KBUILD_CFLAGS += -Wa,-mno-relax
46+
KBUILD_AFLAGS += -Wa,-mno-relax
47+
endif
48+
endif
49+
4150
# ISA string setting
4251
riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
4352
riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima

arch/riscv/errata/sifive/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
obj-y += errata_cip_453.o
1+
obj-$(CONFIG_ERRATA_SIFIVE_CIP_453) += errata_cip_453.o
22
obj-y += errata.o

arch/riscv/kernel/setup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ static void __init init_resources(void)
231231

232232
/* Clean-up any unused pre-allocated resources */
233233
mem_res_sz = (num_resources - res_idx + 1) * sizeof(*mem_res);
234-
memblock_free((phys_addr_t) mem_res, mem_res_sz);
234+
memblock_free(__pa(mem_res), mem_res_sz);
235235
return;
236236

237237
error:
238238
/* Better an empty resource tree than an inconsistent one */
239239
release_child_resources(&iomem_resource);
240-
memblock_free((phys_addr_t) mem_res, mem_res_sz);
240+
memblock_free(__pa(mem_res), mem_res_sz);
241241
}
242242

243243

arch/riscv/mm/init.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,14 +746,18 @@ void __init protect_kernel_text_data(void)
746746
unsigned long init_data_start = (unsigned long)__init_data_begin;
747747
unsigned long rodata_start = (unsigned long)__start_rodata;
748748
unsigned long data_start = (unsigned long)_data;
749-
unsigned long max_low = (unsigned long)(__va(PFN_PHYS(max_low_pfn)));
749+
#if defined(CONFIG_64BIT) && defined(CONFIG_MMU)
750+
unsigned long end_va = kernel_virt_addr + load_sz;
751+
#else
752+
unsigned long end_va = (unsigned long)(__va(PFN_PHYS(max_low_pfn)));
753+
#endif
750754

751755
set_memory_ro(text_start, (init_text_start - text_start) >> PAGE_SHIFT);
752756
set_memory_ro(init_text_start, (init_data_start - init_text_start) >> PAGE_SHIFT);
753757
set_memory_nx(init_data_start, (rodata_start - init_data_start) >> PAGE_SHIFT);
754758
/* rodata section is marked readonly in mark_rodata_ro */
755759
set_memory_nx(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT);
756-
set_memory_nx(data_start, (max_low - data_start) >> PAGE_SHIFT);
760+
set_memory_nx(data_start, (end_va - data_start) >> PAGE_SHIFT);
757761
}
758762

759763
void mark_rodata_ro(void)

0 commit comments

Comments
 (0)