From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AH8x225iz4M1EjHQ5fcrczGTQIX9gvZnbxRZw7gnbqDoE0x3p2v/WrYoGpFYTo1nPwZQaxxiksKcmg== 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 Cc: Heyi Guo , Ruiyu Ni , Ard Biesheuvel , Star Zeng , Eric Dong , Laszlo Ersek , Michael D Kinney 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: [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: , X-List-Received-Date: Fri, 23 Feb 2018 08:47:51 -0000 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(-) 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; } -- 2.7.4