All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Môshe van der Sterre" <me-A/3C56C7qwM@public.gmane.org>
To: Josh Triplett <josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>,
	Andy Lutomirski <luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Matt Fleming
	<matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>,
	"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: BGRT warns again on my system
Date: Sun, 29 May 2016 06:09:01 +0200	[thread overview]
Message-ID: <574A6B5D.60200@moshe.nl> (raw)
In-Reply-To: <20160528222531.GA10687@x>

On 05/29/2016 12:25 AM, Josh Triplett wrote:
> On Sat, May 28, 2016 at 01:46:07PM -0700, Andy Lutomirski wrote:
>> My garbage workstation splats like this on boot:
>>
>> [    0.160523] ioremap: invalid physical address d0c801800000001
>>
>> This was fixed for a while, but I think the problem was reintroduced by:
>>
>> commit 66dbe99cfe30e113d2e571e68b9b6a1a8985a157
>> Author: Môshe van der Sterre <me-A/3C56C7qwM@public.gmane.org>
>> Date:   Mon Feb 1 22:07:03 2016 +0000
>>
>>     x86/efi/bgrt: Don't ignore the BGRT if the 'valid' bit is 0
>>
>> Is there any good way to fix this again?

Is it sensible for efi-bgrt.c to use phys_addr_valid from arch/x86/mm?
That way efi-bgrt.c can choose a noise level on its own. I added a patch
to show what I mean, but is this even allowed by kernel coding
conventions?

> This was the kind of concern I had about ignoring the valid bit.  I
> supported this patch based on the statement that Windows 10 ignores the
> valid bit as well.  Presumably either Windows has some way of detecting
> this kind of problem, or it would break on that system.  If the former,
> does anyone know what algorithm Windows uses to safely check for BGRT?

I don't know the exact steps Windows takes here, but I would also like
to point to the ACPI specification. The way I read it, the valid bit
really is not any indication about having a valid physical address. It
is about having a valid screen state and a better name would perhaps
have been 'onscreen' or 'screenstatenotchanged' etc. To my eyes this is
unintuitive, but it is actually documented this way.
Quoting from the specification:

"It should be set to 1 when the table is written, and invalidated if
there is reason to expect that the screen state has been changed."

The BGRT introduction text also gives a bit more information:

"The table is written when the image is drawn on the screen. This
should be done after it is expected that any firmware components that
may write to the screen are done doing so and it is known that the image
is the only thing on the screen. If the boot path is interrupted (e.g.
by a key press), the valid bit within the status field should be changed
to 0 to indicate to the OS that the current image is invalidated."

On 2 machines I was able to test this on, this matches the behavior I
observed: A normal boot provides valid==1, but booting with a bootmenu
provides valid==0. On the third machine I tested the bit was simply
always 0, with or without bootmenu. On those 3 machines the physical
address was valid and usable in any situation.

> I can see two possible ways to fix this.  If we can detect in advance
> that the address in the BGRT looks bogus (pointing to physical memory
> that doesn't exist, for instance), then we could ignore it entirely
> (without any warning if valid==0, or with a warning if valid==1).  If we
> can't detect that in advance, then we need to revert this patch and go
> back to respecting the valid bit.  (However, trying to check the address
> in advance seems preferable given that some BIOS might have a bogus
> address even with valid==1.)

How do you interpret those words from the specification? I think the
absence of a valid physical address should give the same warning,
unrelated to the valid bit, because I don't think the bit is about that
fact at all.

---
 arch/x86/platform/efi/efi-bgrt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/platform/efi/efi-bgrt.c b/arch/x86/platform/efi/efi-bgrt.c
index 6a2f569..a7fdb61 100644
--- a/arch/x86/platform/efi/efi-bgrt.c
+++ b/arch/x86/platform/efi/efi-bgrt.c
@@ -19,6 +19,8 @@
 #include <linux/efi.h>
 #include <linux/efi-bgrt.h>
 
+#include "../../mm/physaddr.h"
+
 struct acpi_table_bgrt *bgrt_tab;
 void *__initdata bgrt_image;
 size_t __initdata bgrt_image_size;
@@ -67,6 +69,11 @@ void __init efi_bgrt_init(void)
 		return;
 	}
 
+	if (!phys_addr_valid(bgrt_tab->image_address)) {
+		pr_notice("Ignoring BGRT: image address is bogus\n");
+		return;
+	}
+
 	image = memremap(bgrt_tab->image_address, sizeof(bmp_header), MEMREMAP_WB);
 	if (!image) {
 		pr_notice("Ignoring BGRT: failed to map image header memory\n");
-- 
2.4.3

  reply	other threads:[~2016-05-29  4:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-28 20:46 BGRT warns again on my system Andy Lutomirski
     [not found] ` <CALCETrUJ2QoUSYY82Q1BN3niasiunktnrmdE9Lmi2PZnCJRdag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-05-28 22:25   ` Josh Triplett
2016-05-29  4:09     ` Môshe van der Sterre [this message]
     [not found]       ` <574A6B5D.60200-A/3C56C7qwM@public.gmane.org>
2016-06-02  9:24         ` Matt Fleming
     [not found]           ` <20160602092438.GD2658-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-06-19 13:14             ` Môshe van der Sterre
     [not found]               ` <57669AC0.7010905-A/3C56C7qwM@public.gmane.org>
2016-06-19 14:38                 ` Josh Triplett
2016-06-19 14:57                   ` Môshe van der Sterre
2016-06-20  5:38             ` Dave Young
     [not found]               ` <20160620053819.GB13633-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2016-06-20 15:50                 ` Josh Triplett
2016-06-23 12:01                 ` Matt Fleming

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=574A6B5D.60200@moshe.nl \
    --to=me-a/3c56c7qwm@public.gmane.org \
    --cc=josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.