diff options
author | Laszlo Ersek <lersek@redhat.com> | 2014-11-14 10:23:21 +0000 |
---|---|---|
committer | lersek <lersek@Edk2> | 2014-11-14 10:23:21 +0000 |
commit | 1e62c89c3ae0da2eeabb37c5ab299b928ebbbb30 (patch) | |
tree | 9b791151015c27c4afe99e05f8166028a41ddfc7 /OvmfPkg | |
parent | 42e2ff2eb4cda6013ab995757d867f566404cc55 (diff) | |
download | edk2-platforms-1e62c89c3ae0da2eeabb37c5ab299b928ebbbb30.tar.xz |
OvmfPg: flash driver: fix type of EFI_SIZE_TO_PAGES argument (VS2010)
The MarkMemoryRangeForRuntimeAccess() function passes the Length parameter
(of type UINT64) to the macro EFI_SIZE_TO_PAGES(). When building for the
Ia32 platform, this violates the interface contract of the macro:
[...] Passing in a parameter that is larger than UINTN may produce
unexpected results.
In addition, it trips up compilation by VS2010 for the Ia32 platform and
the NOOPT target -- it generates calls to intrinsics, which are not
allowed in edk2.
Fix both issues with the following steps:
(1) Demote the Length parameter of MarkMemoryRangeForRuntimeAccess() to
UINTN. Even a UINT32 value is plenty for representing the size of the
flash chip holding the variable store. Length parameter is used in the
following contexts:
- passed to gDS->RemoveMemorySpace() -- takes an UINT64
- passed to gDS->AddMemorySpace() -- ditto
- passed to EFI_SIZE_TO_PAGES() -- requires an UINTN. This also guarantees
that the return type of EFI_SIZE_TO_PAGES() will be UINTN, hence we can
drop the outer cast.
(2) The only caller of MarkMemoryRangeForRuntimeAccess() is
FvbInitialize(). The latter function populates the local Length variable
(passed to MarkMemoryRangeForRuntimeAccess()) from
PcdGet32(PcdOvmfFirmwareFdSize). Therefore we can simply demote the local
variable to UINTN in this function as well.
- There's only one other use of Length in FvbInitialize(): it is passed to
GetFvbInfo(). GetFvbInfo() takes an UINT64, so passing an UINTN is fine.
Suggested-by: Scott Duplichan <scott@notabs.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Build-tested-by: Scott Duplichan <scott@notabs.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16382 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg')
-rw-r--r-- | OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c index b56ece3931..42060c84cf 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c @@ -895,7 +895,7 @@ STATIC EFI_STATUS
MarkMemoryRangeForRuntimeAccess (
EFI_PHYSICAL_ADDRESS BaseAddress,
- UINT64 Length
+ UINTN Length
)
{
EFI_STATUS Status;
@@ -919,7 +919,7 @@ MarkMemoryRangeForRuntimeAccess ( Status = gBS->AllocatePages (
AllocateAddress,
EfiRuntimeServicesData,
- (UINTN) EFI_SIZE_TO_PAGES (Length),
+ EFI_SIZE_TO_PAGES (Length),
&BaseAddress
);
ASSERT_EFI_ERROR (Status);
@@ -1026,7 +1026,7 @@ Returns: EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface;
UINT32 MaxLbaSize;
EFI_PHYSICAL_ADDRESS BaseAddress;
- UINT64 Length;
+ UINTN Length;
UINTN NumOfBlocks;
EFI_EVENT VirtualAddressChangeEvent;
|