Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp541993img; Fri, 22 Mar 2019 03:34:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqymfSiz/ye4GkFQfaoLUNWDouEJODYUxTvFK+32qG6PEmiG/6+U4wVadRMQ9HB0qHkPxx3n X-Received: by 2002:aa7:8156:: with SMTP id d22mr8555461pfn.230.1553250899032; Fri, 22 Mar 2019 03:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553250899; cv=none; d=google.com; s=arc-20160816; b=0x8vtMfEgAIQv6Rvxt4ZvvjMQ8EKn+X3NAwevo0zFRuHvaW1u9b4Utz7A0LZgpqte5 mUQvNkUTRKBGm3jLXOtijHCGXE74AjVNN6Fj89fUcht4mlUJ9BjTsNviatL13Ke64Oh2 o2Uv4HWBSZYStAh1Fdwo1lu6NfMkSLB4ITD00BrSBDaSKitd0ctC2c3AsxvCjc2xJAyb UaWfVgmf3rWV1zG0cXaytaWl45kzvzgdrUC+S/OvdEdxRoyw84tBOBWtj+6RcXZTbKHE Gt8yu8l0Z+kq9mpynjCadvwErCRzyDkvWvvQxei6XV9QVUBz3WLowq5sLewOM6VHAxhE VQQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=dZhxDdC/Qe4tqiAOQJ+sInBhscxUK5dRSwY91CjQlSQ=; b=pspb5c//dUe3oj85u8kFbT0wiGe9fNz5suaUcRig3J+RJhsSF/5MywlAQqjbJrDL8K bj353ITvUHm1bgM0B1EQvn+xJUnoSV43ikqIJSvDe0p4ynODxUhcQaJEQiy5vSWNBAWM JY3pknVOSEax4cuiaZCiy2puoVk8q2VujlylGadVb2bT5cEaWfdn9d/EOZNHjJYsYWfZ 83xu58Tpvzl7XPPlZpHWAMtEd0WIjx6Melhqp3XXH3/UqvlA0UYP8HABSNLdrACxntil gpnJkIAUYunyQHyr+ao1c6deGTjWcc87Wyy/o2rCi1wH06QtOwlbsRwjPPuyL7fQIfFl k/gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ElTP5n1w; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15si4738266pgm.1.2019.03.22.03.34.43; Fri, 22 Mar 2019 03:34:59 -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=@gmail.com header.s=20161025 header.b=ElTP5n1w; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727969AbfCVKeB (ORCPT + 99 others); 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-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.16.4