From patchwork Sun Dec 15 20:13:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Pakki X-Patchwork-Id: 11293371 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D37F930 for ; Mon, 16 Dec 2019 05:20:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE03C20717 for ; Mon, 16 Dec 2019 05:20:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=umn.edu header.i=@umn.edu header.b="DAEclJHh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE03C20717 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=umn.edu Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1igimy-0006UF-Pl; Mon, 16 Dec 2019 05:19:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1igaGr-0003xT-Ss for xen-devel@lists.xenproject.org; Sun, 15 Dec 2019 20:13:41 +0000 X-Inumbo-ID: 5deb11e6-1f77-11ea-a914-bc764e2007e4 Received: from mta-p8.oit.umn.edu (unknown [134.84.196.208]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5deb11e6-1f77-11ea-a914-bc764e2007e4; Sun, 15 Dec 2019 20:13:32 +0000 (UTC) Received: from localhost (unknown [127.0.0.1]) by mta-p8.oit.umn.edu (Postfix) with ESMTP id 47bbFS351Rz9vY78 for ; Sun, 15 Dec 2019 20:13:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p8.oit.umn.edu ([127.0.0.1]) by localhost (mta-p8.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JRPeiZTjgWYN for ; Sun, 15 Dec 2019 14:13:32 -0600 (CST) Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p8.oit.umn.edu (Postfix) with ESMTPS id 47bbFS27Srz9vY6y for ; Sun, 15 Dec 2019 14:13:32 -0600 (CST) Received: by mail-yb1-f197.google.com with SMTP id e11so4971191ybn.12 for ; Sun, 15 Dec 2019 12:13:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EV3d9IrHuviw6NuP0prZ+L56BjgZrxEmg7Osn+ldLeY=; b=DAEclJHhiwU1JiAx6Swl3XCgRzafLipHbCsIVaj5z9LYNzqOAZW9w5kdRSlZOPBnPH xnE2+TXUGknqfCVyu2aHgFsJjQug1n+ub63TfO56HYcLSpv7VIQFKLB3q4BvCFC3vIj1 miQxJXXvjQof9NQmXTeaJ1k6zeRPguw0aYkMu6lEVdUWNt5JDIzMat8B46oT4XxrWtD6 c759KpV05FW/3kQsaGejmQrlUNY3JAa+iUoIm7yumiJl8zor7MDuveDZQ2K8RKV/2ywD 5IIMq61m0nCcXdoE9TFqZN/KWG65/jfwahOWr1Ev/+o/bl3phO5KCp19FQIvlBA5Z8Wc 505w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EV3d9IrHuviw6NuP0prZ+L56BjgZrxEmg7Osn+ldLeY=; b=Fm+2x+lY/Pwmf/lWN0AKMRhJz8zKiXi+pMGLfy7ggjuGQnVfhctb8gw54XF21ZXkMF RYtk168vivVOuQuh8p/7acfSTw1qGUvaFXrTa9A8z+eW0SVdU79jPGdAB/Y70mXXuYFr 7pEZObaVKxpUS/FWfgFS23y0Inoxc5SJpwRo1ZsKa1esZj64SxUn8VQX/3kn2R9HoSb2 XDiozf5O+oHX4BaPLJj3TkpFVXJkI+GKBywRMsvoEBjG1JApVbYP8Qik9Ews0PmAqq9c u7HahvlcqWDt5vy9g7nnDhQfWDHMjhVFCFaL1YKYwQ1nCbgAaGfXO9Ffjj+iiQ4pMttf aJ0Q== X-Gm-Message-State: APjAAAUqbGbk55xnDqYyB/YMuVhAeaxQEqLXC7KOMqchBtoARi66rWYN OrK5pqOsYJUAx/lwn9EeMkdbjWf1OviuMJ2GgoGXo23p1GsG1s1L7m5zIZxdOhfwFgp9JgA2gJE Zv5TT6e1it9jAdgLAF6jjsVEtOg8cSpY= X-Received: by 2002:a25:d80d:: with SMTP id p13mr140461ybg.160.1576440811793; Sun, 15 Dec 2019 12:13:31 -0800 (PST) X-Google-Smtp-Source: APXvYqw2aXNgpQh2rdh1zAq/XXv8ZBWxNTw/1xzYwr/dwL99HLrUehUYmqdJX5ABNij4OyLLRVnmEw== X-Received: by 2002:a25:d80d:: with SMTP id p13mr140448ybg.160.1576440811576; Sun, 15 Dec 2019 12:13:31 -0800 (PST) Received: from cs-u-syssec1.dtc.umn.edu (cs-u-syssec1.cs.umn.edu. [128.101.106.66]) by smtp.gmail.com with ESMTPSA id v38sm7251276ywh.63.2019.12.15.12.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Dec 2019 12:13:31 -0800 (PST) From: Aditya Pakki To: pakki001@umn.edu Date: Sun, 15 Dec 2019 14:13:21 -0600 Message-Id: <20191215201321.7439-1-pakki001@umn.edu> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 16 Dec 2019 05:19:23 +0000 Subject: [Xen-devel] [PATCH] xen/grant-table: remove unnecessary BUG_ON on gnttab_interface X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , kjlu@umn.edu, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, Boris Ostrovsky Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" grow_gnttab_list() checks for NULL on gnttab_interface immediately after gnttab_expand() check. The patch removes the redundant assertion and replaces the BUG_ON call with recovery code. Signed-off-by: Aditya Pakki --- drivers/xen/grant-table.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 49b381e104ef..f59694c352be 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -664,7 +664,6 @@ static int grow_gnttab_list(unsigned int more_frames) unsigned int nr_glist_frames, new_nr_glist_frames; unsigned int grefs_per_frame; - BUG_ON(gnttab_interface == NULL); grefs_per_frame = gnttab_interface->grefs_per_grant_frame; new_nr_grant_frames = nr_grant_frames + more_frames; @@ -1388,7 +1387,9 @@ static int gnttab_expand(unsigned int req_entries) int rc; unsigned int cur, extra; - BUG_ON(gnttab_interface == NULL); + if (!gnttab_interface) + return -EINVAL; + cur = nr_grant_frames; extra = ((req_entries + gnttab_interface->grefs_per_grant_frame - 1) / gnttab_interface->grefs_per_grant_frame); @@ -1423,7 +1424,9 @@ int gnttab_init(void) /* Determine the maximum number of frames required for the * grant reference free list on the current hypervisor. */ - BUG_ON(gnttab_interface == NULL); + if (!gnttab_interface) + return -EINVAL; + max_nr_glist_frames = (max_nr_grant_frames * gnttab_interface->grefs_per_grant_frame / RPP);