Commit 7a5da02de8d6 ("locking/lockdep: check for freed initmem in
static_obj()") added arch_is_kernel_initmem_freed() which is supposed
to report whether an object is part of already freed init memory.
For the time being, the generic version of arch_is_kernel_initmem_freed()
always reports 'false', allthough free_initmem() is generically called
on all architectures.
Therefore, change the generic version of arch_is_kernel_initmem_freed()
to check whether free_initmem() has been called. If so, then check
if a given address falls into init memory.
In order to use function init_section_contains(), the fonction is
moved at the end of asm-generic/section.h
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Christophe Leroy <redacted>
---
include/asm-generic/sections.h | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
Generic version of arch_is_kernel_initmem_freed() now does the same
as s390 version.
Remove the s390 version.
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Christophe Leroy <redacted>
---
arch/s390/include/asm/sections.h | 12 ------------
arch/s390/mm/init.c | 3 ---
2 files changed, 15 deletions(-)
Generic version of arch_is_kernel_initmem_freed() now does the same
as powerpc version.
Remove the powerpc version.
Signed-off-by: Christophe Leroy <redacted>
---
arch/powerpc/include/asm/sections.h | 13 -------------
1 file changed, 13 deletions(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2021-09-27 13:12:10
Christophe Leroy [off-list ref] writes:
quoted hunk
Commit 7a5da02de8d6 ("locking/lockdep: check for freed initmem in
static_obj()") added arch_is_kernel_initmem_freed() which is supposed
to report whether an object is part of already freed init memory.
For the time being, the generic version of arch_is_kernel_initmem_freed()
always reports 'false', allthough free_initmem() is generically called
on all architectures.
Therefore, change the generic version of arch_is_kernel_initmem_freed()
to check whether free_initmem() has been called. If so, then check
if a given address falls into init memory.
In order to use function init_section_contains(), the fonction is
moved at the end of asm-generic/section.h
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Christophe Leroy <redacted>
---
include/asm-generic/sections.h | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
This will return an incorrect result for a short period during boot
won't it?
See init/main.c:
static int __ref kernel_init(void *unused)
{
...
free_initmem(); <- memory is freed here
mark_readonly();
/*
* Kernel mappings are now finalized - update the userspace page-table
* to finalize PTI.
*/
pti_finalize();
system_state = SYSTEM_RUNNING;
After free_initmem() we have address ranges that are now freed initmem,
but arch_is_kernel_initmem_freed() continues to return 0 (false) for all
addresses, until we update system_state.
Possibly that doesn't matter for any of the current callers, but it
seems pretty dicey to me.
cheers
Commit 7a5da02de8d6 ("locking/lockdep: check for freed initmem in
static_obj()") added arch_is_kernel_initmem_freed() which is supposed
to report whether an object is part of already freed init memory.
For the time being, the generic version of arch_is_kernel_initmem_freed()
always reports 'false', allthough free_initmem() is generically called
on all architectures.
Therefore, change the generic version of arch_is_kernel_initmem_freed()
to check whether free_initmem() has been called. If so, then check
if a given address falls into init memory.
In order to use function init_section_contains(), the fonction is
moved at the end of asm-generic/section.h
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Christophe Leroy <redacted>
---
include/asm-generic/sections.h | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
This will return an incorrect result for a short period during boot
won't it?
See init/main.c:
static int __ref kernel_init(void *unused)
{
...
free_initmem(); <- memory is freed here
mark_readonly();
/*
* Kernel mappings are now finalized - update the userspace page-table
* to finalize PTI.
*/
pti_finalize();
system_state = SYSTEM_RUNNING;
After free_initmem() we have address ranges that are now freed initmem,
but arch_is_kernel_initmem_freed() continues to return 0 (false) for all
addresses, until we update system_state.
Possibly that doesn't matter for any of the current callers, but it
seems pretty dicey to me.
Yes I saw it but as function core_kernel_text() uses that criteria for
deciding whether a given init text address is valid or not, I thought it
was just ok.
Should we add an intermediate state called for exemple
SYSTEM_FREEING_INIT just before SYSTEM_RUNNING ?
Christophe