From 3f841c9e89701a9e46be140256dec848387788f5 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 20 Dec 2017 20:46:12 +0000 Subject: [PATCH] Restore the ability to use EARLY_PRINTF support during most of initarm(). The real kernel page tables are set up much earlier in initarm() now than they were when early printf support was first added, and they end up undoing the mapping made in locore.S for early printf support. This re-adds the mapping after switching to the new/real kernel page tables, making early printf work again right after switching to them. --- sys/arm/arm/machdep.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index 8d1584cd8e70..d1aa26c24b48 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -1128,6 +1128,19 @@ initarm(struct arm_boot_params *abp) pmap_set_tex(); pmap_bootstrap_prepare(lastaddr); + /* + * If EARLY_PRINTF support is enabled, we need to re-establish the + * mapping after pmap_bootstrap_prepare() switches to new page tables. + * Note that we can only do the remapping if the VA is outside the + * kernel, now that we have real virtual (not VA=PA) mappings in effect. + * Early printf does not work between the time pmap_set_tex() does + * cp15_prrr_set() and this code remaps the VA. + */ +#if defined(EARLY_PRINTF) && defined(SOCDEV_PA) && defined(SOCDEV_VA) && SOCDEV_VA < KERNBASE + pmap_preboot_map_attr(SOCDEV_PA, SOCDEV_VA, 1024 * 1024, + VM_PROT_READ | VM_PROT_WRITE, VM_MEMATTR_DEVICE); +#endif + /* * Now that proper page tables are installed, call cpu_setup() to enable * instruction and data caches and other chip-specific features.