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

Suthikulpanit, Suravee
2026-04-06T03:49:42Z

On 3/30/2026 7:17 PM, Jason Gunthorpe wrote:
> 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.

Got it. I missed this one.

Thanks,
Suravee