Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1631840 > unrolled thread

[PATCH] um: Fix to call read_initrd after init_bootmem

Started byMasami Hiramatsu <mhiramat@kernel.org>
First post2017-04-27 05:20 +0200
Last post2017-05-03 23:00 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] um: Fix to call read_initrd after init_bootmem Masami Hiramatsu <mhiramat@kernel.org> - 2017-04-27 05:20 +0200
    Re: [PATCH] um: Fix to call read_initrd after init_bootmem Richard Weinberger <richard@nod.at> - 2017-04-27 16:00 +0200
      Re: [PATCH] um: Fix to call read_initrd after init_bootmem Masami Hiramatsu <mhiramat@kernel.org> - 2017-04-28 00:10 +0200
        Re: [PATCH] um: Fix to call read_initrd after init_bootmem Richard Weinberger <richard@nod.at> - 2017-04-28 00:50 +0200
        Re: [PATCH] um: Fix to call read_initrd after init_bootmem Masami Hiramatsu <mhiramat@kernel.org> - 2017-04-28 00:50 +0200
    Re: [PATCH] um: Fix to call read_initrd after init_bootmem Richard Weinberger <richard.weinberger@gmail.com> - 2017-05-03 23:00 +0200

#1631840 — [PATCH] um: Fix to call read_initrd after init_bootmem

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2017-04-27 05:20 +0200
Subject[PATCH] um: Fix to call read_initrd after init_bootmem
Message-ID<tAI8h-34T-3@gated-at.bofh.it>
Since read_initrd() invokes alloc_bootmem() for allocating
memory to load initrd image, it must be called after init_bootmem.

This makes read_initrd() called directly from setup_arch()
after init_bootmem() and mem_total_pages().

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 arch/um/kernel/initrd.c  |    4 +---
 arch/um/kernel/um_arch.c |    6 ++++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/um/kernel/initrd.c b/arch/um/kernel/initrd.c
index 48bae81..6f6e789 100644
--- a/arch/um/kernel/initrd.c
+++ b/arch/um/kernel/initrd.c
@@ -14,7 +14,7 @@
 static char *initrd __initdata = NULL;
 static int load_initrd(char *filename, void *buf, int size);
 
-static int __init read_initrd(void)
+int __init read_initrd(void)
 {
 	void *area;
 	long long size;
@@ -46,8 +46,6 @@ static int __init read_initrd(void)
 	return 0;
 }
 
-__uml_postsetup(read_initrd);
-
 static int __init uml_initrd_setup(char *line, int *add)
 {
 	initrd = line;
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 4b85acd..64a1fd0 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -338,11 +338,17 @@ int __init linux_main(int argc, char **argv)
 	return start_uml();
 }
 
+int __init __weak read_initrd(void)
+{
+	return 0;
+}
+
 void __init setup_arch(char **cmdline_p)
 {
 	stack_protections((unsigned long) &init_thread_info);
 	setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem);
 	mem_total_pages(physmem_size, iomem_size, highmem);
+	read_initrd();
 
 	paging_init();
 	strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);

[toc] | [next] | [standalone]


#1632117

FromRichard Weinberger <richard@nod.at>
Date2017-04-27 16:00 +0200
Message-ID<tAS7E-1ly-17@gated-at.bofh.it>
In reply to#1631840
Masami,

Am 27.04.2017 um 05:15 schrieb Masami Hiramatsu:
> Since read_initrd() invokes alloc_bootmem() for allocating
> memory to load initrd image, it must be called after init_bootmem.
> 
> This makes read_initrd() called directly from setup_arch()
> after init_bootmem() and mem_total_pages().

Thanks for fixing this! Did you figure since when this is broken?
I think that should go into -stable.

Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1632399

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2017-04-28 00:10 +0200
Message-ID<tAZLQ-6S4-5@gated-at.bofh.it>
In reply to#1632117
Hi Richard,

On Thu, 27 Apr 2017 15:53:25 +0200
Richard Weinberger <richard@nod.at> wrote:

> Masami,
> 
> Am 27.04.2017 um 05:15 schrieb Masami Hiramatsu:
> > Since read_initrd() invokes alloc_bootmem() for allocating
> > memory to load initrd image, it must be called after init_bootmem.
> > 
> > This makes read_initrd() called directly from setup_arch()
> > after init_bootmem() and mem_total_pages().
> 
> Thanks for fixing this! Did you figure since when this is broken?
> I think that should go into -stable.

Thank you for quick response!
As far as I can see, v4.9 kernel has this issue, but v4.4 is OK.
Let me bisect it.

Thank you,

> 
> Thanks,
> //richard


-- 
Masami Hiramatsu <mhiramat@kernel.org>

[toc] | [prev] | [next] | [standalone]


#1632425

FromRichard Weinberger <richard@nod.at>
Date2017-04-28 00:50 +0200
Message-ID<tB0ox-78q-3@gated-at.bofh.it>
In reply to#1632399
Masami,

Am 28.04.2017 um 00:40 schrieb Masami Hiramatsu:
> Finally, git bisect shows that below commit caused this issue.
> 
> b63236972e1344b247750451e2be0a06cd125f21 is the first bad commit
> commit b63236972e1344b247750451e2be0a06cd125f21
> Author: Richard Weinberger <richard@nod.at>

Meh, it's always me. ;-)

> 
> For the stable, any kernel later than v4.8 has this issue.

Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1632426

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2017-04-28 00:50 +0200
Message-ID<tB0ox-78q-5@gated-at.bofh.it>
In reply to#1632399
On Fri, 28 Apr 2017 07:04:14 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Hi Richard,
> 
> On Thu, 27 Apr 2017 15:53:25 +0200
> Richard Weinberger <richard@nod.at> wrote:
> 
> > Masami,
> > 
> > Am 27.04.2017 um 05:15 schrieb Masami Hiramatsu:
> > > Since read_initrd() invokes alloc_bootmem() for allocating
> > > memory to load initrd image, it must be called after init_bootmem.
> > > 
> > > This makes read_initrd() called directly from setup_arch()
> > > after init_bootmem() and mem_total_pages().
> > 
> > Thanks for fixing this! Did you figure since when this is broken?
> > I think that should go into -stable.
> 
> Thank you for quick response!
> As far as I can see, v4.9 kernel has this issue, but v4.4 is OK.
> Let me bisect it.

Finally, git bisect shows that below commit caused this issue.

b63236972e1344b247750451e2be0a06cd125f21 is the first bad commit
commit b63236972e1344b247750451e2be0a06cd125f21
Author: Richard Weinberger <richard@nod.at>
Date:   Sun Jun 12 21:56:42 2016 +0200

    um: Setup physical memory in setup_arch()
    
    Currently UML sets up physical memory very early,
    long before setup_arch() was called by the kernel main
    function.
    This can cause problems when code paths in UML's memory setup
    code assume that the kernel is already running.
    i.e. when kmemleak is enabled it will evaluate current()
    in free_bootmem(). That early current() is undefined and
    UML explodes.
    
    Solve the problem by setting up physical memory in setup_arch(),
    at this stage the kernel has materialized and basic infrastructure
    such as current() works.
    
    Signed-off-by: Richard Weinberger <richard@nod.at>

:040000 040000 94b9403e37b4d14b54f801198af71aed66b07a30 641f2309b7badd723f1996f141aad962255dd689 M	arch

For the stable, any kernel later than v4.8 has this issue.

Thank you,

-- 
Masami Hiramatsu <mhiramat@kernel.org>

[toc] | [prev] | [next] | [standalone]


#1635277

FromRichard Weinberger <richard.weinberger@gmail.com>
Date2017-05-03 23:00 +0200
Message-ID<tD9xo-1ZQ-3@gated-at.bofh.it>
In reply to#1631840
On Thu, Apr 27, 2017 at 5:15 AM, Masami Hiramatsu <mhiramat@kernel.org> wrote:
> Since read_initrd() invokes alloc_bootmem() for allocating
> memory to load initrd image, it must be called after init_bootmem.
>
> This makes read_initrd() called directly from setup_arch()
> after init_bootmem() and mem_total_pages().
>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
>  arch/um/kernel/initrd.c  |    4 +---
>  arch/um/kernel/um_arch.c |    6 ++++++
>  2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/arch/um/kernel/initrd.c b/arch/um/kernel/initrd.c
> index 48bae81..6f6e789 100644
> --- a/arch/um/kernel/initrd.c
> +++ b/arch/um/kernel/initrd.c
> @@ -14,7 +14,7 @@
>  static char *initrd __initdata = NULL;
>  static int load_initrd(char *filename, void *buf, int size);
>
> -static int __init read_initrd(void)
> +int __init read_initrd(void)
>  {
>         void *area;
>         long long size;
> @@ -46,8 +46,6 @@ static int __init read_initrd(void)
>         return 0;
>  }
>
> -__uml_postsetup(read_initrd);
> -
>  static int __init uml_initrd_setup(char *line, int *add)
>  {
>         initrd = line;
> diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
> index 4b85acd..64a1fd0 100644
> --- a/arch/um/kernel/um_arch.c
> +++ b/arch/um/kernel/um_arch.c
> @@ -338,11 +338,17 @@ int __init linux_main(int argc, char **argv)
>         return start_uml();
>  }
>
> +int __init __weak read_initrd(void)
> +{
> +       return 0;
> +}
> +
>  void __init setup_arch(char **cmdline_p)
>  {
>         stack_protections((unsigned long) &init_thread_info);
>         setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem);
>         mem_total_pages(physmem_size, iomem_size, highmem);
> +       read_initrd();
>
>         paging_init();
>         strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
>

Applied.

-- 
Thanks,
//richard

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web