From MAILER-DAEMON Fri Oct 07 04:00:25 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1bsQ4v-00011l-Oj
	for mharc-dmidecode-devel@gnu.org; Fri, 07 Oct 2016 04:00:25 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:37532)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1bsQ4s-00011W-T9
	for dmidecode-devel@nongnu.org; Fri, 07 Oct 2016 04:00:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1bsQ4n-0003Yj-VR
	for dmidecode-devel@nongnu.org; Fri, 07 Oct 2016 04:00:22 -0400
Received: from mx2.suse.de ([195.135.220.15]:45503)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1bsQ4n-0003Rh-NY
	for dmidecode-devel@nongnu.org; Fri, 07 Oct 2016 04:00:17 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx2.suse.de (Postfix) with ESMTP id C5B7EAC29;
	Fri,  7 Oct 2016 08:00:14 +0000 (UTC)
Date: Fri, 7 Oct 2016 10:00:13 +0200
From: Jean Delvare <jdelvare@suse.de>
To: Petr Oros <poros@redhat.com>
Cc: dmidecode-devel@nongnu.org
Message-ID: <20161007100013.1b42533e@endymion>
In-Reply-To: <1475745344.2882.1.camel@redhat.com>
References: <1475745344.2882.1.camel@redhat.com>
Organization: SUSE Linux
X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.31; x86_64-suse-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic]
X-Received-From: 195.135.220.15
Subject: Re: [dmidecode] [PATCH] Prefer SMBIOS3 when read entry point from
 efi systab
X-BeenThere: dmidecode-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <dmidecode-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/dmidecode-devel>, 
	<mailto:dmidecode-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/dmidecode-devel/>
List-Post: <mailto:dmidecode-devel@nongnu.org>
List-Help: <mailto:dmidecode-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/dmidecode-devel>,
	<mailto:dmidecode-devel-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Fri, 07 Oct 2016 08:00:24 -0000

Hi Petr,

Please Cc dmidecode patches to the dmidecode-devel list.

On Thu, 06 Oct 2016 11:15:44 +0200, Petr Oros wrote:
> From 61c2e2b0c3b3c1e103b6648c9450f4c2e8efec52 Mon Sep 17 00:00:00 2001
> From: Petr Oros <poros@redhat.com>
> Date: Thu, 6 Oct 2016 10:48:07 +0200
> Subject: [PATCH] Prefer SMBIOS3 when read entry point from efi systab
> 
>   According to the DMTF SMBIOS reference spec v3.0.0, it is
>   allowed to define both the 64-bit entry point (smbios3) and
>   the 32-bit entry point (smbios), in which case they should
>   either both point to the same SMBIOS structure table, or the
>   table pointed to by the 64-bit entry point should contain a
>   superset of the table contents pointed to by the 32-bit entry
>   point (section 5.2)
> 
>   In this case /sys/firmware/efi/systab can contain:
> 
>     ACPI20=0x7cefe014
>     ACPI=0x7cefe000
>     SMBIOS=0x00dead00
>     SMBIOS3=0xffdeadff

This is a very interesting address :-D

>   But for this case, processing end when found
>   first record and dmidecode fall back to older
>   table and ignore newer version. With this patch,
>   processing continue and SMBIOS accept only
>   if have not SMBIOS3 version.

This was fixed over a year ago in the kernel:

Author: Jean Delvare <jdelvare@suse.de>
Date:   Thu Apr 30 15:23:05 2015 +0200

    efi: dmi: List SMBIOS3 table before SMBIOS table

I suggest you simply backport this fix to your kernel.

> 
>   Testing: tested on fake /sys/firmware/efi/systab
>   ./dmidecode
>   # dmidecode 3.0
>   # SMBIOS entry point at 0x00dead00
>   # SMBIOS3 entry point at 0xffdeadff
>   Found SMBIOS entry point in EFI, reading table from /dev/mem at 0xffdeadff.
> 
> Signed-off-by: Petr Oros <poros@redhat.com>
> ---
>  dmidecode.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/dmidecode.c b/dmidecode.c
> index 3993592..44f1195 100644
> --- a/dmidecode.c
> +++ b/dmidecode.c
> @@ -4755,14 +4755,13 @@ static int address_from_efi(off_t *address)
>  		char *addrp = strchr(linebuf, '=');
>  		*(addrp++) = '\0';
>  		if (strcmp(linebuf, "SMBIOS3") == 0
> -		 || strcmp(linebuf, "SMBIOS") == 0)
> +		 || (strcmp(linebuf, "SMBIOS") == 0 && *address == 0))
>  		{
>  			*address = strtoull(addrp, NULL, 0);
>  			if (!(opt.flags & FLAG_QUIET))
>  				printf("# %s entry point at 0x%08llx\n",
>  				       linebuf, (unsigned long long)*address);
>  			ret = 0;
> -			break;
>  		}
>  	}
>  	if (fclose(efi_systab) != 0)
> @@ -4895,8 +4894,8 @@ int main(int argc, char * const argv[])
>  	}
>  
>  	if (!(opt.flags & FLAG_QUIET))
> -		printf("Found SMBIOS entry point in EFI, reading table from %s.\n",
> -		       opt.devmem);
> +		printf("Found SMBIOS entry point in EFI, reading table from %s at 0x%08lx.\n",
> +		       opt.devmem, fp);
>  	if ((buf = mem_chunk(fp, 0x20, opt.devmem)) == NULL)
>  	{
>  		ret = 1;


-- 
Jean Delvare
SUSE L3 Support


From MAILER-DAEMON Fri Oct 07 04:23:20 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1bsQR6-0007ga-Du
	for mharc-dmidecode-devel@gnu.org; Fri, 07 Oct 2016 04:23:20 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48433)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1bsQR3-0007dc-2b
	for dmidecode-devel@nongnu.org; Fri, 07 Oct 2016 04:23:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1bsQQz-0000Iz-QP
	for dmidecode-devel@nongnu.org; Fri, 07 Oct 2016 04:23:15 -0400
Received: from mx2.suse.de ([195.135.220.15]:47030)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1bsQQz-0000Ha-Iq
	for dmidecode-devel@nongnu.org; Fri, 07 Oct 2016 04:23:13 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx2.suse.de (Postfix) with ESMTP id 2E16DAC29;
	Fri,  7 Oct 2016 08:23:12 +0000 (UTC)
Date: Fri, 7 Oct 2016 10:23:11 +0200
From: Jean Delvare <jdelvare@suse.de>
To: Petr Oros <poros@redhat.com>
Cc: dmidecode-devel@nongnu.org
Message-ID: <20161007102311.210a9cb4@endymion>
In-Reply-To: <1475827886.4450.4.camel@redhat.com>
References: <1475745344.2882.1.camel@redhat.com>
	<20161007100013.1b42533e@endymion>
	<1475827886.4450.4.camel@redhat.com>
Organization: SUSE Linux
X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.31; x86_64-suse-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic]
X-Received-From: 195.135.220.15
Subject: Re: [dmidecode] [PATCH] Prefer SMBIOS3 when read entry point from
 efi systab
X-BeenThere: dmidecode-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <dmidecode-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/dmidecode-devel>, 
	<mailto:dmidecode-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/dmidecode-devel/>
List-Post: <mailto:dmidecode-devel@nongnu.org>
List-Help: <mailto:dmidecode-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/dmidecode-devel>,
	<mailto:dmidecode-devel-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Fri, 07 Oct 2016 08:23:18 -0000

On Fri, 07 Oct 2016 10:11:26 +0200, Petr Oros wrote:
> Jean Delvare p=C3=AD=C5=A1e v Fri 07. 10. 2016 v 10:00 +0200:
> > Hi Petr,
> >=20
> > Please Cc dmidecode patches to the dmidecode-devel list.
> Ok
>=20
> > On Thu, 06 Oct 2016 11:15:44 +0200, Petr Oros wrote:
> > >=20
> > > From 61c2e2b0c3b3c1e103b6648c9450f4c2e8efec52 Mon Sep 17 00:00:00
> > > 2001
> > > From: Petr Oros <poros@redhat.com>
> > > Date: Thu, 6 Oct 2016 10:48:07 +0200
> > > Subject: [PATCH] Prefer SMBIOS3 when read entry point from efi
> > > systab
> > >=20
> > > =C2=A0 According to the DMTF SMBIOS reference spec v3.0.0, it is
> > > =C2=A0 allowed to define both the 64-bit entry point (smbios3) and
> > > =C2=A0 the 32-bit entry point (smbios), in which case they should
> > > =C2=A0 either both point to the same SMBIOS structure table, or the
> > > =C2=A0 table pointed to by the 64-bit entry point should contain a
> > > =C2=A0 superset of the table contents pointed to by the 32-bit entry
> > > =C2=A0 point (section 5.2)
> > >=20
> > > =C2=A0 In this case /sys/firmware/efi/systab can contain:
> > >=20
> > > =C2=A0=C2=A0=C2=A0=C2=A0ACPI20=3D0x7cefe014
> > > =C2=A0=C2=A0=C2=A0=C2=A0ACPI=3D0x7cefe000
> > > =C2=A0=C2=A0=C2=A0=C2=A0SMBIOS=3D0x00dead00
> > > =C2=A0=C2=A0=C2=A0=C2=A0SMBIOS3=3D0xffdeadff
> >=20
> > This is a very interesting address :-D
> :)
> > >=20
> > > =C2=A0 But for this case, processing end when found
> > > =C2=A0 first record and dmidecode fall back to older
> > > =C2=A0 table and ignore newer version. With this patch,
> > > =C2=A0 processing continue and SMBIOS accept only
> > > =C2=A0 if have not SMBIOS3 version.
> >=20
> > This was fixed over a year ago in the kernel:
> >=20
> > Author: Jean Delvare <jdelvare@suse.de>
> > Date:=C2=A0=C2=A0=C2=A0Thu Apr 30 15:23:05 2015 +0200
> >=20
> > =C2=A0=C2=A0=C2=A0=C2=A0efi: dmi: List SMBIOS3 table before SMBIOS table
> >=20
> > I suggest you simply backport this fix to your kernel.
> OK, it will be better solution.
> Note: From the other side, with this patch dmidecode will work
> everywhere ;)

Correct, but this is a more expensive solution, because you have to
read the whole file even if you have found an SMBIOS entry point. Not
that the file is so large that it would really matter... But I see no
reason to make the code slower and more complex if we don't have to,
especially when only 3 kernel versions have the entries in the wrong
order (v3.19 to v4.1.)

--=20
Jean Delvare
SUSE L3 Support


