Linux-EFI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] efi/bgrt: Accept BGRT tables with a version of 0 on Lenovo laptops
@ 2020-01-26 15:02 Hans de Goede
  2020-01-28  7:48 ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2020-01-26 15:02 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Hans de Goede, linux-efi, linux-acpi, stable

Some (somewhat older) Lenovo laptops have a correct BGRT table, except
that the version field is 0 instead of 1.

Quickly after finding this out, even before submitting a first version of
this patch upstream, the list of DMI matches for affected models grew to
3 models (all Ivy Bridge based).

So rather then maintaining an ever growing list with DMI matches for
affected Lenovo models, this commit simply checks if the vendor is Lenovo
when the version is 0 and in that case accepts the out of spec version
working around the Lenovo firmware bug.

Cc: stable@vger.kernel.org
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1791273
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/firmware/efi/efi-bgrt.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c
index b07c17643210..3a2d6d3a590b 100644
--- a/drivers/firmware/efi/efi-bgrt.c
+++ b/drivers/firmware/efi/efi-bgrt.c
@@ -15,6 +15,7 @@
 #include <linux/acpi.h>
 #include <linux/efi.h>
 #include <linux/efi-bgrt.h>
+#include <linux/dmi.h>
 
 struct acpi_table_bgrt bgrt_tab;
 size_t bgrt_image_size;
@@ -42,7 +43,12 @@ void __init efi_bgrt_init(struct acpi_table_header *table)
 		return;
 	}
 	*bgrt = *(struct acpi_table_bgrt *)table;
-	if (bgrt->version != 1) {
+	/*
+	 * Some older Lenovo laptops have a correct BGRT table, except that
+	 * the version field is 0 instead of 1.
+	 */
+	if (bgrt->version != 1 &&
+	    !(bgrt->version == 0 && dmi_name_in_vendors("LENOVO"))) {
 		pr_notice("Ignoring BGRT: invalid version %u (expected 1)\n",
 		       bgrt->version);
 		goto out;
-- 
2.24.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] efi/bgrt: Accept BGRT tables with a version of 0 on Lenovo laptops
  2020-01-26 15:02 [PATCH] efi/bgrt: Accept BGRT tables with a version of 0 on Lenovo laptops Hans de Goede
@ 2020-01-28  7:48 ` Ard Biesheuvel
  2020-01-31 12:47   ` Hans de Goede
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2020-01-28  7:48 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Ard Biesheuvel, linux-efi, ACPI Devel Maling List, stable

On Sun, 26 Jan 2020 at 16:02, Hans de Goede <hdegoede@redhat.com> wrote:
>
> Some (somewhat older) Lenovo laptops have a correct BGRT table, except
> that the version field is 0 instead of 1.
>
> Quickly after finding this out, even before submitting a first version of
> this patch upstream, the list of DMI matches for affected models grew to
> 3 models (all Ivy Bridge based).
>
> So rather then maintaining an ever growing list with DMI matches for
> affected Lenovo models, this commit simply checks if the vendor is Lenovo
> when the version is 0 and in that case accepts the out of spec version
> working around the Lenovo firmware bug.
>
> Cc: stable@vger.kernel.org
> BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1791273
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/firmware/efi/efi-bgrt.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c
> index b07c17643210..3a2d6d3a590b 100644
> --- a/drivers/firmware/efi/efi-bgrt.c
> +++ b/drivers/firmware/efi/efi-bgrt.c
> @@ -15,6 +15,7 @@
>  #include <linux/acpi.h>
>  #include <linux/efi.h>
>  #include <linux/efi-bgrt.h>
> +#include <linux/dmi.h>
>
>  struct acpi_table_bgrt bgrt_tab;
>  size_t bgrt_image_size;
> @@ -42,7 +43,12 @@ void __init efi_bgrt_init(struct acpi_table_header *table)
>                 return;
>         }
>         *bgrt = *(struct acpi_table_bgrt *)table;
> -       if (bgrt->version != 1) {
> +       /*
> +        * Some older Lenovo laptops have a correct BGRT table, except that
> +        * the version field is 0 instead of 1.
> +        */
> +       if (bgrt->version != 1 &&
> +           !(bgrt->version == 0 && dmi_name_in_vendors("LENOVO"))) {
>                 pr_notice("Ignoring BGRT: invalid version %u (expected 1)\n",
>                        bgrt->version);
>                 goto out;

Hi Hans,

Given that the ACPI spec only defines a single version for this table,
which is version #1, wouldn't it be simpler to just assume that
version #0 means version #1 in all cases, rather than using DMI
matches for that? There is no risk of misidentifying another table
version, since none exist ...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] efi/bgrt: Accept BGRT tables with a version of 0 on Lenovo laptops
  2020-01-28  7:48 ` Ard Biesheuvel
@ 2020-01-31 12:47   ` Hans de Goede
  0 siblings, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2020-01-31 12:47 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Ard Biesheuvel, linux-efi, ACPI Devel Maling List, stable

Hi,

On 1/28/20 8:48 AM, Ard Biesheuvel wrote:
> On Sun, 26 Jan 2020 at 16:02, Hans de Goede <hdegoede@redhat.com> wrote:
>>
>> Some (somewhat older) Lenovo laptops have a correct BGRT table, except
>> that the version field is 0 instead of 1.
>>
>> Quickly after finding this out, even before submitting a first version of
>> this patch upstream, the list of DMI matches for affected models grew to
>> 3 models (all Ivy Bridge based).
>>
>> So rather then maintaining an ever growing list with DMI matches for
>> affected Lenovo models, this commit simply checks if the vendor is Lenovo
>> when the version is 0 and in that case accepts the out of spec version
>> working around the Lenovo firmware bug.
>>
>> Cc: stable@vger.kernel.org
>> BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1791273
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   drivers/firmware/efi/efi-bgrt.c | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c
>> index b07c17643210..3a2d6d3a590b 100644
>> --- a/drivers/firmware/efi/efi-bgrt.c
>> +++ b/drivers/firmware/efi/efi-bgrt.c
>> @@ -15,6 +15,7 @@
>>   #include <linux/acpi.h>
>>   #include <linux/efi.h>
>>   #include <linux/efi-bgrt.h>
>> +#include <linux/dmi.h>
>>
>>   struct acpi_table_bgrt bgrt_tab;
>>   size_t bgrt_image_size;
>> @@ -42,7 +43,12 @@ void __init efi_bgrt_init(struct acpi_table_header *table)
>>                  return;
>>          }
>>          *bgrt = *(struct acpi_table_bgrt *)table;
>> -       if (bgrt->version != 1) {
>> +       /*
>> +        * Some older Lenovo laptops have a correct BGRT table, except that
>> +        * the version field is 0 instead of 1.
>> +        */
>> +       if (bgrt->version != 1 &&
>> +           !(bgrt->version == 0 && dmi_name_in_vendors("LENOVO"))) {
>>                  pr_notice("Ignoring BGRT: invalid version %u (expected 1)\n",
>>                         bgrt->version);
>>                  goto out;
> 
> Hi Hans,
> 
> Given that the ACPI spec only defines a single version for this table,
> which is version #1, wouldn't it be simpler to just assume that
> version #0 means version #1 in all cases, rather than using DMI
> matches for that? There is no risk of misidentifying another table
> version, since none exist ...

Ok, I will prepare a new version doing this.

Regards,

Hans


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-26 15:02 [PATCH] efi/bgrt: Accept BGRT tables with a version of 0 on Lenovo laptops Hans de Goede
2020-01-28  7:48 ` Ard Biesheuvel
2020-01-31 12:47   ` Hans de Goede

Linux-EFI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-efi/0 linux-efi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-efi linux-efi/ https://lore.kernel.org/linux-efi \
		linux-efi@vger.kernel.org
	public-inbox-index linux-efi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-efi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git