From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] Allow additions of ACPI tables from command line
Date: Mon, 16 Feb 2009 09:27:26 -0600 [thread overview]
Message-ID: <499985DE.7010807@us.ibm.com> (raw)
In-Reply-To: <20090209142832.GF28969@redhat.com>
Gleb Natapov wrote:
> This is needed to dynamically add SLIC tables with Windows
> activation keys.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> 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
next prev parent reply other threads:[~2009-02-16 15:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-09 14:28 [Qemu-devel] [PATCH v2] Allow additions of ACPI tables from command line Gleb Natapov
2009-02-16 15:27 ` Anthony Liguori [this message]
2009-02-17 7:29 ` Gleb Natapov
2009-02-17 14:19 ` Anthony Liguori
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=499985DE.7010807@us.ibm.com \
--to=aliguori@us.ibm.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.