>That said, perhaps it's better to keep the simplification within a >page-sized range, to avoid introducing subpages unnecessarily.
hi paolo, The sizes of all flatranges merged by flatview_simplify() are page aligned. Flatview_simplify() seems to have the opportunity to do some merging actions only when starting the virtual machine. We can temporarily remove flatview_simplify(). Thanks Felixcui ________________________________ 发件人: Paolo Bonzini <pbonz...@redhat.com> 发送时间: 2021年3月31日 0:35:49 收件人: Richard Henderson; FelixCui-oc; Richard Henderson; Eduardo Habkost; Alex Williamson 抄送: RaymondPang-oc; qemu-devel@nongnu.org; cobechen...@zhaoxin.com 主题: Re: [PATCH 1/1] Remove flatview_simplify() On 30/03/21 18:33, Richard Henderson wrote: > >> Flatview_simplify() can merge many small memory ranges >> into a large one and contains EHCI dma buffers. >> For example,the merged range maybe0xc0000-0xbfffffff. >> When seabios write PAM register to change the properties >> of part of the merged range from RW to readonly, >> this action cause the merged IOVA mapping will be >> unmapped.But EHCI device still send DMA cycles >> and then IOMMU blocks the DMA cycles of EHCI device. > > You've described the problem, and it is quite obviously *not* in memory.c. Well, sort of. The problem is that neither VFIO nor KVM support atomically switching the memory map. For KVM that would be possible, for VFIO based on past discussion it would be much harder. Removing flatview_simplify() seems to be the easiest way to bypass the issue. That said, perhaps it's better to keep the simplification within a page-sized range, to avoid introducing subpages unnecessarily. Paolo