Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3027739pxj; Mon, 17 May 2021 15:57:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsyDJQLo5GuH+wlH8dDHsgyaMBugC9O+EPFihMW9/p5PW+DdStcxptP7phuGtmpslye2cf X-Received: by 2002:a92:d287:: with SMTP id p7mr1732090ilp.30.1621292252988; Mon, 17 May 2021 15:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621292252; cv=none; d=google.com; s=arc-20160816; b=chGPAXnoDOqntMlzzll0CHFMQrCgqnmWXjgi3LBFHvDHcogQ9/mcdowaoom6RV28gh Nnb40PQZKajejmEgo7sOL05AOniH5HkyaA2k5lkLN6JPg/p1VH9fZ91XMoRIcC2N9kRE XM5xKxkFLFJmUfYUHmUHdbtOQJokH4Ng2mc3y96NetYr2AnavZ305hbM4Qhxgk+X/hhm JwIirlKeTD/qRwbZUk7ETBjH/hsV/CFpGa15zoqMid9Rfytwf7FOi6hPhywhCVBcwzOI X9X2nNOFBgsiM0XnqZWeLymJv2w2APWNt7DTxwY7GW+4407OWGKzoPJxywPlhGP+gas+ H3xQ== 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=uTweqd5xmbA9jnODgFZAASLOPYyTwWNx5r1s40mbCHo=; b=NoWfg9EIivnk6YjVtDQEjrPL/857r0y9F7zndqhJJbl8QdcHFEbSj4I6JEQsTKAPpI rB7ELHQLAX3DrGcL63hVc/TwyAhviUIhL6ujuvRkDe9Gs7uvdW9GFn7Ei/IPhov2vHyx kOzAsemJpEbMas0PGjFqeVj40T4vOhVqDHalej0sEB1QmVLWl8EeIfG+IRCwu7rIZfUL MlAbNel/QeB7uOphZ15RfNgX+UXh+/XTlFYyWw+InEus/U6/nzZqRY1v1zn5xgJbAtIt +pNNyw3mxAt+CEI6WmUcmu4REgnpNycaKJNie2Kh+LBchcp3LrVWoT8ZwVmuef5dkEo6 z2Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NzAc+003; 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 w12si19662801jap.71.2021.05.17.15.57.18; Mon, 17 May 2021 15:57:32 -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=NzAc+003; 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 S238873AbhEQOSt (ORCPT + 99 others); Mon, 17 May 2021 10:18:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:46476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238861AbhEQOQo (ORCPT ); Mon, 17 May 2021 10:16:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95686613F5; Mon, 17 May 2021 14:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260577; bh=vkhSz1ZTKlNOYzE0WNy3Upzc4zgTQBrymtxywf8XbVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NzAc+0031mCkqZMkHcaMVB7cVk2whrTb4qChJL+KzRaddQdzp5G/qqssx1+jLZMdF zUfQJcT+xDgc16OIUk3DWurDc2gUdvzbJyJSFhUNjy/juDcFmt5I7ypYk0Qpz9HSoV 9USB7MYX5cYN0jNC/jQE8O5P74OhU/6VRofrvMCs= 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.12 110/363] powerpc/iommu: Annotate nested lock for lockdep Date: Mon, 17 May 2021 15:59:36 +0200 Message-Id: <20210517140306.333521991@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 c00214a4355c..4023f91defa6 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c @@ -1096,7 +1096,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); @@ -1124,7 +1124,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