On 6/7/23 13:08, Sean Christopherson wrote: >>>>>> The current TDX_MODULE_CALL macro handles neither #GP nor #UD. The >>>>>> kernel would hit Oops if SEAMCALL were mistakenly made w/o enabling VMX >>>>>> first. Architecturally, there is no CPU flag to check whether the CPU >>>>>> is in VMX operation. Also, if a BIOS were buggy, it could still report >>>>>> valid TDX private KeyIDs when TDX actually couldn't be enabled. >>>>> I'm not sure this is a great justification. If the BIOS is lying to the >>>>> OS, we _should_ oops. >>>>> >>>>> How else can this happen other than silly kernel bugs. It's OK to oops >>>>> in the face of silly kernel bugs. >>>> TDX KVM + reboot can hit #UD. On reboot, VMX is disabled (VMXOFF) via >>>> syscore.shutdown callback. However, guest TD can be still running to issue >>>> SEAMCALL resulting in #UD. >>>> >>>> Or we can postpone the change and make the TDX KVM patch series carry a patch >>>> for it. >>> How does the existing KVM use of VMLAUNCH/VMRESUME avoid that problem? >> extable. From arch/x86/kvm/vmx/vmenter.S >> >> .Lvmresume: >> vmresume >> jmp .Lvmfail >> >> .Lvmlaunch: >> vmlaunch >> jmp .Lvmfail >> >> _ASM_EXTABLE(.Lvmresume, .Lfixup) >> _ASM_EXTABLE(.Lvmlaunch, .Lfixup) > More specifically, KVM eats faults on VMX and SVM instructions that occur after > KVM forcefully disables VMX/SVM. <grumble> That's a *TOTALLY* different argument than the patch makes. KVM is being a _bit_ nutty here, but I do respect it trying to honor the "-f". I have no objections to the SEAMCALL code being nutty in the same way. Why do I get the feeling that code is being written without understanding _why_, despite this being v11?