From patchwork Sun Aug 13 00:12:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 135006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2055381vqi; Sat, 12 Aug 2023 23:32:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHk/o3utyQlIBR8V7Uzsobin4qV7V5jI6oa4/H8ohrB7hy+MNHYGlxfY5SPEe4QLTf8YhOa X-Received: by 2002:a19:e049:0:b0:4fb:9e1a:e592 with SMTP id g9-20020a19e049000000b004fb9e1ae592mr3593425lfj.4.1691908378334; Sat, 12 Aug 2023 23:32:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691908378; cv=pass; d=google.com; s=arc-20160816; b=JXNJepb/+cmte5QOAvh1jNrNoC70T7W6npQSiZdtswE4Y2CHlRgq5U0gAEMnl3XZfa qhB494Wr1HtnLZNexxkZstGa1f4DKvHgDJozF24K3sJW/4RLZY6NrBuxBIeAKLBSdjQX jXutt5Z1hEPqKrAW4aCxToLzxYZIzTg2HUYyWiE96BpInLmDAPglGoAURvJh4mZkX5BL OOskrFGUr2t5WdQvMoPKC8HtoP8QYugWNqK1Gt3FAa2imjLFLjMJznzJ5ObGXx/sFeG1 eAdinlNogbM0w60wwTNKnHMhOh+tFHkLYFdeGm5Wd3yiP5EZOxHmzm/NM9SG7bjhUSUk isRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=1qIBBAi6csLc7ibdCWGAZKtUI4PfY/ibFH4P7wpyjok=; fh=fq5hksL0nz/0uDo4E1sAlnyqrFNZIpQl1bdrYNS8MsE=; b=rhXkD4u6AWpZQgtCnHk95otEh4tJvfGFyFqYs9LEjHNZ3BRl73Jacj2KJm3/CePVyP H3Hd/OTr3E9EGCClef7uKmdLos3jgWLfvLHHDjZmZWrLayVTRZzGV/o9BYWFkZ9MXtNm LngDO1eF55qbE175ZbSCmdBIsn04WRldcr5byeAX1Ne4bcfi22eUcEuHLAHUbzKCYmB9 V/jLoXH4HpS95O4+pnF/EyMerPQsj03R4dKxKTuZxNRLDFCTT1ZhShv7ar0YjqJxxok6 pu/wnjrlu2Tu5I5nAGzFs2gK0/B2ztDuJBjH4rTNzCk6vg/3t0Omw4Pim52/NzDO9QX1 0Q0A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=DtOgpst7; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id by6-20020a0564021b0600b00523d212769csi3308266edb.227.2023.08.12.23.32.34; Sat, 12 Aug 2023 23:32:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=DtOgpst7; arc=pass (i=1 spf=pass spfdomain=microsoft.com dkim=pass dkdomain=microsoft.com dmarc=pass fromdomain=microsoft.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229758AbjHMAM6 (ORCPT + 99 others); Sat, 12 Aug 2023 20:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjHMAM4 (ORCPT ); Sat, 12 Aug 2023 20:12:56 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2135.outbound.protection.outlook.com [40.107.220.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3860F1BF; Sat, 12 Aug 2023 17:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aIupqdGUQ8izjFrrTmXGS/LlPGZ/T1C4iqlORSgCEJCBfjljhgkhO7n2FQt/5AgEMJrIV2b6o+2Y8UMLmebvH2ogD9WuCcsOnHhEFICvqtjNMhs7zxQhV2V4bjuobTBKyBNjHzB7z3srxUpma+nctEjSSGsR1miI0F25kaZunOZYbZGTppxaXLWPbKt+IEfQG//N/Jn/ubMflxQtQglFs/9Cb7Qrmekk14PhMigssbBm8BQFuggsWv/OCtFyjN108mowbWw9w3wfOJZ8J7vAQXY2UZtv4T4MUyJwZ9sgQa+9RsCkHMfsldglB3OC9jKOhwJxvFCn/3UutcKLvy1Gag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1qIBBAi6csLc7ibdCWGAZKtUI4PfY/ibFH4P7wpyjok=; b=WAnhMzrVZvutoUWhLitlHjk/WsAAGEo6F6RcjMDybVvffb/tjG1eyFB3UkuZWHkJpDvcwFtX1my3pi1/1FgqvptTTlmglO0aN7KJ+asR8IWFun4zahLfMXOXq7pE9Ut/Y38WVMQZ+QWPd04+7MSUdV0SV/F+JButFLFRL9i0YvzPB31bLRMze4+itlt0T+kXzQOC0n/06ve6AVy8qS2v5SoQdJCM8Uuv7LXblwqqEtM5uj3JdBfaPjKMZMhyXEfUW/YjRMLMhPXzryIBTbqcHGhqO5zHxMQC4A9h0XATNxcAqJ3XvX+96rzV0tXlWdtHyp1QHrEf3X0KFI7p6e//ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1qIBBAi6csLc7ibdCWGAZKtUI4PfY/ibFH4P7wpyjok=; b=DtOgpst7CmneomZSzjtGnLSdUM312CLexDUe2xYJMLCRLxyfDELjU5zrdbKjIVMcCV+7XiutChzZug+yGtr/2s57U3s18eYn3fDVT/suPuJ3mBXIRvmlqQ6aX/Fq0/LBb7qBTIFjUxBIig0qJo/YU+1ZRwKalt1UZZzD6wM6g30= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from SN6PR2101MB1101.namprd21.prod.outlook.com (2603:10b6:805:a::15) by PH0PR21MB1291.namprd21.prod.outlook.com (2603:10b6:510:109::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.9; Sun, 13 Aug 2023 00:12:54 +0000 Received: from SN6PR2101MB1101.namprd21.prod.outlook.com ([fe80::d793:7c2a:b49d:b58b]) by SN6PR2101MB1101.namprd21.prod.outlook.com ([fe80::d793:7c2a:b49d:b58b%6]) with mapi id 15.20.6699.009; Sun, 13 Aug 2023 00:12:53 +0000 From: Dexuan Cui To: tglx@linutronix.de, jgg@ziepe.ca, bhelgaas@google.com, haiyangz@microsoft.com, kw@linux.com, kys@microsoft.com, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, mikelley@microsoft.com, robh@kernel.org, wei.liu@kernel.org, helgaas@kernel.org Cc: linux-kernel@vger.kernel.org, Dexuan Cui Subject: [PATCH] PCI: hv: Fix a crash in hv_pci_restore_msi_msg() during hibernation Date: Sat, 12 Aug 2023 17:12:18 -0700 Message-Id: <20230813001218.19716-1-decui@microsoft.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: BYAPR04CA0031.namprd04.prod.outlook.com (2603:10b6:a03:40::44) To SN6PR2101MB1101.namprd21.prod.outlook.com (2603:10b6:805:a::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR2101MB1101:EE_|PH0PR21MB1291:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d44a68f-c041-44ce-082a-08db9b920908 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XdHTt4hV65JyJMO1ac0MIcAuDNb5m2XWHy+lVS0/S0Ekmihqhkj11KmYWZ4IA/LESNH3mqgP7+iysG+LAdqb/T8opQQAy8YbaaA99m1pJjPzOe6fRB1/RLEMakQCG1O8rozwM8COky1jZIV3A6Qyj4/6ip2pj47J//CJIX8HH1NDMQ5PREVZCjfkficY2U7+BOMTIIXwMSrpbziRap6YRH55GWzK9eDqL9ua0olMoibhm/vuFfB/3YO+XgieFPkKihyYgtDAq2ScAON1BHjfx70yjbc18qAtTZm2uUFn8nLOMKCk25KPkUYs0+6DOkAM6aTrJuwivKlwvX/lnCSLQ373NGQuZWqmaBUcplTsWj/nSukyA5DZwLT7+ooptziQ7zKGS66TNDgYT+YEUHMrLAmYtyBgeoLprwRC0530NpxWUZVCVUxBFi3OQ7qHFEKGV361PwjRQCR/Pn6j5mLqw8oiD6PB4OIN+JXtUcoQ3jMlcoYb5C9fqYAY4ZSaXUODG9V/52WWsj0jJgLsAaOaZOzLlrk9ni144cmQy+WB4vF5O8mYuECE7juWxTXsV5ZiuC/JD+4857dMIU7s/3c95PHE28dAUmETk1FH1mU5Lr+1YoiXW9lI7boKDV+v/BHDcd1veWiZ13/5S33XQQ/zMJ80PuaZL79C08YVV42UkYCyF982bWUWSAH4dW7HR37N X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR2101MB1101.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(396003)(366004)(346002)(376002)(39860400002)(451199021)(186006)(1800799006)(7416002)(8676002)(8936002)(41300700001)(5660300002)(86362001)(2906002)(83380400001)(6506007)(107886003)(2616005)(52116002)(6666004)(6512007)(6486002)(82960400001)(82950400001)(36756003)(12101799016)(66476007)(66946007)(66556008)(921005)(316002)(4326008)(478600001)(10290500003)(1076003)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uh0QDX4k3drYcvxtPAMCp0A2bwFBxvVMnf62VvXfS4MtfrW+8xiK3FnPezLdKJvdoMQMmgc0UT537UtEYw42eF80n1DqcpG38/tKZ5P6jFY1+n3X6qwAiOkZI+VmiXe0lPQ7PXryX4gVLGVp+fzJyaGW9JcqrxiSkuFHhobDBbn8Rl34e09NirlSOXyP6hzIskfZE4NPVcMki6CxfBix0+j8zc6Fm1z5S++esYbNpZcsoW/zD/7yF/+pCESabF5yThYIUqjihP4WfGGhPxkUrDYYESMNEnOA2PZAAkdLTx86ATs7+EJs4MHyVeebQkiwBHJwCGsAMQW9f4f2byBU/pwZU904OMatJsakPb19o3wHuBdse78bS6oRjF8V27Q28ER5vx03VRvkeyw+ka64MmO5KsMJITLZhaRvHDMikwNWGvbsKKuEof57bgqCQaeKwW2Gp5b9Em1uJ9EtVer9HUsifl4HHQQkz75jx+6FtGTUcTYA0/SvfGUYg63eDku9vMCVf4lhV+v+qlMYvR5BzaNf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AAqz73ytsBQ1cqX03ehdanFIcidhZG1 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d44a68f-c041-44ce-082a-08db9b920908 X-MS-Exchange-CrossTenant-AuthSource: SN6PR2101MB1101.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2023 00:12:52.8304 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J+KxpcGcgpaVbzjCEniAM4vHV8kNltiaczX1g2lemXOgnxtZNgD8hRWcxI8N4BB/cKaWnrnTZ4xiBP2camd5nQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR21MB1291 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774094519840156363 X-GMAIL-MSGID: 1774094519840156363 For a Linux VM with a NVIDIA GPU running on Hyper-V, before the GPU driver is installed, hibernating the VM will trigger a panic: if the GPU driver is not installed and loaded, MSI-X/MSI is not enabled on the device, so pdev->dev.msi.data is NULL, and msi_lock_descs(&pdev->dev) causes the NULL pointer dereference. Fix this by checking pdev->dev.msi.data. Fixes: dc2b453290c4 ("PCI: hv: Rework MSI handling") Signed-off-by: Dexuan Cui --- 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..fdd01bfb8e10 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->dev.msi.data) + 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);