Re: [PATCH v19 078/130] KVM: TDX: Implement TDX vcpu enter/exit path

From: Binbin Wu
Date: Sat Apr 06 2024 - 21:42:41 EST




On 3/16/2024 1:26 AM, Sean Christopherson wrote:
On Mon, Feb 26, 2024, isaku.yamahata@xxxxxxxxx wrote:
+ */
+ struct kvm_vcpu *vcpu = &tdx->vcpu;
+
+ guest_state_enter_irqoff();
+
+ /*
+ * TODO: optimization:
+ * - Eliminate copy between args and vcpu->arch.regs.
+ * - copyin/copyout registers only if (tdx->tdvmvall.regs_mask != 0)
+ * which means TDG.VP.VMCALL.
+ */
+ args = (struct tdx_module_args) {
+ .rcx = tdx->tdvpr_pa,
+#define REG(reg, REG) .reg = vcpu->arch.regs[VCPU_REGS_ ## REG]
Organizing tdx_module_args's registers by volatile vs. non-volatile is asinine.
This code should not need to exist.

Did you suggest to align the tdx_module_args with enum kvm_reg for GP registers, so it can be done by a simple mem copy?


+ WARN_ON_ONCE(!kvm_rebooting &&
+ (tdx->exit_reason.full & TDX_SW_ERROR) == TDX_SW_ERROR);
+
+ guest_state_exit_irqoff();
+}
+