From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L5edK-0001A0-TX for qemu-devel@nongnu.org; Thu, 27 Nov 2008 06:02:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L5edI-00018k-Qi for qemu-devel@nongnu.org; Thu, 27 Nov 2008 06:02:06 -0500 Received: from [199.232.76.173] (port=59160 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L5edI-00018W-Km for qemu-devel@nongnu.org; Thu, 27 Nov 2008 06:02:04 -0500 Received: from mx2.redhat.com ([66.187.237.31]:43253) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L5edH-0006GT-Ax for qemu-devel@nongnu.org; Thu, 27 Nov 2008 06:02:03 -0500 From: Gleb Natapov Date: Thu, 27 Nov 2008 13:02:30 +0200 Message-ID: <20081127110230.25353.19306.stgit@dhcp-1-237.tlv.redhat.com> In-Reply-To: <20081127110220.25353.83454.stgit@dhcp-1-237.tlv.redhat.com> References: <20081127110220.25353.83454.stgit@dhcp-1-237.tlv.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH v5 2/5] Preserve memory content during SMM init. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: bochs-developers@lists.sourceforge.net Cc: qemu-devel@nongnu.org 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 d9b59d5..4093d88 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,