From patchwork Wed Jun 11 16:40:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 31790 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 27C1B2054B for ; Wed, 11 Jun 2014 16:41:18 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id hz1sf8718995pad.11 for ; Wed, 11 Jun 2014 09:41:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=ZBnaGqGdYucpBOORD2oWOH5BZh+CE1R4PR2n+R2xXoM=; b=IslrXzGF2oqxitA1WVXkCwGM87N7aMazH5zwp2rRcvn2Ktb5Dg1fQSCiRQZmSVijud lwH0J1jTmwRGkdVW87ILLVQciCuB/QYNsvJJsx3Asy5V/9b4TpgmwVM0OAWFFsludaXn JFnE0I+qrU74h0fG4svjDr0QMTJCmX+uSnAcrXPWcPKcLWujx2iO4c8FJzar2j0GmT/8 QR+OrYLFk6smBr2vtEz7gzj84g7Y8B15efsRg0W1SW+wBcttf7uMOIT5z+xPfMJmIZNX CEHcqFtpj/sdD2m9Vt3oAyh1xAQ+X4BL5WzwQdCpnE3kcTh0z8waXNRBeFdYfntdgJzr eAUw== X-Gm-Message-State: ALoCoQlNVknLF/sZv3ZIvMkWQ11j4MoA5tEXP/NxsHKpjdkMQAIWCYamryAfIu8VHvFfKDyeDKpr X-Received: by 10.67.23.41 with SMTP id hx9mr1062442pad.8.1402504877248; Wed, 11 Jun 2014 09:41:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.36.14 with SMTP id o14ls2618012qgo.63.gmail; Wed, 11 Jun 2014 09:41:17 -0700 (PDT) X-Received: by 10.220.250.203 with SMTP id mp11mr39656684vcb.2.1402504877073; Wed, 11 Jun 2014 09:41:17 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id sk10si1859481vec.81.2014.06.11.09.41.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Jun 2014 09:41:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id db11so5964335veb.26 for ; Wed, 11 Jun 2014 09:41:17 -0700 (PDT) X-Received: by 10.52.135.208 with SMTP id pu16mr3940818vdb.8.1402504876990; Wed, 11 Jun 2014 09:41:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp317876vcb; Wed, 11 Jun 2014 09:41:16 -0700 (PDT) X-Received: by 10.224.165.70 with SMTP id h6mr53952927qay.78.1402504876333; Wed, 11 Jun 2014 09:41:16 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id m2si32143197qag.32.2014.06.11.09.41.15 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 11 Jun 2014 09:41:16 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WulZX-000171-QN; Wed, 11 Jun 2014 16:40:23 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WulZV-000158-GH for xen-devel@lists.xen.org; Wed, 11 Jun 2014 16:40:21 +0000 Received: from [85.158.143.35:10080] by server-3.bemta-4.messagelabs.com id 66/10-13602-37688935; Wed, 11 Jun 2014 16:40:19 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1402504816!10734442!3 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8443 invoked from network); 11 Jun 2014 16:40:19 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 11 Jun 2014 16:40:19 -0000 X-IronPort-AV: E=Sophos;i="5.01,459,1400025600"; d="scan'208";a="142556074" Received: from accessns.citrite.net (HELO FTLPEX01CL01.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 11 Jun 2014 16:40:05 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Wed, 11 Jun 2014 12:40:05 -0400 Received: from marilith-n13-p0.uk.xensource.com ([10.80.229.115] helo=marilith-n13.uk.xensource.com.) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1WulZE-0004h3-V0; Wed, 11 Jun 2014 17:40:05 +0100 From: Ian Campbell To: Date: Wed, 11 Jun 2014 17:40:00 +0100 Message-ID: <1402504804-29173-4-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1402504640.16332.50.camel@kazak.uk.xensource.com> References: <1402504640.16332.50.camel@kazak.uk.xensource.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH v2 4/8] xen: arm: only put_page for p2m operations which require it. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: In particular do not do it for CACHEFLUSH. INSERT, RELINQUISH and REMOVE should all put the page (if the current pte is valid). ALLOCATE doesn't need to since it asserts the current PTE must be invalid. Signed-off-by: Ian Campbell Acked-by: Julien Grall --- v2: actual move the put page instead of adding a second one. --- xen/arch/arm/p2m.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 9960e17..ea05b6d 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -299,6 +299,23 @@ enum p2m_operation { CACHEFLUSH, }; +static void p2m_put_page(const lpae_t pte) +{ + /* TODO: Handle other p2m types + * + * It's safe to do the put_page here because page_alloc will + * flush the TLBs if the page is reallocated before the end of + * this loop. + */ + if ( p2m_is_foreign(pte.p2m.type) ) + { + unsigned long mfn = pte.p2m.base; + + ASSERT(mfn_valid(mfn)); + put_page(mfn_to_page(mfn)); + } +} + static int apply_p2m_changes(struct domain *d, enum p2m_operation op, paddr_t start_gpaddr, @@ -400,20 +417,6 @@ static int apply_p2m_changes(struct domain *d, flush |= pte.p2m.valid; - /* TODO: Handle other p2m type - * - * It's safe to do the put_page here because page_alloc will - * flush the TLBs if the page is reallocated before the end of - * this loop. - */ - if ( pte.p2m.valid && p2m_is_foreign(pte.p2m.type) ) - { - unsigned long mfn = pte.p2m.base; - - ASSERT(mfn_valid(mfn)); - put_page(mfn_to_page(mfn)); - } - switch (op) { case ALLOCATE: { @@ -436,6 +439,8 @@ static int apply_p2m_changes(struct domain *d, break; case INSERT: { + if ( pte.p2m.valid ) + p2m_put_page(pte); pte = mfn_to_p2m_entry(maddr >> PAGE_SHIFT, mattr, t); p2m_write_pte(&third[third_table_offset(addr)], pte, flush_pt); @@ -451,6 +456,8 @@ static int apply_p2m_changes(struct domain *d, break; } + p2m_put_page(pte); + count += 0x10; memset(&pte, 0x00, sizeof(pte));