x86/efi: Allow invocation of arbitrary runtime services
authorDavid Howells <dhowells@redhat.com>
Mon, 6 Feb 2017 11:22:40 +0000 (11:22 +0000)
committerIngo Molnar <mingo@kernel.org>
Tue, 7 Feb 2017 09:42:09 +0000 (10:42 +0100)
Provide the ability to perform mixed-mode runtime service calls for x86 in
the same way the following commit provided the ability to invoke for boot
services:

  0a637ee61247bd ("x86/efi: Allow invocation of arbitrary boot services")

Suggested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/1486380166-31868-2-git-send-email-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/boot/compressed/eboot.c
arch/x86/boot/compressed/head_32.S
arch/x86/boot/compressed/head_64.S
arch/x86/include/asm/efi.h

index 6d3aeabbce68b75c2a7db3dae8ba7bcf8853eee3..f99978db6b6fac3f6d2ba75e4b7a3cf2ea182ebc 100644 (file)
@@ -32,6 +32,7 @@ static void setup_boot_services##bits(struct efi_config *c)           \
                                                                        \
        table = (typeof(table))sys_table;                               \
                                                                        \
+       c->runtime_services = table->runtime;                           \
        c->boot_services = table->boottime;                             \
        c->text_output = table->con_out;                                \
 }
index fd0b6a272dd5bf252b4aad12be6b961789cc2404..d85b9625e836d5429e4eff13104e0b01f338f4d0 100644 (file)
@@ -82,7 +82,7 @@ ENTRY(efi_pe_entry)
 
        /* Relocate efi_config->call() */
        leal    efi32_config(%esi), %eax
-       add     %esi, 32(%eax)
+       add     %esi, 40(%eax)
        pushl   %eax
 
        call    make_boot_params
@@ -108,7 +108,7 @@ ENTRY(efi32_stub_entry)
 
        /* Relocate efi_config->call() */
        leal    efi32_config(%esi), %eax
-       add     %esi, 32(%eax)
+       add     %esi, 40(%eax)
        pushl   %eax
 2:
        call    efi_main
@@ -264,7 +264,7 @@ relocated:
 #ifdef CONFIG_EFI_STUB
        .data
 efi32_config:
-       .fill 4,8,0
+       .fill 5,8,0
        .long efi_call_phys
        .long 0
        .byte 0
index 4d85e600db78292b46fc2ed2676b2cb171b708e2..d2ae1f821e0c6b6d85452841160fbaf1c182a743 100644 (file)
@@ -264,7 +264,7 @@ ENTRY(efi_pe_entry)
        /*
         * Relocate efi_config->call().
         */
-       addq    %rbp, efi64_config+32(%rip)
+       addq    %rbp, efi64_config+40(%rip)
 
        movq    %rax, %rdi
        call    make_boot_params
@@ -284,7 +284,7 @@ handover_entry:
         * Relocate efi_config->call().
         */
        movq    efi_config(%rip), %rax
-       addq    %rbp, 32(%rax)
+       addq    %rbp, 40(%rax)
 2:
        movq    efi_config(%rip), %rdi
        call    efi_main
@@ -456,14 +456,14 @@ efi_config:
 #ifdef CONFIG_EFI_MIXED
        .global efi32_config
 efi32_config:
-       .fill   4,8,0
+       .fill   5,8,0
        .quad   efi64_thunk
        .byte   0
 #endif
 
        .global efi64_config
 efi64_config:
-       .fill   4,8,0
+       .fill   5,8,0
        .quad   efi_call
        .byte   1
 #endif /* CONFIG_EFI_STUB */
index e99675b9c861dad48a9c4ba46cc63876255c2748..2f77bcefe6b494cf7dcd5f7158cfe3090893c584 100644 (file)
@@ -191,6 +191,7 @@ static inline efi_status_t efi_thunk_set_virtual_address_map(
 struct efi_config {
        u64 image_handle;
        u64 table;
+       u64 runtime_services;
        u64 boot_services;
        u64 text_output;
        efi_status_t (*call)(unsigned long, ...);
@@ -226,6 +227,10 @@ static inline bool efi_is_64bit(void)
 #define __efi_call_early(f, ...)                                       \
        __efi_early()->call((unsigned long)f, __VA_ARGS__);
 
+#define efi_call_runtime(f, ...)                                       \
+       __efi_early()->call(efi_table_attr(efi_runtime_services, f,     \
+               __efi_early()->runtime_services), __VA_ARGS__)
+
 extern bool efi_reboot_required(void);
 
 #else