Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp200524rdb; Wed, 14 Feb 2024 18:34:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWXsXJgYNaR78Rb4YPcuKPrqlGUMRJ7gS7wKIKDqUduZO6RILFbdfUufWu36f43ef7bCV9p4jXZ9ERljRTeFYrfis4Wm4olTReYTH4EQw== X-Google-Smtp-Source: AGHT+IF8wEdpMc9ZnQtk1C5ajPdXOgCJpI4/MVdo+b6m2U+piEhjteciF9G28ujoeEBBb7jBBf/z X-Received: by 2002:a05:6870:8a2c:b0:21d:e9ed:9f91 with SMTP id p44-20020a0568708a2c00b0021de9ed9f91mr457744oaq.23.1707964441331; Wed, 14 Feb 2024 18:34:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707964441; cv=pass; d=google.com; s=arc-20160816; b=t/0WdjoMT8YyCzn1H/0jGbexU9Q6owf3YKcKAZ1eKYvt8YhVoJJUyvGmM/gLu4NsVl Ab7ZwWC9HM8RgEPWm4owTXx81z/NdewI//VXJD5WncWmUZeHl5S4D/gukrc0IapqjnAG kA7nuuLB2GAFpI1NIxIQIyutJR7/agFSq8us0J5DNqIiPt0/PlBYWKgkRAEhaE38ZB9e l49hWCLxLbLAlks9dtd6huDdPCxcmyul+a1tfm5XJW0eYuYfDWYH6EVS2k2JbSPg4MLj B1oBS2SHkiYdj9Y7ILn9ADCqYhii4Z7E8ZeicdKkIysaJ4oTnQ+CrraL6YYwDtPLqiQf Hm7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=mN7k05qDsCZMvJ231ko7Ex1DhgQgMDJKRw5c4Jz+Jno=; fh=UBR6Ipl7OCO4uQ8JgvcfBeKx7Jgb8qvf/leHCWASAL0=; b=bZHY3q+efYqwDyEhpchOSaB1vMbWpbXB1taAP7JO2G5htlhjgemabUhw6fB/aMkqaH NBOGYIDgbeagANck9mE4lNdooDAoXtzGAEq0jziAeQV99n9eSW20pjBXK1QnxaFaIsqb Wu1uEq1+nGTAzl1QEm//VCBgeNnfkENqZG2O1kQl4y1lhT2T7NZgHMB9uJdHhc4RxVct NX1BECpwsPO/78LHPw/yPEMkCnd5dcgk6bBe68bhiMT2pWX0TBPftrNSlNGuJRsegatP aCobxxCBybXKym+vr223WRSizWtszzUwvLbLM3J0Q/+4CtqNWeR8YE5S/Yctl6pUFkRI TpDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=ZRbSjk+F; arc=pass (i=1 spf=pass spfdomain=ellerman.id.au dkim=pass dkdomain=ellerman.id.au); spf=pass (google.com: domain of linux-kernel+bounces-66241-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66241-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b24-20020a637158000000b005dc6d16be5csi244233pgn.439.2024.02.14.18.34.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 18:34:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66241-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=ZRbSjk+F; arc=pass (i=1 spf=pass spfdomain=ellerman.id.au dkim=pass dkdomain=ellerman.id.au); spf=pass (google.com: domain of linux-kernel+bounces-66241-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66241-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8DCDDB27BE9 for ; Thu, 15 Feb 2024 02:31:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7AFEA4409; Thu, 15 Feb 2024 02:31:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="ZRbSjk+F" Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6EC939B for ; Thu, 15 Feb 2024 02:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=150.107.74.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707964275; cv=none; b=IFtRJqpkhC1zBa3EomMpYmQKKcC7ftMKe9DoLwJ/HmK0pxDeWamKWNy650rM5IBwMFSfVk+XtA2al43uUhr7evgcc/L6SVjfAyu80dTthd5ozCWoeV/KRGIiBPHaKlZcDSm7iZlE8LhEMkryeaP5f1NwrgXXflLE+4SzNRwSbU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707964275; c=relaxed/simple; bh=fWwe+zyzz52O3D2v6MbdZs2U98vj/zxwa7T4woR+DOQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=GFwN3aP3ODvkRpkCIF/6XD/iqxIHICCTwoQTsWTz2JID2C9DFM1QlpRPvU4Z/hHXiIsbeumBzqAzncYWw55faqFrhObVM34Jz0DU0YuuAzLlpIq20r9uGldU71FfwBnAnYbaums0axdUb+AVFRXSjNUsqSvuYolK37tbpDXqDjI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au; spf=pass smtp.mailfrom=ellerman.id.au; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b=ZRbSjk+F; arc=none smtp.client-ip=150.107.74.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ellerman.id.au DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1707964269; bh=mN7k05qDsCZMvJ231ko7Ex1DhgQgMDJKRw5c4Jz+Jno=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ZRbSjk+F0dN7h56CW1VVMZbPdYMZNjqNRFpLazen7bRueZ0r5T1ywezmodVpyjVa9 d92F0UbPkk9cWKe/PUaolTj0uuHCqNcK/ovV+hA+9r8vgDHeXTd6hLN6wCeRtjDm12 wkrFjy7X7ibTf+qIS411Cy5ElqNoS0q5GnEN+y7jmi5FPb/ixivhx/JpCR66PfFpwA JP9jt3Lz0hSKEVJYKjPr8MT4mthYB057UdEkBZa4JxTJLbg6Uas//RbUT4CmRP2859 ZbXPQ2xV1m3X13wKW1QvIjjvoRUVCp+CRxl7+/GFzsANQTLT9gMRfrag8IblLb8+dG 7cgXHvEiWtt2Q== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4TZzZg5B7Nz4wxv; Thu, 15 Feb 2024 13:31:07 +1100 (AEDT) From: Michael Ellerman To: Shivaprasad G Bhat , iommu@lists.linux.dev, linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, npiggin@gmail.com, christophe.leroy@csgroup.eu, aneesh.kumar@kernel.org, naveen.n.rao@linux.ibm.com, jgg@ziepe.ca, jroedel@suse.de, tpearson@raptorengineering.com, aik@amd.com, bgray@linux.ibm.com, gregkh@linuxfoundation.org, sbhat@linux.ibm.com, gbatra@linux.vnet.ibm.com, vaibhav@linux.ibm.com, venkat88@linux.vnet.ibm.com Subject: Re: [PATCH v2] powerpc/iommu: Fix the iommu group reference leak during platform domain attach In-Reply-To: <170793401503.7491.9431631474642074097.stgit@linux.ibm.com> References: <170793401503.7491.9431631474642074097.stgit@linux.ibm.com> Date: Thu, 15 Feb 2024 13:31:06 +1100 Message-ID: <875xyq791x.fsf@mail.lhotse> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Shivaprasad G Bhat writes: > The function spapr_tce_platform_iommu_attach_dev() is missing to call > iommu_group_put() when the domain is already set. This refcount leak > shows up with BUG_ON() during DLPAR remove operation as, > > KernelBug: Kernel bug in state 'None': kernel BUG at arch/powerpc/platforms/pseries/iommu.c:100! > Oops: Exception in kernel mode, sig: 5 [#1] > LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=8192 NUMA pSeries > > Hardware name: IBM,9080-HEX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NH1060_016) hv:phyp pSeries > NIP: c0000000000ff4d4 LR: c0000000000ff4cc CTR: 0000000000000000 > REGS: c0000013aed5f840 TRAP: 0700 Tainted: G I (6.8.0-rc3-autotest-g99bd3cb0d12e) > MSR: 8000000000029033 CR: 44002402 XER: 20040000 > CFAR: c000000000a0d170 IRQMASK: 0 > GPR00: c0000000000ff4cc c0000013aed5fae0 c000000001512700 c0000013aa362138 > GPR04: 0000000000000000 0000000000000000 0000000000000000 0000000119c8afd0 > GPR08: 0000000000000000 c000001284442b00 0000000000000001 0000000000001003 > GPR12: 0000000300000000 c0000018ffff2f00 0000000000000000 0000000000000000 > GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR24: c0000013aed5fc40 0000000000000002 0000000000000000 c000000002757d90 > GPR28: c0000000000ff440 c000000002757cb8 c00000183799c1a0 c0000013aa362b00 > NIP [c0000000000ff4d4] iommu_reconfig_notifier+0x94/0x200 > LR [c0000000000ff4cc] iommu_reconfig_notifier+0x8c/0x200 > Call Trace: > [c0000013aed5fae0] [c0000000000ff4cc] iommu_reconfig_notifier+0x8c/0x200 (unreliable) > [c0000013aed5fb10] [c0000000001a27b0] notifier_call_chain+0xb8/0x19c > [c0000013aed5fb70] [c0000000001a2a78] blocking_notifier_call_chain+0x64/0x98 > [c0000013aed5fbb0] [c000000000c4a898] of_reconfig_notify+0x44/0xdc > [c0000013aed5fc20] [c000000000c4add4] of_detach_node+0x78/0xb0 > [c0000013aed5fc70] [c0000000000f96a8] ofdt_write.part.0+0x86c/0xbb8 > [c0000013aed5fce0] [c00000000069b4bc] proc_reg_write+0xf4/0x150 > [c0000013aed5fd10] [c0000000005bfeb4] vfs_write+0xf8/0x488 > [c0000013aed5fdc0] [c0000000005c0570] ksys_write+0x84/0x140 > [c0000013aed5fe10] [c000000000033358] system_call_exception+0x138/0x330 > [c0000013aed5fe50] [c00000000000d05c] system_call_vectored_common+0x15c/0x2ec > --- interrupt: 3000 at 0x20000433acb4 > > ---[ end trace 0000000000000000 ]--- > > The patch makes the iommu_group_get() call only when using it there by > avoiding the leak. > > Fixes: a8ca9fc9134c ("powerpc/iommu: Do not do platform domain attach atctions after probe") > Reported-by: Venkat Rao Bagalkote > Closes: https://lore.kernel.org/all/274e0d2b-b5cc-475e-94e6-8427e88e271d@linux.vnet.ibm.com > Signed-off-by: Shivaprasad G Bhat > --- > Changelog: > v1: https://lore.kernel.org/all/170784021983.6249.10039296655906636112.stgit@linux.ibm.com/ > - Minor refactor to call the iommu_group_get() only if required. > - Updated the title, description and signature(Closes/Reported-by). Sorry I already applied v1. If you send this as a patch on top of v1 with a new change log I can merge it as a cleanup/rework. cheers