[PATCH 1/1] configure.ac: Fix SDL2 typo by referencing value

2023-07-18 Thread Michał Grzelak
During configuration of SDL2, variable enable_grub_emu_sdl2 is checked
whether to throw an error message. Howerever, error could not happen
because two unequal strings were compared. Fix this by referencing
value of enable_grub_emu_sdl2, not name.

Fixes: 17d6ac1a7 (emu: Add SDL2 support)

Signed-off-by: Michał Grzelak 
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 01500ffdf..27c5918fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1609,7 +1609,7 @@ if test "$platform" = emu; then
 AC_SUBST(HAVE_SDL2)],
 [grub_emu_sdl2_excuse="libSDL2 libraries are required to build 
\`grub-emu' with SDL2 support"])
   [fi]
-  if test x"enable_grub_emu_sdl2" = xyes && test x"$grub_emu_sdl2_excuse" != x 
; then
+  if test x"$enable_grub_emu_sdl2" = xyes && test x"$grub_emu_sdl2_excuse" != 
x ; then
 AC_MSG_ERROR([SDL2 support for grub-emu was explicitly requested but can't 
be compiled ($grub_emu_sdl2_excuse)])
   fi
   if test x"$grub_emu_sdl2_excuse" = x ; then
-- 
2.37.3


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH 0/1] configure.ac: Fix SDL2 typo by referencing value

2023-07-18 Thread Michał Grzelak
Hi all,

Today I have found out that my previous commit b9b9705fb (configure.ac:
Fix typo by adding missing $) was incomplete, and I missed that the same
typo occurs when configuring SDL2 with variable enable_grub_emu_sdl2.
Since previous patch has already been upstreamed and thus those two
patches cannot be squashed, this patch fixes the issue with SDL2.

Best regards,
Michał

Michał Grzelak (1):
  configure.ac: Fix SDL2 typo by referencing value

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.37.3


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] configure.ac: Fix typo by adding missing $

2023-06-29 Thread Michał Grzelak
During configuration of sdl, variable enable_grub_emu_sdl is checked
whether to throw an error message. Howerever, error could not happen
because two unequal strings were compared. Fix this by referencing
value of enable_grub_emu_sdl, not name.

Signed-off-by: Michał Grzelak 
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 9d7854d35..278e5a81f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1638,7 +1638,7 @@ AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
   [grub_emu_sdl_excuse=["libSDL header file is required to build 
\`grub-emu' with SDL support"]])
   [fi]
 
-  if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; 
then
+  if test x"$enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x 
; then
 AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't 
be compiled ($grub_emu_sdl_excuse)])
   fi
   if test x"$grub_emu_sdl_excuse" = x ; then
-- 
2.37.3


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH v2 0/1] tpm: Enable boot despite unknown firmware failure

2023-06-15 Thread Michał Grzelak
Hi all,

This patch fixes small problem with my computer being unbootable under
certain circumstances. It also addresses concerns pointed out by Daniel
with previous version. If there are any, I would appreciate further
comments.

Best regards,
Michał

---
Changelog:
v1->v2:
- change grub_tpm_is_fail_fatal() back to tpm_is_fail_fatal()
- make is_tpm_fail_fatal() static
- move is_tpm_fail_fatal() body to include/grub/tpm.h
- update docs excerpt about tpm_fail_fatal  

Michał Grzelak (1):
  tpm: Enable boot despite unknown firmware failure

 docs/grub.texi   | 5 +
 grub-core/commands/efi/tpm.c | 3 ++-
 grub-core/commands/tpm.c | 7 ---
 include/grub/tpm.h   | 9 +
 4 files changed, 16 insertions(+), 8 deletions(-)

-- 
2.37.3


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH v2 1/1] tpm: Enable boot despite unknown firmware failure

2023-06-15 Thread Michał Grzelak
Currently booting the system is prevented when call to EFI firmware
hash_log_extend_event() returns unknown error. Solve this by following
convention used in commit a4356538d (commands/tpm: Don't propagate
measurement failures to the verifiers layer).

Let the system to be bootable by default when unknown TPM error is
encountered. Check environment variable tpm_fail_fatal to fallback to
previous behaviour.

Signed-off-by: Michał Grzelak 
---
 docs/grub.texi   | 5 +
 grub-core/commands/efi/tpm.c | 3 ++-
 grub-core/commands/tpm.c | 7 ---
 include/grub/tpm.h   | 9 +
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/docs/grub.texi b/docs/grub.texi
index 9b58886a9..fc4e08f2c 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -3841,6 +3841,11 @@ If this variable is set and true (i.e., not set to 
``0'', ``false'',
 fatal. Otherwise, they will merely be debug-logged and boot will
 continue.
 
+Call to EFI firmware, like hash_log_extend_event(), can return an unknown
+error, i.e. due to bug present in firmware. When this variable is set and
+true (same values as with TPM measurements) this situation will be considered
+to be fatal and error-logged as ``unknown TPM error''. If not set, booting
+the OS will be enabled.
 
 @node Environment block
 @section The GRUB environment block
diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
index c616768f9..508ae8b3a 100644
--- a/grub-core/commands/efi/tpm.c
+++ b/grub-core/commands/efi/tpm.c
@@ -146,7 +146,8 @@ grub_efi_log_event_status (grub_efi_status_t status)
 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_error (is_tpm_fail_fatal () ? GRUB_ERR_UNKNOWN_DEVICE
+ : GRUB_ERR_NONE, N_("unknown TPM error"));
 }
 }
 
diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c
index 9f830916d..c7e599170 100644
--- a/grub-core/commands/tpm.c
+++ b/grub-core/commands/tpm.c
@@ -18,7 +18,6 @@
  *  Core TPM support code.
  */
 
-#include 
 #include 
 #include 
 #include 
@@ -40,12 +39,6 @@ grub_tpm_verify_init (grub_file_t io,
   return GRUB_ERR_NONE;
 }
 
-static inline bool
-is_tpm_fail_fatal (void)
-{
-  return grub_env_get_bool ("tpm_fail_fatal", false);
-}
-
 static grub_err_t
 grub_tpm_verify_write (void *context, void *buf, grub_size_t size)
 {
diff --git a/include/grub/tpm.h b/include/grub/tpm.h
index c19fcbd0a..11238da18 100644
--- a/include/grub/tpm.h
+++ b/include/grub/tpm.h
@@ -19,6 +19,8 @@
 #ifndef GRUB_TPM_HEADER
 #define GRUB_TPM_HEADER 1
 
+#include 
+
 #define GRUB_STRING_PCR 8
 #define GRUB_BINARY_PCR 9
 
@@ -37,4 +39,11 @@
 grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size,
 grub_uint8_t pcr, const char *description);
 int grub_tpm_present (void);
+
+static inline bool
+is_tpm_fail_fatal (void)
+{
+  return grub_env_get_bool ("tpm_fail_fatal", false);
+}
+
 #endif
-- 
2.37.3


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] tpm: Enable boot despite unknown firmware failure

2023-06-14 Thread Michał Grzelak
Currently booting the system is prevented when call to EFI firmware
hash_log_extend_event() returns unknown error. Solve this by following
convention used in commit a4356538d (commands/tpm: Don't propagate
measurement failures to the verifiers layer).

Let the system to be bootable by default when unknown TPM error is
encountered. Make grub_tpm_is_fail_fatal() global and move its body to
efi/tpm.c. Check environment variable tpm_fail_fatal to fallback to
previous behaviour.

Signed-off-by: Michał Grzelak 
---
 grub-core/commands/efi/tpm.c | 10 +-
 grub-core/commands/tpm.c | 11 ++-
 include/grub/tpm.h   |  1 +
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
index c616768f9..05f3064f7 100644
--- a/grub-core/commands/efi/tpm.c
+++ b/grub-core/commands/efi/tpm.c
@@ -18,6 +18,7 @@
  *  EFI TPM support code.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -146,7 +147,8 @@ grub_efi_log_event_status (grub_efi_status_t status)
 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_error (grub_tpm_is_fail_fatal () ? GRUB_ERR_UNKNOWN_DEVICE
+ : GRUB_ERR_NONE, N_("unknown TPM error"));
 }
 }
 
@@ -266,6 +268,12 @@ grub_cc_log_event (unsigned char *buf, grub_size_t size, 
grub_uint8_t pcr,
 grub_efi_log_event_status (status);
 }
 
+bool
+grub_tpm_is_fail_fatal (void)
+{
+  return grub_env_get_bool ("tpm_fail_fatal", false);
+}
+
 grub_err_t
 grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr,
const char *description)
diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c
index 9f830916d..f86bdc81e 100644
--- a/grub-core/commands/tpm.c
+++ b/grub-core/commands/tpm.c
@@ -18,7 +18,6 @@
  *  Core TPM support code.
  */
 
-#include 
 #include 
 #include 
 #include 
@@ -40,12 +39,6 @@ grub_tpm_verify_init (grub_file_t io,
   return GRUB_ERR_NONE;
 }
 
-static inline bool
-is_tpm_fail_fatal (void)
-{
-  return grub_env_get_bool ("tpm_fail_fatal", false);
-}
-
 static grub_err_t
 grub_tpm_verify_write (void *context, void *buf, grub_size_t size)
 {
@@ -55,7 +48,7 @@ grub_tpm_verify_write (void *context, void *buf, grub_size_t 
size)
 return GRUB_ERR_NONE;
 
   grub_dprintf ("tpm", "Measuring buffer failed: %d\n", status);
-  return is_tpm_fail_fatal () ? status : GRUB_ERR_NONE;
+  return grub_tpm_is_fail_fatal () ? status : GRUB_ERR_NONE;
 }
 
 static grub_err_t
@@ -91,7 +84,7 @@ grub_tpm_verify_string (char *str, enum 
grub_verify_string_type type)
 return GRUB_ERR_NONE;
 
   grub_dprintf ("tpm", "Measuring string %s failed: %d\n", str, status);
-  return is_tpm_fail_fatal () ? status : GRUB_ERR_NONE;
+  return grub_tpm_is_fail_fatal () ? status : GRUB_ERR_NONE;
 }
 
 struct grub_file_verifier grub_tpm_verifier = {
diff --git a/include/grub/tpm.h b/include/grub/tpm.h
index c19fcbd0a..aea145dd1 100644
--- a/include/grub/tpm.h
+++ b/include/grub/tpm.h
@@ -36,5 +36,6 @@
 
 grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size,
 grub_uint8_t pcr, const char *description);
+bool grub_tpm_is_fail_fatal (void);
 int grub_tpm_present (void);
 #endif
-- 
2.37.3


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel