From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mx.groups.io with SMTP id smtpd.web09.24213.1628522402859990635 for ; Mon, 09 Aug 2021 08:20:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=TTyFAQC2; spf=pass (domain: linaro.org, ip: 209.85.221.48, mailfrom: etienne.carriere@linaro.org) Received: by mail-wr1-f48.google.com with SMTP id b11so5817256wrx.6 for ; Mon, 09 Aug 2021 08:20:02 -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=YlusDItfRLeHhvU074bsSyB657sE1pmPXqJuC2IGQN4=; b=TTyFAQC2dAxN0Cv8AAu8DRxTpJ9cKX/uPKONNXm0Ah1DHTOCQZJvTfJ5VqEo6Le1Gr pTJZzPJJQSwrqj2lzI223t8Kon0YfQ7XsSgU+cjZ4q3syQ5rS86wVlJ2pJNLg04+Zz7b /xLnuefwhKIs0x+UkEZvDC9mhJ2Mx/eQRwCcZPejuH33EM8ZlTaRKDpcEfFocJJuIAaI lTBMZMwHtVwC7QddQeoD6WaBvLlfXk5Tu5X4u2pSENthCsu4fGq8gY4RYKRBW7U1ij1U j2RDtkijAsPp+Jp/m3vteKboWo+GaEvtSo4HRfus1Rm5X0gPA7tEXOXi45G1ok/GAiXQ 4BLg== 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=YlusDItfRLeHhvU074bsSyB657sE1pmPXqJuC2IGQN4=; b=WDK+52vitBOE+lWMxh1GZTbcIfno+JvLQqcr/CadaCThSDRZ+27d1UqsLyotZKZyoG T9PrHO5g+IBeWT4pLI3pWYBoSUz8ZCdTTAziipdNBgskx8x1I2+mf6Pe0cmJ7GzGzgnV w0F1EeSik1q9GxUwjIQgeQSnuHkEzye/WzyiDZ4EU/gICFmOSS/zNl0LwUuiBad1p0zb rZiWorOVr4whLSted6i+drEhXJ2fviPR7il0xWQHYfZAdT5oJnKRa71Z8XRZUqXKGyFZ QbGT6FhMOtz4IfHHLQHr5evLPovZwx8iwGnpNu+peAKUoijQdKXwAId2ZVb4low0GVQH 7jzw== X-Gm-Message-State: AOAM533M6n5vCbvEsO/B9SOt9cJbXKFq/dMG5S4WVddYXJ2FQOAkoFln cweedy0m5mqC2biJ593m3emI7ykZQQVOxg== X-Google-Smtp-Source: ABdhPJy6X+Dd7i62H47oUJWi9UttsEIZKsFHl7u0izdCehsKH+tONWTMqz00bpG9bz89uraorbT/Vg== X-Received: by 2002:a5d:5745:: with SMTP id q5mr24752498wrw.409.1628522401253; Mon, 09 Aug 2021 08:20:01 -0700 (PDT) Return-Path: Received: from lmecxl0524.lme.st.com ([2a04:cec0:1189:835c:f5e6:d24:9eea:1973]) by smtp.gmail.com with ESMTPSA id j14sm20449971wru.58.2021.08.09.08.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 08:20:01 -0700 (PDT) From: "Etienne Carriere" To: devel@edk2.groups.io Cc: Achin Gupta , Ard Biesheuvel , Jiewen Yao , Leif Lindholm , Sami Mujawar , Sughosh Ganu , Liming Gao , Etienne Carriere Subject: [PATCH v5 4/5] StandaloneMmPkg: fix pointer/int casts against 32bit architectures Date: Mon, 9 Aug 2021 17:19:45 +0200 Message-Id: <20210809151946.27600-4-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210809151946.27600-1-etienne.carriere@linaro.org> References: <20210809151946.27600-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. Signed-off-by: Etienne Carriere Acked-by: Jiewen Yao Reviewed-by: Sami Mujawar --- No change since v4 Changes since v3: - Remove Cc tags and apply review tags. No change since v2 No change since v1 --- 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