8 Star 0 Fork 48

src-anolis-os/grub2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0268-TPM-Print-messages-if-measuraments-fail-as-debug-ins.patch 3.62 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2022-04-13 15:15 . update to grub2-2.02-120.el8.src.rpm
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Wed, 16 Oct 2019 15:32:04 +0200
Subject: [PATCH] TPM: Print messages if measuraments fail as debug instead of
error
If the calls to EFI services to do TPM measuraments fail, currently error
messages are printed. But this is not a fatal error and just pollutes the
output, so instead just print them as debug messages.
Resolves: rhbz#1761811
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grub-core/kern/efi/tpm.c | 58 +++++++++++++++++++++++++-----------------------
1 file changed, 30 insertions(+), 28 deletions(-)
diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c
index 0d3ebe22e..5dc908652 100644
--- a/grub-core/kern/efi/tpm.c
+++ b/grub-core/kern/efi/tpm.c
@@ -161,6 +161,34 @@ grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf,
}
}
+static inline grub_err_t grub_tpm_dprintf(grub_efi_status_t status)
+{
+ switch (status) {
+ case GRUB_EFI_SUCCESS:
+ return 0;
+ case GRUB_EFI_DEVICE_ERROR:
+ grub_dprintf ("tpm", "Command failed: 0x%"PRIxGRUB_EFI_STATUS"\n",
+ status);
+ return GRUB_ERR_IO;
+ case GRUB_EFI_INVALID_PARAMETER:
+ grub_dprintf ("tpm", "Invalid parameter: 0x%"PRIxGRUB_EFI_STATUS"\n",
+ status);
+ return GRUB_ERR_BAD_ARGUMENT;
+ case GRUB_EFI_BUFFER_TOO_SMALL:
+ grub_dprintf ("tpm", "Output buffer too small: 0x%"PRIxGRUB_EFI_STATUS"\n",
+ status);
+ return GRUB_ERR_BAD_ARGUMENT;
+ case GRUB_EFI_NOT_FOUND:
+ grub_dprintf ("tpm", "TPM unavailable: 0x%"PRIxGRUB_EFI_STATUS"\n",
+ status);
+ return GRUB_ERR_UNKNOWN_DEVICE;
+ default:
+ grub_dprintf ("tpm", "Unknown TPM error: 0x%"PRIxGRUB_EFI_STATUS"\n",
+ status);
+ return GRUB_ERR_UNKNOWN_DEVICE;
+ }
+}
+
static grub_err_t
grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf,
grub_size_t size, grub_uint8_t pcr,
@@ -194,20 +222,7 @@ grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf,
(unsigned long) buf, (grub_uint64_t) size,
algorithm, event, &eventnum, &lastevent);
- switch (status) {
- case GRUB_EFI_SUCCESS:
- return 0;
- case GRUB_EFI_DEVICE_ERROR:
- return grub_error (GRUB_ERR_IO, N_("Command failed"));
- case GRUB_EFI_INVALID_PARAMETER:
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter"));
- case GRUB_EFI_BUFFER_TOO_SMALL:
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Output buffer too small"));
- case GRUB_EFI_NOT_FOUND:
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable"));
- default:
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error"));
- }
+ return grub_tpm_dprintf(status);
}
static grub_err_t
@@ -240,20 +255,7 @@ grub_tpm2_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf,
status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (unsigned long) buf,
(grub_uint64_t) size, event);
- switch (status) {
- case GRUB_EFI_SUCCESS:
- return 0;
- case GRUB_EFI_DEVICE_ERROR:
- return grub_error (GRUB_ERR_IO, N_("Command failed"));
- case GRUB_EFI_INVALID_PARAMETER:
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter"));
- case GRUB_EFI_BUFFER_TOO_SMALL:
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Output buffer too small"));
- case GRUB_EFI_NOT_FOUND:
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable"));
- default:
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error"));
- }
+ return grub_tpm_dprintf(status);
}
grub_err_t
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/grub2.git
git@gitee.com:src-anolis-os/grub2.git
src-anolis-os
grub2
grub2
a8

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385