From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web09.26612.1656212770864849318 for ; Sat, 25 Jun 2022 20:06:20 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=MwJYWeLo; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656212779; x=1687748779; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HG0cK3ctmkeK6d9c36ZzLWutn8wqiyc9+fEAO7cYAtk=; b=MwJYWeLo/OktH7frZDOJ5TwCIzu7DZaN0XaPU8KHO/9ZJCU978yYBatj 3hfRfTaSliTVsw7IfjWCoBZJ5ncZwmhHD3n3/fCVUZSYJHJYL+b8q0sYG 5eB8nf6TGYjYvXiCZqPkC88ee7Yak7SWNe9EKdMtaTPYu3oTK9WxgQsPi iYWg/x6cmpIAK3/Z5bVaUdrLTlPL/Wtj6DbCYglC281ag73mx6wfymF26 LEMFRaMJ8aSdfLym2XZ7TQu6nHFomtBRqW8lBfsHiFaB0aqhddeOcvklu YKRWN2YYJo3zyFxQJ50kXEFZKuAvnX1zNXIYAt+96OFgXAYEzYVYDjAJD g==; X-IronPort-AV: E=McAfee;i="6400,9594,10389"; a="367554861" X-IronPort-AV: E=Sophos;i="5.92,223,1650956400"; d="scan'208";a="367554861" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2022 20:06:19 -0700 X-IronPort-AV: E=Sophos;i="5.92,223,1650956400"; d="scan'208";a="645862124" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.236]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2022 20:06:18 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann Subject: [PATCH V2 5/8] OvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore Date: Sun, 26 Jun 2022 11:05:54 +0800 Message-Id: <93072b2c22fbd173b6732baaf0dee9d22a3e5db8.1656210686.git.min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Min M Xu ReserveEmuVariableNvStore is updated with below 2 functions defined in PlatformInitLib: - PlatformReserveEmuVariableNvStore - PlatformInitEmuVariableNvStore PlatformInitEmuVariableNvStore works when secure boot feature is enabled. This is because secure boot needs the EFI variables (PK/KEK/DB/DBX, etc) and EmuVariableNvStore is cleared when OVMF is launched with -bios parameter. Cc: Erdem Aktas Cc: James Bottomley [jejb] Cc: Jiewen Yao [jyao1] Cc: Tom Lendacky [tlendacky] Cc: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/PlatformPei/Platform.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 009db67ee60a..b1f8140d6041 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -220,24 +220,13 @@ ReserveEmuVariableNvStore ( EFI_PHYSICAL_ADDRESS VariableStore; RETURN_STATUS PcdStatus; - // - // Allocate storage for NV variables early on so it will be - // at a consistent address. Since VM memory is preserved - // across reboots, this allows the NV variable storage to survive - // a VM reboot. - // - VariableStore = - (EFI_PHYSICAL_ADDRESS)(UINTN) - AllocateRuntimePages ( - EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) - ); - DEBUG (( - DEBUG_INFO, - "Reserved variable store memory: 0x%lX; size: %dkb\n", - VariableStore, - (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024 - )); - PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore); + VariableStore = (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore (); + PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore); + + #ifdef SECURE_BOOT_FEATURE_ENABLED + PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore); + #endif + ASSERT_RETURN_ERROR (PcdStatus); } -- 2.29.2.windows.2