[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: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Wed, 27 Apr 2022 13:16:02 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=CJoWPejBExPDOKG9sp5p2i6RGq9VkJy0n8vU+7Ak5ec=; b=eqV/c78DPE7HoBF3s2NH9Ea62oNFONc4eyuA18KQyE+PDpwyZ/cNgGmoY0b6avjsWmK2sG0kNxl1o8BFAF5if8OZTtaUjsBijKqeWGTWGTB6K9m0qkYLlKDT0BoHAd6QUdkHMKKNMtV2kCCsQ3Z7xOiYohtAV1dN6AuHhjxcFgi6/ygYNcDBQWoL72AeXydJNG0oVGuCFCSakP902cqttY9k+GA2iKCyuhrT5+OoP48i00FyCAwHhx1c9IYhXCiga8LCWJ/61YjfpBV0egfUnSDZm51ln7SQlsPf8n7uT30ShHmOaG7OMG6K0H6rVD2v3mPrj2+Smh9bYxrRVpxMNA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VFD05PsyJNpB1bsIIKIV/+gUHeZJPNCKtlvEqmRY80unAv90pEZDDi+LGNjY7Sd9tvPN6CA/O6KI+adPUbxLehJRZGJDJPBvW00h59iaFEMRpn8y/V4NfcFxA6FjvUBuLN7nZgXCoOJdrpc9efvVBDZpbeaeLGQpHQlA5dcNGCdmfln3L/zYD3bpML1fJVxHig4B7w15KYs1Kzt5tkIWE/wgmjKd1CfGklXc0O7xtmNhO2GOFFnkVEcPQ6Q6TfYhwK6ibVWad87RVPjarlb3d5ksL+kh1ag8lJGSp4WIT5B9lQR26JLLwhmL8LA/cznlDQaOIZn/aQrMHIIkPCOK0w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 27 Apr 2022 13:16:17 +0000
  • Ironport-data: A9a23:Zq7zoaidJ09lE3m2iLPgcL35X161HREKZh0ujC45NGQN5FlHY01je htvWjrXOPzcamv3ctEiYdnn80IF65fRn4cxGwBr/noxEXkb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jefSLlbFILas1hpZHGeIcw98z0M78wIFqtQw24LhX1nS4 YqaT/D3YzdJ5RYlagr41IrbwP9flKyaVOQw5wFWiVhj5TcyplFNZH4tDfjZw0jQG+G4KtWSV efbpIxVy0uCl/sb5nFJpZ6gGqECaua60QFjERO6UYD66vRJjnRaPqrWqJPwwKqY4tmEt4kZ9 TlDiXC/YT0oDq7AwKcZbwV7EnFsfoFYoebIBXfq5KR/z2WeG5ft69NHKRhseKE9pKNwC2wI8 uEEIjcQaBzFn/ix3L+wVuhrgIIkMdXvO4Qc/HpnyFk1D95/GcyFH/qMuI4ehWhu7ixNNa+2i 84xQDxjdhnfJTZIPU8aEskWl+a0nHjvNTZfrTp5oIJpsjSInVAsj9ABNvLHR4eQaepflHyig Uz83m2iUh5BHsymnG/tHnWEw7WncTnAcIAYGaC89/VqqEaO3WFVAxoTPXOrrP/8hkOgVtZ3L 00P5jFovaU07FasTNT2Q1u/unHslgYVRt54A+A8rgaXxcLpDx2xA2EFSntNbYIgvcpvHzgyj AbWwZXuGCBlt6CTRTSF7LCIoDiuOC8Ta2gfeSsDSghD6N7myG0usi/yoh9YOPbdprXI9fvYm FhmcABWa20vsPM2
  • Ironport-hdrordr: A9a23:3m9LNq4dMrBaYGf6xAPXwZGCI+orL9Y04lQ7vn2ZFiY5TiXIra qTdaogviMc0AxhI03Jmbi7Scq9qeu1z+843WBjB8bZYOCAghrmEGgC1/qu/9SEIUHDH4FmpM BdmsRFaeEYSGIK9foSgzPIXerIouP3lpxA7N22pxgCcegpUdAY0+4TMHf4LqQCfngjOXNPLu v42iMonVqdUEVSSv7+KmgOXuDFqdGOvonhewQ6Cxku7xTLpS+06ZbheiLonis2Yndq+/MP4G LFmwv26uGIqPeg0CLR0GfV8tB/hMbh8N1eH8aB4/JlaQkEyzzYJriJaYfy+Azdk9vfr2rCV+ O85SvICv4Drk85uFvF+CcFlTOQiArGoEWStGNwyUGT3fARAghKSvapzLgpDCcwoSAbza5B+b MO0GSDu5VNCxTc2Cz7+tjTThlv0lG5uHw4jIco/jRiuKYlGclsRLYkjQpo+VY7bVDHwZFiFP MrANDX5f5Qf1/fZ3fFvnN3yNjpWngoBB+JTkULp8TQilFt7TpE5lpdwNZakmYL9Zo7RZUB7+ PYMr5wnLULSsMNd6pyCOoIXMPyAG3QRhDHNn6UPD3cZeo6EmOIr4Sy7KQ+5emsdpBNxJwumI 7ZWFcdrmI2c1KGM7z44HSKyGG4fIyQZ0Wc9igF3ekJhlTVfsuZDQSTDFYzjsCnv/ITRsXGRv fbAuMiP8Pe
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYWH75zDdGe3+po0S/evA91QmE7q0DwOQA
  • Thread-topic: [PATCH v4 02/21] IOMMU: simplify unmap-on-error in iommu_map()

On 25/04/2022 09:32, Jan Beulich wrote:
> As of 68a8aa5d7264 ("iommu: make map and unmap take a page count,
> similar to flush") there's no need anymore to have a loop here.
>
> Suggested-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> v3: New.
>
> --- 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.

~Andrew

 


Rackspace

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