From patchwork Fri Dec 2 10:48:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 86271 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp194282qgi; Fri, 2 Dec 2016 02:48:52 -0800 (PST) X-Received: by 10.84.214.15 with SMTP id h15mr95111830pli.135.1480675732101; Fri, 02 Dec 2016 02:48:52 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id g22si4595097pli.174.2016.12.02.02.48.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Dec 2016 02:48:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8FCC381F4D; Fri, 2 Dec 2016 02:48:51 -0800 (PST) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BBF9181EA7 for ; Fri, 2 Dec 2016 02:48:49 -0800 (PST) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 265588E3FB; Fri, 2 Dec 2016 10:48:49 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-74.phx2.redhat.com [10.3.116.74]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uB2AmlX4003644; Fri, 2 Dec 2016 05:48:48 -0500 From: Laszlo Ersek To: edk2-devel-01 Date: Fri, 2 Dec 2016 11:48:44 +0100 Message-Id: <20161202104844.6093-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 02 Dec 2016 10:48:49 +0000 (UTC) Subject: [edk2] [PATCH] OvmfPkg/SmmControl2Dxe: correct PCI_CONFIG_READ_WRITE in S3 boot script X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE expects the PCI address to access in UEFI encoding, not in edk2/PciLib encoding. Convert the ICH9_GEN_PMCON_1 register's address to UEFI representation before storing it in the boot script. Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) -- 2.9.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c b/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c index c5e5ed02f5ad..3694282c82ad 100644 --- a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c +++ b/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -307,6 +308,33 @@ FatalError: } /** + Convert a PCI address originally composed with PCI_LIB_ADDRESS() to + EFI_PCI_ADDRESS() representation (see Table 111. "PCI Configuration Address" + in UEFI-2.6). + + @param[in] PciLibAddress A PCI address originally composed with + PCI_LIB_ADDRESS(). + + @return The converted address suitable for consumers that expect + EFI_PCI_ADDRESS() representation. +**/ +STATIC +UINT64 +ConvertPciLibToEfiPciAddress ( + IN UINT32 PciLibAddress + ) +{ + UINT32 Bus, Device, Function, Register; + + Register = BitFieldRead32 (PciLibAddress, 0, 11); + Function = BitFieldRead32 (PciLibAddress, 12, 14); + Device = BitFieldRead32 (PciLibAddress, 15, 19); + Bus = BitFieldRead32 (PciLibAddress, 20, 27); + + return EFI_PCI_ADDRESS (Bus, Device, Function, Register); +} + +/** Notification callback for S3SaveState installation. @param[in] Event Event whose notification function is being invoked. @@ -362,7 +390,9 @@ OnS3SaveStateInstalled ( S3SaveState, EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE, EfiBootScriptWidthUint16, - (UINT64)POWER_MGMT_REGISTER_Q35 (ICH9_GEN_PMCON_1), + ConvertPciLibToEfiPciAddress ( + POWER_MGMT_REGISTER_Q35 (ICH9_GEN_PMCON_1) + ), &GenPmCon1OrMask, &GenPmCon1AndMask );