From patchwork Fri Feb 23 08:53:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 129335 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp361999lja; Fri, 23 Feb 2018 00:53:54 -0800 (PST) X-Google-Smtp-Source: AH8x225neDeFoF5o1eXv9u5nGBxiOfz/6cjFPnXfgm66X6gS4haNQYlLTvaFlW6ZRVGCv5xWZEME X-Received: by 10.98.112.70 with SMTP id l67mr1038048pfc.196.1519376034614; Fri, 23 Feb 2018 00:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519376034; cv=none; d=google.com; s=arc-20160816; b=vf/Vqviadyqcipt8RBKSCMNPFcmH3wSqa5ndVFsXt89hB8c+/4zlEaLckA8kGKNl/I 797euTGGVEUlu94LGytN3SpAmZX5OS3elaE/MtTH28DbFoQqknc0MPj0gtkg8nQYkTIT i0+cjw78LspILfi3Pg7vpPXEgRxviJA82n4R9vKPtQr29Pqfk4Y4H3Bho5NLg/2tuQlG 3SBqZpaJcQoe+S+S/EGxVzJTiemzBUOZfuZYTJRTEH96IsqCLhzaz45KSgAbscOR398s TnL8jLu3zLeMBfcPfle+e0i/fFfz9iUJj49tT4z7dT/BDnfGtTWVAICLlTZADA5TbtNr w2tg== 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=5tJsCC5q11YwLeQSHbHEKDTDXMI0eyxTYsHx6pTgu8A=; b=g2C7noXLhLIKaCCqbyMf5B9Ly/5u9oMo/KlXySA6R2tnzeGOkrfT924upznm1dKaX8 pqGRrikso6KFPdpFPXVQSTl/6aUyAhpGeEqVY6T20fUe9ehQtNVGmJtanhyLLzHb/SpE 8L/rm7YCffPWgQzjlmF2WWhY9nPQXgj+LnJHQoOt//e+aWRxojBNlk3LVL8vQmx++20V FuNZwy4b2WNVhx/ExRGAWRbIGpWfrMZCFwVmqK+gsXrBu2ZgGFD4b7gz2Gdf6Y7S7/ym b4l5DxGfmYLh5ZKmhwZrAVK2+JmvztxkSTArlKmMx99yqVcl3YKmL8QYkqSfSrnXQcDU zJCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LGL4HG4/; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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. [198.145.21.10]) by mx.google.com with ESMTPS id d26si1274661pge.98.2018.02.23.00.53.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 00:53:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LGL4HG4/; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 8801422436955; Fri, 23 Feb 2018 00:47:52 -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 173BC2243694C for ; Fri, 23 Feb 2018 00:47:51 -0800 (PST) Received: by mail-pl0-x242.google.com with SMTP id i6so4554180plt.7 for ; Fri, 23 Feb 2018 00:53:52 -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=Gtgz/orTjry0vbMrGO3p7NEXe4kq4V+xay6Y0/ltgaw=; b=LGL4HG4/VGXPQf7swJxOXVm7pRsJLaRgmFCvBh6SIsZGjygLJAIcnWWu1YCszzgAuX k7+FMw0hK+b5F1oS4zNyM2yl7PAAtXQ5HS/n0b1es84m0nH8aqZOu2umRk5ulY0Xe+pZ eJ76TrX0atzDbKA5fTkQLS8JSKnxy70jvLPJU= 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=Gtgz/orTjry0vbMrGO3p7NEXe4kq4V+xay6Y0/ltgaw=; b=KFWwifTDxZjT/yyFUthAH0wKzCN+cYmhhMzIzbJaOUWZRp4l7YVTwGOFH3K+0I34Um MyOhZvVna5TkwFosVFB8UP+Ej0BWRHjTS3xdtXaAVW7ABqbhR7vztUXk5dH5dq2AdvNs dR/Gnx98oAvmpWygc4JHyiVd7f8co4SmqTWhoucpjIeWZ4G3qCYPAatyxMVjfXPu6ChJ G8NMAaei2vuTKUceWrgjUK1z80JCgt48VwIF7O6A5WSH7nCFZHKwrOFx0DT8R5Zl8CNP Ea/ywJ1416c/i54hEZok7ZiQtcnxX+1Cv84f8uZRyayVn5P0GMbtm+BsQiTohC1a/wcV dJLg== X-Gm-Message-State: APf1xPAvbm2MlNYIohA5RBFHfoIEuoVBH4RNBP/33DijdMLZxln3Ko7d cVDVvgtLovOX93WKb7TK2QQyi3TbhSQ= X-Received: by 2002:a17:902:461:: with SMTP id 88-v6mr1047242ple.88.1519376032217; Fri, 23 Feb 2018 00:53:52 -0800 (PST) Received: from localhost.localdomain ([45.56.152.187]) by smtp.gmail.com with ESMTPSA id j25sm3422694pgn.92.2018.02.23.00.53.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Feb 2018 00:53:51 -0800 (PST) From: Heyi Guo To: edk2-devel@lists.01.org Date: Fri, 23 Feb 2018 16:53:27 +0800 Message-Id: <1519376008-110662-3-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519376008-110662-1-git-send-email-heyi.guo@linaro.org> References: <1519376008-110662-1-git-send-email-heyi.guo@linaro.org> Subject: [edk2] [RFC v3 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 190f4b0..fef3ece 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; }