From patchwork Fri Jun 2 13:52:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101261 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp205140obc; Fri, 2 Jun 2017 06:55:42 -0700 (PDT) X-Received: by 10.84.212.2 with SMTP id d2mr66107pli.26.1496411742279; Fri, 02 Jun 2017 06:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411742; cv=none; d=google.com; s=arc-20160816; b=jSpb6jLSIgJSP7qsmpS/hL5yxJEl5ToXMlgr5zDRxCEJUh53fQeOI8fj3P0RBj+ezv kKfyz2+yMr6Rz1+iWgd67NKidtR7rQO0OWgKgk3ZU3UhJK9xzE/l4+gDP0AF/tQWVRJb rbQ2rYZYEhurx8nbZgxefYziRCKZ/rrzo478ehCM7C2iu22hl2xxNL2MEJae20xDepCp r3EwYjOas+ZuQ50evzofLBA16qweUG32pBuCmOq2OM+5TYvnt41qiP7CmvP9/Cac9BjU C6nj+/Wgg86lAyvre8se+9B7pMQgN56AwAe9U8Ruaiosht5Fq7YVKru1B3Pmq2fpfxEq iOLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=yCqokJKIL55SHezFbhcx6v9MjiXiIwdHiWCCtvJRqdA=; b=Bs5ROaR9/mfhkv1jUlA2DsDMHp/6ilhUDyeE0rJZSqzREUivP0s3YDedWMeXFID/+W LBbZeQWAG7m2v3NKjOD7k3ELotMYv0zYamE3a3jkS4VKJlO3VWxY2DXwHjVMbCfRJIWN hd3puKSPcCswAtsICC6Eg75qh46yiPW35Q1sseunWVVnuZuLc0i7UJIMmQDHdFx2elxf 6XZllZZToV2J+c065d/XWuY05tGnsoNqzbCiSQ8kW/dTcED3Rk2n4p4bnumhnC713/QZ ebinJxTwfzovSl/CY5TqDxDvLQNX0rtWQhSeAfdasjjmzggTTSd/WBTbq3UMJre/AmDi 2ZOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l17si3183385pgj.43.2017.06.02.06.55.41; Fri, 02 Jun 2017 06:55:42 -0700 (PDT) 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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751651AbdFBNzZ (ORCPT + 25 others); Fri, 2 Jun 2017 09:55:25 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:35123 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbdFBNzV (ORCPT ); Fri, 2 Jun 2017 09:55:21 -0400 Received: by mail-wm0-f52.google.com with SMTP id b84so26401360wmh.0 for ; Fri, 02 Jun 2017 06:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yCqokJKIL55SHezFbhcx6v9MjiXiIwdHiWCCtvJRqdA=; b=gusplvijOQxdHIqT7Vj7R6yUYu7S7rTX2hAFSIPAgjnEASd3Te7MNEQftqzfDyLRdx gozZ7fHEzAcNuRAfj7B4HDNKb26r/5u5zEKRCyTc/0iePmC6Hx1JarknA7lQK9fRfzNh JLMxWxFEd1p0O+rcbuPv32ZhzqeJLTnvnUyI8= 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; bh=yCqokJKIL55SHezFbhcx6v9MjiXiIwdHiWCCtvJRqdA=; b=S0ff6G18M3oxJ56quuHj2ql+ZG4mzgztgjrr5cYqoR3SXyQidm1Ujrz7DUOB4L67Pk l49XEDdUKGRjxraug9TY53L/tCfAs6my0QPBWZG/R37sgU1/LZ4XbvWpDDuBFQAvbBPv LjOk2WMJ83OrWNW4i/y9Y+V0tqtCmS7tQzvyc8/+mtr6cXL5X5Ry+b3Fzb9W9tU4VrBY YHOlz66QMzDXlNkpzkWI7VF2lRjxgRJaH2Jl9JMhgsxIJ6C47dZ2hvshn8SOCtwb6amq ZGIo9B0W93bHl2dbS7Es6Gh9uvIoiE3VGkn3oyUM7XdiMKue057EofDR1MWYjrYyNE+M RYRA== X-Gm-Message-State: AODbwcAzpO1u17+xJQSHEZYx9J3GPU54tBp+JrHclkoQSkSMB7DGsIfN wiEsX1IxeDmPVYGo X-Received: by 10.80.168.102 with SMTP id j93mr6318298edc.32.1496411710265; Fri, 02 Jun 2017 06:55:10 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.55.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:55:09 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Sai Praneeth , Ard Biesheuvel , linux-kernel@vger.kernel.org, Borislav Petkov , Ricardo Neri , Ravi Shankar , Matt Fleming Subject: [PATCH 12/13] x86/efi: Add EFI_PGT_DUMP support for x86_32 and kexec Date: Fri, 2 Jun 2017 13:52:06 +0000 Message-Id: <20170602135207.21708-13-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sai Praneeth EFI_PGT_DUMP, as the name suggests dumps efi page tables to dmesg during kernel boot. This feature is very useful while debugging page faults/null pointer dereferences to efi related addresses. Presently, this feature is limited only to x86_64, so let's extend it to other efi configurations like kexec kernel, efi=old_map and to x86_32 as well. This doesn't effect normal boot path because this config option should be used only for debug purposes. Signed-off-by: Sai Praneeth Prakhya Cc: Borislav Petkov Cc: Ricardo Neri Cc: Ard Biesheuvel Cc: Ravi Shankar Signed-off-by: Matt Fleming --- arch/x86/platform/efi/efi.c | 3 ++- arch/x86/platform/efi/efi_32.c | 9 ++++++++- arch/x86/platform/efi/efi_64.c | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) -- 2.9.3 diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index dc2da5e2c7e4..3cf8536e803b 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -1012,7 +1012,6 @@ static void __init __efi_enter_virtual_mode(void) * necessary relocation fixups for the new virtual addresses. */ efi_runtime_update_mappings(); - efi_dump_pagetable(); /* clean DUMMY object */ efi_delete_dummy_variable(); @@ -1027,6 +1026,8 @@ void __init efi_enter_virtual_mode(void) kexec_enter_virtual_mode(); else __efi_enter_virtual_mode(); + + efi_dump_pagetable(); } /* diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c index 403a987d06c7..fe18c5d32bf0 100644 --- a/arch/x86/platform/efi/efi_32.c +++ b/arch/x86/platform/efi/efi_32.c @@ -44,7 +44,14 @@ int __init efi_alloc_page_tables(void) } void efi_sync_low_kernel_mappings(void) {} -void __init efi_dump_pagetable(void) {} + +void __init efi_dump_pagetable(void) +{ +#ifdef CONFIG_EFI_PGT_DUMP + ptdump_walk_pgd_level(NULL, swapper_pg_dir); +#endif +} + int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) { return 0; diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 6fbf6c47e603..0d8180811445 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -528,7 +528,10 @@ void __init efi_runtime_update_mappings(void) void __init efi_dump_pagetable(void) { #ifdef CONFIG_EFI_PGT_DUMP - ptdump_walk_pgd_level(NULL, efi_pgd); + if (efi_enabled(EFI_OLD_MEMMAP)) + ptdump_walk_pgd_level(NULL, swapper_pg_dir); + else + ptdump_walk_pgd_level(NULL, efi_pgd); #endif }