Re: [PATCH 1/3] KVM: Ioctls for init MSI-X entry

Sheng Yang
2009-02-12T06:28:51Z

On Wednesday 11 February 2009 20:44:57 Avi Kivity wrote:
> Sheng Yang wrote:
> > Introduce KVM_SET_MSIX_NR and KVM_SET_MSIX_ENTRY two ioctls.
> >
> > This two ioctls are used by userspace to specific guest device MSI-X
> > entry number and correlate MSI-X entry with GSI during the initialization
> > stage.
> >
> > MSI-X should be well initialzed before enabling.
> >
> > Don't support change MSI-X entry number for now.
> >
> > Signed-off-by: Sheng Yang <sheng@linux.intel.com>
> > ---
> > include/linux/kvm.h | 14 +++++++
> > include/linux/kvm_host.h | 3 +
> > virt/kvm/kvm_main.c | 96
> > ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113
> > insertions(+), 0 deletions(-)
> >
> > diff --git a/include/linux/kvm.h b/include/linux/kvm.h
> > index c1425ab..5200768 100644
> > --- a/include/linux/kvm.h
> > +++ b/include/linux/kvm.h
> > @@ -474,6 +474,8 @@ struct kvm_irq_routing {
> > #define KVM_ASSIGN_IRQ _IOR(KVMIO, 0x70, \
> > struct kvm_assigned_irq)
> > #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71)
> > +#define KVM_SET_MSIX_NR _IOR(KVMIO, 0x72, struct kvm_assigned_msix_nr)
> > +#define KVM_SET_MSIX_ENTRY _IOR(KVMIO, 0x73, struct
> > kvm_assigned_msix_entry)
> >
> > /*
> > * ioctls for vcpu fds
> > @@ -594,4 +596,16 @@ struct kvm_assigned_irq {
> > #define KVM_DEV_IRQ_ASSIGN_MSI_ACTION KVM_DEV_IRQ_ASSIGN_ENABLE_MSI
> > #define KVM_DEV_IRQ_ASSIGN_ENABLE_MSI (1 << 0)
> >
> > +struct kvm_assigned_msix_nr {
> > + __u32 assigned_dev_id;
> > + __u16 entry_nr;
> > +};
> > +
> > +struct kvm_assigned_msix_entry {
> > + __u32 assigned_dev_id;
> > + __u32 gsi;
> > + __u16 entry;
> > + __u16 pos;
> > +}
>
> I'm guessing the intent here is "msi-x number 'pos' on the host assigned
> device will be injected to the guest as gsi 'gsi'"? What's the meaning
> of 'entry' and 'pos'?

Sorry for the ambiguous. "entry" is the index in device MSI-X table(including
empty entry); "pos" is without the empty entry, and should be less than the
total valid entry numbers that table have. "pos" is mostly a assistant here, I
think it can be estimated.
>
> Both structures need better padding and some documentation.

Of course. Would update the patches.

--
regards
Yang, Sheng