public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Etienne Carriere" <etienne.carriere@linaro.org>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Leif Lindholm <leif@nuviainc.com>,
	Sami Mujawar <sami.mujawar@arm.com>,
	Sughosh Ganu <sughosh.ganu@linaro.org>,
	Thomas Abraham <thomas.abraham@arm.com>,
	Etienne Carriere <etienne.carriere@linaro.org>
Subject: [PATCH v3 5/6] Drivers/OpTee: address cast build warning issue in 32b mode
Date: Tue, 10 Aug 2021 18:40:35 +0200	[thread overview]
Message-ID: <20210810164036.15199-6-etienne.carriere@linaro.org> (raw)
In-Reply-To: <20210810164036.15199-1-etienne.carriere@linaro.org>

Use (UINTN) cast to cast physical or virtual address values to the
pointer size before casting from/to a pointer value.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
---
No change since v2
No change since v1
---
 Drivers/OpTee/OpteeRpmbPkg/OpTeeRpmbFvb.c | 21 +++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/Drivers/OpTee/OpteeRpmbPkg/OpTeeRpmbFvb.c b/Drivers/OpTee/OpteeRpmbPkg/OpTeeRpmbFvb.c
index 6eb19bed0e..83c2750368 100644
--- a/Drivers/OpTee/OpteeRpmbPkg/OpTeeRpmbFvb.c
+++ b/Drivers/OpTee/OpteeRpmbPkg/OpTeeRpmbFvb.c
@@ -305,7 +305,8 @@ OpTeeRpmbFvbRead (
     }
   }
 
-  Base = (VOID *)Instance->MemBaseAddress + (Lba * Instance->BlockSize) + Offset;
+  Base = (VOID *)(UINTN)Instance->MemBaseAddress + (Lba * Instance->BlockSize) +
+         Offset;
   // We could read the data from the RPMB instead of memory
   // The 2 copies should already be identical
   // Copy from memory image
@@ -387,7 +388,8 @@ OpTeeRpmbFvbWrite (
       return Status;
     }
   }
-  Base = (VOID *)Instance->MemBaseAddress + Lba * Instance->BlockSize + Offset;
+  Base = (VOID *)(UINTN)Instance->MemBaseAddress + (Lba * Instance->BlockSize) +
+         Offset;
   Status = ReadWriteRpmb (
              SP_SVC_RPMB_WRITE,
              (UINTN)Buffer,
@@ -477,7 +479,8 @@ OpTeeRpmbFvbErase (
       return EFI_INVALID_PARAMETER;
     }
     NumBytes = NumLba * Instance->BlockSize;
-    Base = (VOID *)Instance->MemBaseAddress + Start * Instance->BlockSize;
+    Base = (VOID *)(UINTN)Instance->MemBaseAddress +
+           (Start * Instance->BlockSize);
     Buf = AllocatePool (NumLba * Instance->BlockSize);
     if (Buf == NULL) {
       return EFI_DEVICE_ERROR;
@@ -689,7 +692,7 @@ InitializeFvAndVariableStoreHeaders (
     goto Exit;
   }
   // Install the combined header in memory
-  CopyMem ((VOID*)Instance->MemBaseAddress, Headers, HeadersLength);
+  CopyMem ((VOID*)(UINTN)Instance->MemBaseAddress, Headers, HeadersLength);
 
 Exit:
   FreePool (Headers);
@@ -747,14 +750,18 @@ FvbInitialize (
   // Read the file from disk and copy it to memory
   ReadEntireFlash (Instance);
 
-  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->MemBaseAddress;
+  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)Instance->MemBaseAddress;
   Status = ValidateFvHeader (FwVolHeader);
   if (EFI_ERROR (Status)) {
     // There is no valid header, so time to install one.
     DEBUG ((DEBUG_INFO, "%a: The FVB Header is not valid.\n", __FUNCTION__));
 
     // Reset memory
-    SetMem64 ((VOID *)Instance->MemBaseAddress, Instance->NBlocks * Instance->BlockSize, ~0UL);
+    SetMem64 (
+      (VOID *)(UINTN)Instance->MemBaseAddress,
+      Instance->NBlocks * Instance->BlockSize,
+      ~0UL
+      );
     DEBUG ((DEBUG_INFO, "%a: Erasing Flash.\n", __FUNCTION__));
     Status = ReadWriteRpmb (
                SP_SVC_RPMB_WRITE,
@@ -827,7 +834,7 @@ OpTeeRpmbFvbInit (
   mInstance.FvbProtocol.Write              = OpTeeRpmbFvbWrite;
   mInstance.FvbProtocol.Read               = OpTeeRpmbFvbRead;
 
-  mInstance.MemBaseAddress = (EFI_PHYSICAL_ADDRESS)Addr;
+  mInstance.MemBaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Addr;
   mInstance.Signature      = FLASH_SIGNATURE;
   mInstance.Initialize     = FvbInitialize;
   mInstance.BlockSize      = EFI_PAGE_SIZE;
-- 
2.17.1


  parent reply	other threads:[~2021-08-10 16:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 16:40 [PATCH v3 0/6] Arm 32bit support in PlatformStandaloneMmRpmb Etienne Carriere
2021-08-10 16:40 ` [PATCH v3 1/6] Platform/ARM/SgiPkg: sync with edk2 StandaloneMmCpu path change Etienne Carriere
2021-08-10 16:40 ` [PATCH v3 2/6] Platform/Socionext/DeveloperBox: " Etienne Carriere
2021-08-10 16:40 ` [PATCH v3 3/6] Platform/StandaloneMm: " Etienne Carriere
2021-08-10 16:40 ` [PATCH v3 4/6] Drivers/OpTee: Add Aarch32 SVC IDs for 32bit Arm targets Etienne Carriere
2021-08-10 16:40 ` Etienne Carriere [this message]
2021-08-10 16:40 ` [PATCH v3 6/6] Platform/StandaloneMm: build StandaloneMmRpmb for 32bit architectures Etienne Carriere
2021-08-11 11:47 ` [PATCH v3 0/6] Arm 32bit support in PlatformStandaloneMmRpmb Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210810164036.15199-6-etienne.carriere@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox