All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-06-16 21:51 ` Stefan Agner
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Agner @ 2015-06-16 21:51 UTC (permalink / raw)
  To: linux
  Cc: linux-arm-kernel, linux-kernel, Stefan Agner, Mark Salter,
	Kees Cook, Laura Abbott, Arnd Bergmann, Ard Biesheuvel,
	Rob Herring

Add early fixmap support, initially to support permanent, fixed
mapping support for early console. A temporary, early pte is
created which is migrated to a permanent mapping in paging_init.
This is also needed since the attributes may change as the memory
types are initialized. The 3MiB range of fixmap spans two pte
tables, but currently only one pte is created for early fixmap
support.

Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
the index for kmap does not start at zero anymore. This reverts
4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
FIX_KMAP_END") to some extent.

Cc: Mark Salter <msalter@redhat.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Kees Cook <keescook@chromium.org>
Cc: Laura Abbott <lauraa@codeaurora.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
Changes since v3:
- Remove address of on functions
- Clear all pmd's except early fixmap pmd in devicemaps_init
- Update comment in devicemaps_init since earlycon works now as debug method
- Add comment regarding FIXMAP_PAGE_IO/FIXMAP_PAGE_NOCACHE use

Changes since v2:
- Rebased and tested on rmk/for-next
- Flush TLB's when clearing the temporary PMD in early_fixmap_shutdown

Changes since v1 (RFC):
- Rebased and tested on v3.19-rc5
- Spelling errors in comments and commit message
- Added Rob's SOB

 arch/arm/Kconfig              |  3 ++
 arch/arm/include/asm/fixmap.h | 15 +++++++-
 arch/arm/kernel/setup.c       |  3 ++
 arch/arm/mm/highmem.c         |  6 +--
 arch/arm/mm/mmu.c             | 88 +++++++++++++++++++++++++++++++++++++++----
 5 files changed, 104 insertions(+), 11 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d0950ce..ef164a7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -186,6 +186,9 @@ config ARCH_HAS_ILOG2_U64
 config ARCH_HAS_BANDGAP
 	bool
 
+config FIX_EARLYCON_MEM
+	def_bool y
+
 config GENERIC_HWEIGHT
 	bool
 	default y
diff --git a/arch/arm/include/asm/fixmap.h b/arch/arm/include/asm/fixmap.h
index 0415eae..58cfe9f 100644
--- a/arch/arm/include/asm/fixmap.h
+++ b/arch/arm/include/asm/fixmap.h
@@ -6,9 +6,13 @@
 #define FIXADDR_TOP		(FIXADDR_END - PAGE_SIZE)
 
 #include <asm/kmap_types.h>
+#include <asm/pgtable.h>
 
 enum fixed_addresses {
-	FIX_KMAP_BEGIN,
+	FIX_EARLYCON_MEM_BASE,
+	__end_of_permanent_fixed_addresses,
+
+	FIX_KMAP_BEGIN = __end_of_permanent_fixed_addresses,
 	FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1,
 
 	/* Support writing RO kernel text via kprobes, jump labels, etc. */
@@ -18,7 +22,16 @@ enum fixed_addresses {
 	__end_of_fixed_addresses
 };
 
+#define FIXMAP_PAGE_COMMON	(L_PTE_YOUNG | L_PTE_PRESENT | L_PTE_XN | L_PTE_DIRTY)
+
+#define FIXMAP_PAGE_NORMAL	(FIXMAP_PAGE_COMMON | L_PTE_MT_WRITEBACK)
+
+/* Used by set_fixmap_(io|nocache), both meant for mapping a device */
+#define FIXMAP_PAGE_IO		(FIXMAP_PAGE_COMMON | L_PTE_MT_DEV_SHARED | L_PTE_SHARED)
+#define FIXMAP_PAGE_NOCACHE	FIXMAP_PAGE_IO
+
 void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
+void __init early_fixmap_init(void);
 
 #include <asm-generic/fixmap.h>
 
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index e6d8c76..6f03beb 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -37,6 +37,7 @@
 #include <asm/cpu.h>
 #include <asm/cputype.h>
 #include <asm/elf.h>
+#include <asm/fixmap.h>
 #include <asm/procinfo.h>
 #include <asm/psci.h>
 #include <asm/sections.h>
@@ -953,6 +954,8 @@ void __init setup_arch(char **cmdline_p)
 	strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = cmd_line;
 
+	early_fixmap_init();
+
 	parse_early_param();
 
 #ifdef CONFIG_MMU
diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c
index b98895d..c7097f9 100644
--- a/arch/arm/mm/highmem.c
+++ b/arch/arm/mm/highmem.c
@@ -78,7 +78,7 @@ void *kmap_atomic(struct page *page)
 
 	type = kmap_atomic_idx_push();
 
-	idx = type + KM_TYPE_NR * smp_processor_id();
+	idx = FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id();
 	vaddr = __fix_to_virt(idx);
 #ifdef CONFIG_DEBUG_HIGHMEM
 	/*
@@ -105,7 +105,7 @@ void __kunmap_atomic(void *kvaddr)
 
 	if (kvaddr >= (void *)FIXADDR_START) {
 		type = kmap_atomic_idx();
-		idx = type + KM_TYPE_NR * smp_processor_id();
+		idx = FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id();
 
 		if (cache_is_vivt())
 			__cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE);
@@ -135,7 +135,7 @@ void *kmap_atomic_pfn(unsigned long pfn)
 		return page_address(page);
 
 	type = kmap_atomic_idx_push();
-	idx = type + KM_TYPE_NR * smp_processor_id();
+	idx = FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id();
 	vaddr = __fix_to_virt(idx);
 #ifdef CONFIG_DEBUG_HIGHMEM
 	BUG_ON(!pte_none(get_fixmap_pte(vaddr)));
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 6ca7d9a..fb9e817 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -357,6 +357,47 @@ const struct mem_type *get_mem_type(unsigned int type)
 }
 EXPORT_SYMBOL(get_mem_type);
 
+static pte_t *(*pte_offset_fixmap)(pmd_t *dir, unsigned long addr);
+
+static pte_t bm_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS]
+	__aligned(PTE_HWTABLE_OFF + PTE_HWTABLE_SIZE) __initdata;
+
+static pte_t * __init pte_offset_early_fixmap(pmd_t *dir, unsigned long addr)
+{
+	return &bm_pte[pte_index(addr)];
+}
+
+static pte_t *pte_offset_late_fixmap(pmd_t *dir, unsigned long addr)
+{
+	return pte_offset_kernel(dir, addr);
+}
+
+static inline pmd_t * __init fixmap_pmd(unsigned long addr)
+{
+	pgd_t *pgd = pgd_offset_k(addr);
+	pud_t *pud = pud_offset(pgd, addr);
+	pmd_t *pmd = pmd_offset(pud, addr);
+
+	return pmd;
+}
+
+void __init early_fixmap_init(void)
+{
+	pmd_t *pmd;
+
+	/*
+	 * The early fixmap range spans multiple pmds, for which
+	 * we are not prepared:
+	 */
+	BUILD_BUG_ON((__fix_to_virt(__end_of_permanent_fixed_addresses) >> PMD_SHIFT)
+		     != FIXADDR_TOP >> PMD_SHIFT);
+
+	pmd = fixmap_pmd(FIXADDR_TOP);
+	pmd_populate_kernel(&init_mm, pmd, bm_pte);
+
+	pte_offset_fixmap = pte_offset_early_fixmap;
+}
+
 /*
  * To avoid TLB flush broadcasts, this uses local_flush_tlb_kernel_range().
  * As a result, this can only be called with preemption disabled, as under
@@ -365,7 +406,7 @@ EXPORT_SYMBOL(get_mem_type);
 void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot)
 {
 	unsigned long vaddr = __fix_to_virt(idx);
-	pte_t *pte = pte_offset_kernel(pmd_off_k(vaddr), vaddr);
+	pte_t *pte = pte_offset_fixmap(pmd_off_k(vaddr), vaddr);
 
 	/* Make sure fixmap region does not exceed available allocation. */
 	BUILD_BUG_ON(FIXADDR_START + (__end_of_fixed_addresses * PAGE_SIZE) >
@@ -855,7 +896,7 @@ static void __init create_mapping(struct map_desc *md)
 	}
 
 	if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
-	    md->virtual >= PAGE_OFFSET &&
+	    md->virtual >= PAGE_OFFSET && md->virtual < FIXADDR_START &&
 	    (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
 		pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n",
 			(long long)__pfn_to_phys((u64)md->pfn), md->virtual);
@@ -1213,10 +1254,10 @@ void __init arm_mm_memblock_reserve(void)
 
 /*
  * Set up the device mappings.  Since we clear out the page tables for all
- * mappings above VMALLOC_START, we will remove any debug device mappings.
- * This means you have to be careful how you debug this function, or any
- * called function.  This means you can't use any function or debugging
- * method which may touch any device, otherwise the kernel _will_ crash.
+ * mappings above VMALLOC_START, except early fixmap, we might remove debug
+ * device mappings.  This means earlycon can be used to debug this function
+ * Any other function or debugging method which may touch any device _will_
+ * crash the kernel.
  */
 static void __init devicemaps_init(const struct machine_desc *mdesc)
 {
@@ -1231,7 +1272,10 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
 
 	early_trap_init(vectors);
 
-	for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
+	/*
+	 * Clear page table except top pmd used by early fixmaps
+	 */
+	for (addr = VMALLOC_START; addr < (FIXADDR_TOP & PMD_MASK); addr += PMD_SIZE)
 		pmd_clear(pmd_off_k(addr));
 
 	/*
@@ -1483,6 +1527,35 @@ void __init early_paging_init(const struct machine_desc *mdesc)
 
 #endif
 
+static void __init early_fixmap_shutdown(void)
+{
+	int i;
+	unsigned long va = fix_to_virt(__end_of_permanent_fixed_addresses - 1);
+
+	pte_offset_fixmap = pte_offset_late_fixmap;
+	pmd_clear(fixmap_pmd(va));
+	local_flush_tlb_kernel_page(va);
+
+	for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
+		pte_t *pte;
+		struct map_desc map;
+
+		map.virtual = fix_to_virt(i);
+		pte = pte_offset_early_fixmap(pmd_off_k(map.virtual), map.virtual);
+
+		/* Only i/o device mappings are supported ATM */
+		if (pte_none(*pte) ||
+		    (pte_val(*pte) & L_PTE_MT_MASK) != L_PTE_MT_DEV_SHARED)
+			continue;
+
+		map.pfn = pte_pfn(*pte);
+		map.type = MT_DEVICE;
+		map.length = PAGE_SIZE;
+
+		create_mapping(&map);
+	}
+}
+
 /*
  * paging_init() sets up the page tables, initialises the zone memory
  * maps, and sets up the zero page, bad page and bad page tables.
@@ -1495,6 +1568,7 @@ void __init paging_init(const struct machine_desc *mdesc)
 	prepare_page_table();
 	map_lowmem();
 	dma_contiguous_remap();
+	early_fixmap_shutdown();
 	devicemaps_init(mdesc);
 	kmap_init();
 	tcm_init();
-- 
2.4.2


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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-06-16 21:51 ` Stefan Agner
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Agner @ 2015-06-16 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add early fixmap support, initially to support permanent, fixed
mapping support for early console. A temporary, early pte is
created which is migrated to a permanent mapping in paging_init.
This is also needed since the attributes may change as the memory
types are initialized. The 3MiB range of fixmap spans two pte
tables, but currently only one pte is created for early fixmap
support.

Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
the index for kmap does not start at zero anymore. This reverts
4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
FIX_KMAP_END") to some extent.

Cc: Mark Salter <msalter@redhat.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Kees Cook <keescook@chromium.org>
Cc: Laura Abbott <lauraa@codeaurora.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
Changes since v3:
- Remove address of on functions
- Clear all pmd's except early fixmap pmd in devicemaps_init
- Update comment in devicemaps_init since earlycon works now as debug method
- Add comment regarding FIXMAP_PAGE_IO/FIXMAP_PAGE_NOCACHE use

Changes since v2:
- Rebased and tested on rmk/for-next
- Flush TLB's when clearing the temporary PMD in early_fixmap_shutdown

Changes since v1 (RFC):
- Rebased and tested on v3.19-rc5
- Spelling errors in comments and commit message
- Added Rob's SOB

 arch/arm/Kconfig              |  3 ++
 arch/arm/include/asm/fixmap.h | 15 +++++++-
 arch/arm/kernel/setup.c       |  3 ++
 arch/arm/mm/highmem.c         |  6 +--
 arch/arm/mm/mmu.c             | 88 +++++++++++++++++++++++++++++++++++++++----
 5 files changed, 104 insertions(+), 11 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d0950ce..ef164a7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -186,6 +186,9 @@ config ARCH_HAS_ILOG2_U64
 config ARCH_HAS_BANDGAP
 	bool
 
+config FIX_EARLYCON_MEM
+	def_bool y
+
 config GENERIC_HWEIGHT
 	bool
 	default y
diff --git a/arch/arm/include/asm/fixmap.h b/arch/arm/include/asm/fixmap.h
index 0415eae..58cfe9f 100644
--- a/arch/arm/include/asm/fixmap.h
+++ b/arch/arm/include/asm/fixmap.h
@@ -6,9 +6,13 @@
 #define FIXADDR_TOP		(FIXADDR_END - PAGE_SIZE)
 
 #include <asm/kmap_types.h>
+#include <asm/pgtable.h>
 
 enum fixed_addresses {
-	FIX_KMAP_BEGIN,
+	FIX_EARLYCON_MEM_BASE,
+	__end_of_permanent_fixed_addresses,
+
+	FIX_KMAP_BEGIN = __end_of_permanent_fixed_addresses,
 	FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1,
 
 	/* Support writing RO kernel text via kprobes, jump labels, etc. */
@@ -18,7 +22,16 @@ enum fixed_addresses {
 	__end_of_fixed_addresses
 };
 
+#define FIXMAP_PAGE_COMMON	(L_PTE_YOUNG | L_PTE_PRESENT | L_PTE_XN | L_PTE_DIRTY)
+
+#define FIXMAP_PAGE_NORMAL	(FIXMAP_PAGE_COMMON | L_PTE_MT_WRITEBACK)
+
+/* Used by set_fixmap_(io|nocache), both meant for mapping a device */
+#define FIXMAP_PAGE_IO		(FIXMAP_PAGE_COMMON | L_PTE_MT_DEV_SHARED | L_PTE_SHARED)
+#define FIXMAP_PAGE_NOCACHE	FIXMAP_PAGE_IO
+
 void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
+void __init early_fixmap_init(void);
 
 #include <asm-generic/fixmap.h>
 
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index e6d8c76..6f03beb 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -37,6 +37,7 @@
 #include <asm/cpu.h>
 #include <asm/cputype.h>
 #include <asm/elf.h>
+#include <asm/fixmap.h>
 #include <asm/procinfo.h>
 #include <asm/psci.h>
 #include <asm/sections.h>
@@ -953,6 +954,8 @@ void __init setup_arch(char **cmdline_p)
 	strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = cmd_line;
 
+	early_fixmap_init();
+
 	parse_early_param();
 
 #ifdef CONFIG_MMU
diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c
index b98895d..c7097f9 100644
--- a/arch/arm/mm/highmem.c
+++ b/arch/arm/mm/highmem.c
@@ -78,7 +78,7 @@ void *kmap_atomic(struct page *page)
 
 	type = kmap_atomic_idx_push();
 
-	idx = type + KM_TYPE_NR * smp_processor_id();
+	idx = FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id();
 	vaddr = __fix_to_virt(idx);
 #ifdef CONFIG_DEBUG_HIGHMEM
 	/*
@@ -105,7 +105,7 @@ void __kunmap_atomic(void *kvaddr)
 
 	if (kvaddr >= (void *)FIXADDR_START) {
 		type = kmap_atomic_idx();
-		idx = type + KM_TYPE_NR * smp_processor_id();
+		idx = FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id();
 
 		if (cache_is_vivt())
 			__cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE);
@@ -135,7 +135,7 @@ void *kmap_atomic_pfn(unsigned long pfn)
 		return page_address(page);
 
 	type = kmap_atomic_idx_push();
-	idx = type + KM_TYPE_NR * smp_processor_id();
+	idx = FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id();
 	vaddr = __fix_to_virt(idx);
 #ifdef CONFIG_DEBUG_HIGHMEM
 	BUG_ON(!pte_none(get_fixmap_pte(vaddr)));
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 6ca7d9a..fb9e817 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -357,6 +357,47 @@ const struct mem_type *get_mem_type(unsigned int type)
 }
 EXPORT_SYMBOL(get_mem_type);
 
+static pte_t *(*pte_offset_fixmap)(pmd_t *dir, unsigned long addr);
+
+static pte_t bm_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS]
+	__aligned(PTE_HWTABLE_OFF + PTE_HWTABLE_SIZE) __initdata;
+
+static pte_t * __init pte_offset_early_fixmap(pmd_t *dir, unsigned long addr)
+{
+	return &bm_pte[pte_index(addr)];
+}
+
+static pte_t *pte_offset_late_fixmap(pmd_t *dir, unsigned long addr)
+{
+	return pte_offset_kernel(dir, addr);
+}
+
+static inline pmd_t * __init fixmap_pmd(unsigned long addr)
+{
+	pgd_t *pgd = pgd_offset_k(addr);
+	pud_t *pud = pud_offset(pgd, addr);
+	pmd_t *pmd = pmd_offset(pud, addr);
+
+	return pmd;
+}
+
+void __init early_fixmap_init(void)
+{
+	pmd_t *pmd;
+
+	/*
+	 * The early fixmap range spans multiple pmds, for which
+	 * we are not prepared:
+	 */
+	BUILD_BUG_ON((__fix_to_virt(__end_of_permanent_fixed_addresses) >> PMD_SHIFT)
+		     != FIXADDR_TOP >> PMD_SHIFT);
+
+	pmd = fixmap_pmd(FIXADDR_TOP);
+	pmd_populate_kernel(&init_mm, pmd, bm_pte);
+
+	pte_offset_fixmap = pte_offset_early_fixmap;
+}
+
 /*
  * To avoid TLB flush broadcasts, this uses local_flush_tlb_kernel_range().
  * As a result, this can only be called with preemption disabled, as under
@@ -365,7 +406,7 @@ EXPORT_SYMBOL(get_mem_type);
 void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot)
 {
 	unsigned long vaddr = __fix_to_virt(idx);
-	pte_t *pte = pte_offset_kernel(pmd_off_k(vaddr), vaddr);
+	pte_t *pte = pte_offset_fixmap(pmd_off_k(vaddr), vaddr);
 
 	/* Make sure fixmap region does not exceed available allocation. */
 	BUILD_BUG_ON(FIXADDR_START + (__end_of_fixed_addresses * PAGE_SIZE) >
@@ -855,7 +896,7 @@ static void __init create_mapping(struct map_desc *md)
 	}
 
 	if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
-	    md->virtual >= PAGE_OFFSET &&
+	    md->virtual >= PAGE_OFFSET && md->virtual < FIXADDR_START &&
 	    (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
 		pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n",
 			(long long)__pfn_to_phys((u64)md->pfn), md->virtual);
@@ -1213,10 +1254,10 @@ void __init arm_mm_memblock_reserve(void)
 
 /*
  * Set up the device mappings.  Since we clear out the page tables for all
- * mappings above VMALLOC_START, we will remove any debug device mappings.
- * This means you have to be careful how you debug this function, or any
- * called function.  This means you can't use any function or debugging
- * method which may touch any device, otherwise the kernel _will_ crash.
+ * mappings above VMALLOC_START, except early fixmap, we might remove debug
+ * device mappings.  This means earlycon can be used to debug this function
+ * Any other function or debugging method which may touch any device _will_
+ * crash the kernel.
  */
 static void __init devicemaps_init(const struct machine_desc *mdesc)
 {
@@ -1231,7 +1272,10 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
 
 	early_trap_init(vectors);
 
-	for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
+	/*
+	 * Clear page table except top pmd used by early fixmaps
+	 */
+	for (addr = VMALLOC_START; addr < (FIXADDR_TOP & PMD_MASK); addr += PMD_SIZE)
 		pmd_clear(pmd_off_k(addr));
 
 	/*
@@ -1483,6 +1527,35 @@ void __init early_paging_init(const struct machine_desc *mdesc)
 
 #endif
 
+static void __init early_fixmap_shutdown(void)
+{
+	int i;
+	unsigned long va = fix_to_virt(__end_of_permanent_fixed_addresses - 1);
+
+	pte_offset_fixmap = pte_offset_late_fixmap;
+	pmd_clear(fixmap_pmd(va));
+	local_flush_tlb_kernel_page(va);
+
+	for (i = 0; i < __end_of_permanent_fixed_addresses; i++) {
+		pte_t *pte;
+		struct map_desc map;
+
+		map.virtual = fix_to_virt(i);
+		pte = pte_offset_early_fixmap(pmd_off_k(map.virtual), map.virtual);
+
+		/* Only i/o device mappings are supported ATM */
+		if (pte_none(*pte) ||
+		    (pte_val(*pte) & L_PTE_MT_MASK) != L_PTE_MT_DEV_SHARED)
+			continue;
+
+		map.pfn = pte_pfn(*pte);
+		map.type = MT_DEVICE;
+		map.length = PAGE_SIZE;
+
+		create_mapping(&map);
+	}
+}
+
 /*
  * paging_init() sets up the page tables, initialises the zone memory
  * maps, and sets up the zero page, bad page and bad page tables.
@@ -1495,6 +1568,7 @@ void __init paging_init(const struct machine_desc *mdesc)
 	prepare_page_table();
 	map_lowmem();
 	dma_contiguous_remap();
+	early_fixmap_shutdown();
 	devicemaps_init(mdesc);
 	kmap_init();
 	tcm_init();
-- 
2.4.2

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

* Re: [PATCH v4] ARM: early fixmap support for earlycon
  2015-06-16 21:51 ` Stefan Agner
@ 2015-06-16 22:32   ` Russell King - ARM Linux
  -1 siblings, 0 replies; 20+ messages in thread
From: Russell King - ARM Linux @ 2015-06-16 22:32 UTC (permalink / raw)
  To: Stefan Agner
  Cc: linux-arm-kernel, linux-kernel, Mark Salter, Kees Cook,
	Laura Abbott, Arnd Bergmann, Ard Biesheuvel, Rob Herring

On Tue, Jun 16, 2015 at 11:51:47PM +0200, Stefan Agner wrote:
> Add early fixmap support, initially to support permanent, fixed
> mapping support for early console. A temporary, early pte is
> created which is migrated to a permanent mapping in paging_init.
> This is also needed since the attributes may change as the memory
> types are initialized. The 3MiB range of fixmap spans two pte
> tables, but currently only one pte is created for early fixmap
> support.
> 
> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
> the index for kmap does not start at zero anymore. This reverts
> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
> FIX_KMAP_END") to some extent.

Sorry, this isn't going to make the next merge window, I've closed my
tree at the end of last week to new submissions (because it got too
painful to maintain the for-next branch due to the number of cross-
dependencies between branches.)  The only patches I'll entertain this
week and throughout the merge window are bug fixes.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-06-16 22:32   ` Russell King - ARM Linux
  0 siblings, 0 replies; 20+ messages in thread
From: Russell King - ARM Linux @ 2015-06-16 22:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jun 16, 2015 at 11:51:47PM +0200, Stefan Agner wrote:
> Add early fixmap support, initially to support permanent, fixed
> mapping support for early console. A temporary, early pte is
> created which is migrated to a permanent mapping in paging_init.
> This is also needed since the attributes may change as the memory
> types are initialized. The 3MiB range of fixmap spans two pte
> tables, but currently only one pte is created for early fixmap
> support.
> 
> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
> the index for kmap does not start at zero anymore. This reverts
> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
> FIX_KMAP_END") to some extent.

Sorry, this isn't going to make the next merge window, I've closed my
tree at the end of last week to new submissions (because it got too
painful to maintain the for-next branch due to the number of cross-
dependencies between branches.)  The only patches I'll entertain this
week and throughout the merge window are bug fixes.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH v4] ARM: early fixmap support for earlycon
  2015-06-16 21:51 ` Stefan Agner
@ 2015-06-16 23:22   ` Stephen Boyd
  -1 siblings, 0 replies; 20+ messages in thread
From: Stephen Boyd @ 2015-06-16 23:22 UTC (permalink / raw)
  To: Stefan Agner, linux
  Cc: Rob Herring, Laura Abbott, Kees Cook, Arnd Bergmann,
	Ard Biesheuvel, linux-kernel, Mark Salter, linux-arm-kernel

On 06/16/2015 02:51 PM, Stefan Agner wrote:
> Add early fixmap support, initially to support permanent, fixed
> mapping support for early console. A temporary, early pte is
> created which is migrated to a permanent mapping in paging_init.
> This is also needed since the attributes may change as the memory
> types are initialized. The 3MiB range of fixmap spans two pte
> tables, but currently only one pte is created for early fixmap
> support.
>
> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
> the index for kmap does not start at zero anymore. This reverts
> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
> FIX_KMAP_END") to some extent.
>
> Cc: Mark Salter <msalter@redhat.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Laura Abbott <lauraa@codeaurora.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
>

Works on msm_serial.

Tested-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-06-16 23:22   ` Stephen Boyd
  0 siblings, 0 replies; 20+ messages in thread
From: Stephen Boyd @ 2015-06-16 23:22 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/16/2015 02:51 PM, Stefan Agner wrote:
> Add early fixmap support, initially to support permanent, fixed
> mapping support for early console. A temporary, early pte is
> created which is migrated to a permanent mapping in paging_init.
> This is also needed since the attributes may change as the memory
> types are initialized. The 3MiB range of fixmap spans two pte
> tables, but currently only one pte is created for early fixmap
> support.
>
> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
> the index for kmap does not start at zero anymore. This reverts
> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
> FIX_KMAP_END") to some extent.
>
> Cc: Mark Salter <msalter@redhat.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Laura Abbott <lauraa@codeaurora.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
>

Works on msm_serial.

Tested-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH v4] ARM: early fixmap support for earlycon
  2015-06-16 23:22   ` Stephen Boyd
@ 2015-06-17  9:33     ` Ard Biesheuvel
  -1 siblings, 0 replies; 20+ messages in thread
From: Ard Biesheuvel @ 2015-06-17  9:33 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Stefan Agner, Russell King - ARM Linux, Rob Herring,
	Laura Abbott, Kees Cook, Arnd Bergmann, linux-kernel,
	Mark Salter, linux-arm-kernel

On 17 June 2015 at 01:22, Stephen Boyd <sboyd@codeaurora.org> wrote:
> On 06/16/2015 02:51 PM, Stefan Agner wrote:
>> Add early fixmap support, initially to support permanent, fixed
>> mapping support for early console. A temporary, early pte is
>> created which is migrated to a permanent mapping in paging_init.
>> This is also needed since the attributes may change as the memory
>> types are initialized. The 3MiB range of fixmap spans two pte
>> tables, but currently only one pte is created for early fixmap
>> support.
>>
>> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
>> the index for kmap does not start at zero anymore. This reverts
>> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
>> FIX_KMAP_END") to some extent.
>>
>> Cc: Mark Salter <msalter@redhat.com>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Laura Abbott <lauraa@codeaurora.org>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> Signed-off-by: Rob Herring <robh@kernel.org>
>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>>
>
> Works on msm_serial.
>
> Tested-by: Stephen Boyd <sboyd@codeaurora.org>
>

I gave this a spin as well, on Arndale, with /chosen/stdout-path set
to &serial_2  and just 'earlycon' (without value) passed on the
command line, and it works fine.

Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-06-17  9:33     ` Ard Biesheuvel
  0 siblings, 0 replies; 20+ messages in thread
From: Ard Biesheuvel @ 2015-06-17  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

On 17 June 2015 at 01:22, Stephen Boyd <sboyd@codeaurora.org> wrote:
> On 06/16/2015 02:51 PM, Stefan Agner wrote:
>> Add early fixmap support, initially to support permanent, fixed
>> mapping support for early console. A temporary, early pte is
>> created which is migrated to a permanent mapping in paging_init.
>> This is also needed since the attributes may change as the memory
>> types are initialized. The 3MiB range of fixmap spans two pte
>> tables, but currently only one pte is created for early fixmap
>> support.
>>
>> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
>> the index for kmap does not start at zero anymore. This reverts
>> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
>> FIX_KMAP_END") to some extent.
>>
>> Cc: Mark Salter <msalter@redhat.com>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Laura Abbott <lauraa@codeaurora.org>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> Signed-off-by: Rob Herring <robh@kernel.org>
>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>>
>
> Works on msm_serial.
>
> Tested-by: Stephen Boyd <sboyd@codeaurora.org>
>

I gave this a spin as well, on Arndale, with /chosen/stdout-path set
to &serial_2  and just 'earlycon' (without value) passed on the
command line, and it works fine.

Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

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

* Re: [PATCH v4] ARM: early fixmap support for earlycon
  2015-06-16 22:32   ` Russell King - ARM Linux
@ 2015-06-17 11:43     ` Stefan Agner
  -1 siblings, 0 replies; 20+ messages in thread
From: Stefan Agner @ 2015-06-17 11:43 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-arm-kernel, linux-kernel, Mark Salter, Kees Cook,
	Laura Abbott, Arnd Bergmann, Ard Biesheuvel, Rob Herring

On 2015-06-17 00:32, Russell King - ARM Linux wrote:
> On Tue, Jun 16, 2015 at 11:51:47PM +0200, Stefan Agner wrote:
>> Add early fixmap support, initially to support permanent, fixed
>> mapping support for early console. A temporary, early pte is
>> created which is migrated to a permanent mapping in paging_init.
>> This is also needed since the attributes may change as the memory
>> types are initialized. The 3MiB range of fixmap spans two pte
>> tables, but currently only one pte is created for early fixmap
>> support.
>>
>> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
>> the index for kmap does not start at zero anymore. This reverts
>> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
>> FIX_KMAP_END") to some extent.
> 
> Sorry, this isn't going to make the next merge window, I've closed my
> tree at the end of last week to new submissions (because it got too
> painful to maintain the for-next branch due to the number of cross-
> dependencies between branches.)  The only patches I'll entertain this
> week and throughout the merge window are bug fixes.

Ok no problem, I guess it's anyway a good idea to add it early in the
development cycle so the change gets a bit more testing coverage. Shall
I rebase the patch just after the merge window and send it out again or
add the patch in its current state to your patch tracker?

--
Stefan


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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-06-17 11:43     ` Stefan Agner
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Agner @ 2015-06-17 11:43 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015-06-17 00:32, Russell King - ARM Linux wrote:
> On Tue, Jun 16, 2015 at 11:51:47PM +0200, Stefan Agner wrote:
>> Add early fixmap support, initially to support permanent, fixed
>> mapping support for early console. A temporary, early pte is
>> created which is migrated to a permanent mapping in paging_init.
>> This is also needed since the attributes may change as the memory
>> types are initialized. The 3MiB range of fixmap spans two pte
>> tables, but currently only one pte is created for early fixmap
>> support.
>>
>> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
>> the index for kmap does not start at zero anymore. This reverts
>> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
>> FIX_KMAP_END") to some extent.
> 
> Sorry, this isn't going to make the next merge window, I've closed my
> tree at the end of last week to new submissions (because it got too
> painful to maintain the for-next branch due to the number of cross-
> dependencies between branches.)  The only patches I'll entertain this
> week and throughout the merge window are bug fixes.

Ok no problem, I guess it's anyway a good idea to add it early in the
development cycle so the change gets a bit more testing coverage. Shall
I rebase the patch just after the merge window and send it out again or
add the patch in its current state to your patch tracker?

--
Stefan

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

* Re: [PATCH v4] ARM: early fixmap support for earlycon
  2015-06-17 11:43     ` Stefan Agner
@ 2015-06-17 19:43       ` Russell King - ARM Linux
  -1 siblings, 0 replies; 20+ messages in thread
From: Russell King - ARM Linux @ 2015-06-17 19:43 UTC (permalink / raw)
  To: Stefan Agner
  Cc: linux-arm-kernel, linux-kernel, Mark Salter, Kees Cook,
	Laura Abbott, Arnd Bergmann, Ard Biesheuvel, Rob Herring

On Wed, Jun 17, 2015 at 01:43:17PM +0200, Stefan Agner wrote:
> On 2015-06-17 00:32, Russell King - ARM Linux wrote:
> > On Tue, Jun 16, 2015 at 11:51:47PM +0200, Stefan Agner wrote:
> >> Add early fixmap support, initially to support permanent, fixed
> >> mapping support for early console. A temporary, early pte is
> >> created which is migrated to a permanent mapping in paging_init.
> >> This is also needed since the attributes may change as the memory
> >> types are initialized. The 3MiB range of fixmap spans two pte
> >> tables, but currently only one pte is created for early fixmap
> >> support.
> >>
> >> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
> >> the index for kmap does not start at zero anymore. This reverts
> >> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
> >> FIX_KMAP_END") to some extent.
> > 
> > Sorry, this isn't going to make the next merge window, I've closed my
> > tree at the end of last week to new submissions (because it got too
> > painful to maintain the for-next branch due to the number of cross-
> > dependencies between branches.)  The only patches I'll entertain this
> > week and throughout the merge window are bug fixes.
> 
> Ok no problem, I guess it's anyway a good idea to add it early in the
> development cycle so the change gets a bit more testing coverage. Shall
> I rebase the patch just after the merge window and send it out again or
> add the patch in its current state to your patch tracker?

Please rebase (if necessary) on -rc1 and send to the patch tracker if
there are no significant changes to it (I doubt there will be.)  If
everything during the merge window works as it should, -rc1 should
basically be the contents of linux-next just before the merge window
opens, plus any fixes that are needed along the way.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-06-17 19:43       ` Russell King - ARM Linux
  0 siblings, 0 replies; 20+ messages in thread
From: Russell King - ARM Linux @ 2015-06-17 19:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 17, 2015 at 01:43:17PM +0200, Stefan Agner wrote:
> On 2015-06-17 00:32, Russell King - ARM Linux wrote:
> > On Tue, Jun 16, 2015 at 11:51:47PM +0200, Stefan Agner wrote:
> >> Add early fixmap support, initially to support permanent, fixed
> >> mapping support for early console. A temporary, early pte is
> >> created which is migrated to a permanent mapping in paging_init.
> >> This is also needed since the attributes may change as the memory
> >> types are initialized. The 3MiB range of fixmap spans two pte
> >> tables, but currently only one pte is created for early fixmap
> >> support.
> >>
> >> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
> >> the index for kmap does not start at zero anymore. This reverts
> >> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
> >> FIX_KMAP_END") to some extent.
> > 
> > Sorry, this isn't going to make the next merge window, I've closed my
> > tree at the end of last week to new submissions (because it got too
> > painful to maintain the for-next branch due to the number of cross-
> > dependencies between branches.)  The only patches I'll entertain this
> > week and throughout the merge window are bug fixes.
> 
> Ok no problem, I guess it's anyway a good idea to add it early in the
> development cycle so the change gets a bit more testing coverage. Shall
> I rebase the patch just after the merge window and send it out again or
> add the patch in its current state to your patch tracker?

Please rebase (if necessary) on -rc1 and send to the patch tracker if
there are no significant changes to it (I doubt there will be.)  If
everything during the merge window works as it should, -rc1 should
basically be the contents of linux-next just before the merge window
opens, plus any fixes that are needed along the way.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH v4] ARM: early fixmap support for earlycon
  2015-06-16 21:51 ` Stefan Agner
@ 2015-06-30 12:33   ` Heiko Stübner
  -1 siblings, 0 replies; 20+ messages in thread
From: Heiko Stübner @ 2015-06-30 12:33 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Stefan Agner, linux, Rob Herring, Laura Abbott, Kees Cook,
	Arnd Bergmann, Ard Biesheuvel, linux-kernel, Mark Salter

Am Dienstag, 16. Juni 2015, 23:51:47 schrieb Stefan Agner:
> Add early fixmap support, initially to support permanent, fixed
> mapping support for early console. A temporary, early pte is
> created which is migrated to a permanent mapping in paging_init.
> This is also needed since the attributes may change as the memory
> types are initialized. The 3MiB range of fixmap spans two pte
> tables, but currently only one pte is created for early fixmap
> support.
> 
> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
> the index for kmap does not start at zero anymore. This reverts
> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
> FIX_KMAP_END") to some extent.
> 
> Cc: Mark Salter <msalter@redhat.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Laura Abbott <lauraa@codeaurora.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Stefan Agner <stefan@agner.ch>

a bit late to the party, but on a rk3288 (Veyron Chromebook) using 8250_dw
Tested-by: Heiko Stuebner <heiko@sntech.de>


Heiko

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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-06-30 12:33   ` Heiko Stübner
  0 siblings, 0 replies; 20+ messages in thread
From: Heiko Stübner @ 2015-06-30 12:33 UTC (permalink / raw)
  To: linux-arm-kernel

Am Dienstag, 16. Juni 2015, 23:51:47 schrieb Stefan Agner:
> Add early fixmap support, initially to support permanent, fixed
> mapping support for early console. A temporary, early pte is
> created which is migrated to a permanent mapping in paging_init.
> This is also needed since the attributes may change as the memory
> types are initialized. The 3MiB range of fixmap spans two pte
> tables, but currently only one pte is created for early fixmap
> support.
> 
> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
> the index for kmap does not start at zero anymore. This reverts
> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
> FIX_KMAP_END") to some extent.
> 
> Cc: Mark Salter <msalter@redhat.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Laura Abbott <lauraa@codeaurora.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Stefan Agner <stefan@agner.ch>

a bit late to the party, but on a rk3288 (Veyron Chromebook) using 8250_dw
Tested-by: Heiko Stuebner <heiko@sntech.de>


Heiko

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

* Re: [PATCH v4] ARM: early fixmap support for earlycon
  2015-06-17 19:43       ` Russell King - ARM Linux
@ 2015-07-06  6:45         ` Stefan Agner
  -1 siblings, 0 replies; 20+ messages in thread
From: Stefan Agner @ 2015-07-06  6:45 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-arm-kernel, linux-kernel, Mark Salter, Kees Cook,
	Laura Abbott, Arnd Bergmann, Ard Biesheuvel, Rob Herring, heiko,
	sboyd

On 2015-06-17 21:43, Russell King - ARM Linux wrote:
> On Wed, Jun 17, 2015 at 01:43:17PM +0200, Stefan Agner wrote:
>> On 2015-06-17 00:32, Russell King - ARM Linux wrote:
>> > On Tue, Jun 16, 2015 at 11:51:47PM +0200, Stefan Agner wrote:
>> >> Add early fixmap support, initially to support permanent, fixed
>> >> mapping support for early console. A temporary, early pte is
>> >> created which is migrated to a permanent mapping in paging_init.
>> >> This is also needed since the attributes may change as the memory
>> >> types are initialized. The 3MiB range of fixmap spans two pte
>> >> tables, but currently only one pte is created for early fixmap
>> >> support.
>> >>
>> >> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
>> >> the index for kmap does not start at zero anymore. This reverts
>> >> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
>> >> FIX_KMAP_END") to some extent.
>> >
>> > Sorry, this isn't going to make the next merge window, I've closed my
>> > tree at the end of last week to new submissions (because it got too
>> > painful to maintain the for-next branch due to the number of cross-
>> > dependencies between branches.)  The only patches I'll entertain this
>> > week and throughout the merge window are bug fixes.
>>
>> Ok no problem, I guess it's anyway a good idea to add it early in the
>> development cycle so the change gets a bit more testing coverage. Shall
>> I rebase the patch just after the merge window and send it out again or
>> add the patch in its current state to your patch tracker?
> 
> Please rebase (if necessary) on -rc1 and send to the patch tracker if
> there are no significant changes to it (I doubt there will be.)  If
> everything during the merge window works as it should, -rc1 should
> basically be the contents of linux-next just before the merge window
> opens, plus any fixes that are needed along the way.

Added with the additional Tested-by tags to the patch tracker (ID
8399/1). No updates were required.

--
Stefan

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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-07-06  6:45         ` Stefan Agner
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Agner @ 2015-07-06  6:45 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015-06-17 21:43, Russell King - ARM Linux wrote:
> On Wed, Jun 17, 2015 at 01:43:17PM +0200, Stefan Agner wrote:
>> On 2015-06-17 00:32, Russell King - ARM Linux wrote:
>> > On Tue, Jun 16, 2015 at 11:51:47PM +0200, Stefan Agner wrote:
>> >> Add early fixmap support, initially to support permanent, fixed
>> >> mapping support for early console. A temporary, early pte is
>> >> created which is migrated to a permanent mapping in paging_init.
>> >> This is also needed since the attributes may change as the memory
>> >> types are initialized. The 3MiB range of fixmap spans two pte
>> >> tables, but currently only one pte is created for early fixmap
>> >> support.
>> >>
>> >> Re-add FIX_KMAP_BEGIN to the index calculation in highmem.c since
>> >> the index for kmap does not start at zero anymore. This reverts
>> >> 4221e2e6b316 ("ARM: 8031/1: fixmap: remove FIX_KMAP_BEGIN and
>> >> FIX_KMAP_END") to some extent.
>> >
>> > Sorry, this isn't going to make the next merge window, I've closed my
>> > tree at the end of last week to new submissions (because it got too
>> > painful to maintain the for-next branch due to the number of cross-
>> > dependencies between branches.)  The only patches I'll entertain this
>> > week and throughout the merge window are bug fixes.
>>
>> Ok no problem, I guess it's anyway a good idea to add it early in the
>> development cycle so the change gets a bit more testing coverage. Shall
>> I rebase the patch just after the merge window and send it out again or
>> add the patch in its current state to your patch tracker?
> 
> Please rebase (if necessary) on -rc1 and send to the patch tracker if
> there are no significant changes to it (I doubt there will be.)  If
> everything during the merge window works as it should, -rc1 should
> basically be the contents of linux-next just before the merge window
> opens, plus any fixes that are needed along the way.

Added with the additional Tested-by tags to the patch tracker (ID
8399/1). No updates were required.

--
Stefan

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

* Re: [PATCH v4] ARM: early fixmap support for earlycon
  2015-06-16 21:51 ` Stefan Agner
@ 2015-07-30 21:02   ` Stefan Agner
  -1 siblings, 0 replies; 20+ messages in thread
From: Stefan Agner @ 2015-07-30 21:02 UTC (permalink / raw)
  To: linux
  Cc: linux-arm-kernel, linux-kernel, Mark Salter, Kees Cook,
	Laura Abbott, Arnd Bergmann, Ard Biesheuvel, Rob Herring

On 2015-06-16 23:51, Stefan Agner wrote:
>  static void __init devicemaps_init(const struct machine_desc *mdesc)
>  {
> @@ -1231,7 +1272,10 @@ static void __init devicemaps_init(const struct
> machine_desc *mdesc)
>  
>  	early_trap_init(vectors);
>  
> -	for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
> +	/*
> +	 * Clear page table except top pmd used by early fixmaps
> +	 */
> +	for (addr = VMALLOC_START; addr < (FIXADDR_TOP & PMD_MASK); addr += PMD_SIZE)
>  		pmd_clear(pmd_off_k(addr));
>  

Hi Russel,

Checked this again, v4 does the right thing:
FIXADDR_TOP (0xffeff000) & PMD_MASK (0xffe00000) gives us the address of
the top PMD (0xFFE00000). We don't clear that since that is taken care
of by early fixmap support (early_fixmap_shutdown). v3 used
FIXADDR_START, which also left out the second to top PMD. The 3MiB of
fixmap spawns two PMD's however only the top PMD is handled by early
fixmap. Hence this was wrong in v3, but is fixed in v4.

Can you reconsider this patch?

--
Stefan

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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-07-30 21:02   ` Stefan Agner
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Agner @ 2015-07-30 21:02 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015-06-16 23:51, Stefan Agner wrote:
>  static void __init devicemaps_init(const struct machine_desc *mdesc)
>  {
> @@ -1231,7 +1272,10 @@ static void __init devicemaps_init(const struct
> machine_desc *mdesc)
>  
>  	early_trap_init(vectors);
>  
> -	for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
> +	/*
> +	 * Clear page table except top pmd used by early fixmaps
> +	 */
> +	for (addr = VMALLOC_START; addr < (FIXADDR_TOP & PMD_MASK); addr += PMD_SIZE)
>  		pmd_clear(pmd_off_k(addr));
>  

Hi Russel,

Checked this again, v4 does the right thing:
FIXADDR_TOP (0xffeff000) & PMD_MASK (0xffe00000) gives us the address of
the top PMD (0xFFE00000). We don't clear that since that is taken care
of by early fixmap support (early_fixmap_shutdown). v3 used
FIXADDR_START, which also left out the second to top PMD. The 3MiB of
fixmap spawns two PMD's however only the top PMD is handled by early
fixmap. Hence this was wrong in v3, but is fixed in v4.

Can you reconsider this patch?

--
Stefan

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

* Re: [PATCH v4] ARM: early fixmap support for earlycon
  2015-07-30 21:02   ` Stefan Agner
@ 2015-08-08 17:53     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 20+ messages in thread
From: Russell King - ARM Linux @ 2015-08-08 17:53 UTC (permalink / raw)
  To: Stefan Agner
  Cc: linux-arm-kernel, linux-kernel, Mark Salter, Kees Cook,
	Laura Abbott, Arnd Bergmann, Ard Biesheuvel, Rob Herring

On Thu, Jul 30, 2015 at 11:02:38PM +0200, Stefan Agner wrote:
> On 2015-06-16 23:51, Stefan Agner wrote:
> >  static void __init devicemaps_init(const struct machine_desc *mdesc)
> >  {
> > @@ -1231,7 +1272,10 @@ static void __init devicemaps_init(const struct
> > machine_desc *mdesc)
> >  
> >  	early_trap_init(vectors);
> >  
> > -	for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
> > +	/*
> > +	 * Clear page table except top pmd used by early fixmaps
> > +	 */
> > +	for (addr = VMALLOC_START; addr < (FIXADDR_TOP & PMD_MASK); addr += PMD_SIZE)
> >  		pmd_clear(pmd_off_k(addr));
> >  
> 
> Hi Russel,
> 
> Checked this again, v4 does the right thing:
> FIXADDR_TOP (0xffeff000) & PMD_MASK (0xffe00000) gives us the address of
> the top PMD (0xFFE00000). We don't clear that since that is taken care
> of by early fixmap support (early_fixmap_shutdown). v3 used
> FIXADDR_START, which also left out the second to top PMD. The 3MiB of
> fixmap spawns two PMD's however only the top PMD is handled by early
> fixmap. Hence this was wrong in v3, but is fixed in v4.
> 
> Can you reconsider this patch?

I applied the patch which was in the patch system, and Olof's builder
reported failures:

        arm.allnoconfig:
:(.init.text+0x7a0): undefined reference to `early_fixmap_init'

        arm.efm32_defconfig:
arch/arm/kernel/setup.c:958: undefined reference to `early_fixmap_init'

        arm.lpc18xx_defconfig:
arch/arm/include/asm/fixmap.h:25:29: error: 'L_PTE_YOUNG' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:25:43: error: 'L_PTE_PRESENT' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:25:59: error: 'L_PTE_XN' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:25:70: error: 'L_PTE_DIRTY' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:30:47: error: 'L_PTE_MT_DEV_SHARED' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:30:69: error: 'L_PTE_SHARED' undeclared (first use in this function)

So I'm going to drop it from my tree.  Please resubmit a fixed version,
thanks.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH v4] ARM: early fixmap support for earlycon
@ 2015-08-08 17:53     ` Russell King - ARM Linux
  0 siblings, 0 replies; 20+ messages in thread
From: Russell King - ARM Linux @ 2015-08-08 17:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 30, 2015 at 11:02:38PM +0200, Stefan Agner wrote:
> On 2015-06-16 23:51, Stefan Agner wrote:
> >  static void __init devicemaps_init(const struct machine_desc *mdesc)
> >  {
> > @@ -1231,7 +1272,10 @@ static void __init devicemaps_init(const struct
> > machine_desc *mdesc)
> >  
> >  	early_trap_init(vectors);
> >  
> > -	for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
> > +	/*
> > +	 * Clear page table except top pmd used by early fixmaps
> > +	 */
> > +	for (addr = VMALLOC_START; addr < (FIXADDR_TOP & PMD_MASK); addr += PMD_SIZE)
> >  		pmd_clear(pmd_off_k(addr));
> >  
> 
> Hi Russel,
> 
> Checked this again, v4 does the right thing:
> FIXADDR_TOP (0xffeff000) & PMD_MASK (0xffe00000) gives us the address of
> the top PMD (0xFFE00000). We don't clear that since that is taken care
> of by early fixmap support (early_fixmap_shutdown). v3 used
> FIXADDR_START, which also left out the second to top PMD. The 3MiB of
> fixmap spawns two PMD's however only the top PMD is handled by early
> fixmap. Hence this was wrong in v3, but is fixed in v4.
> 
> Can you reconsider this patch?

I applied the patch which was in the patch system, and Olof's builder
reported failures:

        arm.allnoconfig:
:(.init.text+0x7a0): undefined reference to `early_fixmap_init'

        arm.efm32_defconfig:
arch/arm/kernel/setup.c:958: undefined reference to `early_fixmap_init'

        arm.lpc18xx_defconfig:
arch/arm/include/asm/fixmap.h:25:29: error: 'L_PTE_YOUNG' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:25:43: error: 'L_PTE_PRESENT' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:25:59: error: 'L_PTE_XN' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:25:70: error: 'L_PTE_DIRTY' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:30:47: error: 'L_PTE_MT_DEV_SHARED' undeclared (first use in this function)
arch/arm/include/asm/fixmap.h:30:69: error: 'L_PTE_SHARED' undeclared (first use in this function)

So I'm going to drop it from my tree.  Please resubmit a fixed version,
thanks.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

end of thread, other threads:[~2015-08-08 17:53 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-16 21:51 [PATCH v4] ARM: early fixmap support for earlycon Stefan Agner
2015-06-16 21:51 ` Stefan Agner
2015-06-16 22:32 ` Russell King - ARM Linux
2015-06-16 22:32   ` Russell King - ARM Linux
2015-06-17 11:43   ` Stefan Agner
2015-06-17 11:43     ` Stefan Agner
2015-06-17 19:43     ` Russell King - ARM Linux
2015-06-17 19:43       ` Russell King - ARM Linux
2015-07-06  6:45       ` Stefan Agner
2015-07-06  6:45         ` Stefan Agner
2015-06-16 23:22 ` Stephen Boyd
2015-06-16 23:22   ` Stephen Boyd
2015-06-17  9:33   ` Ard Biesheuvel
2015-06-17  9:33     ` Ard Biesheuvel
2015-06-30 12:33 ` Heiko Stübner
2015-06-30 12:33   ` Heiko Stübner
2015-07-30 21:02 ` Stefan Agner
2015-07-30 21:02   ` Stefan Agner
2015-08-08 17:53   ` Russell King - ARM Linux
2015-08-08 17:53     ` Russell King - ARM Linux

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.