RISC-V Fixes for 5.11-rc7

I have a handful of fixes for this week:
 
 * A fix to avoid evalating the VA twice in virt_addr_valid, which fixes
   some WARNs under DEBUG_VIRTUAL.
 * Two fixes related to STRICT_KERNEL_RWX: one that fixes some
   permissions when strict is disabled, and one to fix some alignment
   issues when strict is enabled.
 * A fix to disallow the selection of MAXPHYSMEM_2GB on RV32, which isn't
   valid any more but may still show up in some oldconfigs.
 
 We still have the HiFive Unleashed ethernet phy reset regression, so
 there will likely be something coming next week.
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCgAxFiEEKzw3R0RoQ7JKlDp6LhMZ81+7GIkFAmAe7xUTHHBhbG1lckBk
 YWJiZWx0LmNvbQAKCRAuExnzX7sYiQZqD/9ebojeOMusNtAU9Lelz9edLbpMlZ95
 vFxHUD44GmWl6qWCAUAi6rNve8V6yokYNbqqFhZxzKyhnKBqsHBj1vZWnPrne7pB
 bliBvQjlQ6gv7u1Dz+o7+fya1K41jVzKCht4bQqqU8wzVMlo0HIaaeKXfqdSwkZh
 xYEn4D0kI+RqvkM13CkYdPmWuSdhWr5cOlzNvuMssb7RuP6DTx3C/GDomJA59M0u
 tw/FNtSx1Y/PGg+FKoo0DkMqOurjOXZ26/DrroA1ZDO2baqVyrcxjwpqb2FH1FNN
 8PRDROcs22/QEeq0yTwtN6ZYOZoL8MXQslryAAHWbD/nSkM6yR+Tkw3rF+gl2yhH
 ZHq0HtYoemBCfKn1WD2yS8g1UNRN60gKd1+gGREajxFOulDs1Qw0bAWf34aD4Ai8
 1lochKU0eavs0SoP5rb2RLeCpm0o7UOwoaSNSzv+XQTfUuguIXCXHRX2BW0VLero
 RNsz8WF/4g0iRv70JvSyQXnKZed3cEQYcu1JzhE/hxRGaQDsqPDJ1GL7Wx1X5xBF
 0zPGKtfUPfcXAkuyOtkhGrT+HqmNARxZJRV/W67tJ7b0+Cz3L0W98dPMClNlTcwW
 L/Kz00QXW4TBW09Xo1JXq7v+9Z074IRFF26lDZl/jLWarh4F/ii1cGBmMwLtP8rw
 0BJAGFlYP7/Pmw==
 =uPAF
 -----END PGP SIGNATURE-----

Merge tag 'riscv-for-linus-5.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:
 "A handful of fixes for this week:

   - A fix to avoid evalating the VA twice in virt_addr_valid, which
     fixes some WARNs under DEBUG_VIRTUAL.

   - Two fixes related to STRICT_KERNEL_RWX: one that fixes some
     permissions when strict is disabled, and one to fix some alignment
     issues when strict is enabled.

   - A fix to disallow the selection of MAXPHYSMEM_2GB on RV32, which
     isn't valid any more but may still show up in some oldconfigs.

  We still have the HiFive Unleashed ethernet phy reset regression, so
  there will likely be something coming next week"

* tag 'riscv-for-linus-5.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  RISC-V: Define MAXPHYSMEM_1GB only for RV32
  riscv: Align on L1_CACHE_BYTES when STRICT_KERNEL_RWX
  RISC-V: Fix .init section permission update
  riscv: virt_addr_valid must check the address belongs to linear mapping
This commit is contained in:
Linus Torvalds 2021-02-06 15:18:10 -08:00
commit f7455e5d68
4 changed files with 12 additions and 5 deletions

View File

@ -252,8 +252,10 @@ choice
default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY
config MAXPHYSMEM_1GB
depends on 32BIT
bool "1GiB"
config MAXPHYSMEM_2GB
depends on 64BIT && CMODEL_MEDLOW
bool "2GiB"
config MAXPHYSMEM_128GB
depends on 64BIT && CMODEL_MEDANY

View File

@ -135,7 +135,10 @@ extern phys_addr_t __phys_addr_symbol(unsigned long x);
#endif /* __ASSEMBLY__ */
#define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr)))
#define virt_addr_valid(vaddr) ({ \
unsigned long _addr = (unsigned long)vaddr; \
(unsigned long)(_addr) >= PAGE_OFFSET && pfn_valid(virt_to_pfn(_addr)); \
})
#define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC

View File

@ -32,14 +32,14 @@ bool kernel_page_present(struct page *page);
#endif /* __ASSEMBLY__ */
#ifdef CONFIG_ARCH_HAS_STRICT_KERNEL_RWX
#ifdef CONFIG_STRICT_KERNEL_RWX
#ifdef CONFIG_64BIT
#define SECTION_ALIGN (1 << 21)
#else
#define SECTION_ALIGN (1 << 22)
#endif
#else /* !CONFIG_ARCH_HAS_STRICT_KERNEL_RWX */
#else /* !CONFIG_STRICT_KERNEL_RWX */
#define SECTION_ALIGN L1_CACHE_BYTES
#endif /* CONFIG_ARCH_HAS_STRICT_KERNEL_RWX */
#endif /* CONFIG_STRICT_KERNEL_RWX */
#endif /* _ASM_RISCV_SET_MEMORY_H */

View File

@ -293,6 +293,8 @@ void free_initmem(void)
unsigned long init_begin = (unsigned long)__init_begin;
unsigned long init_end = (unsigned long)__init_end;
set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX))
set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
free_initmem_default(POISON_FREE_INITMEM);
}