From patchwork Mon Jun 1 12:08:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 49323 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0E93218FC for ; Mon, 1 Jun 2015 12:09:07 +0000 (UTC) Received: by wgme6 with SMTP id e6sf32756584wgm.3 for ; Mon, 01 Jun 2015 05:09:07 -0700 (PDT) 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:cc:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=GxcxKqYtKSA7ern5hFIwGrzkwOl2SU/nxHRgIXjmTxM=; b=cs+hHI5DyRyLhJo4kasBZV5FuE+hEyuqhL2vcKrHirequ9EwI1LW9iXkWG9Aa/iec1 bRg5DlvjidFP5PWohiQ59M3Fpd1iA0ivioRUm32gl8asLOQP78GsnQbgLsC/XMqAaA0x t1zpM8NiM47g7jyHbXeXKCelSf7+a3rvTqdvCCOCGcpjF2GyuKRYeeO6hEjxKpB3NTKH MWyyPutNQc+YTL36uwyy2LztoK4/VZfUDI6GrZeS9rGQEW+G+aTbqHhsGNh9eTQboavU thXjv/gpzE284zdsnGhojNjJJvBUw/J6jg6bkyCrL0bVITfmndpX4tnlZEIPvv2kCnJR h/IA== X-Gm-Message-State: ALoCoQmXNkC1jhdCYFLZzAXn+lTkqmuafPE5WDqM2QrE2oo0CLwRrKDAzuI2F2meCw6Dpedj/jfs X-Received: by 10.194.179.42 with SMTP id dd10mr20572068wjc.7.1433160547209; Mon, 01 Jun 2015 05:09:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.68 with SMTP id be4ls531468lab.47.gmail; Mon, 01 Jun 2015 05:09:07 -0700 (PDT) X-Received: by 10.112.119.139 with SMTP id ku11mr20112593lbb.49.1433160547045; Mon, 01 Jun 2015 05:09:07 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id li2si12157277lab.51.2015.06.01.05.09.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 05:09:06 -0700 (PDT) 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 laei3 with SMTP id i3so11921674lae.3 for ; Mon, 01 Jun 2015 05:09:06 -0700 (PDT) X-Received: by 10.152.27.1 with SMTP id p1mr20331491lag.112.1433160546615; Mon, 01 Jun 2015 05:09:06 -0700 (PDT) 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.108.230 with SMTP id hn6csp2266224lbb; Mon, 1 Jun 2015 05:09:05 -0700 (PDT) X-Received: by 10.50.73.198 with SMTP id n6mr12889284igv.32.1433160545606; Mon, 01 Jun 2015 05:09:05 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id d18si8127684igz.55.2015.06.01.05.09.04 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 01 Jun 2015 05:09:05 -0700 (PDT) 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 1YzOWW-0000xb-HT; Mon, 01 Jun 2015 12:08:56 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YzOWV-0000xW-8P for edk2-devel@lists.sourceforge.net; Mon, 01 Jun 2015 12:08:55 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.220.42 as permitted sender) client-ip=209.85.220.42; envelope-from=heyi.guo@linaro.org; helo=mail-pa0-f42.google.com; Received: from mail-pa0-f42.google.com ([209.85.220.42]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YzOWU-0006K0-EZ for edk2-devel@lists.sourceforge.net; Mon, 01 Jun 2015 12:08:55 +0000 Received: by payr10 with SMTP id r10so25327721pay.1 for ; Mon, 01 Jun 2015 05:08:48 -0700 (PDT) X-Received: by 10.68.94.37 with SMTP id cz5mr2485952pbb.70.1433160528741; Mon, 01 Jun 2015 05:08:48 -0700 (PDT) Received: from localhost.localdomain ([180.150.157.4]) by mx.google.com with ESMTPSA id nb10sm14345131pdb.76.2015.06.01.05.08.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 05:08:47 -0700 (PDT) From: Heyi Guo To: lersek@redhat.com Date: Mon, 1 Jun 2015 20:08:13 +0800 Message-Id: <1433160495-10385-2-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433160495-10385-1-git-send-email-heyi.guo@linaro.org> References: <1433160495-10385-1-git-send-email-heyi.guo@linaro.org> X-Spam-Score: -1.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_PASS SPF: sender matches SPF record X-Headers-End: 1YzOWU-0006K0-EZ Cc: edk2-devel@lists.sourceforge.net, ilias.biris@linaro.org Subject: [edk2] [PATCH 1/3] OvmfPkg: VirtioBlkDxe: Fix SCT test errors 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: heyi.guo@linaro.org 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 Fix SCT test errors for VirtioBlkDxe with ReadBlocks interface: 1. Media present and media ID should be checked first according to UEFI spec: "The function must return EFI_NO_MEDIA or EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are invalid so the caller can probe for changes in media state". 2. Check Buffer to be not NULL, or we will get below error from QEMU and the emulation will exit abnormally: qemu-system-aarch64: virtio: error trying to map MMIO memory Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Heyi Guo --- OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c index 862957c..36f0fa5 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -363,10 +363,31 @@ VirtioBlkReadBlocks ( { VBLK_DEV *Dev; EFI_STATUS Status; + EFI_BLOCK_IO_MEDIA *Media; + + if (This == NULL) { + return EFI_INVALID_PARAMETER; + } + + Media = This->Media; + + // Check media first according to UEFI spec + if (!Media) { + return EFI_INVALID_PARAMETER; + } + if (!Media->MediaPresent) { + return EFI_NO_MEDIA; + } + if (Media->MediaId != MediaId) { + return EFI_MEDIA_CHANGED; + } if (BufferSize == 0) { return EFI_SUCCESS; } + if (Buffer == NULL) { + return EFI_INVALID_PARAMETER; + } Dev = VIRTIO_BLK_FROM_BLOCK_IO (This); Status = VerifyReadWriteRequest (