Skip to content

TDX: Stop metadata auto-generation, improve readability

Xu Yilun kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6x86/virt/tdx: Move bit definitions of TDX_FEATURES0 to public headerarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.h+4 -30 replies
2/6x86/virt/tdx: Move read_sys_metadata_field() to where it is calledarch/x86/include/asm/tdx_global_metadata.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx_global_metadata.c+24 -240 replies
3/6x86/virt/tdx: Refactor metadata reading with a clearer for looparch/x86/virt/vmx/tdx/tdx_global_metadata.c+86 -860 replies
4/6x86/virt/tdx: Sanity check the size of each metadata fieldarch/x86/virt/vmx/tdx/tdx_global_metadata.c+23 -10 replies
5/6x86/virt/tdx: Add generic support for reading array-typed metadataarch/x86/virt/vmx/tdx/tdx_global_metadata.c+44 -550 replies
6/6x86/virt/tdx: Skip unsupported metadata by querying tdx_feature0arch/x86/include/asm/tdx.h arch/x86/include/asm/tdx_global_metadata.h arch/x86/virt/vmx/tdx/tdx_global_metadata.c+27 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/6] TDX: Stop metadata auto-generation, improve readability

Hi:

This addresses the common need [1][2] to stop auto-generating metadata reading code, improve readability, allowing us to manually edit and review metadata code in a comfortable way. TDX Connect needs to add more metadata fields based on this series, and I believe also for DPAMT and TDX Module runtime update.

The main changes derive from previous code & discussions before auto-generation is introduced, including the usage of
struct field_mapping table, the build-time field size check, the concern about awkward "ret = ret ?: " code pattern. [3]

Another concern from DPAMT [4] leads to the last patch and I realize all optional features may face with the same problem - Optional metadata reading should be skipped when a TDX Module doesn't support, don't fail the whole TDX Module initialization. I use "TDX Module Extensions" as the example and test case just because I have the TDX Connect ENV on hand.

This series is based on Dan's tsm#devsec-phase1 [5] (convenient for my testing), but is clean to apply to v6.18-rc7.

[1] https://lore.kernel.org/kvm/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/kvm/[email protected]/
[4] https://lore.kernel.org/kvm/[email protected]/
[5] https://git.kernel.org/pub/scm/linux/kernel/git/devsec/tsm.git/log/?h=devsec-phase1

Xu Yilun (6):
x86/virt/tdx: Move bit definitions of TDX_FEATURES0 to public header x86/virt/tdx: Move read_sys_metadata_field() to where it is called x86/virt/tdx: Refactor metadata reading with a clearer for loop x86/virt/tdx: Sanity check the size of each metadata field x86/virt/tdx: Add generic support for reading array-typed metadata x86/virt/tdx: Skip unsupported metadata by querying tdx_feature0

 arch/x86/include/asm/tdx.h                  |   5 +
 arch/x86/include/asm/tdx_global_metadata.h  |  12 +-
 arch/x86/virt/vmx/tdx/tdx.h                 |   3 -
 arch/x86/virt/vmx/tdx/tdx.c                 |  20 --
 arch/x86/virt/vmx/tdx/tdx_global_metadata.c | 194 ++++++++++++--------
 5 files changed, 134 insertions(+), 100 deletions(-)
Signature · 1 line
2.25.1