Hi Arnd,
On Tue, Sep 26, 2023 at 09:33:48AM +0200, Arnd Bergmann wrote:
> On Mon, Sep 18, 2023, at 09:29, Mike Rapoport wrote:
> > index a42e4cd11db2..c0b536e398b4 100644
> > --- a/arch/arm/mm/init.c
> > +++ b/arch/arm/mm/init.c
> > +#ifdef CONFIG_XIP_KERNEL
> > +/*
> > + * The XIP kernel text is mapped in the module area for modules and
> > + * some other stuff to work without any indirect relocations.
> > + * MODULES_VADDR is redefined here and not in asm/memory.h to avoid
> > + * recompiling the whole kernel when CONFIG_XIP_KERNEL is turned
> > on/off.
> > + */
> > +#undef MODULES_VADDR
> > +#define MODULES_VADDR (((unsigned long)_exiprom + ~PMD_MASK) &
> > PMD_MASK)
> > +#endif
> > +
> > +#if defined(CONFIG_MMU) && defined(CONFIG_EXECMEM)
> > +static struct execmem_params execmem_params __ro_after_init = {
> > + .ranges = {
> > + [EXECMEM_DEFAULT] = {
> > + .start = MODULES_VADDR,
> > + .end = MODULES_END,
> > + .alignment = 1,
> > + },
>
> This causes a randconfig build failure for me on linux-next now:
>
> arch/arm/mm/init.c:499:25: error: initializer element is not constant
> 499 | #define MODULES_VADDR (((unsigned long)_exiprom + ~PMD_MASK) &
> PMD_MASK)
> | ^
> arch/arm/mm/init.c:506:34: note: in expansion of macro 'MODULES_VADDR'
> 506 | .start = MODULES_VADDR,
> | ^
> arch/arm/mm/init.c:499:25: note: (near initialization for
> 'execmem_params.ranges[0].start')
> 499 | #define MODULES_VADDR (((unsigned long)_exiprom + ~PMD_MASK) &
> PMD_MASK)
> | ^
> arch/arm/mm/init.c:506:34: note: in expansion of macro 'MODULES_VADDR'
> 506 | .start = MODULES_VADDR,
> | ^
>
> I have not done any analysis on the issue so far, I hope
> you can see the problem directly. See
> https://pastebin.com/raw/xVqAyakH for a .config that runs into
> this problem with gcc-13.2.0.
The first patch that breaks XIP build is rather patch 04/13, currently
commit 52a34d45419f ("mm/execmem, arch: convert remaining overrides of
module_alloc to execmem") in mm.git/mm-unstable.
The hunk below is a fix for that and the attached patch is the updated
version of 835bc9685f45 ("arch: make execmem setup available regardless of
CONFIG_MODULES")
Andrew, please let me know if you'd like to me to resend these differently.
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 2c7651a2d84c..096cc1ead635 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -38,8 +38,6 @@
static struct execmem_params execmem_params __ro_after_init = {
.ranges = {
[EXECMEM_DEFAULT] = {
- .start = MODULES_VADDR,
- .end = MODULES_END,
.alignment = 1,
},
},
@@ -49,6 +47,8 @@ struct execmem_params __init *execmem_arch_params(void)
{
struct execmem_range *r = _params.ranges[EXECMEM_DEFAULT];
+ r->start = MODULES_VADDR;
+ r->end = MODULES_END;
r->pgprot = PAGE_KERNEL_EXEC;
if (IS_ENABLED(CONFIG_ARM_MODULE_PLTS)) {
>
> Arnd
--
Sincerely yours,
Mike.
>From a2dae5a88d172d54e7f074799a286faedd2cdb6a Mon Sep 17 00:00:00 2001
From: "Mike Rapoport (IBM)"
Date: Wed, 31 May 2023 14:58:24 +0300
Subject: [PATCH] arch: make execmem setup available regardless of
CONFIG_MODULES
execmem does not depend on modules, on the contrary modules use
execmem.
To make execmem available when CONFIG_MODULES=n, for instance for
kprobes, split execmem_params initialization out from
arch/kernel/module.c and compile it when CONFIG_EXECMEM=y
Signed-off-by: Mike Rapoport (IBM)
---
arch/arm/kernel/module.c | 38 --
arch/arm/mm/init.c | 38 ++
arch/arm64/kernel/module.c | 130
arch/arm64/mm/init.c | 132 +
arch/loongarch/kernel/module.c | 18 -
arch/loongarch/mm/init.c | 20 +
arch/mips/kernel/module.c | 19 -
arch/mips/mm/init.c| 20 +
arch/parisc/kernel/module.c| 17 -
arch/parisc/mm/init.c | 22 +-
arch/powerpc/kernel/module.c | 60 ---
arch/powerpc/mm/mem.c | 62
arch/riscv/kernel/module.c | 39 --
arch/riscv/mm/init.c | 39 ++
arch/s390/kernel/module.c | 25 ---
arch/s390/mm/init.c| 28 +++
arch/sparc/kernel/module.c | 23 --
arch/sparc/mm/Makefile | 2 +
arch/sparc/mm/execmem.c| 25 +++
arch/x86/kernel/module.c | 27 ---
arch/x86/mm/init.c | 29
21 files changed, 416 insertions(+), 397 deletions(-)
create mode 100644 arch/sparc/mm/execmem.c