From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mx.groups.io with SMTP id smtpd.web11.33655.1620661866958878151 for ; Mon, 10 May 2021 08:51:07 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fHuVMnuU; spf=pass (domain: kernel.org, ip: 198.145.29.99, mailfrom: ardb@kernel.org) Received: by mail.kernel.org (Postfix) with ESMTPSA id 333926143C for ; Mon, 10 May 2021 15:51:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620661866; bh=e76MIaF2cLIthk7y6AidnN3OcKbpR7oZbh6wV9Vm6QU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=fHuVMnuUZEsBbO4RjZi8cwmWvCqFqedGRYS8FQKwoEx5T8ggo6dxaROlV+Uq/MDEy sjeSi1qexxNPnwtzGZYTGVyfjvcokFuPhVNmgSN7LttjAxWoTcRtKQD7z7STCjCisA EXTIdzdlnWp7uHcCQ0LY1UAp1roxzGcYtJGsMcEDNEKMlu9j4DodUhVzt7+S80B9jc ae6CeKzD60VB+0UOgj8YKfZl7FRQ01iG9Zt9TEo1YGkSXq5Ro9W3fdPrBR6d3juR50 G97QLiLxjz8c5Vr6Q/Yb5lbUixGF412USL/PaiHsftCMnqSUC1nO2bwuV/rOJaFji0 /rgEQ3rIxgs0A== Received: by mail-oo1-f41.google.com with SMTP id o202-20020a4a2cd30000b02901fcaada0306so3558124ooo.7 for ; Mon, 10 May 2021 08:51:06 -0700 (PDT) X-Gm-Message-State: AOAM532WthRlCcKPjkFdEfeAuXZVaZdsWTdhBAVUijLZS9I99ClzIP8S o68YjPzZfyo7dlXMYZ/k4uSmtC1IBKMI9HJscew= X-Google-Smtp-Source: ABdhPJxJNom4SgAj4EmYkMS3RYHbsQu7nC3mu+JAix30PQyrY7zXD1enGzDDSHTYaSg0ypqogjYRmv2VMsKe4+dty78= X-Received: by 2002:a4a:625c:: with SMTP id y28mr19338291oog.45.1620661865408; Mon, 10 May 2021 08:51:05 -0700 (PDT) MIME-Version: 1.0 References: <20210504152048.8739-1-etienne.carriere@linaro.org> <20210504152048.8739-5-etienne.carriere@linaro.org> In-Reply-To: From: "Ard Biesheuvel" Date: Mon, 10 May 2021 17:50:54 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH 4/5] StandaloneMmPkg: fix pointer/int casts against 32bit architectures To: "Yao, Jiewen" Cc: "devel@edk2.groups.io" , "etienne.carriere@linaro.org" , Achin Gupta , Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Sughosh Ganu Content-Type: text/plain; charset="UTF-8" On Wed, 5 May 2021 at 04:10, Yao, Jiewen wrote: > > Acked-by: Jiewen Yao > > Need ARM expert to comment if it is OK to refer AArch64 for ARM? > This looks fine to me. > > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of Etienne > > Carriere > > Sent: Tuesday, May 4, 2021 11:21 PM > > To: devel@edk2.groups.io > > Cc: Achin Gupta ; Ard Biesheuvel > > ; Yao, Jiewen ; Leif > > Lindholm ; Sami Mujawar ; > > Sughosh Ganu ; Etienne Carriere > > > > Subject: [edk2-devel] [PATCH 4/5] StandaloneMmPkg: fix pointer/int casts > > against 32bit architectures > > > > 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/CreateHobL > > ist.c | 14 +++++++------- > > > > StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/Standalone > > MmCoreEntryPoint.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/CreateHo > > bList.c > > b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHo > > bList.c > > index e8fb96bd6e..4d4cf3d5ff 100644 > > --- > > a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHo > > bList.c > > +++ > > b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHo > > bList.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/Standalon > > eMmCoreEntryPoint.c > > b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/Standalon > > eMmCoreEntryPoint.c > > index 6c50f470aa..b445d6942e 100644 > > --- > > a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/Standalon > > eMmCoreEntryPoint.c > > +++ > > b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/Standalon > > eMmCoreEntryPoint.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 > > > > > > > > > > >