Received: by 10.213.65.68 with SMTP id h4csp670560imn; Sat, 31 Mar 2018 07:11:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx48kri5/Yj4qw+J1P26PHnP+2WVBDWa7CK73zkY5BvhJRdSLqNjAfAgBOikF1b+J9nCRFgtE X-Received: by 10.98.251.5 with SMTP id x5mr2314691pfm.18.1522505515899; Sat, 31 Mar 2018 07:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522505515; cv=none; d=google.com; s=arc-20160816; b=zwcSvMHpgxXaQ9C+T7do5bhby2ovKMlZzJ/wbMwKZNvqCuj1nrdo2SkP/Lb4kZR+IZ nsJPMtwiyNDaeJRup2VtMSlQnCL4gZUlnRpGDyDh1IZmNYZWZWIzBsxpHV9ufE/Bfn5V 9u5/vV2f7FzWMQupTG6spIOTE36boHZuoqQ45xmW/uzUX2ZlfVZ1xoePj0xW6DtjKZ2j dJY4YOoHFf1tBuCo+lqopuUTdJtgcUnZxb408mil/n/s+Fnuajn0ujFVfPhlu9bTrPXR ZX3iP3+WeBpMxiTgVmKMIXnzWdSAtP9Zt2hoNnUIDftxu0DR70GXqyVgWOwiDBy9o/tz Q8Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=y+gXvqBuE0e9phnoccnaJf32FiSkOE1ls200L705uJc=; b=Yy6e83zfpYy8G8tWCEa2nPDEDEyQ+Jw5nbW8Q4t6GJdxs6KOsGm+0FR+RpTx1Cl67j F3dpiuOkbLeTga9Fy2OuSRS5UEna0GbrNOyqNfKtnFoRK0DNo8tLOZJAdSSagb766rWZ LsCp8Zklv2H33J8ivuS544QgkLyPvHhkhC6ywnPqNv+pvlSaPGUYY7mLX+nW7yVLWJYt eSgCQ6YU7Q2qdnLrF++Wn7jF/eAKOWs4n3beNdgDOvD9uCYUxtiNCMZEejMcSXJqpJ2O QYZJI4QK0AT8tVbYg2JPRn+QUcm+OlBA2Nb8b1N/I8EpYnSsQWE77DPkF6GxhgDO/4Xf PyGw== 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 bf3-v6si1146867plb.643.2018.03.31.07.11.41; Sat, 31 Mar 2018 07:11:55 -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; 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 S1752895AbeCaOKg (ORCPT + 99 others); Sat, 31 Mar 2018 10:10:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37506 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752248AbeCaOKf (ORCPT ); Sat, 31 Mar 2018 10:10:35 -0400 Received: from localhost (unknown [62.177.166.178]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C026F504; Sat, 31 Mar 2018 14:10:34 +0000 (UTC) Date: Sat, 31 Mar 2018 16:10:30 +0200 From: Greg Kroah-Hartman To: Hans de Goede Cc: Ard Biesheuvel , "Luis R . Rodriguez" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , linux-kernel@vger.kernel.org, Peter Jones , Dave Olsthoorn , x86@kernel.org, linux-efi@vger.kernel.org Subject: Re: [PATCH 1/2] efi: Export boot-services code and data as debugfs-blobs Message-ID: <20180331141030.GB1074@kroah.com> References: <20180331121944.8618-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180331121944.8618-1-hdegoede@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 31, 2018 at 02:19:43PM +0200, Hans de Goede wrote: > Sometimes it is useful to be able to dump the efi boot-services code and > data. This commit adds these as debugfs-blobs to /sys/kernel/debug/efi, > but only if efi=debug is passed on the kernel-commandline as this requires > not freeing those memory-regions, which costs 20+ MB of RAM. > > Signed-off-by: Hans de Goede > --- > arch/x86/platform/efi/quirks.c | 4 +++ > drivers/firmware/efi/efi.c | 57 ++++++++++++++++++++++++++++++++++ > 2 files changed, 61 insertions(+) > > diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c > index 5b513ccffde4..0f968c7bcfec 100644 > --- a/arch/x86/platform/efi/quirks.c > +++ b/arch/x86/platform/efi/quirks.c > @@ -374,6 +374,10 @@ void __init efi_free_boot_services(void) > int num_entries = 0; > void *new, *new_md; > > + /* Keep all regions for /sys/kernel/debug/efi */ > + if (efi_enabled(EFI_DBG)) > + return; > + > for_each_efi_memory_desc(md) { > unsigned long long start = md->phys_addr; > unsigned long long size = md->num_pages << EFI_PAGE_SHIFT; > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > index cd42f66a7c85..fddc5f706fd2 100644 > --- a/drivers/firmware/efi/efi.c > +++ b/drivers/firmware/efi/efi.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -316,6 +317,59 @@ static __init int efivar_ssdt_load(void) > static inline int efivar_ssdt_load(void) { return 0; } > #endif > > +#ifdef CONFIG_DEBUG_FS > + > +#define EFI_DEBUGFS_MAX_BLOBS 32 > + > +struct debugfs_blob_wrapper debugfs_blob[EFI_DEBUGFS_MAX_BLOBS]; > + > +static void __init efi_debugfs_init(void) > +{ > + struct dentry *efi_debugfs; > + efi_memory_desc_t *md; > + char name[32]; > + int type_count[EFI_BOOT_SERVICES_DATA + 1] = {}; > + int i = 0; > + > + efi_debugfs = debugfs_create_dir("efi", NULL); > + if (IS_ERR_OR_NULL(efi_debugfs)) { > + pr_warn("Could not create efi debugfs entry\n"); > + return; > + } {sigh} No, don't warn, or complain, or do anything else if a debugfs call fails. Just keep on moving, you can always use the return value properly in any future call if you need it, and no code flow should ever care if a debugfs call succeeded or failed. > /* > * We register the efi subsystem with the firmware subsystem and the > * efivars subsystem with the efi subsystem, if the system was booted with > @@ -360,6 +414,9 @@ static int __init efisubsys_init(void) > goto err_remove_group; > } > > + if (efi_enabled(EFI_DBG)) > + efi_debugfs_init(); You never remove the directory? thanks, greg k-h