[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 02/21] IOMMU: simplify unmap-on-error in iommu_map()


  • To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 27 Apr 2022 16:05:30 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/n9Q++3q0pYQZYbGOt+1Me5LfJnrKYNu6hI876RpWg0=; b=kR0dlUVRZC0z/WskbhjIA2mR26lctGlBWEV3SYgwVzE3bohvYQ+7j0uRLfRSndCCK+rzr8dQMcHkTFekX0YbV+w6qGxx57Ma/VQsDQRFKVOt/Yy/Jjs4t7YM6mXmAXIVsccJp8vbGtNhijPDFSXCRsgEi4O8icgTJRv6iDhav8aPOmQyzWcNVTn2ZFf810kICfder7B3VoGp0DFoedy4L2x82XLx+9Xb/HLFlY/4r1SzfQJ7c0709mkRlX80cVFyTlGJgBgZbRCM7jkGPDqwEyTM68Y+WDmTXd8m7Mq9nkr39b55ylWCRM/jxojQ74GiY17EyONV5bj6ihEIMHRNIQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=arJhKsAikM60e3EI4DbhOQZDjN4qyAWWrR25FJhSVqTh+C6aTc5DkSbvkdT6u6dpCTWcx6GbpqBINFEq/74Xax0eaCQsu97jxVi14JRVsNwsmg1J+nQCVjpKvjvEsuaMN8O7mRJ/EZTDJi8nCQyywG/M7Dic0NErYL0LvrsAM9FzBXDhShz2u1VU8w052BVOPDmjuGILKJ/8kygnYXIB2KwKQF4LWQOj9OrGJIuvCV96o5Acm+iSiSNx9L9aPcm2A3bpEETCmQWn1SKJ5QpBJA9ikuFEJHPkiffJs5+IJtnHz6Oi1Rco6p1AbXbXw5IwoiNF+XSn5Am3pb45jemZ1g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 27 Apr 2022 14:05:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.04.2022 15:16, Andrew Cooper wrote:
> On 25/04/2022 09:32, Jan Beulich wrote:
>> --- a/xen/drivers/passthrough/iommu.c
>> +++ b/xen/drivers/passthrough/iommu.c
>> @@ -308,11 +308,9 @@ int iommu_map(struct domain *d, dfn_t df
>>                     d->domain_id, dfn_x(dfn_add(dfn, i)),
>>                     mfn_x(mfn_add(mfn, i)), rc);
>>  
>> -        while ( i-- )
>> -            /* if statement to satisfy __must_check */
>> -            if ( iommu_call(hd->platform_ops, unmap_page, d, dfn_add(dfn, 
>> i),
>> -                            flush_flags) )
>> -                continue;
>> +        /* while statement to satisfy __must_check */
>> +        while ( iommu_unmap(d, dfn, i, flush_flags) )
>> +            break;
> 
> How can this possibly be correct?
> 
> The map_page() calls are made one 4k page at a time, and this while loop
> is undoing every iteration, one 4k page at a time.
> 
> Without this while loop, any failure after the first page will end up
> not being unmapped.

There's no real "while loop" here, it's effectively

        if ( iommu_unmap(d, dfn, i, flush_flags) )
            /* nothing */;

just that I wanted to avoid the empty body (but I could switch if
that's preferred).

Note that the 3rd argument to iommu_unmap() is i, not 1.

But I have to admit that I also have trouble interpreting your last
sentence - how would it matter if there was no code here at all? Or
did you maybe mean "With ..." instead of "Without ..."?

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.