From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Dov Murik <dovmurik@linux.ibm.com>, qemu-devel@nongnu.org
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
Ashish Kalra <ashish.kalra@amd.com>,
Brijesh Singh <brijesh.singh@amd.com>,
Eduardo Habkost <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Connor Kuehl <ckuehl@redhat.com>,
James Bottomley <jejb@linux.ibm.com>,
Richard Henderson <richard.henderson@linaro.org>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Tobin Feldman-Fitzthum <tobin@linux.ibm.com>,
Jim Cadden <jcadden@ibm.com>, Paolo Bonzini <pbonzini@redhat.com>,
Laszlo Ersek <lersek@redhat.com>
Subject: Re: [PATCH v2 1/2] sev/i386: Introduce sev_add_kernel_loader_hashes for measured linux boot
Date: Tue, 22 Jun 2021 11:49:04 +0200 [thread overview]
Message-ID: <d983dbc4-1d6b-c51e-aa1f-3d736ac0d154@redhat.com> (raw)
In-Reply-To: <25b381ad-cdca-60dc-6fb1-1d97ea626843@linux.ibm.com>
On 6/22/21 11:44 AM, Dov Murik wrote:
> On 21/06/2021 23:32, Philippe Mathieu-Daudé wrote:
>> and added qemu_uuid_copy() to complete the API, but that's fine.
>
> I think simple C assignment works for structs (and hence QemuUUID),
> something like:
>
> SevHashTable *ht = ...;
> ht->guid = sev_hash_table_header_guid;
>
> (where both ht->guid and sev_hash_table_header_guid are QemuUUID.)
OK.
>>> + if (!pc_system_ovmf_table_find(SEV_HASH_TABLE_RV_GUID, &data, NULL)) {
>>
>> If we never use the data_len argument, can we simplify the prototype?
>
> The current uses for the OVMF reset vector GUIDed table is for simple
> structs with known length (secret injection page address, SEV-ES reset
> address, SEV table of hashes address). But keeping the length there
> allows adding variable-sized entries such as strings/blobs.
OK. Good opportunity to document the prototype declaration ;)
>
>>
>>> + error_setg(errp, "SEV: kernel specified but OVMF has no hash table guid");
>>> + return false;
>>> + }
>>> + area = (SevHashTableDescriptor *)data;
>>> +
>>> + ht = qemu_map_ram_ptr(NULL, area->base);
>>> +
>>> + /* Populate the hashes table header */
>>> + memcpy(ht->guid, sev_hash_table_header_guid, sizeof(ht->guid));
>>> + ht->len = sizeof(*ht);
>>> +
>>> + /* Calculate hash of kernel command-line */
>>> + if (qcrypto_hash_bytes(QCRYPTO_HASH_ALG_SHA256, ctx->cmdline_data,
>>> + ctx->cmdline_size,
>>> + &hash, &hash_len, errp) < 0) {
>>> + return false;
>>> + }
>>
>> Maybe move the qcrypto_hash_bytes() call before filling ht?
>
> (below)
>
>>
>>> + e = &ht->entries[ht_index++];
>>> + fill_sev_hash_table_entry(e, sev_cmdline_entry_guid, hash, hash_len);
>>> +
>>> + /* Calculate hash of initrd */
>>> + if (ctx->initrd_data) {
>>> + if (qcrypto_hash_bytes(QCRYPTO_HASH_ALG_SHA256, ctx->initrd_data,
>>> + ctx->initrd_size, &hash, &hash_len, errp) < 0) {
>>> + return false;
>>> + }
>>
>> Ah, now I see the pattern. Hmm OK then.
>>
>
> But this might change if initrd_hash is no longer optional (see separate
> self-reply to this patch). In such a case I'll probably first calculate
> all the three hashes, and then fill in the SevHashTable struct.
Yes, sounds simpler.
Regards,
Phil.
next prev parent reply other threads:[~2021-06-22 9:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-21 19:05 [PATCH v2 0/2] x86/sev: Measured Linux SEV guest with kernel/initrd/cmdline Dov Murik
2021-06-21 19:05 ` [PATCH v2 1/2] sev/i386: Introduce sev_add_kernel_loader_hashes for measured linux boot Dov Murik
2021-06-21 20:32 ` Philippe Mathieu-Daudé
2021-06-22 9:44 ` Dov Murik
2021-06-22 9:49 ` Philippe Mathieu-Daudé [this message]
2021-06-22 10:26 ` Dov Murik
2021-06-22 11:10 ` Philippe Mathieu-Daudé
2021-06-22 8:28 ` Dov Murik
2021-06-22 21:15 ` Connor Kuehl
2021-06-23 8:41 ` Dov Murik
2021-06-23 8:49 ` Daniel P. Berrangé
2021-06-23 9:28 ` Dov Murik
2021-06-21 19:05 ` [PATCH v2 2/2] x86/sev: generate SEV kernel loader hashes in x86_load_linux Dov Murik
2021-06-22 20:55 ` Connor Kuehl
2021-06-23 6:54 ` Dov Murik
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=d983dbc4-1d6b-c51e-aa1f-3d736ac0d154@redhat.com \
--to=philmd@redhat.com \
--cc=ashish.kalra@amd.com \
--cc=brijesh.singh@amd.com \
--cc=ckuehl@redhat.com \
--cc=dgilbert@redhat.com \
--cc=dovmurik@linux.ibm.com \
--cc=ehabkost@redhat.com \
--cc=jcadden@ibm.com \
--cc=jejb@linux.ibm.com \
--cc=lersek@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thomas.lendacky@amd.com \
--cc=tobin@linux.ibm.com \
/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).