lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 26 Feb 2020 14:12:26 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Jason Gunthorpe <jgg@...lanox.com>
Cc:     "mst@...hat.com" <mst@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "virtualization@...ts.linux-foundation.org" 
        <virtualization@...ts.linux-foundation.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "tiwei.bie@...el.com" <tiwei.bie@...el.com>,
        "maxime.coquelin@...hat.com" <maxime.coquelin@...hat.com>,
        "cunming.liang@...el.com" <cunming.liang@...el.com>,
        "zhihong.wang@...el.com" <zhihong.wang@...el.com>,
        "rob.miller@...adcom.com" <rob.miller@...adcom.com>,
        "xiao.w.wang@...el.com" <xiao.w.wang@...el.com>,
        "haotian.wang@...ive.com" <haotian.wang@...ive.com>,
        "lingshan.zhu@...el.com" <lingshan.zhu@...el.com>,
        "eperezma@...hat.com" <eperezma@...hat.com>,
        "lulu@...hat.com" <lulu@...hat.com>,
        Parav Pandit <parav@...lanox.com>,
        "kevin.tian@...el.com" <kevin.tian@...el.com>,
        "stefanha@...hat.com" <stefanha@...hat.com>,
        "rdunlap@...radead.org" <rdunlap@...radead.org>,
        "hch@...radead.org" <hch@...radead.org>,
        "aadam@...hat.com" <aadam@...hat.com>,
        Jiri Pirko <jiri@...lanox.com>,
        Shahaf Shuler <shahafs@...lanox.com>,
        "hanand@...inx.com" <hanand@...inx.com>,
        "mhabets@...arflare.com" <mhabets@...arflare.com>
Subject: Re: [PATCH V4 5/5] vdpasim: vDPA device simulator


On 2020/2/21 下午3:57, Jason Wang wrote:
>
> On 2020/2/20 下午11:12, Jason Gunthorpe wrote:
>> On Thu, Feb 20, 2020 at 02:11:41PM +0800, Jason Wang wrote:
>>> +static void vdpasim_device_release(struct device *dev)
>>> +{
>>> +    struct vdpasim *vdpasim = dev_to_sim(dev);
>>> +
>>> +    cancel_work_sync(&vdpasim->work);
>>> +    kfree(vdpasim->buffer);
>>> +    vhost_iotlb_free(vdpasim->iommu);
>>> +    kfree(vdpasim);
>>> +}
>>> +
>>> +static struct vdpasim *vdpasim_create(void)
>>> +{
>>> +    struct virtio_net_config *config;
>>> +    struct vhost_iotlb *iommu;
>>> +    struct vdpasim *vdpasim;
>>> +    struct device *dev;
>>> +    void *buffer;
>>> +    int ret = -ENOMEM;
>>> +
>>> +    iommu = vhost_iotlb_alloc(2048, 0);
>>> +    if (!iommu)
>>> +        goto err;
>>> +
>>> +    buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
>>> +    if (!buffer)
>>> +        goto err_buffer;
>>> +
>>> +    vdpasim = kzalloc(sizeof(*vdpasim), GFP_KERNEL);
>>> +    if (!vdpasim)
>>> +        goto err_alloc;
>>> +
>>> +    vdpasim->buffer = buffer;
>>> +    vdpasim->iommu = iommu;
>>> +
>>> +    config = &vdpasim->config;
>>> +    config->mtu = 1500;
>>> +    config->status = VIRTIO_NET_S_LINK_UP;
>>> +    eth_random_addr(config->mac);
>>> +
>>> +    INIT_WORK(&vdpasim->work, vdpasim_work);
>>> +    spin_lock_init(&vdpasim->lock);
>>> +
>>> +    vringh_set_iotlb(&vdpasim->vqs[0].vring, vdpasim->iommu);
>>> +    vringh_set_iotlb(&vdpasim->vqs[1].vring, vdpasim->iommu);
>>> +
>>> +    dev = &vdpasim->dev;
>>> +    dev->release = vdpasim_device_release;
>>> +    dev->coherent_dma_mask = DMA_BIT_MASK(64);
>>> +    set_dma_ops(dev, &vdpasim_dma_ops);
>>> +    dev_set_name(dev, "%s", VDPASIM_NAME);
>>> +
>>> +    ret = device_register(&vdpasim->dev);
>>> +    if (ret)
>>> +        goto err_init;
>> It is a bit weird to be creating this dummy parent, couldn't this be
>> done by just passing a NULL parent to vdpa_alloc_device, doing
>> set_dma_ops() on the vdpasim->vdpa->dev and setting dma_device to
>> vdpasim->vdpa->dev ?
>
>
> I think it works.


Rethink about this, since most hardware vDPA driver will have a parent 
and will use it to find the parent structure e.g

dev_get_drvdata(vdpa->dev->parent)

So I keep this dummy parent in V5.

Thanks


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ