Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3556438pxp; Tue, 15 Mar 2022 00:41:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5mpJhyxstbR4mES6FcPcuuDwN6x7YM9YHe5UJlH/Vv/IR5LpL1nTP8vNZ8vmISjnC2KwJ X-Received: by 2002:a17:907:160a:b0:6db:ec4f:4fc5 with SMTP id hb10-20020a170907160a00b006dbec4f4fc5mr3172986ejc.303.1647330113466; Tue, 15 Mar 2022 00:41:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647330113; cv=none; d=google.com; s=arc-20160816; b=jm9RBPVTw+owiIK+89GdzRb5t2krfBY7ONBQ0DsUvrMkYZvB/6AWE4u3+Rs+uk0EZT 5V7w7K5z+1XTc/kMDzR2qgmGAzt14dzYSntAiXaR+4W13MASYjTk0OfQPYUv0gS2bB1X 6CQICC/h54j9ezDfszYiCT0E2sWQKD0ZE9KhZpkllx0wR5HoahveXvkmZ1X8dZsqxoRb vbv+QDli7LmX3var1xaXG/2YPeclNutpTiODpr/gN4F+yC4uwuRp/VuDE/nDRfCD4yiq 87WLVxYKFCsji5SZA1fCRv6db/p2ZUKaVwuhbCoU4tg5LMup4wnYX0aHptK1nlsgWNCw JiUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hR1J2h65OImOmY/Z5VAteYJJAzBhrtY4h1xds8YuCu4=; b=FXf3sv7EjfxWB1Ehe1jcn5bSOp/hH5JVTq7yBrUOU60GztMoD+Eq8WzeQ6oOVCoKxt uy4ABnQAhl7cGpj0JOMCAzVPL9kzat6XHLS0PA3QDiEzgI/F/Do6vNnGfsMVMbJkKDQ3 LtisHFnwBBaVd60fI7fnTmtrQz5Q1V3q4n1K8YjOg+XXj6E0jPu8vdDnD2X0+Pk9g3pt 6AzAYZaJ0s6bqMC41EsSVEkC+6IWHyUB+R4KjS+soM1UptYAWIqpa+MI6aiiiHtsWoyT J0vVVLHg/499xGAYBsBXYdabEyA4uk+EI9U8fdcNzZwESlDpcXqdSNHruBiW5RVrCLFT KFMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gEghXoJg; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji15-20020a170907980f00b006db41df2ecasi11892249ejc.635.2022.03.15.00.41.28; Tue, 15 Mar 2022 00:41:53 -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=@linuxfoundation.org header.s=korg header.b=gEghXoJg; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241818AbiCNM2D (ORCPT + 99 others); Mon, 14 Mar 2022 08:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243356AbiCNMUe (ORCPT ); Mon, 14 Mar 2022 08:20:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D333B54190; Mon, 14 Mar 2022 05:15:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BD3F8B80DF4; Mon, 14 Mar 2022 12:15:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13AC2C340EC; Mon, 14 Mar 2022 12:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647260151; bh=WJulgjcHdOlBuDGWLD209+QllLpMieV0m3t5lXXmYO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gEghXoJgQBwRP2MA8jIw4bHJLE7Xfhi2ayqLzyRTrWgNmnGn6gmo4qoywiNUZsRjr 9IyNnUSZGc7OgEHIB5R/3ZdjkeD1hJHe6OIr6v0XRfRFTmFXk7wjAbSf+imu6omUdy 7DiPr873/5XKDfqIeKWxWe4+xkcRp9BZlnEqKVgA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wanpeng Li , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.16 064/121] KVM: Fix lockdep false negative during host resume Date: Mon, 14 Mar 2022 12:54:07 +0100 Message-Id: <20220314112745.912517994@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Wanpeng Li [ Upstream commit 4cb9a998b1ce25fad74a82f5a5c45a4ef40de337 ] I saw the below splatting after the host suspended and resumed. WARNING: CPU: 0 PID: 2943 at kvm/arch/x86/kvm/../../../virt/kvm/kvm_main.c:5531 kvm_resume+0x2c/0x30 [kvm] CPU: 0 PID: 2943 Comm: step_after_susp Tainted: G W IOE 5.17.0-rc3+ #4 RIP: 0010:kvm_resume+0x2c/0x30 [kvm] Call Trace: syscore_resume+0x90/0x340 suspend_devices_and_enter+0xaee/0xe90 pm_suspend.cold+0x36b/0x3c2 state_store+0x82/0xf0 kernfs_fop_write_iter+0x1b6/0x260 new_sync_write+0x258/0x370 vfs_write+0x33f/0x510 ksys_write+0xc9/0x160 do_syscall_64+0x3b/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae lockdep_is_held() can return -1 when lockdep is disabled which triggers this warning. Let's use lockdep_assert_not_held() which can detect incorrect calls while holding a lock and it also avoids false negatives when lockdep is disabled. Signed-off-by: Wanpeng Li Message-Id: <1644920142-81249-1-git-send-email-wanpengli@tencent.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- virt/kvm/kvm_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 71ddc7a8bc30..6ae9e04d0585 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -5347,9 +5347,7 @@ static int kvm_suspend(void) static void kvm_resume(void) { if (kvm_usage_count) { -#ifdef CONFIG_LOCKDEP - WARN_ON(lockdep_is_held(&kvm_count_lock)); -#endif + lockdep_assert_not_held(&kvm_count_lock); hardware_enable_nolock(NULL); } } -- 2.34.1