From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0FAD3CCF9F8 for ; Wed, 5 Nov 2025 15:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dmjmfo22QwufKip+RFN2GwcKXDk7+fDMohFzNqFh1wo=; b=yvK3Ak/soKTOD7pP8CCGGAK0Xt LiZvZUVM3VjgjUDTHOp3bPburnXcKNydvra23drFPpgnWEvYIPLUG5c77FLyrfZhCzcKRAEpkx0zP XAPRFYR8+Fs3aFV09l4FjJkhDWeWchfkxbz+/1jsYDwaxB2KdItXKjPoatvIcIRokC7ANDk6f0bEl 5i5092hsYMqvVd7Ep7UsBPBy35fwkFX9cwnEvp9xekQYjlOCZZwWhpNbCCNmQAtlcmT1FAOaI1gNy 7ga55lavbvP8MVeyAWchclhNUSjQ/aw+5PFCnbfuIeRnU9L3u2Jaq0nQnM4pFNXpi3AJGrJyHgfTG sSLeQm8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vGfPC-0000000Dw3J-31rQ; Wed, 05 Nov 2025 15:26:38 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vGfPA-0000000Dw2L-18Ts for linux-arm-kernel@lists.infradead.org; Wed, 05 Nov 2025 15:26:37 +0000 Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-3418ada9e6cso1978169a91.1 for ; Wed, 05 Nov 2025 07:26:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1762356395; x=1762961195; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dmjmfo22QwufKip+RFN2GwcKXDk7+fDMohFzNqFh1wo=; b=iDewj5jzpJ4BBrzV4dZGab58MK62rovLkvr+hG4RFcoGHlYhQv7iLb2JGDGOwxK9dG jtf7FF1RAcPgZhrqCQjjmO0qA7gXYDXGUBPkerDVd4wRMlYcBxzSaJspRzcrnoTufLx3 dnabE8POzccSz7v+pMgInT10JnK6JxxY1DPf4SR1gBbSBtQmfvDYuSRpozIdnd6RpAd3 xjwMhGgeJwqKPqN+H4uNLDSSfz0HtRY/y+3PiZtUVhMPxhZvIr3HWRlBCJmjAnF5wLyf nDF/UHn8LuZKREmY93wNgMGRX7nYM9Bgstq5reSDHh00uhZkIEytjxTV87HcO8w44EzR IgVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762356395; x=1762961195; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dmjmfo22QwufKip+RFN2GwcKXDk7+fDMohFzNqFh1wo=; b=rOfhGb4mD7aTT+TVEcC9kuZWFtufQvBmfmHkEATLvIrCWsW8zsIIK0Es0kdCrSaptC xU8CdXa4Yvc2EU2iJl9Xk9M/EiG+uOALHsWUktBRw+mmIKFSuOeddHlzMFMj6ZQPAcbz Tj8FTMuY0Vl8q4XJsNskdGCQbJ9EmLqxmPGIID3Tpt8mBYXAwOZBypNJlIAz1QWgX8v6 dE5FCNkIN4vRZjbL9XqtGnLe3NjZwzkDuCOPRUvr1dbeBA7FjMfKQFpKS417RTlG3woF P1nkodbNenTvT/oyGhuLB0j35F0BXIWbtpuYGsiQStOdnhkL8BxeldU/CVEJ56pp5bKJ PK3Q== X-Forwarded-Encrypted: i=1; AJvYcCU18+RX7wPeznimzJ9+IO2kZKQsB4n8wXPnLuj1bVNsqwFAVdw6P3DN3I1rg67Nf5dz1JOGgWNM9DKKuizsBwFf@lists.infradead.org X-Gm-Message-State: AOJu0YyjVuXwcZgCuXXAH2g25nzEd/fC27XqcGj/qa0Yuu4/LkCuuFVs 2qSOuhqKYqXmP9dBJjmsumBnA/K8RuipyMy7XlD/2MNBef3QGQmO1dZHyx5dx0l4sPpJ67Fim8G jVKAC7A== X-Google-Smtp-Source: AGHT+IEksiko2nLkYHDcuQoizh41Xk4dhEPlLcSxUswEaWhydqjlp9gNPv6q5VYl/pXem0FsGEVxprPZGIk= X-Received: from pjbtc7.prod.google.com ([2002:a17:90b:5407:b0:340:b503:505f]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:384d:b0:340:9cf1:54d0 with SMTP id 98e67ed59e1d1-341a6c08e65mr4623520a91.1.1762356395074; Wed, 05 Nov 2025 07:26:35 -0800 (PST) Date: Wed, 5 Nov 2025 07:26:33 -0800 In-Reply-To: Mime-Version: 1.0 References: <20251017003244.186495-1-seanjc@google.com> <20251017003244.186495-5-seanjc@google.com> Message-ID: Subject: Re: [PATCH v3 04/25] KVM: x86/mmu: Add dedicated API to map guest_memfd pfn into TDP MMU From: Sean Christopherson To: Yan Zhao Cc: Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Madhavan Srinivasan , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Paolo Bonzini , "Kirill A. Shutemov" , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Ira Weiny , Kai Huang , Michael Roth , Vishal Annapurve , Rick Edgecombe , Ackerley Tng , Binbin Wu Content-Type: text/plain; charset="us-ascii" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251105_072636_317352_B5FB1137 X-CRM114-Status: GOOD ( 25.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Nov 05, 2025, Yan Zhao wrote: > On Wed, Nov 05, 2025 at 03:32:29PM +0800, Yan Zhao wrote: > > On Tue, Nov 04, 2025 at 09:57:26AM -0800, Sean Christopherson wrote: > > > On Thu, Oct 30, 2025, Yan Zhao wrote: > > > > On Wed, Oct 22, 2025 at 12:53:53PM +0800, Yan Zhao wrote: > > > > > On Thu, Oct 16, 2025 at 05:32:22PM -0700, Sean Christopherson wrote: > > > > > > Link: https://lore.kernel.org/all/20250709232103.zwmufocd3l7sqk7y@amd.com > > > > > > > > > > Hi Sean, > > > > > > > > > > Will you post [1] to fix the AB-BA deadlock issue for huge page in-place > > > > > conversion as well? > > > > > > If you (or anyone) has the bandwidth, please pick it up. I won't have cycles to > > > look at that for many weeks (potentially not even this calendar year). > > Got it! > > On the other hand, do you think we can address the warning as below? > > The code is based on [2]. > Hmm, updated the diff. > > diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c > index 7b4a4474d468..543e1eb9db65 100644 > --- a/virt/kvm/guest_memfd.c > +++ b/virt/kvm/guest_memfd.c > @@ -853,6 +853,9 @@ static int kvm_gmem_init_inode(struct inode *inode, loff_t size, u64 flags) > inode->i_size = size; > mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); > mapping_set_inaccessible(inode->i_mapping); > + if (flags &GUEST_MEMFD_FLAG_MMAP) > + lockdep_set_subclass(&inode->i_mapping->invalidate_lock, 1); > + > /* Unmovable mappings are supposed to be marked unevictable as well. */ > WARN_ON_ONCE(!mapping_unevictable(inode->i_mapping)); > > > > As noted in [3], the only scenario can trigger the warning after [2] is when a > > process creates a TDX VM with non-in-place-conversion guest_memfd and a normal > > VM with in-place-conversion guest_memfd. The two invalidate_lock's don't contend > > with each other theoretically. Hmm, no, I think we need to hoist gup() call outside of filemap_invalidate_lock(), because I don't think this is strictly limited to TDX VMs without in-place conversion. Even with in-place conversion, I think KVM should allow the source page to be shared memory, at which point I believe this becomes a legimate AB-BA issue. In general, playing lockdep games with so many subsystems involved terrifies me. > > [2] https://lore.kernel.org/all/cover.1760731772.git.ackerleytng@google.com/ > > [3] https://lore.kernel.org/all/aQMi%2Fn9DVyeaWsVH@yzhao56-desk.sh.intel.com/