From: Avi Kivity <avi@redhat.com>
To: "Han, Weidong" <weidong.han@intel.com>
Cc: "Woodhouse, David" <david.woodhouse@intel.com>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
"Kay, Allen M" <allen.m.kay@intel.com>,
"Yu, Fenghua" <fenghua.yu@intel.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>
Subject: Re: [PATCH 1/2] VT-d: Support multiple device assignment for KVM
Date: Wed, 26 Nov 2008 12:53:14 +0200 [thread overview]
Message-ID: <492D2A9A.1010900@redhat.com> (raw)
In-Reply-To: <715D42877B251141A38726ABF5CABF2C018BEB5D99@pdsmsx503.ccr.corp.intel.com>
Han, Weidong wrote:
> In order to support multiple device assignment for KVM, this patch does following main changes:
> - extend dmar_domain to own multiple devices from different iommus, use a bitmap of iommus to replace iommu pointer in dmar_domain.
> - add a flag DOMAIN_FLAG_VIRTUAL_MACHINE to represent KVM VT-d usage. Many functions (e.g. intel_map_single() and intel_unmap_single()) won't be used by KVM VT-d. Let them return directly when this flag is set.
>
This seems brittle. An API that has some functions shorted out
depending on some flag is hard to understand and use.
We should either implement the functions, or split the API into a basic
version that talks only to one device, and an expanded versions that
talks to multiple devices, and is implemented by the using the lower
level API. This may require more changes due to the need to share io
pagetables.
> - "SAGAW" capability may be different across iommus, that's to say the VT-d page table levels may be different among iommus. This patch uses a defaut agaw, and skip top levels of page tables for iommus which have smaller agaw than default.
>
Neat trick.
> void free_dmar_iommu(struct intel_iommu *iommu)
> {
> struct dmar_domain *domain;
> @@ -960,7 +1054,14 @@ void free_dmar_iommu(struct intel_iommu *iommu)
> for (; i < cap_ndoms(iommu->cap); ) {
> domain = iommu->domains[i];
> clear_bit(i, iommu->domain_ids);
> - domain_exit(domain);
> +
> + if (domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) {
> + /* domain may be referenced by other iommus */
> + if (domain_in_other_iommus(domain, iommu) == 0)
> + domain_exit(domain);
> + }
> + else
> + domain_exit(domain);
>
Things like this are best expressed using reference counts, which
removes the need for the test as well.
> +
> + /* Skip top levels of page tables for
> + * iommu which has less agaw than default.
> + */
> + for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) {
> + pgd = phys_to_virt(dma_pte_addr(*pgd));
> + if (!dma_pte_present(*pgd)) {
> + spin_unlock_irqrestore(&iommu->lock, flags);
> + return -ENOMEM;
> + }
> + }
> + }
>
Need to check that the agaw is sufficient for mapped memory (and when
adding a device or mapping more memory, need a similar check).
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2008-11-26 10:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-26 3:18 [PATCH 1/2] VT-d: Support multiple device assignment for KVM Han, Weidong
2008-11-26 10:53 ` Avi Kivity [this message]
2008-11-26 14:04 ` Han, Weidong
2008-11-26 19:07 ` Yu, Fenghua
2008-11-27 3:38 ` Han, Weidong
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=492D2A9A.1010900@redhat.com \
--to=avi@redhat.com \
--cc=allen.m.kay@intel.com \
--cc=david.woodhouse@intel.com \
--cc=fenghua.yu@intel.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jbarnes@virtuousgeek.org \
--cc=kvm@vger.kernel.org \
--cc=weidong.han@intel.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