From: joeyli <jlee-IBi9RG/b67k@public.gmane.org>
To: Matt Fleming <matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
Cc: Matthew Garrett
<matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org>,
"Fleming,
Matt" <matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"rja-sJ/iWh9BUns@public.gmane.org"
<rja-sJ/iWh9BUns@public.gmane.org>,
"mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
<mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org"
<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
"bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org"
<bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org>,
"jkosina-AlSwsSmVLrQ@public.gmane.org"
<jkosina-AlSwsSmVLrQ@public.gmane.org>,
"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
<x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org"
<tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
"hpa-VuQAYsv1563Yd54FQh9/CA@public.gmane.org"
<hpa-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
"akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org"
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
"oneukum-l3A5Bk7waGM@public.gmane.org"
<oneukum-l3A5Bk7waGM@public.gmane.org>
Subject: Re: [PATCH] Modify UEFI anti-bricking code
Date: Thu, 06 Jun 2013 13:05:10 +0800 [thread overview]
Message-ID: <1370495110.6523.35.camel@linux-s257.site> (raw)
In-Reply-To: <20130605155904.GC30420-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
於 三,2013-06-05 於 16:59 +0100,Matt Fleming 提到:
> On Wed, 05 Jun, at 02:53:27PM, Matthew Garrett wrote:
> > On Wed, 2013-06-05 at 15:49 +0100, Fleming, Matt wrote:
> >
> > > Folks, what do you want me to do with this? Merge it with Matthew's patch?
> >
> > Do that and add Joey's signed-off-by?
>
> Right, this is what I've got queued up.
>
> ---
>
> >From 380dcc12ba82f4e10feb6a72207b2e4771d16d8d Mon Sep 17 00:00:00 2001
> From: Matthew Garrett <matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org>
> Date: Sat, 1 Jun 2013 16:06:20 -0400
> Subject: [PATCH] Modify UEFI anti-bricking code
>
> This patch reworks the UEFI anti-bricking code, including an effective
> reversion of cc5a080c and 31ff2f20. It turns out that calling
> QueryVariableInfo() from boot services results in some firmware
> implementations jumping to physical addresses even after entering virtual
> mode, so until we have 1:1 mappings for UEFI runtime space this isn't
> going to work so well.
[...]
The follow diff change is base on 380dcc12 patch queued in efi git tree,
it included Matthew and hpa's suggestions. I fix the attributes of DUMMY
object to NV/BS/RT and introduced a #define of the minimum reserve flash
space.
This change works to me on OVMF.
Thanks a lot!
Joey Lee
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index cc3cfe8..2617675 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -53,6 +53,8 @@
#define EFI_DEBUG 1
+#define EFI_MIN_RESERVE 5120
+
#define EFI_DUMMY_GUID \
EFI_GUID(0x4424ac57, 0xbe4b, 0x47dd, 0x9e, 0x97, 0xed, 0x50, 0xf0, 0x9f, 0x92, 0xa9)
@@ -988,7 +990,11 @@ void __init efi_enter_virtual_mode(void)
kfree(new_memmap);
/* clean DUMMY object */
- efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID, 0, 0, NULL);
+ efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID,
+ EFI_VARIABLE_NON_VOLATILE |
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
+ 0, NULL);
}
/*
@@ -1051,7 +1057,12 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
* write if permitting it would reduce the available space to under
* 5KB. This figure was provided by Samsung, so should be safe.
*/
- if ((remaining_size - size < 5120) && !efi_no_storage_paranoia) {
+ if ((remaining_size - size < EFI_MIN_RESERVE) &&
+ !efi_no_storage_paranoia) {
+
+ if (!(attributes & EFI_VARIABLE_NON_VOLATILE))
+ return EFI_OUT_OF_RESOURCES;
+
/*
* Triggering garbage collection may require that the firmware
* generate a real EFI_OUT_OF_RESOURCES error. We can force
@@ -1061,7 +1072,10 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
void *dummy = kmalloc(dummy_size, GFP_ATOMIC);
status = efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID,
- attributes, dummy_size, dummy);
+ EFI_VARIABLE_NON_VOLATILE |
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
+ dummy_size, dummy);
if (status == EFI_SUCCESS) {
/*
@@ -1085,7 +1099,7 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
/*
* There still isn't enough room, so return an error
*/
- if (remaining_size - size < 5120)
+ if (remaining_size - size < EFI_MIN_RESERVE)
return EFI_OUT_OF_RESOURCES;
}
next prev parent reply other threads:[~2013-06-06 5:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-01 20:06 [PATCH] Modify UEFI anti-bricking code Matthew Garrett
[not found] ` <1370117180-1712-1-git-send-email-matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org>
2013-06-02 15:48 ` Russ Anderson
2013-06-04 5:29 ` Lingzhu Xiang
2013-06-03 12:17 ` Matt Fleming
2013-06-03 14:58 ` Matthew Garrett
2013-06-03 16:13 ` joeyli
2013-06-03 16:31 ` Matthew Garrett
[not found] ` <1370277079.6315.14.camel-+5W/JHIUVxg@public.gmane.org>
2013-06-04 3:35 ` joeyli
2013-06-05 14:49 ` Fleming, Matt
[not found] ` <CAL01qptzxe5L6Vq+nBZLq+bQNxbe_i_2OdKMNJGZQDfMihaHOw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-05 14:53 ` Matthew Garrett
[not found] ` <1370444007.6315.32.camel-+5W/JHIUVxg@public.gmane.org>
2013-06-05 15:59 ` Matt Fleming
[not found] ` <20130605155904.GC30420-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-06-05 16:08 ` Matthew Garrett
[not found] ` <1370448519.6315.36.camel-+5W/JHIUVxg@public.gmane.org>
2013-06-05 19:59 ` Matt Fleming
2013-06-06 2:24 ` joeyli
2013-06-05 20:19 ` H. Peter Anvin
2013-06-06 5:05 ` joeyli [this message]
2013-06-06 5:41 ` joeyli
2013-06-06 5:42 ` Matthew Garrett
[not found] ` <1370497321.6315.44.camel-+5W/JHIUVxg@public.gmane.org>
2013-06-06 7:40 ` joeyli
[not found] ` <1370504426.6523.49.camel-ONCj+Eqt86TasUa73XJKwA@public.gmane.org>
2013-06-06 9:25 ` Matt Fleming
[not found] ` <20130606092542.GE30420-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-06-06 14:48 ` Russ Anderson
[not found] ` <20130606144846.GA10393-sJ/iWh9BUns@public.gmane.org>
2013-06-06 15:00 ` Matt Fleming
[not found] ` <20130606150039.GL30420-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-06-06 15:28 ` Russ Anderson
2013-06-10 18:54 ` Russ Anderson
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=1370495110.6523.35.camel@linux-s257.site \
--to=jlee-ibi9rg/b67k@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org \
--cc=hpa-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=jkosina-AlSwsSmVLrQ@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org \
--cc=matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org \
--cc=mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=oneukum-l3A5Bk7waGM@public.gmane.org \
--cc=rja-sJ/iWh9BUns@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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