From: Tim Deegan Subject: Re: [PATCH v2 1/4] xen: make logdirty and iommu mutually exclusive Date: Thu, 24 Apr 2014 13:50:50 +0200 Message-ID: <20140424115050.GE48969@deinos.phlegethon.org> References: <1398240984-67266-1-git-send-email-roger.pau@citrix.com> <1398240984-67266-2-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WdIB2-0004Fm-Qz for xen-devel@lists.xenproject.org; Thu, 24 Apr 2014 11:50:53 +0000 Content-Disposition: inline In-Reply-To: <1398240984-67266-2-git-send-email-roger.pau@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roger Pau Monne Cc: xen-devel@lists.xenproject.org, Jan Beulich List-Id: xen-devel@lists.xenproject.org Hi, = At 10:16 +0200 on 23 Apr (1398244581), Roger Pau Monne wrote: > Prevent the usage of global logdirty if the domain is using the IOMMU, > and also prevent passthrough of devices if logdirty is enabled. > = > Signed-off-by: Roger Pau Monn=E9 Yes, this is the sort of thing I had in mind (thuogh I agree with Jan's review comments). Cheers, Tim. > --- > xen/arch/x86/mm/hap/hap.c | 9 +++++++++ > xen/arch/x86/mm/shadow/common.c | 9 +++++++++ > xen/drivers/passthrough/iommu.c | 3 ++- > 3 files changed, 20 insertions(+), 1 deletions(-) > = > diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c > index 68a0c25..352edfd 100644 > --- a/xen/arch/x86/mm/hap/hap.c > +++ b/xen/arch/x86/mm/hap/hap.c > @@ -175,6 +175,15 @@ out: > */ > static int hap_enable_log_dirty(struct domain *d, bool_t log_global) > { > + > + if ( iommu_enabled && need_iommu(d) && log_global ) > + { > + /* > + * Refuse to turn on global log-dirty mode > + * if the domain is using the IOMMU. > + */ > + return -EINVAL; > + } > /* turn on PG_log_dirty bit in paging mode */ > paging_lock(d); > d->arch.paging.mode |=3D PG_log_dirty; > diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/com= mon.c > index 9258d2a..dd55455 100644 > --- a/xen/arch/x86/mm/shadow/common.c > +++ b/xen/arch/x86/mm/shadow/common.c > @@ -3422,6 +3422,15 @@ int shadow_enable_log_dirty(struct domain *d, bool= _t log_global) > { > int ret; > = > + if ( iommu_enabled && need_iommu(d) && log_global ) > + { > + /* > + * Refuse to turn on global log-dirty mode > + * if the domain is using the IOMMU. > + */ > + return -EINVAL; > + } > + > paging_lock(d); > if ( shadow_mode_enabled(d) ) > { > diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/io= mmu.c > index 0cf0748..ef6660f 100644 > --- a/xen/drivers/passthrough/iommu.c > +++ b/xen/drivers/passthrough/iommu.c > @@ -292,7 +292,8 @@ static int assign_device(struct domain *d, u16 seg, u= 8 bus, u8 devfn) > * enabled for this domain */ > if ( unlikely(!need_iommu(d) && > (d->arch.hvm_domain.mem_sharing_enabled || > - d->mem_event->paging.ring_page)) ) > + d->mem_event->paging.ring_page || > + paging_mode_log_dirty(d))) ) > return -EXDEV; > = > if ( !spin_trylock(&pcidevs_lock) ) > -- = > 1.7.7.5 (Apple Git-26) > =