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::243; helo=mail-pl0-x243.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) (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 26902209574EF for ; Mon, 26 Feb 2018 18:04:42 -0800 (PST) Received: by mail-pl0-x243.google.com with SMTP id w21so10470278plp.11 for ; Mon, 26 Feb 2018 18:10:47 -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=AYSvTpkKH3HkKndCwIKm4x8MwR03fLPgznyqaVdDMa8=; b=UkfZeyX2SARL+o5dHkLdlXATEIezdepys0QYhBzU2CaSo5stdqDB7t2JN0vRGeCMI7 eyihx7Et4swMOkCU+4Zh0GrFJWfFp5D5c1iiHcsnBspl43h35rA/N/22oIHFcEoG+1Ab FItvGR/A3OXJskopW013f7szJ+K7B18ZlH1NE= 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=AYSvTpkKH3HkKndCwIKm4x8MwR03fLPgznyqaVdDMa8=; b=f0QVlW2BZu8mqqias27wdIFb4bHaf1Dm8FVU7PY61yeB5AhWNxZBlgr9YdVsmFMxZi J95ZMO+nKIITa3F0AC5UPAzRao6rIage6TfK+08c4p4KqZgGvbz50LlUVodkPhgQpSNW 7EP7i3GhyBNrh/bEsQbnoGZ5yrGW66mQDNwoUelsxs/w8TX9x5klAQViiF1BC2qSLsXH 7B61HOIcN8DGhk8A1q8NkeIPqeiKjvrJIQ0qX9QNYBIvLzbOwz4VUWJR14zCtdOhPUO8 7aifys5j3KnyVEsyJMhYG8yhFYplSfBgr2TyFZWqj6RiWfm9/dDrac7JTmRU5idtVwR2 qA6Q== X-Gm-Message-State: APf1xPAbw1OZZJt38qzd8chlX1dZ27c8jtE0YWOPmbJRY65K8weUwaae YsuHwVe5FKwIw+/rhPpA5Q7NAONK9oI= X-Google-Smtp-Source: AH8x224wuZM7YRi7lhankbNrEBRgx2jnGVhQR/B6Irpd9e8EbEmkilNDi74hZq48pOGQZtbZHE13xA== X-Received: by 2002:a17:902:710f:: with SMTP id a15-v6mr12304249pll.87.1519697447479; Mon, 26 Feb 2018 18:10:47 -0800 (PST) Received: from localhost.localdomain ([104.237.91.49]) by smtp.gmail.com with ESMTPSA id a138sm21289210pfd.47.2018.02.26.18.10.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 18:10:47 -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: Tue, 27 Feb 2018 10:09:48 +0800 Message-Id: <1519697389-3525-3-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519697389-3525-1-git-send-email-heyi.guo@linaro.org> References: <1519697389-3525-1-git-send-email-heyi.guo@linaro.org> Subject: [RFC v4 2/3] 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: Tue, 27 Feb 2018 02:04:42 -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 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