From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: Ard Biesheuvel <ardb@kernel.org>,
linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Arvind Sankar <nivedita@alum.mit.edu>,
Guenter Roeck <linux@roeck-us.net>, Joe Perches <joe@perches.com>
Subject: [PATCH 02/15] efi/libstub: Add a helper function to split 64-bit values
Date: Fri, 8 May 2020 20:01:44 +0200 [thread overview]
Message-ID: <20200508180157.1816-3-ardb@kernel.org> (raw)
In-Reply-To: <20200508180157.1816-1-ardb@kernel.org>
From: Arvind Sankar <nivedita@alum.mit.edu>
In several places 64-bit values need to be split up into two 32-bit
fields, in order to be backward-compatible with the old 32-bit ABIs.
Instead of open-coding this, add a helper function to set a 64-bit value
as two 32-bit fields.
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Link: https://lore.kernel.org/r/20200430182843.2510180-3-nivedita@alum.mit.edu
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
drivers/firmware/efi/libstub/efistub.h | 7 ++++++
drivers/firmware/efi/libstub/gop.c | 6 ++---
drivers/firmware/efi/libstub/x86-stub.c | 32 +++++++++++--------------
3 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 5ff63230a1f1..e8aa70ba08d5 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -87,6 +87,13 @@ extern const efi_system_table_t *efi_system_table;
((handle = efi_get_handle_at((array), i)) || true); \
i++)
+static inline
+void efi_set_u64_split(u64 data, u32 *lo, u32 *hi)
+{
+ *lo = lower_32_bits(data);
+ *hi = upper_32_bits(data);
+}
+
/*
* Allocation types for calls to boottime->allocate_pages.
*/
diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c
index 216327d0b034..64cee0febae0 100644
--- a/drivers/firmware/efi/libstub/gop.c
+++ b/drivers/firmware/efi/libstub/gop.c
@@ -422,7 +422,6 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
efi_graphics_output_protocol_t *gop;
efi_graphics_output_protocol_mode_t *mode;
efi_graphics_output_mode_info_t *info;
- efi_physical_addr_t fb_base;
gop = find_gop(proto, size, handles);
@@ -442,9 +441,8 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
si->lfb_width = info->horizontal_resolution;
si->lfb_height = info->vertical_resolution;
- fb_base = efi_table_attr(mode, frame_buffer_base);
- si->lfb_base = lower_32_bits(fb_base);
- si->ext_lfb_base = upper_32_bits(fb_base);
+ efi_set_u64_split(efi_table_attr(mode, frame_buffer_base),
+ &si->lfb_base, &si->ext_lfb_base);
if (si->ext_lfb_base)
si->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index d4bafd7f6f9f..f91d4aab0156 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -408,9 +408,8 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
if (!cmdline_ptr)
goto fail;
- hdr->cmd_line_ptr = (unsigned long)cmdline_ptr;
- /* Fill in upper bits of command line address, NOP on 32 bit */
- boot_params->ext_cmd_line_ptr = (u64)(unsigned long)cmdline_ptr >> 32;
+ efi_set_u64_split((unsigned long)cmdline_ptr,
+ &hdr->cmd_line_ptr, &boot_params->ext_cmd_line_ptr);
hdr->ramdisk_image = 0;
hdr->ramdisk_size = 0;
@@ -427,10 +426,10 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
ULONG_MAX);
if (status != EFI_SUCCESS)
goto fail2;
- hdr->ramdisk_image = ramdisk_addr & 0xffffffff;
- hdr->ramdisk_size = ramdisk_size & 0xffffffff;
- boot_params->ext_ramdisk_image = (u64)ramdisk_addr >> 32;
- boot_params->ext_ramdisk_size = (u64)ramdisk_size >> 32;
+ efi_set_u64_split(ramdisk_addr, &hdr->ramdisk_image,
+ &boot_params->ext_ramdisk_image);
+ efi_set_u64_split(ramdisk_size, &hdr->ramdisk_size,
+ &boot_params->ext_ramdisk_size);
}
}
@@ -639,17 +638,14 @@ static efi_status_t exit_boot_func(struct efi_boot_memmap *map,
: EFI32_LOADER_SIGNATURE;
memcpy(&p->efi->efi_loader_signature, signature, sizeof(__u32));
- p->efi->efi_systab = (unsigned long)efi_system_table;
+ efi_set_u64_split((unsigned long)efi_system_table,
+ &p->efi->efi_systab, &p->efi->efi_systab_hi);
p->efi->efi_memdesc_size = *map->desc_size;
p->efi->efi_memdesc_version = *map->desc_ver;
- p->efi->efi_memmap = (unsigned long)*map->map;
+ efi_set_u64_split((unsigned long)*map->map,
+ &p->efi->efi_memmap, &p->efi->efi_memmap_hi);
p->efi->efi_memmap_size = *map->map_size;
-#ifdef CONFIG_X86_64
- p->efi->efi_systab_hi = (unsigned long)efi_system_table >> 32;
- p->efi->efi_memmap_hi = (unsigned long)*map->map >> 32;
-#endif
-
return EFI_SUCCESS;
}
@@ -785,10 +781,10 @@ unsigned long efi_main(efi_handle_t handle,
status = efi_load_initrd_dev_path(&addr, &size, ULONG_MAX);
if (status == EFI_SUCCESS) {
- hdr->ramdisk_image = (u32)addr;
- hdr->ramdisk_size = (u32)size;
- boot_params->ext_ramdisk_image = (u64)addr >> 32;
- boot_params->ext_ramdisk_size = (u64)size >> 32;
+ efi_set_u64_split(addr, &hdr->ramdisk_image,
+ &boot_params->ext_ramdisk_image);
+ efi_set_u64_split(size, &hdr->ramdisk_size,
+ &boot_params->ext_ramdisk_size);
} else if (status != EFI_NOT_FOUND) {
efi_printk("efi_load_initrd_dev_path() failed!\n");
goto fail;
--
2.17.1
next prev parent reply other threads:[~2020-05-08 18:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-08 18:01 [GIT PULL 00/15] More EFI changes for v5.8 Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 01/15] efi/x86: Use correct size for boot_params Ard Biesheuvel
2020-05-08 18:01 ` Ard Biesheuvel [this message]
2020-05-08 18:01 ` [PATCH 03/15] efi/libstub: Move pr_efi/pr_efi_err into efi namespace Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 04/15] efi/x86: Use efi_err for error messages Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 05/15] efi/gop: " Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 06/15] efi/tpm: " Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 07/15] efi/libstub: Upgrade ignored dtb= argument message to error Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 08/15] efi/x86: Move command-line initrd loading to efi_main Ard Biesheuvel
2020-05-27 22:30 ` Williams, Dan J
2020-05-27 22:46 ` Arvind Sankar
2020-05-27 22:56 ` Dan Williams
2020-05-27 23:02 ` Arvind Sankar
2020-05-27 23:13 ` Dan Williams
2020-05-27 23:26 ` [PATCH] efi/x86: Don't blow away existing initrd Arvind Sankar
2020-05-28 6:34 ` Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 09/15] efi/libstub: Unify initrd loading across architectures Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 10/15] efi/x86: Support builtin command line Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 11/15] efi/libstub: Check return value of efi_parse_options Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 12/15] efi/libstub: Fix mixed mode boot issue after macro refactor Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 13/15] efi/libstub/x86: Work around LLVM ELF quirk build regression Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 14/15] efi/libstub: Make efi_printk() input argument const char* Ard Biesheuvel
2020-05-08 18:01 ` [PATCH 15/15] efi/libstub: Correct comment typos Ard Biesheuvel
2020-05-14 9:05 ` [GIT PULL 00/15] More EFI changes for v5.8 Ard Biesheuvel
2020-05-20 7:20 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200508180157.1816-3-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=joe@perches.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mingo@kernel.org \
--cc=nivedita@alum.mit.edu \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).