qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: ben@skyportsystems.com, mst@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 05/10] ACPI: Add Virtual Machine Generation ID support
Date: Thu, 9 Feb 2017 20:27:51 +0100	[thread overview]
Message-ID: <e23ba6e2-10b6-0cd2-b42c-0a4c66c706d6@redhat.com> (raw)
In-Reply-To: <20170209182316.71d5df5f@nial.brq.redhat.com>

On 02/09/17 18:23, Igor Mammedov wrote:
> On Wed, 8 Feb 2017 01:48:42 +0100
> Laszlo Ersek <lersek@redhat.com> wrote:
> 
>> On 02/05/17 10:12, ben@skyportsystems.com wrote:
>>> From: Ben Warren <ben@skyportsystems.com>
> [...]
> 
>> (2) Structure of the vmgenid fw_cfg blob, AKA "why that darn offset 40
>> decimal".
>>
>> I explained it under points (6) and (7) in the following message:
>>
>> Message-Id: <c16a03d5-820a-f719-81ea-43858f903395@redhat.com>
>> URL: https://www.mail-archive.com/qemu-devel@nongnu.org/msg425226.html
>>
>> The story is that *wherever* an ADD_POINTER command points to -- that
>> is, at the *exact* target address --, OVMF will look for an ACPI table
>> header, somewhat heuristically. If it finds a byte pattern that (a) fits
>> into the remaining blob and (b) passes some superficial ACPI table
>> header checks, such as length and checksum, then OVMF assumes that the
>> blob contains an ACPI table there, and passes the address (again, the
>> exact, relocated, absolute target address of ADD_POINTER) to
>> EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable().
>>
>> We want to disable this heuristic for the vmgenid blob. *If* the blob
>> contained only 16 bytes (for the GUID), then the heuristic would
>> automatically disable itself, because the ACPI table header (36 bytes)
>> is larger than 16 bytes, so OVMF wouldn't even look. However, for the
>> caching and other VMGENID requirements, we need to allocate a full page
>> with the blob (4KB), hence OVMF *will* look. If we placed the GUID right
>> at the start of the page, then OVMF would sanity-check it as an ACPI
>> table header. The check would *most likely* not pass, so things would be
>> fine in practice, but we can do better than that: just put 40 zero bytes
>> at the front of the blob.
>>
>> And this is why the ADD_POINTER command has to point to the beginning of
>> the blob (i.e., 36 zero bytes), to "suppress the OVMF ACPI SDT header
>> detection". (The other 4 bytes are for arriving at an address divisible
>> by 8, which is a VMGENID requirement for the GUID.)
>>
>> The consequence is that both the ADDR method and QEMU's guest memory
>> access code have to add 40 manually.
> The longer I look "suppress the OVMF ACPI SDT header detection",
> the less I like approach.
> 
> It looks somewhat backwards where a firmware forces QEMU
> to use non obvious offsets to workaround OVMF ACPI table detection
> heuristics.

This is for historical reasons -- when the linker/loader commands were
invented, it wasn't considered that in UEFI, ACPI tables cannot just be
linked together in-place, instead they'd have to be passed to
EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() one by one, for copying. The
commands didn't provide dedicated means for identifying individual
tables in blobs. Hence the heuristics built upon ADD_POINTER.

And once you have heuristics, you want to suppress them occasionally, if
you can find a way.

> Can we add and use explicit flag to mark blobs as ACPI tables,
> so that OVMF won't have to guess whether to hand off table
> as ACPI to UEFI stack or just keep it to yourself?

The ADD_POINTER-based heuristics cannot be turned off for ACPI table
identification, because a single fw_cfg blob can (and does) contain
multiple ACPI tables, and OVMF needs to figure out, somehow, where each
of those tables start. Blob-level hints won't help with this.

The following could be an improvement though: a blob-level hint (perhaps
in the ALLOCATE command) that the blob contains *no* ACPI tables. In
this case, OVMF could turn off the table recognition heuristics for
those ADD_POINTER commands that point into such blobs. (Plus mark the
blob for permanent preservation at once, and not only when an
ADD_POINTER "probe" into the blob fails.)

OVMF currently ignores the Zone field in the ALLOCATE command, so that
could be extended / abused for such a hint, without breaking
compatibility with OVMF. (Not sure about SeaBIOS.)

Otherwise, a new allocation command will be necessary. (Which should
embed the current ALLOCATE command structure fully, at some offset.)

Thanks
Laszlo

  parent reply	other threads:[~2017-02-09 19:28 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-05  9:11 [Qemu-devel] [PATCH v5 00/10] Add support for VM Generation ID ben
2017-02-05  9:11 ` [Qemu-devel] [PATCH v5 01/10] ACPI: Add a function for building named qword entries ben
2017-02-07 13:51   ` Igor Mammedov
2017-02-07 20:09     ` Laszlo Ersek
2017-02-08 10:43       ` Igor Mammedov
2017-02-08 10:53         ` Laszlo Ersek
2017-02-08 20:24           ` Ben Warren
2017-02-05  9:11 ` [Qemu-devel] [PATCH v5 02/10] linker-loader: Add new 'write pointer' command ben
2017-02-06 14:56   ` Michael S. Tsirkin
2017-02-06 17:16     ` Ben Warren
2017-02-06 17:31       ` Michael S. Tsirkin
2017-02-07 12:11         ` Igor Mammedov
2017-02-07 20:20           ` Laszlo Ersek
2017-02-05  9:11 ` [Qemu-devel] [PATCH v5 03/10] docs: VM Generation ID device description ben
2017-02-06 20:18   ` Eric Blake
2017-02-07 20:54   ` Laszlo Ersek
2017-02-10  0:55   ` Laszlo Ersek
2017-02-05  9:11 ` [Qemu-devel] [PATCH v5 04/10] ACPI: Add vmgenid storage entries to the build tables ben
2017-02-07 22:06   ` Laszlo Ersek
2017-02-05  9:12 ` [Qemu-devel] [PATCH v5 05/10] ACPI: Add Virtual Machine Generation ID support ben
2017-02-06 16:15   ` Michael S. Tsirkin
2017-02-06 17:29     ` Ben Warren
2017-02-06 17:41       ` Michael S. Tsirkin
2017-02-06 17:59         ` Ben Warren
2017-02-06 18:17           ` Michael S. Tsirkin
2017-02-06 18:48             ` Ben Warren
2017-02-06 19:04               ` Michael S. Tsirkin
2017-02-06 19:44                 ` Ben Warren
2017-02-07 14:00         ` Igor Mammedov
2017-02-07 15:35           ` Michael S. Tsirkin
2017-02-07 16:04             ` Igor Mammedov
2017-02-07 16:22               ` Michael S. Tsirkin
2017-02-07 13:48   ` Igor Mammedov
2017-02-07 15:36     ` Michael S. Tsirkin
2017-02-08 20:19     ` Ben Warren
2017-02-09  9:59       ` Igor Mammedov
2017-02-08  0:48   ` Laszlo Ersek
2017-02-08 11:04     ` Igor Mammedov
2017-02-08 11:17       ` Laszlo Ersek
2017-02-08 12:00         ` Igor Mammedov
2017-02-08 22:34     ` Ben Warren
2017-02-08 23:43       ` Laszlo Ersek
2017-02-09 17:23     ` Igor Mammedov
2017-02-09 18:21       ` Michael S. Tsirkin
2017-02-09 19:27       ` Laszlo Ersek [this message]
2017-02-09 20:02         ` Ben Warren
2017-02-09 20:24           ` Laszlo Ersek
2017-02-09 20:39             ` Ben Warren
2017-02-10  8:54               ` Igor Mammedov
2017-02-09  0:37   ` Laszlo Ersek
2017-02-05  9:12 ` [Qemu-devel] [PATCH v5 06/10] qmp/hmp: add query-vm-generation-id and 'info vm-generation-id' commands ben
2017-02-05  9:12 ` [Qemu-devel] [PATCH v5 07/10] qmp/hmp: add set-vm-generation-id commands ben
2017-02-07 13:50   ` Igor Mammedov
2017-02-08 22:01   ` Laszlo Ersek
2017-02-05  9:12 ` [Qemu-devel] [PATCH v5 08/10] PC: Support dynamic sysbus on pc_i440fx ben
2017-02-06 16:31   ` Michael S. Tsirkin
2017-02-12 19:55     ` Marcel Apfelbaum
2017-02-13  0:32       ` Ben Warren
2017-02-07 14:05   ` Igor Mammedov
2017-02-05  9:12 ` [Qemu-devel] [PATCH v5 09/10] tests: Move reusable ACPI macros into a new header file ben
2017-02-05  9:12 ` [Qemu-devel] [PATCH v5 10/10] tests: Add unit tests for the VM Generation ID feature ben
2017-02-10 10:12 ` [Qemu-devel] [PATCH v5 00/10] Add support for VM Generation ID Laszlo Ersek
2017-02-10 10:28   ` Igor Mammedov
2017-02-10 15:31   ` Michael S. Tsirkin
2017-02-10 16:16     ` Igor Mammedov
2017-02-10 18:18       ` Andrew Jones
2017-02-10 18:27         ` Andreas Färber
2017-02-13 11:00           ` Igor Mammedov
2017-02-13 13:00             ` Michael S. Tsirkin
2017-02-13 13:40               ` Igor Mammedov

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=e23ba6e2-10b6-0cd2-b42c-0a4c66c706d6@redhat.com \
    --to=lersek@redhat.com \
    --cc=ben@skyportsystems.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).