From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M9QrC-0005ry-NM for qemu-devel@nongnu.org; Wed, 27 May 2009 17:40:18 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M9Qr7-0005pr-Kf for qemu-devel@nongnu.org; Wed, 27 May 2009 17:40:17 -0400 Received: from [199.232.76.173] (port=42274 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9Qr7-0005pi-Ep for qemu-devel@nongnu.org; Wed, 27 May 2009 17:40:13 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:60415) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M9Qr7-00024W-2a for qemu-devel@nongnu.org; Wed, 27 May 2009 17:40:13 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e3.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n4RLZaHd021017 for ; Wed, 27 May 2009 17:35:36 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n4RLe93f184566 for ; Wed, 27 May 2009 17:40:09 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n4RLe9BW005439 for ; Wed, 27 May 2009 17:40:09 -0400 From: Beth Kon Date: Wed, 27 May 2009 17:42:05 -0400 Message-Id: <1243460525-25570-1-git-send-email-eak@us.ibm.com> Subject: [Qemu-devel] [PATCH] Correct SMBIOS handling of multiple tables List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: bochs-developers@lists.sourceforge.net, Beth Kon , alex.williamson@hp.com The current code prevents multiple entries of the same type table, as required, for example, by table type 4. Signed-off-by: Beth Kon diff --git a/bios/rombios32.c b/bios/rombios32.c index f861f81..43aa065 100644 --- a/bios/rombios32.c +++ b/bios/rombios32.c @@ -2146,6 +2146,10 @@ struct smbios_table { #define SMBIOS_FIELD_ENTRY 0 #define SMBIOS_TABLE_ENTRY 1 +#ifdef BX_QEMU + static uint64_t smbios_used_bitmap[4] = { 0 }; +#endif + static size_t smbios_load_field(int type, size_t offset, void *addr) { @@ -2496,14 +2500,9 @@ smbios_load_external(int type, char **p, unsigned *nr_structs, unsigned *max_struct_size) { #ifdef BX_QEMU - static uint64_t used_bitmap[4] = { 0 }; char *start = *p; int i; - /* Check if we've already reported these tables */ - if (used_bitmap[(type >> 6) & 0x3] & (1ULL << (type & 0x3f))) - return 1; - /* Don't introduce spurious end markers */ if (type == 127) return 0; @@ -2555,7 +2554,7 @@ smbios_load_external(int type, char **p, unsigned *nr_structs, } /* Mark that we've reported on this type */ - used_bitmap[(type >> 6) & 0x3] |= (1ULL << (type & 0x3f)); + smbios_used_bitmap[(type >> 6) & 0x3] |= (1ULL << (type & 0x3f)); return (start != *p); #else /* !BX_QEMU */ @@ -2612,6 +2611,9 @@ void smbios_init(void) add_struct(32, p); /* Add any remaining provided entries before the end marker */ for (i = 0; i < 256; i++) + /* Check if we've already reported these tables */ + if (smbios_used_bitmap[(i >> 6) & 0x3] & (1ULL << (i & 0x3f))) + continue; smbios_load_external(i, &p, &nr_structs, &max_struct_size); add_struct(127, p);