From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F00C2EE49A0 for ; Tue, 22 Aug 2023 01:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232030AbjHVBWr (ORCPT ); Mon, 21 Aug 2023 21:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbjHVBWk (ORCPT ); Mon, 21 Aug 2023 21:22:40 -0400 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA631123; Mon, 21 Aug 2023 18:22:38 -0700 (PDT) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1bf1935f6c2so26452505ad.1; Mon, 21 Aug 2023 18:22:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692667358; x=1693272158; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=u4XMj6NCEe6Vw86vn80CV6xa830vO2fpeQEV9NovfxU=; b=kuLXc8zg+iUYY6rwMVDghw9elJlZlaXB2Pw9kzkvOlsQMI5RopnGbOCi8fv3qU1kkd A4+Jvoi9C+yxo13F01UGMll7wDwUfadas326RKZY5ew4LL/sJSTsr4aaFu4nq4cqPErE x3JBIS4hCJ+yrH0ghlk45jLLzKK5uBDWiB+trGTmi9a6LJSe10OG3jYlEaT4EsPK/c5c IEJ99V2LYX9nKHJkVSfTL5keJ6h3vr7EAi1KuOJBlVTyaTV+e2cjcWayIU2guLwJRNYa 42Gmc6k9yraPdH0fFN/yVTZFdbBJ+767Cb13iHqHgguTrrboWGjXM2Ji/UaDvz0lejAN ofYg== X-Gm-Message-State: AOJu0YzxcddVZG6Ou4o7kYFmEMBIDeLHa885IdDKwoHkov8ACdvKe3qB FXuYKvxJPPXZnEF524anWeo= X-Google-Smtp-Source: AGHT+IEReTPdnzD7gRJqUON++JWGiLkPednkeuQJ9Q/LGmsS3qQTO7HlxxeZYUTBxkB0Kho8i/vjYg== X-Received: by 2002:a17:903:41d1:b0:1bf:193a:70b6 with SMTP id u17-20020a17090341d100b001bf193a70b6mr12540696ple.5.1692667357727; Mon, 21 Aug 2023 18:22:37 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([20.69.120.36]) by smtp.gmail.com with ESMTPSA id 12-20020a170902ee4c00b001bbb1eec92dsm7683523plo.224.2023.08.21.18.22.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 18:22:37 -0700 (PDT) Date: Tue, 22 Aug 2023 01:22:17 +0000 From: Wei Liu To: "Michael Kelley (LINUX)" Cc: Dexuan Cui , "tglx@linutronix.de" , "jgg@ziepe.ca" , "bhelgaas@google.com" , Haiyang Zhang , "kw@linux.com" , KY Srinivasan , "linux-hyperv@vger.kernel.org" , "linux-pci@vger.kernel.org" , "lpieralisi@kernel.org" , "robh@kernel.org" , "wei.liu@kernel.org" , "helgaas@kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] PCI: hv: Fix a crash in hv_pci_restore_msi_msg() during hibernation Message-ID: References: <20230816175939.21566-1-decui@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 16, 2023 at 08:10:25PM +0000, Michael Kelley (LINUX) wrote: > From: Dexuan Cui Sent: Wednesday, August 16, 2023 11:00 AM > > > > When a Linux VM with an assigned PCI device runs on Hyper-V, if the PCI > > device driver is not loaded yet (i.e. MSI-X/MSI is not enabled on the > > device yet), doing a VM hibernation triggers a panic in > > hv_pci_restore_msi_msg() -> msi_lock_descs(&pdev->dev), because > > pdev->dev.msi.data is still NULL. > > > > Avoid the panic by checking if MSI-X/MSI is enabled. > > > > Fixes: dc2b453290c4 ("PCI: hv: Rework MSI handling") > > Signed-off-by: Dexuan Cui > > --- > > > > Changes in v2: > > Replaced the test "if (!pdev->dev.msi.data)" with > > "if (!pdev->msi_enabled && !pdev->msix_enabled)". > > Thanks Michael! > > Updated the changelog accordingly. > > > > 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 2d93d0c4f10d..bed3cefdaf19 100644 > > --- a/drivers/pci/controller/pci-hyperv.c > > +++ b/drivers/pci/controller/pci-hyperv.c > > @@ -3983,6 +3983,9 @@ static int hv_pci_restore_msi_msg(struct pci_dev *pdev, void *arg) > > struct msi_desc *entry; > > int ret = 0; > > > > + if (!pdev->msi_enabled && !pdev->msix_enabled) > > + return 0; > > + > > msi_lock_descs(&pdev->dev); > > msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) { > > irq_data = irq_get_irq_data(entry->irq); > > -- > > 2.25.1 > > Reviewed-by: Michael Kelley > > I expect this to go through the PCI tree. Just let me know if I should pick this up. Thanks, Wei.