From patchwork Wed Apr 29 13:51:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 47712 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 072D32121F for ; Wed, 29 Apr 2015 14:00:57 +0000 (UTC) Received: by wixv7 with SMTP id v7sf14370532wix.0 for ; Wed, 29 Apr 2015 07:00:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=RAYWC+FvKXLM0Rgly+YxSG/bP4JVa35NoxbBaHnKZ9A=; b=bxzWVdsv8eDzTl77vD0o0haXx38pZg5sqdd/Tsl6e86yl3ALwF9K2wXyy+WA3l6HnJ wXUGuHbzOJIkoQ7JpK3eZrVX/WsV0kf7VlVFhJH0gni+BGoLvue/EpYhjCgwK7x22sw2 G0orz60of8f8eQVmR3yET7lW+BReszqS5mg/kd5E6tcH+OnqevvidNAOqCZ7/LJllut0 qiHdLWaGG/9nrqlP9OFtl5C/GAlk23gnIXaMg628Ty3uEpxzgl17UKSIACpe9LXXmT8s lWPvJpb+hJQhRHmfcIsKbWE3KXp5b6941OIMVCCpYUbpb8MJbMhW10DfGKOs/fW9WrXc jszQ== X-Gm-Message-State: ALoCoQkKoJOIyTIXk1AvvpLB4kXFPreM3uZsEL6xo+oO3SFrSjDZD0/C0EOwXaqKPYGY2YBWIpg4 X-Received: by 10.112.28.111 with SMTP id a15mr13272125lbh.21.1430316056275; Wed, 29 Apr 2015 07:00:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.10.208 with SMTP id k16ls239306lab.42.gmail; Wed, 29 Apr 2015 07:00:56 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr19574370lad.56.1430316056066; Wed, 29 Apr 2015 07:00:56 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id e7si19438056lbc.62.2015.04.29.07.00.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Apr 2015 07:00:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by layy10 with SMTP id y10so20797659lay.0 for ; Wed, 29 Apr 2015 07:00:56 -0700 (PDT) X-Received: by 10.152.27.1 with SMTP id p1mr18748152lag.112.1430316055966; Wed, 29 Apr 2015 07:00:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp2522888lbt; Wed, 29 Apr 2015 07:00:55 -0700 (PDT) X-Received: by 10.70.90.231 with SMTP id bz7mr41861618pdb.15.1430316052692; Wed, 29 Apr 2015 07:00:52 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id gl6si39571325pac.197.2015.04.29.07.00.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Apr 2015 07:00:52 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YnSVj-0002cc-FK; Wed, 29 Apr 2015 13:58:47 +0000 Received: from mail-wi0-f172.google.com ([209.85.212.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YnSVf-0002ZT-Sp for linux-arm-kernel@lists.infradead.org; Wed, 29 Apr 2015 13:58:44 +0000 Received: by wiun10 with SMTP id n10so66936251wiu.1 for ; Wed, 29 Apr 2015 06:58:21 -0700 (PDT) X-Received: by 10.180.83.193 with SMTP id s1mr6019891wiy.22.1430315542035; Wed, 29 Apr 2015 06:52:22 -0700 (PDT) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id fa8sm21307548wib.14.2015.04.29.06.52.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Apr 2015 06:52:21 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk Subject: [RFC PATCH] ARM: add fixmap based earlycon support Date: Wed, 29 Apr 2015 15:51:48 +0200 Message-Id: <1430315508-7582-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150429_065844_121012_5DB41ABC X-CRM114-Status: GOOD ( 11.53 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.172 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: roy.franz@linaro.org, Ard Biesheuvel , leif.lindholm@linaro.org, nico@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This adds support for fixmap based earlycon by moving the fixmap initialization to an earlier stage and introducing the Kconfig symbol that wires up the existing code. Signed-off-by: Ard Biesheuvel --- arch/arm/Kconfig | 3 +++ arch/arm/include/asm/fixmap.h | 6 ++++++ arch/arm/kernel/setup.c | 2 ++ arch/arm/mm/mmu.c | 16 +++++++++++++--- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 45df48ba0b12..0076330789f5 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -287,6 +287,9 @@ config GENERIC_BUG def_bool y depends on BUG +config FIX_EARLYCON_MEM + def_bool y + config PGTABLE_LEVELS int default 3 if ARM_LPAE diff --git a/arch/arm/include/asm/fixmap.h b/arch/arm/include/asm/fixmap.h index 0415eae1df27..e0abd3a150ee 100644 --- a/arch/arm/include/asm/fixmap.h +++ b/arch/arm/include/asm/fixmap.h @@ -1,6 +1,10 @@ #ifndef _ASM_FIXMAP_H #define _ASM_FIXMAP_H +#include + +#define FIXMAP_PAGE_IO L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY + #define FIXADDR_START 0xffc00000UL #define FIXADDR_END 0xfff00000UL #define FIXADDR_TOP (FIXADDR_END - PAGE_SIZE) @@ -11,6 +15,8 @@ enum fixed_addresses { FIX_KMAP_BEGIN, FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1, + FIX_EARLYCON_MEM_BASE, + /* Support writing RO kernel text via kprobes, jump labels, etc. */ FIX_TEXT_POKE0, FIX_TEXT_POKE1, diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 6c777e908a24..2e4b3c22be4d 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -80,6 +80,7 @@ extern void early_paging_init(const struct machine_desc *, extern void sanity_check_meminfo(void); extern enum reboot_mode reboot_mode; extern void setup_dma_zone(const struct machine_desc *desc); +extern void early_fixmap_init(void); unsigned int processor_id; EXPORT_SYMBOL(processor_id); @@ -915,6 +916,7 @@ void __init setup_arch(char **cmdline_p) const struct machine_desc *mdesc; setup_processor(); + early_fixmap_init(); mdesc = setup_machine_fdt(__atags_pointer); if (!mdesc) mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type); diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 4e6ef896c619..d072726c3781 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -1231,7 +1231,9 @@ static void __init devicemaps_init(const struct machine_desc *mdesc) early_trap_init(vectors); - for (addr = VMALLOC_START; addr; addr += PMD_SIZE) + for (addr = VMALLOC_START; addr < FIXADDR_START; addr += PMD_SIZE) + pmd_clear(pmd_off_k(addr)); + for (addr = round_up(FIXADDR_END, PMD_SIZE); addr; addr += PMD_SIZE) pmd_clear(pmd_off_k(addr)); /* @@ -1321,9 +1323,17 @@ static void __init kmap_init(void) pkmap_page_table = early_pte_alloc(pmd_off_k(PKMAP_BASE), PKMAP_BASE, _PAGE_KERNEL_TABLE); #endif +} + +void __init early_fixmap_init(void) +{ + static u8 fixmap_pte[PTE_HWTABLE_OFF + PTE_HWTABLE_SIZE] __page_aligned_bss; + pmd_t *pmd = pmd_off_k(FIXADDR_START); + + if (pmd_none(*pmd)) + __pmd_populate(pmd, __pa(fixmap_pte), _PAGE_KERNEL_TABLE); - early_pte_alloc(pmd_off_k(FIXADDR_START), FIXADDR_START, - _PAGE_KERNEL_TABLE); + BUG_ON(pmd_bad(*pmd)); } static void __init map_lowmem(void)