Skip to content

Commit c14b586

Browse files
committed
slaunch: txt: improve error output
* Add missing newlines. * Use grub_dprintf() to provide more context, each next grub_error() discards the message of the previous one unless error stack is pushed. Signed-off-by: Sergii Dmytruk <[email protected]>
1 parent e3e9d85 commit c14b586

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

grub-core/loader/slaunch/x86_efi_linux.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ sl_efi_load_mle_data (struct grub_slaunch_params *slparams,
112112
sizeof (struct linux_kernel_info));
113113

114114
if (OFFSET_OF (mle_header_offset, &kernel_info) >= grub_le_to_cpu32 (kernel_info.size))
115-
return grub_error (GRUB_ERR_BAD_OS, N_("not an slaunch kernel: lack of mle_header_offset"));
115+
{
116+
grub_dprintf ("slaunch", "not an slaunch kernel: lack of mle_header_offset\n");
117+
return GRUB_ERR_BAD_OS;
118+
}
116119

117120
mle_hdr_offset = grub_le_to_cpu32 (kernel_info.mle_header_offset);
118121
mle_hdr = (struct grub_txt_mle_header *)((grub_addr_t)kernel_addr + slparams->mle_header_offset);
@@ -128,19 +131,23 @@ sl_efi_load_mle_data (struct grub_slaunch_params *slparams,
128131

129132
if (mle_hdr_offset >= 0x1000)
130133
{
131-
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("not an slaunch kernel: no MLE header found"));
134+
grub_dprintf ("slaunch", "not an slaunch kernel: no MLE header found\n");
135+
return GRUB_ERR_BAD_ARGUMENT;
132136
}
133137

134138
mle_hdr_offset = foffset_to_voffset (loaded_image, mle_hdr_offset);
135139
if (mle_hdr_offset >= (1ULL << 32))
136-
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("failed to map MLE header"));
140+
{
141+
grub_dprintf ("slaunch", "failed to map MLE header\n");
142+
return GRUB_ERR_BAD_ARGUMENT;
143+
}
137144
}
138145

139146
if (grub_memcmp (mle_hdr->uuid, GRUB_TXT_MLE_UUID, 16) != 0)
140147
{
141148
grub_dprintf ("slaunch", "Not an MLE header at %llu\n",
142149
(unsigned long long)((grub_addr_t)kernel_addr + mle_hdr_offset));
143-
return grub_error (GRUB_ERR_BAD_OS, N_("failed to locate MLE header"));
150+
return GRUB_ERR_BAD_OS;
144151
}
145152

146153
slparams->mle_header_offset = mle_hdr_offset;
@@ -335,22 +342,22 @@ grub_sl_efi_txt_setup (struct grub_slaunch_params *slparams, void *kernel_addr,
335342
err = sl_efi_load_mle_data (slparams, kernel_addr, start, loaded_image, is_linux);
336343
if (err != GRUB_ERR_NONE)
337344
{
338-
grub_dprintf ("slaunch", N_("failed to load MLE data"));
345+
grub_dprintf ("slaunch", N_("failed to load MLE data\n"));
339346
goto fail;
340347
}
341348

342349
/* Final stage for secure launch, setup TXT and install the SLR table */
343350
err = grub_txt_boot_prepare (slparams);
344351
if (err != GRUB_ERR_NONE)
345352
{
346-
grub_dprintf ("slaunch", N_("failed to prepare TXT"));
353+
grub_dprintf ("slaunch", N_("failed to prepare TXT\n"));
347354
goto fail;
348355
}
349356

350357
err = sl_efi_install_slr_table (slparams);
351358
if (err != GRUB_ERR_NONE)
352359
{
353-
grub_dprintf ("slaunch", N_("failed to register SLRT with UEFI"));
360+
grub_dprintf ("slaunch", N_("failed to register SLRT with UEFI\n"));
354361
goto fail;
355362
}
356363

@@ -414,7 +421,10 @@ grub_sl_efi_skinit_setup (struct grub_slaunch_params *slparams, void *kernel_add
414421

415422
err = sl_efi_load_mle_data (slparams, kernel_addr, start, loaded_image, is_linux);
416423
if (err != GRUB_ERR_NONE)
417-
goto fail;
424+
{
425+
grub_dprintf ("slaunch", N_("failed to load MLE data\n"));
426+
goto fail;
427+
}
418428

419429
/*
420430
* AMD SKL final setup may relocate the SKL module. It is also what sets the SLRT and DCE

0 commit comments

Comments
 (0)