* [PATCH 0/1] dmi_scan: uuid: fix endianess for smbios >= 0x206
@ 2015-12-22 13:53 Andrea Arcangeli
2015-12-22 13:53 ` [PATCH 1/1] " Andrea Arcangeli
0 siblings, 1 reply; 4+ messages in thread
From: Andrea Arcangeli @ 2015-12-22 13:53 UTC (permalink / raw)
To: Ivan Khoronzhuk, Matt Fleming
Cc: Paolo Bonzini, Federico Simoncelli, linux-kernel, Andrew Morton
Hello,
this fixes https://bugzilla.kernel.org/show_bug.cgi?id=109731
Without this fix when this code runs:
if (dmi_ver >= 0x020600)
sprintf(s, "%pUL", d);
else
sprintf(s, "%pUB", d);
dmi_ver is still set to the old 0x20X instead of 0x20X00 as intended
after commit 95be58df74a5b21e5a78e45fddb2fd59112524c5.
Andrea Arcangeli (1):
dmi_scan: uuid: fix endianess for smbios >= 0x206
drivers/firmware/dmi_scan.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/1] dmi_scan: uuid: fix endianess for smbios >= 0x206
2015-12-22 13:53 [PATCH 0/1] dmi_scan: uuid: fix endianess for smbios >= 0x206 Andrea Arcangeli
@ 2015-12-22 13:53 ` Andrea Arcangeli
2015-12-22 15:17 ` Matt Fleming
0 siblings, 1 reply; 4+ messages in thread
From: Andrea Arcangeli @ 2015-12-22 13:53 UTC (permalink / raw)
To: Ivan Khoronzhuk, Matt Fleming
Cc: Paolo Bonzini, Federico Simoncelli, linux-kernel, Andrew Morton
The dmi_ver wasn't updated correctly before the dmi_decode method run
to save the uuid.
That resulted in "dmidecode -s system-uuid" and
/sys/class/dmi/id/product_uuid disagreeing. The latter was buggy and
this fixes it.
Reported-by: Federico Simoncelli <fsimonce@redhat.com>
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---
drivers/firmware/dmi_scan.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index ac1ce4a..0e08e66 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -521,6 +521,7 @@ static int __init dmi_present(const u8 *buf)
dmi_ver = smbios_ver;
else
dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F);
+ dmi_ver <<= 8;
dmi_num = get_unaligned_le16(buf + 12);
dmi_len = get_unaligned_le16(buf + 6);
dmi_base = get_unaligned_le32(buf + 8);
@@ -528,15 +529,14 @@ static int __init dmi_present(const u8 *buf)
if (dmi_walk_early(dmi_decode) == 0) {
if (smbios_ver) {
pr_info("SMBIOS %d.%d present.\n",
- dmi_ver >> 8, dmi_ver & 0xFF);
+ dmi_ver >> 16, (dmi_ver >> 8) & 0xFF);
} else {
smbios_entry_point_size = 15;
memcpy(smbios_entry_point, buf,
smbios_entry_point_size);
pr_info("Legacy DMI %d.%d present.\n",
- dmi_ver >> 8, dmi_ver & 0xFF);
+ dmi_ver >> 16, (dmi_ver >> 8) & 0xFF);
}
- dmi_ver <<= 8;
dmi_format_ids(dmi_ids_string, sizeof(dmi_ids_string));
printk(KERN_DEBUG "DMI: %s\n", dmi_ids_string);
return 0;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] dmi_scan: uuid: fix endianess for smbios >= 0x206
2015-12-22 13:53 ` [PATCH 1/1] " Andrea Arcangeli
@ 2015-12-22 15:17 ` Matt Fleming
2016-01-06 13:01 ` Jean Delvare
0 siblings, 1 reply; 4+ messages in thread
From: Matt Fleming @ 2015-12-22 15:17 UTC (permalink / raw)
To: Andrea Arcangeli
Cc: Ivan Khoronzhuk, Paolo Bonzini, Federico Simoncelli, linux-kernel,
Andrew Morton, Jean Delvare
(Cc'ing Jean since he's the maintainer)
On Tue, 22 Dec, at 02:53:10PM, Andrea Arcangeli wrote:
> The dmi_ver wasn't updated correctly before the dmi_decode method run
> to save the uuid.
>
> That resulted in "dmidecode -s system-uuid" and
> /sys/class/dmi/id/product_uuid disagreeing. The latter was buggy and
> this fixes it.
>
> Reported-by: Federico Simoncelli <fsimonce@redhat.com>
> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
> ---
> drivers/firmware/dmi_scan.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> index ac1ce4a..0e08e66 100644
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -521,6 +521,7 @@ static int __init dmi_present(const u8 *buf)
> dmi_ver = smbios_ver;
> else
> dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F);
> + dmi_ver <<= 8;
> dmi_num = get_unaligned_le16(buf + 12);
> dmi_len = get_unaligned_le16(buf + 6);
> dmi_base = get_unaligned_le32(buf + 8);
> @@ -528,15 +529,14 @@ static int __init dmi_present(const u8 *buf)
> if (dmi_walk_early(dmi_decode) == 0) {
> if (smbios_ver) {
> pr_info("SMBIOS %d.%d present.\n",
> - dmi_ver >> 8, dmi_ver & 0xFF);
> + dmi_ver >> 16, (dmi_ver >> 8) & 0xFF);
> } else {
> smbios_entry_point_size = 15;
> memcpy(smbios_entry_point, buf,
> smbios_entry_point_size);
> pr_info("Legacy DMI %d.%d present.\n",
> - dmi_ver >> 8, dmi_ver & 0xFF);
> + dmi_ver >> 16, (dmi_ver >> 8) & 0xFF);
> }
> - dmi_ver <<= 8;
> dmi_format_ids(dmi_ids_string, sizeof(dmi_ids_string));
> printk(KERN_DEBUG "DMI: %s\n", dmi_ids_string);
> return 0;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] dmi_scan: uuid: fix endianess for smbios >= 0x206
2015-12-22 15:17 ` Matt Fleming
@ 2016-01-06 13:01 ` Jean Delvare
0 siblings, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2016-01-06 13:01 UTC (permalink / raw)
To: Matt Fleming
Cc: Andrea Arcangeli, Ivan Khoronzhuk, Paolo Bonzini,
Federico Simoncelli, linux-kernel, Andrew Morton
Hi Matt, Andrea,
On Tue, 22 Dec 2015 15:17:51 +0000, Matt Fleming wrote:
> (Cc'ing Jean since he's the maintainer)
>
> On Tue, 22 Dec, at 02:53:10PM, Andrea Arcangeli wrote:
> > The dmi_ver wasn't updated correctly before the dmi_decode method run
> > to save the uuid.
> >
> > That resulted in "dmidecode -s system-uuid" and
> > /sys/class/dmi/id/product_uuid disagreeing. The latter was buggy and
> > this fixes it.
> >
> > Reported-by: Federico Simoncelli <fsimonce@redhat.com>
> > Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
> > ---
> > drivers/firmware/dmi_scan.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> > index ac1ce4a..0e08e66 100644
> > --- a/drivers/firmware/dmi_scan.c
> > +++ b/drivers/firmware/dmi_scan.c
> > @@ -521,6 +521,7 @@ static int __init dmi_present(const u8 *buf)
> > dmi_ver = smbios_ver;
> > else
> > dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F);
> > + dmi_ver <<= 8;
> > dmi_num = get_unaligned_le16(buf + 12);
> > dmi_len = get_unaligned_le16(buf + 6);
> > dmi_base = get_unaligned_le32(buf + 8);
> > @@ -528,15 +529,14 @@ static int __init dmi_present(const u8 *buf)
> > if (dmi_walk_early(dmi_decode) == 0) {
> > if (smbios_ver) {
> > pr_info("SMBIOS %d.%d present.\n",
> > - dmi_ver >> 8, dmi_ver & 0xFF);
> > + dmi_ver >> 16, (dmi_ver >> 8) & 0xFF);
> > } else {
> > smbios_entry_point_size = 15;
> > memcpy(smbios_entry_point, buf,
> > smbios_entry_point_size);
> > pr_info("Legacy DMI %d.%d present.\n",
> > - dmi_ver >> 8, dmi_ver & 0xFF);
> > + dmi_ver >> 16, (dmi_ver >> 8) & 0xFF);
> > }
> > - dmi_ver <<= 8;
> > dmi_format_ids(dmi_ids_string, sizeof(dmi_ids_string));
> > printk(KERN_DEBUG "DMI: %s\n", dmi_ids_string);
> > return 0;
Baaah. This was supposed to be fixed by my commit
5c1ac56b51b9d222ab202dec1ac2f4215346129d ("firmware: dmi_scan: Fix
ordering of product_uuid") but clearly I missed half of the required
changes. Should have tested...
The irony is that I clearly remember when reviewing Ivan's patches that
I did not like this part of the code. Quoting myself:
"I understand this was the easiest way to implement the change, but I'm
not really comfortable with dmi_ver having different formats for
different parts of the code. This is rather error prone for future
changes, even if the code is currently correct."
Even though I was wrong when claiming that the code was "currently
correct", I should have listened to my gut feeling back then and asked
for a different implementation.
Anyway... Thanks Andrea, applied with the missing "Fixes:" markers
added. I'll send to Linus soon.
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-06 13:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-22 13:53 [PATCH 0/1] dmi_scan: uuid: fix endianess for smbios >= 0x206 Andrea Arcangeli
2015-12-22 13:53 ` [PATCH 1/1] " Andrea Arcangeli
2015-12-22 15:17 ` Matt Fleming
2016-01-06 13:01 ` Jean Delvare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox