From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andres Lagar-Cavilla Subject: [PATCH 2 of 2] Correct p2m unlocking during grant table map Date: Fri, 13 Jan 2012 00:33:39 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: andres@gridcentric.ca, tim@xen.org, adin@gridcentric.ca List-Id: xen-devel@lists.xenproject.org xen/common/grant_table.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) We were not putting gfn's consistently. Signed-off-by: Andres Lagar-Cavilla diff -r 1ab50ad829d6 -r abdb908c0aed xen/common/grant_table.c --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -141,7 +141,7 @@ shared_entry_header(struct grant_table * #define active_entry(t, e) \ ((t)->active[(e)/ACGNT_PER_PAGE][(e)%ACGNT_PER_PAGE]) -/* Check if the page has been paged out */ +/* Check if the page has been paged out. If rc == GNTST_okay, caller must do put_gfn(rd, gfn) */ static int __get_paged_frame(unsigned long gfn, unsigned long *frame, int readonly, struct domain *rd) { int rc = GNTST_okay; @@ -573,7 +573,10 @@ __gnttab_map_grant_ref( gfn = sha1 ? sha1->frame : sha2->full_page.frame; rc = __get_paged_frame(gfn, &frame, !!(op->flags & GNTMAP_readonly), rd); if ( rc != GNTST_okay ) + { + gfn = INVALID_GFN; goto unlock_out; + } act->gfn = gfn; act->domid = ld->domain_id; act->frame = frame; @@ -700,7 +703,8 @@ __gnttab_map_grant_ref( op->handle = handle; op->status = GNTST_okay; - put_gfn(rd, gfn); + if ( gfn != INVALID_GFN ) + put_gfn(rd, gfn); rcu_unlock_domain(rd); return;