From patchwork Thu Oct 2 10:02:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38287 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 84B8C20549 for ; Thu, 2 Oct 2014 10:06:39 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id n3sf330064wiv.8 for ; Thu, 02 Oct 2014 03:06:38 -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=3f5wzbypQ8vD/rC1bykXFwKnpL4kfkKgYQUHpslt2L8=; b=jJxNpx22FpQIrqYOTyoCA1dHZXFE8jj9ndtfaqSMHJTL7nWTwoPdWHIunvZuR0ZunP ce6/rJ/2NRJRMV+tE2pum9whCPdlC1eIN57QqKOfZhR0CySh8Ccelgtg1XVUxt42UdaI eMwRkqLuKvJwri37VmgqGNf0a1OunXAVo2QpMm2yZgY13MebHUvy/eJ0+JX8ckINqzCk DOGJQumKAAbTcWNG06UsVEaZL5crCHVTCj+yWxpG5Z2hs8tDs3Yz63QCZ+srNBkbOdH1 T3KdR9r31xCAFwxlrk8dZ6AO9Km+2cvQV95WqZlwgw1th3RZYXeKprujRcCY5tbkCdtO DUpA== X-Gm-Message-State: ALoCoQmrbKU5xZKNMzaC1oot5ydEOiIw9KMf5aecHifsg29Y8zFElw7sbX+Ffkb/ha36ongBcO// X-Received: by 10.181.28.169 with SMTP id jp9mr451542wid.6.1412244398747; Thu, 02 Oct 2014 03:06:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.226 with SMTP id d2ls244206lab.66.gmail; Thu, 02 Oct 2014 03:06:38 -0700 (PDT) X-Received: by 10.152.27.66 with SMTP id r2mr31937402lag.84.1412244398490; Thu, 02 Oct 2014 03:06:38 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com [209.85.215.45]) by mx.google.com with ESMTPS id d9si5675427laf.133.2014.10.02.03.06.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 03:06:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id q1so2023177lam.18 for ; Thu, 02 Oct 2014 03:06:38 -0700 (PDT) X-Received: by 10.112.134.229 with SMTP id pn5mr32350856lbb.22.1412244398285; Thu, 02 Oct 2014 03:06:38 -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.112.130.169 with SMTP id of9csp25667lbb; Thu, 2 Oct 2014 03:06:37 -0700 (PDT) X-Received: by 10.220.100.10 with SMTP id w10mr48555633vcn.2.1412244397110; Thu, 02 Oct 2014 03:06:37 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id w7si2768316vcn.49.2014.10.02.03.06.36 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 Oct 2014 03:06:37 -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 1XZdFq-0001BD-C4; Thu, 02 Oct 2014 10:04:58 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZdFo-00019m-5l for xen-devel@lists.xensource.com; Thu, 02 Oct 2014 10:04:56 +0000 Received: from [85.158.139.211:38006] by server-6.bemta-5.messagelabs.com id D6/A6-06284-7432D245; Thu, 02 Oct 2014 10:04:55 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1412244292!11575707!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.12.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31470 invoked from network); 2 Oct 2014 10:04:54 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-12.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 2 Oct 2014 10:04:54 -0000 X-IronPort-AV: E=Sophos;i="5.04,638,1406592000"; d="scan'208";a="177412877" 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, 2 Oct 2014 06:04:51 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XZdFe-0001pd-MR; Thu, 02 Oct 2014 11:04:46 +0100 From: Stefano Stabellini To: Date: Thu, 2 Oct 2014 11:02:36 +0100 Message-ID: <1412244158-12124-2-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@citrix.com, tim@xen.org, Ian.Campbell@citrix.com, jbeulich@suse.com, Stefano Stabellini Subject: [Xen-devel] [PATCH 2/4] xen: introduce grant_map_exists 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: stefano.stabellini@eu.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.215.45 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: Check whether an mfn has been granted to a given domain on a target grant table. Signed-off-by: Stefano Stabellini CC: jbeulich@suse.com CC: tim@xen.org --- xen/common/grant_table.c | 32 ++++++++++++++++++++++++++++++++ xen/include/xen/grant_table.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 23266c3..e1dc330 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -484,6 +484,38 @@ static int _set_status(unsigned gt_version, return _set_status_v2(domid, readonly, mapflag, shah, act, status); } +bool_t grant_map_exists(struct domain *ld, + struct grant_table *rgt, + unsigned long mfn) +{ + struct active_grant_entry *act; + grant_ref_t ref; + bool_t ret = 0; + + spin_lock(&rgt->lock); + + for ( ref = 0; ref != nr_grant_entries(rgt); ref++ ) + { + act = &active_entry(rgt, ref); + + if ( !act->pin ) + continue; + + if ( act->domid != ld->domain_id ) + continue; + + if ( act->frame != mfn ) + continue; + + ret = 1; + break; + } + + spin_unlock(&rgt->lock); + + return ret; +} + static void mapcount( struct grant_table *lgt, struct domain *rd, unsigned long mfn, unsigned int *wrc, unsigned int *rdc) diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h index 5941191..2df390f 100644 --- a/xen/include/xen/grant_table.h +++ b/xen/include/xen/grant_table.h @@ -97,6 +97,10 @@ int grant_table_create( void grant_table_destroy( struct domain *d); +bool_t grant_map_exists(struct domain *ld, + struct grant_table *rgt, + unsigned long mfn); + /* Domain death release of granted mappings of other domains' memory. */ void gnttab_release_mappings(