linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/2] EFI touchups for v5.7
@ 2020-03-29  8:05 Ard Biesheuvel
  2020-03-29  8:05 ` [PATCH 1/2] efi/libstub/arm64: avoid image_base value from efi_loaded_image Ard Biesheuvel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2020-03-29  8:05 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner; +Cc: linux-arm-kernel, Ard Biesheuvel

Hello Ingo, Thomas,

Please pull the below into tip:efi/core - it is a pair of fixes for the
code that has been queued up for v5.7

Thanks,
Ard.


The following changes since commit d5528d5e91041e68e8eab9792ce627705a0ed273:

  partitions/efi: Fix partition name parsing in GUID partition entry (2020-03-08 10:00:09 +0100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git efi-next

for you to fetch changes up to c6987a415f71352fe1483b09d8b0027ccf3b2175:

  efi/libstub/arm: fix spurious message that an initrd was loaded (2020-03-29 09:48:42 +0200)

----------------------------------------------------------------
Some EFI followup fixes for v5.7:
- fix arm64 boot regression on broken, older versions of GRUB
- suppress spurious 'initrd loaded from command line' print

----------------------------------------------------------------
Ard Biesheuvel (2):
      efi/libstub/arm64: avoid image_base value from efi_loaded_image
      efi/libstub/arm: fix spurious message that an initrd was loaded

 drivers/firmware/efi/libstub/arm-stub.c   | 2 +-
 drivers/firmware/efi/libstub/arm64-stub.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] efi/libstub/arm64: avoid image_base value from efi_loaded_image
  2020-03-29  8:05 [GIT PULL 0/2] EFI touchups for v5.7 Ard Biesheuvel
@ 2020-03-29  8:05 ` Ard Biesheuvel
  2020-03-29  8:05 ` [PATCH 2/2] efi/libstub/arm: fix spurious message that an initrd was loaded Ard Biesheuvel
  2020-03-29 10:08 ` [GIT PULL 0/2] EFI touchups for v5.7 Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2020-03-29  8:05 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner; +Cc: linux-arm-kernel, Ard Biesheuvel

Commit 9f9223778ef3 ("efi/libstub/arm: Make efi_entry() an ordinary
PE/COFF entrypoint") did some code refactoring to get rid of the
EFI entry point assembler code, and in the process, it got rid of the
assignment of image_addr to the value of _text. Instead, it switched
to using the image_base field of the efi_loaded_image struct provided
by UEFI, which should contain the same value.

However, Michael reports that this is not the case: older GRUB builds
corrupt this value in some way, and since we can easily switch back to
referring to _text to discover this value, let's simply do that.

While at it, fix another issue in commit 9f9223778ef3, which may result
in the unassigned image_addr to be misidentified as the preferred load
offset of the kernel, which is unlikely but will cause a boot crash if
it does occur.

Finally, let's add a warning if the _text vs. image_base discrepancy is
detected, so we can tell more easily how widespread this issue actually
is.

Reported-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/libstub/arm64-stub.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c
index 9254cd8ab2d3..db0c1a9c1699 100644
--- a/drivers/firmware/efi/libstub/arm64-stub.c
+++ b/drivers/firmware/efi/libstub/arm64-stub.c
@@ -116,6 +116,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
 		 * Mustang), we can still place the kernel at the address
 		 * 'dram_base + TEXT_OFFSET'.
 		 */
+		*image_addr = (unsigned long)_text;
 		if (*image_addr == preferred_offset)
 			return EFI_SUCCESS;
 
@@ -140,7 +141,11 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
 		}
 		*image_addr = *reserve_addr + TEXT_OFFSET;
 	}
-	memcpy((void *)*image_addr, image->image_base, kernel_size);
+
+	if (image->image_base != _text)
+		pr_efi_err("FIRMWARE BUG: efi_loaded_image_t::image_base has bogus value\n");
+
+	memcpy((void *)*image_addr, _text, kernel_size);
 
 	return EFI_SUCCESS;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] efi/libstub/arm: fix spurious message that an initrd was loaded
  2020-03-29  8:05 [GIT PULL 0/2] EFI touchups for v5.7 Ard Biesheuvel
  2020-03-29  8:05 ` [PATCH 1/2] efi/libstub/arm64: avoid image_base value from efi_loaded_image Ard Biesheuvel
@ 2020-03-29  8:05 ` Ard Biesheuvel
  2020-03-29 10:08 ` [GIT PULL 0/2] EFI touchups for v5.7 Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2020-03-29  8:05 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner; +Cc: linux-arm-kernel, Ard Biesheuvel

Commit ec93fc371f014a6f ("efi/libstub: Add support for loading the initrd
from a device path") added a diagnostic print to the ARM version of the
EFI stub that reports whether an initrd has been loaded that was passed
via the command line using initrd=. However, it failed to take into
account that, for historical reasons, the file loading routines return
EFI_SUCCESS when no file was found, and the only way to decide whether
a file was loaded is to inspect the 'size' argument that is passed by
reference. So let's inspect this returned size, to prevent the print
from being emitted even if no initrd was loaded at all.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/libstub/arm-stub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 13559c7e6643..99a5cde7c2d8 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -277,7 +277,7 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg)
 		} else if (status == EFI_NOT_FOUND) {
 			status = efi_load_initrd(image, &initrd_addr, &initrd_size,
 						 ULONG_MAX, max_addr);
-			if (status == EFI_SUCCESS)
+			if (status == EFI_SUCCESS && initrd_size > 0)
 				pr_efi("Loaded initrd from command line option\n");
 		}
 		if (status != EFI_SUCCESS)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [GIT PULL 0/2] EFI touchups for v5.7
  2020-03-29  8:05 [GIT PULL 0/2] EFI touchups for v5.7 Ard Biesheuvel
  2020-03-29  8:05 ` [PATCH 1/2] efi/libstub/arm64: avoid image_base value from efi_loaded_image Ard Biesheuvel
  2020-03-29  8:05 ` [PATCH 2/2] efi/libstub/arm: fix spurious message that an initrd was loaded Ard Biesheuvel
@ 2020-03-29 10:08 ` Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2020-03-29 10:08 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-efi, Thomas Gleixner, linux-arm-kernel, Borislav Petkov


* Ard Biesheuvel <ardb@kernel.org> wrote:

> Hello Ingo, Thomas,
> 
> Please pull the below into tip:efi/core - it is a pair of fixes for the
> code that has been queued up for v5.7
> 
> Thanks,
> Ard.

Applied to tip:efi/core, thanks Ard!

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-03-29 10:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-29  8:05 [GIT PULL 0/2] EFI touchups for v5.7 Ard Biesheuvel
2020-03-29  8:05 ` [PATCH 1/2] efi/libstub/arm64: avoid image_base value from efi_loaded_image Ard Biesheuvel
2020-03-29  8:05 ` [PATCH 2/2] efi/libstub/arm: fix spurious message that an initrd was loaded Ard Biesheuvel
2020-03-29 10:08 ` [GIT PULL 0/2] EFI touchups for v5.7 Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).