On Mon, Jan 16, 2017 at 03:52:10PM +0800, Jason Wang wrote: > > > On 2017年01月16日 15:43, Peter Xu wrote: > >On Mon, Jan 16, 2017 at 01:53:54PM +0800, Jason Wang wrote: > >> > >>On 2017年01月13日 11:06, Peter Xu wrote: > >>>Before this one we only invalidate context cache when we receive context > >>>entry invalidations. However it's possible that the invalidation also > >>>contains a domain switch (only if cache-mode is enabled for vIOMMU). > >>So let's check for CM before replaying? > >When CM is not set, there should have no device needs > >IOMMU_NOTIFIER_MAP notifies. So IMHO it won't hurt if we replay here > >(so the notifier_list will only contain UNMAP notifiers at most, and > >sending UNMAP to those devices should not affect them at all). > > > >If we check CM before replay, it'll be faster when guest change iommu > >domain for a specific device. But after all this kind of operation is > >extremely rare, while if we check CM bit, we have a "assumption" in > >the code that MAP is depending on CM. In that case, to make the codes > >cleaner, I'd slightly prefer not check it here. How do you think? > > Ok, I think maybe it's better to add a comment here.
How about this? + /* + * So a device is moving out of (or moving into) a + * domain, a replay() suites here to notify all the + * IOMMU_NOTIFIER_MAP registers about this change. + * This won't bring bad even if we have no such + * notifier registered - the IOMMU notification + * framework will skip MAP notifications if that + * happened. + */ memory_region_iommu_replay_all(&vtd_as->iommu); Thanks, -- peterx