From patchwork Fri Jul 22 16:27:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 72631 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1084573qga; Fri, 22 Jul 2016 09:29:20 -0700 (PDT) X-Received: by 10.67.8.10 with SMTP id dg10mr7902518pad.54.1469204960386; Fri, 22 Jul 2016 09:29:20 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id oy8si16556401pac.126.2016.07.22.09.29.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jul 2016 09:29:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bQdJI-0001UK-TJ; Fri, 22 Jul 2016 16:28:24 +0000 Received: from mail-it0-x233.google.com ([2607:f8b0:4001:c0b::233]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bQdJD-0001Qj-80 for linux-arm-kernel@lists.infradead.org; Fri, 22 Jul 2016 16:28:21 +0000 Received: by mail-it0-x233.google.com with SMTP id f6so40683344ith.1 for ; Fri, 22 Jul 2016 09:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tWR9m7u0C4LM3jn3IdbAhtiAWUCkz67oxbUBy6zdl1M=; b=NEGbJycCeLq7aNHJNgZx0/B/k4xfh0K+dp1tJ74i1xNYQHDVdSSqA3fWTnOazhiHW/ iCXAt7Yb1lkiovTRd4BM4tve+zZw01dyTEd6hIDf/pfqz2f1rzC1Kwa8vmZo0GHKvbs2 GyFiuwyhbZ9qaZPosLV9aSa0oiXyikd1FCgFU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tWR9m7u0C4LM3jn3IdbAhtiAWUCkz67oxbUBy6zdl1M=; b=f8iKnLa9vIMmwBNNmVcLkpmVhz75nxaG4cYzVR08FAkBOiN/NBiSX9mWwmUU37CKQx HH+WuJyvA/prCwaelYEg6BqLMSV2NeTq++K90e+Si1pYNwBYxL2bxwQJYsmuNn9G1MYf HCM50vWHizXFTXPamLmJnyMNRzWk9B/LCJd+pdPwHCa6rXaGVkdZ7FoLcI5NpGuvUBis 3JVa5rSKTEsAVPK+xfE+uJ44sU//5U/i55RkbF3LxH+0EQFU98sN9BJUkaoUibmsSWcu noub6kjELoI/0gg3exY8u5LgLnFNGLoXa/z9EOPLL1bnmBjNoTdDkaW0mxA75r8QswZ6 KSZA== X-Gm-Message-State: AEkoousJNNHQn7cXOg5djhgYV0mTfkUh/P1I9okH4U+tTiQfm+FKjtDwJv0RECl+KMwdlrdI4jU39Z2DnZ7mdVrP X-Received: by 10.36.107.211 with SMTP id v202mr5115474itc.51.1469204878007; Fri, 22 Jul 2016 09:27:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.214.6 with HTTP; Fri, 22 Jul 2016 09:27:57 -0700 (PDT) In-Reply-To: <64a731b2-1ddb-78f5-fd02-204f19f0a432@arm.com> References: <1467204690-10790-1-git-send-email-ard.biesheuvel@linaro.org> <1467204690-10790-3-git-send-email-ard.biesheuvel@linaro.org> <64a731b2-1ddb-78f5-fd02-204f19f0a432@arm.com> From: Ard Biesheuvel Date: Fri, 22 Jul 2016 18:27:57 +0200 Message-ID: Subject: Re: [PATCH 2/5] arm64: efi: always map runtime services code and data regions down to pages To: Sudeep Holla X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160722_092819_803714_30D013A1 X-CRM114-Status: GOOD ( 19.29 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4001:c0b:0:0:0:233 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "linux-efi@vger.kernel.org" , Matt Fleming , Catalin Marinas , Leif Lindholm , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org On 22 July 2016 at 16:30, Sudeep Holla wrote: > Hi Ard, > > On 29/06/16 13:51, Ard Biesheuvel wrote: >> >> To avoid triggering diagnostics in the MMU code that are finicky about >> splitting block mappings into more granular mappings, ensure that regions >> that are likely to appear in the Memory Attributes table as well as the >> UEFI memory map are always mapped down to pages. This way, we can use >> apply_to_page_range() instead of create_pgd_mapping() for the second pass, >> which cannot split or merge block entries, and operates strictly on PTEs. >> >> Note that this aligns the arm64 Memory Attributes table handling code with >> the ARM code, which already uses apply_to_page_range() to set the strict >> permissions. >> > > This patch is merged in arm64/for-next/core now and when I try that > branch with defconfig + CONFIG_PROVE_LOCKING, I get the following splat > on boot and it fails to boot further on Juno. > > I could bisect that to this patch(Commit bd264d046aad ("arm64: efi: > always map runtime services code and data regions down to pages") in > that branch) > Hi Sudeep, I can reproduce this on QEMU as well. It appears that apply_to_page_range() expects pages containing translation tables to have their per-page spinlock initialized if they are not part of init_mm. This makes the problem go away for me (just as a temporary hack) but I will try to come up with something more appropriate, and check if ARM has the same issue (since it uses apply_to_page_range() as well) -- Ard. > -->8 > > efi: memattr: Processing EFI Memory Attributes table: > efi: memattr: 0x0000f9400000-0x0000f942ffff [Runtime Data |RUN| | > |XP| | | | | | | | ] > Unable to handle kernel NULL pointer dereference at virtual address 00000018 > pgd = ffff000009aa4000 > [00000018] *pgd=00000009ffffe003, *pud=00000009ffffd003, > *pmd=0000000000000000 > Internal error: Oops: 96000004 [#1] PREEMPT SMP > Modules linked in: > CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.7.0-rc7-next-20160722 #134 > Hardware name: ARM Juno development board (r2) (DT) > task: ffff800976ca0000 task.stack: ffff800976c3c000 > PC is at __lock_acquire+0x13c/0x19e0 > LR is at lock_acquire+0x4c/0x68 > pc : [] lr : [] pstate: 200000c5 > .... > __lock_acquire+0x13c/0x19e0 > lock_acquire+0x4c/0x68 > _raw_spin_lock+0x40/0x58 > apply_to_page_range+0x18c/0x388 > efi_set_mapping_permissions+0x34/0x44 > efi_memattr_apply_permissions+0x200/0x2a8 > arm_enable_runtime_services+0x1b4/0x1fc > do_one_initcall+0x38/0x128 > kernel_init_freeable+0x84/0x1f0 > kernel_init+0x10/0x100 > ret_from_fork+0x10/0x40 > Code: 5280003c 79004401 140000b5 b000b880 (f9400282) > ---[ end trace 892120beb6681b4e ]--- > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -272,6 +272,7 @@ static phys_addr_t late_pgtable_alloc(void) { void *ptr = (void *)__get_free_page(PGALLOC_GFP); BUG_ON(!ptr); + BUG_ON(!pgtable_page_ctor(virt_to_page(ptr))); /* Ensure the zeroed page is visible to the page table walker */ dsb(ishst);