From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.1504.1595269016756613853 for ; Mon, 20 Jul 2020 11:16:56 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: samer.el-haj-mahmoud@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B537B113E; Mon, 20 Jul 2020 11:16:55 -0700 (PDT) Received: from U203705.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 750BF3F66F; Mon, 20 Jul 2020 11:16:55 -0700 (PDT) From: "Samer El-Haj-Mahmoud" To: devel@edk2.groups.io Cc: Leif Lindholm , Pete Batard , Andrei Warkentin , Ard Biesheuvel Subject: [edk2-platform][PATCH v1 1/7] Platforms/RaspberryPi: Fix NULL AssetTag in SMBIOS Date: Mon, 20 Jul 2020 14:16:40 -0400 Message-Id: <20200720181646.2891-2-Samer.El-Haj-Mahmoud@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200720181646.2891-1-Samer.El-Haj-Mahmoud@arm.com> References: <20200720181646.2891-1-Samer.El-Haj-Mahmoud@arm.com> Commit 6d4fed696d004a6aeb795369aa38d4ce1d39f308 added support for reporting AssetTag in RPi SMBIOS Types 2 and 3. The default AssetTag is an empty string. SMBIOS does not allow empty strings to be referenced from the corresponding string field. This caused breakage in parsing SMBIOS Types 2 and 3 fields that follow the AssetTag field. The issue caused an FWTS test failure, as reported in: https://github.com/pftf/RPi4/issues/75 The fix is to detect if no AssetTag is set in the UEFI variable, and if so, change the AssetTag SMBIOS field to an empty blank space. Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Signed-off-by: Samer El-Haj-Mahmoud --- Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c index d5fb843d43ce..6eef66f125f8 100644 --- a/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c +++ b/Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c @@ -793,7 +793,13 @@ BoardInfoUpdateSmbiosType2 ( if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Failed to get Asset Tag: %r\n", Status)); } - UnicodeStrToAsciiStrS(AssetTagVar, mChassisAssetTag, sizeof(mChassisAssetTag)); + + if (AssetTagVar[0] == L'\0') { + // SMBIOS referenced strings cannot be NULL. If no AssetTag is set, default to a blank space. + UnicodeStrToAsciiStrS(L" ", mChassisAssetTag, sizeof(mChassisAssetTag)); + } else { + UnicodeStrToAsciiStrS(AssetTagVar, mChassisAssetTag, sizeof(mChassisAssetTag)); + } DEBUG ((DEBUG_INFO, "System Asset Tag : %a\n", mChassisAssetTag)); LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBoardInfoType2, mBoardInfoType2Strings, NULL); -- 2.17.1