From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by mx.groups.io with SMTP id smtpd.web08.7250.1620141658905294444 for ; Tue, 04 May 2021 08:20:59 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=gmGeZI2J; spf=pass (domain: linaro.org, ip: 209.85.128.51, mailfrom: etienne.carriere@linaro.org) Received: by mail-wm1-f51.google.com with SMTP id g65so5692360wmg.2 for ; Tue, 04 May 2021 08:20:58 -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=7YEiXj8d0sQ43YZ2CmE4sJCQYagKr0o8gh0E/4xza2s=; b=gmGeZI2JBRsIhsjobkxVqi8fuos7S1ZJOBgBezUXFI0BLbuFW6nh+RgAeP3Y5eAd6u yOdPOIwp+J+6uKIkVn/28FQgiMFB8uC28wZKQOgZKKlEq9Eym3bvOzOFADw1UF5pJiIF irTV+piQq+pHJMOFlor1tSQr6WES1mthFpMZtsq5Z8qLyI6r//A5cbRK6gNm3CWYyY7V PCuNsfGZGOTRFIIqSmTzXQrCstNyP7EPeMUbKKopAmzPadI2J9m2bU1lDMBPN0TL1HAL /tDYxFdxDoSe1Wfqit9cmW6vosDWJZSvdw8LJ42ap8c0xIaFyn0z9cwxQTqHzsCpmgPM WASQ== 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=7YEiXj8d0sQ43YZ2CmE4sJCQYagKr0o8gh0E/4xza2s=; b=AOE3XOxfh9hZkFzJG4K+23yS1yaj9TBDD+l+uSiSRMIK6YdzVYD2GsiTgrLPbB0utE 6HJE3uM2LfVJmyftnX6EADUbEec60EJ9H56Iep24NojMksG9YKLEz7J06GzI8S1sgeKG rt7oRoAn9njb0O0WzFvcfbNMvAZOoQ2xgsA9iamisLg5jcobhLkUR8VzWKYqdiW2jevb lMYC17dTWbi9FTp1X4K6xCOz8EgUF9nvHmjA9goNympDyUoupR5prLUVyxzAxXeSBcA5 oK7FsSMVY36AOm5LPkBpmgj8t+KM3HdEyJnleYsAHkd+FaiAqsNGkZuCmEyWpWTT/mfh kInw== X-Gm-Message-State: AOAM5326kDGq7jXNXOyURMaxBJdSpYhqyXxbpdAVRn4LoQ3Txzzj1wer +1Rie9WDYj7nZhrSBAdiDpkV22a1fqm8AA== X-Google-Smtp-Source: ABdhPJyJovNlOuqWnblM4G0OFg80ZvwS7WSSMlhVI8RH+uGt3vd63b7jsPSR/rW9uvKtJlp01fDScA== X-Received: by 2002:a05:600c:3515:: with SMTP id h21mr4626235wmq.148.1620141657394; Tue, 04 May 2021 08:20:57 -0700 (PDT) Return-Path: Received: from lmecxl0524.lme.st.com ([2a04:cec0:11d7:652f:452f:f0ef:fb46:d5f4]) by smtp.gmail.com with ESMTPSA id c2sm2919661wmr.22.2021.05.04.08.20.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 May 2021 08:20:56 -0700 (PDT) From: "Etienne Carriere" To: devel@edk2.groups.io Cc: Achin Gupta , Ard Biesheuvel , Jiewen Yao , Leif Lindholm , Sami Mujawar , Sughosh Ganu , Etienne Carriere Subject: [PATCH 4/5] StandaloneMmPkg: fix pointer/int casts against 32bit architectures Date: Tue, 4 May 2021 17:20:47 +0200 Message-Id: <20210504152048.8739-5-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210504152048.8739-1-etienne.carriere@linaro.org> References: <20210504152048.8739-1-etienne.carriere@linaro.org> Use intermediate (UINTN) cast when casting int from/to pointer. This is needed as UINT64 values cast from/to 32bit pointer for 32bit architectures. Cc: Achin Gupta Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Leif Lindholm Cc: Sami Mujawar Cc: Sughosh Ganu Signed-off-by: Etienne Carriere --- StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c | 8 ++++---- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHobList.c | 14 +++++++------- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c index 6884095c49..d4590bcd19 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c @@ -164,8 +164,8 @@ StandaloneMmCpuInitialize ( // Share the entry point of the CPU driver DEBUG ((DEBUG_INFO, "Sharing Cpu Driver EP *0x%lx = 0x%lx\n", - (UINT64) CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr, - (UINT64) PiMmStandaloneArmTfCpuDriverEntry)); + (UINTN) CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr, + (UINTN) PiMmStandaloneArmTfCpuDriverEntry)); *(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) = PiMmStandaloneArmTfCpuDriverEntry; // Find the descriptor that contains the whereabouts of the buffer for @@ -180,8 +180,8 @@ StandaloneMmCpuInitialize ( return Status; } - DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalStart - 0x%lx\n", (UINT64) NsCommBufMmramRange->PhysicalStart)); - DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalSize - 0x%lx\n", (UINT64) NsCommBufMmramRange->PhysicalSize)); + DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalStart - 0x%lx\n", (UINTN) NsCommBufMmramRange->PhysicalStart)); + DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalSize - 0x%lx\n", (UINTN) NsCommBufMmramRange->PhysicalSize)); CopyMem (&mNsCommBuffer, NsCommBufMmramRange, sizeof(EFI_MMRAM_DESCRIPTOR)); DEBUG ((DEBUG_INFO, "mNsCommBuffer: 0x%016lx - 0x%lx\n", mNsCommBuffer.CpuStart, mNsCommBuffer.PhysicalSize)); diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHobList.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHobList.c index e8fb96bd6e..4d4cf3d5ff 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHobList.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHobList.c @@ -72,14 +72,14 @@ CreateHobListFromBootInfo ( // Create a hoblist with a PHIT and EOH HobStart = HobConstructor ( - (VOID *) PayloadBootInfo->SpMemBase, + (VOID *) (UINTN) PayloadBootInfo->SpMemBase, (UINTN) PayloadBootInfo->SpMemLimit - PayloadBootInfo->SpMemBase, - (VOID *) PayloadBootInfo->SpHeapBase, - (VOID *) (PayloadBootInfo->SpHeapBase + PayloadBootInfo->SpHeapSize) + (VOID *) (UINTN) PayloadBootInfo->SpHeapBase, + (VOID *) (UINTN) (PayloadBootInfo->SpHeapBase + PayloadBootInfo->SpHeapSize) ); // Check that the Hoblist starts at the bottom of the Heap - ASSERT (HobStart == (VOID *) PayloadBootInfo->SpHeapBase); + ASSERT (HobStart == (VOID *) (UINTN) PayloadBootInfo->SpHeapBase); // Build a Boot Firmware Volume HOB BuildFvHob (PayloadBootInfo->SpImageBase, PayloadBootInfo->SpImageSize); @@ -190,9 +190,9 @@ CreateHobListFromBootInfo ( MmramRanges[3].RegionState = EFI_CACHEABLE | EFI_ALLOCATED; // Base and size of heap memory shared by all cpus - MmramRanges[4].PhysicalStart = (EFI_PHYSICAL_ADDRESS) HobStart; - MmramRanges[4].CpuStart = (EFI_PHYSICAL_ADDRESS) HobStart; - MmramRanges[4].PhysicalSize = HobStart->EfiFreeMemoryBottom - (EFI_PHYSICAL_ADDRESS) HobStart; + MmramRanges[4].PhysicalStart = (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart; + MmramRanges[4].CpuStart = (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart; + MmramRanges[4].PhysicalSize = HobStart->EfiFreeMemoryBottom - (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart; MmramRanges[4].RegionState = EFI_CACHEABLE | EFI_ALLOCATED; // Base and size of heap memory shared by all cpus diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c index 6c50f470aa..b445d6942e 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c @@ -328,7 +328,7 @@ _ModuleEntryPoint ( // Locate PE/COFF File information for the Standalone MM core module Status = LocateStandaloneMmCorePeCoffData ( - (EFI_FIRMWARE_VOLUME_HEADER *) PayloadBootInfo->SpImageBase, + (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PayloadBootInfo->SpImageBase, &TeData, &TeDataSize ); -- 2.17.1