From nobody Tue May 7 18:57:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521086457598559.5169498360959; Wed, 14 Mar 2018 21:00:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AF0F422603B1C; Wed, 14 Mar 2018 20:54:32 -0700 (PDT) Received: from mail-pf0-x231.google.com (mail-pf0-x231.google.com [IPv6:2607:f8b0:400e:c00::231]) (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 29C80225892D3 for ; Wed, 14 Mar 2018 20:54:30 -0700 (PDT) Received: by mail-pf0-x231.google.com with SMTP id j2so2354515pff.10 for ; Wed, 14 Mar 2018 21:00:54 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id e4sm8107785pfa.166.2018.03.14.21.00.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 21:00:53 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::231; helo=mail-pf0-x231.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org 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=BwZx+quN1GrEF+Tkz0rgusbFNo/t8Ot0pZFC3n8/xF4=; b=QiALn0Pf7KQMEZ/0BRU0KLRitmnjIEGihiLAg/x78WPUVIbb1JnSwCDIGZM2O3Hsrb kWj/7YT9xcRaueQvkZoHme88AeQt8wMN5NB5GsEA+hE51vAqz9cQSGwFCfOOMww5y/Mr z9XLwDfe4z5P8euTmRl8PANA5l8WTx3iyQcEU= 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=BwZx+quN1GrEF+Tkz0rgusbFNo/t8Ot0pZFC3n8/xF4=; b=d+YKEHLKgbvJMxECSh/qaMMF/I6PvNVfQ3bCR1WAAENlfkZahEFCWoxPcXcOIBv82G 7ltnyFw68EGIex2OQISFX/gQh+R7L9MWbeko8YEn5q55NEJ+Wsyw1fRWve5bKlvjzcE6 EJTTpG73pLxSzenqs5PYC+Ms1fWukjFjJ2HS8PCTnPkkfnBDhBPRSL8CaAWDWnAWr7+3 huBGw2O/eFeeFHzjHswAT6Ixb8gaiQAEqVDEtb07E7SWzf2qq/5kaL7OhJpgQ/DJWxzO BOBMu2pr4QYdHZHgFOsGGtXWfocSwLGWcLJgYv5GrxRHKXAk7/s77GKMb6xEGeEMkVyo WX/g== X-Gm-Message-State: AElRT7HcHZvR6aZZVqwIWKKF5Ai6jwso5rzGTnq8PUlQRkYdY2RqBs1b 9aSedjIFzYbjNkBRdAnV8W42AiuY4+4= X-Google-Smtp-Source: AG47ELu9mLCsvBgGTglyIVCmi0LCpAVA1fdPl0zwIN/GIEuZBs4k9W4+nDHisZpYhInzalveoehmog== X-Received: by 10.98.133.193 with SMTP id m62mr6478706pfk.74.1521086453927; Wed, 14 Mar 2018 21:00:53 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.01.org Date: Thu, 15 Mar 2018 12:00:19 +0800 Message-Id: <1521086424-113954-2-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: [edk2] [PATCH v6 1/6] CorebootPayloadPkg/PciHostBridgeLib: clear aperture vars for (re)init 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 , Ard Biesheuvel , Heyi Guo , Laszlo Ersek , Prince Agyeman MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use ZeroMem() to initialize (or re-initialize) all fields in temporary PCI_ROOT_BRIDGE_APERTURE variables to zero. This is not mandatory but helpful for future extension: when we add new fields to PCI_ROOT_BRIDGE_APERTURE and the default value of these fields can safely be zero, this code will not suffer from an additional change. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Heyi Guo Signed-off-by: Yi Li Cc: Maurice Ma Cc: Prince Agyeman Cc: Benjamin You Cc: Ruiyu Ni Cc: Laszlo Ersek Cc: Ard Biesheuvel --- Notes: v6: - Move ZeroMem() into the loop just as Laszlo commented on OvmfPkg [Laszlo] - Minor changes in commit message CorebootPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c | 7 +++= +++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CorebootPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSuppo= rt.c b/CorebootPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c index 6d94ff72c956..18dcbafdf0c6 100644 --- a/CorebootPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c +++ b/CorebootPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeSupport.c @@ -328,8 +328,13 @@ ScanForRootBridges ( for (PrimaryBus =3D 0; PrimaryBus <=3D PCI_MAX_BUS; PrimaryBus =3D SubBu= s + 1) { SubBus =3D PrimaryBus; Attributes =3D 0; + + ZeroMem (&Io, sizeof (Io)); + ZeroMem (&Mem, sizeof (Mem)); + ZeroMem (&MemAbove4G, sizeof (MemAbove4G)); + ZeroMem (&PMem, sizeof (PMem)); + ZeroMem (&PMemAbove4G, sizeof (PMemAbove4G)); Io.Base =3D Mem.Base =3D MemAbove4G.Base =3D PMem.Base =3D PMemAbove4G= .Base =3D MAX_UINT64; - Io.Limit =3D Mem.Limit =3D MemAbove4G.Limit =3D PMem.Limit =3D PMemAbo= ve4G.Limit =3D 0; // // Scan all the PCI devices on the primary bus of the PCI root bridge // --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Tue May 7 18:57:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521086459878665.737554066043; Wed, 14 Mar 2018 21:00:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 146B9226462FA; Wed, 14 Mar 2018 20:54:35 -0700 (PDT) Received: from mail-pl0-x22c.google.com (mail-pl0-x22c.google.com [IPv6:2607:f8b0:400e:c01::22c]) (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 6966F225892C7 for ; Wed, 14 Mar 2018 20:54:33 -0700 (PDT) Received: by mail-pl0-x22c.google.com with SMTP id f23-v6so3004424plr.10 for ; Wed, 14 Mar 2018 21:00:56 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id e4sm8107785pfa.166.2018.03.14.21.00.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 21:00:55 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::22c; helo=mail-pl0-x22c.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org 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=Z8JVlvRoQ3Jwafg74pPV1vabHXB0mrC1DPXnIdywwvE=; b=EFztKKJPaAjvWli2uGqkaXCBJ7K+wqf1CVm6zMVD9JOCfA7lzbBiBQnbAXZMCmAhQh cdBz0yY0HUqsdqZSWIhZg0O2iZUrHH5g802kzEaUxm8Vo8ekCAVjS8dp8+v+HbLSfWbk JKiU6SpoMjrBY1S6NUXfey1OZfXj+jlahxQhM= 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=Z8JVlvRoQ3Jwafg74pPV1vabHXB0mrC1DPXnIdywwvE=; b=FXJ7DufNglhtut2RDyiJgan/hVZ7k89XlB8SR/4x16+kNuvVKmf3EhzbWv3lPn2hJF Of2gmAwefcczysoWaEtL+DqeSvrX9a7SXmhCxNPZMaqFuZxVU2c7+Z9oXet/PN5dP9D3 mti2HZbe6O5dh3bxZo6b+V4/Xwpw/fbNt09RYHJfYJJKzF1jq+gHfZzBqLm4OE0lLo3I tUwswh4so5bCQP5mARp+mcf8rIx5UF++liD6tatU+ZrEEr3qvJrHomILwnOakcMYq0a3 lFvDfSXvTqBLaYOSi1LUfWbdAALiH3FKW4fkio3weBEHv6pOu53sqCiuxaDs5L5Fl4VL sr1A== X-Gm-Message-State: AElRT7FKIqgBD5rKwS/mDFWu0FE0aWX9jCiPuiszqutrWS2Ur99881+o 9o4uauYcOi/5fg5Fw3bV8ZnggM5uDMo= X-Google-Smtp-Source: AG47ELsObGxsPpRWNIvkUbIcPaucTa1HSajvwiCy8/rIQJboPq9xCaDWwJSU2d3kx0FjYVmGxk9ekw== X-Received: by 2002:a17:902:8c97:: with SMTP id t23-v6mr6635508plo.372.1521086456403; Wed, 14 Mar 2018 21:00:56 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.01.org Date: Thu, 15 Mar 2018 12:00:20 +0800 Message-Id: <1521086424-113954-3-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: [edk2] [PATCH v6 2/6] OvmfPkg/PciHostBridgeLib: clear PCI aperture vars for (re)init 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 , Ard Biesheuvel , Jordan Justen , Heyi Guo , Anthony Perard , Laszlo Ersek MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use ZeroMem() to initialize (or re-initialize) all fields in temporary PCI_ROOT_BRIDGE_APERTURE variables to zero. This is not mandatory but is helpful for future extension: when we add new fields to PCI_ROOT_BRIDGE_APERTURE and the default value of these fields can safely be zero, this code will not suffer from an additional change. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Heyi Guo Signed-off-by: Yi Li Cc: Jordan Justen Cc: Anthony Perard Cc: Julien Grall Cc: Ruiyu Ni Cc: Laszlo Ersek Cc: Ard Biesheuvel --- Notes: v6: - Move ZeroMem() into the loop [Laszlo] - Move ZeroMem() after checking PcdPciDisableBusEnumeration [Laszlo] - Commit title change (However 74 characters will cause PatchCheck warning, so I tried to reduce the length to eliminate the warning) [l= aszlo] - Minor changes in commit message OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 4 ++++ OvmfPkg/Library/PciHostBridgeLib/XenSupport.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/= Library/PciHostBridgeLib/PciHostBridgeLib.c index ff837035caff..65d0ef9252c5 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -221,6 +221,10 @@ PciHostBridgeGetRootBridges ( return ScanForRootBridges (Count); } =20 + ZeroMem (&Io, sizeof (Io)); + ZeroMem (&Mem, sizeof (Mem)); + ZeroMem (&MemAbove4G, sizeof (MemAbove4G)); + Attributes =3D EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO | EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO | EFI_PCI_ATTRIBUTE_ISA_IO_16 | diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Librar= y/PciHostBridgeLib/XenSupport.c index 31c63ae19e0a..920417950ad9 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c +++ b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c @@ -202,8 +202,13 @@ ScanForRootBridges ( for (PrimaryBus =3D 0; PrimaryBus <=3D PCI_MAX_BUS; PrimaryBus =3D SubBu= s + 1) { SubBus =3D PrimaryBus; Attributes =3D 0; + + ZeroMem (&Io, sizeof (Io)); + ZeroMem (&Mem, sizeof (Mem)); + ZeroMem (&MemAbove4G, sizeof (MemAbove4G)); + ZeroMem (&PMem, sizeof (PMem)); + ZeroMem (&PMemAbove4G, sizeof (PMemAbove4G)); Io.Base =3D Mem.Base =3D MemAbove4G.Base =3D PMem.Base =3D PMemAbove4G= .Base =3D MAX_UINT64; - Io.Limit =3D Mem.Limit =3D MemAbove4G.Limit =3D PMem.Limit =3D PMemAbo= ve4G.Limit =3D 0; // // Scan all the PCI devices on the primary bus of the PCI root bridge // --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Tue May 7 18:57:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521086462033291.9483020581275; Wed, 14 Mar 2018 21:01:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 743CC2264D223; Wed, 14 Mar 2018 20:54:36 -0700 (PDT) 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 91FAB225892DD for ; Wed, 14 Mar 2018 20:54:35 -0700 (PDT) Received: by mail-pl0-x243.google.com with SMTP id c8-v6so2132669plr.8 for ; Wed, 14 Mar 2018 21:00:59 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id e4sm8107785pfa.166.2018.03.14.21.00.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 21:00:58 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 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=2cP1Kc08sYx9mind/8WQGD3k/jUDSrlrpi4kOPMcESM=; b=LfDCacjKi8qcBNMRBxzML/0xlb+YkmqSYKE0R23h5/8+YptdbC+7V9yzShOAqHqJHM Ikl/pfYVD89DVPIitSfoz32GDTHGmNG4z2Wmj8TyC5g+rH62X82REYyAaHxu6dd8qBKb 1HcGpu+jSKKw4/fRnnlEN/d3wfMM+0iBxxhkU= 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=2cP1Kc08sYx9mind/8WQGD3k/jUDSrlrpi4kOPMcESM=; b=JH8e5fQcDvjzHHJTRSysYtK/qoQx5vdxGI5KK+uMlX56Ilr7IAMA8IBqZIQxa+otOW SqqTOwmMps2fjN+vHdN8k9f4+ZyUhOWAZrcPr4eeHLP+koDuo+rP6PYYp6FIG1QCwpns fo9eX06TTsjhupec0nmflS3YXWciJ5OsEPnEntK3ZMx54j+kefNqiPqyyt86GVEqMYb8 PrNO03Hyhur4rTe/THmyEdyn5tgO3/Hw8TwvIdony2LEk8MqiFrI97Bs38DvtQxD+n+S L/Tz1c5QXISiy/7qP9Wn6zdiVuppvFJMb/VzN+82IXwDK8f3hmaiW4kU8bzWYWQHY7Zb LmdA== X-Gm-Message-State: AElRT7Eo7w4YkbOHFAOzTZqO6pAgeINKEZVISOt+9BCg17Gs/e21WSes 15z5psaz6qMXrJM2J0ieTTV44vQFPS4= X-Google-Smtp-Source: AG47ELuYhi0U8cfn5K4AJacRHMNivSq+6iueCJabQTyR+y7SuMD/TtqVqI6Yz1sE0SfzpMIJNwSSBg== X-Received: by 2002:a17:902:b101:: with SMTP id q1-v6mr6453980plr.287.1521086458833; Wed, 14 Mar 2018 21:00:58 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.01.org Date: Thu, 15 Mar 2018 12:00:21 +0800 Message-Id: <1521086424-113954-4-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: [edk2] [PATCH v6 3/6] MdeModulePkg/PciHostBridgeLib.h: add address Translation 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 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add Translation field to PCI_ROOT_BRIDGE_APERTURE. Translation is used to represent the difference between device address and host address, if they are not the same on some platforms. In UEFI 2.7, "Address Translation Offset" is "Offset to apply to the Starting address to convert it to a PCI address". This means: Translation =3D device address - host address So we also use the above calculation for this Translation field to keep consistent. 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/Include/Library/PciHostBridgeLib.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/MdeModulePkg/Include/Library/PciHostBridgeLib.h b/MdeModulePkg= /Include/Library/PciHostBridgeLib.h index d42e9ecdd763..18963a0d3821 100644 --- a/MdeModulePkg/Include/Library/PciHostBridgeLib.h +++ b/MdeModulePkg/Include/Library/PciHostBridgeLib.h @@ -20,8 +20,27 @@ // (Base > Limit) indicates an aperture is not available. // typedef struct { + // + // Base and Limit are the device address instead of host address when + // Translation is not zero + // UINT64 Base; UINT64 Limit; + // + // According to UEFI 2.7, Device Address =3D Host Address + Translation, + // so Translation =3D Device Address - Host Address. + // On platforms where Translation is not zero, the subtraction is probab= ly to + // be performed with UINT64 wrap-around semantics, for we may translate = an + // above-4G host address into a below-4G device address for legacy PCIe = device + // compatibility. + // + // NOTE: The alignment of Translation is required to be larger than any = BAR + // alignment in the same root bridge, so that the same alignment can be + // applied to both device address and host address, which simplifies the + // situation and makes the current resource allocation code in generic P= CI + // host bridge driver still work. + // + UINT64 Translation; } PCI_ROOT_BRIDGE_APERTURE; =20 typedef struct { --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Tue May 7 18:57:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521086466248988.8169245717544; Wed, 14 Mar 2018 21:01:06 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 13DAF20956060; Wed, 14 Mar 2018 20:54:40 -0700 (PDT) Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::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 6F4392264D23D for ; Wed, 14 Mar 2018 20:54:38 -0700 (PDT) Received: by mail-pf0-x241.google.com with SMTP id m68so2356501pfm.11 for ; Wed, 14 Mar 2018 21:01:02 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id e4sm8107785pfa.166.2018.03.14.21.00.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 21:01:00 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::241; helo=mail-pf0-x241.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org 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=+PnSMFLtl15XuDxKhN1muGJAlTYztAduT9osFw3KD7I=; b=IXiLTGR3Bsw6PqLXNlCcEoPyahdmKKLH4ngqpbIbuEh49r9hN3c6pdAGL96sbGdZA6 iosGx2hxKJO1BekpzZ+jyZyAZBmEXOK0xVU091avHy7I607F5DfP4lPCqprpWEwSbxG6 Dg97kK+sAJT7z/BeSMN91rZ8RBKvd8EylgWKg= 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=+PnSMFLtl15XuDxKhN1muGJAlTYztAduT9osFw3KD7I=; b=Pfu4TzdnAmb79qoSB/p49KWWNDAP2VkTmFTyLBV/LzolS42j320rMIHe0WA/lGaCA+ Lz8MMovSN3WY1JiCdH6wDE36tsR+SWyfLkvQPq2KnZpEL7Fs7LIsfsQX6Ho2x2Fh1ctK 08R4C0K93AgG1ywbX+a7nRhLHNtKtf1Vq07viYKWDO+CYqXvV2E7f04+y1FUzSVvCXTP s16CXg/1aQ5vPPyRXvpZabAJkhmENQt/vBc9LXEBPxvaYGaInhkbwIv95dpf5dCFCWuD W6hme1AsmbnK+XoPcfDLa7nEtQpy41Y3ssKeOaefU3D1V0V2l9aFSSVLUcwjUjSvdjrD 866A== X-Gm-Message-State: AElRT7Gsb1MI9avIAT2nLQP/bjEkAe3At8PphcXUIUzqzS7QFCzko+og qdUoyY3whIoOaIOJQ6r4CNBJDSfv9ZY= X-Google-Smtp-Source: AG47ELsVsqq4kqVb/Hqg44v35s255qXJ5uLK65TmdwrFM41ckEwVEUbqHNcqupg5ykfgjHe0C9dvsw== X-Received: by 10.101.83.199 with SMTP id z7mr5758976pgr.105.1521086461447; Wed, 14 Mar 2018 21:01:01 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.01.org Date: Thu, 15 Mar 2018 12:00:22 +0800 Message-Id: <1521086424-113954-5-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: [edk2] [PATCH v6 4/6] MdeModulePkg/PciHostBridgeDxe: Add support for address translation 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 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" PCI address translation is necessary for some non-x86 platforms. On such platforms, address value (denoted as "device address" or "address in PCI view") set to PCI BAR registers in configuration space might be different from the address which is used by CPU to access the registers in memory BAR or IO BAR spaces (denoted as "host address" or "address in CPU view"). The difference between the two addresses is called "Address Translation Offset" or simply "translation", and can be represented by "Address Translation Offset" in ACPI QWORD Address Space Descriptor (Offset 0x1E). However UEFI and ACPI differs on the definitions of QWORD Address Space Descriptor, and we will follow UEFI definition on UEFI protocols, such as PCI root bridge IO protocol and PCI IO protocol. In UEFI 2.7, "Address Translation Offset" is "Offset to apply to the Starting address to convert it to a PCI address". This means: 1. Translation =3D device address - host address. 2. PciRootBridgeIo->Configuration should return CPU view address, as well as PciIo->GetBarAttributes. Summary of addresses used in protocol interfaces and internal implementations: 1. *Only* the following protocol interfaces assume Address is Device Address: (1). PciHostBridgeResourceAllocation.GetProposedResources() Otherwise PCI bus driver cannot set correct address into PCI BARs. (2). PciRootBridgeIo.Mem.Read() and PciRootBridgeIo.Mem.Write() (3). PciRootBridgeIo.CopyMem() UEFI and PI spec have clear statements for all other protocol interfaces about the address type. 2. Library interfaces and internal implementation: (1). Base and Limit in PCI_ROOT_BRIDGE_APERTURE are device address. It is easy to check whether the address is below 4G or above 4G. (2). Addresses in PCI_ROOT_BRIDGE_INSTANCE.ResAllocNode are host address, for they are allocated from GCD. (3). Address passed to PciHostBridgeResourceConflict is host address, for it comes from PCI_ROOT_BRIDGE_INSTANCE.ResAllocNode. RESTRICTION: to simplify the situation, we require the alignment of Translation must be larger than any BAR alignment in the same root bridge, so that resource allocation alignment can be applied to both device address and host address. 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 --- Notes: v6: - Change ASSERT(FALSE) to ASSERT ((Translation & Alignment) =3D=3D 0) a= nd move ASSERT before if-check [Ray] - Print translation of bus and then assert [Ray] - Add function header for RootBridgeIoGetMemTranslationByAddress() [Ray] =20 v5: - Add check for the alignment of Translation against the BAR alignment [Ray] - Keep coding style of comments consistent with the context [Ray] - Comment change for Base in PCI_RES_NODE [Ray] - Add macros of TO_HOST_ADDRESS and TO_DEVICE_ADDRESS for address type conversion (After that we can also simply the comments about the calculation [Ray] - Add check for bus translation offset in CreateRootBridge(), making sure it is zero, and unify code logic for all types of resource after that [Ray] - Use GetTranslationByResourceType() to simplify the code in RootBridgeIoConfiguration() (also fix a bug in previous patch version of missing a break after case TypePMem64) [Ray] - Commit message refinement [Ray] =20 v4: - Add ASSERT (FALSE) to default branch in GetTranslationByResourceType [Laszlo] - Fix bug when passing BaseAddress to gDS->AllocateIoSpace and gDS->AllocateMemorySpace [Laszlo] - Add comment for applying alignment to both device address and host address, and add NOTE for the alignment requirement of Translation, as well as in commit message [Laszlo][Ray] - Improve indention for the code in CreateRootBridge [Laszlo] - Improve comment for Translation in PCI_ROOT_BRIDGE_APERTURE definition [Laszlo] - Ignore translation of bus in CreateRootBridge =20 v4: - Add ASSERT (FALSE) to default branch in GetTranslationByResourceType [Laszlo] - Fix bug when passing BaseAddress to gDS->AllocateIoSpace and gDS->AllocateMemorySpace [Laszlo] - Add comment for applying alignment to both device address and host address, and add NOTE for the alignment requirement of Translation, as well as in commit message [Laszlo][Ray] - Improve indention for the code in CreateRootBridge [Laszlo] - Improve comment for Translation in PCI_ROOT_BRIDGE_APERTURE definition [Laszlo] - Ignore translation of bus in CreateRootBridge MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h | 21 +++ MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostResource.h | 3 + MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 129 ++++++++++++= ++++--- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 135 ++++++++++++= ++++++-- 4 files changed, 261 insertions(+), 27 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h b/MdeMod= ulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h index 9a8ca21f4819..c2791ea5c2a4 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h @@ -38,6 +38,13 @@ typedef struct { #define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResA= lloc, PCI_HOST_BRIDGE_SIGNATURE) =20 // +// Macros to translate device address to host address and vice versa. Acco= rding +// to UEFI 2.7, device address =3D host address + translation offset. +// +#define TO_HOST_ADDRESS(DeviceAddress,TranslationOffset) ((DeviceAddress) = - (TranslationOffset)) +#define TO_DEVICE_ADDRESS(HostAddress,TranslationOffset) ((HostAddress) + = (TranslationOffset)) + +// // Driver Entry Point // /** @@ -247,6 +254,20 @@ ResourceConflict ( IN PCI_HOST_BRIDGE_INSTANCE *HostBridge ); =20 +/** + This routine gets translation offset from a root bridge instance by reso= urce type. + + @param RootBridge The Root Bridge Instance for the resources. + @param ResourceType The Resource Type of the translation offset. + + @retval The Translation Offset of the specified resource. +**/ +UINT64 +GetTranslationByResourceType ( + IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge, + IN PCI_RESOURCE_TYPE ResourceType + ); + extern EFI_METRONOME_ARCH_PROTOCOL *mMetronome; extern EFI_CPU_IO2_PROTOCOL *mCpuIo; #endif diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostResource.h b/MdeM= odulePkg/Bus/Pci/PciHostBridgeDxe/PciHostResource.h index 8612c0c3251b..a6c3739db368 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostResource.h +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostResource.h @@ -38,6 +38,9 @@ typedef enum { =20 typedef struct { PCI_RESOURCE_TYPE Type; + // + // Base is a host address + // UINT64 Base; UINT64 Length; UINT64 Alignment; diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c b/MdeMod= ulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c index 1494848c3e8c..5342efd89275 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c @@ -33,6 +33,39 @@ EFI_EVENT mIoMmuEvent; VOID *mIoMmuRegistration; =20 /** + This routine gets translation offset from a root bridge instance by reso= urce type. + + @param RootBridge The Root Bridge Instance for the resources. + @param ResourceType The Resource Type of the translation offset. + + @retval The Translation Offset of the specified resource. +**/ +UINT64 +GetTranslationByResourceType ( + IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge, + IN PCI_RESOURCE_TYPE ResourceType + ) +{ + switch (ResourceType) { + case TypeIo: + return RootBridge->Io.Translation; + case TypeMem32: + return RootBridge->Mem.Translation; + case TypePMem32: + return RootBridge->PMem.Translation; + case TypeMem64: + return RootBridge->MemAbove4G.Translation; + case TypePMem64: + return RootBridge->PMemAbove4G.Translation; + case TypeBus: + return RootBridge->Bus.Translation; + default: + ASSERT (FALSE); + return 0; + } +} + +/** Ensure the compatibility of an IO space descriptor with the IO aperture. =20 The IO space descriptor can come from the GCD IO space map, or it can @@ -366,6 +399,7 @@ InitializePciHostBridge ( UINTN MemApertureIndex; BOOLEAN ResourceAssigned; LIST_ENTRY *Link; + UINT64 HostAddress; =20 RootBridges =3D PciHostBridgeGetRootBridges (&RootBridgeCount); if ((RootBridges =3D=3D NULL) || (RootBridgeCount =3D=3D 0)) { @@ -411,8 +445,15 @@ InitializePciHostBridge ( } =20 if (RootBridges[Index].Io.Base <=3D RootBridges[Index].Io.Limit) { + // + // Base and Limit in PCI_ROOT_BRIDGE_APERTURE are device address. + // For GCD resource manipulation, we need to use host address. + // + HostAddress =3D TO_HOST_ADDRESS (RootBridges[Index].Io.Base, + RootBridges[Index].Io.Translation); + Status =3D AddIoSpace ( - RootBridges[Index].Io.Base, + HostAddress, RootBridges[Index].Io.Limit - RootBridges[Index].Io.Base = + 1 ); ASSERT_EFI_ERROR (Status); @@ -422,7 +463,7 @@ InitializePciHostBridge ( EfiGcdIoTypeIo, 0, RootBridges[Index].Io.Limit - RootBridges[Index].I= o.Base + 1, - &RootBridges[Index].Io.Base, + &HostAddress, gImageHandle, NULL ); @@ -443,14 +484,20 @@ InitializePciHostBridge ( =20 for (MemApertureIndex =3D 0; MemApertureIndex < ARRAY_SIZE (MemApertur= es); MemApertureIndex++) { if (MemApertures[MemApertureIndex]->Base <=3D MemApertures[MemApertu= reIndex]->Limit) { + // + // Base and Limit in PCI_ROOT_BRIDGE_APERTURE are device address. + // For GCD resource manipulation, we need to use host address. + // + HostAddress =3D TO_HOST_ADDRESS (MemApertures[MemApertureIndex]->B= ase, + MemApertures[MemApertureIndex]->Translation); Status =3D AddMemoryMappedIoSpace ( - MemApertures[MemApertureIndex]->Base, + HostAddress, MemApertures[MemApertureIndex]->Limit - MemApertures[Me= mApertureIndex]->Base + 1, EFI_MEMORY_UC ); ASSERT_EFI_ERROR (Status); Status =3D gDS->SetMemorySpaceAttributes ( - MemApertures[MemApertureIndex]->Base, + HostAddress, MemApertures[MemApertureIndex]->Limit - MemApertur= es[MemApertureIndex]->Base + 1, EFI_MEMORY_UC ); @@ -463,7 +510,7 @@ InitializePciHostBridge ( EfiGcdMemoryTypeMemoryMappedIo, 0, MemApertures[MemApertureIndex]->Limit - MemApert= ures[MemApertureIndex]->Base + 1, - &MemApertures[MemApertureIndex]->Base, + &HostAddress, gImageHandle, NULL ); @@ -654,6 +701,11 @@ AllocateResource ( if (BaseAddress < Limit) { // // Have to make sure Aligment is handled since we are doing direct add= ress allocation + // Strictly speaking, alignment requirement should be applied to device + // address instead of host address which is used in GCD manipulation b= elow, + // but as we restrict the alignment of Translation to be larger than a= ny BAR + // alignment in the root bridge, we can simplify the situation and con= sider + // the same alignment requirement is also applied to host address. // BaseAddress =3D ALIGN_VALUE (BaseAddress, LShiftU64 (1, BitsOfAlignmen= t)); =20 @@ -721,6 +773,7 @@ NotifyPhase ( PCI_RESOURCE_TYPE Index2; BOOLEAN ResNodeHandled[TypeMax]; UINT64 MaxAlignment; + UINT64 Translation; =20 HostBridge =3D PCI_HOST_BRIDGE_FROM_THIS (This); =20 @@ -822,14 +875,43 @@ NotifyPhase ( BitsOfAlignment =3D LowBitSet64 (Alignment + 1); BaseAddress =3D MAX_UINT64; =20 + // + // RESTRICTION: To simplify the situation, we require the alignm= ent of + // Translation must be larger than any BAR alignment in the same= root + // bridge, so that resource allocation alignment can be applied = to + // both device address and host address. + // + Translation =3D GetTranslationByResourceType (RootBridge, Index); + ASSERT ((Translation & Alignment) =3D=3D 0); + if ((Translation & Alignment) !=3D 0) { + DEBUG ((DEBUG_ERROR, "[%a:%d] Translation %lx is not aligned t= o %lx!\n", + __FUNCTION__, __LINE__, Translation, Alignment + )); + // + // This may be caused by too large alignment or too small + // Translation; pick the 1st possibility and return out of res= ource, + // which can also go thru the same process for out of resource + // outside the loop. + // + ReturnStatus =3D EFI_OUT_OF_RESOURCES; + continue; + } + switch (Index) { case TypeIo: + // + // Base and Limit in PCI_ROOT_BRIDGE_APERTURE are device addre= ss. + // For AllocateResource is manipulating GCD resource, we need = to use + // host address here. + // BaseAddress =3D AllocateResource ( FALSE, RootBridge->ResAllocNode[Index].Length, MIN (15, BitsOfAlignment), - ALIGN_VALUE (RootBridge->Io.Base, Alignment + = 1), - RootBridge->Io.Limit + TO_HOST_ADDRESS (ALIGN_VALUE (RootBridge->Io.B= ase, Alignment + 1), + RootBridge->Io.Translation), + TO_HOST_ADDRESS (RootBridge->Io.Limit, + RootBridge->Io.Translation) ); break; =20 @@ -838,8 +920,10 @@ NotifyPhase ( TRUE, RootBridge->ResAllocNode[Index].Length, MIN (63, BitsOfAlignment), - ALIGN_VALUE (RootBridge->MemAbove4G.Base, Alig= nment + 1), - RootBridge->MemAbove4G.Limit + TO_HOST_ADDRESS (ALIGN_VALUE (RootBridge->MemA= bove4G.Base, Alignment + 1), + RootBridge->MemAbove4G.Translation), + TO_HOST_ADDRESS (RootBridge->MemAbove4G.Limit, + RootBridge->MemAbove4G.Translation) ); if (BaseAddress !=3D MAX_UINT64) { break; @@ -853,8 +937,10 @@ NotifyPhase ( TRUE, RootBridge->ResAllocNode[Index].Length, MIN (31, BitsOfAlignment), - ALIGN_VALUE (RootBridge->Mem.Base, Alignment += 1), - RootBridge->Mem.Limit + TO_HOST_ADDRESS (ALIGN_VALUE (RootBridge->Mem.= Base, Alignment + 1), + RootBridge->Mem.Translation), + TO_HOST_ADDRESS (RootBridge->Mem.Limit, + RootBridge->Mem.Translation) ); break; =20 @@ -863,8 +949,10 @@ NotifyPhase ( TRUE, RootBridge->ResAllocNode[Index].Length, MIN (63, BitsOfAlignment), - ALIGN_VALUE (RootBridge->PMemAbove4G.Base, Ali= gnment + 1), - RootBridge->PMemAbove4G.Limit + TO_HOST_ADDRESS (ALIGN_VALUE (RootBridge->PMem= Above4G.Base, Alignment + 1), + RootBridge->PMemAbove4G.Translation), + TO_HOST_ADDRESS (RootBridge->PMemAbove4G.Limit, + RootBridge->PMemAbove4G.Translation) ); if (BaseAddress !=3D MAX_UINT64) { break; @@ -877,8 +965,10 @@ NotifyPhase ( TRUE, RootBridge->ResAllocNode[Index].Length, MIN (31, BitsOfAlignment), - ALIGN_VALUE (RootBridge->PMem.Base, Alignment = + 1), - RootBridge->PMem.Limit + TO_HOST_ADDRESS (ALIGN_VALUE (RootBridge->PMem= .Base, Alignment + 1), + RootBridge->PMem.Translation), + TO_HOST_ADDRESS (RootBridge->PMem.Limit, + RootBridge->PMem.Translation) ); break; =20 @@ -1421,7 +1511,14 @@ GetProposedResources ( Descriptor->Desc =3D ACPI_ADDRESS_SPACE_DESCRIP= TOR; Descriptor->Len =3D sizeof (EFI_ACPI_ADDRESS_S= PACE_DESCRIPTOR) - 3;; Descriptor->GenFlag =3D 0; - Descriptor->AddrRangeMin =3D RootBridge->ResAllocNode[I= ndex].Base; + // + // AddrRangeMin in Resource Descriptor here should be device add= ress + // instead of host address, or else PCI bus driver cannot set co= rrect + // address into PCI BAR registers. + // Base in ResAllocNode is a host address, so conversion is need= ed. + // + Descriptor->AddrRangeMin =3D TO_DEVICE_ADDRESS (RootBri= dge->ResAllocNode[Index].Base, + GetTranslationByResourceType (RootBridge, Index)); Descriptor->AddrRangeMax =3D 0; Descriptor->AddrTranslationOffset =3D (ResStatus =3D=3D ResAlloc= ated) ? EFI_RESOURCE_SATISFIED : PCI_RESOURCE_LESS; Descriptor->AddrLen =3D RootBridge->ResAllocNode[I= ndex].Length; diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c b/MdeM= odulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c index dc06c16dc038..5764c2f49f92 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c @@ -86,12 +86,38 @@ CreateRootBridge ( (Bridge->AllocationAttributes & EFI_PCI_HOST_BRIDGE_COMBINE_MEM_= PMEM) !=3D 0 ? L"CombineMemPMem " : L"", (Bridge->AllocationAttributes & EFI_PCI_HOST_BRIDGE_MEM64_DECODE= ) !=3D 0 ? L"Mem64Decode" : L"" )); - DEBUG ((EFI_D_INFO, " Bus: %lx - %lx\n", Bridge->Bus.Base, Bri= dge->Bus.Limit)); - DEBUG ((EFI_D_INFO, " Io: %lx - %lx\n", Bridge->Io.Base, Brid= ge->Io.Limit)); - DEBUG ((EFI_D_INFO, " Mem: %lx - %lx\n", Bridge->Mem.Base, Bri= dge->Mem.Limit)); - DEBUG ((EFI_D_INFO, " MemAbove4G: %lx - %lx\n", Bridge->MemAbove4G.Ba= se, Bridge->MemAbove4G.Limit)); - DEBUG ((EFI_D_INFO, " PMem: %lx - %lx\n", Bridge->PMem.Base, Br= idge->PMem.Limit)); - DEBUG ((EFI_D_INFO, " PMemAbove4G: %lx - %lx\n", Bridge->PMemAbove4G.B= ase, Bridge->PMemAbove4G.Limit)); + DEBUG (( + EFI_D_INFO, " Bus: %lx - %lx Translation=3D%lx\n", + Bridge->Bus.Base, Bridge->Bus.Limit, Bridge->Bus.Translation + )); + // + // Translation for bus is not supported. + // + ASSERT (Bridge->Bus.Translation =3D=3D 0); + if (Bridge->Bus.Translation !=3D 0) { + return NULL; + } + + DEBUG (( + DEBUG_INFO, " Io: %lx - %lx Translation=3D%lx\n", + Bridge->Io.Base, Bridge->Io.Limit, Bridge->Io.Translation + )); + DEBUG (( + DEBUG_INFO, " Mem: %lx - %lx Translation=3D%lx\n", + Bridge->Mem.Base, Bridge->Mem.Limit, Bridge->Mem.Translation + )); + DEBUG (( + DEBUG_INFO, " MemAbove4G: %lx - %lx Translation=3D%lx\n", + Bridge->MemAbove4G.Base, Bridge->MemAbove4G.Limit, Bridge->MemAbove4G.= Translation + )); + DEBUG (( + DEBUG_INFO, " PMem: %lx - %lx Translation=3D%lx\n", + Bridge->PMem.Base, Bridge->PMem.Limit, Bridge->PMem.Translation + )); + DEBUG (( + DEBUG_INFO, " PMemAbove4G: %lx - %lx Translation=3D%lx\n", + Bridge->PMemAbove4G.Base, Bridge->PMemAbove4G.Limit, Bridge->PMemAbove= 4G.Translation + )); =20 // // Make sure Mem and MemAbove4G apertures are valid @@ -206,7 +232,12 @@ CreateRootBridge ( } RootBridge->ResAllocNode[Index].Type =3D Index; if (Bridge->ResourceAssigned && (Aperture->Limit >=3D Aperture->Base))= { - RootBridge->ResAllocNode[Index].Base =3D Aperture->Base; + // + // Base in ResAllocNode is a host address, while Base in Aperture is= a + // device address. + // + RootBridge->ResAllocNode[Index].Base =3D TO_HOST_ADDRESS (Aperture= ->Base, + Aperture->Translation); RootBridge->ResAllocNode[Index].Length =3D Aperture->Limit - Apertur= e->Base + 1; RootBridge->ResAllocNode[Index].Status =3D ResAllocated; } else { @@ -404,6 +435,40 @@ RootBridgeIoCheckParameter ( } =20 /** + Use address to match apertures of memory type and then get the correspon= ding + translation. + + @param RootBridge The root bridge instance. + @param Address The address used to match aperture. + @param Translation Pointer containing the output translation. + + @return EFI_SUCCESS Get translation successfully. + @return EFI_INVALID_PARAMETER No matched memory aperture; the input Add= ress + must be invalid. +**/ +EFI_STATUS +RootBridgeIoGetMemTranslationByAddress ( + IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge, + IN UINT64 Address, + IN OUT UINT64 *Translation + ) +{ + if (Address >=3D RootBridge->Mem.Base && Address <=3D RootBridge->Mem.Li= mit) { + *Translation =3D RootBridge->Mem.Translation; + } else if (Address >=3D RootBridge->PMem.Base && Address <=3D RootBridge= ->PMem.Limit) { + *Translation =3D RootBridge->PMem.Translation; + } else if (Address >=3D RootBridge->MemAbove4G.Base && Address <=3D Root= Bridge->MemAbove4G.Limit) { + *Translation =3D RootBridge->MemAbove4G.Translation; + } else if (Address >=3D RootBridge->PMemAbove4G.Base && Address <=3D Roo= tBridge->PMemAbove4G.Limit) { + *Translation =3D RootBridge->PMemAbove4G.Translation; + } else { + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; +} + +/** Polls an address in memory mapped I/O space until an exit condition is m= et, or a timeout occurs. =20 @@ -658,13 +723,25 @@ RootBridgeIoMemRead ( ) { EFI_STATUS Status; + PCI_ROOT_BRIDGE_INSTANCE *RootBridge; + UINT64 Translation; =20 Status =3D RootBridgeIoCheckParameter (This, MemOperation, Width, Addres= s, Count, Buffer); if (EFI_ERROR (Status)) { return Status; } - return mCpuIo->Mem.Read (mCpuIo, (EFI_CPU_IO_PROTOCOL_WIDTH) Width, Addr= ess, Count, Buffer); + + RootBridge =3D ROOT_BRIDGE_FROM_THIS (This); + Status =3D RootBridgeIoGetMemTranslationByAddress (RootBridge, Address, = &Translation); + if (EFI_ERROR (Status)) { + return Status; + } + + // Address passed to CpuIo->Mem.Read needs to be a host address instead = of + // device address. + return mCpuIo->Mem.Read (mCpuIo, (EFI_CPU_IO_PROTOCOL_WIDTH) Width, + TO_HOST_ADDRESS (Address, Translation), Count, Buffer); } =20 /** @@ -705,13 +782,25 @@ RootBridgeIoMemWrite ( ) { EFI_STATUS Status; + PCI_ROOT_BRIDGE_INSTANCE *RootBridge; + UINT64 Translation; =20 Status =3D RootBridgeIoCheckParameter (This, MemOperation, Width, Addres= s, Count, Buffer); if (EFI_ERROR (Status)) { return Status; } - return mCpuIo->Mem.Write (mCpuIo, (EFI_CPU_IO_PROTOCOL_WIDTH) Width, Add= ress, Count, Buffer); + + RootBridge =3D ROOT_BRIDGE_FROM_THIS (This); + Status =3D RootBridgeIoGetMemTranslationByAddress (RootBridge, Address, = &Translation); + if (EFI_ERROR (Status)) { + return Status; + } + + // Address passed to CpuIo->Mem.Write needs to be a host address instead= of + // device address. + return mCpuIo->Mem.Write (mCpuIo, (EFI_CPU_IO_PROTOCOL_WIDTH) Width, + TO_HOST_ADDRESS (Address, Translation), Count, Buffer); } =20 /** @@ -746,6 +835,8 @@ RootBridgeIoIoRead ( ) { EFI_STATUS Status; + PCI_ROOT_BRIDGE_INSTANCE *RootBridge; + Status =3D RootBridgeIoCheckParameter ( This, IoOperation, Width, Address, Count, Buffer @@ -753,7 +844,13 @@ RootBridgeIoIoRead ( if (EFI_ERROR (Status)) { return Status; } - return mCpuIo->Io.Read (mCpuIo, (EFI_CPU_IO_PROTOCOL_WIDTH) Width, Addre= ss, Count, Buffer); + + RootBridge =3D ROOT_BRIDGE_FROM_THIS (This); + + // Address passed to CpuIo->Io.Read needs to be a host address instead of + // device address. + return mCpuIo->Io.Read (mCpuIo, (EFI_CPU_IO_PROTOCOL_WIDTH) Width, + TO_HOST_ADDRESS (Address, RootBridge->Io.Translation), Count, Buffer= ); } =20 /** @@ -788,6 +885,8 @@ RootBridgeIoIoWrite ( ) { EFI_STATUS Status; + PCI_ROOT_BRIDGE_INSTANCE *RootBridge; + Status =3D RootBridgeIoCheckParameter ( This, IoOperation, Width, Address, Count, Buffer @@ -795,7 +894,13 @@ RootBridgeIoIoWrite ( if (EFI_ERROR (Status)) { return Status; } - return mCpuIo->Io.Write (mCpuIo, (EFI_CPU_IO_PROTOCOL_WIDTH) Width, Addr= ess, Count, Buffer); + + RootBridge =3D ROOT_BRIDGE_FROM_THIS (This); + + // Address passed to CpuIo->Io.Write needs to be a host address instead = of + // device address. + return mCpuIo->Io.Write (mCpuIo, (EFI_CPU_IO_PROTOCOL_WIDTH) Width, + TO_HOST_ADDRESS (Address, RootBridge->Io.Translation), Count, Buffer= ); } =20 /** @@ -1615,9 +1720,17 @@ RootBridgeIoConfiguration ( =20 Descriptor->Desc =3D ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor->Len =3D sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3; + // According to UEFI 2.7, RootBridgeIo->Configuration should return ad= dress + // range in CPU view (host address), and ResAllocNode->Base is already= a CPU + // view address (host address). Descriptor->AddrRangeMin =3D ResAllocNode->Base; Descriptor->AddrRangeMax =3D ResAllocNode->Base + ResAllocNode->Lengt= h - 1; Descriptor->AddrLen =3D ResAllocNode->Length; + Descriptor->AddrTranslationOffset =3D GetTranslationByResourceType ( + RootBridge, + ResAllocNode->Type + ); + switch (ResAllocNode->Type) { =20 case TypeIo: --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Tue May 7 18:57:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 152108646988112.165874785530946; Wed, 14 Mar 2018 21:01:09 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 82D1020956066; Wed, 14 Mar 2018 20:54:42 -0700 (PDT) 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) 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) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 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) From: Heyi Guo To: edk2-devel@lists.01.org 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: [edk2] [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: , Cc: Ruiyu Ni , Yi Li , Eric Dong , Ard Biesheuvel , Heyi Guo , Michael D Kinney , Laszlo Ersek , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 =3D 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; } =20 + // According to UEFI 2.7, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL::Configuration= () + // returns host address instead of device address, while AddrTranslation= Offset + // is not zero, and device address =3D host address + AddrTranslationOff= set, so + // we convert host address to device address for range compare. while (Configuration->Desc =3D=3D ACPI_ADDRESS_SPACE_DESCRIPTOR) { if ((Configuration->ResType =3D=3D ACPI_ADDRESS_SPACE_TYPE_MEM) && - (Configuration->AddrRangeMin <=3D AddrRangeMin) && - (Configuration->AddrRangeMin + Configuration->AddrLen >=3D AddrRan= geMin + AddrLen) + (Configuration->AddrRangeMin + Configuration->AddrTranslationOffse= t <=3D AddrRangeMin) && + (Configuration->AddrRangeMin + Configuration->AddrLen + Configurat= ion->AddrTranslationOffset >=3D AddrRangeMin + AddrLen) ) { return Configuration->AddrTranslationOffset; } --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Tue May 7 18:57:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521086473404325.43622525633873; Wed, 14 Mar 2018 21:01:13 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F0BFD2095606B; Wed, 14 Mar 2018 20:54:45 -0700 (PDT) Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (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 BD91620956064 for ; Wed, 14 Mar 2018 20:54:44 -0700 (PDT) Received: by mail-pl0-x244.google.com with SMTP id ay1-v6so3017941plb.7 for ; Wed, 14 Mar 2018 21:01:08 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.100]) by smtp.gmail.com with ESMTPSA id e4sm8107785pfa.166.2018.03.14.21.01.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 21:01:05 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org 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=rhviWW23udxmj5gdM/D8sUe3FXKlLK7DSnq5kj3vWis=; b=PL3G5DfS9e/gJenyArbVHrbmpGJRWiE5OsHXJH8Rm5FShzfnz7hGaoQhlr0YO8EUKq dHKr82sbEhUtPtRfQ0RE9epSBgk9WxpS9E3OBGzbxh6UQq+U7rbq0DTMj8pH/brOUK4A adapIuXc9emKwpOAOCKHxmkZ5sYOAFos4MaQA= 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=rhviWW23udxmj5gdM/D8sUe3FXKlLK7DSnq5kj3vWis=; b=WpwozYfb2tmKZYk1v00m7JilAdCHmZ7bmpgIT2LTCj+9ikNcdoqzU6PYtwvvODyS0B ki6DXer7Uu7UtqeC+BlKadfpx4SNVpSGgtwGW89ab2Z+JMFKxSKrzDZdFzSpMR0DaqhO usKLo8avel6+RcUV64R1c1bEy8hnn9iX2GSgofeV/sLjFp4E6AbzorvXwxWfozzxWILN Bwy2QDvjDY/Z1S3nWA/1Gm3ACwgqvGn8ytr8LwJ9i2+dLhsT00ZljOhsLGnlJ+917SEM Rtf6DlovObApvimC2aWlOH6yHEW2XRVUhvSCDJBu/CIaFr1G/h5VIBa5DNfxvIoOTNh+ Ddpw== X-Gm-Message-State: AElRT7GEzBNSofGpTw4X6q2WGkH9nJRjrmpqgW14hqVARk79mrL7ikJf rwEOOqlLFqowh7Ks/K6qCG/DhWEHaKI= X-Google-Smtp-Source: AG47ELuvg61///CC0s+4vnbtL/mNwYSvsvPAHKfKkEB6ML7Hmtc8iKqgMaHlGjF32I8d/xGeWeY9og== X-Received: by 2002:a17:902:f81:: with SMTP id 1-v6mr6420289plz.265.1521086466451; Wed, 14 Mar 2018 21:01:06 -0700 (PDT) From: Heyi Guo To: edk2-devel@lists.01.org Date: Thu, 15 Mar 2018 12:00:24 +0800 Message-Id: <1521086424-113954-7-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: [edk2] [PATCH v6 6/6] 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: , Cc: Ruiyu Ni , Yi Li , Eric Dong , Ard Biesheuvel , Heyi Guo , Michael D Kinney , Laszlo Ersek , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" According to UEFI spec 2.7, PciIo->GetBarAttributes should return host address (CPU view ddress) rather than device address (PCI view address), and device address =3D host address + address translation offset, so we subtract translation from device address before returning. 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/= PciBusDxe/PciIo.c index fef3eceb7f62..62179eb44bbd 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c @@ -1972,6 +1972,10 @@ PciIoGetBarAttributes ( return EFI_UNSUPPORTED; } } + + // According to UEFI spec 2.7, we need return host address for + // PciIo->GetBarAttributes, and host address =3D device address - tran= slation. + Descriptor->AddrRangeMin -=3D Descriptor->AddrTranslationOffset; } =20 return EFI_SUCCESS; --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel