linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany
@ 2019-03-24 11:08 Anup Patel
  2019-03-24 14:57 ` Christoph Hellwig
  2019-03-24 19:14 ` Gary Guo
  0 siblings, 2 replies; 7+ messages in thread
From: Anup Patel @ 2019-03-24 11:08 UTC (permalink / raw)
  To: Palmer Dabbelt, Albert Ou
  Cc: Atish Patra, Paul Walmsley, Christoph Hellwig, Mike Rapoport,
	linux-riscv, linux-kernel, Anup Patel, Christoph Hellwig

The Linux RISC-V 32bit kernel is broken after we moved setup_vm() from
kernel/setup.c to mm/init.c because Linux RISC-V 32bit kernel by default
uses cmodel=medlow which results in a non-position-independent setup_vm().

This patch fixes Linux RISC-V 32bit kernel booting by:
1. Forcing cmodel=medany for mm/init.c
2. Moving remaing MM-related stuff va_pa_offset, pfn_base and
   empty_zero_page from kernel/setup.c to mm/init.c

Fixes: 6f1e9e946f0b ("RISC-V: Move setup_vm() to mm/init.c")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
---
 arch/riscv/kernel/setup.c | 8 --------
 arch/riscv/mm/Makefile    | 2 ++
 arch/riscv/mm/init.c      | 9 +++++++++
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index ecb654f6a79e..540a331d1376 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -48,14 +48,6 @@ struct screen_info screen_info = {
 };
 #endif
 
-unsigned long va_pa_offset;
-EXPORT_SYMBOL(va_pa_offset);
-unsigned long pfn_base;
-EXPORT_SYMBOL(pfn_base);
-
-unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
-EXPORT_SYMBOL(empty_zero_page);
-
 /* The lucky hart to first increment this variable will boot the other cores */
 atomic_t hart_lottery;
 unsigned long boot_cpu_hartid;
diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile
index eb22ab49b3e0..7307609d405b 100644
--- a/arch/riscv/mm/Makefile
+++ b/arch/riscv/mm/Makefile
@@ -3,3 +3,5 @@ obj-y += fault.o
 obj-y += extable.o
 obj-y += ioremap.o
 obj-y += cacheflush.o
+
+CFLAGS_init.o := -mcmodel=medany
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index b379a75ac6a6..1e7a106fb583 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -25,6 +25,15 @@
 #include <asm/pgtable.h>
 #include <asm/io.h>
 
+unsigned long va_pa_offset;
+EXPORT_SYMBOL(va_pa_offset);
+unsigned long pfn_base;
+EXPORT_SYMBOL(pfn_base);
+
+unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]
+							__page_aligned_bss;
+EXPORT_SYMBOL(empty_zero_page);
+
 static void __init zone_sizes_init(void)
 {
 	unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany
  2019-03-24 11:08 [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany Anup Patel
@ 2019-03-24 14:57 ` Christoph Hellwig
  2019-03-24 16:43   ` Mike Rapoport
  2019-03-25  3:19   ` Anup Patel
  2019-03-24 19:14 ` Gary Guo
  1 sibling, 2 replies; 7+ messages in thread
From: Christoph Hellwig @ 2019-03-24 14:57 UTC (permalink / raw)
  To: Anup Patel
  Cc: Palmer Dabbelt, Albert Ou, Atish Patra, Paul Walmsley,
	Christoph Hellwig, Mike Rapoport, linux-riscv, linux-kernel,
	Christoph Hellwig

On Sun, Mar 24, 2019 at 11:08:29AM +0000, Anup Patel wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>

Huh?  I don't think this is from Mike and me.

> +unsigned long va_pa_offset;
> +EXPORT_SYMBOL(va_pa_offset);
> +unsigned long pfn_base;
> +EXPORT_SYMBOL(pfn_base);

Can you move va_pa_offset and pfn_base next to the swapper_pg_dir
declaration?  Thats where I move them in my current nommu patchset,
as that allows to just have a single CONFIG_NOMMU in mm/init.c.

Otherwise this looks fine to me.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany
  2019-03-24 14:57 ` Christoph Hellwig
@ 2019-03-24 16:43   ` Mike Rapoport
  2019-03-25  3:19     ` Anup Patel
  2019-03-25  3:19   ` Anup Patel
  1 sibling, 1 reply; 7+ messages in thread
From: Mike Rapoport @ 2019-03-24 16:43 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Anup Patel, Palmer Dabbelt, Albert Ou, Atish Patra,
	Paul Walmsley, Christoph Hellwig, linux-riscv, linux-kernel

On Sun, Mar 24, 2019 at 03:57:08PM +0100, Christoph Hellwig wrote:
> On Sun, Mar 24, 2019 at 11:08:29AM +0000, Anup Patel wrote:
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> 
> Huh?  I don't think this is from Mike and me.

Suggested-by: would me more appropriate indeed :)
 
> > +unsigned long va_pa_offset;
> > +EXPORT_SYMBOL(va_pa_offset);
> > +unsigned long pfn_base;
> > +EXPORT_SYMBOL(pfn_base);
> 
> Can you move va_pa_offset and pfn_base next to the swapper_pg_dir
> declaration?  Thats where I move them in my current nommu patchset,
> as that allows to just have a single CONFIG_NOMMU in mm/init.c.
> 
> Otherwise this looks fine to me.
> 

-- 
Sincerely yours,
Mike.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany
  2019-03-24 11:08 [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany Anup Patel
  2019-03-24 14:57 ` Christoph Hellwig
@ 2019-03-24 19:14 ` Gary Guo
  2019-03-25  3:21   ` Anup Patel
  1 sibling, 1 reply; 7+ messages in thread
From: Gary Guo @ 2019-03-24 19:14 UTC (permalink / raw)
  To: Anup Patel
  Cc: Palmer Dabbelt, Albert Ou, linux-kernel, Mike Rapoport,
	Christoph Hellwig, Atish Patra, Paul Walmsley, linux-riscv,
	Christoph Hellwig



> -----Original Message-----
> From: linux-riscv <linux-riscv-bounces@lists.infradead.org> On Behalf Of Anup
> Patel
> Sent: Sunday, March 24, 2019 11:08
> To: Palmer Dabbelt <palmer@sifive.com>; Albert Ou <aou@eecs.berkeley.edu>
> Cc: Anup Patel <Anup.Patel@wdc.com>; linux-kernel@vger.kernel.org; Mike
> Rapoport <rppt@linux.ibm.com>; Christoph Hellwig <hch@infradead.org>; Atish
> Patra <Atish.Patra@wdc.com>; Paul Walmsley <paul.walmsley@sifive.com>;
> linux-riscv@lists.infradead.org; Christoph Hellwig <hch@lst.de>
> Subject: [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany
> 
> diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile
> index eb22ab49b3e0..7307609d405b 100644
> --- a/arch/riscv/mm/Makefile
> +++ b/arch/riscv/mm/Makefile
> @@ -3,3 +3,5 @@ obj-y += fault.o
>  obj-y += extable.o
>  obj-y += ioremap.o
>  obj-y += cacheflush.o
> +
> +CFLAGS_init.o := -mcmodel=medany

I think you should also remove CFLAGS_setup.o from kernel/Makefile, as I think it was there solely for the correctness of setup_vm. As setup_vm is now in mm/init.o, the old CFLAGS probably isn't needed and should be removed in the same patch. Disclaimer: I haven't tested it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany
  2019-03-24 16:43   ` Mike Rapoport
@ 2019-03-25  3:19     ` Anup Patel
  0 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2019-03-25  3:19 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Christoph Hellwig, Anup Patel, Palmer Dabbelt, Albert Ou,
	Atish Patra, Paul Walmsley, Christoph Hellwig, linux-riscv,
	linux-kernel

On Sun, Mar 24, 2019 at 10:13 PM Mike Rapoport <rppt@linux.ibm.com> wrote:
>
> On Sun, Mar 24, 2019 at 03:57:08PM +0100, Christoph Hellwig wrote:
> > On Sun, Mar 24, 2019 at 11:08:29AM +0000, Anup Patel wrote:
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > > Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> >
> > Huh?  I don't think this is from Mike and me.
>
> Suggested-by: would me more appropriate indeed :)

Sure, I will use Suggested-by: here.

Regards,
Anup

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany
  2019-03-24 14:57 ` Christoph Hellwig
  2019-03-24 16:43   ` Mike Rapoport
@ 2019-03-25  3:19   ` Anup Patel
  1 sibling, 0 replies; 7+ messages in thread
From: Anup Patel @ 2019-03-25  3:19 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Anup Patel, Palmer Dabbelt, Albert Ou, Atish Patra,
	Paul Walmsley, Christoph Hellwig, Mike Rapoport, linux-riscv,
	linux-kernel

On Sun, Mar 24, 2019 at 8:27 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Sun, Mar 24, 2019 at 11:08:29AM +0000, Anup Patel wrote:
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
>
> Huh?  I don't think this is from Mike and me.
>
> > +unsigned long va_pa_offset;
> > +EXPORT_SYMBOL(va_pa_offset);
> > +unsigned long pfn_base;
> > +EXPORT_SYMBOL(pfn_base);
>
> Can you move va_pa_offset and pfn_base next to the swapper_pg_dir
> declaration?  Thats where I move them in my current nommu patchset,
> as that allows to just have a single CONFIG_NOMMU in mm/init.c.
>
> Otherwise this looks fine to me.

Sure, no problem. I will send update and send v2.

Regards,
Anup

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany
  2019-03-24 19:14 ` Gary Guo
@ 2019-03-25  3:21   ` Anup Patel
  0 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2019-03-25  3:21 UTC (permalink / raw)
  To: Gary Guo
  Cc: Anup Patel, Palmer Dabbelt, Albert Ou, linux-kernel,
	Mike Rapoport, Christoph Hellwig, Atish Patra, Paul Walmsley,
	linux-riscv, Christoph Hellwig

On Mon, Mar 25, 2019 at 12:44 AM Gary Guo <gary@garyguo.net> wrote:
>
>
>
> > -----Original Message-----
> > From: linux-riscv <linux-riscv-bounces@lists.infradead.org> On Behalf Of Anup
> > Patel
> > Sent: Sunday, March 24, 2019 11:08
> > To: Palmer Dabbelt <palmer@sifive.com>; Albert Ou <aou@eecs.berkeley.edu>
> > Cc: Anup Patel <Anup.Patel@wdc.com>; linux-kernel@vger.kernel.org; Mike
> > Rapoport <rppt@linux.ibm.com>; Christoph Hellwig <hch@infradead.org>; Atish
> > Patra <Atish.Patra@wdc.com>; Paul Walmsley <paul.walmsley@sifive.com>;
> > linux-riscv@lists.infradead.org; Christoph Hellwig <hch@lst.de>
> > Subject: [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany
> >
> > diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile
> > index eb22ab49b3e0..7307609d405b 100644
> > --- a/arch/riscv/mm/Makefile
> > +++ b/arch/riscv/mm/Makefile
> > @@ -3,3 +3,5 @@ obj-y += fault.o
> >  obj-y += extable.o
> >  obj-y += ioremap.o
> >  obj-y += cacheflush.o
> > +
> > +CFLAGS_init.o := -mcmodel=medany
>
> I think you should also remove CFLAGS_setup.o from kernel/Makefile, as I think it was there solely for the correctness of setup_vm. As setup_vm is now in mm/init.o, the old CFLAGS probably isn't needed and should be removed in the same patch. Disclaimer: I haven't tested it.

Sure, I will remove it in v2 patch. Thanks for catching.

Regards,
Anup

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-03-25  3:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-24 11:08 [PATCH] RISC-V: Always compile mm/init.c with cmodel=medany Anup Patel
2019-03-24 14:57 ` Christoph Hellwig
2019-03-24 16:43   ` Mike Rapoport
2019-03-25  3:19     ` Anup Patel
2019-03-25  3:19   ` Anup Patel
2019-03-24 19:14 ` Gary Guo
2019-03-25  3:21   ` Anup Patel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).