From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.303.1662438976985344787 for ; Mon, 05 Sep 2022 21:36:23 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=YwnV6mmw; spf=permerror, err=too many SPF records (domain: intel.com, ip: 192.55.52.115, 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=1662438983; x=1693974983; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uPyYXd/pMfFSYSQl5k0XeYW9R12e1zQxKbSpXLW7mso=; b=YwnV6mmwrbEFvUMqy/+WDrDMw0jckA4G3wrMZ30TT76H1i4oDeBjF5Hg X8NJ80vcvREzI0SC1FV5jd+L0CT+4E/10F/JnubMOes/B4jsEQ3usB4hU 0QSy//pwoOO8vCb/GtiCW1ec+bZJezgJ6qvPQOc/vDj/gha65q3uFROTc DBuJYKxoBjwADmEAjGWzu2JO0bLwip1hs3A1BR3nC/dYSQHVG1V6AM+Qj yhlqdtoyPq0hxxPsPXT4r6V84RO8MFjIhKjjbE6P5zzKrTLgfvYTmxKMI QdALzPQmdnoAHugQZeuxpQ/B4PIzwB7GyeDh+O2qgFpJGJoFBaiGsHabM Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10461"; a="296502078" X-IronPort-AV: E=Sophos;i="5.93,293,1654585200"; d="scan'208";a="296502078" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 21:36:23 -0700 X-IronPort-AV: E=Sophos;i="5.93,293,1654585200"; d="scan'208";a="675517312" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.4.118]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 21:36:21 -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 V5 4/8] OvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore Date: Tue, 6 Sep 2022 12:35:56 +0800 Message-Id: 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 Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Acked-by: 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