Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1946127img; Sat, 23 Mar 2019 17:28:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvtYiSIib2FHKrgJxHoAtOX9Z8eT5JogdbZPIniFZI36Hc7syUacC8tQ5RvWElaW5AKVnM X-Received: by 2002:aa7:818a:: with SMTP id g10mr16631877pfi.178.1553387331662; Sat, 23 Mar 2019 17:28:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553387331; cv=none; d=google.com; s=arc-20160816; b=pY/R+Cbvl3ortjucYmlkI2+QiGKVuLbTvM4a6YPxJcmVCUMWAv1vojcRaN2rKdF5Ip Zx/RUX/i5sX7Id1GQKoia+YFRhYSBrr1+BbRzmn2WK31p2WRdqMzzVZcGlr7efFerZ+p NyjMTbEbUBDJllZ5A/Z4QUmr0yr+qqa6bpez3grfJuBzg6h2rCECwh0EavLgjAGLb6GF 1c0UTNn7F28Npk91dTFWswREYIDQM1VgMTOhJkxl1wSiGuPetMuxRxjDUBuEOVDc+2Vs s1hPT07FxdARStnyV3higPTrEyLucvXQWPsuoZFTQlN1HRVc8WApRGjme9cQgwaLEMwY Mvxg== 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=CbUSEHqcoUkDGqUdp2rOVluubXrcpUo4iCJTOliClM1FUZFc+88W88jnhOxOPlLvhK pUPlWzTCDmRlD0SmBPju8t/9LcKHPJdtyfZ39+V1d8kJgPTM4eifWIwVNJv8DZoXcSZn GXPsJhh+RjNeR1dVjHnjF0dVsE/wWIXCJ3YWvKCVm1ASkANYAvrjFNz5rFYEV2e62icK A/1RyjkCAmQdkWw8MlOzGujf+AlWuo5mTP3sjryZAZnXR4onvCAXVV/kP+zxKD7gMWSe +Y4EwSouLwMmS1rBngTve31Jzc/mC71zV2Mw90G2LqtpunbHYvbClyyymh+WdkztXgUN fDOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Spyy5rGW; 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 c19si2514856pfi.230.2019.03.23.17.28.11; Sat, 23 Mar 2019 17:28:51 -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=Spyy5rGW; 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 S1727954AbfCXA0o (ORCPT + 99 others); Sat, 23 Mar 2019 20:26:44 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41393 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727319AbfCXA0o (ORCPT ); Sat, 23 Mar 2019 20:26:44 -0400 Received: by mail-pg1-f195.google.com with SMTP id k11so3948990pgb.8; Sat, 23 Mar 2019 17:26:43 -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=Spyy5rGW+mybuiFbAZSI3utxWF/QbLOVK0U/rl6IYo3mkRjCowmXiJYqJCUnab4Uns 8AKSCgHNnuiS0A01agvJmQYCKtX+QdlgjGCWkJVdsXd7xBS1P1hYqqv3abm7HzUyl8EZ RDu3lYmVAbYBAwcuumFxOoQqnDZ+CB9wm+gp3LVubEggi85oMaDPd3hfA9Lu5E+7ar59 5sqCofMA2/V4+OztSXTkTpjBoP3ff1LDFYBjLkHesDLdabNveX03sOnMlVQPo22JcNCI /lqVJvuID0K5KpKAN0S0ECW/qbi2O/QuQjoseBPVwm3UGOTsPHwz8tWLIDytBKGBfE8T Fn3A== 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=OTleZJ32DDVGcU39itjsIgB8YRvo9Twhnt/G2U1kx1hBgcQBHGMnL8kJ3SuCUKqmxf 4uy2rWTlhB63Ji6O46UhE1wiArnrL6uFA/f/m6Nw7z1lUK7f/lJs86nsG2J1ZrYt6Nmj IjuSRilMl8KkX1cmtEueP30Ew+16Vpxyjxi58BuFc7Xzo4qJHlZaRBMmHnL7Vn+avSo2 rHpIlatWwvQnd8F31+nCLRn7wPEkKfCVhyD1Ct6WuG60DZ+H1qGaThixJmGuTWZ6HGCL Pe1p1NIlxtXn/BWzjkMN2X/vSNhs6+75nvrOgYp03iHpscCw1vLyX3uRwrf7OS/xcFpd q3pA== X-Gm-Message-State: APjAAAUPdx2R0hyEcvC1mIl2/ubWxTHHF/FxCpomrfKcyEiPIPw3oXZG njFlDeTkXQT9IY5nI07svBM= X-Received: by 2002:a17:902:8ecc:: with SMTP id x12mr5278077plo.0.1553387202877; Sat, 23 Mar 2019 17:26:42 -0700 (PDT) Received: from linux-l9pv.suse ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id r66sm13737687pfr.131.2019.03.23.17.26.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 23 Mar 2019 17:26:41 -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: Sun, 24 Mar 2019 08:26:20 +0800 Message-Id: <20190324002621.3551-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