From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1FcM-0005pt-5b for qemu-devel@nongnu.org; Tue, 24 Nov 2015 10:34:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1FcI-00043Z-8R for qemu-devel@nongnu.org; Tue, 24 Nov 2015 10:34:54 -0500 Received: from mail-vk0-x22f.google.com ([2607:f8b0:400c:c05::22f]:34904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1FcI-00043I-3Y for qemu-devel@nongnu.org; Tue, 24 Nov 2015 10:34:50 -0500 Received: by vkha189 with SMTP id a189so13886866vkh.2 for ; Tue, 24 Nov 2015 07:34:49 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1447884282.4697.111.camel@redhat.com> References: <00fe01d1210c$1be12880$53a37980$@samsung.com> <1447884282.4697.111.camel@redhat.com> From: Peter Maydell Date: Tue, 24 Nov 2015 15:34:30 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 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: Pavel Fedin , QEMU Developers On 18 November 2015 at 22:04, Alex Williamson wrote: > On Tue, 2015-11-17 at 10:46 +0300, Pavel Fedin wrote: >> 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. > 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. Thanks, There are a number of different interesting page sizes here: * the host kernel page size * the target CPU architecture's worst-case smallest page size * the page size the guest kernel is actually using at the moment (consider a 4K-page guest kernel on a 64K-page host kernel) These don't necessarily have to all be the same. I would expect VFIO to be interested in the host kernel page size, not TARGET_PAGE_ALIGN. It might also be interested in the in-practice guest kernel page settings, but you can't actually determine those from outside. (In general non-TCG code should probably not try to use the TARGET_PAGE_* constants.) thanks -- PMM