From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M4Fgc-0004lP-0G for qemu-devel@nongnu.org; Wed, 13 May 2009 10:43:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M4FgW-0004fe-Oe for qemu-devel@nongnu.org; Wed, 13 May 2009 10:43:57 -0400 Received: from [199.232.76.173] (port=50775 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M4FgW-0004fV-L1 for qemu-devel@nongnu.org; Wed, 13 May 2009 10:43:52 -0400 Received: from e5.ny.us.ibm.com ([32.97.182.145]:58420) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M4FgV-0000tl-UZ for qemu-devel@nongnu.org; Wed, 13 May 2009 10:43:52 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e5.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n4DEcfqR017910 for ; Wed, 13 May 2009 10:38:41 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n4DEhnEH198730 for ; Wed, 13 May 2009 10:43:49 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n4DEhnie018127 for ; Wed, 13 May 2009 10:43:49 -0400 From: Anthony Liguori Date: Wed, 13 May 2009 09:43:46 -0500 Message-Id: <1242225826-15384-3-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1242225826-15384-1-git-send-email-aliguori@us.ibm.com> References: <1242225826-15384-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 2/2] reset state for load_linux List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mark McLoughlin , Glauber Costa , Anthony Liguori From: Glauber Costa The linux loader is just an option rom like any other, just with some special requirements. Right now, our option rom resetting mechanism is not being applied to it. As a result, users using -kernel will not be able to successfully reboot their machines This patch fixes it by saving all the data we generated in the load_linux() function, to be used later by the option rom resetting mechanism. This also includes Mark's fix for -kernel Signed-off-by: Glauber Costa Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori diff --git a/hw/pc.c b/hw/pc.c index c33cd75..40486aa 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -471,7 +471,7 @@ static void bochs_bios_init(void) /* Generate an initial boot sector which sets state and jump to a specified vector */ -static void generate_bootsect(uint8_t *option_rom, +static void generate_bootsect(target_phys_addr_t option_rom, uint32_t gpr[8], uint16_t segs[6], uint16_t ip) { uint8_t rom[512], *p, *reloc; @@ -545,7 +545,8 @@ static void generate_bootsect(uint8_t *option_rom, sum += rom[i]; rom[sizeof(rom) - 1] = -sum; - memcpy(option_rom, rom, sizeof(rom)); + cpu_physical_memory_write_rom(option_rom, rom, sizeof(rom)); + option_rom_setup_reset(option_rom, sizeof (rom)); } static long get_file_size(FILE *f) @@ -562,7 +563,7 @@ static long get_file_size(FILE *f) return size; } -static void load_linux(uint8_t *option_rom, +static void load_linux(target_phys_addr_t option_rom, const char *kernel_filename, const char *initrd_filename, const char *kernel_cmdline) @@ -713,6 +714,12 @@ static void load_linux(uint8_t *option_rom, memset(gpr, 0, sizeof gpr); gpr[4] = cmdline_addr-real_addr-16; /* SP (-16 is paranoia) */ + option_rom_setup_reset(real_addr, setup_size); + option_rom_setup_reset(prot_addr, kernel_size); + option_rom_setup_reset(cmdline_addr, cmdline_size); + if (initrd_filename) + option_rom_setup_reset(initrd_addr, initrd_size); + generate_bootsect(option_rom, gpr, seg, 0); } @@ -920,10 +927,10 @@ vga_bios_error: offset = 0; if (linux_boot) { option_rom_offset = qemu_ram_alloc(TARGET_PAGE_SIZE); - load_linux(phys_ram_base + option_rom_offset, - kernel_filename, initrd_filename, kernel_cmdline); cpu_register_physical_memory(0xd0000, TARGET_PAGE_SIZE, option_rom_offset); + load_linux(0xd0000, + kernel_filename, initrd_filename, kernel_cmdline); offset = TARGET_PAGE_SIZE; } -- 1.6.0.6