Received: by 10.223.185.111 with SMTP id b44csp76705wrg; Fri, 9 Mar 2018 01:14:01 -0800 (PST) X-Google-Smtp-Source: AG47ELtOKECdap2pDJZ8n4RJZ274q/MYbR+ppaejXaEvdQas9d45d5j8EnYKCNC5b947ZutgCAtd X-Received: by 2002:a17:902:710f:: with SMTP id a15-v6mr26390134pll.87.1520586841141; Fri, 09 Mar 2018 01:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520586841; cv=none; d=google.com; s=arc-20160816; b=MulmeCBIQgtekjB256IyKSURemuqVlUORHmTg2f2n/U7ez9lCSIp3UdiUbIeRu19yd lCFhc+zWw4kdNVYxPmZf47gnS7Hvn7Ql9dsYKY9nWJ1VywRH4iMSoNL4N9tt5h4fr/LY kXXectuOPebw6am0JxsiHSaeAPdy20wieL3E1DQVJ1ac4tM+5HJKuR1WAsjtwl7MEkje VSZtpj59CDTUClbYmgI0/Hb9Ni7qRm/9IjcMHZDKKi67q4mtXFEXIXeGQPrlyXV/TXlW NQjVRZu4DHyg5nGFvYT6aUWxkUgJkWu5aDLmldd2IE00YrVswX0A8RyXdt+ILfK5htq4 Py1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=yOVU7ckadLhdQew41Qcuzo9KvdmdyLVHipFzK65s9jg=; b=S1GDblFJSI8lVCb35j392vrYZemm79Rg4RzsWNirPNyiVOFLdOjmz0l+HQMzwF8MeB 02EQdsXUtsYIg211sppXJk4Q6dxEWA9N664vCNndEZQ/GjhbUVysMBmfa7TrQf9vFUOc IB6yBkZkWgFqNeUnqz3Wy3zpc+rRGuB6eowW+DgF81j3vkkIY14A8EEZMLGdC97diFc9 EMeeCVSaBAyb49MBDeW2T5JVMKUWeflPJgEp2hcIjgWnAdaQNkeRNhRlI29XIMRrrEeN k6cs6qXk8xy7ZyMrkn/H9eHl0uHoLt0i+87ye1i+u7Aigod7nar26gfq6UCV3SxYSzGK N8qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si445959pge.465.2018.03.09.01.13.46; Fri, 09 Mar 2018 01:14:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751941AbeCIJLn (ORCPT + 99 others); Fri, 9 Mar 2018 04:11:43 -0500 Received: from terminus.zytor.com ([198.137.202.136]:53905 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751321AbeCIJLj (ORCPT ); Fri, 9 Mar 2018 04:11:39 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w299BEXL032275; Fri, 9 Mar 2018 01:11:14 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w299BEcv032272; Fri, 9 Mar 2018 01:11:14 -0800 Date: Fri, 9 Mar 2018 01:11:14 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Mark Rutland Message-ID: Cc: torvalds@linux-foundation.org, mingo@kernel.org, mark.rutland@arm.com, peterz@infradead.org, ard.biesheuvel@linaro.org, will.deacon@arm.com, matt@codeblueprint.co.uk, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de Reply-To: torvalds@linux-foundation.org, mingo@kernel.org, peterz@infradead.org, mark.rutland@arm.com, ard.biesheuvel@linaro.org, will.deacon@arm.com, matt@codeblueprint.co.uk, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com In-Reply-To: <20180308080020.22828-2-ard.biesheuvel@linaro.org> References: <20180308080020.22828-2-ard.biesheuvel@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/core] efi/arm*: Only register page tables when they exist Git-Commit-ID: 6b31a2fa1e8f7bc6c2a474b4a12dad7a145cf83d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6b31a2fa1e8f7bc6c2a474b4a12dad7a145cf83d Gitweb: https://git.kernel.org/tip/6b31a2fa1e8f7bc6c2a474b4a12dad7a145cf83d Author: Mark Rutland AuthorDate: Thu, 8 Mar 2018 08:00:09 +0000 Committer: Ingo Molnar CommitDate: Fri, 9 Mar 2018 08:58:21 +0100 efi/arm*: Only register page tables when they exist Currently the arm/arm64 runtime code registers the runtime servies pagetables with ptdump regardless of whether runtime services page tables have been created. As efi_mm.pgd is NULL in these cases, attempting to dump the efi page tables results in a NULL pointer dereference in the ptdump code: /sys/kernel/debug# cat efi_page_tables [ 479.522600] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 479.522715] Mem abort info: [ 479.522764] ESR = 0x96000006 [ 479.522850] Exception class = DABT (current EL), IL = 32 bits [ 479.522899] SET = 0, FnV = 0 [ 479.522937] EA = 0, S1PTW = 0 [ 479.528200] Data abort info: [ 479.528230] ISV = 0, ISS = 0x00000006 [ 479.528317] CM = 0, WnR = 0 [ 479.528317] user pgtable: 4k pages, 48-bit VAs, pgd = 0000000064ab0cb0 [ 479.528449] [0000000000000000] *pgd=00000000fbbe4003, *pud=00000000fb66e003, *pmd=0000000000000000 [ 479.528600] Internal error: Oops: 96000006 [#1] PREEMPT SMP [ 479.528664] Modules linked in: [ 479.528699] CPU: 0 PID: 2457 Comm: cat Not tainted 4.15.0-rc3-00065-g2ad2ee7ecb5c-dirty #7 [ 479.528799] Hardware name: FVP Base (DT) [ 479.528899] pstate: 00400009 (nzcv daif +PAN -UAO) [ 479.528941] pc : walk_pgd.isra.1+0x20/0x1d0 [ 479.529011] lr : ptdump_walk_pgd+0x30/0x50 [ 479.529105] sp : ffff00000bf4bc20 [ 479.529185] x29: ffff00000bf4bc20 x28: 0000ffff9d22e000 [ 479.529271] x27: 0000000000020000 x26: ffff80007b4c63c0 [ 479.529358] x25: 00000000014000c0 x24: ffff80007c098900 [ 479.529445] x23: ffff00000bf4beb8 x22: 0000000000000000 [ 479.529532] x21: ffff00000bf4bd70 x20: 0000000000000001 [ 479.529618] x19: ffff00000bf4bcb0 x18: 0000000000000000 [ 479.529760] x17: 000000000041a1c8 x16: ffff0000082139d8 [ 479.529800] x15: 0000ffff9d3c6030 x14: 0000ffff9d2527f4 [ 479.529924] x13: 00000000000003f3 x12: 0000000000000038 [ 479.530000] x11: 0000000000000003 x10: 0101010101010101 [ 479.530099] x9 : 0000000017e94050 x8 : 000000000000003f [ 479.530226] x7 : 0000000000000000 x6 : 0000000000000000 [ 479.530313] x5 : 0000000000000001 x4 : 0000000000000000 [ 479.530416] x3 : ffff000009069fd8 x2 : 0000000000000000 [ 479.530500] x1 : 0000000000000000 x0 : 0000000000000000 [ 479.530599] Process cat (pid: 2457, stack limit = 0x000000005d1b0e6f) [ 479.530660] Call trace: [ 479.530746] walk_pgd.isra.1+0x20/0x1d0 [ 479.530833] ptdump_walk_pgd+0x30/0x50 [ 479.530907] ptdump_show+0x10/0x20 [ 479.530920] seq_read+0xc8/0x470 [ 479.531023] full_proxy_read+0x60/0x90 [ 479.531100] __vfs_read+0x18/0x100 [ 479.531180] vfs_read+0x88/0x160 [ 479.531267] SyS_read+0x48/0xb0 [ 479.531299] el0_svc_naked+0x20/0x24 [ 479.531400] Code: 91400420 f90033a0 a90707a2 f9403fa0 (f9400000) [ 479.531499] ---[ end trace bfe8e28d8acb2b67 ]--- Segmentation fault Let's avoid this problem by only registering the tables after their successful creation, which is also less confusing when EFI runtime services are not in use. Reported-by: Will Deacon Signed-off-by: Mark Rutland Signed-off-by: Ard Biesheuvel Acked-by: Will Deacon Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180308080020.22828-2-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/arm-runtime.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 1cc41c3d6315..86a1ad17a32e 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -54,6 +54,9 @@ static struct ptdump_info efi_ptdump_info = { static int __init ptdump_init(void) { + if (!efi_enabled(EFI_RUNTIME_SERVICES)) + return 0; + return ptdump_debugfs_register(&efi_ptdump_info, "efi_page_tables"); } device_initcall(ptdump_init);