All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
To: Auger Eric <eric.auger@redhat.com>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"devel@acpica.org" <devel@acpica.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	"virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"virtio-dev@lists.oasis-open.org"
	<virtio-dev@lists.oasis-open.org>
Cc: "Jayachandran.Nair@cavium.com" <Jayachandran.Nair@cavium.com>,
	Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
	"ashok.raj@intel.com" <ashok.raj@intel.com>,
	"mst@redhat.com" <mst@redhat.com>,
	Marc Zyngier <Marc.Zyngier@arm.com>,
	Will Deacon <Will.Deacon@arm.com>,
	"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
	"robert.moore@intel.com" <robert.moore@intel.com>,
	"lv.zheng@intel.com" <lv.zheng@intel.com>,
	Sudeep Holla <Sudeep.Holla@arm.com>,
	"lenb@kernel.org" <lenb@kernel.org>,
	Robin Murphy <Robin.Murphy@arm.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"hanjun.guo@linaro.org" <hanjun.guo@linaro.org>
Subject: Re: [RFC PATCH v2 2/5] iommu/virtio-iommu: Add probe request
Date: Tue, 16 Jan 2018 17:46:40 +0000	[thread overview]
Message-ID: <5dbd05b0-aeb2-dcd5-f134-692957db0b39__40023.9239134409$1516124553$gmane$org@arm.com> (raw)
In-Reply-To: <d4640ecc-8029-413b-1485-a6062c3b8ece@redhat.com>

On 16/01/18 09:25, Auger Eric wrote:
[...]
>> +static int viommu_add_resv_mem(struct viommu_endpoint *vdev,
>> +			       struct virtio_iommu_probe_resv_mem *mem,
>> +			       size_t len)
>> +{
>> +	struct iommu_resv_region *region = NULL;
>> +	unsigned long prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO;
>> +
>> +	u64 addr = le64_to_cpu(mem->addr);
>> +	u64 size = le64_to_cpu(mem->size);
>> +
>> +	if (len < sizeof(*mem))
>> +		return -EINVAL;
>> +
>> +	switch (mem->subtype) {
>> +	case VIRTIO_IOMMU_RESV_MEM_T_MSI:
>> +		region = iommu_alloc_resv_region(addr, size, prot,
>> +						 IOMMU_RESV_MSI);
>> +		break;
>> +	case VIRTIO_IOMMU_RESV_MEM_T_RESERVED:
>> +	default:
>> +		region = iommu_alloc_resv_region(addr, size, 0,
>> +						 IOMMU_RESV_RESERVED);
>> +		break;
>> +	}
>> +
>> +	list_add(&vdev->resv_regions, &region->list);
>> +
>> +	if (mem->subtype != VIRTIO_IOMMU_RESV_MEM_T_RESERVED &&
>> +	    mem->subtype != VIRTIO_IOMMU_RESV_MEM_T_MSI) {
>> +		/* Please update your driver. */
>> +		pr_warn("unknown resv mem subtype 0x%x\n", mem->subtype);
>> +		return -EINVAL;
>> +	}
> why not adding this in the switch default case and do not call list_add
> in case the subtype region is not recognized?

Even if the subtype isn't recognized, I think the range should still be
reserved, so that the guest kernel doesn't map it and break something.
That's why I put the following in the spec, 2.6.8.2.1 Driver
Requirements: Property RESV_MEM:

"""
The driver SHOULD treat any subtype it doesn’t recognize as if it was
VIRTIO_IOMMU_RESV_MEM_T_RESERVED.
"""

>> +
>> +	return 0;
>> +}
>> +
>> +static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev)
>> +{
>> +	int ret;
>> +	u16 type, len;
>> +	size_t cur = 0;
>> +	struct virtio_iommu_req_probe *probe;
>> +	struct virtio_iommu_probe_property *prop;
>> +	struct iommu_fwspec *fwspec = dev->iommu_fwspec;
>> +	struct viommu_endpoint *vdev = fwspec->iommu_priv;
>> +
>> +	if (!fwspec->num_ids)
>> +		/* Trouble ahead. */
>> +		return -EINVAL;
>> +
>> +	probe = kzalloc(sizeof(*probe) + viommu->probe_size +
>> +			sizeof(struct virtio_iommu_req_tail), GFP_KERNEL);
>> +	if (!probe)
>> +		return -ENOMEM;
>> +
>> +	probe->head.type = VIRTIO_IOMMU_T_PROBE;
>> +	/*
>> +	 * For now, assume that properties of an endpoint that outputs multiple
>> +	 * IDs are consistent. Only probe the first one.
>> +	 */
>> +	probe->endpoint = cpu_to_le32(fwspec->ids[0]);
>> +
>> +	ret = viommu_send_req_sync(viommu, probe);
>> +	if (ret) {
> goto out?

Ok

[...]
>> +
>> +	iommu_dma_get_resv_regions(dev, head);
> this change may belong to the 1st patch.

Indeed

Thanks,
Jean
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2018-01-16 17:46 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 18:52 [RFC PATCH v2 0/5] Add virtio-iommu driver Jean-Philippe Brucker
2017-11-17 18:52 ` [virtio-dev] " Jean-Philippe Brucker
2017-11-17 18:52 ` [RFC PATCH v2 1/5] iommu: " Jean-Philippe Brucker
2017-11-17 18:52   ` [virtio-dev] " Jean-Philippe Brucker
2017-11-29 15:17   ` Jean-Philippe Brucker
2017-11-29 15:17   ` Jean-Philippe Brucker
2017-11-29 15:17     ` Jean-Philippe Brucker
2018-01-15 15:12   ` Auger Eric
2018-01-15 15:12     ` [virtio-dev] " Auger Eric
2018-01-16 17:45     ` Jean-Philippe Brucker
2018-01-16 17:45     ` Jean-Philippe Brucker
2018-01-16 17:45       ` [virtio-dev] " Jean-Philippe Brucker
2018-01-15 15:12   ` Auger Eric
2017-11-17 18:52 ` Jean-Philippe Brucker
2017-11-17 18:52 ` [RFC PATCH v2 2/5] iommu/virtio-iommu: Add probe request Jean-Philippe Brucker
2017-11-17 18:52   ` [virtio-dev] " Jean-Philippe Brucker
2018-01-16  9:25   ` Auger Eric
2018-01-16  9:25     ` [virtio-dev] " Auger Eric
2018-01-16 17:46     ` Jean-Philippe Brucker [this message]
2018-01-16 17:46     ` Jean-Philippe Brucker
2018-01-16 17:46       ` [virtio-dev] " Jean-Philippe Brucker
2018-01-16  9:25   ` Auger Eric
2018-01-16 23:26   ` Auger Eric
2018-01-16 23:26     ` [virtio-dev] " Auger Eric
2018-01-19 16:21     ` Jean-Philippe Brucker
2018-01-19 16:21       ` [virtio-dev] " Jean-Philippe Brucker
2018-01-19 17:22       ` Auger Eric
2018-01-19 17:22       ` Auger Eric
2018-01-19 17:22         ` [virtio-dev] " Auger Eric
2018-01-19 16:21     ` Jean-Philippe Brucker
2018-01-16 23:26   ` Auger Eric
2017-11-17 18:52 ` Jean-Philippe Brucker
2017-11-17 18:52 ` [RFC PATCH v2 3/5] iommu/virtio-iommu: Add event queue Jean-Philippe Brucker
2017-11-17 18:52   ` [virtio-dev] " Jean-Philippe Brucker
2018-01-16 10:10   ` Auger Eric
2018-01-16 10:10     ` [virtio-dev] " Auger Eric
2018-01-16 17:48     ` Jean-Philippe Brucker
2018-01-16 17:48       ` [virtio-dev] " Jean-Philippe Brucker
2018-01-16 17:48     ` Jean-Philippe Brucker
2018-01-16 10:10   ` Auger Eric
2017-11-17 18:52 ` Jean-Philippe Brucker
2017-11-17 18:52 ` [RFC PATCH v2 4/5] ACPI/IORT: Support paravirtualized IOMMU Jean-Philippe Brucker
2017-11-17 18:52 ` Jean-Philippe Brucker
2017-11-17 18:52   ` [virtio-dev] " Jean-Philippe Brucker
2017-11-29 15:17   ` Jean-Philippe Brucker
2017-11-29 15:17   ` Jean-Philippe Brucker
2017-11-29 15:17     ` Jean-Philippe Brucker
2017-11-17 18:52 ` [RFC PATCH v2 5/5] ACPI/IORT: Move IORT to the ACPI folder Jean-Philippe Brucker
2017-11-17 18:52   ` [virtio-dev] " Jean-Philippe Brucker
2017-11-17 18:52 ` Jean-Philippe Brucker

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='5dbd05b0-aeb2-dcd5-f134-692957db0b39__40023.9239134409$1516124553$gmane$org@arm.com' \
    --to=jean-philippe.brucker@arm.com \
    --cc=Jayachandran.Nair@cavium.com \
    --cc=Lorenzo.Pieralisi@arm.com \
    --cc=Marc.Zyngier@arm.com \
    --cc=Robin.Murphy@arm.com \
    --cc=Sudeep.Holla@arm.com \
    --cc=Will.Deacon@arm.com \
    --cc=ashok.raj@intel.com \
    --cc=devel@acpica.org \
    --cc=eric.auger@redhat.com \
    --cc=hanjun.guo@linaro.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=lv.zheng@intel.com \
    --cc=mst@redhat.com \
    --cc=rjw@rjwysocki.net \
    --cc=robert.moore@intel.com \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=virtualization@lists.linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.