Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp435949rdb; Thu, 2 Nov 2023 07:58:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHiJCA6ZHojFomF5+Fg5HMH5npR1C3vN7QMaxmSMAQcGBdwoq7Fj4Ybrg+d/I6fghmPmE2B X-Received: by 2002:a17:903:2286:b0:1cc:43ca:b5b3 with SMTP id b6-20020a170903228600b001cc43cab5b3mr14940467plh.28.1698937081279; Thu, 02 Nov 2023 07:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698937081; cv=none; d=google.com; s=arc-20160816; b=A4bm1f/7rZLFUkep3NIVkXQvfobeR/WFmup9awbrny7XR7olE6hTqlzN6PzHFZtF/P JuS6c6BhaxZxHluXVSXi+jbZXbarH442gBoh1LfM0LR3pQricz8HNQMFwf+3HAND4BV7 uU3sYidtN1HBdlLiYQq+BtzA697FlH/wTzmt0mlJ8Q2oQxIwevnITVvjygEXr0I8GGvM YDtlOZfxpGWcoKY8+1/R2JweWj/7jNrKc67nxneisIwLhQ5nn+dBaRMkIAI1JiU8GZph GU8pa226/5OZA0QfTGaT9oR+TvWq+xcjfB6tYhzlm39r5azPTewPBPe1NJwp1fclVZae SDkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oO6y6W0Hx2JX7rhY2F9inSHXy5EHTr89TCOrnU0rbjw=; fh=xK+wiX2TTq7O2X4TlNj4MXVc7h6ma8eyuy1Ur/RMLHE=; b=MA+RiOnpyUMMbKe2ELuGm9AqxKdGTH1ZOT8cmQgfW53hrB3TT7Wde2EzhcHyOLipxd FmwhRWraDd1CHgVosiDx4XPzLd9kYwgkJ494sr35oM4R+UqexlR3K7cX9pB8sMP5OCOU HGB8BYdEXkMwKbSebLt5PCU8OaJ4XYoS5yanHVc7fw19CpAmjqrRaZn0vIbJxelUBL3b VqT0HtRti6UJzUhjGGJhUsIPtH5In521f8X9hC3rbRumc4wpta3VZB7s3dghdMEpOn0P PsNcWc5ljQkt9rEnK0/qHI/XGLcpoElv29lEhNGF+fV3RLmwh/sX7n5QpmjcsWXlxTSy I3MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WABnDmPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id jy5-20020a17090342c500b001ca0b64f5a6si181plb.449.2023.11.02.07.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 07:58:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WABnDmPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 837C2810F0CE; Thu, 2 Nov 2023 07:57:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229569AbjKBO5y (ORCPT + 99 others); Thu, 2 Nov 2023 10:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbjKBO5w (ORCPT ); Thu, 2 Nov 2023 10:57:52 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E46EA184 for ; Thu, 2 Nov 2023 07:57:47 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-778940531dbso60626885a.0 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=vger.kernel.org; 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=WABnDmPn5on4qHZIWANY+CuhNh4heHUUGc6Z1RpTJLvLhxOk+sFyH+7L2AMchSpL+J PqTaI1s7f8Li/A5NPoBSePZDyRbPHpIjbQibERvyfmOYab7P1mS/fEx/Ot1dD7SS07Sq n9IDH2JN36ixe5W+G1wkbrhTu0CciPOYRUXpGTs/Np6efSo4vcQl9aTaK6cHnRj/iEhT qAwV4QY/CeuwrE7DRseMVwtFTV8DJd0oawbA/2gsPZ7fZzws34hrWcbJ0hQ4jxOHVpMk t16vU8dc5ir/4snBt+0cgtgoUpngRtkZeb9eKQw/qFTh/kpSmArsYS3sMQiq1pXXbwx9 MGNg== 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=jHmFrm824Z5XCsMjR7B6GL7l0s1rO2k3yD++KOk9UcxWomXdY1L67eM7itt+zP7RPJ zko9h+w9amiT8VxozmE10aHl7dm6HGbUhTqUXYF3LJFasJkrMp3OpPnx9WLq749DnWTD i45YoqBu7EgMX7ox/5wqvo7XyPDmzVr/01omGnI8MEuP1uLh5mfkuG7VW/EQ1PIP3L6C wWjUp4wzRpjFEmsP5Xyw/kFucZMSKVwxD81/PyvPbHcwsdZICjMo/NKeIkJsj0giCKY6 PbMqKwRrv1kwbb8fUNl5503uGbb2UVngm1IYEq7McF6QnheMfnJMcUIDq/J/hVQevh1B qMmQ== X-Gm-Message-State: AOJu0YxsT/a4vBp6JFi6LCl6mkG0n33Fn1SX8JpZKs0nmbrs4jCUVXaA AHNGT8IU3meH1dKxDpxy8ZzeZoG0nYeZ44qhz1/DlQ== 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) 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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]); Thu, 02 Nov 2023 07:57:58 -0700 (PDT) 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