Re: [PATCH 15/22] iommu/amd: Introduce helper function for updating domain ID mapping table

Jason Gunthorpe
2026-03-30T12:17:08Z

On Mon, Mar 30, 2026 at 08:41:59AM +0000, Suravee Suthikulpanit wrote:
> +int amd_viommu_domain_id_update(struct amd_iommu *iommu, u16 gid,
> + u16 hdom_id, u16 gdom_id)
> +{
> + u64 val, tmp1, tmp2;
> + u8 __iomem *vfctrl = VIOMMU_VFCTRL_MMIO_BASE(iommu, gid);
> +
> + tmp1 = gdom_id;
> + tmp1 = ((tmp1 & 0xFFFFULL) << 46);
> + tmp2 = hdom_id;
> + tmp2 = ((tmp2 & 0xFFFFULL) << 14);
> + val = tmp1 | tmp2 | 0x8000000000000001UL;
> + writeq(val, vfctrl + VIOMMU_VFCTRL_GUEST_DID_MAP_CONTROL1_OFFSET);

Use genmask and field prep. Check all the patches for stuff like this
and fix it..

Jason