From patchwork Wed Nov 12 14:03:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 40669 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 59844206A5 for ; Wed, 12 Nov 2014 14:04:33 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e51sf8134511eek.10 for ; Wed, 12 Nov 2014 06:04:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=M8alU63+JOH4RE7qs9cIAiSLIkQJZz95RPOJwyc6KT8=; b=hf4o6AsyXkIJL5ONfKwpIE175u8b3/0QyoCpLBXv8XVtoO1fpQzuWEslic3pSaqE5w kWyAbaPOYxBcG19TP4Wlrj70fWGPbbgstZ5UIq3cLyN8Sn0C2YbE7izFtwmUGZsgUXFa SGYEZ/xLvm8rmrOYSk+yjfQ7kLqD7IR7DBTais/vlnmqVjhLqP7bI0mvqypmcg3KSCZB DAPJBNv/OuNoLUr3aIv3a0JsCpNkUzcgI1wxsxPvOPN43pwUyZ+l4rXohlilXIr+MB/t CL+kLR/ElXyo2ehZoAIxUmjrznNe//ixlxovjXFaZpdUg2NRyk3/c74MNO8/mTdT8tjG znIw== X-Gm-Message-State: ALoCoQmjb16PHwiZDn0VWOXcK3BRdnzwC/AbT67JSB/jCTcmyp1iJgc8ju5Tojtxshvu6OrpDndR X-Received: by 10.152.7.73 with SMTP id h9mr906381laa.6.1415801072589; Wed, 12 Nov 2014 06:04:32 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.4.5 with SMTP id ca5ls541784lad.68.gmail; Wed, 12 Nov 2014 06:04:32 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr42427335laa.71.1415801072344; Wed, 12 Nov 2014 06:04:32 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id cb5si35148213lad.16.2014.11.12.06.04.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 06:04:32 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id z11so2601144lbi.39 for ; Wed, 12 Nov 2014 06:04:32 -0800 (PST) X-Received: by 10.152.37.69 with SMTP id w5mr1917961laj.67.1415801072201; Wed, 12 Nov 2014 06:04:32 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp428756lbc; Wed, 12 Nov 2014 06:04:31 -0800 (PST) X-Received: by 10.50.70.40 with SMTP id j8mr40583563igu.31.1415801070713; Wed, 12 Nov 2014 06:04:30 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id h7si19530075iga.21.2014.11.12.06.04.30 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 12 Nov 2014 06:04:30 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XoYWz-0002iW-JP; Wed, 12 Nov 2014 14:04:21 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XoYWx-0002iR-Jx for edk2-devel@lists.sourceforge.net; Wed, 12 Nov 2014 14:04:19 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=lersek@redhat.com; helo=mx1.redhat.com; Received: from mx1.redhat.com ([209.132.183.28]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1XoYWw-0000l0-9X for edk2-devel@lists.sourceforge.net; Wed, 12 Nov 2014 14:04:19 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sACE4Bux001560 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Nov 2014 09:04:11 -0500 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-88.ams2.redhat.com [10.36.116.88]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sACE457P030648; Wed, 12 Nov 2014 09:04:09 -0500 From: Laszlo Ersek To: edk2-devel@lists.sourceforge.net, jordan.l.justen@intel.com, scott@notabs.org, qin.long@intel.com Date: Wed, 12 Nov 2014 15:03:55 +0100 Message-Id: <1415801041-17550-2-git-send-email-lersek@redhat.com> In-Reply-To: <1415801041-17550-1-git-send-email-lersek@redhat.com> References: <1415801041-17550-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -2.1 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1XoYWw-0000l0-9X Subject: [edk2] [PATCH 1/7] OvmfPg: flash driver: fix type of EFI_SIZE_TO_PAGES argument (VS2010) X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lersek@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c index b56ece3..42060c8 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;