mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Fleming <matt@console-pimps.org>
To: linux-efi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Matt Fleming <matt.fleming@intel.com>
Subject: [PATCH] x86, efi: retry ExitBootServices() on failure
Date: Wed, 22 May 2013 15:15:00 +0100	[thread overview]
Message-ID: <1369232100-27232-1-git-send-email-matt@console-pimps.org> (raw)

From: Matt Fleming <matt.fleming@intel.com>

ExitBootServices() can legitimately fail if any of the event handlers
that are signaled by its invocation change the memory map. In that case,
we need to get the memory map and exit boot services again. Only retry
once so that we don't get stuck if ExitBootServices() is returning a
genuine error value.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/x86/boot/compressed/eboot.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 35ee62f..a88a81d 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -1037,6 +1037,7 @@ static efi_status_t exit_boot(struct boot_params *boot_params,
 	efi_memory_desc_t *mem_map;
 	efi_status_t status;
 	__u32 desc_version;
+	bool called_exit = false;
 	u8 nr_entries;
 	int i;
 
@@ -1049,9 +1050,10 @@ again:
 	if (status != EFI_SUCCESS)
 		return status;
 
+get_map:
 	status = efi_call_phys5(sys_table->boottime->get_memory_map, &size,
 				mem_map, &key, &desc_size, &desc_version);
-	if (status == EFI_BUFFER_TOO_SMALL) {
+	if (status == EFI_BUFFER_TOO_SMALL && !called_exit) {
 		low_free(_size, (unsigned long)mem_map);
 		goto again;
 	}
@@ -1074,8 +1076,20 @@ again:
 	/* Might as well exit boot services now */
 	status = efi_call_phys2(sys_table->boottime->exit_boot_services,
 				handle, key);
-	if (status != EFI_SUCCESS)
-		goto free_mem_map;
+	if (status != EFI_SUCCESS) {
+		/*
+		 * ExitBootServices() will fail if any of the event
+		 * handlers change the memory map. In which case, we
+		 * must be prepared to retry, but only once so that
+		 * we're guaranteed to exit on repeated failures instead
+		 * of spinning forever.
+		 */
+		if (called_exit)
+			goto free_mem_map;
+
+		called_exit = true;
+		goto get_map;
+	}
 
 	/* Historic? */
 	boot_params->alt_mem_k = 32 * 1024;
-- 
1.8.1.4


             reply	other threads:[~2013-05-22 14:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-22 14:15 Matt Fleming [this message]
2013-06-11  6:52 Matt Fleming
2013-06-11  7:22 ` Matt Fleming
2013-06-13 16:00 ` joeyli
2013-06-17  9:21   ` Matt Fleming
2013-06-17  9:46     ` Jan Beulich
2013-06-17 10:17       ` Matt Fleming
2013-06-17 10:41         ` joeyli
2013-06-17 11:02         ` Jan Beulich
2013-06-17 12:30           ` Matt Fleming
2013-06-18  0:18             ` Zachary Bobroff
2013-06-18  2:47               ` joeyli
2013-06-18  4:20                 ` Zachary Bobroff
2013-06-18  7:34                   ` joeyli
2013-06-18 13:03               ` Jan Beulich
2013-06-18 22:12                 ` Zachary Bobroff
2013-06-19  8:43                   ` matt
2013-06-19  8:53                     ` H. Peter Anvin
2013-06-20 18:04                       ` Zachary Bobroff
2013-06-26 13:12                         ` matt

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=1369232100-27232-1-git-send-email-matt@console-pimps.org \
    --to=matt@console-pimps.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    /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

all inboxes | Powered by JetHome®