From patchwork Thu Nov 13 11:16:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 40733 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 A83F3240ED for ; Thu, 13 Nov 2014 11:16:55 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e51sf9251527eek.10 for ; Thu, 13 Nov 2014 03:16:55 -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=bl/j+Ck95GOiefxQO+QHq516H58ODReAagYLqbp5Nn7483rHqgUEQv/8VSDmaql9BH lMWg0rtqRD84k9JU2y/UlBYaPhgZvGPaq2XnbqRDi7jJR/UYWx+eTPklqeufdrzov3kP Bb5ecA87CMQzRJwGXBYcgJ+/S6xtuboiZv3a1/MuANehomIRDnvzVgmfD8BhbRMUdCo/ Wkm2/h8i9XZBjtw9B5cUJi7dIf+WcJM9RAg0tPXgrdhkltFlA9Jr5FR+2sMs4N4FkPJv UL+g2MrGWXJeJAme+Yf7VDBvU/ttpXuk7BWz0d4Qg1nIs4Ys4hwC9RK0nz8XcZ0m8dWu pFAw== X-Gm-Message-State: ALoCoQn1Wdoxka32F7HD0lrMMYsAh/you2nTE/XjYtS3nuO65raDy7AFDQIGCIUzZmhSdcXpXeVb X-Received: by 10.112.159.199 with SMTP id xe7mr204764lbb.21.1415877414597; Thu, 13 Nov 2014 03:16:54 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.201 with SMTP id s9ls484443laj.100.gmail; Thu, 13 Nov 2014 03:16:54 -0800 (PST) X-Received: by 10.112.146.37 with SMTP id sz5mr1766720lbb.27.1415877414324; Thu, 13 Nov 2014 03:16:54 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id y9si38202140lbr.1.2014.11.13.03.16.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Nov 2014 03:16:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id ge10so13211085lab.30 for ; Thu, 13 Nov 2014 03:16:54 -0800 (PST) X-Received: by 10.153.7.170 with SMTP id dd10mr1809869lad.44.1415877414229; Thu, 13 Nov 2014 03:16:54 -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 ew9csp572463lbc; Thu, 13 Nov 2014 03:16:53 -0800 (PST) X-Received: by 10.43.14.74 with SMTP id pp10mr1612438icb.72.1415877412124; Thu, 13 Nov 2014 03:16:52 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id h10si27245373igt.36.2014.11.13.03.16.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Nov 2014 03:16:52 -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-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XosOJ-0005SK-Fd; Thu, 13 Nov 2014 11:16:43 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XosOH-0005S2-CE for edk2-devel@lists.sourceforge.net; Thu, 13 Nov 2014 11:16:41 +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 1XosOF-0005G4-VG for edk2-devel@lists.sourceforge.net; Thu, 13 Nov 2014 11:16:41 +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 sADBGYOW030367 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 13 Nov 2014 06:16:34 -0500 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-83.ams2.redhat.com [10.36.116.83]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sADBGTmx018997 for ; Thu, 13 Nov 2014 06:16:32 -0500 From: Laszlo Ersek To: edk2-devel@lists.sourceforge.net Date: Thu, 13 Nov 2014 12:16:19 +0100 Message-Id: <1415877385-18341-2-git-send-email-lersek@redhat.com> In-Reply-To: <1415877385-18341-1-git-send-email-lersek@redhat.com> References: <1415877385-18341-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -2.5 (--) 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 -1.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1XosOF-0005G4-VG Subject: [edk2] [PATCH v2 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.215.43 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;