]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
efi/runtime-wrappers: Add a nonblocking version of QueryVariableInfo()
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 1 Feb 2016 22:06:57 +0000 (22:06 +0000)
committerTim Gardner <tim.gardner@canonical.com>
Wed, 20 Apr 2016 20:08:48 +0000 (14:08 -0600)
BugLink: http://bugs.launchpad.net/bugs/1569924
This introduces a new runtime wrapper for the
QueryVariableInfo() UEFI Runtime Service, which gives up
immediately rather than spins on failure to grab the efi_runtime
spinlock.

This is required in the non-blocking path of the efi-pstore
code.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/1454364428-494-4-git-send-email-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from commit d3cac1f83c631b9fe5edaebcba49f6989bfff089)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Andy Whitcroft <andy.whitcroft@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/firmware/efi/runtime-wrappers.c
include/linux/efi.h

index 228bbf91046137de619a4f8f89825e8ccc34b5ab..e9f2867f0d915de0830f41df9790f8d5e6413ec6 100644 (file)
@@ -230,6 +230,27 @@ static efi_status_t virt_efi_query_variable_info(u32 attr,
        return status;
 }
 
+static efi_status_t
+virt_efi_query_variable_info_nonblocking(u32 attr,
+                                        u64 *storage_space,
+                                        u64 *remaining_space,
+                                        u64 *max_variable_size)
+{
+       unsigned long flags;
+       efi_status_t status;
+
+       if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
+               return EFI_UNSUPPORTED;
+
+       if (!spin_trylock_irqsave(&efi_runtime_lock, flags))
+               return EFI_NOT_READY;
+
+       status = efi_call_virt(query_variable_info, attr, storage_space,
+                              remaining_space, max_variable_size);
+       spin_unlock_irqrestore(&efi_runtime_lock, flags);
+       return status;
+}
+
 static efi_status_t virt_efi_get_next_high_mono_count(u32 *count)
 {
        unsigned long flags;
@@ -300,6 +321,7 @@ void efi_native_runtime_setup(void)
        efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count;
        efi.reset_system = virt_efi_reset_system;
        efi.query_variable_info = virt_efi_query_variable_info;
+       efi.query_variable_info_nonblocking = virt_efi_query_variable_info_nonblocking;
        efi.update_capsule = virt_efi_update_capsule;
        efi.query_capsule_caps = virt_efi_query_capsule_caps;
 }
index 9ca3f71751580ed009bec3c08b5bddd4f2f4f6ab..f9ed5d080ce4093d45ce80014ed088b0d79869d4 100644 (file)
@@ -855,6 +855,7 @@ extern struct efi {
        efi_set_variable_t *set_variable;
        efi_set_variable_t *set_variable_nonblocking;
        efi_query_variable_info_t *query_variable_info;
+       efi_query_variable_info_t *query_variable_info_nonblocking;
        efi_update_capsule_t *update_capsule;
        efi_query_capsule_caps_t *query_capsule_caps;
        efi_get_next_high_mono_count_t *get_next_high_mono_count;