From patchwork Thu Nov 13 11:16:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 40738 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C146D240ED for ; Thu, 13 Nov 2014 11:17:06 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id b13sf7640517wgh.2 for ; Thu, 13 Nov 2014 03:17:00 -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=17rj+2avAsY0NEo2dD1id8hU/I5I49HQKSxMQasIKQg=; b=Jn3F77CplnMvaQsOZO8QiBHoj7lqclUNJoRWmjrxq2rdP8xveABPfxmVBZq9IKM1UJ sP3Zv2PKgYQz6fDloc0VEcIeVb264cGgmlUjFGSkuAYAPuuYMrJW/gKTJdZ9PRAX+tg/ sowLjaFsXY7YnK/+PhGNCGanihoQUmbPBt47+WuIt3kjEsQOdr1m8w0IJR/7WYmtwbSd IROd0fdJM/Cr8fGQUwn5pUt9rmqArUbEH/CZ+A7Ko3e9UZqsEkab4cCJidHo8lohSo62 K4Gh0WzvGiDkr8em6xYjCA1nzJnR8tuV5X83zQWg7OeWPpUvzux1Wv9J3iMB3VMJrbko QKhw== X-Gm-Message-State: ALoCoQmx9pq9mC7AyjVQigjLgUHAxCoBaKjqog3EkQsVgp/GDRKFHQ77exVASVutf+Ve0nTYE5J5 X-Received: by 10.194.71.19 with SMTP id q19mr432450wju.5.1415877419990; Thu, 13 Nov 2014 03:16:59 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.9 with SMTP id ls9ls782718lac.44.gmail; Thu, 13 Nov 2014 03:16:59 -0800 (PST) X-Received: by 10.152.5.6 with SMTP id o6mr1869576lao.8.1415877419796; Thu, 13 Nov 2014 03:16:59 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id az19si38207831lab.0.2014.11.13.03.16.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Nov 2014 03:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id hz20so2922878lab.31 for ; Thu, 13 Nov 2014 03:16:59 -0800 (PST) X-Received: by 10.152.37.69 with SMTP id w5mr1718118laj.67.1415877419696; Thu, 13 Nov 2014 03:16:59 -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 ew9csp572471lbc; Thu, 13 Nov 2014 03:16:58 -0800 (PST) X-Received: by 10.107.155.209 with SMTP id d200mr1995095ioe.12.1415877418252; Thu, 13 Nov 2014 03:16:58 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id x9si39992997ica.12.2014.11.13.03.16.57 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Nov 2014 03:16:58 -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 1XosOP-0001wO-Vf; Thu, 13 Nov 2014 11:16:50 +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 1XosOO-0001w7-Bj for edk2-devel@lists.sourceforge.net; Thu, 13 Nov 2014 11:16:48 +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 1XosON-0007Ri-Fq for edk2-devel@lists.sourceforge.net; Thu, 13 Nov 2014 11:16:48 +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 sADBGeLb030381 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 13 Nov 2014 06:16:40 -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 sADBGTn1018997 for ; Thu, 13 Nov 2014 06:16:39 -0500 From: Laszlo Ersek To: edk2-devel@lists.sourceforge.net Date: Thu, 13 Nov 2014 12:16:21 +0100 Message-Id: <1415877385-18341-4-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: 1XosON-0007Ri-Fq Subject: [edk2] [PATCH v2 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.215.44 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 --- 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; }