From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by mx.groups.io with SMTP id smtpd.web09.15206.1621230693035041116 for ; Sun, 16 May 2021 22:51:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=xRCuAQ03; spf=pass (domain: linaro.org, ip: 209.85.128.45, mailfrom: etienne.carriere@linaro.org) Received: by mail-wm1-f45.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso4394203wmh.4 for ; Sun, 16 May 2021 22:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3gWv8A+rNNej/Fh2Ox5FBifmFxl3u8NrdP9j1xlv35U=; b=xRCuAQ03UhBvJ9xAjH9GUlYUwWyd3IE6c4DwnJV3ocy1gPVCfcEHFj4OgOD87HBv+8 6xVj6o+66jTJuDfEDlmn+ftu2Xyv6MATERylnYq3nRpWXMZ/xK3ULJr6RGxPSAvTPqkL CtdlhL3x4W38Q4RNRREmkpUhjUSPmNWtma8mZL7/zc9ZnBRpk0Mo+sC9Ic68y8JCNF+v U8RIgDvqUCsLJSJ7DMuxRdMZqvGyCah04vVlh1d6/Hi6OiZZx3f9+9flZzrwYjySr4Pr 4DDQxzO+vTfoCcmrXc0qOawfnMQqAyAXxlNGGbfKxFyD3K/7nQkM0pUiUO7ZppRseurP 5b2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3gWv8A+rNNej/Fh2Ox5FBifmFxl3u8NrdP9j1xlv35U=; b=JtAp3nQF68SQtZ7VgBVeAzBNykrVhMsUQCS2d7+2492D6R5YC3MquxH//cRJrg6UGa 1xX6b8jqA8kFzlthdTXRdWTtkOJrJgGG/UOUfNusZKJ3J+h6CNSYsGsL4Ic6STmbapeZ FUHG7AaYph9Re+EF0weuhKMq7oJJ4Q7HuFSbC/AaTf3BPVRR+q4Y5eatEoqkgZQhbIF2 7CRu+Dxl7WbYcUXkym/LKn+CIyj8oSSqljI9T4fAbPPV4IiqEDDmSn5AWyTZDOJFb3BZ UZTO9DjRhif262SOCUroFDVLMy/NtVb9+PQ1emq10gWrDnbCOiHH/+RTdLOQzyMUee2t MmmA== X-Gm-Message-State: AOAM531ODn0iaHS8KI3W6ME3crl4hyQ1IbkBx/JtTkzIlWKgpYdK9Jsl Dq1b47DOyWxKZHklxVd1pv54cDIxecXQNeXO X-Google-Smtp-Source: ABdhPJzPM0nqRKuOErLb2yqOavb7phTbfOZvXwZWZ6Ki6Zwvz/0jUvXBTasnVDIenUA8GX1/lhoZpQ== X-Received: by 2002:a1c:4043:: with SMTP id n64mr17710476wma.9.1621230691602; Sun, 16 May 2021 22:51:31 -0700 (PDT) Return-Path: Received: from lmecxl0524.lme.st.com (2a01cb058b850800452ff0effb46d5f4.ipv6.abo.wanadoo.fr. [2a01:cb05:8b85:800:452f:f0ef:fb46:d5f4]) by smtp.gmail.com with ESMTPSA id a23sm82660wrc.22.2021.05.16.22.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 May 2021 22:51:31 -0700 (PDT) From: "Etienne Carriere" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Ilias Apalodimas , Leif Lindholm , Sami Mujawar , Sughosh Ganu , Thomas Abraham , Etienne Carriere Subject: [edk2-platforms][PATCH v2 5/6] Drivers/OpTee: address cast build warning issue in 32b mode Date: Mon, 17 May 2021 07:50:46 +0200 Message-Id: <20210517055047.30814-5-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210517055047.30814-1-etienne.carriere@linaro.org> References: <20210517055047.30814-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 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