Re: [RFCv2 PATCH 2/7] iommu/amd: Refactor set_dte_entry

From: Jason Gunthorpe
Date: Fri Mar 08 2024 - 08:51:58 EST


On Thu, Jan 11, 2024 at 06:06:41PM -0600, Suravee Suthikulpanit wrote:

> - old_domid = dev_table[devid].data[1] & DEV_DOMID_MASK;
> - dev_table[devid].data[1] = flags;
> - dev_table[devid].data[0] = pte_root;
> + dev_table[devid].data[0] = target.data[0];
> + dev_table[devid].data[1] = target.data[1];
> + dev_table[devid].data[2] = target.data[2];

Maybe you could have convinced me this doesn't have bugs today with 2
qword updates, but no way this is OK.

The multi qword update needs to be sequenced correctly so the HW
doesn't have tearing. The manual talks about this and it talks about
128 bit updates too.

This needs to follow the design ARM has where it uses the special
update logic to reliably sequence the change. Since nesting is making
the update more complex it becomes important.

Jason