From patchwork Wed Jul 9 12:07:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 33289 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A8A5023932 for ; Wed, 9 Jul 2014 12:09:10 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id v10sf2577613qac.8 for ; Wed, 09 Jul 2014 05:09:10 -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=Yuh/l+DirU4uIrT8V9hy8WWeNIZREj0M15oWbwuCD0o=; b=BzyGvrHVKqoTTybMeDjv/rOfNaPl+lm5WJxUXLHsMY20xKKFuPwFFvn4hgi7WKVM30 7jTWFRVwtT4iBSXZiHEfYsZ4TZ6+JJcDU3si15+OoPlY4jzEYd3rpPcFzDnuzHDX/Dwd 0Pf3HtVdkRM/vSDLRyvGPT8vnkZnfCQQaI+CLLK6MB4smHwUctwoQEg1QAStJt5tIxTN dnJ4eYeh/aIHGjeMCM2BT9/BkRssxjdZNJnqISp8ecmZc8tqNjiv0EyW2gv/kTMNHsiZ NlXn54aqcxu+NIyrG65G73Q4Q65BGyridXxURHualHYt503kt/Ffe/dZg3ndOJW91AjW cc8A== X-Gm-Message-State: ALoCoQmvOI9htuKoxfbsMfoCC76iMlFt2Q4lxbtYitNZ6W9bIkFocURWC2m5v2Ye8seh5QQZ8ZAI X-Received: by 10.236.207.164 with SMTP id n24mr19762117yho.5.1404907750559; Wed, 09 Jul 2014 05:09:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.72 with SMTP id k66ls2500327qgd.96.gmail; Wed, 09 Jul 2014 05:09:10 -0700 (PDT) X-Received: by 10.58.245.194 with SMTP id xq2mr39656711vec.26.1404907750473; Wed, 09 Jul 2014 05:09:10 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id v15si21404014vcj.8.2014.07.09.05.09.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 05:09:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jx11so156691veb.9 for ; Wed, 09 Jul 2014 05:09:10 -0700 (PDT) X-Received: by 10.58.229.162 with SMTP id sr2mr39089254vec.15.1404907750403; Wed, 09 Jul 2014 05:09:10 -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.37.5 with SMTP id tc5csp41889vcb; Wed, 9 Jul 2014 05:09:10 -0700 (PDT) X-Received: by 10.224.65.134 with SMTP id j6mr17718188qai.90.1404907748623; Wed, 09 Jul 2014 05:09:08 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id b53si7417340qgd.32.2014.07.09.05.09.08 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 09 Jul 2014 05:09:08 -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 1X4qfL-0006Ng-6O; Wed, 09 Jul 2014 12:08:03 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X4qfB-0006JN-Vl for xen-devel@lists.xen.org; Wed, 09 Jul 2014 12:07:55 +0000 Received: from [85.158.143.35:63821] by server-1.bemta-4.messagelabs.com id 9D/17-09496-9903DB35; Wed, 09 Jul 2014 12:07:53 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1404907669!16872645!3 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23578 invoked from network); 9 Jul 2014 12:07:52 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-9.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 9 Jul 2014 12:07:52 -0000 X-IronPort-AV: E=Sophos;i="5.01,631,1400025600"; d="scan'208";a="151203275" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 09 Jul 2014 12:07:52 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Wed, 9 Jul 2014 08:07:51 -0400 Received: from marilith-n13-p0.uk.xensource.com ([10.80.229.115] helo=localhost.localdomain) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1X4qf8-00010w-FS; Wed, 09 Jul 2014 13:07:51 +0100 Received: by localhost.localdomain (sSMTP sendmail emulation); Wed, 09 Jul 2014 13:07:50 +0100 From: Ian Campbell To: Date: Wed, 9 Jul 2014 13:07:42 +0100 Message-ID: <1404907666-8594-4-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1404907608.16789.18.camel@kazak.uk.xensource.com> References: <1404907608.16789.18.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 v5 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.178 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));