From patchwork Thu Mar 1 06:57:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 130113 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp2452426edc; Wed, 28 Feb 2018 22:58:18 -0800 (PST) X-Google-Smtp-Source: AG47ELuejmXWRY/h9KIdr4bQ4Ez6LgkGWxlWmBMiAmlJ+U/o9ZTCdOngMJ2l+6IT1RTJmQ8QBlnM X-Received: by 10.99.117.76 with SMTP id f12mr753564pgn.410.1519887498445; Wed, 28 Feb 2018 22:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519887498; cv=none; d=google.com; s=arc-20160816; b=R6M/oMRzzUBM9k0YIkJuGeavae2Mg7JeCsVFpCLqW9a7qyIge1XDmv6p8XbedN31NG GQYDtjTSFYe6++gp3Fz1nYEUwdDWF2fvCIo3PeKPbHe31oKv5nb8MK8cTKlNPKMkg7g1 oYslK9DwXy83H2cn7u4yRfZnhhg2DsJZK13qjsfwUyVTYQhPZ6PLej1SOdH2STLifN/H oLzca4cbIlkczNwOxEKUai+6AtU4AZXi4byqaD5wYtA0SRtCVPXhu5v73Rf5yIJNxUoX RRhGcdumlTtu9AcWCryv3Oh/McvXeqlg5Dn6+C1jERlmi2N/oYLOQnOEkg3x87lZIuy2 Tlmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=UDNdoFR4SAy+V/us9MtJt2m1KC6lQkSITkNyl/kAPmc=; b=rB7D9kcJkxQnqgLktUxBWc9NcF5wh573h0soa9oZvW38Ste9AkOUdMu1mVvi51baYp MWvcyI5tN1qR+bm9nbi7sys0OlBSz96QTxjXsRKS/uxI/60Wc9U7wdl8CjM7suWUbGNh 6hBAatdMd82MAB7GTPu6bByBcrbQHqIVM+sncr8kambnFyRJJeCia/bcjZsctp90itiz Iksswb6BMtXRE6Rdl8sflEukRVw97HMXnW3qsM5oazvUYlRC4dltN4w6IRduUjlZWW0q 94Q04DCWKDS4wRBsfVtmU//IBB0E3fBozemZNeR031UM0gY/WJ/wBht05H5UkQylPPCS Xyow== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aaPDSb9i; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id t28si1271896pfk.309.2018.02.28.22.58.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 22:58:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aaPDSb9i; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BD4E22034D8E3; Wed, 28 Feb 2018 22:52:09 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::242; helo=mail-pl0-x242.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x242.google.com (mail-pl0-x242.google.com [IPv6:2607:f8b0:400e:c01::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7CB332242384D for ; Wed, 28 Feb 2018 22:52:08 -0800 (PST) Received: by mail-pl0-x242.google.com with SMTP id 93-v6so3127957plc.9 for ; Wed, 28 Feb 2018 22:58:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AYSvTpkKH3HkKndCwIKm4x8MwR03fLPgznyqaVdDMa8=; b=aaPDSb9iNRBZGRVw9Tl6EWkzr/pSosfiiv04t850nnMzRzL6NOCgIVPCR36xnXMf4d WSuJ8Vo4zCXS4jXO5n/3xRl53CgYmte47zlA4InVIWKC++SL+7WYnYaAEngjoEtXYLfV KNkvKF/VcCswgYpOiSfhcW8sY/ZZ5Q5FK0oR0= 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=AYSvTpkKH3HkKndCwIKm4x8MwR03fLPgznyqaVdDMa8=; b=BbmxM6lxN8B7+/00OWV/TGNgHYPLaTQDTPKpEQkbRIe3A3B1zqCU9mtIsyn0qU6TDx 8XUT0IPQhjdqKI4FjT+/nI61dZJmoh7+WcYb2Zj4K0GBgFlVr/gw2Ir2ooxEXXhP0BXY iM0bIBMMOSV8oJUb53u9SnUySPv8SVU9tQAhHVziWGuSNPE1DXUirkf70SS0i/gx96tO k3zGmmVKg+gUrAW4k8gJeqaPGkDkAG/UNvoHqMUpQ/LC0RsLdr8saRtUBIflwV20sXLb yVcmjJiSg3ZDfWGhCm/8QwG3zPltYBZtn67ZVH9+rZD32EfGWV87LRvNiVq+w0y1ApTW 0pxw== X-Gm-Message-State: APf1xPCKWadWY9Ed/NVehbfyOfU32TRNmltdVPXUXcSPvjEnE/mPXu+M DLHvqr0KHcv9PlCRgXvY6Fq2CjUNuGo= X-Received: by 2002:a17:902:518d:: with SMTP id y13-v6mr955163plh.121.1519887496119; Wed, 28 Feb 2018 22:58:16 -0800 (PST) Received: from localhost.localdomain ([45.56.152.115]) by smtp.gmail.com with ESMTPSA id p63sm6489867pfk.74.2018.02.28.22.58.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Feb 2018 22:58:15 -0800 (PST) From: Heyi Guo To: edk2-devel@lists.01.org Date: Thu, 1 Mar 2018 14:57:23 +0800 Message-Id: <1519887444-75510-6-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519887444-75510-1-git-send-email-heyi.guo@linaro.org> References: <1519887444-75510-1-git-send-email-heyi.guo@linaro.org> Subject: [edk2] [PATCH v5 5/6] MdeModulePkg/PciBus: convert host address to device address X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Eric Dong , Ard Biesheuvel , Heyi Guo , Michael D Kinney , Laszlo Ersek , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" According to UEFI spec 2.7, PciRootBridgeIo->Configuration() should return host address (CPU view ddress) rather than device address (PCI view address), so in function GetMmioAddressTranslationOffset we need to convert the range to device address before comparing. And device address = host address + translation offset. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Heyi Guo Cc: Ruiyu Ni Cc: Ard Biesheuvel Cc: Star Zeng Cc: Eric Dong Cc: Laszlo Ersek Cc: Michael D Kinney --- MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c index 190f4b0dc7ed..fef3eceb7f62 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c @@ -1812,10 +1812,14 @@ GetMmioAddressTranslationOffset ( return (UINT64) -1; } + // According to UEFI 2.7, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL::Configuration() + // returns host address instead of device address, while AddrTranslationOffset + // is not zero, and device address = host address + AddrTranslationOffset, so + // we convert host address to device address for range compare. while (Configuration->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) { if ((Configuration->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) && - (Configuration->AddrRangeMin <= AddrRangeMin) && - (Configuration->AddrRangeMin + Configuration->AddrLen >= AddrRangeMin + AddrLen) + (Configuration->AddrRangeMin + Configuration->AddrTranslationOffset <= AddrRangeMin) && + (Configuration->AddrRangeMin + Configuration->AddrLen + Configuration->AddrTranslationOffset >= AddrRangeMin + AddrLen) ) { return Configuration->AddrTranslationOffset; }