From patchwork Fri Mar 22 10:33:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 10865479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71DE915AC for ; Fri, 22 Mar 2019 10:34:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 524DF2A60B for ; Fri, 22 Mar 2019 10:34:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 451F52A65B; Fri, 22 Mar 2019 10:34:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAF2E2A60B for ; Fri, 22 Mar 2019 10:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727754AbfCVKeB (ORCPT ); Fri, 22 Mar 2019 06:34:01 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44085 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727739AbfCVKeB (ORCPT ); Fri, 22 Mar 2019 06:34:01 -0400 Received: by mail-pg1-f195.google.com with SMTP id i2so1223444pgj.11; Fri, 22 Mar 2019 03:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dZhxDdC/Qe4tqiAOQJ+sInBhscxUK5dRSwY91CjQlSQ=; b=ElTP5n1wpgt0y5iAgi21gAuo0spGZDqhq68weaFLRtb/NTJpNuS/SmTJuodnaovfNb s8QfcHzkt0JFGkh3dWrXzyp9fvNSOvsFNBO6AU6KMU4iBwBZzBWvSVKZfdy5rlGa7w7y B+8iLCF5LgWAHKQ1K4RHmOMR+KONTWv9YpQbD94sWrs51PHlZS0PR1MSLxqEIWYUzfFS yk5losiWqVwmIfSEXhE8oh0ZOD2LbyZwSLsu3BteUR15Rcr416lbZYBELexaKKn0Ci1i Q0aKFXMWirJXl2YZp6qXEphFJuwkrWiVuUrFdPidx82fg2q8sUeaY98BvmB0vpb7Un8v OFFQ== 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=dZhxDdC/Qe4tqiAOQJ+sInBhscxUK5dRSwY91CjQlSQ=; b=py4q7EGWJ2ZWWx+ckg1So/9l6rSIL9tE+yaHHIrdpuFJdOU4xaHW6r/5ax2VIPi+hp 34E9XTh0jCTJHhokWMZaJwyOONg0VbAl6VaeITZ+Tz2wbwyFOvI2OYse7umB6qDLgp1c 57aduKqX8qeY6sZCS6uD07FMhA58/an1cPEv5HTyfUjPNdkz4efejxjnoMUfG2z1NcxU 4t5wHn2aJFGczZLS6drl1nGiYjKF/rGwlmWCsmUe2dKHfWyDoCk1J7RQt4q9ex2uS9lm KQFAFBokJNubDhaL6BH2/x9Cw5UazZo8YgHprKipS3+caX37FSrCLqVbrXkj+iEvXdGu mNRw== X-Gm-Message-State: APjAAAVh0ULpej+4RRtZm7S4zcXA2H7mKFDc59eNBOPdtSz2Mo3b9hyX w/+5ztu5iLcjXvnLEjjNYoA= X-Google-Smtp-Source: APXvYqzFJDtBWBT3GBBFqyLcyjpgdZ0DyM2Oh+tkI21b/hNCJ5Z10Wo4bnls5DBP/C+epVuShVOwvw== X-Received: by 2002:aa7:8b93:: with SMTP id r19mr8223640pfd.163.1553250840143; Fri, 22 Mar 2019 03:34:00 -0700 (PDT) Received: from linux-l9pv.suse ([202.47.205.198]) by smtp.gmail.com with ESMTPSA id l7sm22276889pfj.162.2019.03.22.03.33.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Mar 2019 03:33:59 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: Ard Biesheuvel , James Morris , "Serge E . Hallyn" , David Howells , Josh Boyer , Nayna Jain , Mimi Zohar Cc: linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, "Lee, Chun-Yi" , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck Subject: [PATCH 1/2] efi: add a function for transferring status to string Date: Fri, 22 Mar 2019 18:33:49 +0800 Message-Id: <20190322103350.27764-1-jlee@suse.com> X-Mailer: git-send-email 2.12.3 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This function can be used to transfer EFI status code to string for printing out debug message. Using this function can improve the readability of log. Cc: Ard Biesheuvel Cc: Kees Cook Cc: Anton Vorontsov Cc: Colin Cross Cc: Tony Luck Signed-off-by: "Lee, Chun-Yi" --- include/linux/efi.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/linux/efi.h b/include/linux/efi.h index 54357a258b35..a43cb0dc37af 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1768,4 +1768,32 @@ struct linux_efi_memreserve { #define EFI_MEMRESERVE_COUNT(size) (((size) - sizeof(struct linux_efi_memreserve)) \ / sizeof(((struct linux_efi_memreserve *)0)->entry[0])) +#define EFI_STATUS_STR(_status) \ +case EFI_##_status: \ + return "EFI_" __stringify(_status); + +static inline char * +efi_status_to_str(efi_status_t status) +{ + switch (status) { + EFI_STATUS_STR(SUCCESS) + EFI_STATUS_STR(LOAD_ERROR) + EFI_STATUS_STR(INVALID_PARAMETER) + EFI_STATUS_STR(UNSUPPORTED) + EFI_STATUS_STR(BAD_BUFFER_SIZE) + EFI_STATUS_STR(BUFFER_TOO_SMALL) + EFI_STATUS_STR(NOT_READY) + EFI_STATUS_STR(DEVICE_ERROR) + EFI_STATUS_STR(WRITE_PROTECTED) + EFI_STATUS_STR(OUT_OF_RESOURCES) + EFI_STATUS_STR(NOT_FOUND) + EFI_STATUS_STR(ABORTED) + EFI_STATUS_STR(SECURITY_VIOLATION) + default: + pr_warn("Unknown efi status: 0x%lx", status); + } + + return "Unknown efi status"; +} + #endif /* _LINUX_EFI_H */