* [PATCH] riscv: Correct the MODULES_VADDR
@ 2023-08-01 11:10 Song Shuai
2023-08-01 12:05 ` Alexandre Ghiti
0 siblings, 1 reply; 4+ messages in thread
From: Song Shuai @ 2023-08-01 11:10 UTC (permalink / raw)
To: paul.walmsley, palmer, aou, akpm, guoren, alexghiti,
sergey.matyukevich, david, wangkefeng.wang, panqinglin2020,
woodrow.shen
Cc: linux-riscv, linux-kernel, Song Shuai
As Documentation/riscv/vm-layout.rst describes, the 2G-sized "modules, BPF"
area should lie right before the "kernel" area. But the current definition
of MODULES_VADDR isn't consistent with that, so correct it.
Before this patch, the size of "modules" from print_vm_layout() is not 2G.
[ 0.000000] modules : 0xffffffff2ff2f000 - 0xffffffffae600000 (2022 MB)
[ 0.000000] lowmem : 0xff60000000000000 - 0xff60000040000000 (1024 MB)
[ 0.000000] kernel : 0xffffffffae600000 - 0xffffffffffffffff (1305 MB)
After this patch, the size is 2G.
[ 0.000000] modules : 0xffffffff3a000000 - 0xffffffffba000000 (2048 MB)
[ 0.000000] lowmem : 0xff60000000000000 - 0xff60000040000000 (1024 MB)
[ 0.000000] kernel : 0xffffffffba000000 - 0xffffffffffffffff (1119 MB)
Signed-off-by: Song Shuai <suagrfillet@gmail.com>
---
arch/riscv/include/asm/pgtable.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 75970ee2bda2..7c57e17fc758 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -53,8 +53,8 @@
#ifdef CONFIG_64BIT
/* This is used to define the end of the KASAN shadow region */
#define MODULES_LOWEST_VADDR (KERNEL_LINK_ADDR - SZ_2G)
-#define MODULES_VADDR (PFN_ALIGN((unsigned long)&_end) - SZ_2G)
#define MODULES_END (PFN_ALIGN((unsigned long)&_start))
+#define MODULES_VADDR (MODULES_END - SZ_2G)
#endif
/*
--
2.20.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: Correct the MODULES_VADDR
2023-08-01 11:10 [PATCH] riscv: Correct the MODULES_VADDR Song Shuai
@ 2023-08-01 12:05 ` Alexandre Ghiti
2023-08-01 23:20 ` Guo Ren
0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Ghiti @ 2023-08-01 12:05 UTC (permalink / raw)
To: Song Shuai
Cc: paul.walmsley, palmer, aou, akpm, guoren, sergey.matyukevich,
david, wangkefeng.wang, panqinglin2020, woodrow.shen,
linux-riscv, linux-kernel
Hi Song,
On Tue, Aug 1, 2023 at 1:10 PM Song Shuai <suagrfillet@gmail.com> wrote:
>
> As Documentation/riscv/vm-layout.rst describes, the 2G-sized "modules, BPF"
> area should lie right before the "kernel" area. But the current definition
> of MODULES_VADDR isn't consistent with that, so correct it.
>
> Before this patch, the size of "modules" from print_vm_layout() is not 2G.
>
> [ 0.000000] modules : 0xffffffff2ff2f000 - 0xffffffffae600000 (2022 MB)
> [ 0.000000] lowmem : 0xff60000000000000 - 0xff60000040000000 (1024 MB)
> [ 0.000000] kernel : 0xffffffffae600000 - 0xffffffffffffffff (1305 MB)
>
> After this patch, the size is 2G.
>
> [ 0.000000] modules : 0xffffffff3a000000 - 0xffffffffba000000 (2048 MB)
> [ 0.000000] lowmem : 0xff60000000000000 - 0xff60000040000000 (1024 MB)
> [ 0.000000] kernel : 0xffffffffba000000 - 0xffffffffffffffff (1119 MB)
>
> Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> ---
> arch/riscv/include/asm/pgtable.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index 75970ee2bda2..7c57e17fc758 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -53,8 +53,8 @@
> #ifdef CONFIG_64BIT
> /* This is used to define the end of the KASAN shadow region */
> #define MODULES_LOWEST_VADDR (KERNEL_LINK_ADDR - SZ_2G)
> -#define MODULES_VADDR (PFN_ALIGN((unsigned long)&_end) - SZ_2G)
> #define MODULES_END (PFN_ALIGN((unsigned long)&_start))
> +#define MODULES_VADDR (MODULES_END - SZ_2G)
> #endif
>
> /*
> --
> 2.20.1
>
The documentation is approximative, the modules must stay within a 2GB
window to *all* the kernel symbols, hence the __end - 2G, not __start.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: Correct the MODULES_VADDR
2023-08-01 12:05 ` Alexandre Ghiti
@ 2023-08-01 23:20 ` Guo Ren
2023-08-02 1:05 ` Song Shuai
0 siblings, 1 reply; 4+ messages in thread
From: Guo Ren @ 2023-08-01 23:20 UTC (permalink / raw)
To: Alexandre Ghiti
Cc: Song Shuai, paul.walmsley, palmer, aou, akpm, sergey.matyukevich,
david, wangkefeng.wang, panqinglin2020, woodrow.shen,
linux-riscv, linux-kernel
On Tue, Aug 1, 2023 at 8:05 AM Alexandre Ghiti <alexghiti@rivosinc.com> wrote:
>
> Hi Song,
>
> On Tue, Aug 1, 2023 at 1:10 PM Song Shuai <suagrfillet@gmail.com> wrote:
> >
> > As Documentation/riscv/vm-layout.rst describes, the 2G-sized "modules, BPF"
> > area should lie right before the "kernel" area. But the current definition
> > of MODULES_VADDR isn't consistent with that, so correct it.
> >
> > Before this patch, the size of "modules" from print_vm_layout() is not 2G.
> >
> > [ 0.000000] modules : 0xffffffff2ff2f000 - 0xffffffffae600000 (2022 MB)
> > [ 0.000000] lowmem : 0xff60000000000000 - 0xff60000040000000 (1024 MB)
> > [ 0.000000] kernel : 0xffffffffae600000 - 0xffffffffffffffff (1305 MB)
> >
> > After this patch, the size is 2G.
> >
> > [ 0.000000] modules : 0xffffffff3a000000 - 0xffffffffba000000 (2048 MB)
> > [ 0.000000] lowmem : 0xff60000000000000 - 0xff60000040000000 (1024 MB)
> > [ 0.000000] kernel : 0xffffffffba000000 - 0xffffffffffffffff (1119 MB)
> >
> > Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> > ---
> > arch/riscv/include/asm/pgtable.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> > index 75970ee2bda2..7c57e17fc758 100644
> > --- a/arch/riscv/include/asm/pgtable.h
> > +++ b/arch/riscv/include/asm/pgtable.h
> > @@ -53,8 +53,8 @@
> > #ifdef CONFIG_64BIT
> > /* This is used to define the end of the KASAN shadow region */
> > #define MODULES_LOWEST_VADDR (KERNEL_LINK_ADDR - SZ_2G)
> > -#define MODULES_VADDR (PFN_ALIGN((unsigned long)&_end) - SZ_2G)
> > #define MODULES_END (PFN_ALIGN((unsigned long)&_start))
> > +#define MODULES_VADDR (MODULES_END - SZ_2G)
> > #endif
> >
> > /*
> > --
> > 2.20.1
> >
>
> The documentation is approximative, the modules must stay within a 2GB
> window to *all* the kernel symbols, hence the __end - 2G, not __start.
Thus, the ftrace detour trampoline could cover all kernel symbols.
--
Best Regards
Guo Ren
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: Correct the MODULES_VADDR
2023-08-01 23:20 ` Guo Ren
@ 2023-08-02 1:05 ` Song Shuai
0 siblings, 0 replies; 4+ messages in thread
From: Song Shuai @ 2023-08-02 1:05 UTC (permalink / raw)
To: Guo Ren
Cc: Alexandre Ghiti, paul.walmsley, palmer, aou, akpm,
sergey.matyukevich, david, wangkefeng.wang, panqinglin2020,
woodrow.shen, linux-riscv, linux-kernel
Guo Ren <guoren@kernel.org> 于2023年8月1日周二 23:20写道:
>
> On Tue, Aug 1, 2023 at 8:05 AM Alexandre Ghiti <alexghiti@rivosinc.com> wrote:
> >
> > Hi Song,
> >
> > On Tue, Aug 1, 2023 at 1:10 PM Song Shuai <suagrfillet@gmail.com> wrote:
> > >
> > > As Documentation/riscv/vm-layout.rst describes, the 2G-sized "modules, BPF"
> > > area should lie right before the "kernel" area. But the current definition
> > > of MODULES_VADDR isn't consistent with that, so correct it.
> > >
> > > Before this patch, the size of "modules" from print_vm_layout() is not 2G.
> > >
> > > [ 0.000000] modules : 0xffffffff2ff2f000 - 0xffffffffae600000 (2022 MB)
> > > [ 0.000000] lowmem : 0xff60000000000000 - 0xff60000040000000 (1024 MB)
> > > [ 0.000000] kernel : 0xffffffffae600000 - 0xffffffffffffffff (1305 MB)
> > >
> > > After this patch, the size is 2G.
> > >
> > > [ 0.000000] modules : 0xffffffff3a000000 - 0xffffffffba000000 (2048 MB)
> > > [ 0.000000] lowmem : 0xff60000000000000 - 0xff60000040000000 (1024 MB)
> > > [ 0.000000] kernel : 0xffffffffba000000 - 0xffffffffffffffff (1119 MB)
> > >
> > > Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> > > ---
> > > arch/riscv/include/asm/pgtable.h | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> > > index 75970ee2bda2..7c57e17fc758 100644
> > > --- a/arch/riscv/include/asm/pgtable.h
> > > +++ b/arch/riscv/include/asm/pgtable.h
> > > @@ -53,8 +53,8 @@
> > > #ifdef CONFIG_64BIT
> > > /* This is used to define the end of the KASAN shadow region */
> > > #define MODULES_LOWEST_VADDR (KERNEL_LINK_ADDR - SZ_2G)
> > > -#define MODULES_VADDR (PFN_ALIGN((unsigned long)&_end) - SZ_2G)
> > > #define MODULES_END (PFN_ALIGN((unsigned long)&_start))
> > > +#define MODULES_VADDR (MODULES_END - SZ_2G)
> > > #endif
> > >
> > > /*
> > > --
> > > 2.20.1
> > >
> >
> > The documentation is approximative, the modules must stay within a 2GB
> > window to *all* the kernel symbols, hence the __end - 2G, not __start.
> Thus, the ftrace detour trampoline could cover all kernel symbols.
>
That's another view to help me understand the definition of
MODULES_VADDR,Thanks.
> --
> Best Regards
> Guo Ren
--
Thanks,
Song
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-02 1:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01 11:10 [PATCH] riscv: Correct the MODULES_VADDR Song Shuai
2023-08-01 12:05 ` Alexandre Ghiti
2023-08-01 23:20 ` Guo Ren
2023-08-02 1:05 ` Song Shuai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®