From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37E301B274 for ; Thu, 2 Nov 2023 14:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OUvo3mzq" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-777719639adso59161785a.3 for ; Thu, 02 Nov 2023 07:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698937067; x=1699541867; darn=lists.linux.dev; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oO6y6W0Hx2JX7rhY2F9inSHXy5EHTr89TCOrnU0rbjw=; b=OUvo3mzqxfaAoOh7mkwn5Zy0ahatDbHLJYvcQypZVvFyal1EgtU/64YCzX5izmk5X/ XYIN/OSTxAAeae2jYMdJt1bbg6ws5MfrVPCeGW9LOQdZ/04YyQ2zC0hwrA29DrKRY6aO jhmkCWYxQZKMkTkD+6c+sJE0OapE0FuKXsaLJc2kYOzo6zFKHptyRbTlsr2v1DinPaoC FDhvMSqnGWmYEvjPv0Jjk7eRm/xWi8gC++DNyEnlz+SzIioZkdQfcscDJOg4eTKoEMXn nOlv2cglIAvkgi3PJ4+2kkCmsOGEG4pgtKr56iFRslSO3a42pxkJ+wzt7mvRirALCMWR 7GGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698937067; x=1699541867; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oO6y6W0Hx2JX7rhY2F9inSHXy5EHTr89TCOrnU0rbjw=; b=tBUn1v54DgR2mZUVTr6Xydd0OQTC5zavbVykRe0hmMDtb//TO4ql6PvGwAlQh7Tpzr Q/KrzEP+o/L6PNphuOMoHJkUFBw+z2kvWwJPRQTlIYUT20KYd7mcE54yIUhO2DmhNefm MxQpkejvVHruZ16nAd91gG6mNTbcxAe1fPijIvltr0C3aLSloFWJ+7FQ9xRdU9iEazS4 4fbHEBYrndH1VRlI2j3Pt8yi1Zv1mpx3PCzaL3tsDoVrDnxFBk4abOAlj9ge/dUo8nmY rqQNGTNyecfwZW/J4igLaCP/1TQDUcdUxZzIxOMVd39IIeVMTrc7JU+lkHL+O3H6S7+c A5dA== X-Gm-Message-State: AOJu0YwHDk/O2eHirMkFrBSq8h8+26p/Kz1RTwyTkWXQxWOxapjrjsVf uMgNqGTkNG5Ri7MFL5xLuvyndeaX0FkmmkBzkF/jpQ== X-Google-Smtp-Source: AGHT+IHH5fWOUl6XWE3cRbRkmtci3EQG11sJ5sTElOUO4i3o8jogptvsMwjY2tQIjVOiF2P5A518xtVBqTDVb2uPT1o= X-Received: by 2002:a05:6214:252d:b0:66d:1b2f:3f64 with SMTP id gg13-20020a056214252d00b0066d1b2f3f64mr24532994qvb.31.1698937066885; Thu, 02 Nov 2023 07:57:46 -0700 (PDT) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-13-seanjc@google.com> In-Reply-To: From: Fuad Tabba Date: Thu, 2 Nov 2023 14:57:10 +0000 Message-ID: Subject: Re: [PATCH v13 12/35] KVM: Prepare for handling only shared mappings in mmu_notifier events To: Sean Christopherson Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Xu Yilun , Chao Peng , Jarkko Sakkinen , Anish Moorthy , David Matlack , Yu Zhang , Isaku Yamahata , =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Nov 2, 2023 at 2:41=E2=80=AFPM Sean Christopherson wrote: > > On Thu, Nov 02, 2023, Fuad Tabba wrote: > > Hi, > > > > On Fri, Oct 27, 2023 at 7:22=E2=80=AFPM Sean Christopherson wrote: > > > > > > Add flags to "struct kvm_gfn_range" to let notifier events target onl= y > > > shared and only private mappings, and write up the existing mmu_notif= ier > > > events to be shared-only (private memory is never associated with a > > > userspace virtual address, i.e. can't be reached via mmu_notifiers). > > > > > > Add two flags so that KVM can handle the three possibilities (shared, > > > private, and shared+private) without needing something like a tri-sta= te > > > enum. > > > > > > Link: https://lore.kernel.org/all/ZJX0hk+KpQP0KUyB@google.com > > > Signed-off-by: Sean Christopherson > > > --- > > > include/linux/kvm_host.h | 2 ++ > > > virt/kvm/kvm_main.c | 7 +++++++ > > > 2 files changed, 9 insertions(+) > > > > > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > > > index 96aa930536b1..89c1a991a3b8 100644 > > > --- a/include/linux/kvm_host.h > > > +++ b/include/linux/kvm_host.h > > > @@ -263,6 +263,8 @@ struct kvm_gfn_range { > > > gfn_t start; > > > gfn_t end; > > > union kvm_mmu_notifier_arg arg; > > > + bool only_private; > > > + bool only_shared; > > > > If these flags aren't used in this patch series, should this patch be > > moved to the other series? > > If *both* TDX and SNP need this patch, then I think it's probably worth a= pplying > it now to make their lives easier. But if only one needs the support, th= en I > completely agree this should be punted to whichever series needs it (this= also > came up in v11, but we didn't force the issue). > > Mike, Isaku? > > > Also, if shared+private is a possibility, doesn't the prefix "only_" > > confuse things a bit? I.e., what is shared+private, is it when both > > are 0 or when both are 1? I assume it's the former (both are 0), but > > it might be clearer. > > Heh, I was hoping that "only_private && only_shared" would be obviously n= onsensical. > > The only alternative I can think would be to add an enum, e.g. > > enum { > PROCESS_PRIVATE_AND_SHARED, > PROCESS_ONLY_PRIVATE, > PROCESS_ONLY_SHARED, > }; > > because every other way of expressing the flags either results in more co= nfusion > or an unsafe default. I.e. I want zapping only private or only shared to= require > the caller to explicitly set a non-zero value, which is how I ended up wi= th > "only_{private,shared}" as opposed to "process_{private,shared}". I don't have a strong opinion about this. Having an enum looks good to me. Cheers, /fuad