TDX: Fix and enhancement
cover TDX: Fix and enhancement
Patch 1 and patch 3 are the left review feedback of TDX QEMU v9 series.
Patch 2 is caught during preparing patch 3.
Xiaoyao Li (3):
i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f i386/tdx: Fix the typo of the comment of struct TdxGuest i386/tdx: Clarify the error message of
mrconfigid/mrowner/mrownerconfig
target/i386/cpu.h | 4 ++-- target/i386/kvm/tdx.c | 14 ++++++++++---- target/i386/kvm/tdx.h | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-)
base-commit: 6322b753f798337835e205b6d805356bea582c86
Signature · 1 line
2.43.0
PATCH 1/3 i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f
The name of "enable_cpuid_0x1f" isn't right to its behavior because the leaf 0x1f can be enabled even when "enable_cpuid_0x1f" is false.
Rename it to "force_cpuid_0x1f" to better reflect its behavior.
---
Suggested by Igor at https://lore.kernel.org/qemu-devel/[email protected]/
--- target/i386/cpu.h | 4 ++-- target/i386/kvm/tdx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
target/i386/cpu.h +2 -2
@@ -2270,7 +2270,7 @@ struct ArchCPU {bool enable_cpuid_0xb;/* Force to enable cpuid 0x1f */ -bool enable_cpuid_0x1f; +bool force_cpuid_0x1f;/* Enable auto level-increase for all CPUID leaves */ bool full_cpuid_auto_level;
@@ -2540,7 +2540,7 @@ void mark_forced_on_features(X86CPU *cpu, FeatureWord w, uint64_t mask,static inline bool x86_has_cpuid_0x1f (X86CPU *cpu) { -return cpu->enable_cpuid_0x1f || +return cpu->force_cpuid_0x1f ||x86_has_extended_topo (cpu->env.avail_cpu_topo); }
target/i386/kvm/tdx.c +1 -1
@@ -746,7 +746,7 @@ static void tdx_cpu_instance_init(X86ConfidentialGuest *cg, CPUState *cpu)/* invtsc is fixed1 for TD guest */ object_property_set_bool (OBJECT (cpu),"invtsc" , true, &error_abort); - x86cpu->enable_cpuid_0x1f = true; + x86cpu->force_cpuid_0x1f = true; } static uint32_t tdx_adjust_cpuid_features(X86ConfidentialGuest *cg,
Signature · 1 line
2.43.0
Re: [PATCH 1/3] i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f
Quoted 5 lines · Xiaoyao Li
The name of "
enable_cpuid_0x1f" isn't right to its behavior because the leaf0x1fcan be enabled even when "enable_cpuid_0x1f" is false.Rename it to "
force_cpuid_0x1f" to better reflect its behavior.
Quoted 8 lines
Suggested-by Igor Mammedov <[email protected]>Signed-off-by Xiaoyao Li <[email protected]>---
Suggested by Igor at https://lore.kernel.org/qemu-devel/[email protected]/--- target/i386/cpu.h | 4 ++-- target/i386/kvm/tdx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: 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 :|
Re: [PATCH 1/3] i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f
In reply to Xiaoyao LiQuoted 7 lines · On Tue, 3 Jun 2025 01:03:03 -0400 Xiaoyao Li <[email protected]> wrote:
The name of "
enable_cpuid_0x1f" isn't right to its behavior because the leaf0x1fcan be enabled even when "enable_cpuid_0x1f" is false.Rename it to "
force_cpuid_0x1f" to better reflect its behavior.Suggested-by Igor Mammedov <[email protected]>Signed-off-by Xiaoyao Li <[email protected]>
Quoted 42 lines
---
Suggested by Igor at https://lore.kernel.org/qemu-devel/[email protected]/--- target/i386/cpu.h | 4 ++-- target/i386/kvm/tdx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)target/i386/cpu.h +2
-2@@ -2270,7 +2270,7 @@ struct ArchCPU {bool enable_cpuid_0xb;/* Force to enable cpuid 0x1f */ -bool enable_cpuid_0x1f; +bool force_cpuid_0x1f;/* Enable auto level-increase for all CPUID leaves */ bool full_cpuid_auto_level;@@ -2540,7 +2540,7 @@ void mark_forced_on_features(X86CPU *cpu, FeatureWord w, uint64_t mask,static inline bool x86_has_cpuid_0x1f (X86CPU *cpu) { -return cpu->enable_cpuid_0x1f || +return cpu->force_cpuid_0x1f ||x86_has_extended_topo (cpu->env.avail_cpu_topo); }target/i386/kvm/tdx.c +1
-1@@ -746,7 +746,7 @@ static void tdx_cpu_instance_init(X86ConfidentialGuest *cg, CPUState *cpu)/* invtsc is fixed1 for TD guest */ object_property_set_bool (OBJECT (cpu),"invtsc" , true, &error_abort); - x86cpu->enable_cpuid_0x1f = true; + x86cpu->force_cpuid_0x1f = true; } static uint32_t tdx_adjust_cpuid_features(X86ConfidentialGuest *cg,
Re: [PATCH 1/3] i386/cpu: Rename enable_cpuid_0x1f to force_cpuid_0x1f
In reply to Xiaoyao LiQuoted 10 lines · Xiaoyao Li
Date: Tue, 3 Jun 2025 01:03:03 -0400
From: Xiaoyao Li <[email protected]>
Subject: [PATCH 1/3] i386/cpu: Renameenable_cpuid_0x1ftoforce_cpuid_0x1f
X-Mailer: git-send-email 2.43.0The name of "
enable_cpuid_0x1f" isn't right to its behavior because the leaf0x1fcan be enabled even when "enable_cpuid_0x1f" is false.Rename it to "
force_cpuid_0x1f" to better reflect its behavior.
Quoted 8 lines
Suggested-by Igor Mammedov <[email protected]>Signed-off-by Xiaoyao Li <[email protected]>---
Suggested by Igor at https://lore.kernel.org/qemu-devel/[email protected]/--- target/i386/cpu.h | 4 ++-- target/i386/kvm/tdx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
PATCH 2/3 i386/tdx: Fix the typo of the comment of struct TdxGuest
In reply to Xiaoyao LiChange sha348 to sha384.
--- target/i386/kvm/tdx.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/i386/kvm/tdx.h +3 -3
@@ -40,9 +40,9 @@ typedef struct TdxGuest {bool initialized;uint64_t attributes;/* TD attributes */ uint64_t xfam; -char *mrconfigid;/* base64 encoded sha348 digest */ -char *mrowner;/* base64 encoded sha348 digest */ -char *mrownerconfig;/* base64 encoded sha348 digest */ +char *mrconfigid;/* base64 encoded sha384 digest */ +char *mrowner;/* base64 encoded sha384 digest */ +char *mrownerconfig;/* base64 encoded sha384 digest */ MemoryRegion *tdvf_mr;TdxFirmware tdvf;
Signature · 1 line
2.43.0
Re: [PATCH 2/3] i386/tdx: Fix the typo of the comment of struct TdxGuest
Quoted 6 lines · Xiaoyao Li
Change sha348 to sha384.
Signed-off-by Xiaoyao Li <[email protected]>--- target/i386/kvm/tdx.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: 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 :|
Re: [PATCH 2/3] i386/tdx: Fix the typo of the comment of struct TdxGuest
In reply to Xiaoyao LiQuoted 3 lines · On Tue, 3 Jun 2025 01:03:04 -0400 Xiaoyao Li <[email protected]> wrote:
Change sha348 to sha384.
Signed-off-by Xiaoyao Li <[email protected]>
Quoted 21 lines
--- target/i386/kvm/tdx.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)target/i386/kvm/tdx.h +3
-3@@ -40,9 +40,9 @@ typedef struct TdxGuest {bool initialized;uint64_t attributes;/* TD attributes */ uint64_t xfam; -char *mrconfigid;/* base64 encoded sha348 digest */ -char *mrowner;/* base64 encoded sha348 digest */ -char *mrownerconfig;/* base64 encoded sha348 digest */ +char *mrconfigid;/* base64 encoded sha384 digest */ +char *mrowner;/* base64 encoded sha384 digest */ +char *mrownerconfig;/* base64 encoded sha384 digest */ MemoryRegion *tdvf_mr;TdxFirmware tdvf;
Re: [PATCH 2/3] i386/tdx: Fix the typo of the comment of struct TdxGuest
In reply to Xiaoyao LiQuoted 6 lines · Xiaoyao Li
Date: Tue, 3 Jun 2025 01:03:04 -0400
From: Xiaoyao Li <[email protected]>
Subject: [PATCH 2/3] i386/tdx: Fix the typo of the comment of struct
TdxGuest
X-Mailer: git-send-email 2.43.0
Quoted 6 lines
Change sha348 to sha384.
Signed-off-by Xiaoyao Li <[email protected]>--- target/i386/kvm/tdx.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
PATCH 3/3 i386/tdx: Clarify the error message of mrconfigid/mrowner/mrownerconfig
In reply to Xiaoyao LiThe error message is misleading - we successfully decoded the data, the decoded data was simply with the wrong length.
Change the error message to show it is an length check failure with both the received and expected values.
---
Suggested by Daniel at https://lore.kernel.org/qemu-devel/[email protected]/
--- target/i386/kvm/tdx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
target/i386/kvm/tdx.c +9 -3
@@ -1026,7 +1026,9 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)return -1 ; }if (data_len !=QCRYPTO_HASH_DIGEST_LEN_SHA384 ) { -error_setg (errp,"TDX: failed to decode mrconfigid" ); +error_setg (errp,"TDX 'mrconfigid' sha384 digest was %ld bytes, " +"expected %d bytes" , data_len, +QCRYPTO_HASH_DIGEST_LEN_SHA384 );return -1 ; }memcpy (init_vm->mrconfigid, data, data_len);
@@ -1039,7 +1041,9 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)return -1 ; }if (data_len !=QCRYPTO_HASH_DIGEST_LEN_SHA384 ) { -error_setg (errp,"TDX: failed to decode mrowner" ); +error_setg (errp,"TDX 'mrowner' sha384 digest was %ld bytes, " +"expected %d bytes" , data_len, +QCRYPTO_HASH_DIGEST_LEN_SHA384 );return -1 ; }memcpy (init_vm->mrowner, data, data_len);
@@ -1052,7 +1056,9 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)return -1 ; }if (data_len !=QCRYPTO_HASH_DIGEST_LEN_SHA384 ) { -error_setg (errp,"TDX: failed to decode mrownerconfig" ); +error_setg (errp,"TDX 'mrownerconfig' sha384 digest was %ld bytes, " +"expected %d bytes" , data_len, +QCRYPTO_HASH_DIGEST_LEN_SHA384 );return -1 ; }memcpy (init_vm->mrownerconfig, data, data_len);
Signature · 1 line
2.43.0
Re: [PATCH 3/3] i386/tdx: Clarify the error message of mrconfigid/mrowner/mrownerconfig
Quoted 6 lines · Xiaoyao Li
The error message is misleading - we successfully decoded the data, the decoded data was simply with the wrong length.
Change the error message to show it is an length check failure with both the received and expected values.
Quoted 7 lines
Suggested-by Daniel P. Berrangé <[email protected]>Signed-off-by Xiaoyao Li <[email protected]>---
Suggested by Daniel at https://lore.kernel.org/qemu-devel/[email protected]/--- target/i386/kvm/tdx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: 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 :|
Re: [PATCH 3/3] i386/tdx: Clarify the error message of mrconfigid/mrowner/mrownerconfig
In reply to Xiaoyao LiQuoted 8 lines · On Tue, 3 Jun 2025 01:03:05 -0400 Xiaoyao Li <[email protected]> wrote:
The error message is misleading - we successfully decoded the data, the decoded data was simply with the wrong length.
Change the error message to show it is an length check failure with both the received and expected values.
Suggested-by Daniel P. Berrangé <[email protected]>Signed-off-by Xiaoyao Li <[email protected]>
Quoted 43 lines
---
Suggested by Daniel at https://lore.kernel.org/qemu-devel/[email protected]/--- target/i386/kvm/tdx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)target/i386/kvm/tdx.c +9
-3@@ -1026,7 +1026,9 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)return -1 ; }if (data_len !=QCRYPTO_HASH_DIGEST_LEN_SHA384 ) { -error_setg (errp,"TDX: failed to decode mrconfigid" ); +error_setg (errp,"TDX 'mrconfigid' sha384 digest was %ld bytes, " +"expected %d bytes" , data_len, +QCRYPTO_HASH_DIGEST_LEN_SHA384 );return -1 ; }memcpy (init_vm->mrconfigid, data, data_len);@@ -1039,7 +1041,9 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)return -1 ; }if (data_len !=QCRYPTO_HASH_DIGEST_LEN_SHA384 ) { -error_setg (errp,"TDX: failed to decode mrowner" ); +error_setg (errp,"TDX 'mrowner' sha384 digest was %ld bytes, " +"expected %d bytes" , data_len, +QCRYPTO_HASH_DIGEST_LEN_SHA384 );return -1 ; }memcpy (init_vm->mrowner, data, data_len);@@ -1052,7 +1056,9 @@ int tdx_pre_create_vcpu(CPUState *cpu, Error **errp)return -1 ; }if (data_len !=QCRYPTO_HASH_DIGEST_LEN_SHA384 ) { -error_setg (errp,"TDX: failed to decode mrownerconfig" ); +error_setg (errp,"TDX 'mrownerconfig' sha384 digest was %ld bytes, " +"expected %d bytes" , data_len, +QCRYPTO_HASH_DIGEST_LEN_SHA384 );return -1 ; }memcpy (init_vm->mrownerconfig, data, data_len);
Re: [PATCH 3/3] i386/tdx: Clarify the error message of mrconfigid/mrowner/mrownerconfig
In reply to Xiaoyao LiQuoted 12 lines · Xiaoyao Li
Date: Tue, 3 Jun 2025 01:03:05 -0400
From: Xiaoyao Li <[email protected]>
Subject: [PATCH 3/3] i386/tdx: Clarify the error message of
mrconfigid/mrowner/mrownerconfig
X-Mailer: git-send-email 2.43.0The error message is misleading - we successfully decoded the data, the decoded data was simply with the wrong length.
Change the error message to show it is an length check failure with both the received and expected values.
Quoted 7 lines
Suggested-by Daniel P. Berrangé <[email protected]>Signed-off-by Xiaoyao Li <[email protected]>---
Suggested by Daniel at https://lore.kernel.org/qemu-devel/[email protected]/--- target/i386/kvm/tdx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Paolo Bonzini
AppliedQueued, thanks.
Paolo