From patchwork Tue Jul 1 15:16:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 32903 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 DC68020DCC for ; Tue, 1 Jul 2014 15:18:25 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id i8sf22071627qcq.8 for ; Tue, 01 Jul 2014 08:18:25 -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:cc:subject :precedence:list-id:list-unsubscribe:list-post:list-help :list-subscribe:mime-version:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive :content-type:content-transfer-encoding; bh=GYYYUlSYXnumItjth0eRE+jExrafb75P/kQO3N9JplM=; b=QQopnlsjMAXQUQKpbV1JVTa74t77gTUG2uNkcLT5sWmrrJ1iA0WaZVE1CUSWy+gJst TuN7NmJgKuC6xQx1Cw+4aC2RVQwRmyCqE3BR2FbL2OF7Y0zE8/qQWFrHpAEYi3b4jMx5 Sb6pOVJpt9y3Vrvxl2ZQF8qb1QZD5nANKAM965n3OmmL+j6OUgUI17BgynEZKK738Thk BTG0FQqeytg5JNoOEeoUS6Z6+Nz56s7MnyXCv+NVefUblY1LLhQY82s1Hmz3Oe2N+5yS EMpRgy6XvUiag5tLit4PVDR6zOtRv4FQSUdwSYs0byLpTJ4HismDWV7CKSaH9/inQxm5 CgYA== X-Gm-Message-State: ALoCoQmYoUzizyej+5UzVrLhVfU+TuvlwrDlFoeofxvP3FuDB86K0gRlMq9bjRwWroQAYTsroFpt X-Received: by 10.52.36.211 with SMTP id s19mr21933056vdj.7.1404227905227; Tue, 01 Jul 2014 08:18:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.50 with SMTP id i47ls2037143qgd.38.gmail; Tue, 01 Jul 2014 08:18:25 -0700 (PDT) X-Received: by 10.220.17.199 with SMTP id t7mr39667441vca.1.1404227905093; Tue, 01 Jul 2014 08:18:25 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id uc3si11545615vec.97.2014.07.01.08.18.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Jul 2014 08:18:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.182 as permitted sender) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id oy12so9815867veb.13 for ; Tue, 01 Jul 2014 08:18:25 -0700 (PDT) X-Received: by 10.52.244.81 with SMTP id xe17mr867714vdc.24.1404227904989; Tue, 01 Jul 2014 08:18:24 -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 tc5csp222824vcb; Tue, 1 Jul 2014 08:18:24 -0700 (PDT) X-Received: by 10.58.186.172 with SMTP id fl12mr1193514vec.39.1404227904143; Tue, 01 Jul 2014 08:18:24 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ta7si4128669veb.78.2014.07.01.08.18.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 01 Jul 2014 08:18:24 -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 1X1znv-0002VN-GT; Tue, 01 Jul 2014 15:17:07 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X1znt-0002VB-MF for xen-devel@lists.xenproject.org; Tue, 01 Jul 2014 15:17:05 +0000 Received: from [85.158.137.68:59517] by server-9.bemta-3.messagelabs.com id 93/25-09496-1F0D2B35; Tue, 01 Jul 2014 15:17:05 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-8.tower-31.messagelabs.com!1404227824!13420264!1 X-Originating-IP: [209.85.212.176] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7766 invoked from network); 1 Jul 2014 15:17:04 -0000 Received: from mail-wi0-f176.google.com (HELO mail-wi0-f176.google.com) (209.85.212.176) by server-8.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 1 Jul 2014 15:17:04 -0000 Received: by mail-wi0-f176.google.com with SMTP id n3so8006987wiv.3 for ; Tue, 01 Jul 2014 08:17:03 -0700 (PDT) X-Received: by 10.194.5.103 with SMTP id r7mr53465662wjr.41.1404227820272; Tue, 01 Jul 2014 08:17:00 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id u10sm44327860wix.11.2014.07.01.08.16.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Jul 2014 08:16:59 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 1 Jul 2014 16:16:55 +0100 Message-Id: <1404227815-8661-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH] xen/arm: Drop reference on foreign page when guest_physmap_add_entry has failed 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: , MIME-Version: 1.0 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: julien.grall@linaro.org 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.182 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: When a foreign page is added to the guest p2m, we take a reference on this page. Currently if the mapping has failed when a leak a reference, this will result to the guest will foreign guest will became a zombie as soon as it's destroyed. Signed-off-by: Julien Grall --- xen/arch/arm/mm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 7e8e06a..03a0533 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -994,6 +994,7 @@ int xenmem_add_to_physmap_one( unsigned long mfn = 0; int rc; p2m_type_t t; + struct page_info *page = NULL; switch ( space ) { @@ -1041,7 +1042,6 @@ int xenmem_add_to_physmap_one( case XENMAPSPACE_gmfn_foreign: { struct domain *od; - struct page_info *page; p2m_type_t p2mt; od = rcu_lock_domain_by_any_id(foreign_domid); if ( od == NULL ) @@ -1091,6 +1091,14 @@ int xenmem_add_to_physmap_one( /* Map at new location. */ rc = guest_physmap_add_entry(d, gpfn, mfn, 0, t); + /* If we fail to add the mapping, we need to drop the reference we + * took earlier on foreign pages */ + if ( rc && space == XENMAPSPACE_gmfn_foreign ) + { + ASSERT(page != NULL); + put_page(page); + } + return rc; }