From patchwork Mon Nov 10 18:47:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 40525 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 321DD244B0 for ; Mon, 10 Nov 2014 18:47:28 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e51sf5915741eek.10 for ; Mon, 10 Nov 2014 10:47:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=1LbNhGjKklpM8v8zERigEi+4lWZ+I/571Qk6uFye9f4=; b=mGmhEJCjAdIi5sthphSuIAttOzPrrO5ITGki84eFPQJ66FGuWBBHZ4EHyfeE8kE/kx 1DcGkmdJm1YwgpweuVUM7P72aKgoQC2B1pwugJhkQ/jlmRcxK5B+XhYyKvj4w2iRR15k p7WAjwbEzwSd/k+b60xEpqXkAcleJxUkWs/SBcC6B0sJQgvE0Lns+J7t2/y/1/hDgkP6 6aroDfV4vaG/913Isc4v6htYU7XML/l9/HUsx5O4/6kfIMwFZ/Y5ewYLoWkbS0TyYpIk TQrNPrCNYYbsnEcbgnJVRttJTla/1RqBIxfVJ4lOdj47CD2ahn2XOOPAIlo5863H4Jb3 GnDw== X-Gm-Message-State: ALoCoQknkfm+1qSsOrKP0tkfvexVyz/AmgOGaaQel+AIhv4/7NzWeQivqo6s90npPE/eQqy+cneD X-Received: by 10.112.180.71 with SMTP id dm7mr137989lbc.18.1415645247267; Mon, 10 Nov 2014 10:47:27 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.226 with SMTP id r2ls575412lal.49.gmail; Mon, 10 Nov 2014 10:47:27 -0800 (PST) X-Received: by 10.112.139.165 with SMTP id qz5mr4279725lbb.96.1415645246983; Mon, 10 Nov 2014 10:47:26 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id ll12si28340024lac.58.2014.11.10.10.47.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Nov 2014 10:47:26 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gm9so8307140lab.33 for ; Mon, 10 Nov 2014 10:47:26 -0800 (PST) X-Received: by 10.152.116.102 with SMTP id jv6mr11488052lab.40.1415645246843; Mon, 10 Nov 2014 10:47:26 -0800 (PST) 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.184.201 with SMTP id ew9csp142585lbc; Mon, 10 Nov 2014 10:47:25 -0800 (PST) X-Received: by 10.70.38.198 with SMTP id i6mr34168840pdk.93.1415645244893; Mon, 10 Nov 2014 10:47:24 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qn7si17411839pbc.63.2014.11.10.10.47.24 for ; Mon, 10 Nov 2014 10:47:24 -0800 (PST) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751936AbaKJSrX (ORCPT + 4 others); Mon, 10 Nov 2014 13:47:23 -0500 Received: from mail-wi0-f172.google.com ([209.85.212.172]:62971 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751934AbaKJSrX (ORCPT ); Mon, 10 Nov 2014 13:47:23 -0500 Received: by mail-wi0-f172.google.com with SMTP id bs8so11831253wib.17 for ; Mon, 10 Nov 2014 10:47:18 -0800 (PST) X-Received: by 10.180.93.195 with SMTP id cw3mr32467902wib.68.1415645238618; Mon, 10 Nov 2014 10:47:18 -0800 (PST) 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 l10sm14416085wif.20.2014.11.10.10.47.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Nov 2014 10:47:17 -0800 (PST) From: Ard Biesheuvel To: grant.likely@linaro.org, leif.lindholm@linaro.org, geoff.levand@linaro.org, mark.rutland@arm.com, rob.herring@linaro.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel Subject: [PATCH v2 2/2] arm64: fdt: call preserve_fdt() before unflattening it Date: Mon, 10 Nov 2014 19:47:02 +0100 Message-Id: <1415645222-14909-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1415645222-14909-1-git-send-email-ard.biesheuvel@linaro.org> References: <1415645222-14909-1-git-send-email-ard.biesheuvel@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.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.46 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , To support the new /sys/firmware/fdt entry that gives access to the FDT blob as passed by the bootloader, call preserve_fdt() in the early arch code to make a copy of it before the unflattening code gets its hands on it. Also, make the early mapping of the FDT read only so we are certain it will not get clobbered by anything called by setup_machine_fdt(), which handles the FDT blob even earlier. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 3 +++ arch/arm64/kernel/setup.c | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 0a6e4f924df8..df25dffcda9f 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -79,8 +79,10 @@ #ifdef CONFIG_ARM64_64K_PAGES #define MM_MMUFLAGS PTE_ATTRINDX(MT_NORMAL) | PTE_FLAGS +#define MM_MMUFLAGS_RO PTE_ATTRINDX(MT_NORMAL) | PTE_FLAGS | PTE_RDONLY #else #define MM_MMUFLAGS PMD_ATTRINDX(MT_NORMAL) | PMD_FLAGS +#define MM_MMUFLAGS_RO PMD_ATTRINDX(MT_NORMAL) | PMD_FLAGS | PMD_SECT_RDONLY #endif /* @@ -607,6 +609,7 @@ __create_page_tables: * Map the FDT blob (maximum 2MB; must be within 512MB of * PHYS_OFFSET). */ + ldr x7, =MM_MMUFLAGS_RO mov x3, x21 // FDT phys address and x3, x3, #~((1 << 21) - 1) // 2MB aligned mov x6, #PAGE_OFFSET diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 2437196cc5d4..1b535cc42981 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -394,6 +394,7 @@ void __init setup_arch(char **cmdline_p) efi_idmap_init(); + preserve_fdt(); unflatten_device_tree(); psci_init();