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.web10.68.1628613653009596832 for ; Tue, 10 Aug 2021 09:40:53 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=zCGhk3bh; 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 g138so1677178wmg.4 for ; Tue, 10 Aug 2021 09:40:52 -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=qa9IH0OCaf/VyOUoHjoRmP31Sr6pHZ+BleP63unrdHY=; b=zCGhk3bhzAvHr9NNhhaxx1uWMxtn1ZEFXxx2+9kLuQQhT0tumQjmb0L8tdbskocZnV qgqY57IZ8O9R/lS3Q3Zt0DNC5UlQCqsvnhYcrQyMNf4TlO8/iXK6BYZVe8hwZ5R7cRCn TJYJHDcIalrAePxdbw6apIjE1olYz65c8rhsvjykrJJ+iCs9kgZAWpFI83vjvivCQChB TK9sHFC8/PUmOhIKDpFDhb+9ShJUgMQm4l2f+INwM7Qmkwab4DQl3t/77c2AQ92cNUXD YZdtl1dR3eFzQBQX3HbMCy/9h5B5h6YEQRc6PbDGWA8HIRhgO2nOsFp7NdYKU8/4aX5p BWFg== 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=qa9IH0OCaf/VyOUoHjoRmP31Sr6pHZ+BleP63unrdHY=; b=SzDQ3t3LDemMaru+td7e3DVGC2ntm5NLqEqtfH5tc1LW9TPZ69WAu6ua0OOD4uD0o/ Ek6ggnIOmkhtk27nCFlVqlPCg1ftOIzpjkJ0Y9nIASYgmt62zPt288cuqaisAySIUjoB kONNmYRFMjJoF3V+zhDFmJLlOOM8uXe1hKv41v2yUsavlJJ8iUVG6fJNpDWZXYLvnVE0 iliTt2wzPmem6AmfL7xTQG915ekMHO5C8BkThPJ014iUqUUFaV4nqgWQBqnAbMYjewBd xKT/AjnoSWveA7f7IlyCDU53BTDVGIoBJ1y9G6i1PK4oqAUx55Ox05GUTWYrxBVjvNAz CLAQ== X-Gm-Message-State: AOAM5300hhjNXGzp2UM3g9aZkW1E3oK7x8SSOcjT4xeu8143VHhx0FZN /Vo7gtOIV8AtVmx2JUZPR9m3IhAtI824Ug== X-Google-Smtp-Source: ABdhPJywk8teI1y2yMSDNkL0DKT0bRhMBCnG3NOi/19qJZ+oZzWeX66Rs8fX0nPD4Jav/PodP6tObA== X-Received: by 2002:a05:600c:294a:: with SMTP id n10mr12351797wmd.67.1628613651548; Tue, 10 Aug 2021 09:40:51 -0700 (PDT) Return-Path: Received: from lmecxl0524.lme.st.com ([2a04:cec0:10c1:ef71:f5e6:d24:9eea:1973]) by smtp.gmail.com with ESMTPSA id i3sm3196261wmb.17.2021.08.10.09.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 09:40:51 -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: [PATCH v3 5/6] Drivers/OpTee: address cast build warning issue in 32b mode Date: Tue, 10 Aug 2021 18:40:35 +0200 Message-Id: <20210810164036.15199-6-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210810164036.15199-1-etienne.carriere@linaro.org> References: <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 Cc: Ilias Apalodimas Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Etienne Carriere --- 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