Skip to content

Commit f7455e5

Browse files
committed
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
2 parents f06279e + de5f4b8 commit f7455e5

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

arch/riscv/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,10 @@ choice
252252
default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY
253253

254254
config MAXPHYSMEM_1GB
255+
depends on 32BIT
255256
bool "1GiB"
256257
config MAXPHYSMEM_2GB
258+
depends on 64BIT && CMODEL_MEDLOW
257259
bool "2GiB"
258260
config MAXPHYSMEM_128GB
259261
depends on 64BIT && CMODEL_MEDANY

arch/riscv/include/asm/page.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ extern phys_addr_t __phys_addr_symbol(unsigned long x);
135135

136136
#endif /* __ASSEMBLY__ */
137137

138-
#define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr)))
138+
#define virt_addr_valid(vaddr) ({ \
139+
unsigned long _addr = (unsigned long)vaddr; \
140+
(unsigned long)(_addr) >= PAGE_OFFSET && pfn_valid(virt_to_pfn(_addr)); \
141+
})
139142

140143
#define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
141144

arch/riscv/include/asm/set_memory.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ bool kernel_page_present(struct page *page);
3232

3333
#endif /* __ASSEMBLY__ */
3434

35-
#ifdef CONFIG_ARCH_HAS_STRICT_KERNEL_RWX
35+
#ifdef CONFIG_STRICT_KERNEL_RWX
3636
#ifdef CONFIG_64BIT
3737
#define SECTION_ALIGN (1 << 21)
3838
#else
3939
#define SECTION_ALIGN (1 << 22)
4040
#endif
41-
#else /* !CONFIG_ARCH_HAS_STRICT_KERNEL_RWX */
41+
#else /* !CONFIG_STRICT_KERNEL_RWX */
4242
#define SECTION_ALIGN L1_CACHE_BYTES
43-
#endif /* CONFIG_ARCH_HAS_STRICT_KERNEL_RWX */
43+
#endif /* CONFIG_STRICT_KERNEL_RWX */
4444

4545
#endif /* _ASM_RISCV_SET_MEMORY_H */

arch/riscv/kernel/setup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ void free_initmem(void)
293293
unsigned long init_begin = (unsigned long)__init_begin;
294294
unsigned long init_end = (unsigned long)__init_end;
295295

296-
set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
296+
if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX))
297+
set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
298+
297299
free_initmem_default(POISON_FREE_INITMEM);
298300
}

0 commit comments

Comments
 (0)