From patchwork Thu Mar 15 04:00: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: 131734 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp618614ljb; Wed, 14 Mar 2018 21:01:12 -0700 (PDT) X-Google-Smtp-Source: AG47ELv3TpSoCl7n9ciwLLX4NGmjYJHPrVdI9sMa+x2LWRBlcQiv04HLk+tIlvdI5TlgwCpq/zSu X-Received: by 10.98.85.197 with SMTP id j188mr6453384pfb.86.1521086472069; Wed, 14 Mar 2018 21:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521086472; cv=none; d=google.com; s=arc-20160816; b=pvD5YtatYF4vTxV8+Ktld+O23lhJ6uWBV4thtxROCBSbjSY1h5NNgsudrvUr70qqhC 2wvd6vFXO04nHvebnMfxIBXhyllEkux+dBxbujJaWqpWSVQ99OHX9e6rNoyzm/D2NJfY vUKp/hfVfkz3VdPYxR9Or16d4ZQ4iY7BRFaY3s2dF3/u9y/3dsrvhtgo0ohcQwSj5mI6 vxyZAYHLk+HIaveYsBnub8zw9QNHJh8XBkbM/Vy6IyrmhyLdcGODRGXfOaejiFqmrp8u yoVZzpu+EuusT4Xdu/yvEv5gEqKWeytHK3NIGoBJsdi2GQtCvIpkb72V+Aqadn1uC5Lk RExg== 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=eAL6dcIHsG31FMAVchMRyiTq2y8b8QbUk33q8lugBoA=; b=zOCp+6CeH9qAnyZshGaTyVyE+GTeo/Qf8M/BjxNQJlieAumeMdix3OLoChsblHuwsC NeJAzjq2k9DV6xFeHG/U5JT2lIQxfOiuf2NsUrkvV333NsM8WVcVXgH45GlEFo3R/vfF d3X/6SHdAEEL6+03MopGO0yLHx4tWViV5AJm9isswHBmLo3KkLZ4Yaw7MgD/Q3+F4uDP CEq+C4OYda0KzcLW+khuF8bIaorE6jMIWk9LtDhqv5dopmfBbEOHxo8tkvim2pCTBI4m J1CnM2Xkojih7s/8BmsEBLgcjNegw6Hc7C4/yRijH+qaKPhF9sAaX7zNuqcokmoyZeyC /yfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RlT7v2Tf; 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 g4si2293074pgr.471.2018.03.14.21.01.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 21:01:11 -0700 (PDT) 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=RlT7v2Tf; 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 82D1020956066; Wed, 14 Mar 2018 20:54:42 -0700 (PDT) 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:c05::241; helo=mail-pg0-x241.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (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 CBC1920956066 for ; Wed, 14 Mar 2018 20:54:40 -0700 (PDT) Received: by mail-pg0-x241.google.com with SMTP id e9so2297714pgs.10 for ; Wed, 14 Mar 2018 21:01:04 -0700 (PDT) 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=Ls40rj9ABwSl9LQsgv8UPrD1J5WGgRgvchmgjSIO/30=; b=RlT7v2TfWMnEONHXYAuExhbRrtCAp2AOsan1psCwbE0IGw+9zmXZTic842H6R6t7rE zY0VPAXNEyHCSH+UB0CuT19lT+wsmGqmQf7Cy4xHtP/eEN/3FQivth5nHGybK7nlPE0t tw0JT8yIC8NFCI2aj5gHxovyUUuq9KeHOBznY= 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=Ls40rj9ABwSl9LQsgv8UPrD1J5WGgRgvchmgjSIO/30=; b=cuzdOODCwOgNXkejJkWAfPiKYvpjyKXGaJQSMAZ2AObwudZ2RhvA+ZWpgl+PHSZI73 C4EAIC5pgujGmVeiH9R6t2XfLP6Lky+dGI+ziC4nzFsv6kswLtmwi5e0ZVhmQKZrLapA +If6mn9zmXBEnY9Miammg8NqP5QsIm6quX3j02mBSrg+qayUYGrWkj1Z0YZFDVjb3Ng0 xMRX5S90GT1+F3TLfs/BbbkKbsKhJ+JUeoHJWpMAMevba0VT1WK0B1PvsVYERsXvavqn 0iSVk+ZZKnDravutEmEVv+iX8clJEHIs2b9yTsDq4qxpLfRjnC0qtwz4v5QAtP+br3cp /H6w== X-Gm-Message-State: AElRT7H7QSdShWPaigckygBcla1a0TVUjAGYJM3Alc/bG8BmQOQ7rm2Y OGyQk5l6Tt1g9Bcc5IDZ7YVZY0xXJL4= X-Received: by 10.99.60.79 with SMTP id i15mr5554002pgn.399.1521086463962; Wed, 14 Mar 2018 21:01:03 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id e4sm8107785pfa.166.2018.03.14.21.01.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 21:01:03 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.01.org Date: Thu, 15 Mar 2018 12:00:23 +0800 Message-Id: <1521086424-113954-6-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521086424-113954-1-git-send-email-heyi.guo@linaro.org> References: <1521086424-113954-1-git-send-email-heyi.guo@linaro.org> Subject: [edk2] [PATCH v6 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 , Yi Li , 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 Signed-off-by: Yi Li 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; }