From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Francesco Lavra" <francescolavra.fl@gmail.com>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
kvm@vger.kernel.org, qemu-devel@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Rick Edgecombe" <rick.p.edgecombe@intel.com>
Subject: Re: [PATCH v9 13/55] i386/tdx: Support user configurable mrconfigid/mrowner/mrownerconfig
Date: Thu, 8 May 2025 16:55:09 +0100 [thread overview]
Message-ID: <aBzT3TrdldaN-uqx@redhat.com> (raw)
In-Reply-To: <20250508150002.689633-14-xiaoyao.li@intel.com>
On Thu, May 08, 2025 at 10:59:19AM -0400, Xiaoyao Li wrote:
> From: Isaku Yamahata <isaku.yamahata@intel.com>
>
> Three sha384 hash values, mrconfigid, mrowner and mrownerconfig, of a TD
> can be provided for TDX attestation. Detailed meaning of them can be
> found: https://lore.kernel.org/qemu-devel/31d6dbc1-f453-4cef-ab08-4813f4e0ff92@intel.com/
>
> Allow user to specify those values via property mrconfigid, mrowner and
> mrownerconfig. They are all in base64 format.
>
> example
> -object tdx-guest, \
> mrconfigid=ASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8BI0VniavN7wEjRWeJq83v,\
> mrowner=ASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8BI0VniavN7wEjRWeJq83v,\
> mrownerconfig=ASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8BI0VniavN7wEjRWeJq83v
>
> Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
> Co-developed-by: Xiaoyao Li <xiaoyao.li@intel.com>
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> Acked-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> Changes in v9:
> - return -1 directly when qbase64_decode() return NULL; (Daniel)
>
> Changes in v8:
> - it gets squashed into previous patch in v7. So split it out in v8;
>
> Changes in v6:
> - refine the doc comment of QAPI properties;
>
> Changes in v5:
> - refine the description of QAPI properties and add description of
> default value when not specified;
>
> Changes in v4:
> - describe more of there fields in qom.json
> - free the old value before set new value to avoid memory leak in
> _setter(); (Daniel)
>
> Changes in v3:
> - use base64 encoding instread of hex-string;
> ---
> qapi/qom.json | 16 +++++++-
> target/i386/kvm/tdx.c | 95 +++++++++++++++++++++++++++++++++++++++++++
> target/i386/kvm/tdx.h | 3 ++
> 3 files changed, 113 insertions(+), 1 deletion(-)
>
> diff --git a/qapi/qom.json b/qapi/qom.json
> index f229bb07aaec..a8379bac1719 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -1060,11 +1060,25 @@
> # pages. Some guest OS (e.g., Linux TD guest) may require this to
> # be set, otherwise they refuse to boot.
> #
> +# @mrconfigid: ID for non-owner-defined configuration of the guest TD,
> +# e.g., run-time or OS configuration (base64 encoded SHA384 digest).
> +# Defaults to all zeros.
> +#
> +# @mrowner: ID for the guest TD’s owner (base64 encoded SHA384 digest).
> +# Defaults to all zeros.
> +#
> +# @mrownerconfig: ID for owner-defined configuration of the guest TD,
> +# e.g., specific to the workload rather than the run-time or OS
> +# (base64 encoded SHA384 digest). Defaults to all zeros.
> +#
> # Since: 10.1
> ##
> { 'struct': 'TdxGuestProperties',
> 'data': { '*attributes': 'uint64',
> - '*sept-ve-disable': 'bool' } }
> + '*sept-ve-disable': 'bool',
> + '*mrconfigid': 'str',
> + '*mrowner': 'str',
> + '*mrownerconfig': 'str' } }
>
> ##
> # @ThreadContextProperties:
> diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c
> index 3de3b5fa6a49..39fd964c6b27 100644
> --- a/target/i386/kvm/tdx.c
> +++ b/target/i386/kvm/tdx.c
> @@ -11,8 +11,10 @@
>
> #include "qemu/osdep.h"
> #include "qemu/error-report.h"
> +#include "qemu/base64.h"
> #include "qapi/error.h"
> #include "qom/object_interfaces.h"
> +#include "crypto/hash.h"
>
> #include "hw/i386/x86.h"
> #include "kvm_i386.h"
> @@ -240,6 +242,7 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)
> CPUX86State *env = &x86cpu->env;
> g_autofree struct kvm_tdx_init_vm *init_vm = NULL;
> Error *local_err = NULL;
> + size_t data_len;
> int retry = 10000;
> int r = 0;
>
> @@ -251,6 +254,45 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)
> init_vm = g_malloc0(sizeof(struct kvm_tdx_init_vm) +
> sizeof(struct kvm_cpuid_entry2) * KVM_MAX_CPUID_ENTRIES);
>
> + if (tdx_guest->mrconfigid) {
> + g_autofree uint8_t *data = qbase64_decode(tdx_guest->mrconfigid,
> + strlen(tdx_guest->mrconfigid), &data_len, errp);
> + if (!data) {
> + return -1;
> + }
> + if (data_len != QCRYPTO_HASH_DIGEST_LEN_SHA384) {
> + error_setg(errp, "TDX: failed to decode mrconfigid");
As a general guideline I'd always suggest including both the received
and expected values, when reporting an length check failure. Also
the error message is misleading - we successfully decoded the data,
the decoded data was simply the wrong length.
eg
error_setg(errp, "TDX mrconfigid sha386 digest was %d bytes, expected %d bytes")
data_len, QCRYPTO_HASH_DIGEST_LEN_SHA384);
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2025-05-08 15:55 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-08 14:59 [PATCH v9 00/55] QEMU TDX support Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 01/55] *** HACK *** linux-headers: Update headers to pull in TDX API changes Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 02/55] i386: Introduce tdx-guest object Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 03/55] i386/tdx: Implement tdx_kvm_type() for TDX Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 04/55] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 05/55] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 06/55] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 07/55] kvm: Introduce kvm_arch_pre_create_vcpu() Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 08/55] i386/tdx: Initialize TDX before creating TD vcpus Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 09/55] i386/tdx: Add property sept-ve-disable for tdx-guest object Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 10/55] i386/tdx: Make sept_ve_disable set by default Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 11/55] i386/tdx: Wire CPU features up with attributes of TD guest Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 12/55] i386/tdx: Validate TD attributes Xiaoyao Li
2025-05-08 15:50 ` Daniel P. Berrangé
2025-05-08 14:59 ` [PATCH v9 13/55] i386/tdx: Support user configurable mrconfigid/mrowner/mrownerconfig Xiaoyao Li
2025-05-08 15:55 ` Daniel P. Berrangé [this message]
2025-05-09 6:21 ` Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 14/55] i386/tdx: Set APIC bus rate to match with what TDX module enforces Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 15/55] i386/tdx: Implement user specified tsc frequency Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 16/55] i386/tdx: load TDVF for TD guest Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 17/55] i386/tdvf: Introduce function to parse TDVF metadata Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 18/55] i386/tdx: Parse TDVF metadata for TDX VM Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 19/55] i386/tdx: Don't initialize pc.rom for TDX VMs Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 20/55] i386/tdx: Track mem_ptr for each firmware entry of TDVF Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 21/55] i386/tdx: Track RAM entries for TDX VM Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 22/55] headers: Add definitions from UEFI spec for volumes, resources, etc Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 23/55] i386/tdx: Setup the TD HOB list Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 24/55] i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 25/55] i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 26/55] i386/tdx: Finalize TDX VM Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 27/55] i386/tdx: Enable user exit on KVM_HC_MAP_GPA_RANGE Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 28/55] i386/tdx: Handle KVM_SYSTEM_EVENT_TDX_FATAL Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 29/55] i386/tdx: Wire TDX_REPORT_FATAL_ERROR with GuestPanic facility Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 30/55] kvm: Check KVM_CAP_MAX_VCPUS at vm level Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 31/55] i386/cpu: introduce x86_confidential_guest_cpu_instance_init() Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 32/55] i386/tdx: implement tdx_cpu_instance_init() Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 33/55] i386/cpu: Introduce enable_cpuid_0x1f to force exposing CPUID 0x1f Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 34/55] i386/tdx: Force " Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 35/55] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 36/55] i386/tdx: Disable SMM for TDX VMs Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 37/55] i386/tdx: Disable PIC " Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 38/55] i386/tdx: Set and check kernel_irqchip mode for TDX Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 39/55] i386/tdx: Don't synchronize guest tsc for TDs Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 40/55] i386/tdx: Only configure MSR_IA32_UCODE_REV in kvm_init_msrs() " Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 41/55] i386/apic: Skip kvm_apic_put() for TDX Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 42/55] cpu: Don't set vcpu_dirty when guest_state_protected Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 43/55] i386/cgs: Rename *mask_cpuid_features() to *adjust_cpuid_features() Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 44/55] i386/tdx: Implement adjust_cpuid_features() for TDX Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 45/55] i386/tdx: Add TDX fixed1 bits to supported CPUIDs Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 46/55] i386/tdx: Add supported CPUID bits related to TD Attributes Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 47/55] i386/tdx: Add supported CPUID bits relates to XFAM Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 48/55] i386/tdx: Add XFD to supported bit of TDX Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 49/55] i386/tdx: Define supported KVM features for TDX Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 50/55] i386/cgs: Introduce x86_confidential_guest_check_features() Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 51/55] i386/tdx: Fetch and validate CPUID of TD guest Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 52/55] i386/tdx: Don't treat SYSCALL as unavailable Xiaoyao Li
2025-05-08 14:59 ` [PATCH v9 53/55] i386/tdx: Make invtsc default on Xiaoyao Li
2025-05-08 15:00 ` [PATCH v9 54/55] i386/tdx: Validate phys_bits against host value Xiaoyao Li
2025-05-08 15:00 ` [PATCH v9 55/55] docs: Add TDX documentation Xiaoyao Li
2025-05-26 16:12 ` [PATCH v9 00/55] QEMU TDX support Paolo Bonzini
2025-05-27 1:30 ` Xiaoyao Li
2025-05-27 4:27 ` Markus Armbruster
2025-05-27 7:46 ` Xiaoyao Li
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=aBzT3TrdldaN-uqx@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=francescolavra.fl@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rick.p.edgecombe@intel.com \
--cc=xiaoyao.li@intel.com \
--cc=zhao1.liu@intel.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 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.