Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965023AbeAJDGE (ORCPT + 1 other); Tue, 9 Jan 2018 22:06:04 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48186 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752252AbeAJDGD (ORCPT ); Tue, 9 Jan 2018 22:06:03 -0500 Subject: Re: [PATCH 2/2] xen/gntdev: Fix partial gntdev_mmap() cleanup To: Ross Lagerwall , xen-devel@lists.xenproject.org Cc: Juergen Gross , linux-kernel@vger.kernel.org References: <20180109121022.11467-1-ross.lagerwall@citrix.com> <20180109121022.11467-2-ross.lagerwall@citrix.com> From: Boris Ostrovsky Message-ID: Date: Tue, 9 Jan 2018 20:22:56 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180109121022.11467-2-ross.lagerwall@citrix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8769 signatures=668652 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801100038 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 01/09/2018 07:10 AM, Ross Lagerwall wrote: > When cleaning up after a partially successful gntdev_mmap(), unmap the > successfully mapped grant pages otherwise Xen will kill the domain if > in debug mode (Attempt to implicitly unmap a granted PTE) or Linux will > kill the process and emit "BUG: Bad page map in process" if Xen is in > release mode. > > This is only needed when use_ptemod is true because gntdev_put_map() > will unmap grant pages itself when use_ptemod is false. > > Signed-off-by: Ross Lagerwall Reviewed-by: Boris Ostrovsky although I wonder whether it may be possible to have gntdev_put_map() figure whether to unmap the pages if use_ptemod is set. > --- > drivers/xen/gntdev.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c > index d3391a1..bd56653 100644 > --- a/drivers/xen/gntdev.c > +++ b/drivers/xen/gntdev.c > @@ -1071,8 +1071,10 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) > out_unlock_put: > mutex_unlock(&priv->lock); > out_put_map: > - if (use_ptemod) > + if (use_ptemod) { > map->vma = NULL; > + unmap_grant_pages(map, 0, map->count); > + } > gntdev_put_map(priv, map); > return err; > } >