On Wed, Feb 19, 2025 at 11:43:46AM +1100, Alexey Kardashevskiy wrote: > On 19/2/25 10:51, Jason Gunthorpe wrote: > > On Wed, Feb 19, 2025 at 10:35:28AM +1100, Alexey Kardashevskiy wrote: > > > > > With in-place conversion, we could map the entire guest once in the HV IOMMU > > > and control the Cbit via the guest's IOMMU table (when available). Thanks, > > > > Isn't it more complicated than that? I understood you need to have a > > IOPTE boundary in the hypervisor at any point where the guest Cbit > > changes - so you can't just dump 1G hypervisor pages to cover the > > whole VM, you have to actively resize ioptes? > > When the guest Cbit changes, only AMD RMP table requires update but not > necessaryly NPT or IOPTEs. > (I may have misunderstood the question, what meaning does "dump 1G pages" > have?). AFAIK that is not true, if there are mismatches in page size, ie the RMP is 2M and the IOPTE is 1G then things do not work properly. It is why we had to do this: > > This was the whole motivation to adding the page size override kernel > > command line. commit f0295913c4b4f377c454e06f50c1a04f2f80d9df Author: Joerg Roedel <jroedel@xxxxxxx> Date: Thu Sep 5 09:22:40 2024 +0200 iommu/amd: Add kernel parameters to limit V1 page-sizes Add two new kernel command line parameters to limit the page-sizes used for v1 page-tables: nohugepages - Limits page-sizes to 4KiB v2_pgsizes_only - Limits page-sizes to 4Kib/2Mib/1GiB; The same as the sizes used with v2 page-tables This is needed for multiple scenarios. When assigning devices to SEV-SNP guests the IOMMU page-sizes need to match the sizes in the RMP table, otherwise the device will not be able to access all shared memory. Also, some ATS devices do not work properly with arbitrary IO page-sizes as supported by AMD-Vi, so limiting the sizes used by the driver is a suitable workaround. All-in-all, these parameters are only workarounds until the IOMMU core and related APIs gather the ability to negotiate the page-sizes in a better way. Signed-off-by: Joerg Roedel <jroedel@xxxxxxx> Reviewed-by: Vasant Hegde <vasant.hegde@xxxxxxx> Link: https://lore.kernel.org/r/20240905072240.253313-1-joro@xxxxxxxxxx Jason