From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 DE02320886D9B for ; Mon, 18 Feb 2019 05:15:29 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B955C1F78; Mon, 18 Feb 2019 13:15:29 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-242.rdu2.redhat.com [10.10.120.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB5C75ED24; Mon, 18 Feb 2019 13:15:27 +0000 (UTC) To: Jordan Justen , edk2-devel@lists.01.org Cc: Ard Biesheuvel , Anthony Perard , Julien Grall References: <20190218041141.21363-1-jordan.l.justen@intel.com> <20190218041141.21363-11-jordan.l.justen@intel.com> From: Laszlo Ersek Message-ID: <13453c76-e0af-ca3a-e803-c53e6ce496d9@redhat.com> Date: Mon, 18 Feb 2019 14:15:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190218041141.21363-11-jordan.l.justen@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 18 Feb 2019 13:15:29 +0000 (UTC) Subject: Re: [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 13:15:30 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 02/18/19 05:11, Jordan Justen wrote: > 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; > Assuming the previous PEI Core patches in this series don't change the order, it looks like the PeiCheckAndSwitchStack() function [MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c] logs the "stack ever used" stat first, and calls the TemporaryRamMigration() PPI member second. Thus, by the time we overwrite the temp RAM in this patch, the statistics will have been printed in PeiCheckAndSwitchStack(). OK. Reviewed-by: Laszlo Ersek Thanks Laszlo