xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Wang <wei.wang2@amd.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: keir@xen.org, xen-devel@lists.xensource.com,
	Ian.Jackson@eu.citrix.com, Ian.Campbell@citrix.com
Subject: Re: [PATCH 1 of 6 V5] amd iommu: Add 2 hypercalls for libxc
Date: Fri, 10 Feb 2012 16:42:10 +0100	[thread overview]
Message-ID: <4F353AD2.7030705@amd.com> (raw)
In-Reply-To: <4F3545E8020000780007261B@nat28.tlf.novell.com>

On 02/10/2012 04:29 PM, Jan Beulich wrote:
>>>> On 10.02.12 at 16:07, Wei Wang<wei.wang2@amd.com>  wrote:
>> @@ -916,3 +933,45 @@ const struct hvm_mmio_handler iommu_mmio
>>       .read_handler = guest_iommu_mmio_read,
>>       .write_handler = guest_iommu_mmio_write
>>   };
>> +
>> +/* iommu hypercall handler */
>> +int iommu_bind_bdf(struct domain* d, uint16_t gseg, uint16_t gbdf,
>> +                   uint16_t mseg, uint16_t mbdf)
>> +{
>> +    struct pci_dev *pdev;
>> +    int ret = -ENODEV;
>> +
>> +    if ( !iommu_found() || !iommu_enabled || !iommuv2_enabled )
>> +        return ret;
>> +
>> +    spin_lock(&pcidevs_lock);
>> +
>> +    for_each_pdev( d, pdev )
>> +    {
>> +        if ( (pdev->seg != mseg) || (pdev->bus != PCI_BUS(mbdf) ) ||
>> +             (pdev->devfn != PCI_DEVFN2(mbdf)) )
>> +            continue;
>> +
>> +        pdev->gseg = gseg;
>> +        pdev->gbdf = gbdf;
>> +        ret = 0;
>> +    }
>> +
>> +    spin_unlock(&pcidevs_lock);
>> +    return ret;
>> +}
>> +
>> +void iommu_set_msi(struct domain* d, uint16_t vector, uint16_t dest,
>> +                   uint16_t dest_mode, uint16_t delivery_mode,
>> +                   uint16_t trig_mode)
>
> Why are these all uint16_t?

uint8_t might better... I will change it.

>
>> +{
>> +    struct guest_iommu *iommu = domain_iommu(d);
>> +
>> +    if ( !iommu )
>> +        return;
>> +
>> +    iommu->msi.vector = vector;
>> +    iommu->msi.dest = dest;
>> +    iommu->msi.dest_mode = dest_mode;
>> +    iommu->msi.trig_mode = trig_mode;
>> +}
>> diff -r 593deed8f62d -r 9cf24ad61936 xen/drivers/passthrough/iommu.c
>> --- a/xen/drivers/passthrough/iommu.c	Thu Feb 09 06:09:17 2012 -0800
>> +++ b/xen/drivers/passthrough/iommu.c	Fri Feb 10 15:49:09 2012 +0100
>> @@ -648,6 +648,40 @@ int iommu_do_domctl(
>>           put_domain(d);
>>           break;
>>
>> +    case XEN_DOMCTL_guest_iommu_op:
>> +    {
>> +        xen_domctl_guest_iommu_op_t * guest_op;
>> +
>> +        if ( unlikely((d = get_domain_by_id(domctl->domain)) == NULL) )
>> +        {
>> +            gdprintk(XENLOG_ERR,
>> +                    "XEN_DOMCTL_guest_iommu_op: get_domain_by_id()
>> failed\n");
>> +            ret = -EINVAL;
>> +            break;
>> +        }
>> +
>> +        guest_op =&(domctl->u.guest_iommu_op);
>> +        switch ( guest_op->op )
>> +        {
>> +            case XEN_DOMCTL_GUEST_IOMMU_OP_SET_MSI:
>
> Indentation.
can be fixed.

Thanks,
Wei
>
>> +                iommu_set_msi(d, guest_op->u.msi.vector,
>> +                              guest_op->u.msi.dest,
>> +                              guest_op->u.msi.dest_mode,
>> +                              guest_op->u.msi.delivery_mode,
>> +                              guest_op->u.msi.trig_mode);
>> +                ret = 0;
>> +                break;
>> +            case XEN_DOMCTL_GUEST_IOMMU_OP_BIND_BDF:
>> +                ret = iommu_bind_bdf(d, guest_op->u.bdf_bind.g_seg,
>> +                                     guest_op->u.bdf_bind.g_bdf,
>> +                                     guest_op->u.bdf_bind.m_seg,
>> +                                     guest_op->u.bdf_bind.m_bdf);
>> +                break;
>> +        }
>> +        put_domain(d);
>> +        break;
>> +    }
>> +
>>       default:
>>           ret = -ENOSYS;
>>           break;
>> diff -r 593deed8f62d -r 9cf24ad61936 xen/include/public/domctl.h
>> --- a/xen/include/public/domctl.h	Thu Feb 09 06:09:17 2012 -0800
>> +++ b/xen/include/public/domctl.h	Fri Feb 10 15:49:09 2012 +0100
>> @@ -871,6 +871,31 @@ struct xen_domctl_set_access_required {
>>   typedef struct xen_domctl_set_access_required
>> xen_domctl_set_access_required_t;
>>   DEFINE_XEN_GUEST_HANDLE(xen_domctl_set_access_required_t);
>>
>> +/* Support for guest iommu emulation */
>> +struct xen_domctl_guest_iommu_op {
>> +    /* XEN_DOMCTL_GUEST_IOMMU_OP_* */
>> +#define XEN_DOMCTL_GUEST_IOMMU_OP_SET_MSI               0
>> +#define XEN_DOMCTL_GUEST_IOMMU_OP_BIND_BDF              1
>> +    uint8_t op;
>> +    union {
>> +        struct iommu_msi {
>> +        uint8_t  vector;
>> +        uint8_t  dest;
>> +        uint8_t  dest_mode;
>> +        uint8_t  delivery_mode;
>> +        uint8_t  trig_mode;
>
> Indentation again.
>
> Jan
>
>> +        } msi;
>> +        struct bdf_bind {
>> +            uint16_t            g_seg;
>> +            uint16_t            g_bdf;
>> +            uint16_t            m_seg;
>> +            uint16_t            m_bdf;
>> +        } bdf_bind;
>> +    } u;
>> +};
>> +typedef struct xen_domctl_guest_iommu_op xen_domctl_guest_iommu_op_t;
>> +DEFINE_XEN_GUEST_HANDLE(xen_domctl_guest_iommu_op_t);
>> +
>>   struct xen_domctl {
>>       uint32_t cmd;
>>   #define XEN_DOMCTL_createdomain                   1
>
>

  reply	other threads:[~2012-02-10 15:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-10 15:07 [PATCH 0 of 6 V5] amd iommu: support ats/gpgpu passthru on iommuv2 systems Wei Wang
2012-02-10 15:07 ` [PATCH 1 of 6 V5] amd iommu: Add 2 hypercalls for libxc Wei Wang
2012-02-10 15:29   ` Jan Beulich
2012-02-10 15:42     ` Wei Wang [this message]
2012-02-10 15:07 ` [PATCH 2 of 6 V5] amd iommu: Add a hypercall for hvmloader Wei Wang
2012-02-10 15:07 ` [PATCH 3 of 6 V5] hvmloader: Build IVRS table Wei Wang
2012-02-10 15:07 ` [PATCH 4 of 6 V5] libxc: add wrappers for new hypercalls Wei Wang
2012-02-10 15:07 ` [PATCH 5 of 6 V5] libxl: bind virtual bdf to physical bdf after device assignment Wei Wang
2012-02-10 15:07 ` [PATCH 6 of 6 V5] libxl: Introduce a new guest config file parameter Wei Wang
2012-02-13 16:54 ` [PATCH 0 of 6 V5] amd iommu: support ats/gpgpu passthru on iommuv2 systems Ian Jackson
2012-02-15  9:49   ` Wei Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F353AD2.7030705@amd.com \
    --to=wei.wang2@amd.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).