From patchwork Tue Feb 27 02:09:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 129729 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp868945lja; Mon, 26 Feb 2018 18:10:50 -0800 (PST) X-Google-Smtp-Source: AH8x224CLrVcByAEQ6Se+2p9HYWXzDEKmTiV8awCrdABEp52ymzGNw52Ei5IH3kzcbHJ1o5jZvKa X-Received: by 2002:a17:902:7046:: with SMTP id h6-v6mr12073935plt.301.1519697450154; Mon, 26 Feb 2018 18:10:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519697450; cv=none; d=google.com; s=arc-20160816; b=y1ZTS42LKz6cPUuvP6sDAh4oGUrj+UVhbKKiN5IoG2oYLHT8cDkNaUaH5AU23KwqD+ ageHR3DewdKvtLU6CgrJMvVoQqMQUob9Ix4QWAz+PGSRLgLwInJvIwQvIajwj1cIUNT2 rowChonShfd9lobs0AYH0iIrN72sduq8bXiXZXBTVuZxcIYPjESQyC+LDlqAl7mRZviq bs/kjDHKABwgbkMMSzamYz73Unhwfgo0cIbxQ2HuQTCe0v7A9JTA49ydQk77Uk42729t odtRCb4UltmOFy3Ubf3fwVea8spqyRipkOSj3Z8qn3UH9aRZ5FnNYfQvdmsegRqFDkbj y0FQ== 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=R1rkWfDBtSG2IjouGTNQxTpXNyBmWYAhi9pFWuvfXxHc5NUsq4tfaZXO0KdzhD0BNC WEoJE8nDIbtF/gVweNwH0hK+auCJvZdsebs4z7om9NvphpPgWYxN2Npn8yqTQWJOM/y2 XxOkZXtdRCVNQTIkW5Ljfn/XJGj5pic0Udefu6E7FohDxIP0pbAwGav7FdwNpXU0T8Ep DAuDhzq3Rat8lwtCHNKFxIXZlfsfdWNtP3rARlKPKwOmQ5GxKQIBmHocfS2nDLfEVITI VgVv2XhaV7qEwoyWUor93QDCxCJ77uxR7o9yPvDbrsWynn0c7IJSeQexPUV0pFaBqj+W HvCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UkfZeyX2; 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 d19-v6si7592840pls.822.2018.02.26.18.10.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2018 18:10:50 -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=UkfZeyX2; 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 8827820955F2B; Mon, 26 Feb 2018 18:04:43 -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::243; helo=mail-pl0-x243.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) (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 26902209574EF for ; Mon, 26 Feb 2018 18:04:42 -0800 (PST) Received: by mail-pl0-x243.google.com with SMTP id w21so10470278plp.11 for ; Mon, 26 Feb 2018 18:10:47 -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=UkfZeyX2SARL+o5dHkLdlXATEIezdepys0QYhBzU2CaSo5stdqDB7t2JN0vRGeCMI7 eyihx7Et4swMOkCU+4Zh0GrFJWfFp5D5c1iiHcsnBspl43h35rA/N/22oIHFcEoG+1Ab FItvGR/A3OXJskopW013f7szJ+K7B18ZlH1NE= 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=f0QVlW2BZu8mqqias27wdIFb4bHaf1Dm8FVU7PY61yeB5AhWNxZBlgr9YdVsmFMxZi J95ZMO+nKIITa3F0AC5UPAzRao6rIage6TfK+08c4p4KqZgGvbz50LlUVodkPhgQpSNW 7EP7i3GhyBNrh/bEsQbnoGZ5yrGW66mQDNwoUelsxs/w8TX9x5klAQViiF1BC2qSLsXH 7B61HOIcN8DGhk8A1q8NkeIPqeiKjvrJIQ0qX9QNYBIvLzbOwz4VUWJR14zCtdOhPUO8 7aifys5j3KnyVEsyJMhYG8yhFYplSfBgr2TyFZWqj6RiWfm9/dDrac7JTmRU5idtVwR2 qA6Q== X-Gm-Message-State: APf1xPAbw1OZZJt38qzd8chlX1dZ27c8jtE0YWOPmbJRY65K8weUwaae YsuHwVe5FKwIw+/rhPpA5Q7NAONK9oI= X-Received: by 2002:a17:902:710f:: with SMTP id a15-v6mr12304249pll.87.1519697447479; Mon, 26 Feb 2018 18:10:47 -0800 (PST) Received: from localhost.localdomain ([104.237.91.49]) by smtp.gmail.com with ESMTPSA id a138sm21289210pfd.47.2018.02.26.18.10.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 18:10:47 -0800 (PST) From: Heyi Guo To: edk2-devel@lists.01.org Date: Tue, 27 Feb 2018 10:09:48 +0800 Message-Id: <1519697389-3525-3-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519697389-3525-1-git-send-email-heyi.guo@linaro.org> References: <1519697389-3525-1-git-send-email-heyi.guo@linaro.org> Subject: [edk2] [RFC v4 2/3] 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; }