Re: [PATCH v8 2/5] x86/tdx: Add TDX Guest event notify interrupt support

From: Kai Huang
Date: Thu Jun 23 2022 - 05:47:16 EST


>
> >
> > That being said, if a TD has multiple devices, it cannot know whether the VMM
> > will inject the removal event via the vector set by SetupEventNotifyInterrupt.
> > And for the same device in the same TD, different VMMs may use different way to
> > notify its removal.
>
> As per current design, If it is used for device removal, I think all registered
> device drivers will get the notification and the individual device driver has
> to check whether it is applicable for them.

The problem is there's no _specification_ around this. As I said above, I don't
see why TDX architecture cannot support Qemu enumerated ACPI-based hotplug,
which uses SCI. Maybe I am missing something here, but IMHO we should have some
_specification_ around SetupEventNotifyInterrupt in GHCI.

>
> If the SetupEventNotifyInterrupt TDVMCALL specification is extended to specify
> the exact device or use case detail, then it can optimize the implementation.
>
> >
> > It seems GetQuote is the only user of SetupEventNotifyInterrupt. Maybe we
> > should just declare it is for GetQuote.
>
> Ok.

If you believe this is reasonable, perhaps you can drive the spec change.

>
> >
> > Isaku, what do you think? Does this make sense?
> >
> > >
> > > In TDX guest, SetupEventNotifyInterrupt hypercall can be used by the
> > > guest to specify which interrupt vector to use as an event-notify
> > > vector to the VMM. Details about the SetupEventNotifyInterrupt
> > > hypercall can be found in TDX Guest-Host Communication Interface
> > > (GHCI) Specification, sec 3.5 "VP.VMCALL<SetupEventNotifyInterrupt>".
> > > Add a tdx_hcall_set_notify_intr() helper function to implement the
> > > SetupEventNotifyInterrupt hypercall.
> >
> > As you also used "can" above, the GHCI only says the VMM _CAN_ inject the vector
> > set by SetupEventNotifyInterrupt, but not must (3.3 TDG.VP.VMCALL<GetQuote>).
> > This means theoretically TD should implement pooling mode in case VMM doesn't
> > support injecting event via vector done by SetupEventNotifyInterrupt?
>
> Yes. But GetQuote specification does not talk about the pooling mode
> use case as well. So I think it is just a wording confusion.

It doesn't need to mention I think. "can" means VMM can choose to inject or
not, but not must, which basically implies GetQuote should support pooling.

>
> >
> > Perhaps we should update the GHCI spec to use must..
>
> Ok.

If you don't want to support pooling, I guess you'd better to improve the GHCI.

[...]

>
>
> > resource especially on server systems with a lot of CPUs.
>
> FWIW, this reservation is protected with CONFIG_INTEL_TDX_GUEST. So it will be
> reserved only for TDX use case.

This reason doesn't stand. I think distributions basically tends to enable all
Kconfig options so one binary works on all machines, so it can be (maybe likely)
turned on even on bare-metal machines.

--
Thanks,
-Kai