From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by mx.groups.io with SMTP id smtpd.web08.18532.1621255580702173152 for ; Mon, 17 May 2021 05:46:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=Z1zQiYjD; spf=pass (domain: linaro.org, ip: 209.85.128.42, mailfrom: ilias.apalodimas@linaro.org) Received: by mail-wm1-f42.google.com with SMTP id u133so3507959wmg.1 for ; Mon, 17 May 2021 05:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tKl6+AAsG5r7EuAFVbRSZAEt1fZI3EtVPXi4PWic6eg=; b=Z1zQiYjDMys/uc2tXcv8usiNmlpquWRmvQs1t8wcqb4NgmAK2lST+7X4JhCraBYZoe byuPbNVkcXcBWp5DI4ZhQ7PLDidYOFWUsZaYWP5I9h6yI9dEDnmF9G9W0ZO2WlrYpE0I 808EJiKiVbqqrgcu4xx8BQrS2mkXdXtlqhICqjzxAPGYLd+2gAeJ2VfTo/j4INbHzZvC +SjcE8fqFd+p4x/9Oli9U0GlI78loATh/o/IgGbY9+cLC5CDQUN55P3jcdamIJqheRJo RNjckNVTRWdV0kFJ3V2Y4z+tnv0mOsDRiV+7zNg1EbSnWkgZyaDZJtjd5nL/L5FtGTYX j5kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tKl6+AAsG5r7EuAFVbRSZAEt1fZI3EtVPXi4PWic6eg=; b=FsEqqbcdtuP/6K4SBHe3RsrAgbCb+V9bMgmLHW9hyG85FrivPVPcx9UsE48ROPZjQh tG7ZLmBXH2ZybeyUKU6ehYfa4iMi/OKmbozGKHe7UVSmiLT1haVA0hLofOXQ0Q+YGEy3 ZEjp0Elth1Dxu5xP/vox3OUvleYXjDet9lwkyGEKgW6pnsHo8XaGsUPFAG+Yp8H5gznx N+4QYbFTs535JsAlJLB5CH/sIKEK1Y4RY72HZ2C01a2MDjCAv0nURcNw3FFStkWYIX8/ 9t5+iGyjSDeUUjEnK6FuRK3EwsglcI1Jp/ispV5V1QALw7Y5yejqPTmVbW4b6vltP03B vwWw== X-Gm-Message-State: AOAM531cjVNmaYK/LgA0vRRsUedFtuyuxeb9SopRmm5OyRnQmURk1P7b JQErLsZ11FugYBJQoF3xv4pkfA== X-Google-Smtp-Source: ABdhPJybqB3hNpegTWuNRTT8gyzbEBDfXXjzfMvHKV+ZNoVKbACyuczJ6sT1I9fIoi5jocX5S0ECmw== X-Received: by 2002:a1c:1bd6:: with SMTP id b205mr6457692wmb.170.1621255579346; Mon, 17 May 2021 05:46:19 -0700 (PDT) Return-Path: Received: from enceladus ([94.69.77.156]) by smtp.gmail.com with ESMTPSA id k6sm20514035wmi.42.2021.05.17.05.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 05:46:19 -0700 (PDT) Date: Mon, 17 May 2021 15:46:16 +0300 From: "Ilias Apalodimas" To: Etienne Carriere Cc: devel@edk2.groups.io, Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Sughosh Ganu , Thomas Abraham Subject: Re: [edk2-platforms][PATCH v2 5/6] Drivers/OpTee: address cast build warning issue in 32b mode Message-ID: References: <20210517055047.30814-1-etienne.carriere@linaro.org> <20210517055047.30814-5-etienne.carriere@linaro.org> MIME-Version: 1.0 In-Reply-To: <20210517055047.30814-5-etienne.carriere@linaro.org> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, May 17, 2021 at 07:50:46AM +0200, 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 > Cc: Ilias Apalodimas > Cc: Leif Lindholm > Cc: Sami Mujawar > Signed-off-by: Etienne Carriere > --- > 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 > Acked-by: Ilias Apalodimas