From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4984520945BE2 for ; Sun, 10 Sep 2017 21:58:30 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 10 Sep 2017 22:01:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,376,1500966000"; d="scan'208";a="1013044046" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.7]) by orsmga003.jf.intel.com with ESMTP; 10 Sep 2017 22:01:23 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Ard Biesheuvel , Benjamin Herrenschmidt , Andrew Fish , Dong Wei , Laszlo Ersek , Bartosz Szczepanek Date: Mon, 11 Sep 2017 13:01:21 +0800 Message-Id: <20170911050121.85708-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 Subject: [PATCH] MdeModulePkg/PciBusDxe: GetBarAttributes() returns Host address X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Sep 2017 04:58:30 -0000 Per the UEFI Spec, GetBarAttributes() should return the Host address. But current implementation returns the address read from the BAR, which is the Device address. Per the description of AddressTranslationOffset in ACPI spec: "For bridges that translate addresses across the bridge, this is the offset that must be added to the address on the secondary side to obtain the address on the primary side." HostAddress = DeviceAddress + AddressTranslationOffset. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Ard Biesheuvel Cc: Benjamin Herrenschmidt Cc: Andrew Fish Cc: Dong Wei Cc: Laszlo Ersek Cc: Bartosz Szczepanek --- MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c index cc7125e4fc..852d35d710 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c @@ -1955,7 +1955,7 @@ PciIoGetBarAttributes ( End->Checksum = 0; // - // Get the Address Translation Offset + // Get the Address Translation Offset and convert the Device address to Host address. // if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) { Descriptor->AddrTranslationOffset = GetMmioAddressTranslationOffset ( @@ -1967,6 +1967,7 @@ PciIoGetBarAttributes ( FreePool (Descriptor); return EFI_UNSUPPORTED; } + Descriptor->AddrRangeMin += Descriptor->AddrTranslationOffset; } } -- 2.12.2.windows.2