Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5210586pxj; Wed, 26 May 2021 05:35:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycQVewoFvz9HTFGu1ZjdIpAOTybBK5zktng1OCIRUHvbjHG19qWlikZi52JtNoni1y5kI5 X-Received: by 2002:a05:6e02:490:: with SMTP id b16mr27410930ils.213.1622032544141; Wed, 26 May 2021 05:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622032544; cv=none; d=google.com; s=arc-20160816; b=zrvrMIfN5T5JOYdpBDo8RnckelQD7pS4OKrgQ3Bp/QqldowmMfq/9gTYjDH9IMHAop nIgCjhmeAcQ5/ccDWe0wNVTOpnJiGbvG45H0m5zsu5PHTlGe4lxBFzR4lXRi7TqiY/l2 xD6iJ+WDw4z+P+weYKTEvPeguaWcMeIXKXVUzidC0OmifFwXmdle34IrEc6LfjvpF02U mu/pmAW1/98rgh9nXBbl5VMCvWtNPKgPRa0TZxbHcmaVRsTHhVtwq3IHDimL1apK3sKH ItI7Vs1K1Qe0e17WVx+KqM5k53IOxpZGFp0dRccdjtq5bBSdECcWEWWwlLm1R779JzDj gXQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=3bo+c3S5QKp7gdHebx8LdhAWUc/HOzQNqyiFqhVHljE=; b=Ibw49EYhbfzLYS7skoKt7xdahdgZCenQdt3mmBbySwUS7BaZ5A1kn2M5pQwAmsNe2C hwKl2PyVDmlKnonsG8JwaeE2G7f2aBSiC/zjwm2hXJXEX1wP9pyDKzfEpO4BiKUavaN9 elqJhNMwgUEN4VAcYMpHgHxaoPhr7z6vvkJZMAo/ciwqFLHxwLE5kHdQgkJxGQhb9pBQ t7oy/+uWzEfNhkS/qibCQpfrHNpimDItI8rkyYVXPy2iX04uSIUtwgYwZGJPzYlTdelE DkTkNTc45/7tQKt8Upy/hWPRdu+vTe2pi35vm3UxToZXlGBSnTWYX5Agr/ZOMVQDfLTz Hzpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m30si22065985jav.6.2021.05.26.05.35.30; Wed, 26 May 2021 05:35:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233764AbhEZKJr (ORCPT + 99 others); Wed, 26 May 2021 06:09:47 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:33638 "EHLO mail-wr1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233787AbhEZKJk (ORCPT ); Wed, 26 May 2021 06:09:40 -0400 Received: by mail-wr1-f42.google.com with SMTP id n2so540206wrm.0; Wed, 26 May 2021 03:08:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3bo+c3S5QKp7gdHebx8LdhAWUc/HOzQNqyiFqhVHljE=; b=Nokw/GcI40kiAgn9bR+XmcEgIytbeQ9lkyqLwtknX4cImDKORZELPgR/UtDRc9a1EG Zg9KH4oL+TaZn+eFctTpi9zwFbBHkYeNTE9pKaAKeNiWsikK0TL28caT4pB6Y3k0ofjr LqwJIzzSknbU9YzkoLd/6mEcK3LPFIHe2EhrVNkuKDsBQv34ikQ9ZI1+zfdNSTe36mKr cujmhg0vD8Og0WwVkhecaB6Lo6CVThH0CL1/D9V1r/VV+vHYsRI75KdL4zDh23kOQt8B fJOIrNQXwmP10fnuBO35oxZlQMXWi7HDMxI8oNYjXjwBkO/ITzJpZcdtj1H5pcbPcSl0 +qVA== X-Gm-Message-State: AOAM530Z/WGuVFc4Isqd8D7XD520pikYayZAMi5UHFwtiSGaGMZHxlUg Edw/SW9hVQ2ZXu3Gh/w0+s8= X-Received: by 2002:adf:fd81:: with SMTP id d1mr32269275wrr.37.1622023687273; Wed, 26 May 2021 03:08:07 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id v18sm23315208wro.18.2021.05.26.03.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 03:08:06 -0700 (PDT) Date: Wed, 26 May 2021 10:08:05 +0000 From: Wei Liu To: Haiyang Zhang Cc: bhelgaas@google.com, lorenzo.pieralisi@arm.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, kys@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] pci-hyperv: Add check for hyperv_initialized in init_hv_pci_drv() Message-ID: <20210526100805.xpeen7td45cswqsw@liuwe-devbox-debian-v2> References: <1621984653-1210-1-git-send-email-haiyangz@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1621984653-1210-1-git-send-email-haiyangz@microsoft.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 25, 2021 at 04:17:33PM -0700, Haiyang Zhang wrote: > Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), > so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the > init_hv_pci_drv() will exit immediately, without any side effects, like > assignments to hvpci_block_ops, etc. > > Signed-off-by: Haiyang Zhang > Reported-and-tested-by: Mohammad Alqayeem Reviewed-by: Wei Liu > --- > drivers/pci/controller/pci-hyperv.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index 6511648271b2..bebe3eeebc4e 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -3476,6 +3476,9 @@ static void __exit exit_hv_pci_drv(void) > > static int __init init_hv_pci_drv(void) > { > + if (!hv_is_hyperv_initialized()) > + return -ENODEV; > + > /* Set the invalid domain number's bit, so it will not be used */ > set_bit(HVPCI_DOM_INVALID, hvpci_dom_map); > > -- > 2.25.1 >