From nobody Sun May 5 16:33:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+84372+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84372+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1638767950; cv=none; d=zohomail.com; s=zohoarc; b=imtCPREP/Y26HbHGWmz6nRQmO3sN3+xPUPKyns9SWpPCi9Tm8Q30lsN/NlY8lYUiE9dgZgF6zhJq7HjZyI25tBqZRUcvee9v1Bmo2jxaZJETvmTcg2kADgBiqb6FPwaa2E+4+x6Z6gvGDVhOK+0Sa1N76rUeYuYEGqgsWlDGNMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638767950; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=9pBo3xxELckotvZ94ifHmY+eX5ngvUPr4V94CLZkZkA=; b=e+RD3AkDUy8JGc5DERIqEJ725nt7M/Mf8EbhnRCGys6gAKwLJe520i0LZImYewPMUJMnzwaGNni4my3G49iAkCAfhlos0O2AWmXtpRWWlojvfoI/DaOavT8DAxxnuLZ18N+dxMThHOyRb3MTSP4ySgMoCGAaKlqGMRZ6pqTmzrk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84372+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1638767949739142.74910083769078; Sun, 5 Dec 2021 21:19:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id tfu4YY1788612xDf6CcgGwEs; Sun, 05 Dec 2021 21:19:09 -0800 X-Received: from loongson.cn (loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web08.46969.1638763240722636584 for ; Sun, 05 Dec 2021 20:00:41 -0800 X-Received: from kvm-dev1.localdomain (unknown [10.2.5.134]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Axmsjliq1hTmkDAA--.7214S2; Mon, 06 Dec 2021 12:00:37 +0800 (CST) From: "xianglai" To: devel@edk2.groups.io Cc: xianglai li Subject: [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G Date: Mon, 6 Dec 2021 12:00:33 +0800 Message-Id: <13a7bcbac5bbc7f9cd6a26d6d8ac4eb30f059ec2.1638759596.git.lixianglai@loongson.cn> In-Reply-To: References: X-CM-TRANSID: AQAAf9Axmsjliq1hTmkDAA--.7214S2 X-Coremail-Antispam: 1UD129KBjvJXoW3Xw15JFy8Gw48XF17CFykZrb_yoW3Ar13pa 1qyr93W3s3ZFW5Kw4v9r9rt3WIkas8C34fJ3yaqw1kGwsrZFsxCa1UG3WrGF4xXw1DJwn7 Wr47XF1DWF1UAFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5ol0xt5qjotxo6or00hjvr0hdfq/ Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lixianglai@loongson.cn X-Gm-Message-State: E07ui1zP12N7TW02fIeNZSDOx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1638767949; bh=FFFVJJuOCBEwuBhpnH1nCVcNWnhz7N8lNBIHoQtLEQc=; h=Cc:Date:From:Reply-To:Subject:To; b=fESBTmkHJ9dYPoGhVGL6MNuehjX3T1nBs2k7AM/KiONGN6ByzY93KG3J0YX1lebqogC xpjusNrzCCkUr7x/Gjx+/46598QSxJNFQGnkCqshnZ8hDwJN4EzQwbwIfAeO8m91/2Df4 5lYq70tZtrrJisiuilRIUeI8FekT+GW+Yxk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1638767950474100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In FvbInitialize Function, PcdFlashNvStorageVariableBase64 PcdFlashNvStorageFtwWorkingBase PcdFlashNvStorageFtwSpareBase will not exceed 0x100000000, Due to truncation and variable type limitations. That leads to the NV variable cannot be saved to the memory above 4G. Modify as follows: 1.Remove the forced type conversion of UINT32. 2.Use UINT64 type variables. Signed-off-by: xianglai li Reviewed-by: Gerd Hoffmann Reviewed-by: Jiewen Yao --- OvmfPkg/AmdSev/AmdSevX64.dsc | 2 ++ OvmfPkg/Bhyve/BhyveX64.dsc | 2 ++ OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c | 8 +++----- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf | 4 ++-- OvmfPkg/Microvm/MicrovmX64.dsc | 2 ++ OvmfPkg/OvmfPkgIa32.dsc | 2 ++ OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++ OvmfPkg/OvmfPkgX64.dsc | 2 ++ OvmfPkg/OvmfXen.dsc | 2 ++ 9 files changed, 19 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index 5ee5445..d5ad34a 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -535,6 +535,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 =20 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc index d8fe607..8584e32 100644 --- a/OvmfPkg/Bhyve/BhyveX64.dsc +++ b/OvmfPkg/Bhyve/BhyveX64.dsc @@ -513,6 +513,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 =20 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c b/OvmfPkg/EmuVariableFv= bRuntimeDxe/Fvb.c index 766ad1e..2d03af1 100644 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c +++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c @@ -776,15 +776,14 @@ FvbInitialize ( SetMem (Ptr, EMU_FVB_SIZE, ERASED_UINT8); InitializeFvAndVariableStoreHeaders (Ptr); } - PcdStatus =3D PcdSet64S (PcdFlashNvStorageVariableBase64, (UINT32)(UINTN= ) Ptr); + PcdStatus =3D PcdSet64S (PcdFlashNvStorageVariableBase64, (UINTN) Ptr); ASSERT_RETURN_ERROR (PcdStatus); =20 // // Initialize the Fault Tolerant Write data area // SubPtr =3D (VOID*) ((UINT8*) Ptr + PcdGet32 (PcdFlashNvStorageVariableSi= ze)); - PcdStatus =3D PcdSet32S (PcdFlashNvStorageFtwWorkingBase, - (UINT32)(UINTN) SubPtr); + PcdStatus =3D PcdSet64S (PcdFlashNvStorageFtwWorkingBase64, (UINTN) SubP= tr); ASSERT_RETURN_ERROR (PcdStatus); =20 // @@ -792,8 +791,7 @@ FvbInitialize ( // SubPtr =3D (VOID*) ((UINT8*) Ptr + EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE); - PcdStatus =3D PcdSet32S (PcdFlashNvStorageFtwSpareBase, - (UINT32)(UINTN) SubPtr); + PcdStatus =3D PcdSet64S (PcdFlashNvStorageFtwSpareBase64, (UINTN) SubPtr= ); ASSERT_RETURN_ERROR (PcdStatus); =20 // diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf b/OvmfPkg/EmuVariable= FvbRuntimeDxe/Fvb.inf index 225ea27..0811545 100644 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf +++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf @@ -59,8 +59,8 @@ =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved =20 [Depex] diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc index 617f925..57d6caa 100644 --- a/OvmfPkg/Microvm/MicrovmX64.dsc +++ b/OvmfPkg/Microvm/MicrovmX64.dsc @@ -553,6 +553,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 =20 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 6a5be97..3d45e08 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -596,6 +596,8 @@ =20 !if $(SMM_REQUIRE) =3D=3D FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 !endif diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 71227d1..347467d 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -602,6 +602,8 @@ =20 !if $(SMM_REQUIRE) =3D=3D FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 !endif diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 52f7598..e7d34dd 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -602,6 +602,8 @@ =20 !if $(SMM_REQUIRE) =3D=3D FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 !endif diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index a31519e..74e878f 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -460,6 +460,8 @@ [PcdsDynamicDefault] gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 --=20 1.8.3.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#84372): https://edk2.groups.io/g/devel/message/84372 Mute This Topic: https://groups.io/mt/87534620/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-