From nobody Tue Apr 23 10:17:54 2024 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=1558142395; cv=none; d=zoho.com; s=zohoarc; b=cvCS8qcNoSIdi0doUaUllCNE6Ec0n5KtbmSbKhyCMHzWYh05NpbtJyr05GG536b6q/X7BK8VWLp53FUOtTO+id0CulGW2371EHX9v/5ulHF0e6Kt7+Pn8C67fegp+oTU44JORYUAd3JcLQO6phOmRDtiFse1HE+oTGsW7NsJnWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558142395; 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=FvWUTE7xdtSE705roh2w2f/ZXYXnnuaTMhGYPU01eheNCgVOhfCslk2Fbfaxz8e+Y8w/CCscqCi4Y2hydGIgNCWALswYJsZZlpm868rqgXPoZMrQF46dA/2b2YHeCac8stCeqzbmXuO/EwtO0KFU65bEf3ZTexjXTH6dNX/MYl4= 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 1558142395386134.1443064095796; Fri, 17 May 2019 18:19:55 -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 1FB4012E2E72; Sat, 18 May 2019 00:53:21 +0000 (UTC) Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by coreboot.org (Postfix) with ESMTP id 5A01412E2E6F for ; Sat, 18 May 2019 00:53:12 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4HKnIYT183164; Fri, 17 May 2019 20:57:49 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2sdntuc2qa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 May 2019 20:57:48 +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 x4HKvirj020337; Fri, 17 May 2019 20:57:48 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2shh5h9dm6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 May 2019 20:57:48 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4HKvlLF011231; Fri, 17 May 2019 20:57:47 GMT Received: from nexus.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 17 May 2019 20:57:47 +0000 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=NHwxRxH44HwMBHTaRMd4VW+gjm5A63MLN0L0wpbhk0/p4r+AFd+7mxrq+3D6hLs0hHdo r0oxzandRtygVQib5yzh4tQhrLerEjJzcSYr1g6kGtLdrev1Mqd/LaFUF0eSU3VC0sFw vizP0W5xlWouKGbi7jWRcNB+H970uQshpE4/cG/EZs7Ew4CSsvHksCToiHMl9tO/on0J OaDoCoEQ5Sg5pXVMGu/LNvQfFMLj0KdPpF4ecJK4hP8YebV+0Xq963VLd1szHDwMveKE dCdVw6mAV6p23LYMCqWh/iUNgK20UNQDm8IMOz6gFWqOEVz1DD/bRLK0If+S5tYV5bXv zA== From: Sam Eiderman To: seabios@seabios.org, kraxel@redhat.com, kevin@koconnor.net Date: Fri, 17 May 2019 23:57:23 +0300 Message-Id: <20190517205726.34703-4-shmuel.eiderman@oracle.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20190517205726.34703-1-shmuel.eiderman@oracle.com> References: <20190517205726.34703-1-shmuel.eiderman@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9260 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-1905170124 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9260 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-1905170124 Message-ID-Hash: PF2HHXKIDU2SET7Y6VPXX365NNRCZ22M X-Message-ID-Hash: PF2HHXKIDU2SET7Y6VPXX365NNRCZ22M 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 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 X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org 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