public inbox for linux-coco@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 00/20] x86/tdx: Rewrite TDCALL wrappers
@ 2024-05-17 14:19 Kirill A. Shutemov
  2024-05-17 14:19 ` [PATCH 01/20] x86/tdx: Introduce tdvmcall_trampoline() Kirill A. Shutemov
                   ` (20 more replies)
  0 siblings, 21 replies; 38+ messages in thread
From: Kirill A. Shutemov @ 2024-05-17 14:19 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, Dave Hansen, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin,
	K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
	Josh Poimboeuf, Peter Zijlstra
  Cc: linux-coco, linux-kernel, linux-hyperv, Kirill A. Shutemov

Sean noticing that the TDCALL wrappers were generating a lot of awful
code.

TDCALL calls are centralized into a few megawrappers that take the
struct tdx_module_args as input. Most of the call sites only use a few
arguments, but they have to zero out unused fields in the structure to
avoid data leaks to the VMM. This leads to the compiler generating
inefficient code: dozens of instructions per call site to clear unused
fields of the structure.

This issue can be avoided by using more targeted wrappers.

After the rewrite code size is cut by ~3K:

add/remove: 7/15 grow/shrink: 1/17 up/down: 212/-3502 (-3290)

Please take a look. I would appreciate any feedback.

Kirill A. Shutemov (20):
  x86/tdx: Introduce tdvmcall_trampoline()
  x86/tdx: Add macros to generate TDVMCALL wrappers
  x86/tdx: Convert port I/O handling to use new TDVMCALL macros
  x86/tdx: Convert HLT handling to use new TDVMCALL_0()
  x86/tdx: Convert MSR read handling to use new TDVMCALL_1()
  x86/tdx: Convert MSR write handling to use new TDVMCALL_0()
  x86/tdx: Convert CPUID handling to use new TDVMCALL_4()
  x86/tdx: Convert MMIO handling to use new TDVMCALL macros
  x86/tdx: Convert MAP_GPA hypercall to use new TDVMCALL macros
  x86/tdx: Convert GET_QUOTE hypercall to use new TDVMCALL macros
  x86/tdx: Rewrite tdx_panic() without __tdx_hypercall()
  x86/tdx: Rewrite tdx_kvm_hypercall() without __tdx_hypercall()
  x86/tdx: Rewrite hv_tdx_hypercall() without __tdx_hypercall()
  x86/tdx: Add macros to generate TDCALL wrappers
  x86/tdx: Convert PAGE_ACCEPT tdcall to use new TDCALL_0() macro
  x86/tdx: Convert VP_INFO tdcall to use new TDCALL_5() macro
  x86/tdx: Convert VM_RD/VM_WR tdcalls to use new TDCALL macros
  x86/tdx: Convert VP_VEINFO_GET tdcall to use new TDCALL_5() macro
  x86/tdx: Convert MR_REPORT tdcall to use new TDCALL_0() macro
  x86/tdx: Remove old TDCALL wrappers

 arch/x86/boot/compressed/tdx.c    |  32 +---
 arch/x86/coco/tdx/tdcall.S        | 145 ++++++++++-----
 arch/x86/coco/tdx/tdx-shared.c    |  26 +--
 arch/x86/coco/tdx/tdx.c           | 298 ++++++++----------------------
 arch/x86/hyperv/ivm.c             |  33 +---
 arch/x86/include/asm/shared/tdx.h | 159 +++++++++++-----
 arch/x86/include/asm/tdx.h        |   2 +
 arch/x86/virt/vmx/tdx/tdxcall.S   |  29 +--
 tools/objtool/noreturns.h         |   2 +-
 9 files changed, 322 insertions(+), 404 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2024-05-28  5:33 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-17 14:19 [PATCH 00/20] x86/tdx: Rewrite TDCALL wrappers Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 01/20] x86/tdx: Introduce tdvmcall_trampoline() Kirill A. Shutemov
2024-05-17 15:21   ` Dave Hansen
2024-05-20 10:32     ` Kirill A. Shutemov
2024-05-20 15:49       ` Dave Hansen
2024-05-17 17:02   ` Paolo Bonzini
2024-05-20 10:35     ` Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 02/20] x86/tdx: Add macros to generate TDVMCALL wrappers Kirill A. Shutemov
2024-05-17 16:54   ` Paolo Bonzini
2024-05-20 10:35     ` Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 03/20] x86/tdx: Convert port I/O handling to use new TDVMCALL macros Kirill A. Shutemov
2024-05-17 15:28   ` Dave Hansen
2024-05-17 17:37     ` Paolo Bonzini
2024-05-17 14:19 ` [PATCH 04/20] x86/tdx: Convert HLT handling to use new TDVMCALL_0() Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 05/20] x86/tdx: Convert MSR read handling to use new TDVMCALL_1() Kirill A. Shutemov
2024-05-28  5:33   ` Wei Liu
2024-05-17 14:19 ` [PATCH 06/20] x86/tdx: Convert MSR write handling to use new TDVMCALL_0() Kirill A. Shutemov
2024-05-28  5:33   ` Wei Liu
2024-05-17 14:19 ` [PATCH 07/20] x86/tdx: Convert CPUID handling to use new TDVMCALL_4() Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 08/20] x86/tdx: Convert MMIO handling to use new TDVMCALL macros Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 09/20] x86/tdx: Convert MAP_GPA hypercall " Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 10/20] x86/tdx: Convert GET_QUOTE " Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 11/20] x86/tdx: Rewrite tdx_panic() without __tdx_hypercall() Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 12/20] x86/tdx: Rewrite tdx_kvm_hypercall() " Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 13/20] x86/tdx: Rewrite hv_tdx_hypercall() " Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 14/20] x86/tdx: Add macros to generate TDCALL wrappers Kirill A. Shutemov
2024-05-17 17:04   ` Paolo Bonzini
2024-05-17 14:19 ` [PATCH 15/20] x86/tdx: Convert PAGE_ACCEPT tdcall to use new TDCALL_0() macro Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 16/20] x86/tdx: Convert VP_INFO tdcall to use new TDCALL_5() macro Kirill A. Shutemov
2024-05-17 15:57   ` Dave Hansen
2024-05-20 11:02     ` Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 17/20] x86/tdx: Convert VM_RD/VM_WR tdcalls to use new TDCALL macros Kirill A. Shutemov
2024-05-17 16:07   ` Dave Hansen
2024-05-17 14:19 ` [PATCH 18/20] x86/tdx: Convert VP_VEINFO_GET tdcall to use new TDCALL_5() macro Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 19/20] x86/tdx: Convert MR_REPORT tdcall to use new TDCALL_0() macro Kirill A. Shutemov
2024-05-17 14:19 ` [PATCH 20/20] x86/tdx: Remove old TDCALL wrappers Kirill A. Shutemov
2024-05-17 15:18 ` [PATCH 00/20] x86/tdx: Rewrite " Dave Hansen
2024-05-20 11:56   ` Huang, Kai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox