Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jan 2018 23:24:53 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r327656 - stable/11/sys/arm/arm
Message-ID:  <201801062324.w06NOrgQ014475@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sat Jan  6 23:24:52 2018
New Revision: 327656
URL: https://svnweb.freebsd.org/changeset/base/327656

Log:
  MFC r327048-r327050
  
  r327048:
  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.
  
  r327049:
  Allow pmap_kremove() to remove 1MB section mappings as well as 4K pages.
  This will allow it to undo temporary device mappings such as those made
  with pmap_preboot_map_attr().
  
  Reviewed by:	cognet
  
  r327050:
  If a temporary mapping is made to support EARLY_PRINTF, undo that mapping
  after cninit() runs, otherwise we leave a bogus device-memory mapping in
  userspace VA in the kernel pmap forever.
  
  Pointed out by:	cognet

Modified:
  stable/11/sys/arm/arm/machdep.c
  stable/11/sys/arm/arm/pmap-v6.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm/arm/machdep.c
==============================================================================
--- stable/11/sys/arm/arm/machdep.c	Sat Jan  6 23:20:35 2018	(r327655)
+++ stable/11/sys/arm/arm/machdep.c	Sat Jan  6 23:24:52 2018	(r327656)
@@ -1115,6 +1115,19 @@ initarm(struct arm_boot_params *abp)
 	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.
 	 */
@@ -1176,6 +1189,14 @@ initarm(struct arm_boot_params *abp)
 	OF_interpret("perform-fixup", 0);
 	platform_gpio_init();
 	cninit();
+
+	/*
+	 * If we made a mapping for EARLY_PRINTF after pmap_bootstrap_prepare(),
+	 * undo it now that the normal console printf works.
+	 */
+#if defined(EARLY_PRINTF) && defined(SOCDEV_PA) && defined(SOCDEV_VA) && SOCDEV_VA < KERNBASE
+	pmap_kremove(SOCDEV_VA);
+#endif
 
 	debugf("initarm: console initialized\n");
 	debugf(" arg1 kmdp = 0x%08x\n", (uint32_t)kmdp);

Modified: stable/11/sys/arm/arm/pmap-v6.c
==============================================================================
--- stable/11/sys/arm/arm/pmap-v6.c	Sat Jan  6 23:20:35 2018	(r327655)
+++ stable/11/sys/arm/arm/pmap-v6.c	Sat Jan  6 23:24:52 2018	(r327656)
@@ -1312,10 +1312,16 @@ pmap_kenter(vm_offset_t va, vm_paddr_t pa)
 PMAP_INLINE void
 pmap_kremove(vm_offset_t va)
 {
+	pt1_entry_t *pte1p;
 	pt2_entry_t *pte2p;
 
-	pte2p = pt2map_entry(va);
-	pte2_clear(pte2p);
+	pte1p = kern_pte1(va);
+	if (pte1_is_section(pte1_load(pte1p))) {
+		pte1_clear(pte1p);
+	} else {
+		pte2p = pt2map_entry(va);
+		pte2_clear(pte2p);
+	}
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801062324.w06NOrgQ014475>