From: Gleb Natapov <gleb@qumranet.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: [PATCH 0/3]: Add UUID command-line option
Date: Tue, 5 Aug 2008 17:33:19 +0300 [thread overview]
Message-ID: <20080805143319.GC3689@minantech.com> (raw)
In-Reply-To: <f43fc5580807301032j2dc2b2fbmf6b53a5ebdf4504@mail.gmail.com>
> Here's a patch implementing a configuration ROM (probably in a bad
> address) including a fake UUID. I skipped the more difficult parts
> like kernel address etc.
I haven't seen any comments on this. Anthony, is this approach
acceptable?
> Index: qemu/hw/pc.c
> ===================================================================
> --- qemu.orig/hw/pc.c 2008-07-30 16:58:03.000000000 +0000
> +++ qemu/hw/pc.c 2008-07-30 17:24:01.000000000 +0000
> @@ -32,6 +32,7 @@
> #include "smbus.h"
> #include "boards.h"
> #include "console.h"
> +#include "firmware_abi.h"
>
> /* output Bochs bios info messages */
> //#define DEBUG_BIOS
> @@ -41,6 +42,8 @@
> #define VGABIOS_CIRRUS_FILENAME "vgabios-cirrus.bin"
>
> #define PC_MAX_BIOS_SIZE (4 * 1024 * 1024)
> +#define PC_CFG_ROM_ADDR 0xf0000000
> +#define PC_CFG_ROM_SIZE 4096
>
> /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables. */
> #define ACPI_DATA_SIZE 0x10000
> @@ -712,6 +715,55 @@
> nb_ne2k++;
> }
>
> +static int pc_cfg_rom_set_params(ram_addr_t cfg_rom,
> + const char *arch,
> + ram_addr_t below_4g_mem_size,
> + ram_addr_t above_4g_mem_size,
> + const char *boot_devices)
> +{
> + uint32_t start;
> + uint8_t image[PC_CFG_ROM_SIZE];
> + ohwcfg_v3_t *header = (ohwcfg_v3_t *)ℑ
> + struct pc_arch_cfg *pc_header;
> + extern int nographic;
> +
> + memset(image, '\0', sizeof(image));
> +
> + // Try to match PPC NVRAM
> + strcpy((char *)header->struct_ident, "QEMU_BIOS");
> + header->struct_version = cpu_to_le32(3); /* structure v3 */
> +
> + header->nvram_arch_ptr = cpu_to_le16(sizeof(ohwcfg_v3_t));
> + header->nvram_arch_size = cpu_to_le16(sizeof(struct pc_arch_cfg));
> + strcpy((char *)header->arch, arch);
> + header->nb_cpus = smp_cpus & 0xff;
> + header->RAM0_base = 0;
> + header->RAM0_size = cpu_to_le64((uint64_t)below_4g_mem_size);
> + if (above_4g_mem_size) {
> + header->RAM1_base = 0x100000000ULL;
> + header->RAM1_size = cpu_to_le64((uint64_t)above_4g_mem_size);
> + }
> + strcpy((char *)header->boot_devices, boot_devices);
> + header->nboot_devices = strlen(boot_devices) & 0xff;
> +
> + if (nographic)
> + header->graphic_flags = cpu_to_le16(OHW_GF_NOGRAPHICS);
> +
> + strncpy((char *)header->uuid, "QEMUQEMUQEMUQEMU", 16);
> +
> + header->crc = cpu_to_le16(OHW_compute_crc(header, 0x00, 0xF8));
> +
> + // Architecture specific header
> + start = sizeof(ohwcfg_v3_t);
> + pc_header = (struct pc_arch_cfg *)&image[start];
> + pc_header->valid = 1;
> + start += sizeof(struct pc_arch_cfg);
> +
> + cpu_physical_memory_write_rom(cfg_rom, image, sizeof(image));
> +
> + return 0;
> +}
> +
> /* PC hardware initialisation */
> static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
> const char *boot_device, DisplayState *ds,
> @@ -723,6 +775,7 @@
> int ret, linux_boot, i;
> ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
> ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
> + ram_addr_t cfg_rom_offset;
> int bios_size, isa_bios_size, vga_bios_size;
> PCIBus *pci_bus;
> int piix3_devfn = -1;
> @@ -867,6 +920,14 @@
> cpu_register_physical_memory((uint32_t)(-bios_size),
> bios_size, bios_offset | IO_MEM_ROM);
>
> + /* map configuration ROM */
> + cfg_rom_offset = qemu_ram_alloc(PC_CFG_ROM_SIZE);
> + cpu_register_physical_memory(PC_CFG_ROM_ADDR, PC_CFG_ROM_SIZE,
> + cfg_rom_offset | IO_MEM_ROM);
> + pc_cfg_rom_set_params(PC_CFG_ROM_ADDR, pci_enabled? "pc" : "isapc",
> + below_4g_mem_size, above_4g_mem_size,
> + boot_device);
> +
> bochs_bios_init();
>
> if (linux_boot)
> Index: qemu/hw/firmware_abi.h
> ===================================================================
> --- qemu.orig/hw/firmware_abi.h 2008-07-30 16:57:53.000000000 +0000
> +++ qemu/hw/firmware_abi.h 2008-07-30 17:22:12.000000000 +0000
> @@ -54,8 +54,10 @@
> uint8_t pad3[5];
> /* 0xD0: boot devices */
> uint8_t boot_devices[0x10];
> - /* 0xE0 */
> - uint8_t pad4[0x1C]; /* 28 */
> + /* 0xE0: UUID */
> + uint8_t uuid[0x10];
> + /* 0xF0 */
> + uint8_t pad4[0xC]; /* 12 */
> /* 0xFC: checksum */
> uint16_t crc;
> uint8_t pad5[0x02];
> @@ -176,6 +178,12 @@
> header->checksum = tmp;
> }
>
> +/* PC configuration structure */
> +struct pc_arch_cfg {
> + uint8_t valid;
> + uint8_t unused[63];
> +};
> +
> #else /* __ASSEMBLY__ */
>
> /* Structure offsets for asm use */
> Index: qemu/hw/sun4m.c
> ===================================================================
> --- qemu.orig/hw/sun4m.c 2008-07-30 17:24:14.000000000 +0000
> +++ qemu/hw/sun4m.c 2008-07-30 17:24:56.000000000 +0000
> @@ -213,6 +213,8 @@
> if (nographic)
> header->graphic_flags = cpu_to_be16(OHW_GF_NOGRAPHICS);
>
> + strncpy((char *)header->uuid, "QEMUQEMUQEMUQEMU", 16);
> +
> header->crc = cpu_to_be16(OHW_compute_crc(header, 0x00, 0xF8));
>
> // Architecture specific header
> Index: qemu/hw/sun4u.c
> ===================================================================
> --- qemu.orig/hw/sun4u.c 2008-07-30 17:24:16.000000000 +0000
> +++ qemu/hw/sun4u.c 2008-07-30 17:24:33.000000000 +0000
> @@ -144,6 +144,8 @@
> if (nographic)
> header->graphic_flags = cpu_to_be16(OHW_GF_NOGRAPHICS);
>
> + strncpy((char *)header->uuid, "QEMUQEMUQEMUQEMU", 16);
> +
> header->crc = cpu_to_be16(OHW_compute_crc(header, 0x00, 0xF8));
>
> // Architecture specific header
--
Gleb.
next prev parent reply other threads:[~2008-08-05 14:33 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 13:25 [Qemu-devel] [PATCH 0/3]: Add UUID command-line option Chris Lalancette
2008-07-28 14:15 ` [Qemu-devel] " Gleb Natapov
2008-07-28 14:37 ` Anthony Liguori
2008-07-28 14:41 ` Chris Lalancette
2008-07-28 15:02 ` Anthony Liguori
2008-07-28 15:09 ` Chris Lalancette
2008-07-28 15:12 ` Anthony Liguori
2008-07-28 15:42 ` Chris Lalancette
2008-07-28 16:02 ` Gleb Natapov
2008-07-28 16:17 ` Anthony Liguori
2008-07-28 16:27 ` Gleb Natapov
2008-07-28 17:41 ` Blue Swirl
2008-07-28 16:28 ` Jamie Lokier
2008-07-28 19:02 ` Anthony Liguori
2008-07-28 20:00 ` Jamie Lokier
2008-07-28 20:25 ` Anthony Liguori
2008-07-28 20:40 ` Paul Brook
2008-07-28 20:55 ` Anthony Liguori
2008-07-29 6:31 ` Gleb Natapov
2008-07-28 15:48 ` Jamie Lokier
2008-07-31 19:45 ` [Qemu-devel] " Sebastian Herbszt
2008-07-28 15:49 ` [Qemu-devel] " Jamie Lokier
2008-07-28 16:06 ` Anthony Liguori
2008-07-28 15:35 ` Gleb Natapov
2008-07-29 19:22 ` Anthony Liguori
2008-07-29 19:50 ` Gleb Natapov
2008-07-30 17:32 ` Blue Swirl
2008-08-05 14:33 ` Gleb Natapov [this message]
2008-08-06 2:35 ` Anthony Liguori
2008-08-06 16:26 ` Blue Swirl
2008-08-06 16:33 ` Anthony Liguori
2008-08-06 22:07 ` [Qemu-devel] " Sebastian Herbszt
2008-08-06 22:11 ` [Qemu-devel] " Anthony Liguori
2008-07-29 8:15 ` Daniel P. Berrange
2008-07-29 8:42 ` Chris Lalancette
2008-07-28 15:51 ` Jamie Lokier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080805143319.GC3689@minantech.com \
--to=gleb@qumranet.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.