public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sami Mujawar" <sami.mujawar@arm.com>
To: Etienne Carriere <etienne.carriere@linaro.org>, devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Leif Lindholm <leif@nuviainc.com>,
	Sughosh Ganu <sughosh.ganu@linaro.org>,
	Thomas Abraham <thomas.abraham@arm.com>
Subject: Re: [edk2-platforms][PATCH 3/4] Drivers/OpTee: address cast build warning issue in 32b mode
Date: Wed, 12 May 2021 11:24:27 +0100	[thread overview]
Message-ID: <030b0205-6450-1f19-11c9-26d32139364e@arm.com> (raw)
In-Reply-To: <20210510075304.9125-4-etienne.carriere@linaro.org>

Hi Etienn,

Thank you for this patch.

These changes look good to me.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 10/05/2021 08:53 AM, Etienne Carriere wrote:
> 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>
> ---
>   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;

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

  reply	other threads:[~2021-05-12 10:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10  7:53 [edk2-platforms][PATCH 0/4] Arm 32bit support in StandaloneMmRpmb Etienne Carriere
2021-05-10  7:53 ` [edk2-platforms][PATCH 1/4] sync with edk2 where StandaloneMmCpu moved to AArch64/ parent directory Etienne Carriere
2021-05-12 10:11   ` Sami Mujawar
2021-05-10  7:53 ` [edk2-platforms][PATCH 2/4] Drivers/OpTee: Add Aarch32 SVC IDs for 32bit Arm targets Etienne Carriere
2021-05-12 10:11   ` Sami Mujawar
2021-05-10  7:53 ` [edk2-platforms][PATCH 3/4] Drivers/OpTee: address cast build warning issue in 32b mode Etienne Carriere
2021-05-12 10:24   ` Sami Mujawar [this message]
2021-05-10  7:53 ` [edk2-platforms][PATCH 4/4] Platform/StandaloneMm: build StandaloneMmRpmb for 32bit architectures Etienne Carriere
2021-05-12 10:13   ` Sami Mujawar
2021-05-10 15:57 ` [edk2-platforms][PATCH 0/4] Arm 32bit support in StandaloneMmRpmb Ard Biesheuvel
2021-05-10 18:04   ` Ilias Apalodimas

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=030b0205-6450-1f19-11c9-26d32139364e@arm.com \
    --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