From: "Laszlo Ersek" <lersek@redhat.com>
To: jejb@linux.ibm.com, devel@edk2.groups.io
Cc: dovmurik@linux.vnet.ibm.com, Dov.Murik1@il.ibm.com,
ashish.kalra@amd.com, brijesh.singh@amd.com, tobin@ibm.com,
david.kaplan@amd.com, jon.grimm@amd.com, thomas.lendacky@amd.com,
frankeh@us.ibm.com,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH v2 3/6] OvmfPkg: convert ES Reset Block structure to be guided
Date: Wed, 25 Nov 2020 00:15:15 +0100 [thread overview]
Message-ID: <cc18a03a-06a4-7f30-eea2-6420bf5355ad@redhat.com> (raw)
In-Reply-To: <ac1be33204a45fb53b028ef5e9e285720209316e.camel@linux.ibm.com>
On 11/24/20 20:05, James Bottomley wrote:
> On Mon, 2020-11-23 at 23:16 +0100, Laszlo Ersek wrote:
>> On 11/20/20 19:45, James Bottomley wrote:
>>> diff --git a/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm
>>> b/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm
>>> index 980e0138e7fe..baf9d09f3625 100644
>>> --- a/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm
>>> +++ b/OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm
>>> @@ -25,21 +25,40 @@ ALIGN 16
>>> TIMES (0x1000 - ($ - EndOfPageTables) - 0x20) DB 0
>>> %endif
>>>
>>> +;
>>> +; Padding to ensure first guid starts at 0xffffffd0
>>> +;
>>> +TIMES (32 - ((guidedStructureEnd - guidedStructureStart) % 32)) DB
>>> 0
>>
>> (2) This will insert 32 zero bytes if the size is already aligned to
>> 32
>> bytes (because 32-0 = 32). In other words, the above produces 1 to 32
>> zero bytes, dependent on table size.
>>
>> The variant I proposed in point (5) at
>>
>> https://edk2.groups.io/g/devel/message/67621
>>
>> https://www.redhat.com/archives/edk2-devel-archive/2020-November/msg00781.html
>>
>> takes this into account, and only prepends 0 to 31 bytes (inclusive):
>>
>> TIMES (31 - (guidedStructureEnd - guidedStructureStart + 31) % 32)
>> DB 0
[...]
> I get the mathematics, but I'm a bit hazy on the why. I structured my
> patch on the basis that some zero padding seems necessary (which does
> mean you have to add extra zeros when the structure fits exactly into
> 32 bytes). If we don't need any zero pad at all then I agree with what
> you say above, we should use the shortest feasible pad.
The outermost table footer reports the cumulative size, so a
zero-terminator at the front is not needed.
> My other question is why 32 above? If the object is simply to push the
> table guid to 0xffffffd0 in the OVMF.fd then
>
> TIMES (15 - ((guidedStructureEnd - guidedStructureStart + 15) % 16)) DB 0
>
> or
>
> TIMES 16 - ((guidedStructureEnd - guidedStructureStart) % 16)) DB 0
>
> Depending on whether we need zeros or not, always works because the
> code is align 16 not align 32.
Right, I think you are correct.
>> (4) can we make the whole table size field 32-bit? I don't have a
>> particular use case in mind, it just looks more extensible than 16-
>> bit. We can still keep the individual structs we have in mind 16-bit
>> sized.
>
> Actually, no ... or at least not unless we alter the reset vector. The
> problem is the reset vector is actually:
>
> nop
> nop
> jmp EarlyBspInitReal16
>
> But that jmp is 16-bit code, meaning the relative jump which goes over
> the table is at most -32768, so the table can never be larger than
> about 32k bytes.
Great catch! :)
>> (7) suggest "run off the beginning of the table"
>>
>> ... I realize "start" and "end" can be interpreted temporally and
>> spatially. In a forward traversal they are the same, but now they
>> aren't. I suggest we use the spatial (address space order)
>> interpretation.
>
> Well we have to be consistent, so if you're thinking backwards it's
> header and end, but the other way around it has to be footer and
> beginning, so I updated it.
OK, thanks. I guess I should be OK with either interpretation, as long
as we'll have considered it from a consistency perspective.
>> (9) The 16-bit size field of the SEV-ES reset block structure is not
>> documented.
>
> Well, it is ... it's become part of the table structure, so it's
> documented at the top of the table as:
>
> ; The table is composed of structures with the form:
> ;
> ; Data (arbitrary bytes identified by guid)
> ; length from start of data to end of guid (2 bytes)
> ; guid (16 bytes)
>
> All the comment is doing is describing the layout of the data.
>
> I can add a length here if you like, but I'd probably better add one to
> the secret table as well to be consistent.
Ahh wait, no, now I understand it.
When I wrote my previous comment, I didn't understand why you listed all
of the fields explicitly, *except* the size. In particular, why you
listed the GUID (*unlike* the size), in spite of the GUID *too* being
pre-declared (*like* the size).
But now I understand -- you didn't re-declare the GUID *field* for this
particular GUIDed structure, you only provided the *value* of the GUID
field.
Perhaps juggling the words could improve understanding:
GUID ("SEV-ES reset block"): 00f771de-1a7e-4fcb-890e-68c77e2fb44e
But, it's up to you. I agree the listing is consistent the way you proposed.
Thanks!
Laszlo
next prev parent reply other threads:[~2020-11-24 23:15 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 18:45 [PATCH v2 0/6] SEV Encrypted Boot for Ovmf James Bottomley
2020-11-20 18:45 ` [PATCH v2 1/6] OvmfPkg/Amdsev: Base commit to build encrypted boot specific OVMF James Bottomley
2020-11-23 18:01 ` Laszlo Ersek
2020-11-23 23:25 ` James Bottomley
2020-11-23 23:43 ` Laszlo Ersek
2020-11-20 18:45 ` [PATCH v2 2/6] OvmfPkg/AmdSev: add Grub Firmware Volume Package James Bottomley
2020-11-23 21:08 ` Laszlo Ersek
2020-11-24 6:38 ` James Bottomley
2020-11-24 8:23 ` Laszlo Ersek
2020-11-24 14:54 ` Laszlo Ersek
2020-11-24 15:58 ` Laszlo Ersek
2020-11-24 16:22 ` [edk2-devel] " James Bottomley
2020-11-24 23:22 ` Laszlo Ersek
2020-11-24 23:42 ` James Bottomley
2020-11-25 1:27 ` James Bottomley
2020-11-25 14:01 ` Laszlo Ersek
2020-11-25 16:02 ` James Bottomley
2020-11-25 17:09 ` James Bottomley
2020-11-25 18:17 ` James Bottomley
2020-11-25 19:20 ` Laszlo Ersek
2020-11-25 20:11 ` James Bottomley
2020-11-25 18:35 ` Laszlo Ersek
2020-11-25 19:08 ` Laszlo Ersek
2020-11-25 19:14 ` Laszlo Ersek
2020-11-20 18:45 ` [PATCH v2 3/6] OvmfPkg: convert ES Reset Block structure to be guided James Bottomley
2020-11-23 22:16 ` Laszlo Ersek
2020-11-24 14:57 ` Lendacky, Thomas
2020-11-24 19:07 ` James Bottomley
2020-11-24 23:19 ` Laszlo Ersek
2020-11-24 19:05 ` James Bottomley
2020-11-24 23:15 ` Laszlo Ersek [this message]
2020-11-20 18:45 ` [PATCH v2 4/6] OvmfPkg: create a SEV secret area in the AmdSev memfd James Bottomley
2020-11-23 22:28 ` Laszlo Ersek
2020-11-20 18:45 ` [PATCH v2 5/6] OvmfPkg/AmdSev: assign and protect the Sev Secret area James Bottomley
2020-11-23 22:38 ` Laszlo Ersek
2020-11-20 18:45 ` [PATCH v2 6/6] OvmfPkg/AmdSev: Expose the Sev Secret area using a configuration table James Bottomley
2020-11-23 22:56 ` Laszlo Ersek
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-list 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=cc18a03a-06a4-7f30-eea2-6420bf5355ad@redhat.com \
--to=devel@edk2.groups.io \
/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