From patchwork Mon Apr 25 08:32:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12825384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C06AC433EF for ; Mon, 25 Apr 2022 08:32:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.312491.529742 (Exim 4.92) (envelope-from ) id 1niu8l-0005Kd-If; Mon, 25 Apr 2022 08:32:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 312491.529742; Mon, 25 Apr 2022 08:32:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1niu8l-0005KW-Eb; Mon, 25 Apr 2022 08:32:15 +0000 Received: by outflank-mailman (input) for mailman id 312491; Mon, 25 Apr 2022 08:32:13 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1niu8j-0005KM-OR for xen-devel@lists.xenproject.org; Mon, 25 Apr 2022 08:32:13 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 34642581-c472-11ec-8fc2-03012f2f19d4; Mon, 25 Apr 2022 10:32:12 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2057.outbound.protection.outlook.com [104.47.12.57]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-25-oUMUKYlAMVa2Yg-nFT7akw-1; Mon, 25 Apr 2022 10:32:11 +0200 Received: from DU2PR04MB8616.eurprd04.prod.outlook.com (2603:10a6:10:2db::16) by HE1PR0402MB2923.eurprd04.prod.outlook.com (2603:10a6:3:da::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.21; Mon, 25 Apr 2022 08:32:09 +0000 Received: from DU2PR04MB8616.eurprd04.prod.outlook.com ([fe80::5cb0:5195:4203:7c2f]) by DU2PR04MB8616.eurprd04.prod.outlook.com ([fe80::5cb0:5195:4203:7c2f%9]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 08:32:09 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 34642581-c472-11ec-8fc2-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1650875532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/iXrr5wbNhiSfeRN5CafS9CPFmFmiZ1NrYkK3k2eoBc=; b=OrXI8RrCgJYu0U36MH1G3nbd00GCoYsXRFNdWVCyKqlDLAWjZ2v/rYKAtPzu2GVqyJ3QYv ISeEhvBFztkrr/AhUWx16Ejg2Hyfoeadr+tjP3V8ajKtXsbgce/Q261GeqpYP0aiLx/MnK b7Nv+wq+BjkpArljAeWXp2ycfRRR6Rg= X-MC-Unique: oUMUKYlAMVa2Yg-nFT7akw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JHI0KfcCU2uigwWDWFkCx6UQb18qfCQvO4Xtbxp02SKFpdwTu8bwWyGGuWZqshO0KX31eFKZ2n4ZifoUlYNNTTlY65ffS4ZS2QSK49+3R/IRuX1I12hgNnlr4O5jcC5gtglVAqdb/ZhxNJO5n+TDxsc3FWu9lAFhIvQae2tsWgkGgrU5jx40LMxAnK4wifPHdU/GICO6wX6NB7hTYDeZPHguap0WLuKxDl1a56GFcwZGIlPkN4cnmED3QllQuQVlor1tfsaRfvgu4XcRhGGEMO8/osZr8Y4PgSa9t4RRC+uM3IOfsnMkVhg6my/A+wAjVMnsAd9WqHG9OJi3wNyjHg== 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=rjdSQtedmMFCh8llXOYSf/g3U8VFnBdTE7dsIXoukzk=; b=WsFxqEPx2zlx2PsD33HJ1WnxZ2pguQ9u43ppwthKVBozbTx/1oioyitOrsQ1m76GmqlZvBpXSA9uAMtxVtEUTXLeaEIqr+xiFiMeJFeRbZvmeoFF39+hu4GH3vx52/h/QXwZ1CLcDWmWhen1+sTcCuS2DEdW5kHG4ifLnQP75WQ5nuC2dAf2OXKUZ4/4scDVnexkRFkl+UYNsnxhKmG5P+cKhvSzgwH9BcA0SygWVTqRkS3/7p+Xg7LCudqG/HkbCd2YrRiHKo5XfRutP/SP4sIEKxy9mXcUeOmgsLmTPpRCWYhwMJmRBenX88w32HKh4/65BKytgtP4qwkrPSEP6A== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Mon, 25 Apr 2022 10:32:10 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: [PATCH v4 02/21] IOMMU: simplify unmap-on-error in iommu_map() Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" CC: Andrew Cooper , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: In-Reply-To: X-ClientProxiedBy: AS9PR06CA0330.eurprd06.prod.outlook.com (2603:10a6:20b:45b::9) To DU2PR04MB8616.eurprd04.prod.outlook.com (2603:10a6:10:2db::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bab5479d-ae76-4ef6-773d-08da269616bd X-MS-TrafficTypeDiagnostic: HE1PR0402MB2923:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4plGuojbvHRApdQtJBz5lbEa4KFSgYrAfWdhtKGjJzcLRz0T2jqpuT6+2YD+LiLN+70FjKx85i4q7NOy1P3/BjRQyw5zjA2E1GJXZtDLvSAgIYuXWIOr7GdVK3nUMe6grWwRaO/cpI4LkYVFFHiLNrGp9r49iTQEWnj6RaiE8KQ8dPZAopM+1fddAxazCC9IlNmdM6jvb+bdS2n7vCbJYT6z2gmPXBCcaBVfGS6/OF6kOwOEpRxicVOZrjfJ/r8j2rPRhxykfyVSujkHUnFpYG6GUAFVtccMyv6BeIpK6Fs6Cpnvt+daCzXb3h6Zaa54ZehWF15nml1RMUuAW5V0BJhEmBKmtjVdOniM8IGGVxqiyoyF3TUqUxBK5/LcftisJ69nDT7eMZ0QCqwmjo4zvcxOWeivt1CUGx3f3tvobed80iTGyJbEyabKYWlab0n1rT6Faf/myCHsw7YRyYsZmUrVIfxrnJI09zDtlWEgFAxi6Sw4Tu5b6YIFlp9Z06DRBosHA+OUcYmg7Ur5ZiUQRV/rYzFNq315+00+bLxlCvZ3/r2sTSoO6CMEdrE76GAQX5eUPnRVrwHhfC1f/kEsorxx5b6hOgY0fgfg+gLJv4FEzoF6+9w1w7P//ekXOdymEqLXdqa0d2DDMiqmImSSiAZCVaET5OTeYo19XgIzlMBJ9wMp1t5PYaxTeQwg79HR4/4BtMlDVH2ASgDM88Z5XQRpHgy8i0H/6d4tDk+F1srOAcqmiBYU8KtxxSEF37j2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8616.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(66476007)(8676002)(316002)(86362001)(66946007)(5660300002)(4744005)(31696002)(66556008)(38100700002)(6666004)(2906002)(6506007)(2616005)(4326008)(8936002)(186003)(26005)(6512007)(54906003)(6916009)(508600001)(6486002)(36756003)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SRBWLxRBnBIwe8OiebPawFRHRf1xo+30UsiNPDLrhKJoYjwOHAm3mwCUFXmmF0JqRACpAXgzVquzlsoRkbQpeF/jiXmGhJgAEYjMVC0dQEUnRfun7LtrwPTRdtoImZtfHsHcif9hmYM8ay3nrMF4pJOyl9Gqjq+29+rSTISuaDPBf0Hj7I0nAmQjpRyLrSbT9yt3ZEiq169ci1CKwFe7wMYCSzb4wb22G14Q1iKxLH3AKmDvP03/r0niaPQMrzocaFaipMF3HKLVlmLjkr+JYFGctrHoAUaRJw3lAIIgEG/oAT0CClSh+Gd2Ow656lVsUeZqzThD/Amw2Le5T2Un2bZ/Dnx1mzzkIKN9i38LHBb1WZ5mItLhW1p3pefTSOfk1tKrbQHGfs/04+DXXpo4c+P6TEyZ5Z4iaxEMrlC/T4qiTpxTmlXNDu3IPOVPVPLYAy5KYN8Dby91/roKeBvxV89EI9mUn5dblwVqixnFvEmLLCygQG8cOVsRSNUVy5JyRqX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Hd9pJJ06Ln/7JFJQGdz/q0CB2y5/LplOylO8emOIm6hifYHIUN9LXt2KvR1yTk53OIXDLaBrMZYo9UKkmO/YS0bD50NrzIUGx++HAWNGFo3ELd9dnw9mNCKEBgij3363b37EUkrTt5YeWqwfJYLHxBQrKg== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: bab5479d-ae76-4ef6-773d-08da269616bd X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8616.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:32:09.5905 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: td2wkBK9YkcAHiFj5mmvYuijr+lhcC4Pjzl44ZVZqzBUX58CA8SXvlhRVCvp1HNuwG7nnafQr988hMtZ6HouEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0402MB2923 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é Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné --- 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; if ( !is_hardware_domain(d) ) domain_crash(d);