From patchwork Fri Oct 3 14:50:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38324 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7A8B420F2E for ; Fri, 3 Oct 2014 14:54:35 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id cc10sf917677wib.3 for ; Fri, 03 Oct 2014 07:54:34 -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=nuuLXNBP8wI30I/g53NV0Z1spMceG7B8tOqFj4dty38=; b=HAd6bM6B2427mudizIsvENI6PNl2LQTKPaz3j6cm6nvEEMm/21FrDn+n839vJCbUwT UyqQzk6bOsY/DcvYIHoavJOiiGvzPiVN5ODHTSSEKKHfnF4rOv9iASl0zX58V3204h6f 6C9Dm3qH6t1kDHmXFlyZIC4Qz4cOufb/r+UP2Lhyr6ylfm/z22AWfhE/9TAo/JhfjE31 gtAAjaOCdWGPlDX+frwzefv/zv1AYaUiTq4fJvD9ATE3D61Y2LiZCj09Ot1csYoo9Gla hHdQ7Wjh8k+06+R9ubA9DvbucI7YtBT44D6G0wrdF4/g3JZtOsBkr7mLqGkIYrWGyePA XQfw== X-Gm-Message-State: ALoCoQkYZNHbHVE38CZkbkYlP4OEoaF/cec42qWR369CRErzoMqstEltWGe9os0tE0h69ooceISr X-Received: by 10.180.74.14 with SMTP id p14mr1914343wiv.6.1412348074718; Fri, 03 Oct 2014 07:54:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.97 with SMTP id u1ls328175lae.105.gmail; Fri, 03 Oct 2014 07:54:34 -0700 (PDT) X-Received: by 10.152.9.37 with SMTP id w5mr6563708laa.28.1412348074531; Fri, 03 Oct 2014 07:54:34 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id rm7si11596217lbb.55.2014.10.03.07.54.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 Oct 2014 07:54:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id w7so1169871lbi.9 for ; Fri, 03 Oct 2014 07:54:34 -0700 (PDT) X-Received: by 10.112.4.33 with SMTP id h1mr5966097lbh.67.1412348074370; Fri, 03 Oct 2014 07:54:34 -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 of9csp242185lbb; Fri, 3 Oct 2014 07:54:33 -0700 (PDT) X-Received: by 10.220.133.1 with SMTP id d1mr4384633vct.5.1412348072556; Fri, 03 Oct 2014 07:54:32 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id rx7si4522722vdc.93.2014.10.03.07.54.27 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 03 Oct 2014 07:54:32 -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 1Xa4Ea-0002y5-NF; Fri, 03 Oct 2014 14:53:28 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xa4EZ-0002xc-J2 for xen-devel@lists.xensource.com; Fri, 03 Oct 2014 14:53:27 +0000 Received: from [85.158.137.68:64850] by server-15.bemta-3.messagelabs.com id BD/F0-01573-668BE245; Fri, 03 Oct 2014 14:53:26 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1412348005!11364255!1 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 1728 invoked from network); 3 Oct 2014 14:53:26 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-2.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 3 Oct 2014 14:53:26 -0000 X-IronPort-AV: E=Sophos;i="5.04,647,1406592000"; d="scan'208";a="177906021" 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; Fri, 3 Oct 2014 10:52:59 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xa4E2-0000Fl-AP; Fri, 03 Oct 2014 15:52:54 +0100 From: Stefano Stabellini To: Date: Fri, 3 Oct 2014 15:50:43 +0100 Message-ID: <1412347845-27755-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, Ian.Campbell@citrix.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v2 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.217.178 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 --- Changes in v2: - make the function static; - remove the spin_lock. --- xen/common/grant_table.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 23266c3..7a6399b 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -484,6 +484,36 @@ static int _set_status(unsigned gt_version, return _set_status_v2(domid, readonly, mapflag, shah, act, status); } +static 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; + + ASSERT(&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; + } + + return ret; +} + static void mapcount( struct grant_table *lgt, struct domain *rd, unsigned long mfn, unsigned int *wrc, unsigned int *rdc)