From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzMT2-0007QZ-T0 for qemu-devel@nongnu.org; Thu, 19 Nov 2015 05:29:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZzMSy-0000am-Po for qemu-devel@nongnu.org; Thu, 19 Nov 2015 05:29:28 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:26719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzMSy-0000aO-KA for qemu-devel@nongnu.org; Thu, 19 Nov 2015 05:29:24 -0500 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NY200J5X54SHJ90@mailout2.w1.samsung.com> for qemu-devel@nongnu.org; Thu, 19 Nov 2015 10:29:16 +0000 (GMT) From: Pavel Fedin References: <00fe01d1210c$1be12880$53a37980$@samsung.com> <1447884282.4697.111.camel@redhat.com> In-reply-to: <1447884282.4697.111.camel@redhat.com> Date: Thu, 19 Nov 2015 13:29:15 +0300 Message-id: <013101d122b5$240ef500$6c2cdf00$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: quoted-printable Content-language: ru Subject: Re: [Qemu-devel] [PATCH] vfio: Align iova also to IOMMU page size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 'Alex Williamson' Cc: 'Peter Maydell' , qemu-devel@nongnu.org Hello! > > On some architectures TARGET_PAGE_ALIGN() is not enough to get the = right > > alignment. For example on ARM TARGET_PAGE_BITS is 10 because some = old CPUs > > support 1K page size, while minimum SMMU page size is 4K. > > > > This fixes problems like: > > > > 2015-11-17T07:37:42.892265Z qemu-system-aarch64: VFIO_MAP_DMA: -22 > > 2015-11-17T07:37:42.892309Z qemu-system-aarch64: = vfio_dma_map(0x223da230, 0x80002f0400, > 0x10fc00, 0x7f89b40400) =3D -22 (Invalid > > argument) > > qemu: hardware error: vfio: DMA mapping failed, unable to continue [skip] > I don't understand how this is supposed to work, if we align to a = larger > size than the processor, then there are processor size pages of RAM = than > could be handed out as DMA targets for devices, but we can't map them > through the IOMMU. Thus if the guest tries to use them, we get IOMMU > faults in the host and likely memory corruption in the guest because = the > device can't read or write to the page it's supposed to. This doesn't > seem like the right solution. Well, this was my first try on the problem. I've got your idea. But i = guess we should discuss the proper solution then. So, i've got this problem on ARM64. On ARM64 we actually can never have = 1K pages. This page size was supported only by old 32-bit ARM CPUs, up = to ARMv5 IIRC, then it was dropped. Linux OS never even used it. But, since qemu can emulate those ancient CPUs, TARGET_PAGE_BITS is = defined to 10 for ARM. And, ARM64 and ARM32 is actually the same target = for qemu, so this is why we still get it. Perhaps, TARGET_PAGE_BITS should be a variable for ARM, and we should = set it according to the actual used CPU. Then this IOMMU alignment = problem would disappear automatically. What do you think? Cc'ed Peter since he is the main ARM guy here. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia