From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L2Dt7-00049B-Kn for qemu-devel@nongnu.org; Mon, 17 Nov 2008 18:52:13 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L2Dt6-00048z-7V for qemu-devel@nongnu.org; Mon, 17 Nov 2008 18:52:13 -0500 Received: from [199.232.76.173] (port=54233 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L2Dt5-00048w-UM for qemu-devel@nongnu.org; Mon, 17 Nov 2008 18:52:11 -0500 Received: from mail.gmx.net ([213.165.64.20]:32780) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1L2Dt5-0005BT-7X for qemu-devel@nongnu.org; Mon, 17 Nov 2008 18:52:11 -0500 Message-ID: <6BBD568AF57A42CE81244D009F97923C@FSCPC> From: "Sebastian Herbszt" References: <20081116093345.23209.79952.stgit@dhcp-1-237.local> <20081116093355.23209.96231.stgit@dhcp-1-237.local> In-Reply-To: <20081116093355.23209.96231.stgit@dhcp-1-237.local> Date: Tue, 18 Nov 2008 00:51:17 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [Bochs-developers] [PATCH v4 2/5] Preserve memory content duringSMM init. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov , bochs-developers@lists.sourceforge.net Cc: qemu-devel@nongnu.org Gleb Natapov wrote: > Signed-off-by: Gleb Natapov > --- > > bios/rombios32.c | 10 ++++++++-- > 1 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/bios/rombios32.c b/bios/rombios32.c > index 7b354a8..7075aa9 100644 > --- a/bios/rombios32.c > +++ b/bios/rombios32.c > @@ -731,6 +731,12 @@ static void smm_init(PCIDevice *d) > value = pci_config_readl(d, 0x58); > if ((value & (1 << 25)) == 0) { > > + /* enable the SMM memory window */ > + pci_config_writeb(&i440_pcidev, 0x72, 0x02 | 0x48); > + > + /* save original memory content */ > + memcpy((void *)0xa8000, (void *)0x38000, 0x8000); > + > /* copy the SMM relocation code */ > memcpy((void *)0x38000, &smm_relocation_start, > &smm_relocation_end - &smm_relocation_start); > @@ -747,8 +753,8 @@ static void smm_init(PCIDevice *d) > /* wait until SMM code executed */ > while (inb(0xb3) != 0x00); > > - /* enable the SMM memory window */ > - pci_config_writeb(&i440_pcidev, 0x72, 0x02 | 0x48); > + /* restore original memory content */ > + memcpy((void *)0x38000, (void *)0xa8000, 0x8000); > > /* copy the SMM code */ > memcpy((void *)0xa8000, &smm_code_start, Gleb, can you please explain why this is needed? smm_init() is currently only run on VM start and overwriting memory is not an issue there. This would matter on S3 resume, but smm_init() is not run there. It is only run from pci_bios_init(), but on S3 resume we bail out from rombios32.c before this call. Your patch to handle S3 in qemu does use qemu_system_reset_request() which does reset some emulated devices. Since piix4_pm does not register a reset handler it is not reset. I assume the reset on S3 resume is a hardware reset and the state of piix4_pm should be reset too, right? cpu_reset() in target-i386/helper.c does set smbase to 0x30000. Since the piix4_pm state is not lost, APMC_EN is still set and even on a normal reset SMBASE is not relocated. If i don't mistake smm_init() should be run on S3 resume and we would need something like pci_for_each_device(find_piix4pm) if (piix4pm_pcidev) smm_init(); in the resume path in rombios32.c. - Sebastian