From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web12.32335.1656631779038420889 for ; Thu, 30 Jun 2022 16:29:48 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Nm2+Csr6; spf=pass (domain: intel.com, ip: 134.134.136.126, 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=1656631788; x=1688167788; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ib84mONkNIXVdoWg3PuWE8rxzaUJns7GSSx3bu8lxCU=; b=Nm2+Csr6HSv5lsQiSBIHBglaUHw4HySH0c4rE+TeKa0YiHTvHJLzqa0g FcAA/BRCB7d8RtEn7SYMEeKTebbutRPdmUgDD8CbBuxy+DC2G3r1Yalcb /iqp1b7MKXw3ox3YAlZI2SjjPU0z8+6jdxxpXUKnIEUBWrbh713GtKiPx YQt0mnh0cPIY9G5kih/N1F7UbGrUiZnMJ3G0p/YD0daJgZY9aA+Qyw7tC RGOUxuHfYXgO8F52aq29xGCzwwSSw2XBk6+k1BM6FXmvh7mzTyoXNCLpp 9SFYMDI283Kev72IiXedTKUbgmAhZEUk20PNRLLFKQ1tSZvPJqxSxgnxl Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10394"; a="265528335" X-IronPort-AV: E=Sophos;i="5.92,235,1650956400"; d="scan'208";a="265528335" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2022 16:29:45 -0700 X-IronPort-AV: E=Sophos;i="5.92,235,1650956400"; d="scan'208";a="648098681" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.210]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2022 16:29:44 -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 V4 4/8] OvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore Date: Fri, 1 Jul 2022 07:29:13 +0800 Message-Id: <1aab00b3eba2fd8a019f9941da46e62dbfa80f82.1656630360.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 Cc: Jiewen Yao Cc: Tom Lendacky 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