Skip to content

Commit f774b7d

Browse files
Marc Zyngierctmarinas
authored andcommitted
arm64: fixmap: fix missing sub-page offset for earlyprintk
Commit d57c33c (add generic fixmap.h) added (among other similar things) set_fixmap_io to deal with early ioremap of devices. More recently, commit bf4b558 (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: Will Deacon <will.deacon@arm.com> Acked-by: Mark Salter <msalter@redhat.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent da6e4cb commit f774b7d

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎arch/arm64/kernel/early_printk.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,8 @@ static int __init setup_early_printk(char *buf)
143143
}
144144
/* no options parsing yet */
145145

146-
if (paddr) {
147-
set_fixmap_io(FIX_EARLYCON_MEM_BASE, paddr);
148-
early_base = (void __iomem *)fix_to_virt(FIX_EARLYCON_MEM_BASE);
149-
}
146+
if (paddr)
147+
early_base = (void __iomem *)set_fixmap_offset_io(FIX_EARLYCON_MEM_BASE, paddr);
150148

151149
printch = match->printch;
152150
early_console = &early_console_dev;

‎include/asm-generic/fixmap.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,8 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
9393
#define set_fixmap_io(idx, phys) \
9494
__set_fixmap(idx, phys, FIXMAP_PAGE_IO)
9595

96+
#define set_fixmap_offset_io(idx, phys) \
97+
__set_fixmap_offset(idx, phys, FIXMAP_PAGE_IO)
98+
9699
#endif /* __ASSEMBLY__ */
97100
#endif /* __ASM_GENERIC_FIXMAP_H */

0 commit comments

Comments
 (0)