From patchwork Wed May 11 08:45:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 9066011 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 99E39BF29F for ; Wed, 11 May 2016 08:48:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B87B220103 for ; Wed, 11 May 2016 08:48:23 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CCF78200E0 for ; Wed, 11 May 2016 08:48:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0PmH-0000ix-46; Wed, 11 May 2016 08:45:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0PmE-0000ir-Qd for xen-devel@lists.xen.org; Wed, 11 May 2016 08:45:55 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 1F/D8-04060-141F2375; Wed, 11 May 2016 08:45:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAKsWRWlGSWpSXmKPExsVyMfSWk67DR6N wg3vnNS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oxJb9ayFfSJVhw/vJypgfGWUBcjF4eQQD+j xOpHJ1lAHBaBdlaJxas62EEcCYHFrBK7Nrxn7GLkBHJyJKZumcUEYvMKCEqcnPmEBSJeJLGif zoziC0sIClxZfp0sLiQgI/E338vwXo5BUIkXvzdwwqxrpFZovfAUrAEi4CqxKofIEUcQIMMJS ZuqQYxeQUCJJYu14YYmS1x5MtMNhCbDaji/4ezYONFBJQkzk14wAYykllgPpPEvpMnwG5gFnC RWLC1m3UCo9AsJKfOQpKaBbSCWUBdYv08IQjTSWLdNTOICmuJrwuPQVUrSkzpfsg+C+xJGYmW a5tZFjCyr2LUKE4tKkst0jW00EsqykzPKMlNzMzRNTQw1stNLS5OTE/NSUwq1kvOz93ECIyXe gYGxh2Mv097HmKU5GBSEuXtf2kULsSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC9/d7oJxgUWp6ak VaZg4wcmHSEhw8SiK8oh+A0rzFBYm5xZnpEKlTjMYcW35fW8vEsW3qvbVMQix5+XmpUuK87iC lAiClGaV5cINgCeUSo6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWHePyD38GTmlcDtewV0ChPQ KdXXwU4pSURISTUwhogWNbcWhpbvu189W/WJL/vEyprar3ZSVXvXr/WaJRq66kJDyoENYo81L Cbcueap5tvjZFcruvvN70mqnSe0V7c6n93VM5/7mbDQ4Uc3xFu+afO5pnlueBKw/uCrq1JmYa VLjqof9DBSyjDu/F/wZsXZ/Hvd634L+RpyHRa4H3tM/nxXX+V5JZbijERDLeai4kQAoCT3/iM DAAA= X-Env-Sender: dunlapg@gmail.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1462956351!31986990!1 X-Originating-IP: [209.85.218.66] X-SpamReason: No, hits=0.3 required=7.0 tests=RCVD_BY_IP X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37860 invoked from network); 11 May 2016 08:45:52 -0000 Received: from mail-oi0-f66.google.com (HELO mail-oi0-f66.google.com) (209.85.218.66) by server-7.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 11 May 2016 08:45:52 -0000 Received: by mail-oi0-f66.google.com with SMTP id i2so5761355oib.3 for ; Wed, 11 May 2016 01:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=+sPA96GGMt981NbYRf4XD5aa6Moa1AkOrdFh1mMpLrs=; b=gCT6gb5FrVb+6YDdpcVbc32AD2EOLFFNtes6ij5meCnPme9dpjhWWVSfsUvsXUH1pK 8+59bSAw0n81auhTbYArOx3vi//VRpdIr7x1V0GX9IlwPQLtknrXT4OnrRlzywrqQMmP APIFzT2M3JSlXcCARaK72nr2HIf8CsWpWzt+jqBN0kCKOr8j00JgH3hhllJH61NqyOMc SibXWs3zRw+sS3mwrRRzL7Q9aZ5lRzBms9rSKDbb8n2NGARNpUUq0D5NOzKq3YGlFZ59 kJiCKtsmQRsSULYDLwZxbbEqLIwDFmufx9MuCt16euAlAgRoinp8zQ7t9wRmKkCAjlBV Ko8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=+sPA96GGMt981NbYRf4XD5aa6Moa1AkOrdFh1mMpLrs=; b=CxZ7rUPd60F9JyWu9BTJGX7lOhMuAD+mJDlLGXuAlHshirYfNzS6BK2GeowwanZV2Z g0jHGxQTSIaEWCruE+DaEuvRm7rmvWCbDxSOczV4B/0m7kobsiNsoInn9cDvty3rvggd ttoPxQYoubGRQ+9UK8IDL00VNgBesy4Rp3SE/GpGwXxMFfBn1M0u3LKXK9/j2OHxgrGS heTUGtjFNs9CdNOMY59I03MHoC1HNtwm3XIE2a5YwgiZ7dnEjQMb/xpjETClBJ+jXx1s FBe9NLS79chhXehmlHoxXy1r2EMatPS7rz/V/A28MctPLZOVIqVUrIG7BWMTmF0wKp5u BMNw== X-Gm-Message-State: AOPr4FUEZPbUn/qYgfhWFnhtBI/MZKjhPvr9JnNPiZUEBv6jZvQ1iiheTKLXacKdDPKa1joBAMsKzvTpw/VEzQ== MIME-Version: 1.0 X-Received: by 10.157.29.201 with SMTP id w9mr1240332otw.196.1462956350647; Wed, 11 May 2016 01:45:50 -0700 (PDT) Received: by 10.202.213.129 with HTTP; Wed, 11 May 2016 01:45:50 -0700 (PDT) In-Reply-To: <945CA011AD5F084CBEA3E851C0AB28894B8AC6DB@SHSMSX101.ccr.corp.intel.com> References: <1462524880-67205-1-git-send-email-quan.xu@intel.com> <1462524880-67205-4-git-send-email-quan.xu@intel.com> <5731BB7602000078000E9E7C@prv-mh.provo.novell.com> <945CA011AD5F084CBEA3E851C0AB28894B8AC6DB@SHSMSX101.ccr.corp.intel.com> Date: Wed, 11 May 2016 09:45:50 +0100 X-Google-Sender-Auth: vCsWnd90Ra3YmkKj5fbhQAqQXeE Message-ID: From: George Dunlap To: "Xu, Quan" Cc: "Tian, Kevin" , Keir Fraser , "Nakajima, Jun" , Andrew Cooper , Dario Faggioli , "xen-devel@lists.xen.org" , Jan Beulich Subject: Re: [Xen-devel] [PATCH v4 03/10] IOMMU/MMU: enhance the call trees of IOMMU unmapping and mapping X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, May 11, 2016 at 3:26 AM, Xu, Quan wrote: > Agreed. Thanks for your careful checking. > > Check it again -- > 1. then I am no need to check 'rc' as below: > > if ( rc == 0 && p2m_is_hostp2m(p2m) && need_iommu(d) && > need_modify_vtd_table ) > { > + if ( !rc ) > + rc = ret; > ... > > + if ( !rc && unlikely(ret) ) > + rc = ret; > } Actually, in the case of iommu_map_page(), you can just use rc directly and not bother using ret at all. (In the case of iommu_unmap_page(), you still need to use ret and check that rc != 0 to make sure you get the first error.) Something like applying the attached patch (not built or nitpicked for style, just for clarity). -George diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 814cb72..f8360c6 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -828,7 +828,7 @@ out: ept_sync_domain(p2m); /* For host p2m, may need to change VT-d page table.*/ - if ( entry_written && p2m_is_hostp2m(p2m) && need_iommu(d) && + if ( rc == 0 && p2m_is_hostp2m(p2m) && need_iommu(d) && need_modify_vtd_table ) { if ( iommu_hap_pt_share ) @@ -838,16 +838,13 @@ out: if ( iommu_flags ) for ( i = 0; i < (1 << order); i++ ) { - ret = iommu_map_page(d, gfn + i, mfn_x(mfn) + i, iommu_flags); + rc = iommu_map_page(d, gfn + i, mfn_x(mfn) + i, iommu_flags); - if ( unlikely(ret) ) + if ( unlikely(rc) ) { while ( i-- ) iommu_unmap_page(p2m->domain, gfn + i); - if ( !rc ) - rc = ret; - break; } }