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: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 C1AA62034D8DA for ; Wed, 21 Feb 2018 22:49:08 -0800 (PST) Received: by mail-pg0-x241.google.com with SMTP id w17so1678590pgv.6 for ; Wed, 21 Feb 2018 22:55:09 -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=+GJo2QQXZEN++sPMqRowakOjtGx+V6d9h5IFqO803no=; b=YymQMF+F4UsUboJDukORe9WZgW8u/DvODOKGKBZuOfV6iqGcLhuEvzlH7Z5afUSP10 C0nXNiMOHTHfKCH7sYy45rTFe4XZWEOXl3eSJdYnCeXPtFtqxjcqYe4TmoIi9l+n4T2F PYSbfcO4RQdbbi8A3Un8noRXskAnt6ZkBPZec= 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=+GJo2QQXZEN++sPMqRowakOjtGx+V6d9h5IFqO803no=; b=Xj6wV9yHm0sqfzN8Dse9aaOzY2qT/wSW8lYexUz7+8ETJtdaiCFOzkp6SVYd9dR8jA RdBkt/jsbVXtSTFxlsqhNJHS1w1rkwcBF1qqChZWWElM+Wz6XMBg2AWfe13Rv19BWdKn uto+5Ydl9fNlFXulIjL+Nd96/WF2cCHqnoNufe7MSVrkH7v7vM5ZvHdLdJaWEeRLi2R2 AE+mHmO55jXySsWy60NWJ8jvEAzLIQRXzWhlX9AGXjkLcbBRPntgHDzSUcE2wddbU6wM 6tTEm8Typlz+C0GSFMA7z981hwAEY6HLrdq0d+ioz/nBwobKo7J3HChfR2gl2bAXqoge 8V3A== X-Gm-Message-State: APf1xPD36cXiHY8lQ2oCsQELjeanVJuj/HpwR7MswyyX6pkul/UrmE/G 1p6CC5+oWP1E6Q8hpt/e7ZOSITkDmB4= X-Google-Smtp-Source: AH8x227mMfyCYLwqWcc/HOGZljV7aq0gFJjG1Fi/HdwTbFaXdrpZNSsT81bgZC/3oZ1aV4qCGJr6Ig== X-Received: by 10.99.125.16 with SMTP id y16mr4780627pgc.3.1519282508615; Wed, 21 Feb 2018 22:55:08 -0800 (PST) Received: from localhost.localdomain ([45.56.152.187]) by smtp.gmail.com with ESMTPSA id v88sm35677342pfd.68.2018.02.21.22.55.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Feb 2018 22:55:08 -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: Thu, 22 Feb 2018 14:54:34 +0800 Message-Id: <1519282474-94811-3-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519282474-94811-1-git-send-email-heyi.guo@linaro.org> References: <1519282474-94811-1-git-send-email-heyi.guo@linaro.org> Subject: [RFC v2 2/2] MdeModulePkg/PciBus: return CPU address for GetBarAttributes 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: Thu, 22 Feb 2018 06:49:09 -0000 PciIo::GetBarAttributes should return CPU view address according to UEFI spec 2.7, so we change the implementation to follow the spec. 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c index 190f4b0..0aafcba 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c @@ -1814,8 +1814,8 @@ GetMmioAddressTranslationOffset ( 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; } @@ -1968,6 +1968,11 @@ PciIoGetBarAttributes ( return EFI_UNSUPPORTED; } } + + // According to UEFI spec 2.7, we need return CPU view address for PciIo::GetBarAttributes, + // and PCI view = CPU view + translation + Descriptor->AddrRangeMin -= Descriptor->AddrTranslationOffset; + Descriptor->AddrRangeMax -= Descriptor->AddrTranslationOffset; } return EFI_SUCCESS; -- 2.7.4