From patchwork Mon Mar 20 20:57:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 95587 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1132709qgd; Mon, 20 Mar 2017 13:57:31 -0700 (PDT) X-Received: by 10.98.194.88 with SMTP id l85mr34272817pfg.55.1490043451455; Mon, 20 Mar 2017 13:57:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si18740788pga.229.2017.03.20.13.57.31; Mon, 20 Mar 2017 13:57:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; 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-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754902AbdCTU5b (ORCPT + 2 others); Mon, 20 Mar 2017 16:57:31 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:35803 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754805AbdCTU5a (ORCPT ); Mon, 20 Mar 2017 16:57:30 -0400 Received: by mail-wr0-f174.google.com with SMTP id g10so100413707wrg.2 for ; Mon, 20 Mar 2017 13:57:29 -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; bh=iOcasdbN7mHzYzrtihzTsfUWMezZd1GiWf8+8urHchk=; b=KWOdN84Ov8Tm/twPLcZ548X0qx1+uAqeXlo+UmxMx0X3DXbz8TznmJT1ESkHpXLd97 WOOv9RbzNZpDMBCj4OoMmvme4sdXK/EHiIKTw993c2h5YU5OxTJ/O15oSViwutWt+ObG udwOmM9agkhFLbbggV0cbyZsbGEaHcWpTdOGY= 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; bh=iOcasdbN7mHzYzrtihzTsfUWMezZd1GiWf8+8urHchk=; b=d0IAznCm+O8EY6GuXPALLQyv2EHgQ4Q7N5jgnVGAO+k6y7pjInCdtDowdLaj6hXRsa hIJrYhDNY1d+3Krf++IHic/V1/M73aQw9awmZEtOhMRUsPKSovAyoXCthJNHUwD4fw9A UwHh/JAmdR2xXdkPz5mm2VgDueBSkS8k6BxBnJvF3lfggv174gHYngbrTY2//dqdDNUG MqkoJaBnPUC91ybc5aDEiRQZyTmq8akg7FHWX902y5nI3KKrbhNTEr/fsWDZHKNUoJSm 1YZ2RK6plOBY1nHZUVJ2git9OIiIjklgxsUhfUzStJMB/M5U1G5IpUlNZtLF+iP0jrcW kLxw== X-Gm-Message-State: AFeK/H12UTCXargEQonqt4JNqCayZfzf1wIRYmRWzBRyfoKAnyY0XRwgQMZOONLHg1XO/Wl2 X-Received: by 10.223.157.38 with SMTP id k38mr25302359wre.156.1490043448755; Mon, 20 Mar 2017 13:57:28 -0700 (PDT) Received: from localhost.localdomain (189.17.90.92.rev.sfr.net. [92.90.17.189]) by smtp.gmail.com with ESMTPSA id w99sm9592239wrb.3.2017.03.20.13.57.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 13:57:28 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org Cc: leif.lindholm@linaro.org, mark.rutland@arm.com, matt@codeblueprint.co.uk, rfranz@cavium.com, Ard Biesheuvel Subject: [PATCH] efi/libstub: arm/arm64: make debug prints dependent on efi=debug Date: Mon, 20 Mar 2017 20:57:05 +0000 Message-Id: <1490043425-20118-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org The EFI stub currently prints a number of diagnostic messages that do not carry a lot of information. Since these prints are not controlled by 'loglevel' or other command line parameters, and since they appear on the EFI framebuffer as well (if enabled), it would be nice if we could turn them off. So let's only print them if 'efi=debug' is passed on the command line, or when CONFIG_DEBUG_EFI is set in the kernel build configuration. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/arm32-stub.c | 2 ++ drivers/firmware/efi/libstub/efi-stub-helper.c | 23 ++++++++++++++--------- drivers/firmware/efi/libstub/efistub.h | 9 +++++++++ drivers/firmware/efi/libstub/secureboot.c | 2 ++ include/linux/efi.h | 3 --- 5 files changed, 27 insertions(+), 12 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c index e1f0b28e1dcb..fd07ab3378bd 100644 --- a/drivers/firmware/efi/libstub/arm32-stub.c +++ b/drivers/firmware/efi/libstub/arm32-stub.c @@ -9,6 +9,8 @@ #include #include +#include "efistub.h" + efi_status_t check_platform_features(efi_system_table_t *sys_table_arg) { int block; diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 919822b7773d..1ef299b15458 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -32,6 +32,13 @@ static unsigned long __chunk_size = EFI_READ_CHUNK_SIZE; +static int __debug_enabled = IS_ENABLED(CONFIG_DEBUG_EFI); + +int __pure debug_enabled(void) +{ + return __debug_enabled; +} + #define EFI_MMAP_NR_SLACK_SLOTS 8 struct file_info { @@ -414,14 +421,6 @@ efi_status_t efi_parse_options(char *cmdline) char *str; /* - * Currently, the only efi= option we look for is 'nochunk', which - * is intended to work around known issues on certain x86 UEFI - * versions. So ignore for now on other architectures. - */ - if (!IS_ENABLED(CONFIG_X86)) - return EFI_SUCCESS; - - /* * If no EFI parameters were specified on the cmdline we've got * nothing to do. */ @@ -437,13 +436,19 @@ efi_status_t efi_parse_options(char *cmdline) * skip over arguments we don't understand. */ while (*str) { + if (*str == ' ') + break; + if (!strncmp(str, "nochunk", 7)) { str += strlen("nochunk"); __chunk_size = -1UL; + } else if (!strncmp(str, "debug", 5)) { + str += strlen("debug"); + __debug_enabled = 1; } /* Group words together, delimited by "," */ - while (*str && *str != ',') + while (*str && *str != ',' && *str != ' ') str++; if (*str == ',') diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 71c4d0e3c4ed..5ed16e6e166f 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -24,6 +24,15 @@ #define EFI_ALLOC_ALIGN EFI_PAGE_SIZE #endif +extern int __pure debug_enabled(void); + +#define pr_efi(sys_table, msg) do { \ + if (debug_enabled()) efi_printk(sys_table, "EFI stub: "msg); \ +} while (0) + +#define pr_efi_err(sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg) + + void efi_char16_printk(efi_system_table_t *, efi_char16_t *); efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image, diff --git a/drivers/firmware/efi/libstub/secureboot.c b/drivers/firmware/efi/libstub/secureboot.c index 5da36e56b36a..8c34d50a4d80 100644 --- a/drivers/firmware/efi/libstub/secureboot.c +++ b/drivers/firmware/efi/libstub/secureboot.c @@ -12,6 +12,8 @@ #include #include +#include "efistub.h" + /* BIOS variables */ static const efi_guid_t efi_variable_guid = EFI_GLOBAL_VARIABLE_GUID; static const efi_char16_t const efi_SecureBoot_name[] = { diff --git a/include/linux/efi.h b/include/linux/efi.h index 94d34e0be24f..0a22c8ab5873 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1435,9 +1435,6 @@ static inline int efi_runtime_map_copy(void *buf, size_t bufsz) /* prototypes shared between arch specific and generic stub code */ -#define pr_efi(sys_table, msg) efi_printk(sys_table, "EFI stub: "msg) -#define pr_efi_err(sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg) - void efi_printk(efi_system_table_t *sys_table_arg, char *str); void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,