From patchwork Thu Jun 26 10:17:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 32546 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 362B32066E for ; Thu, 26 Jun 2014 10:19:01 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id uz6sf18167744obc.8 for ; Thu, 26 Jun 2014 03:19:00 -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=a4rnYFpiEcQYDEtGKOOZnMRwm94Gsep39VTWm6HW3bCw1c/TBmmJ8Fth74mRF9Xspr DXkxKGVWip2Po4TReouI2oSqHkzKgZEBbr6JOQ1KUnkT4gBS1g1CP0AhZQrQij+j5T0A 4cEej05OMkvG55gZT440fqDdjzjQ5W0/jd5WnyqeQXJf8v3YsV5oP7HknqBQo5V6Tf/h ikz7b6EI50mt7GYM6wuuOLjOtwKf1rgRI/2wvdQNu95SKW0OcSeWqK5OyTEsb1gI1VSj jtwopUCrqnxU9yJMrwjOUlVq2j3CDNAqrbEYy78uPTCIFHJTDQJRvtbImMnX+hfGH2Ay nU2Q== X-Gm-Message-State: ALoCoQkJfB1aMCh7jvx4nalqfIO7Yw/XtbEbHhY2/Lx58DJZ91s36Bqoo14kqiRZCGITt3+qNm07 X-Received: by 10.50.73.35 with SMTP id i3mr1617370igv.2.1403777940802; Thu, 26 Jun 2014 03:19:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.198 with SMTP id h64ls110170qgf.66.gmail; Thu, 26 Jun 2014 03:19:00 -0700 (PDT) X-Received: by 10.52.255.65 with SMTP id ao1mr1404967vdd.43.1403777940718; Thu, 26 Jun 2014 03:19:00 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id hk8si4044338vdb.79.2014.06.26.03.19.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Jun 2014 03:19:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id id10so3296485vcb.10 for ; Thu, 26 Jun 2014 03:19:00 -0700 (PDT) X-Received: by 10.58.118.168 with SMTP id kn8mr567446veb.44.1403777940609; Thu, 26 Jun 2014 03:19:00 -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 tc5csp19457vcb; Thu, 26 Jun 2014 03:19:00 -0700 (PDT) X-Received: by 10.140.80.144 with SMTP id c16mr19217492qgd.79.1403777939508; Thu, 26 Jun 2014 03:18:59 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id m100si8622527qga.3.2014.06.26.03.18.59 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 26 Jun 2014 03:18:59 -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 1X06k7-00066G-D7; Thu, 26 Jun 2014 10:17:23 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X06k5-00065L-RR for xen-devel@lists.xen.org; Thu, 26 Jun 2014 10:17:22 +0000 Received: from [85.158.143.35:58619] by server-3.bemta-4.messagelabs.com id B9/D6-16194-133FBA35; Thu, 26 Jun 2014 10:17:21 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1403777838!5974012!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 12778 invoked from network); 26 Jun 2014 10:17:20 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-2.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 26 Jun 2014 10:17:20 -0000 X-IronPort-AV: E=Sophos;i="5.01,552,1400025600"; d="scan'208";a="147517490" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 26 Jun 2014 10:17:18 +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; Thu, 26 Jun 2014 06:17:17 -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 1X06k1-0004Wh-HX; Thu, 26 Jun 2014 11:17:17 +0100 From: Ian Campbell To: Date: Thu, 26 Jun 2014 11:17:13 +0100 Message-ID: <1403777837-16779-4-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1403777793.16595.21.camel@kazak.uk.xensource.com> References: <1403777793.16595.21.camel@kazak.uk.xensource.com> 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 v3 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.220.179 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));