From 6f0c8d2c920c82359f231205b26eb4ddd3718e1d Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 5 Sep 2023 16:25:05 -0400 Subject: Print errors when setting/clearing memory attrs When working on issues with the memory attributes API, shim does not currently display any errors which are returned from the API itself. This adds those error messages. Resolves #575 Signed-off-by: Peter Jones --- pe.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pe.c b/pe.c index b3a9d46f..33056017 100644 --- a/pe.c +++ b/pe.c @@ -498,10 +498,20 @@ update_mem_attrs(uintptr_t addr, uint64_t size, uefi_clear_attrs = shim_mem_attrs_to_uefi_mem_attrs (clear_attrs); dprint("translating clear_attrs from 0x%lx to 0x%lx\n", clear_attrs, uefi_clear_attrs); efi_status = EFI_SUCCESS; - if (uefi_set_attrs) + if (uefi_set_attrs) { efi_status = proto->SetMemoryAttributes(proto, physaddr, size, uefi_set_attrs); - if (!EFI_ERROR(efi_status) && uefi_clear_attrs) + if (EFI_ERROR(efi_status)) { + dprint(L"Failed to set memory attrs:0x%0x physaddr:0x%llx size:0x%0lx status:%r\n", + uefi_set_attrs, physaddr, size, efi_status); + } + } + if (!EFI_ERROR(efi_status) && uefi_clear_attrs) { efi_status = proto->ClearMemoryAttributes(proto, physaddr, size, uefi_clear_attrs); + if (EFI_ERROR(efi_status)) { + dprint(L"Failed to clear memory attrs:0x%0x physaddr:0x%llx size:0x%0lx status:%r\n", + uefi_clear_attrs, physaddr, size, efi_status); + } + } ret = efi_status; efi_status = get_mem_attrs (addr, size, &after); -- cgit v1.2.3