From patchwork Mon Mar 20 13:11:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chenhui Sun X-Patchwork-Id: 95539 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp937824qgd; Mon, 20 Mar 2017 06:19:16 -0700 (PDT) X-Received: by 10.200.54.13 with SMTP id m13mr25080665qtb.214.1490015956343; Mon, 20 Mar 2017 06:19:16 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z53si12859845qta.146.2017.03.20.06.19.15; Mon, 20 Mar 2017 06:19:16 -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 D153663E86; Mon, 20 Mar 2017 13:19:15 +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 EE4C0607F6; Mon, 20 Mar 2017 13:16:55 +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 E61DA607B8; Mon, 20 Mar 2017 13:16:34 +0000 (UTC) Received: from mail-pf0-f177.google.com (mail-pf0-f177.google.com [209.85.192.177]) by lists.linaro.org (Postfix) with ESMTPS id C22B363E8F for ; Mon, 20 Mar 2017 13:15:19 +0000 (UTC) Received: by mail-pf0-f177.google.com with SMTP id p189so42675486pfp.1 for ; Mon, 20 Mar 2017 06:15:19 -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=ndZojj+hI3dYtdjExew4/paU2pwYirB6AWbzHfXCeas=; b=HGAb8PMPnfBPWNNUHsB3om2haSv7s0wg9OJoBYGF/YpAXtYT2kniZB2HjI8mVSfXwK /fE21BUzxuEN1AtWuVZL/dCeCL/CBy8udwfXFrWgGL/hwb3N3fAz8eraoEIF8zdWlNg1 FFlR6j4MFevZMxFPt52jJXi4mC8r0rvcZmz+PjjdJd0+77v6aaa8UDlCZV4nahld/Nco /oMTT6McOrp8NIBMFV2GYv8CzMYR8e2UeGQakkDJfoW7irM4V6DYP01nfZqyIfWWUz6e /ho6JMq6RhY+1oV1B6tJN/8LUZfpbw70b+O/o36m1xgBymxy0XP/HOo/vKjVB8sTUVn9 2Ngg== X-Gm-Message-State: AFeK/H17jF45+jqpmMS1Ax4ERY0calizwLBBDObSbhiC8NGT7mt+0G+ypxn+P399DEzMexkUodo= X-Received: by 10.84.217.2 with SMTP id o2mr39952319pli.51.1490015718991; Mon, 20 Mar 2017 06:15:18 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id a62sm33573787pgc.60.2017.03.20.06.15.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 06:15:18 -0700 (PDT) From: Chenhui Sun To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org Date: Mon, 20 Mar 2017 21:11:15 +0800 Message-Id: <1490015485-53685-12-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 , wanglijun , sunchenhui@huawei.com, wanghuiqiang@huawei.com Subject: [Linaro-uefi] [Linaro-uefi v1 11/21] Hisilicon: Fix SCT PCIBusSupportTest error 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_PCI_ROOT_BRIDGE_IO_PROTOCOL/EFI_PCI_IO_PROTOCOL must returns EFI_INVALID_PARAMETER, change return value. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: wanglijun Signed-off-by: Heyi Guo Signed-off-by: Yi Li --- .../Drivers/PciHostBridgeDxe/PciRootBridgeIo.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c b/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c index 03edcf1..30619f5 100644 --- a/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c @@ -824,8 +824,8 @@ RootBridgeConstructor ( PrivateData->Supports = EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO | EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO | \ EFI_PCI_ATTRIBUTE_ISA_IO_16 | EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO | \ EFI_PCI_ATTRIBUTE_VGA_MEMORY | \ - EFI_PCI_ATTRIBUTE_VGA_IO_16 | EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 | \ - EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER; + EFI_PCI_ATTRIBUTE_VGA_IO_16 | EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; + PrivateData->Attributes = PrivateData->Supports; Protocol->ParentHandle = HostBridgeHandle; @@ -1275,6 +1275,9 @@ RootBridgeIoPollMem ( return EFI_INVALID_PARAMETER; } + if (Width > EfiPciWidthUint64) { + return EFI_INVALID_PARAMETER; + } // // No matter what, always do a single poll. // @@ -2010,7 +2013,10 @@ RootBridgeIoMap ( ) { DMA_MAP_OPERATION DmaOperation; - + if (HostAddress == NULL || NumberOfBytes == NULL || DeviceAddress == NULL || + Mapping == NULL) { + return EFI_INVALID_PARAMETER; + } if (Operation == EfiPciOperationBusMasterRead) { DmaOperation = MapOperationBusMasterRead; } else if (Operation == EfiPciOperationBusMasterWrite) { @@ -2245,6 +2251,11 @@ RootBridgeIoSetAttributes ( PrivateData = DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(This); + if((Attributes & (EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED)) && + (ResourceBase == NULL || ResourceLength == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (Attributes != 0) { if ((Attributes & (~(PrivateData->Supports))) != 0) { return EFI_UNSUPPORTED;