Re: [PATCH v8 06/10] iommu/amd: Modify set_dte_entry() to use 256-bit DTE helpers

Suthikulpanit, Suravee
2024-11-01T15:02:59Z

On 11/1/2024 7:10 PM, Jason Gunthorpe wrote:
> On Thu, Oct 31, 2024 at 06:42:39PM +0000, Suravee Suthikulpanit wrote:
>> +struct dev_table_entry *amd_iommu_get_ivhd_dte_flags(u16 segid, u16 devid)
>> +{
>> + struct ivhd_dte_flags *e;
>> + unsigned int best_len = UINT_MAX;
>> + struct dev_table_entry *dte = NULL;
>> +
>> + for_each_ivhd_dte_flags(e) {
>> + /*
>> + * Need to go through the whole list to find the smallest range,
>> + * which contains the devid.
>> + */
>> + if ((e->segid == segid) &&
>> + (e->devid_first >= devid) &&
>> + (e->devid_last <= devid)) {
>
> Again, I don't know much about this format, but are you sure about
> this logic? Consider:
>
> e->devid_first = 10
> devid = 12
> e->devid_last = 15
>
> (e->devid_first >= devid) == 10 >= 12 == FALSE
> (e->devid_last <= devid) == 15 <= 12 == FALSE
>
> FALSE && FALSE == FALSE
>
> It seems to me it does not do what the comment says? Compare to the
> version I sent in my last email

Ah, sorry again for this stupid mistake. You are correct. Thank you very
much for catching this. I am sending V9 with only the fix for this.

Thanks,
Suravee