From patchwork Thu Mar 15 06:04:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 131750 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp703247ljb; Wed, 14 Mar 2018 23:05:26 -0700 (PDT) X-Google-Smtp-Source: AG47ELudTgMAhhR9rhzcAzSB5CcXjmOLYsoLHtLLPMGEG2euBBJLfNzZF+O5g3DBCIOVpyUE0Xyn X-Received: by 2002:a17:902:209:: with SMTP id 9-v6mr6612259plc.403.1521093926410; Wed, 14 Mar 2018 23:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521093926; cv=none; d=google.com; s=arc-20160816; b=PMebNv//Q0AqjAwIpblafvPmbsVR66LB/6MA98CXpEu0a2jAOJHQGiioBr+YNoDAvg pJ7NzIRznRORkngBHSF+OuMQCcqutQG7TT5GjqD8kaKGM95W8GYnKcUFQAiU3LW6FNei e/VlMdufyUilpfVk0cpFcL2loleyXOYgPQ5gcxiW45e5cdtsR8xawjzzLNJOtRT9mhs7 pKVnq4nfGhtSpqxEGWyjYM/21XQ8EIjqcRZSdnMH1QNEW0nVfHi4PYRhwrPB5iq80cRI SppXKbCec5jRtsE/SoMR7uLVJqR/Kgmmarr0fG2ra5mCZUv3GVbQb4VBXMavIouan6Gb Fw1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=Y3ZpS3Kem3JBAAGMCeUNrb29FF7KHwhqR+av7wJZXXY=; b=DSY5F626h1LLYuwjPQ2X6KSvW2Zym98XcyVYr+zcaQHqozhidfvOtIohXfpR1rf3L7 0buHO0Np37ZaQ5IguE+vBjp9EmhaSdlgQKwd3n3mvKmUxCX4wv2mIjn8G9c+isHIVnFW QbS4gRY5skeyW+iU2hhGFkO0l9UZjB7TJJ6coTL0T1T9hgJ0XiG+zfh6yWEzb9pQg8QZ Zuq92BVGJNi1KQE/+eCzNu9OtMPI1BEwwo65BVq9qT/2Ou9kCbshFupf2bv1m1A6ktMg Rq/XOtzIUCBVa9ZfADxCi2QF6WzifeaNscRXJJdjGht7xyS5ylDedUPB+FcnLPFVZg68 Nn/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N7p27n2S; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 7-v6si3308273ple.604.2018.03.14.23.05.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 23:05:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N7p27n2S; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1C20A2202E4B9; Wed, 14 Mar 2018 22:59:02 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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-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 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: [edk2] [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: , Cc: Ruiyu Ni , Yi Li , Eric Dong , Ard Biesheuvel , Heyi Guo , Michael D Kinney , Laszlo Ersek , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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; }