From patchwork Wed Nov 12 14:03:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 40670 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 80BAB206A5 for ; Wed, 12 Nov 2014 14:04:41 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf2006689wiv.2 for ; Wed, 12 Nov 2014 06:04:40 -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=0ad5PXTV+Wh5L3VVjc9SBG/zVA5d5qSchEwvrcLmWl0=; b=VQpJc6MRSDgef+7Zv3y1RHpxaZ45m+n5eY7E20IodX5XOVev1yOrxZZwQmptJQKaWH MUSRQLucu+hUcoLQPVu36Q95g846oczDYxgHvHRmbKzQivhxtYpKUwlvjHl8Qvc8+YVQ OU9ga2mpk+gMroDkcp46MLY2rkgHFVMGAjGdJ3b+5cX/7bD2vU8ZS1vw916nojEDL5uL IdKg7YPqoLJALwovKAVCT8Ysx0O9Z36oIXuo/FpUec/lcbrzI9IgJDCx55a8JSJedbC5 a/LFGqGMECCwtm3X5//o7w1RJo5C+U+1pjnGYogl8vyu2SFrGvPggE8el6HTQKv24/nJ mQJA== X-Gm-Message-State: ALoCoQmBDtwxQJD8J8NRwQVsMXotQUfVmUMGRHQT4mUzyqfxDU1fa5QIY5eBLgRjQoUSPOys6vUo X-Received: by 10.112.55.10 with SMTP id n10mr521516lbp.14.1415801080804; Wed, 12 Nov 2014 06:04:40 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.169 with SMTP id r9ls553285laj.57.gmail; Wed, 12 Nov 2014 06:04:40 -0800 (PST) X-Received: by 10.112.12.35 with SMTP id v3mr2703704lbb.80.1415801080248; Wed, 12 Nov 2014 06:04:40 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id ir2si34888724lac.127.2014.11.12.06.04.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 06:04:40 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id 10so9475854lbg.0 for ; Wed, 12 Nov 2014 06:04:40 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr41789589laz.27.1415801080146; Wed, 12 Nov 2014 06:04:40 -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 ew9csp428781lbc; Wed, 12 Nov 2014 06:04:39 -0800 (PST) X-Received: by 10.43.128.71 with SMTP id hd7mr47808693icc.36.1415801078712; Wed, 12 Nov 2014 06:04:38 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id nk7si36347699icb.61.2014.11.12.06.04.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 12 Nov 2014 06:04:38 -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-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XoYXA-00044X-Fm; Wed, 12 Nov 2014 14:04:32 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XoYX9-00044R-9r for edk2-devel@lists.sourceforge.net; Wed, 12 Nov 2014 14:04:31 +0000 Received-SPF: pass (sog-mx-1.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-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1XoYX8-000129-C8 for edk2-devel@lists.sourceforge.net; Wed, 12 Nov 2014 14:04:31 +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 sACE4LqY001598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Nov 2014 09:04:21 -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 sACE457R030648; Wed, 12 Nov 2014 09:04:18 -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:57 +0100 Message-Id: <1415801041-17550-4-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: 1XoYX8-000129-C8 Subject: [edk2] [PATCH 3/7] OvmfPkg: flash driver: drop needlessly wide multiplication (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.169 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 From: Scott Duplichan The current types of subexpressions used in QemuFlashPtr() are as follows. (We also show the types of "larger" subexpressions, according to operator binding.) mFlashBase + (Lba * mFdBlockSize) + Offset ^ ^ ^ ^ | | | | (UINT8*) EFI_LBA UINTN UINTN (UINT64) --------------------------------- ------ (UINT8*) UINTN ------------------------------------------ (UINT8*) When building with VS2010 for Ia32 / NOOPT, the 64-by-32 bit multiplication is translated to an intrinsic, which is not allowed in edk2. Recognize that "Lba" is always bounded by "mFdBlockCount" (an UINTN) here -- all callers of QemuFlashPtr() ensure that. In addition, the flash chip in question is always under 4GB, which is why we can address it at all on Ia32. Narrow "Lba" to UINTN, without any loss of range. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Scott Duplichan [commit message by lersek@redhat.com] Signed-off-by: Laszlo Ersek Signed-off-by: Laszlo Ersek --- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c index f9c6f5c..a96e0e5 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c @@ -54,7 +54,7 @@ QemuFlashPtr ( IN UINTN Offset ) { - return mFlashBase + (Lba * mFdBlockSize) + Offset; + return mFlashBase + ((UINTN)Lba * mFdBlockSize) + Offset; }