From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=jordan.l.justen@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 0A3852194EB7D for ; Sun, 17 Feb 2019 20:12:02 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2019 20:12:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,383,1544515200"; d="scan'208";a="321197999" Received: from mmdandap-mobl1.amr.corp.intel.com (HELO jljusten-skl.amr.corp.intel.com) ([10.254.8.66]) by fmsmga005.fm.intel.com with ESMTP; 17 Feb 2019 20:12:01 -0800 From: Jordan Justen To: edk2-devel@lists.01.org Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Anthony Perard , Julien Grall Date: Sun, 17 Feb 2019 20:11:41 -0800 Message-Id: <20190218041141.21363-11-jordan.l.justen@intel.com> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20190218041141.21363-1-jordan.l.justen@intel.com> References: <20190218041141.21363-1-jordan.l.justen@intel.com> MIME-Version: 1.0 Subject: [PATCH 10/10] OvmfPkg/Sec: Fill Temp Ram after TemporaryRamMigration X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Feb 2019 04:12:02 -0000 Content-Transfer-Encoding: 8bit On some platforms, the TemporaryRamMigration PPI may cause Temporary RAM to become inaccessible after the RAM is migrated. To emulate this in OVMF, we should initialize memory to a bad state to make sure it isn't accidentally being used after TemporaryRamMigration is called. I tested IA32 booting to shell and X64 booting to OS with this change. With X64 I also tested S3 suspend/resume. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall --- OvmfPkg/Sec/SecMain.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 86c22a2ac9..72946e0eab 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -948,6 +948,14 @@ TemporaryRamMigration ( LongJump (&JumpBuffer, (UINTN)-1); } + // + // Initialize Temporary RAM to a bad value to make sure it will not + // be used after migration. + // + SetMem32 ( + (VOID*)(UINTN)TemporaryMemoryBase, CopySize, + PcdGet32 (PcdInitValueInTempStack)); + SaveAndSetDebugTimerInterrupt (OldStatus); return EFI_SUCCESS; -- 2.20.0.rc1