From: Ben-Ami Yassour <benami@il.ibm.com>
To: "Han, Weidong" <weidong.han@intel.com>
Cc: amit.shah@qumranet.com, Muli Ben-Yehuda <MULI@il.ibm.com>,
raharper@us.ibm.com, kvm@vger.kernel.org
Subject: RE: [PATCH] KVM: PCIPT: VT-d: fix context mapping
Date: Thu, 19 Jun 2008 15:28:44 +0300 [thread overview]
Message-ID: <1213878524.7454.4.camel@lnx-benami> (raw)
In-Reply-To: <08DF4D958216244799FC84F3514D70F00180ECFD@pdsmsx415.ccr.corp.intel.com>
On Thu, 2008-06-19 at 16:59 +0800, Han, Weidong wrote:
> benami@il.ibm.com wrote:
> > From: Ben-Ami Yassour <benami@il.ibm.com>
> >
> > When changing the VT-d context mapping, according to the spec, it is
> > required
> > to first set the context to not present, flush and only then apply the
> > new context.
> >
> > Signed-off-by: Ben-Ami Yassour <benami@il.ibm.com>
> > ---
> > drivers/pci/intel-iommu.c | 17 +++++++++++++++++
> > 1 files changed, 17 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
> > index 930874f..dcdfa97 100644
> > --- a/drivers/pci/intel-iommu.c
> > +++ b/drivers/pci/intel-iommu.c
> > @@ -56,6 +56,7 @@
> >
> >
> > static void flush_unmaps_timeout(unsigned long data);
> > +static void detach_domain_for_dev(struct dmar_domain *domain, u8
> > bus, u8 devfn);
> >
> > DEFINE_TIMER(unmap_timer, flush_unmaps_timeout, 0, 0);
> >
> > @@ -1264,7 +1265,23 @@ static int domain_context_mapping_one(struct
> > dmar_domain *domain, if (!context)
> > return -ENOMEM;
> > spin_lock_irqsave(&iommu->lock, flags);
> > +
> > + if (context_present(*context) &&
> > + (context_domain_id(*context) == domain->id) &&
> > + (context_address_width(*context) == domain->agaw) &&
> > + (context_address_root(*context) ==
> virt_to_phys(domain->pgd)) &&
> > + (context_translation_type(*context) ==
> CONTEXT_TT_MULTI_LEVEL)
> > && + (!context_fault_disable(*context))) {
> > + spin_unlock_irqrestore(&iommu->lock, flags);
> > + return 0;
> > + }
>
> Only need to check context_present(*context) according to VT-d spec,
> which says "software must not modify fields other than the Present (P)
> field of currently present root-entries or context-entries."
>
> Randy (Weidong)
The logic here is that, if no change is made to the context then just
return ok (0). Otherwise, according to the spec, we need to first
invalidate the context, flush it, and only then apply the changes to the
context.
The other option is to make sure that before every call to this function
the context is invalidated, but disabling it inside the function seems
safer. do you agree with that?
Regards,
Ben
>
> > +
> > + spin_unlock_irqrestore(&iommu->lock, flags);
> > +
> > + detach_domain_for_dev(domain, bus, devfn);
> >
> > + spin_lock_irqsave(&iommu->lock, flags);
> > +
> > context_clear_entry(*context);
> > context_set_domain_id(*context, domain->id);
> > context_set_address_width(*context, domain->agaw);
next prev parent reply other threads:[~2008-06-19 12:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-17 19:05 Patches for vtd pci passthrough benami
2008-06-17 19:05 ` [PATCH] KVM: PCIPT: fix compilation errors benami
2008-06-17 19:05 ` [PATCH] KVM: PCIPT: VT-d: fix guest unmap benami
2008-06-17 19:05 ` [PATCH] KVM: PCIPT: free device structure on vm destroy benami
2008-06-17 19:05 ` [PATCH] KVM: PCIPT: VT-d: fix context mapping benami
2008-06-17 19:25 ` KVM: PCIPT: temporary fix for pio (userspace part) benami
2008-06-17 19:25 ` [PATCH] " benami
2008-06-18 20:30 ` [PATCH] KVM: PCIPT: VT-d: fix context mapping Muli Ben-Yehuda
2008-06-19 8:59 ` Han, Weidong
2008-06-19 12:28 ` Ben-Ami Yassour [this message]
2008-06-19 14:18 ` Han, Weidong
2008-06-19 17:44 ` Ben-Ami Yassour1
2008-06-20 6:23 ` Han, Weidong
2008-06-30 15:32 ` Ben-Ami Yassour
2008-07-01 2:22 ` Han, Weidong
2008-06-17 21:29 ` [PATCH] KVM: PCIPT: VT-d: fix guest unmap Anthony Liguori
2008-06-18 12:06 ` Ben-Ami Yassour
2008-06-18 20:48 ` Anthony Liguori
2008-06-18 21:23 ` Muli Ben-Yehuda
2008-06-18 21:41 ` Anthony Liguori
2008-06-20 18:59 ` Avi Kivity
2008-06-20 19:28 ` Anthony Liguori
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=1213878524.7454.4.camel@lnx-benami \
--to=benami@il.ibm.com \
--cc=MULI@il.ibm.com \
--cc=amit.shah@qumranet.com \
--cc=kvm@vger.kernel.org \
--cc=raharper@us.ibm.com \
--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