RISC-V Fixes for 5.13-rc5

* 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.
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCgAxFiEEKzw3R0RoQ7JKlDp6LhMZ81+7GIkFAmC7i5ATHHBhbG1lckBk
 YWJiZWx0LmNvbQAKCRAuExnzX7sYiaQVEAC5/S8N9LdmN6ObGTjmuitfi2YMAnQ/
 rNPbZNU/rF9Xf09QmJYHzLh4K6rdLRhd1ZL/voYSEzjZqq9vF60f6gQGgGQ9tULM
 OEMfVPsUdqHte+8qG9HkseeRTjpqOlV8iSYIvDNOPdXaT8O4OSIx7LZQDpF1nvbg
 0KU0BE6BtL6NfAL2yF9HB2jlB5hiN9IZRWj9IXl84Rd8838/b09BUY7KPOMv6W3v
 ENkMkWsWuqxnZFsWdlNErveujULZTETpRuGp01/vqweTMfMGPkhQV73qGMbj1w42
 jLPPFJL62B7v7y24c+MdWdNMnKSGkjXoKXX4UjK0e96zIwq9nRx+346Jx+zZSO0Y
 4zeUTPUCOXycU+p/kB6odLq6dXmjx0RiG2hxjCZawpHGiyTYZ3j7rl5dzQXFN4Ad
 Onc54gQ/w0+yIvasOi7uQnBHtIRpkr2Lu3kK91ZzFF5W0qlio7GbvIgD09ny098c
 2j9x/Mp8qUdPSqtIBZ4djB8tGcMfPPW3fcaCDtcjBID+RdMSHzIkyWqCMQYhCEoJ
 Ke/B04Of0ExM5SmFE/LP63zpTYmGy8TNWyjKvC1cuegE3yUsEAoNve8d922wiAtO
 8exiHjhc+eRO127EXWQNJU6A9HJ7maO+a8o22fgLdQNZkR829wLaJmo3PQ6//L/5
 s2tj7h30zAvxOw==
 =vuVu
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2021-06-05 10:45:13 -07:00
commit af8d9eb840
4 changed files with 18 additions and 5 deletions

View File

@ -38,6 +38,15 @@ else
KBUILD_LDFLAGS += -melf32lriscv
endif
ifeq ($(CONFIG_LD_IS_LLD),y)
KBUILD_CFLAGS += -mno-relax
KBUILD_AFLAGS += -mno-relax
ifneq ($(LLVM_IAS),1)
KBUILD_CFLAGS += -Wa,-mno-relax
KBUILD_AFLAGS += -Wa,-mno-relax
endif
endif
# ISA string setting
riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima

View File

@ -1,2 +1,2 @@
obj-y += errata_cip_453.o
obj-$(CONFIG_ERRATA_SIFIVE_CIP_453) += errata_cip_453.o
obj-y += errata.o

View File

@ -231,13 +231,13 @@ static void __init init_resources(void)
/* Clean-up any unused pre-allocated resources */
mem_res_sz = (num_resources - res_idx + 1) * sizeof(*mem_res);
memblock_free((phys_addr_t) mem_res, mem_res_sz);
memblock_free(__pa(mem_res), mem_res_sz);
return;
error:
/* Better an empty resource tree than an inconsistent one */
release_child_resources(&iomem_resource);
memblock_free((phys_addr_t) mem_res, mem_res_sz);
memblock_free(__pa(mem_res), mem_res_sz);
}

View File

@ -746,14 +746,18 @@ void __init protect_kernel_text_data(void)
unsigned long init_data_start = (unsigned long)__init_data_begin;
unsigned long rodata_start = (unsigned long)__start_rodata;
unsigned long data_start = (unsigned long)_data;
unsigned long max_low = (unsigned long)(__va(PFN_PHYS(max_low_pfn)));
#if defined(CONFIG_64BIT) && defined(CONFIG_MMU)
unsigned long end_va = kernel_virt_addr + load_sz;
#else
unsigned long end_va = (unsigned long)(__va(PFN_PHYS(max_low_pfn)));
#endif
set_memory_ro(text_start, (init_text_start - text_start) >> PAGE_SHIFT);
set_memory_ro(init_text_start, (init_data_start - init_text_start) >> PAGE_SHIFT);
set_memory_nx(init_data_start, (rodata_start - init_data_start) >> PAGE_SHIFT);
/* rodata section is marked readonly in mark_rodata_ro */
set_memory_nx(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT);
set_memory_nx(data_start, (max_low - data_start) >> PAGE_SHIFT);
set_memory_nx(data_start, (end_va - data_start) >> PAGE_SHIFT);
}
void mark_rodata_ro(void)