On 7/3/23 10:55, kirill.shutemov@xxxxxxxxxxxxxxx wrote: >> I'm thikning we want something along the lines of the Xen preemptible >> hypercalls, except less crazy. Where the caller does: >> >> for (;;) { >> ret = tdcall(fn, args); >> if (ret == -EAGAIN) { >> cond_resched(); >> continue; >> } >> break; >> } >> >> And then the TDX black box provides a guarantee that any one tdcall (or >> seamcall or whatever) never takes more than X ns (possibly even >> configurable) and we get to raise a bug report if we can prove it >> actually takes longer. > TDG.VP.VMCALL TDCALL can take arbitrary amount of time as it handles over > control to the host/VMM. > > But I'm not quite follow how it is different from the host stopping > scheduling vCPU on a random instruction. It can happen at any point and > TDCALL is not special from this PoV. Well, for one, if the host stops the vCPU on a random instruction the host has to restore all the vCPU state. *ALL* of it. That means that after the host hands control back, the guest is perfectly ready to take all the interrupts that are pending. These TDCALLs are *VERY* different. The guest gets control back and has some amount of its state zapped, RBP being the most annoying current example of state that is lost. So the guest resumes control here and must handle all of its interrupts with some of its state (and thus ability to cleanly handle the interrupt) gone. The instructions after state is lost are very much special. Just look at the syscall gap.