Re: [PATCH 2/2] asm-generic: add an optional pfn_valid check to page_to_phys
Le 23/10/2024 à 07:36, Christoph Hellwig a écrit : page_to_pfn is usually implemented by pointer arithmetics on the memory map, which means that bogus input can lead to even more bogus output. Powerpc had a pfn_valid check on the intermediate pfn in the page_to_phys implementation when CONFIG_DEBUG_VIRTUAL is defined, which seems generally useful, so add that to the generic version. Signed-off-by: Christoph Hellwig --- include/asm-generic/memory_model.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/include/asm-generic/memory_model.h b/include/asm-generic/memory_model.h index a73a140cbecd..6d1fb6162ac1 100644 --- a/include/asm-generic/memory_model.h +++ b/include/asm-generic/memory_model.h @@ -64,7 +64,17 @@ static inline int pfn_valid(unsigned long pfn) #define page_to_pfn __page_to_pfn #define pfn_to_page __pfn_to_page +#ifdef CONFIG_DEBUG_VIRTUAL +#define page_to_phys(page) \ +({ \ + unsigned long __pfn = page_to_pfn(page);\ + \ + WARN_ON_ONCE(!pfn_valid(__pfn));\ On powerpc I think it was a WARN_ON(). Will a WARN_ON_ONCE() be enough ? + PFN_PHYS(__pfn);\ +}) +#else #define page_to_phys(page)PFN_PHYS(page_to_pfn(page)) +#endif /* CONFIG_DEBUG_VIRTUAL */ #define phys_to_page(phys)pfn_to_page(PHYS_PFN(phys)) #endif /* __ASSEMBLY__ */ ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v7 6/8] x86/module: prepare module loading for ROX allocations of text
On Tue, Nov 05, 2024 at 09:02:26AM +0200, Mike Rapoport wrote: > There's a silly mistake in cfi_rewrite_endbr() in that commit, the patch > below should fix it. Can you please test? Yup, that was it! All my machines boot with this diff applied on top of next-20241105, so with that fixed, I think we are all good here. Tested-by: Nathan Chancellor > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > index 3407efc26528..243843e44e89 100644 > --- a/arch/x86/kernel/alternative.c > +++ b/arch/x86/kernel/alternative.c > @@ -1241,7 +1241,7 @@ static void cfi_rewrite_endbr(s32 *start, s32 *end, > struct module *mod) > void *addr = (void *)s + *s; > void *wr_addr = module_writable_address(mod, addr); > > - poison_endbr(addr+16, wr_addr, false); > + poison_endbr(addr + 16, wr_addr + 16, false); > } > } Cheers, Nathan ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc