linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: fixmap: fix missing sub-page offset for earlyprintk
@ 2014-04-28 18:50 Marc Zyngier
  2014-04-28 19:44 ` Mark Salter
  2014-04-28 23:51 ` Rob Herring
  0 siblings, 2 replies; 4+ messages in thread
From: Marc Zyngier @ 2014-04-28 18:50 UTC (permalink / raw)
  To: linux-arm-kernel

Commit d57c33c5daa4 (add generic fixmap.h) added (among other
similar things) set_fixmap_io to deal with early ioremap of devices.

More recently, commit bf4b558eba92 (arm64: add early_ioremap support)
converted the arm64 earlyprintk to use set_fixmap_io. A side effect of
this conversion is that my virtual machines have stopped booting when
I pass "earlyprintk=uart8250-8bit,0x3f8" to the guest kernel.

Turns out that the new earlyprintk code doesn't care at all about
sub-page offsets, and just assumes that the earlyprintk device will
be page-aligned. Obviously, that doesn't play well with the above example.

Further investigation shows that set_fixmap_io uses __set_fixmap instead
of __set_fixmap_offset. A fix is to introduce a set_fixmap_offset_io that
uses the latter, and to remove the superflous call to fix_to_virt
(which only returns the value that set_fixmap_io has already given us).

With this applied, my VMs are back in business. Tested on a Cortex-A57
platform with kvmtool as platform emulation.

Cc: Mark Salter <msalter@redhat.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 arch/arm64/kernel/early_printk.c | 6 ++----
 include/asm-generic/fixmap.h     | 3 +++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kernel/early_printk.c b/arch/arm64/kernel/early_printk.c
index ffbbdde..2dc36d0 100644
--- a/arch/arm64/kernel/early_printk.c
+++ b/arch/arm64/kernel/early_printk.c
@@ -143,10 +143,8 @@ static int __init setup_early_printk(char *buf)
 	}
 	/* no options parsing yet */
 
-	if (paddr) {
-		set_fixmap_io(FIX_EARLYCON_MEM_BASE, paddr);
-		early_base = (void __iomem *)fix_to_virt(FIX_EARLYCON_MEM_BASE);
-	}
+	if (paddr)
+		early_base = (void __iomem *)set_fixmap_offset_io(FIX_EARLYCON_MEM_BASE, paddr);
 
 	printch = match->printch;
 	early_console = &early_console_dev;
diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
index 5a64ca4..f23174f 100644
--- a/include/asm-generic/fixmap.h
+++ b/include/asm-generic/fixmap.h
@@ -93,5 +93,8 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
 #define set_fixmap_io(idx, phys) \
 	__set_fixmap(idx, phys, FIXMAP_PAGE_IO)
 
+#define set_fixmap_offset_io(idx, phys) \
+	__set_fixmap_offset(idx, phys, FIXMAP_PAGE_IO)
+
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_GENERIC_FIXMAP_H */
-- 
1.8.3.4

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

* [PATCH] arm64: fixmap: fix missing sub-page offset for earlyprintk
  2014-04-28 18:50 [PATCH] arm64: fixmap: fix missing sub-page offset for earlyprintk Marc Zyngier
@ 2014-04-28 19:44 ` Mark Salter
  2014-04-28 23:51 ` Rob Herring
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Salter @ 2014-04-28 19:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2014-04-28 at 19:50 +0100, Marc Zyngier wrote:
> Commit d57c33c5daa4 (add generic fixmap.h) added (among other
> similar things) set_fixmap_io to deal with early ioremap of devices.
> 
> More recently, commit bf4b558eba92 (arm64: add early_ioremap support)
> converted the arm64 earlyprintk to use set_fixmap_io. A side effect of
> this conversion is that my virtual machines have stopped booting when
> I pass "earlyprintk=uart8250-8bit,0x3f8" to the guest kernel.
> 
> Turns out that the new earlyprintk code doesn't care at all about
> sub-page offsets, and just assumes that the earlyprintk device will
> be page-aligned. Obviously, that doesn't play well with the above example.
> 
> Further investigation shows that set_fixmap_io uses __set_fixmap instead
> of __set_fixmap_offset. A fix is to introduce a set_fixmap_offset_io that
> uses the latter, and to remove the superflous call to fix_to_virt
> (which only returns the value that set_fixmap_io has already given us).
> 
> With this applied, my VMs are back in business. Tested on a Cortex-A57
> platform with kvmtool as platform emulation.
> 
> Cc: Mark Salter <msalter@redhat.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---

Acked-by: Mark Salter <msalter@redhat.com>

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

* [PATCH] arm64: fixmap: fix missing sub-page offset for earlyprintk
  2014-04-28 18:50 [PATCH] arm64: fixmap: fix missing sub-page offset for earlyprintk Marc Zyngier
  2014-04-28 19:44 ` Mark Salter
@ 2014-04-28 23:51 ` Rob Herring
  2014-04-29  8:57   ` Catalin Marinas
  1 sibling, 1 reply; 4+ messages in thread
From: Rob Herring @ 2014-04-28 23:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 28, 2014 at 1:50 PM, Marc Zyngier <marc.zyngier@arm.com> wrote:
> Commit d57c33c5daa4 (add generic fixmap.h) added (among other
> similar things) set_fixmap_io to deal with early ioremap of devices.
>
> More recently, commit bf4b558eba92 (arm64: add early_ioremap support)
> converted the arm64 earlyprintk to use set_fixmap_io. A side effect of
> this conversion is that my virtual machines have stopped booting when
> I pass "earlyprintk=uart8250-8bit,0x3f8" to the guest kernel.
>
> Turns out that the new earlyprintk code doesn't care at all about
> sub-page offsets, and just assumes that the earlyprintk device will
> be page-aligned. Obviously, that doesn't play well with the above example.
>
> Further investigation shows that set_fixmap_io uses __set_fixmap instead
> of __set_fixmap_offset. A fix is to introduce a set_fixmap_offset_io that
> uses the latter, and to remove the superflous call to fix_to_virt
> (which only returns the value that set_fixmap_io has already given us).
>
> With this applied, my VMs are back in business. Tested on a Cortex-A57
> platform with kvmtool as platform emulation.
>
> Cc: Mark Salter <msalter@redhat.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
>  arch/arm64/kernel/early_printk.c | 6 ++----
>  include/asm-generic/fixmap.h     | 3 +++
>  2 files changed, 5 insertions(+), 4 deletions(-)

This will be fixed already in 3.16 with my earlycon series[1] if this
is not taken for 3.15.

Probably still a good addition for fixmap.

Rob

[1] https://lkml.org/lkml/2014/4/18/573

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

* [PATCH] arm64: fixmap: fix missing sub-page offset for earlyprintk
  2014-04-28 23:51 ` Rob Herring
@ 2014-04-29  8:57   ` Catalin Marinas
  0 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2014-04-29  8:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 29, 2014 at 12:51:18AM +0100, Rob Herring wrote:
> On Mon, Apr 28, 2014 at 1:50 PM, Marc Zyngier <marc.zyngier@arm.com> wrote:
> > Commit d57c33c5daa4 (add generic fixmap.h) added (among other
> > similar things) set_fixmap_io to deal with early ioremap of devices.
> >
> > More recently, commit bf4b558eba92 (arm64: add early_ioremap support)
> > converted the arm64 earlyprintk to use set_fixmap_io. A side effect of
> > this conversion is that my virtual machines have stopped booting when
> > I pass "earlyprintk=uart8250-8bit,0x3f8" to the guest kernel.
> >
> > Turns out that the new earlyprintk code doesn't care at all about
> > sub-page offsets, and just assumes that the earlyprintk device will
> > be page-aligned. Obviously, that doesn't play well with the above example.
> >
> > Further investigation shows that set_fixmap_io uses __set_fixmap instead
> > of __set_fixmap_offset. A fix is to introduce a set_fixmap_offset_io that
> > uses the latter, and to remove the superflous call to fix_to_virt
> > (which only returns the value that set_fixmap_io has already given us).
> >
> > With this applied, my VMs are back in business. Tested on a Cortex-A57
> > platform with kvmtool as platform emulation.
> >
> > Cc: Mark Salter <msalter@redhat.com>
> > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > Cc: Will Deacon <will.deacon@arm.com>
> > Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> > ---
> >  arch/arm64/kernel/early_printk.c | 6 ++----
> >  include/asm-generic/fixmap.h     | 3 +++
> >  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> This will be fixed already in 3.16 with my earlycon series[1] if this
> is not taken for 3.15.

I'd like to take this for 3.15 as it's currently broken. I just need
another ack from Arnd on the generic header change.

-- 
Catalin

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

end of thread, other threads:[~2014-04-29  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-28 18:50 [PATCH] arm64: fixmap: fix missing sub-page offset for earlyprintk Marc Zyngier
2014-04-28 19:44 ` Mark Salter
2014-04-28 23:51 ` Rob Herring
2014-04-29  8:57   ` Catalin Marinas

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).