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 CBC1920956066 for ; Wed, 14 Mar 2018 20:54:40 -0700 (PDT) Received: by mail-pg0-x241.google.com with SMTP id e9so2297714pgs.10 for ; Wed, 14 Mar 2018 21:01:04 -0700 (PDT) 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=Ls40rj9ABwSl9LQsgv8UPrD1J5WGgRgvchmgjSIO/30=; b=RlT7v2TfWMnEONHXYAuExhbRrtCAp2AOsan1psCwbE0IGw+9zmXZTic842H6R6t7rE zY0VPAXNEyHCSH+UB0CuT19lT+wsmGqmQf7Cy4xHtP/eEN/3FQivth5nHGybK7nlPE0t tw0JT8yIC8NFCI2aj5gHxovyUUuq9KeHOBznY= 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=Ls40rj9ABwSl9LQsgv8UPrD1J5WGgRgvchmgjSIO/30=; b=cuzdOODCwOgNXkejJkWAfPiKYvpjyKXGaJQSMAZ2AObwudZ2RhvA+ZWpgl+PHSZI73 C4EAIC5pgujGmVeiH9R6t2XfLP6Lky+dGI+ziC4nzFsv6kswLtmwi5e0ZVhmQKZrLapA +If6mn9zmXBEnY9Miammg8NqP5QsIm6quX3j02mBSrg+qayUYGrWkj1Z0YZFDVjb3Ng0 xMRX5S90GT1+F3TLfs/BbbkKbsKhJ+JUeoHJWpMAMevba0VT1WK0B1PvsVYERsXvavqn 0iSVk+ZZKnDravutEmEVv+iX8clJEHIs2b9yTsDq4qxpLfRjnC0qtwz4v5QAtP+br3cp /H6w== X-Gm-Message-State: AElRT7H7QSdShWPaigckygBcla1a0TVUjAGYJM3Alc/bG8BmQOQ7rm2Y OGyQk5l6Tt1g9Bcc5IDZ7YVZY0xXJL4= X-Google-Smtp-Source: AG47ELvcheVk+tYlWLHNLJ7pIXOuD4E7LeEAj9vBQLdfYX3hqKoLlWoIZ8aSbQ6iGueUiCT+TI2LPQ== X-Received: by 10.99.60.79 with SMTP id i15mr5554002pgn.399.1521086463962; Wed, 14 Mar 2018 21:01:03 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id e4sm8107785pfa.166.2018.03.14.21.01.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 21:01:03 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.01.org Cc: Heyi Guo , Yi Li , Ruiyu Ni , Ard Biesheuvel , Star Zeng , Eric Dong , Laszlo Ersek , Michael D Kinney Date: Thu, 15 Mar 2018 12:00:23 +0800 Message-Id: <1521086424-113954-6-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521086424-113954-1-git-send-email-heyi.guo@linaro.org> References: <1521086424-113954-1-git-send-email-heyi.guo@linaro.org> Subject: [PATCH v6 5/6] 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: Thu, 15 Mar 2018 03:54:41 -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 Signed-off-by: Yi Li 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 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; } -- 2.7.4