From patchwork Mon Mar 20 13:11:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chenhui Sun X-Patchwork-Id: 95546 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp939184qgd; Mon, 20 Mar 2017 06:22:37 -0700 (PDT) X-Received: by 10.237.44.229 with SMTP id g92mr25653234qtd.204.1490016157303; Mon, 20 Mar 2017 06:22:37 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p125si12879903qke.181.2017.03.20.06.22.36; Mon, 20 Mar 2017 06:22:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id CEEE260A1C; Mon, 20 Mar 2017 13:22:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 55D7763E98; Mon, 20 Mar 2017 13:17:43 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A289363E98; Mon, 20 Mar 2017 13:17:32 +0000 (UTC) Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by lists.linaro.org (Postfix) with ESMTPS id 5BA8263E7D for ; Mon, 20 Mar 2017 13:15:42 +0000 (UTC) Received: by mail-pf0-f174.google.com with SMTP id e129so27024789pfh.0 for ; Mon, 20 Mar 2017 06:15:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iosVBv/pv1NytOYgAGOq55KS28UVlhj3IFnsPS95OGQ=; b=jihPn+lN1dTnE33mD+2O6G7hbAzzP0/H5gSoyOJKqSCZ/6Fs6RdnPCtpueE16ashZW EwDHvDbacoUb1thkT0VJl+/QoYGdixlCNR/1rHHnHnJO1dzfz3ioG35XR75mnErQZXYk FlqaV9vXVonuB3DC96HeGjHuTcuhn4waKJmTfnyO3KxvSlpyXHM9s8TQnEDLVo8oJNta 3jzHd5nTEKORzzpS41Vyb17IlpIdqLKUrA1aNAvk6trpTDkpO3Tm4vzm1aLvq7Ffn1AW +ooe3JFYhx92AONyd0TCdxzrCe+Vy4gp1NxKB8N+RzyuDGGl3oAZqfkAll1w9TOvP7cV g4EQ== X-Gm-Message-State: AFeK/H22sdAOUJPMBDHrxE3eIoD4RegBi6P+sHd5d+Lql0Zp+U0JHoQWnkRsuT1QoRW0G6ixMmE= X-Received: by 10.98.20.79 with SMTP id 76mr32243502pfu.242.1490015741641; Mon, 20 Mar 2017 06:15:41 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id a62sm33573787pgc.60.2017.03.20.06.15.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 06:15:41 -0700 (PDT) From: Chenhui Sun To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org Date: Mon, 20 Mar 2017 21:11:24 +0800 Message-Id: <1490015485-53685-21-git-send-email-chenhui.sun@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490015485-53685-1-git-send-email-chenhui.sun@linaro.org> References: <1490015485-53685-1-git-send-email-chenhui.sun@linaro.org> Cc: Yi Li , Chenhui Sun , wangljjun , sunchenhui@huawei.com, wanghuiqiang@huawei.com Subject: [Linaro-uefi] [Linaro-uefi v1 20/21] Hisilicon: Fixed SCT MediaAccessTest\BlockIOProtocolTest issue X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" EFI_BLOCK_IO_PROTOCOL.ReadBlocks - ReadBlocks() returns valid parameter Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: wangljjun Signed-off-by: Heyi Guo Signed-off-by: Yi Li --- Chips/Hisilicon/Drivers/FlashFvbDxe/FlashBlockIoDxe.c | 12 ++++++++++-- Chips/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c | 2 +- Drivers/Block/ramdisk/ramdisk.c | 18 +++++++++++------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Chips/Hisilicon/Drivers/FlashFvbDxe/FlashBlockIoDxe.c b/Chips/Hisilicon/Drivers/FlashFvbDxe/FlashBlockIoDxe.c index 91c0733..5d5f3fa 100644 --- a/Chips/Hisilicon/Drivers/FlashFvbDxe/FlashBlockIoDxe.c +++ b/Chips/Hisilicon/Drivers/FlashFvbDxe/FlashBlockIoDxe.c @@ -29,10 +29,14 @@ FlashBlockIoReadBlocks ( OUT VOID* Buffer ) { - FLASH_INSTANCE* Instance; - EFI_STATUS Status; + FLASH_INSTANCE* Instance; + EFI_STATUS Status; + EFI_BLOCK_IO_MEDIA *Media; + UINTN IoAlign; Instance = INSTANCE_FROM_BLKIO_THIS(This); + Media = This->Media; + IoAlign = Media->IoAlign; DEBUG ((EFI_D_INFO, "FlashBlockIoReadBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes (%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer)); @@ -44,6 +48,10 @@ FlashBlockIoReadBlocks ( { Status = EFI_MEDIA_CHANGED; } + else if (IoAlign > 0 && (((UINTN) Buffer & (IoAlign - 1)) != 0)) + { + Status = EFI_INVALID_PARAMETER; + } else { Status = FlashReadBlocks (Instance, Lba, BufferSizeInBytes, Buffer); diff --git a/Chips/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c b/Chips/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c index d118a90..c719d53 100644 --- a/Chips/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c +++ b/Chips/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.c @@ -1125,7 +1125,7 @@ FlashReadBlocks ( // We must have some bytes to read if (BufferSizeInBytes == 0) { - return EFI_BAD_BUFFER_SIZE; + return EFI_SUCCESS; } // The size of the buffer must be a multiple of the block size diff --git a/Drivers/Block/ramdisk/ramdisk.c b/Drivers/Block/ramdisk/ramdisk.c index bd2607d..14c2f0e 100644 --- a/Drivers/Block/ramdisk/ramdisk.c +++ b/Drivers/Block/ramdisk/ramdisk.c @@ -481,14 +481,18 @@ STATIC EFI_STATUS RamDiskReadBlocks( Media = This->Media; - if(BufferSize % Media->BlockSize != 0) + if (Media->MediaId != MediaId) { + return EFI_MEDIA_CHANGED; + } + if (BufferSize % Media->BlockSize != 0) { return EFI_BAD_BUFFER_SIZE; - - if(LBA > Media->LastBlock) - return EFI_DEVICE_ERROR; - - if(LBA + BufferSize / Media->BlockSize - 1 > Media->LastBlock) - return EFI_DEVICE_ERROR; + } + if (BufferSize == 0) { + return EFI_SUCCESS; + } + if (LBA + BufferSize / Media->BlockSize - 1 > Media->LastBlock) { + return EFI_INVALID_PARAMETER; + } RamDiskDev = RAM_DISK_FROM_THIS(This); RamDiskLBA = RamDiskDev->Start + MultU64x32(LBA,Media->BlockSize);