From patchwork Wed Oct 23 16:28:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 21233 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 607CC20F5A for ; Wed, 23 Oct 2013 16:29:02 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id n12sf3323904oag.0 for ; Wed, 23 Oct 2013 09:29:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=b2T/+5A6Gp9c8AH+xpy17nROR/UyvwmSIGuAhPp3laA=; b=eQsdfKubr0Q29Yc3DZHHpF2z8FCdZwoy6qPoMmVS5yyR6eJc0NpjGwRze7odtKTsSE iMBs7soFSukcctA/nvQLMCJu1IaDBpJbUCCoUp6t7UtRBolLsaT4inTTXdGq/XsQWmAJ tqVEzAS1yT8AuAvck90V+jO0VlLhRA03qWIkqiAkjmSQGAC9DQ1M651U7sbxp19KgdbI OCuMXlRkchO/HKQhZEO6LphtJJsPlWYxkdyNifrfgpup9nMuczo3R8dhdr0IRalqePmB qkDwA3/Aj8a0H7GHKKXjxUqFR8qY64fYN8rk6i5MP0UOi7zptL8vLoHF1sEOp6XMZX/h s9Kw== X-Received: by 10.182.66.75 with SMTP id d11mr888182obt.49.1382545741408; Wed, 23 Oct 2013 09:29:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.74.198 with SMTP id w6ls547056qev.9.gmail; Wed, 23 Oct 2013 09:29:01 -0700 (PDT) X-Received: by 10.220.47.10 with SMTP id l10mr1067089vcf.32.1382545741274; Wed, 23 Oct 2013 09:29:01 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id bl10si7385503vcb.84.2013.10.23.09.29.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 09:29:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id id10so659478vcb.40 for ; Wed, 23 Oct 2013 09:29:01 -0700 (PDT) X-Gm-Message-State: ALoCoQnRSNXx4TBKw3iidb6YPfjJ335qXnI1u+Qdo5LI+R38+PnTkt1r0oVr+j9GqOJ5t9CeRJml X-Received: by 10.220.74.69 with SMTP id t5mr1764960vcj.18.1382545741137; Wed, 23 Oct 2013 09:29:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp324393vcz; Wed, 23 Oct 2013 09:29:00 -0700 (PDT) X-Received: by 10.194.240.197 with SMTP id wc5mr2490426wjc.23.1382545740194; Wed, 23 Oct 2013 09:29:00 -0700 (PDT) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id vt5si9721169wjc.113.2013.10.23.09.28.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 09:29:00 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.178; Received: by mail-we0-f178.google.com with SMTP id q59so1065933wes.37 for ; Wed, 23 Oct 2013 09:28:59 -0700 (PDT) X-Received: by 10.180.24.197 with SMTP id w5mr2889627wif.8.1382545739561; Wed, 23 Oct 2013 09:28:59 -0700 (PDT) Received: from localhost.localdomain ([109.144.228.239]) by mx.google.com with ESMTPSA id ey4sm18640430wic.11.2013.10.23.09.28.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Oct 2013 09:28:59 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: ian.campbell@citrix.com, tim@xen.org, patches@linaro.org, stefano.stabellini@eu.citrix.com, Julien Grall Subject: [PATCH] xen/arm: add_to_physmap_one: Avoid to map mfn 0 if an error occurs Date: Wed, 23 Oct 2013 17:28:47 +0100 Message-Id: <1382545727-6595-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , By default, the function add_to_physmap_one set mfn to 0. Some code paths that result to an error, continue and the map the mfn 0 (valid on ARM) to the slot given by the guest. To fix the problem, return directly an error if sanity check has failed. Signed-off-by: Julien Grall Acked-by: Tim Deegan Acked-by: Stefano Stabellini --- xen/arch/arm/mm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 474dfef..eaeb0c3 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -981,6 +981,8 @@ static int xenmem_add_to_physmap_one( idx &= ~XENMAPIDX_grant_table_status; if ( idx < nr_status_frames(d->grant_table) ) mfn = virt_to_mfn(d->grant_table->status[idx]); + else + return -EINVAL; } else { @@ -990,6 +992,8 @@ static int xenmem_add_to_physmap_one( if ( idx < nr_grant_frames(d->grant_table) ) mfn = virt_to_mfn(d->grant_table->shared_raw[idx]); + else + return -EINVAL; } d->arch.grant_table_gpfn[idx] = gpfn; @@ -999,6 +1003,8 @@ static int xenmem_add_to_physmap_one( case XENMAPSPACE_shared_info: if ( idx == 0 ) mfn = virt_to_mfn(d->shared_info); + else + return -EINVAL; break; case XENMAPSPACE_gmfn_foreign: {