From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) by mx.groups.io with SMTP id smtpd.web08.625.1659161876704010576 for ; Fri, 29 Jul 2022 23:17:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PH4155zZ; spf=pass (domain: gmail.com, ip: 209.85.210.42, mailfrom: ammrat13@gmail.com) Received: by mail-ot1-f42.google.com with SMTP id k25-20020a056830169900b0061c6f68f451so4665334otr.9 for ; Fri, 29 Jul 2022 23:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jwPwRliAX+Qasvs84IQRNZ5p6uLQCu+YfuhQKaZjIXo=; b=PH4155zZqcPHYI9PwwzSsL1o5MHl1fiXazC1qSgdH+vAHMp+pUjvzqnPC5LQHfBKWy HhZX/4V8a5fl81zGwn9fvu2IhqSXCodd93sbaEaYTBfubEIgwZHrx5cerUeUyB0nXyJQ 1o888zsYoRkwVk6v/LbgJF7AdE326Yf0R7GT9EqicJxrbpQJQKZvP3RtbQ8wjH6HnrSk 71olF0buuPJFaiuCMoPYbyNnL6q+sp/fLTr6xEl2rMc/D9iAsMtrQwZvUGZbVPPiEleD YY/8qofk/PVZNVDMpuQEOesHolmCPd9+nI5pw4MgI2A0BUiRFY11qnrLS8b1z1lXXg2M eaGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jwPwRliAX+Qasvs84IQRNZ5p6uLQCu+YfuhQKaZjIXo=; b=6nl/1e5azZgih8kYJayKA2OEPuQiMs/piqpss40NhZyReMmtU20vJpUnpeWGay9nEU E5AJtQKKd9i5sTyCvWH+fzVqKD2H/mBchYzU2ze/9eH7IEr8rBJmKAw2x2qJAr10j7XX Ot3Bq/GswXQiCdEFreYVykDBnORf9rkGpC73Olx45xKwR31zeD3pQ09WzMdISSwMSvW2 P9P8ux6bBvFasnaQKXF7Lz6mbDuhuP5Ql3y7rCBSuz7MwhuIcBNax/3+CHe5e8Ippr5K BCqt4O98xRZ7/IaoyElMWZ5lrfNq9toPVojf24ILP7ygbm1IkslgbUUa3CD1B3HOYkHz weZA== X-Gm-Message-State: AJIora/xh9Gm47ODs7JUO548h+2FJhJ0gVyVfnwDpPyOG1Xqj5vHNe8H 7AzoJPI4Bls+8gPGz8h7m1OhQBq4y+w= X-Google-Smtp-Source: AGRyM1u03o7T9h8jzukc1SNklptpTIsj6eyZp6wxjnYJy8Rnm9wXO7BOmSMzIyqc1kBfRDyP0EcnKQ== X-Received: by 2002:a9d:6f01:0:b0:61c:b224:e7c9 with SMTP id n1-20020a9d6f01000000b0061cb224e7c9mr2748044otq.245.1659161875856; Fri, 29 Jul 2022 23:17:55 -0700 (PDT) Return-Path: Received: from archPC.hsd1.tx.comcast.net ([76.31.233.245]) by smtp.gmail.com with ESMTPSA id j8-20020a9d7d88000000b0061c3753c30dsm1592914otn.17.2022.07.29.23.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 23:17:55 -0700 (PDT) From: "Ammar Ratnani" To: devel@edk2.groups.io Cc: Ammar Ratnani Subject: [PATCH] OvmfPkg/SmbiosPlatformDxe: Always add BIOS Information structure Date: Sat, 30 Jul 2022 02:17:36 -0400 Message-Id: <9fd37a04bed1f8e0f7cfd0882d54ff17ff198af5.1659161548.git.ammrat13@gmail.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable If OVMF is not running on Cloud Hypervisor nor QEMU, previously no SMBIOS structures would be registered with the EFI_SMBIOS_PROTOCOL. This patch instead registers the default BIOS Information (Type 0) structure, defined as mOvmfDefaultType0 in SmbiosPlatformDxe.c. This change appeases (at least) the Windows Deployment Services client, which requires some SMBIOS data to be present. Signed-off-by: Ammar Ratnani --- OvmfPkg/SmbiosPlatformDxe/EntryPoint.c | 11 ++++ OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 59 +++++++++++-------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c b/OvmfPkg/SmbiosPlatfor= mDxe/EntryPoint.c index e55d135504..4f82cf5da8 100644 --- a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c +++ b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c @@ -48,5 +48,16 @@ SmbiosTablePublishEntry ( }=0D }=0D =0D + //=0D + // If Status still reads EFI_NOT_FOUND, either there are no drivers=0D + // implementing EFI_SMBIOS_PROTOCOL, or none of the above codepaths ran.= In=0D + // the second case, call InstallAllStructures with NULL so that the defa= ult=0D + // Type 0 (BIOS Information) structure is installed. In the first case,= =0D + // calling InstallAllStructures is harmless because it'll fail immediate= ly.=0D + //=0D + if (Status =3D=3D EFI_NOT_FOUND) {=0D + Status =3D InstallAllStructures (NULL);=0D + }=0D +=0D return Status;=0D }=0D diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/Smbios= PlatformDxe/SmbiosPlatformDxe.c index 94249d3ff1..e575a5f141 100644 --- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c +++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c @@ -93,12 +93,17 @@ SmbiosTableLength ( /**=0D Install all structures from the given SMBIOS structures block=0D =0D + Notice that the SMBIOS table address is optional. If it's not provided, = this=0D + function will function as if the first structure encountered is an=0D + End-of-Table (Type 127). Importantly, in that case it will still install= =0D + mOvmfDefaultType0.=0D +=0D @param TableAddress SMBIOS tables starting address=0D =0D **/=0D EFI_STATUS=0D InstallAllStructures (=0D - IN UINT8 *TableAddress=0D + IN UINT8 *TableAddress OPTIONAL=0D )=0D {=0D EFI_SMBIOS_PROTOCOL *Smbios;=0D @@ -119,34 +124,36 @@ InstallAllStructures ( return Status;=0D }=0D =0D - SmbiosTable.Raw =3D TableAddress;=0D - if (SmbiosTable.Raw =3D=3D NULL) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D NeedSmbiosType0 =3D TRUE;=0D =0D - while (SmbiosTable.Hdr->Type !=3D 127) {=0D - //=0D - // Log the SMBIOS data for this structure=0D - //=0D - SmbiosHandle =3D SmbiosTable.Hdr->Handle;=0D - Status =3D Smbios->Add (=0D - Smbios,=0D - NULL,=0D - &SmbiosHandle,=0D - (EFI_SMBIOS_TABLE_HEADER *)SmbiosTable.Raw=0D - );=0D - ASSERT_EFI_ERROR (Status);=0D -=0D - if (SmbiosTable.Hdr->Type =3D=3D 0) {=0D - NeedSmbiosType0 =3D FALSE;=0D + //=0D + // If the TableAddress is NULL, that's not an error. Just don't try to l= oop=0D + // over it.=0D + //=0D + SmbiosTable.Raw =3D TableAddress;=0D + if (SmbiosTable.Raw !=3D NULL) {=0D + while (SmbiosTable.Hdr->Type !=3D 127) {=0D + //=0D + // Log the SMBIOS data for this structure=0D + //=0D + SmbiosHandle =3D SmbiosTable.Hdr->Handle;=0D + Status =3D Smbios->Add (=0D + Smbios,=0D + NULL,=0D + &SmbiosHandle,=0D + (EFI_SMBIOS_TABLE_HEADER *)SmbiosTable.Raw= =0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + if (SmbiosTable.Hdr->Type =3D=3D 0) {=0D + NeedSmbiosType0 =3D FALSE;=0D + }=0D +=0D + //=0D + // Get the next structure address=0D + //=0D + SmbiosTable.Raw =3D (UINT8 *)(SmbiosTable.Raw + SmbiosTableLength (S= mbiosTable));=0D }=0D -=0D - //=0D - // Get the next structure address=0D - //=0D - SmbiosTable.Raw =3D (UINT8 *)(SmbiosTable.Raw + SmbiosTableLength (Smb= iosTable));=0D }=0D =0D if (NeedSmbiosType0) {=0D --=20 2.37.1