[Intel-gfx] [PATCH] efi/x86: Protect rtc_lock from interrupts

Chris Wilson chris at chris-wilson.co.uk
Mon Mar 2 08:35:26 UTC 2020


commit 83a0a2ea0b991927e42984be220329e776ce7137
Author: Ard Biesheuvel <ardb at kernel.org>
Date:   Fri Jul 20 10:47:18 2018 +0900

    efi/x86: Prevent reentrant firmware calls in mixed mode

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 arch/x86/platform/efi/efi_64.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index fa8506e76bbe..8e2d23938aa3 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -572,16 +572,16 @@ static efi_status_t efi_thunk_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 	u32 phys_tm, phys_tc;
 	unsigned long flags;
 
-	spin_lock(&rtc_lock);
-	spin_lock_irqsave(&efi_runtime_lock, flags);
+	spin_lock_irqsave(&rtc_lock, flags);
+	spin_lock(&efi_runtime_lock);
 
 	phys_tm = virt_to_phys_or_null(tm);
 	phys_tc = virt_to_phys_or_null(tc);
 
 	status = efi_thunk(get_time, phys_tm, phys_tc);
 
-	spin_unlock_irqrestore(&efi_runtime_lock, flags);
-	spin_unlock(&rtc_lock);
+	spin_unlock(&efi_runtime_lock);
+	spin_unlock_irqrestore(&rtc_lock, flags);
 
 	return status;
 }
@@ -592,15 +592,15 @@ static efi_status_t efi_thunk_set_time(efi_time_t *tm)
 	u32 phys_tm;
 	unsigned long flags;
 
-	spin_lock(&rtc_lock);
-	spin_lock_irqsave(&efi_runtime_lock, flags);
+	spin_lock_irqave(&rtc_lock, flags);
+	spin_lock(&efi_runtime_lock);
 
 	phys_tm = virt_to_phys_or_null(tm);
 
 	status = efi_thunk(set_time, phys_tm);
 
-	spin_unlock_irqrestore(&efi_runtime_lock, flags);
-	spin_unlock(&rtc_lock);
+	spin_unlock(&efi_runtime_lock);
+	spin_unlock_irqrestore(&rtc_lock, flags);
 
 	return status;
 }
@@ -613,8 +613,8 @@ efi_thunk_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
 	u32 phys_enabled, phys_pending, phys_tm;
 	unsigned long flags;
 
-	spin_lock(&rtc_lock);
-	spin_lock_irqsave(&efi_runtime_lock, flags);
+	spin_lock_irqsave(&rtc_lock, flags);
+	spin_lock(&efi_runtime_lock);
 
 	phys_enabled = virt_to_phys_or_null(enabled);
 	phys_pending = virt_to_phys_or_null(pending);
@@ -623,8 +623,8 @@ efi_thunk_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
 	status = efi_thunk(get_wakeup_time, phys_enabled,
 			     phys_pending, phys_tm);
 
-	spin_unlock_irqrestore(&efi_runtime_lock, flags);
-	spin_unlock(&rtc_lock);
+	spin_unlock(&efi_runtime_lock);
+	spin_unlock_irqrestore(&rtc_lock, flags);
 
 	return status;
 }
@@ -636,15 +636,15 @@ efi_thunk_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
 	u32 phys_tm;
 	unsigned long flags;
 
-	spin_lock(&rtc_lock);
-	spin_lock_irqsave(&efi_runtime_lock, flags);
+	spin_lock_irqsave(&rtc_lock, flags);
+	spin_lock(&efi_runtime_lock);
 
 	phys_tm = virt_to_phys_or_null(tm);
 
 	status = efi_thunk(set_wakeup_time, enabled, phys_tm);
 
-	spin_unlock_irqrestore(&efi_runtime_lock, flags);
-	spin_unlock(&rtc_lock);
+	spin_unlock(&efi_runtime_lock);
+	spin_unlock_irqrestore(&rtc_lock, flags);
 
 	return status;
 }
-- 
2.25.1



More information about the Intel-gfx mailing list