On Fri, Jan 20, 2017 at 08:59:01AM +0000, Tian, Kevin wrote:
[...]
> > > Also for hot-add
> > > device path, some check of caching mode is required. If not set,
> > > should we fail hot-add operation? I don't think we have such physical
> > > platform with some devices behind IOMMU while others not.
> >
> > Could you explain in what case will we fail a hot plug?
> >
>
> user enables intel-iommu, but don't set caching mode.
>
> Then later user hot-add a PCI device to the VM. Guest will assume
> newly assigned device also behind the default vIOMMU, and thus
> needs to setup IOVA mappings, which is then broken...
Is the newly added device a vfio-pci device? If so, we should hit
this and VM will stops to work:
if (!s->cache_mode_enabled && new & IOMMU_NOTIFIER_MAP) {
error_report("We need to set cache_mode=1 for intel-iommu to enable "
"device assignment with IOMMU protection.");
exit(1);
}
I admit this is not user-friendly, and a better way may be that we
disallow the hot-plug in that case, telling the user about the error,
rather than crashing the VM. But, I think that can be a patch outside
this series, considering (again) that this only affects advanced
users.
Thanks,
-- peterx