Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp352170pxj; Tue, 18 May 2021 05:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/5Go/Rb0gqjKs8VB7ooWurCXW7PYm3D9jN9IhaC9lPOqmSUuC3LOrhIA5AD02easj8SQW X-Received: by 2002:a17:906:46d1:: with SMTP id k17mr5617805ejs.77.1621339318626; Tue, 18 May 2021 05:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621339318; cv=none; d=google.com; s=arc-20160816; b=Zw3vdeCBSl5X/N2Rnsj+1mhkwll9jVI3jC6/n9Bw1+YNDCAf90Uhvc/ER5anS7fbbP sGYpS4qwJmTCaDnsExWBQD74c55hGyEvLz4JL1jAE5OKGo2QQDboy5M/68/u7OmgbEEX ePDBIrnaHvUu3VixE3ptJsvXdWhnaIUESw8QRSS89XXwzC5qswycHX2vO1p3lesRO2ic seKwlNFPUR3eHedqVeKWLNYa5QvSWKoqDoWcLWvqkmyNl3JEp3gLYSzGq+JFSQWCUqAi PHecq6WnRipBKegckwoP+7gLVehicepsUNb9Xg7Ih3jaDZUkCzGe5b45vtS/87p7KFQm il0w== 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=y+OeFvHEgoSQFwqdQn+JJKX/X5n6EQwdaTKJ2E1GS2Q=; b=eTq2UkGHJ368/qov9ggLq1NtWIEKUdO1BhTtbl2w67R4bE3gf1Yyea5pBZgkSuQ+pP O6FjAcrqwjS0rPSGOgAeKvxAMpA77sLPR+VrcTKFK6MxH2f4XxnVpua+dWSqUrEehcpj wgo8gdnLQpu0PHs4uCPEhJw3KBYaQJxU3uAZ04xiKLbPhKpcwwaLG+aGzrCNoXy/cdb0 V0Ir+N6jlFepPACa7IDbSH65DQqEEaysrweOVKHi343W4bV3raq33LtPirTCi6pWEGyd KRtRXQ0NhUs10Oq6gKpNMg7d8lfb5ZLB77mS8CpsaafBTI2wHAKo3XkWir+uhQDKZa4X Sy8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pkksm8xt; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si18940282edy.298.2021.05.18.05.01.29; Tue, 18 May 2021 05:01:58 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pkksm8xt; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243840AbhEQP0d (ORCPT + 99 others); Mon, 17 May 2021 11:26:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:37256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243290AbhEQPMg (ORCPT ); Mon, 17 May 2021 11:12:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2506261C46; Mon, 17 May 2021 14:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261890; bh=w1k4f0i6yOmkScwiFjhzfL8jY/5nHyF4SbdTGYR6oc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pkksm8xtCMA8pUoh6N0qW03DLksVL1yvMizp23cPGr/wOL8J3sd7K71Ooc+Sh/yqw KwohQEKqJ6gd3dSutMWiBknrVwg+P/c5minFyNQaKopGtmdm6KmOAleStYeONIK8B3 JPCSGKmTjGBX6vRzK3bFAO/HZniRnBBoEZVE1/gY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Kardashevskiy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.10 081/289] powerpc/iommu: Annotate nested lock for lockdep Date: Mon, 17 May 2021 16:00:06 +0200 Message-Id: <20210517140307.918061667@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexey Kardashevskiy [ Upstream commit cc7130bf119add37f36238343a593b71ef6ecc1e ] The IOMMU table is divided into pools for concurrent mappings and each pool has a separate spinlock. When taking the ownership of an IOMMU group to pass through a device to a VM, we lock these spinlocks which triggers a false negative warning in lockdep (below). This fixes it by annotating the large pool's spinlock as a nest lock which makes lockdep not complaining when locking nested locks if the nest lock is locked already. === WARNING: possible recursive locking detected 5.11.0-le_syzkaller_a+fstn1 #100 Not tainted -------------------------------------------- qemu-system-ppc/4129 is trying to acquire lock: c0000000119bddb0 (&(p->lock)/1){....}-{2:2}, at: iommu_take_ownership+0xac/0x1e0 but task is already holding lock: c0000000119bdd30 (&(p->lock)/1){....}-{2:2}, at: iommu_take_ownership+0xac/0x1e0 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&(p->lock)/1); lock(&(p->lock)/1); === Signed-off-by: Alexey Kardashevskiy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210301063653.51003-1-aik@ozlabs.ru Signed-off-by: Sasha Levin --- arch/powerpc/kernel/iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index 5b69a6a72a0e..6806eefa52ce 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c @@ -1050,7 +1050,7 @@ int iommu_take_ownership(struct iommu_table *tbl) spin_lock_irqsave(&tbl->large_pool.lock, flags); for (i = 0; i < tbl->nr_pools; i++) - spin_lock(&tbl->pools[i].lock); + spin_lock_nest_lock(&tbl->pools[i].lock, &tbl->large_pool.lock); iommu_table_release_pages(tbl); @@ -1078,7 +1078,7 @@ void iommu_release_ownership(struct iommu_table *tbl) spin_lock_irqsave(&tbl->large_pool.lock, flags); for (i = 0; i < tbl->nr_pools; i++) - spin_lock(&tbl->pools[i].lock); + spin_lock_nest_lock(&tbl->pools[i].lock, &tbl->large_pool.lock); memset(tbl->it_map, 0, sz); -- 2.30.2