From patchwork Tue Jul 1 08:26:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 32859 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ED84B203C0 for ; Tue, 1 Jul 2014 08:29:23 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id i8sf20875280qcq.0 for ; Tue, 01 Jul 2014 01:29:23 -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=aFejDInE7u92CCxFbzSg3EDkDWIAxUf8xQ9gof7hIqMOZgWea15LlsR157Hj3EVh8Y SUzl6VsN+q1oqdiFWgPpzyM719KQPLEEJCpFTVRswfqvNO5CwcBu6h65t72wb2P/9THL Ky7T8fl7o2spV0v05p4Ndgbo5SFYNwoLbjprC7e/9tb69uL/DUDMepJjVapTf5JAWnTg IvqD9Wp/xxF5CX3Z9CzDGAOokKMSaHqOuowqc9JsHbBsgTL5MkK2IYdd836kuSOIQZr/ ronXAWwhDi298KWgz3/+C7EfuHljuRCexWu+mNzZRW41aEkl3jsR6xRaqzWuMd3JhJfW 3Mjw== X-Gm-Message-State: ALoCoQm7B2n5hxXOmKn21sfqgrRVIIYAC/YWR0+m1jtu7Kqav8wpKX81KesMhQHTZql/wThbZJI9 X-Received: by 10.236.171.234 with SMTP id r70mr2785515yhl.45.1404203363830; Tue, 01 Jul 2014 01:29:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.239 with SMTP id l102ls1822885qgd.81.gmail; Tue, 01 Jul 2014 01:29:23 -0700 (PDT) X-Received: by 10.52.248.146 with SMTP id ym18mr36173032vdc.8.1404203363751; Tue, 01 Jul 2014 01:29:23 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id fn3si3691882vec.42.2014.07.01.01.29.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Jul 2014 01:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jz11so9273077veb.17 for ; Tue, 01 Jul 2014 01:29:23 -0700 (PDT) X-Received: by 10.220.177.133 with SMTP id bi5mr37346243vcb.26.1404203363677; Tue, 01 Jul 2014 01:29:23 -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 tc5csp198715vcb; Tue, 1 Jul 2014 01:29:23 -0700 (PDT) X-Received: by 10.140.82.113 with SMTP id g104mr66885945qgd.55.1404203363201; Tue, 01 Jul 2014 01:29:23 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id 94si28628026qgl.70.2014.07.01.01.29.22 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 01 Jul 2014 01:29:23 -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 1X1tPb-0000k1-G2; Tue, 01 Jul 2014 08:27:35 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X1tPa-0000jh-9b for xen-devel@lists.xen.org; Tue, 01 Jul 2014 08:27:34 +0000 Received: from [193.109.254.147:59317] by server-10.bemta-14.messagelabs.com id 11/F6-01431-5F072B35; Tue, 01 Jul 2014 08:27:33 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1404203251!14679715!2 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 3948 invoked from network); 1 Jul 2014 08:27:32 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-7.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 1 Jul 2014 08:27:32 -0000 X-IronPort-AV: E=Sophos;i="5.01,580,1400025600"; d="scan'208";a="148822953" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 01 Jul 2014 08:27:03 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.3.181.6; Tue, 1 Jul 2014 04:27:02 -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 1X1tP4-0008Hn-L3; Tue, 01 Jul 2014 09:27:02 +0100 From: Ian Campbell To: Date: Tue, 1 Jul 2014 09:26:57 +0100 Message-ID: <1404203222-30111-4-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1404202883.1829.125.camel@dagon.hellion.org.uk> References: <1404202883.1829.125.camel@dagon.hellion.org.uk> MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH v4 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.172 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));