From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6iHe-0001uh-Gy for qemu-devel@nongnu.org; Mon, 14 Jul 2014 11:35:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6iHY-00020G-D8 for qemu-devel@nongnu.org; Mon, 14 Jul 2014 11:35:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6iHY-0001zj-5o for qemu-devel@nongnu.org; Mon, 14 Jul 2014 11:35:12 -0400 Message-ID: <1405352105.4098.105.camel@ul30vt.home> From: Alex Williamson Date: Mon, 14 Jul 2014 09:35:05 -0600 In-Reply-To: <1405339783-4501-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1405339783-4501-1-git-send-email-gwshan@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] sPAPR/IOMMU: Fix TCE entry permission List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gavin Shan Cc: aik@ozlabs.ru, qemu-devel@nongnu.org, agraf@suse.de On Mon, 2014-07-14 at 22:09 +1000, Gavin Shan wrote: > The permission of TCE entry should exclude physical base address. > Otherwise, unmapping TCE entry can be interpreted to mapping TCE > entry wrongly for VFIO devices. > > Signed-off-by: Gavin Shan > --- > hw/misc/vfio.c | 2 +- > hw/ppc/spapr_iommu.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) I'll give an ack and hope that agraf is planning another 2.1 pull. If not, let me know. Thanks Acked-by: Alex Williamson > diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c > index f9426ef..75ccceb 100644 > --- a/hw/misc/vfio.c > +++ b/hw/misc/vfio.c > @@ -2316,7 +2316,7 @@ static void vfio_iommu_map_notify(Notifier *n, void *data) > return; > } > > - if (iotlb->perm != IOMMU_NONE) { > + if ((iotlb->perm & IOMMU_RW) != IOMMU_NONE) { > vaddr = memory_region_get_ram_ptr(mr) + xlat; > > ret = vfio_dma_map(container, iotlb->iova, > diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c > index e603ac1..e223374 100644 > --- a/hw/ppc/spapr_iommu.c > +++ b/hw/ppc/spapr_iommu.c > @@ -81,7 +81,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr) > ret.iova = addr & page_mask; > ret.translated_addr = tce & page_mask; > ret.addr_mask = ~page_mask; > - ret.perm = tce; > + ret.perm = tce & IOMMU_RW; > } > trace_spapr_iommu_xlate(tcet->liobn, addr, ret.iova, ret.perm, > ret.addr_mask); > @@ -225,7 +225,7 @@ static target_ulong put_tce_emu(sPAPRTCETable *tcet, target_ulong ioba, > entry.iova = ioba & page_mask; > entry.translated_addr = tce & page_mask; > entry.addr_mask = ~page_mask; > - entry.perm = tce; > + entry.perm = tce & IOMMU_RW; > memory_region_notify_iommu(&tcet->iommu, entry); > > return H_SUCCESS;