Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2183182rdb; Sun, 3 Dec 2023 06:10:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhXNJ9X24Mt7bntDbmUlBHrM5Zh2/QONg9bw8ubJ8r7VXtqmdKCD0W7JFw8q83uTcJvyim X-Received: by 2002:a17:902:e845:b0:1d0:977e:2994 with SMTP id t5-20020a170902e84500b001d0977e2994mr94845plg.36.1701612641427; Sun, 03 Dec 2023 06:10:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701612641; cv=none; d=google.com; s=arc-20160816; b=0y3+mdMctWBUKmyLgPv5rvmI/s7u/FydsaoXwI0AMdwDm5WxFVEH9hDKGAcw1EFtjw MDa8u36YVQbzLbNwR7SNIls8BkCaax/ulwzstsfhlYSXjgA7Ug7iQ38KsPkujesshhSa 5p+LPlMu9eYuNU8bH0NqEMRAKIiOY3PQzQKBtpo6TBlL/MDm3+1VCMy1UXV7HQB+Outj KnEvaxxWYgyMRvtqe6WJhEgV4cVPKkkIskb+pMj/HBPzReI9mSuduXGRH975qBXUKTNm h13HI4PWVl8/dkcch8O7tFZYSLon8tSOH8Iy0dvx16sMoXzlTAu2DArifx8IUyye21E5 8NSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CiMNgzFr7xNUwBtnhCHdgoiuX87pimcKNL7aMsL6fgY=; fh=LvR0iFQNUCFuLf0e0dfpbwu/ZRO+ihf5gBz7bBaQp/0=; b=o4GnMv+P5OqDX4/CgCJ/iHE/+j7bJc/xpYTsBtUVNo4xX3xBjaSicFjhva1RoIXJAV kAD4svon92hsFg8Wm+HURtl77BFY6Ksx9oKbLmT44R2jFRNofik7Ue7sfb99/z7lx5CM tXRI2zJ57Cw2i/nEUOdSMRy7hrSqUtG5g9k4Idwq2TuW2B+zyPcFzLb0sh0KH7IK0WGi pnzU03OJJLpO2Ync/NjxCGtlwRZnj+Y3I5VctNMJelcKXigUWzcpMXMo/GcXvdyf1qHZ Z6j6z1AHQIfprJqstTJK7yj/C2eLJ4MpAVkz0DamyYt+40AtF0FByGceDP+YYKgP6JlE JhlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=OKzguQkS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d10-20020a17090ad3ca00b002851c699781si6258841pjw.154.2023.12.03.06.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 06:10:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=OKzguQkS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3C8B0806920D; Sun, 3 Dec 2023 06:10:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233386AbjLCOHz (ORCPT + 99 others); Sun, 3 Dec 2023 09:07:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLCOHy (ORCPT ); Sun, 3 Dec 2023 09:07:54 -0500 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFA6FF4 for ; Sun, 3 Dec 2023 06:07:58 -0800 (PST) Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-67ab5e015aaso6751036d6.0 for ; Sun, 03 Dec 2023 06:07:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1701612478; x=1702217278; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CiMNgzFr7xNUwBtnhCHdgoiuX87pimcKNL7aMsL6fgY=; b=OKzguQkSABjtxWcOMcm+Qbmet+nHku05O6x23HTlp1qxdIcYZhiIeX07SPUb1E2IF/ kYP/aC1uzAYZHJX6YNAFeYWxjkGz87iG6PM5xB8mIeskDKJW2Jd1oz2mWRNywi13ddRb rL5cnPtHr04ZcvHCFcbbh1FJ3/i2ih0Z2s8KEqc8CV1X69q2fEzRg9NPvGRmq1DUEy2L I01Fz22rSLoLI7+p4usNhV5XZetpCquDVJjGgygKl8tZYmK2sYyXfqyqacbQwAyEVJci zescEoj/ayE/KRPps3Qc6uCwyA3DUXhbQJpwWZtn7ppvYg52EJ+lhK/mbycRZIl2Jn2J sZIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701612478; x=1702217278; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CiMNgzFr7xNUwBtnhCHdgoiuX87pimcKNL7aMsL6fgY=; b=rNEZxx6sux7oM1JbwIzUQXTGQnR7Eamu1rhnsTSrAR4K0XhaLS65X1SwgxkXSPII5q zs5k22ddfy2UtDDElIdFH5z2qyexa6KmNFHAxgzZ7MSXODk457cTOoSb2GGrPqOvFIq6 mVOBdpFbSu8fyw1koGTVEvAORZgmUwAOEpDMUgZZofb/YQKMva7SY0uQ77U7luou/VFT 88lNA/hyae0A/G+fdMHsfcsHnU06VnycGs9tGjAiN4pek9tctcqDjIaTeU+okZUnz4Tf mjQSHtYWK1m/wmv/qCwicJMlOyla6tlPTPmhNGh/EGMDdJ+XNO+669qlCOUULFAfXHAJ Wwng== X-Gm-Message-State: AOJu0Yzb0ZcY5TgZ1l1+uAJmhei9Pl1yH/y7Uc1y0Qqi0lTEMnfkyjK4 EqiYC5iehr+kXmUuI4XYtUbxHw== X-Received: by 2002:a05:622a:7148:b0:423:e4f1:4958 with SMTP id jc8-20020a05622a714800b00423e4f14958mr3926493qtb.56.1701612477906; Sun, 03 Dec 2023 06:07:57 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-134-23-187.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.134.23.187]) by smtp.gmail.com with ESMTPSA id z9-20020ac87109000000b00419c40a0d70sm3402958qto.54.2023.12.03.06.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 06:07:56 -0800 (PST) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1r9n8W-009HdE-5C; Sun, 03 Dec 2023 10:07:56 -0400 Date: Sun, 3 Dec 2023 10:07:56 -0400 From: Jason Gunthorpe To: Sean Christopherson Cc: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton Subject: Re: [PATCH 05/26] vfio: KVM: Pass get/put helpers from KVM to VFIO, don't do circular lookup Message-ID: <20231203140756.GI1489931@ziepe.ca> References: <20230916003118.2540661-1-seanjc@google.com> <20230916003118.2540661-6-seanjc@google.com> <20230918152110.GI13795@ziepe.ca> <20230918160258.GL13795@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 03 Dec 2023 06:10:37 -0800 (PST) On Fri, Dec 01, 2023 at 04:51:55PM -0800, Sean Christopherson wrote: > There's one more wrinkle: this patch is buggy in that it doesn't ensure the liveliness > of KVM-the-module, i.e. nothing prevents userspace from unloading kvm.ko while VFIO > still holds a reference to a kvm structure, and so invoking ->put_kvm() could jump > into freed code. To fix that, KVM would also need to pass along a module pointer :-( Maybe we should be refcounting the struct file not the struct kvm? Then we don't need special helpers and it keeps the module alive correctly. Jason