Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86/EFI changes from Peter Anvin:

 - Improve the initrd handling in the EFI boot stub by allowing forward
   slashes in the pathname - from Chun-Yi Lee.

 - Cleanup code duplication in the EFI mixed kernel/firmware code - from
   Satoru Takeuchi.

 - efivarfs bug fixes for more strict filename validation, with lots of
   input from Al Viro.

* 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86, efi: remove duplicate code in setup_arch() by using, efi_is_native()
  efivarfs: guid part of filenames are case-insensitive
  efivarfs: Validate filenames much more aggressively
  efivarfs: Use sizeof() instead of magic number
  x86, efi: Allow slash in file path of initrd
This commit is contained in:
Linus Torvalds
2013-02-27 16:17:42 -08:00
5 changed files with 166 additions and 23 deletions

View File

@@ -19,23 +19,28 @@
static efi_system_table_t *sys_table;
static void efi_char16_printk(efi_char16_t *str)
{
struct efi_simple_text_output_protocol *out;
out = (struct efi_simple_text_output_protocol *)sys_table->con_out;
efi_call_phys2(out->output_string, out, str);
}
static void efi_printk(char *str)
{
char *s8;
for (s8 = str; *s8; s8++) {
struct efi_simple_text_output_protocol *out;
efi_char16_t ch[2] = { 0 };
ch[0] = *s8;
out = (struct efi_simple_text_output_protocol *)sys_table->con_out;
if (*s8 == '\n') {
efi_char16_t nl[2] = { '\r', 0 };
efi_call_phys2(out->output_string, out, nl);
efi_char16_printk(nl);
}
efi_call_phys2(out->output_string, out, ch);
efi_char16_printk(ch);
}
}
@@ -709,7 +714,12 @@ static efi_status_t handle_ramdisks(efi_loaded_image_t *image,
if ((u8 *)p >= (u8 *)filename_16 + sizeof(filename_16))
break;
*p++ = *str++;
if (*str == '/') {
*p++ = '\\';
*str++;
} else {
*p++ = *str++;
}
}
*p = '\0';
@@ -737,7 +747,9 @@ static efi_status_t handle_ramdisks(efi_loaded_image_t *image,
status = efi_call_phys5(fh->open, fh, &h, filename_16,
EFI_FILE_MODE_READ, (u64)0);
if (status != EFI_SUCCESS) {
efi_printk("Failed to open initrd file\n");
efi_printk("Failed to open initrd file: ");
efi_char16_printk(filename_16);
efi_printk("\n");
goto close_handles;
}

View File

@@ -102,7 +102,14 @@ extern void efi_call_phys_epilog(void);
extern void efi_unmap_memmap(void);
extern void efi_memory_uc(u64 addr, unsigned long size);
#ifndef CONFIG_EFI
#ifdef CONFIG_EFI
static inline bool efi_is_native(void)
{
return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT);
}
#else
/*
* IF EFI is not configured, have the EFI calls return -ENOSYS.
*/

View File

@@ -1196,8 +1196,7 @@ void __init setup_arch(char **cmdline_p)
* mismatched firmware/kernel archtectures since there is no
* support for runtime services.
*/
if (efi_enabled(EFI_BOOT) &&
IS_ENABLED(CONFIG_X86_64) != efi_enabled(EFI_64BIT)) {
if (efi_enabled(EFI_BOOT) && !efi_is_native()) {
pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n");
efi_unmap_memmap();
}

View File

@@ -69,11 +69,6 @@ struct efi_memory_map memmap;
static struct efi efi_phys __initdata;
static efi_system_table_t efi_systab __initdata;
static inline bool efi_is_native(void)
{
return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT);
}
unsigned long x86_efi_facility;
/*