[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [Qemu-devel] [RFC v4 10/16] virtio-iommu: Implement probe
From: |
Auger Eric |
Subject: |
Re: [Qemu-arm] [Qemu-devel] [RFC v4 10/16] virtio-iommu: Implement probe request |
Date: |
Wed, 27 Sep 2017 17:40:43 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
Hi Tomasz,
On 27/09/2017 12:53, Tomasz Nowicki wrote:
> Hi Eric,
>
> On 19.09.2017 09:46, Eric Auger wrote:
>> This patch implements the PROBE request. At the moment,
>> no reserved regions are returned.
>>
>> At the moment reserved regions are stored per device.
>>
>> Signed-off-by: Eric Auger <address@hidden>
>>
>> ---
>>
>
> [...]
>
>> +
>> +static int virtio_iommu_fill_property(int devid, int type,
>> + viommu_property_buffer *bufstate)
>> +{
>> + int ret = -ENOSPC;
>> +
>> + if (bufstate->filled + 4 >= VIOMMU_PROBE_SIZE) {
>> + bufstate->error = true;
>> + goto out;
>> + }
>> +
>> + switch (type) {
>> + case VIRTIO_IOMMU_PROBE_T_NONE:
>> + ret = virtio_iommu_fill_none_prop(bufstate);
>> + break;
>> + case VIRTIO_IOMMU_PROBE_T_RESV_MEM:
>> + {
>> + viommu_dev *dev = bufstate->dev;
>> +
>> + g_tree_foreach(dev->reserved_regions,
>> + virtio_iommu_fill_resv_mem_prop,
>> + bufstate);
>> + if (!bufstate->error) {
>> + ret = 0;
>> + }
>> + break;
>> + }
>> + default:
>> + ret = -ENOENT;
>> + break;
>> + }
>> +out:
>> + if (ret) {
>> + error_report("%s property of type=%d could not be filled (%d),"
>> + " remaining size = 0x%lx",
>> + __func__, type, ret, bufstate->filled);
>> + }
>> + return ret;
>> +}
>> +
>> +static int virtio_iommu_probe(VirtIOIOMMU *s,
>> + struct virtio_iommu_req_probe *req,
>> + uint8_t *buf)
>> +{
>> + uint32_t devid = le32_to_cpu(req->device);
>> + int16_t prop_types = SUPPORTED_PROBE_PROPERTIES, type;
>> + viommu_property_buffer bufstate;
>> + viommu_dev *dev;
>> + int ret;
>> +
>> + dev = g_tree_lookup(s->devices, GUINT_TO_POINTER(devid));
>> + if (!dev) {
>> + return -EINVAL;
>> + }
>> +
>> + bufstate.start = buf;
>> + bufstate.filled = 0;
>> + bufstate.dev = dev;
>
> bufstate.error is not initialized which may cause false alarm in
> virtio_iommu_fill_property()
thanks for spotting that. I owe you several fixes in both vsmmuv3 and
virtio-iommu. Thank you for testing, again!
Best Regards
Eric
>
>> +
>> + while ((type = ctz32(prop_types)) != 32) {
>> + ret = virtio_iommu_fill_property(devid, 1 << type, &bufstate);
>> + if (ret) {
>> + break;
>> + }
>> + prop_types &= ~(1 << type);
>> + }
>> + virtio_iommu_fill_property(devid, VIRTIO_IOMMU_PROBE_T_NONE,
>> &bufstate);
>> +
>> + return VIRTIO_IOMMU_S_OK;
>> +}
>> +
>> #define get_payload_size(req) (\
>> sizeof((req)) - sizeof(struct virtio_iommu_req_tail))
>> @@ -433,6 +567,24 @@ static int
>> virtio_iommu_handle_unmap(VirtIOIOMMU *s,
>> return virtio_iommu_unmap(s, &req);
>> }
>
> Thanks,
> Tomasz
>
- [Qemu-arm] [RFC v4 06/16] virtio-iommu: Register attached devices, (continued)
- [Qemu-arm] [RFC v4 06/16] virtio-iommu: Register attached devices, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 07/16] virtio-iommu: Implement attach/detach command, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 08/16] virtio-iommu: Implement map/unmap, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 09/16] virtio-iommu: Implement translate, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 10/16] virtio-iommu: Implement probe request, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 11/16] hw/arm/virt: Add 2.11 machine type, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 12/16] hw/arm/virt: Add virtio-iommu to the virt board, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 13/16] memory.h: Add set_page_size_mask IOMMUMemoryRegion callback, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 15/16] virtio-iommu: Implement set_page_size_mask, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 14/16] hw/vfio/common: Set the IOMMUMemoryRegion supported page sizes, Eric Auger, 2017/09/19
- [Qemu-arm] [RFC v4 16/16] hw/vfio/common: Do not print error when viommu translates into an mmio region, Eric Auger, 2017/09/19
- Re: [Qemu-arm] [RFC v4 00/16] VIRTIO-IOMMU device, Tomasz Nowicki, 2017/09/27