[edk2-devel] [edk2-platforms] [PATCH] KabyLakeSiliconPkg: Bitmask comparison logic bug

Nate DeSimone posted 1 patch 3 years, 10 months ago
Failed in applying to current master (apply log)
.../KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c   | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2-devel] [edk2-platforms] [PATCH] KabyLakeSiliconPkg: Bitmask comparison logic bug
Posted by Nate DeSimone 3 years, 10 months ago
(Cpptv & B_PCH_SPI_SFDPX_VSCCX_CPPTV) can only evaluate to
two possible values, 0x0 or B_PCH_SPI_SFDPX_VSCCX_CPPTV
(aka BIT31). The current comparison to 0x1 will always fail.

Fixed the if statement to compare to B_PCH_SPI_SFDPX_VSCCX_CPPTV.

Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
---
 .../KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c
index a255e7e514..467e133cd5 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c
@@ -167,7 +167,7 @@ CheckBootFirmwareMediaProtection (
       FreePool (HstiErrorString);
     }
   } else {
-    if ((Cpptv & B_PCH_SPI_SFDPX_VSCCX_CPPTV) == 1) {
+    if ((Cpptv & B_PCH_SPI_SFDPX_VSCCX_CPPTV) == B_PCH_SPI_SFDPX_VSCCX_CPPTV) {
 
       HstiErrorString = BuildHstiErrorString (HSTI_BYTE0_BOOT_FIRMWARE_MEDIA_PROTECTION_ERROR_CODE_6 ,HSTI_SPI_FLASH_CONFIGURATION, HSTI_BYTE0_BOOT_FIRMWARE_MEDIA_PROTECTION_ERROR_STRING_6);
       Status = HstiLibAppendErrorString (
-- 
2.20.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#60999): https://edk2.groups.io/g/devel/message/60999
Mute This Topic: https://groups.io/mt/74787555/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [edk2-platforms] [PATCH] KabyLakeSiliconPkg: Bitmask comparison logic bug
Posted by Chaganty, Rangasai V 3 years, 10 months ago
Good catch. 
Reviewed-by: Sai Chaganty <rangasai.v.chaganty@intel.com>

-----Original Message-----
From: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com> 
Sent: Tuesday, June 09, 2020 5:31 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>
Subject: [edk2-platforms] [PATCH] KabyLakeSiliconPkg: Bitmask comparison logic bug

(Cpptv & B_PCH_SPI_SFDPX_VSCCX_CPPTV) can only evaluate to two possible values, 0x0 or B_PCH_SPI_SFDPX_VSCCX_CPPTV (aka BIT31). The current comparison to 0x1 will always fail.

Fixed the if statement to compare to B_PCH_SPI_SFDPX_VSCCX_CPPTV.

Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
---
 .../KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c
index a255e7e514..467e133cd5 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtect
+++ ion.c
@@ -167,7 +167,7 @@ CheckBootFirmwareMediaProtection (
       FreePool (HstiErrorString);
     }
   } else {
-    if ((Cpptv & B_PCH_SPI_SFDPX_VSCCX_CPPTV) == 1) {
+    if ((Cpptv & B_PCH_SPI_SFDPX_VSCCX_CPPTV) == 
+ B_PCH_SPI_SFDPX_VSCCX_CPPTV) {
 
       HstiErrorString = BuildHstiErrorString (HSTI_BYTE0_BOOT_FIRMWARE_MEDIA_PROTECTION_ERROR_CODE_6 ,HSTI_SPI_FLASH_CONFIGURATION, HSTI_BYTE0_BOOT_FIRMWARE_MEDIA_PROTECTION_ERROR_STRING_6);
       Status = HstiLibAppendErrorString (
--
2.20.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61110): https://edk2.groups.io/g/devel/message/61110
Mute This Topic: https://groups.io/mt/74787555/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [edk2-platforms] [PATCH] KabyLakeSiliconPkg: Bitmask comparison logic bug
Posted by Chiu, Chasel 3 years, 10 months ago
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

> -----Original Message-----
> From: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
> Sent: Wednesday, June 10, 2020 8:31 AM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Chaganty, Rangasai V
> <rangasai.v.chaganty@intel.com>
> Subject: [edk2-platforms] [PATCH] KabyLakeSiliconPkg: Bitmask comparison
> logic bug
> 
> (Cpptv & B_PCH_SPI_SFDPX_VSCCX_CPPTV) can only evaluate to two possible
> values, 0x0 or B_PCH_SPI_SFDPX_VSCCX_CPPTV (aka BIT31). The current
> comparison to 0x1 will always fail.
> 
> Fixed the if statement to compare to B_PCH_SPI_SFDPX_VSCCX_CPPTV.
> 
> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
> ---
>  .../KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c   | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git
> a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c
> b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c
> index a255e7e514..467e133cd5 100644
> ---
> a/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtection.c
> +++ b/Silicon/Intel/KabylakeSiliconPkg/Hsti/Dxe/BootFirmwareMediaProtect
> +++ ion.c
> @@ -167,7 +167,7 @@ CheckBootFirmwareMediaProtection (
>        FreePool (HstiErrorString);
>      }
>    } else {
> -    if ((Cpptv & B_PCH_SPI_SFDPX_VSCCX_CPPTV) == 1) {
> +    if ((Cpptv & B_PCH_SPI_SFDPX_VSCCX_CPPTV) ==
> + B_PCH_SPI_SFDPX_VSCCX_CPPTV) {
> 
>        HstiErrorString = BuildHstiErrorString
> (HSTI_BYTE0_BOOT_FIRMWARE_MEDIA_PROTECTION_ERROR_CODE_6 ,HSTI_
> SPI_FLASH_CONFIGURATION,
> HSTI_BYTE0_BOOT_FIRMWARE_MEDIA_PROTECTION_ERROR_STRING_6);
>        Status = HstiLibAppendErrorString (
> --
> 2.20.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61172): https://edk2.groups.io/g/devel/message/61172
Mute This Topic: https://groups.io/mt/74787555/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-