From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LZ5O3-0005fI-KV for qemu-devel@nongnu.org; Mon, 16 Feb 2009 10:27:59 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LZ5O1-0005f6-P5 for qemu-devel@nongnu.org; Mon, 16 Feb 2009 10:27:59 -0500 Received: from [199.232.76.173] (port=32902 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LZ5O1-0005f1-HV for qemu-devel@nongnu.org; Mon, 16 Feb 2009 10:27:57 -0500 Received: from e4.ny.us.ibm.com ([32.97.182.144]:50592) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LZ5O1-0004Y2-8j for qemu-devel@nongnu.org; Mon, 16 Feb 2009 10:27:57 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e4.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n1GFPk2A029933 for ; Mon, 16 Feb 2009 10:25:46 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n1GFRufu193414 for ; Mon, 16 Feb 2009 10:27:56 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n1GFRtxu025186 for ; Mon, 16 Feb 2009 10:27:55 -0500 Received: from squirrel.codemonkey.ws (sig-9-65-85-240.mts.ibm.com [9.65.85.240]) by d01av01.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n1GFRtdm025166 for ; Mon, 16 Feb 2009 10:27:55 -0500 Message-ID: <499985DE.7010807@us.ibm.com> Date: Mon, 16 Feb 2009 09:27:26 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH v2] Allow additions of ACPI tables from command line References: <20090209142832.GF28969@redhat.com> In-Reply-To: <20090209142832.GF28969@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Gleb Natapov wrote: > This is needed to dynamically add SLIC tables with Windows > activation keys. > > Signed-off-by: Gleb Natapov > diff --git a/hw/acpi.c b/hw/acpi.c > index 4338d02..7175598 100644 > --- a/hw/acpi.c > +++ b/hw/acpi.c > @@ -561,3 +561,170 @@ void qemu_system_powerdown(void) > } > } > #endif > + > +struct acpi_table_header > +{ > + char signature [4]; /* ACPI signature (4 ASCII characters) */ > + uint32_t length; /* Length of table, in bytes, including header */ > + uint8_t revision; /* ACPI Specification minor version # */ > + uint8_t checksum; /* To make sum of entire table == 0 */ > + char oem_id [6]; /* OEM identification */ > + char oem_table_id [8]; /* OEM table identification */ > + uint32_t oem_revision; /* OEM revision number */ > + char asl_compiler_id [4]; /* ASL compiler vendor ID */ > + uint32_t asl_compiler_revision; /* ASL compiler revision number */ > +}; > I don't have a lot of confidence that this table is going to be padded correctly by all compilers on all architectures. I'd suggest explicit padding. > +int acpi_table_add(const char *t) > +{ > + static const char *dfl_id = "QEMUQEMU"; > + char buf[1024], *p, *f; > + struct acpi_table_header acpi_hdr; > + unsigned long val; > + size_t off; > + > + memset(&acpi_hdr, 0, sizeof(acpi_hdr)); > + > + if (get_param_value(buf, sizeof(buf), "sig", t)) { > + strncpy(acpi_hdr.signature, buf, 4); > + } else { > + strncpy(acpi_hdr.signature, dfl_id, 4); > + } > + if (get_param_value(buf, sizeof(buf), "rev", t)) { > + val = strtoul(buf, &p, 10); > + if (val > 255 || *p != '\0') > + goto out; > + } else { > + val = 1; > + } > + acpi_hdr.revision = (int8_t)val; > You're filling this table out in host endianness, not guest endianness. The table gets passed directly to the guest's BIOS though. > + if (get_param_value(buf, sizeof(buf), "oem_id", t)) { > + strncpy(acpi_hdr.oem_id, buf, 6); > is oem_id supposed to be NULL terminated or just NULL padded? Regards, Anthony Liguori