[edk2-devel] [PATCH v2] MinPlatformPkg/SecFspWrapperPlatformSecLib: Change TopOfTemporaryRam type

Zhang, Shenglei posted 1 patch 4 years, 7 months ago
Failed in applying to current master (apply log)
.../SecFspWrapperPlatformSecLib/SecGetPerformance.c       | 8 ++++----
.../SecFspWrapperPlatformSecLib/SecPlatformInformation.c  | 6 +++---
2 files changed, 7 insertions(+), 7 deletions(-)
[edk2-devel] [PATCH v2] MinPlatformPkg/SecFspWrapperPlatformSecLib: Change TopOfTemporaryRam type
Posted by Zhang, Shenglei 4 years, 7 months ago
Update the type of TopOfTemporaryRam from UINT32 to UINTN.
This change is intended to support X64 build scenarios.
The original code(line 64) may cast the overfloewed result
produced by "(TopOfTemporaryRam - sizeof (UINT32))"from
32bit to 64bit.

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
v2: As TopOfTemporaryRam is defined as UINTN in v2, remove
    all the related casting operations which exist in v1 patch. 

 .../SecFspWrapperPlatformSecLib/SecGetPerformance.c       | 8 ++++----
 .../SecFspWrapperPlatformSecLib/SecPlatformInformation.c  | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c
index c4eeb2b1..8535ae04 100644
--- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c
@@ -41,7 +41,7 @@ SecGetPerformance (
 {
   UINT32      Size;
   UINT32      Count;
-  UINT32      TopOfTemporaryRam;
+  UINTN       TopOfTemporaryRam;
   UINT64      Ticker;
   VOID        *TopOfTemporaryRamPpi;
   EFI_STATUS  Status;
@@ -77,12 +77,12 @@ SecGetPerformance (
   // |  TSC[31:00]  |
   // |--------------|
   //
-  TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof(UINT32);
+  TopOfTemporaryRam = (UINTN)TopOfTemporaryRamPpi - sizeof(UINT32);
   TopOfTemporaryRam -= sizeof(UINT32) * 2;
-  Count             = *(UINT32 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32));
+  Count             = *(UINT32 *)(TopOfTemporaryRam - sizeof (UINT32));
   Size              = Count * sizeof (UINT32);
 
-  Ticker = *(UINT64 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32) - Size - sizeof (UINT32) * 2);
+  Ticker = *(UINT64 *) (TopOfTemporaryRam - sizeof (UINT32) - Size - sizeof (UINT32) * 2);
   Performance->ResetEnd = GetTimeInNanoSecond (Ticker);
 
   return EFI_SUCCESS;
diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c
index 5b94ed2b..ade36ab5 100644
--- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c
@@ -36,7 +36,7 @@ SecPlatformInformation (
   UINT32      *Bist;
   UINT32      Size;
   UINT32      Count;
-  UINT32      TopOfTemporaryRam;
+  UINTN       TopOfTemporaryRam;
   VOID        *TopOfTemporaryRamPpi;
   EFI_STATUS  Status;
 
@@ -59,9 +59,9 @@ SecPlatformInformation (
   // This routine copies the BIST information to the buffer pointed by
   // PlatformInformationRecord for output.
   //
-  TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof (UINT32);
+  TopOfTemporaryRam = (UINTN)TopOfTemporaryRamPpi - sizeof (UINT32);
   TopOfTemporaryRam -= sizeof(UINT32) * 2;
-  Count             = *((UINT32 *)(UINTN) (TopOfTemporaryRam - sizeof (UINT32)));
+  Count             = *((UINT32 *)(TopOfTemporaryRam - sizeof (UINT32)));
   Size              = Count * sizeof (IA32_HANDOFF_STATUS);
 
   if ((*StructureSize) < (UINT64) Size) {
-- 
2.18.0.windows.1


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

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

Re: [edk2-devel] [PATCH v2] MinPlatformPkg/SecFspWrapperPlatformSecLib: Change TopOfTemporaryRam type
Posted by Kubacki, Michael A 4 years, 7 months ago
Reviewed-by: Michael Kubacki <michael.a.kubacki@intel.com>

> -----Original Message-----
> From: Zhang, Shenglei
> Sent: Wednesday, September 4, 2019 11:20 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [PATCH v2] MinPlatformPkg/SecFspWrapperPlatformSecLib: Change
> TopOfTemporaryRam type
> 
> Update the type of TopOfTemporaryRam from UINT32 to UINTN.
> This change is intended to support X64 build scenarios.
> The original code(line 64) may cast the overfloewed result produced by
> "(TopOfTemporaryRam - sizeof (UINT32))"from 32bit to 64bit.
> 
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
> v2: As TopOfTemporaryRam is defined as UINTN in v2, remove
>     all the related casting operations which exist in v1 patch.
> 
>  .../SecFspWrapperPlatformSecLib/SecGetPerformance.c       | 8 ++++----
>  .../SecFspWrapperPlatformSecLib/SecPlatformInformation.c  | 6 +++---
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatf
> ormSecLib/SecGetPerformance.c
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatf
> ormSecLib/SecGetPerformance.c
> index c4eeb2b1..8535ae04 100644
> ---
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatf
> ormSecLib/SecGetPerformance.c
> +++
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlat
> +++ formSecLib/SecGetPerformance.c
> @@ -41,7 +41,7 @@ SecGetPerformance (
>  {
>    UINT32      Size;
>    UINT32      Count;
> -  UINT32      TopOfTemporaryRam;
> +  UINTN       TopOfTemporaryRam;
>    UINT64      Ticker;
>    VOID        *TopOfTemporaryRamPpi;
>    EFI_STATUS  Status;
> @@ -77,12 +77,12 @@ SecGetPerformance (
>    // |  TSC[31:00]  |
>    // |--------------|
>    //
> -  TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi -
> sizeof(UINT32);
> +  TopOfTemporaryRam = (UINTN)TopOfTemporaryRamPpi - sizeof(UINT32);
>    TopOfTemporaryRam -= sizeof(UINT32) * 2;
> -  Count             = *(UINT32 *) (UINTN) (TopOfTemporaryRam - sizeof
> (UINT32));
> +  Count             = *(UINT32 *)(TopOfTemporaryRam - sizeof (UINT32));
>    Size              = Count * sizeof (UINT32);
> 
> -  Ticker = *(UINT64 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32) - Size
> - sizeof (UINT32) * 2);
> +  Ticker = *(UINT64 *) (TopOfTemporaryRam - sizeof (UINT32) - Size -
> + sizeof (UINT32) * 2);
>    Performance->ResetEnd = GetTimeInNanoSecond (Ticker);
> 
>    return EFI_SUCCESS;
> diff --git
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatf
> ormSecLib/SecPlatformInformation.c
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatf
> ormSecLib/SecPlatformInformation.c
> index 5b94ed2b..ade36ab5 100644
> ---
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatf
> ormSecLib/SecPlatformInformation.c
> +++
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlat
> +++ formSecLib/SecPlatformInformation.c
> @@ -36,7 +36,7 @@ SecPlatformInformation (
>    UINT32      *Bist;
>    UINT32      Size;
>    UINT32      Count;
> -  UINT32      TopOfTemporaryRam;
> +  UINTN       TopOfTemporaryRam;
>    VOID        *TopOfTemporaryRamPpi;
>    EFI_STATUS  Status;
> 
> @@ -59,9 +59,9 @@ SecPlatformInformation (
>    // This routine copies the BIST information to the buffer pointed by
>    // PlatformInformationRecord for output.
>    //
> -  TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof
> (UINT32);
> +  TopOfTemporaryRam = (UINTN)TopOfTemporaryRamPpi - sizeof
> (UINT32);
>    TopOfTemporaryRam -= sizeof(UINT32) * 2;
> -  Count             = *((UINT32 *)(UINTN) (TopOfTemporaryRam - sizeof
> (UINT32)));
> +  Count             = *((UINT32 *)(TopOfTemporaryRam - sizeof (UINT32)));
>    Size              = Count * sizeof (IA32_HANDOFF_STATUS);
> 
>    if ((*StructureSize) < (UINT64) Size) {
> --
> 2.18.0.windows.1


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

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

Re: [edk2-devel] [PATCH v2] MinPlatformPkg/SecFspWrapperPlatformSecLib: Change TopOfTemporaryRam type
Posted by Chiu, Chasel 4 years, 7 months ago
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

> -----Original Message-----
> From: Zhang, Shenglei
> Sent: Thursday, September 5, 2019 2:20 PM
> To: devel@edk2.groups.io
> Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [PATCH v2] MinPlatformPkg/SecFspWrapperPlatformSecLib: Change
> TopOfTemporaryRam type
> 
> Update the type of TopOfTemporaryRam from UINT32 to UINTN.
> This change is intended to support X64 build scenarios.
> The original code(line 64) may cast the overfloewed result produced by
> "(TopOfTemporaryRam - sizeof (UINT32))"from 32bit to 64bit.
> 
> Cc: Michael Kubacki <michael.a.kubacki@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
> v2: As TopOfTemporaryRam is defined as UINTN in v2, remove
>     all the related casting operations which exist in v1 patch.
> 
>  .../SecFspWrapperPlatformSecLib/SecGetPerformance.c       | 8 ++++----
>  .../SecFspWrapperPlatformSecLib/SecPlatformInformation.c  | 6 +++---
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor
> mSecLib/SecGetPerformance.c
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor
> mSecLib/SecGetPerformance.c
> index c4eeb2b1..8535ae04 100644
> ---
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor
> mSecLib/SecGetPerformance.c
> +++
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlat
> +++ formSecLib/SecGetPerformance.c
> @@ -41,7 +41,7 @@ SecGetPerformance (
>  {
>    UINT32      Size;
>    UINT32      Count;
> -  UINT32      TopOfTemporaryRam;
> +  UINTN       TopOfTemporaryRam;
>    UINT64      Ticker;
>    VOID        *TopOfTemporaryRamPpi;
>    EFI_STATUS  Status;
> @@ -77,12 +77,12 @@ SecGetPerformance (
>    // |  TSC[31:00]  |
>    // |--------------|
>    //
> -  TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi -
> sizeof(UINT32);
> +  TopOfTemporaryRam = (UINTN)TopOfTemporaryRamPpi - sizeof(UINT32);
>    TopOfTemporaryRam -= sizeof(UINT32) * 2;
> -  Count             = *(UINT32 *) (UINTN) (TopOfTemporaryRam - sizeof
> (UINT32));
> +  Count             = *(UINT32 *)(TopOfTemporaryRam - sizeof
> (UINT32));
>    Size              = Count * sizeof (UINT32);
> 
> -  Ticker = *(UINT64 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32) - Size
> - sizeof (UINT32) * 2);
> +  Ticker = *(UINT64 *) (TopOfTemporaryRam - sizeof (UINT32) - Size -
> + sizeof (UINT32) * 2);
>    Performance->ResetEnd = GetTimeInNanoSecond (Ticker);
> 
>    return EFI_SUCCESS;
> diff --git
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor
> mSecLib/SecPlatformInformation.c
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor
> mSecLib/SecPlatformInformation.c
> index 5b94ed2b..ade36ab5 100644
> ---
> a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor
> mSecLib/SecPlatformInformation.c
> +++
> b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlat
> +++ formSecLib/SecPlatformInformation.c
> @@ -36,7 +36,7 @@ SecPlatformInformation (
>    UINT32      *Bist;
>    UINT32      Size;
>    UINT32      Count;
> -  UINT32      TopOfTemporaryRam;
> +  UINTN       TopOfTemporaryRam;
>    VOID        *TopOfTemporaryRamPpi;
>    EFI_STATUS  Status;
> 
> @@ -59,9 +59,9 @@ SecPlatformInformation (
>    // This routine copies the BIST information to the buffer pointed by
>    // PlatformInformationRecord for output.
>    //
> -  TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof
> (UINT32);
> +  TopOfTemporaryRam = (UINTN)TopOfTemporaryRamPpi - sizeof (UINT32);
>    TopOfTemporaryRam -= sizeof(UINT32) * 2;
> -  Count             = *((UINT32 *)(UINTN) (TopOfTemporaryRam - sizeof
> (UINT32)));
> +  Count             = *((UINT32 *)(TopOfTemporaryRam - sizeof
> (UINT32)));
>    Size              = Count * sizeof (IA32_HANDOFF_STATUS);
> 
>    if ((*StructureSize) < (UINT64) Size) {
> --
> 2.18.0.windows.1


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

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