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::241; helo=mail-pl0-x241.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::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 AD33F21E08283 for ; Wed, 14 Mar 2018 22:59:00 -0700 (PDT) Received: by mail-pl0-x241.google.com with SMTP id u13-v6so3172030plq.1 for ; Wed, 14 Mar 2018 23:05:24 -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=/ILEGYndAnBI9hVnKCAq12KVLmeyy+j6gCOqjTVR60A=; b=N7p27n2Se5X/Vd4slGB6or2+szxfmCRXLLNnLcRcdNIIwBHqm/OOocE5VbWGVpdVEz bJz1H0jUvgxbvg5Ag9/9lpX26x2XFRmLLRezuh+esQq99Q5xBByWU5y6P9kRRZpuhg9O hIHiN5UPK4AlBFtytpLE9u/Gm84/ehxDoRoqk= 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=/ILEGYndAnBI9hVnKCAq12KVLmeyy+j6gCOqjTVR60A=; b=aOzjSV3a7cdpfDKRJNf927Ymo9o2+TsWUBWYOz0f/Eq1DMQcFgrvYeNhqxMKVCfHu2 nZJ1/+rLMd0mcjj5VJgB7q2YXAXihryaz+/bOHLnYPKSpJULUhciOJ46NHri4qDM/npV 2iMjlsE2wO606c9J36G5T38T0mXjDA3D6BqjsqytqxeFkcyFz3PvBW3k/vuzsYTdUk3D 7f9+OakDOP1CjCsG9Hls+9xgs6IW0eKuDCpBwTXSYIBoWU8wFS+/l2rrjIPdQGlDbB2b fKU6wA7efb/W/aeGIM5sDb0yxj0ChcsR5uFOZa9CD94vVmM5oNFoWIJMvJWVDMqjB5Jn fMMg== X-Gm-Message-State: AElRT7GQLEbRb2CsmPm+LnslVe69kGqZKI6GC87Y91LuDDmx9AKn9BmQ 9UerJSghR/aVVaMdGkBRHuZ+cPrPXEg= X-Google-Smtp-Source: AG47ELv+ERXVVOejfTHCtDvlZApWzWTwJdCqNytipcjRa+szGNBE2RzywiglDDkpRUDyKSWxkGu5lA== X-Received: by 2002:a17:902:8:: with SMTP id 8-v6mr6618374pla.291.1521093923966; Wed, 14 Mar 2018 23:05:23 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id 70sm7436192pgb.86.2018.03.14.23.05.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 23:05:23 -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 14:04:02 +0800 Message-Id: <1521093843-48615-6-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521093843-48615-1-git-send-email-heyi.guo@linaro.org> References: <1521093843-48615-1-git-send-email-heyi.guo@linaro.org> Subject: [PATCH v7 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 05:59:01 -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 Reviewed-by: Ni Ruiyu 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