From patchwork Thu May 16 10:28:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 10946301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEE091395 for ; Thu, 16 May 2019 10:29:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC307288F8 for ; Thu, 16 May 2019 10:29:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF59728978; Thu, 16 May 2019 10:29:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66299288F8 for ; Thu, 16 May 2019 10:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MnsZrCavNE6+LsqpvzW6lSEYdTxpjmQvdFBk61Ey+5Q=; b=kbY6p3xxo8PZ1c XQFxYV1ay97VCScTdO9fKy1hzHOvZ2xTRHqNxILLEihIIXrmp3nueYzm9a/yqoiExHRTQmwxVBgUs wXfizVN/op1Fgh8S4ws8ZJecLdslJGa7FO9FWy93pedLNzawyt7F6MCkuG4uZp5ea4oYYW3LHBJYi q32lG7VG49CMd9ovKJQMw4ZfiiWaYwPx10YNd0ltXY8pRiEixNMz41hzzSWqt9I+SUzO2jKMB642h 39SinS1Ss1I+XWjFLL1qKolivJKBEbCvzmd9fuMq+Eblf5sj0snASv9sKSYOHfEpB/dJOYIYLBVUa JaweCZSr9AfX1UZyg59A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hRDdA-0001wb-FC; Thu, 16 May 2019 10:28:56 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hRDd6-0001uw-M0 for linux-arm-kernel@lists.infradead.org; Thu, 16 May 2019 10:28:54 +0000 Received: by mail-pl1-x644.google.com with SMTP id c5so1400631pll.11 for ; Thu, 16 May 2019 03:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g6nTVnaTPu6u0ik4+YTeRCBKr6f5B4jeaBgRZ5SbxTw=; b=ZQ/kc6aBkZflGhXSDxDpSNRqmjhb6N9q0F7lksh1UBLl2/I6uLpMJ2EFTj5RVV6ZxA IcqVwlZFK1fgG3i5YsdnWHnSvAe8T4bmzMowpcI9tL+lc9gEd+w3HwFB2PVGkTmHiNqw kznERwYCaREsUwnxdTq4nxj3gvx3GkByAOgng= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g6nTVnaTPu6u0ik4+YTeRCBKr6f5B4jeaBgRZ5SbxTw=; b=qLFfsCQ48bxtItLTJglgEaxioTo+hcuwcwQryHHnkj0QaZVBk/sPXudSd9XW5vyPR0 qfTH+phtqIo1d6U244QBgPpsCkECWlrW9VBg7VvzI5017pkSn2mBaGZuzZDWpe8IbPd/ yWDm3zNG26jPo1P/2nrf/PGha/+q75gE4153y5oniMYQ9TwxUWF6kDUpgz3LrCnP7vO1 cy5iz3oxgIGDjGVnQHuyqs3HgBTq6Gt6cg3gMv5BmwijRBUXPWkVrvq79l7MisAlqEVB cf7x6Is/8OY2umueAnR0BlwvOCiqj4OjagLspyqx0ss29AONRTaHe9P27UMGxiFhWEQ+ FT1A== X-Gm-Message-State: APjAAAVjh6m45lEnWoQsJluJ0U3tpSNYOMUkN432pQ27UA21UTy6Q88q LpYmDq8LDb/BAN97xs8WDeptdimWQjY= X-Google-Smtp-Source: APXvYqz6D4VCan2gvNE8/0EMna/+ZpJBgnCigTNFcMqpDIsMc91bUoTxMOxk4U2jcWrjaJnlZy8LoA== X-Received: by 2002:a17:902:9a81:: with SMTP id w1mr47668258plp.71.1558002531758; Thu, 16 May 2019 03:28:51 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:b852:bd51:9305:4261]) by smtp.gmail.com with ESMTPSA id h123sm9338048pfe.80.2019.05.16.03.28.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 May 2019 03:28:51 -0700 (PDT) From: Hsin-Yi Wang To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/3] arm64: implement update_fdt_pgprot() Date: Thu, 16 May 2019 18:28:16 +0800 Message-Id: <20190516102817.188519-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190516102817.188519-1-hsinyi@chromium.org> References: <20190516102817.188519-1-hsinyi@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190516_032852_717287_06C7342C X-CRM114-Status: GOOD ( 14.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Yu Zhao , Kees Cook , Ard Biesheuvel , Catalin Marinas , Stephen Boyd , Chintan Pandya , Will Deacon , linux-kernel@vger.kernel.org, Mike Rapoport , Jun Yao , Miles Chen , Rob Herring , James Morse , Hsin-Yi Wang , Andrew Murray , Andrew Morton , Laura Abbott , Frank Rowand , Robin Murphy Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Basically does similar things like __fixmap_remap_fdt(). It's supposed to be called after fixmap_remap_fdt() is called at least once, so region checking can be skipped. Since it needs to know dt physical address, make a copy of the value of __fdt_pointer. Signed-off-by: Hsin-Yi Wang --- arch/arm64/kernel/setup.c | 2 ++ arch/arm64/mm/mmu.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 413d566405d1..207cbb5f7965 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -66,6 +66,7 @@ static int num_standard_resources; static struct resource *standard_resources; phys_addr_t __fdt_pointer __initdata; +phys_addr_t fdt_pointer; /* * Standard memory resources @@ -292,6 +293,7 @@ void __init setup_arch(char **cmdline_p) early_fixmap_init(); early_ioremap_init(); + fdt_pointer = __fdt_pointer; setup_machine_fdt(__fdt_pointer); parse_early_param(); diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index a170c6369a68..196ab4d9e92a 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -953,6 +954,22 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys) return dt_virt; } +extern phys_addr_t fdt_pointer; + +/* Should be called after fixmap_remap_fdt() is called. */ +void update_fdt_pgprot(pgprot_t prot) +{ + u64 dt_virt_base = __fix_to_virt(FIX_FDT); + int offset, size; + + offset = fdt_pointer % SWAPPER_BLOCK_SIZE; + size = fdt_totalsize((void *)dt_virt_base + offset); + + update_mapping_prot(round_down(fdt_pointer, SWAPPER_BLOCK_SIZE), + dt_virt_base, + round_up(offset + size, SWAPPER_BLOCK_SIZE), prot); +} + int __init arch_ioremap_pud_supported(void) { /* only 4k granule supports level 1 block mappings */