From nobody Tue Mar 3 06:34:31 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1558208553; cv=none; d=zoho.com; s=zohoarc; b=Nba6018hhKYlF03Y741TPsKAwEZDJ6WYPZMJaLIqcJrWOfYBe49BJerfffyoAeYXF94gR3+S/BwQJtg7CR7dnZ6Z/Wmh8dgBoIXZ3l8nv2nqz0jrPMitcbUx6aXa+OzuI4csoaqaDwVjo3Q5DbpsEPTeLDAjxaiAKQJCEceAbZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558208553; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=+PZNc9I1AH2Zs37rqL50u/v7t8H8tQjS7s18B6yXJGE=; b=GKeqy8FydvgxP4gcJR+QNFV/kc2TrIMPkQXMVrnafc2uekASTJITCyXuDJw6Onet80DpB9JYZ9X8icekkyf0yLEf5uDyrJ4QIz785Jw+yYyGD3swj6XdU76W/ODK0v0HNgErEgKEB3tuNJSfiWATcq5hGDONeGc6v2UyFULtAHc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1558208553151954.1877885658462; Sat, 18 May 2019 12:42:33 -0700 (PDT) Received: from [192.168.203.99] (mailu_mailman-core_1.mailu_default [192.168.203.99]) by coreboot.org (Postfix) with ESMTP id 0506012E2E84; Sat, 18 May 2019 19:42:27 +0000 (UTC) Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by coreboot.org (Postfix) with ESMTP id C242212E111A for ; Sat, 18 May 2019 19:42:16 +0000 (UTC) Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4IG8rle115911; Sat, 18 May 2019 16:16:58 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 2sj7jd9h6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 18 May 2019 16:16:58 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4IGG2VM003657; Sat, 18 May 2019 16:16:57 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2sj9chn5ha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 18 May 2019 16:16:57 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4IGGvkA025606; Sat, 18 May 2019 16:16:57 GMT Received: from nexus.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 18 May 2019 09:16:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=IkHgpKgcXflQ7DfCPUACNWMCGlq6rcLC5YIqr5sE43Q=; b=2QO/MOF9MrClQJdsrJQy51RihlNFJPjhTTFfePRspnB20oHy54AuYImabYXGWU0l2ys7 X+FfRM0TPo6BKuJi9khSbrIxhceAXFZwKcc4iYTtS6zgARoaWkxmCN9DK+vE1DpULvfH HvNZWjUd0CjSkcdOdKksHLIOohRtXOGYTjgU5rXT7K6450nw2LQh3aNmVxuxBbaOHX/D zysFUA2HLn8V+Vyj7UHTDhRvlfTxU268MXdsXIXF7ho5B+DR8r+OGB5Egmh+yj1RxOBQ Li2MeGgmEcO872sflu8fF4Eb9y9/8X3/tNXQJb1/i99+KYq71uZQnzaR+MWmadwYAd0v OQ== From: Sam Eiderman To: seabios@seabios.org, kraxel@redhat.com, kevin@koconnor.net Date: Sat, 18 May 2019 19:15:39 +0300 Message-Id: <20190518161542.12662-4-shmuel.eiderman@oracle.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20190518161542.12662-1-shmuel.eiderman@oracle.com> References: <20190518161542.12662-1-shmuel.eiderman@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9261 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905180117 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9261 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905180117 Message-ID-Hash: WJHO56DPWQZHLC2KO7JYYWTO5B5OTIYU X-Message-ID-Hash: WJHO56DPWQZHLC2KO7JYYWTO5B5OTIYU X-MailFrom: shmuel.eiderman@oracle.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: arbel.moshe@oracle.com, konrad.wilk@oracle.com X-Mailman-Version: 3.2.2 Precedence: list Subject: [SeaBIOS] [PATCH v2 3/6] bios_date: Change BiosDate to SMBIOS bios date List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org X-Spamd-Bar: / X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liran Alon Windows kernel extracts various BIOS information at boot-time. The method it uses to extract SystemBiosDate is very hueristic. It is done by nt!CmpGetBiosDate(). nt!CmpGetBiosDate() works by scanning all BIOS memory from 0xF0000 to 0xFFFF5 (FSEG) in search for a string which is formatted like a date. It then chooses the string which represents the most recent date, and writes it to: HKLM/HARDWARE/DESCRIPTION/System SystemBiosDate This date should usually be BiosDate located at FSEG(0xFFF5). In some cases when the SMBIOS tables are small enough (both in legacy and non-legacy mode) - These tables are allocated in FSEG instead of high-mem, specifically Type0->release_date string which might cause SystemBiosDate to change - depending on its value. This leads to an inconsistent behaviour that depends on the SMBIOS table sizes. We fix this inconsistency by changing BiosDate to the same value provided by SMBIOS, regardless whether SMBIOS tables reside in FSEG or high-mem. For reference implementation of nt!CmpGetBiosDate(), see ReactOS: https://doxygen.reactos.org/d5/dd2/i386_2cmhardwr_8c.html Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Signed-off-by: Liran Alon --- src/fw/biostables.c | 36 ++++++++++++++++++++++++++++++++++++ src/fw/smbios.c | 20 +++++++++++++++++++- src/util.h | 1 + 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/fw/biostables.c b/src/fw/biostables.c index 546e83c6..90bb3b92 100644 --- a/src/fw/biostables.c +++ b/src/fw/biostables.c @@ -268,6 +268,38 @@ smbios_next(struct smbios_entry_point *smbios, void *p= rev) return prev; } =20 +// Get string from the smbios table. +void * +smbios_get_str(struct smbios_entry_point *smbios, void *offset, u8 n) +{ + if (!smbios || !offset || n =3D=3D 0) + return NULL; + void *start =3D (void*)smbios->structure_table_address; + void *end =3D start + smbios->structure_table_length; + void *prev =3D NULL; + struct smbios_structure_header *hdr =3D offset; + + if (offset + sizeof(*hdr) > end) + return NULL; + + offset +=3D hdr->length; + + while (n > 0) { + prev =3D offset; + while (*(u8*)offset) { + if (offset + 3 > end) + return NULL; /* not enough space for "\0\0" */ + offset++; + } + if (prev =3D=3D offset) + return NULL; /* reached end of table */ + n--; + offset++; + } + + return prev; +} + struct smbios_entry_point *SMBiosAddr; =20 void @@ -409,6 +441,7 @@ smbios_romfile_setup(void) struct romfile_s *f_tables =3D romfile_find("etc/smbios/smbios-tables"= ); struct smbios_entry_point ep; struct smbios_type_0 *t0; + char *release_date; u16 qtables_len, need_t0 =3D 1; u8 *qtables, *tables; =20 @@ -432,6 +465,9 @@ smbios_romfile_setup(void) for (t0 =3D smbios_next(&ep, NULL); t0; t0 =3D smbios_next(&ep, t0)) if (t0->header.type =3D=3D 0) { need_t0 =3D 0; + /* Sync BIOS hardcoded date with the SMBIOS provided one */ + release_date =3D smbios_get_str(&ep, t0, t0->bios_release_date= _str); + smbios_update_bios_date(release_date); break; } =20 diff --git a/src/fw/smbios.c b/src/fw/smbios.c index 96104714..7cb02dba 100644 --- a/src/fw/smbios.c +++ b/src/fw/smbios.c @@ -160,12 +160,26 @@ get_external(int type, char **p, unsigned *nr_structs, } \ } while (0) =20 +void +smbios_update_bios_date(const char *release_date) +{ + if (!release_date) + return; + if (strlen(release_date) =3D=3D sizeof("mm/dd/yyyy") - 1) { + memcpy(BiosDate, release_date, sizeof("mm/dd/") - 1); + memcpy(BiosDate + sizeof("mm/dd/") - 1, + release_date + sizeof("mm/dd/yy") - 1, + sizeof("yy") - 1); + } +} + /* Type 0 -- BIOS Information */ static void * smbios_init_type_0(void *start) { struct smbios_type_0 *p =3D (struct smbios_type_0 *)start; char *end =3D (char *)start + sizeof(struct smbios_type_0); + char *release_date; size_t size; int str_index =3D 0; =20 @@ -178,7 +192,11 @@ smbios_init_type_0(void *start) =20 p->bios_starting_address_segment =3D 0xe800; =20 - load_str_field_with_default(0, bios_release_date_str, BIOS_DATE); + /* Sync BIOS hardcoded date with the SMBIOS provided one */ + release_date =3D end; + load_str_field_with_default(0, bios_release_date_str, BiosDate); + if (p->bios_release_date_str) + smbios_update_bios_date(release_date); =20 p->bios_rom_size =3D 0; /* FIXME */ =20 diff --git a/src/util.h b/src/util.h index 68ba848d..81cddbbd 100644 --- a/src/util.h +++ b/src/util.h @@ -84,6 +84,7 @@ void copy_smbios(void *pos); void display_uuid(void); void copy_table(void *pos); void smbios_setup(void); +void smbios_update_bios_date(const char *release_date); =20 // fw/coreboot.c extern const char *CBvendor, *CBpart; --=20 2.13.3 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org