Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp427446rdb; Thu, 2 Nov 2023 07:41:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzl8bt2xudf8dY4NKtmzfiLFb8mxM1tgYbnIxyPDbP4Zm6ZQ7GEwUhx7n07TbCqlimTDi/ X-Received: by 2002:a05:6a20:7483:b0:16b:e46e:1246 with SMTP id p3-20020a056a20748300b0016be46e1246mr20697721pzd.30.1698936114002; Thu, 02 Nov 2023 07:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698936113; cv=none; d=google.com; s=arc-20160816; b=ondgYuUZBIdHY7nSRG249pOkrMskZK8wHHfIB5YfSBevqnV4jGS8VhOrgeaiMl3PBq FzN0Yb+gdUKkDYgyVlqIZ1OH03mKzZx7m9Tu0dVaDqwZjOCZK/RZMGE9LIuCHXsnBE+N o/5DmiBb4jxmNh0YHO8deLyuor8dyKfM+yAyGoxaBWkK63BirOjzzW89+tlFQ4lPjheD N9KgbvL4UX/rQnlB+I4e+MBs6TLQp1MyYpMVp+5b0Jkf8dw8RrP5lqclHgtPi7alGVRh g5jN00cFa0PztRhta43OsQJ5UXRpyia5FZB4N31JXQ1txZpjsJQR7CSxa/z5/DmPO+MT kVgw== 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:from:subject :message-id:references:mime-version:in-reply-to:date:dkim-signature; bh=xhBeRDHIuw2MhHJCiZzpmIP+VopsidfcOzvL++iqJMc=; fh=7qfmZqbAAQZvvB1jb24P2S6ewyTKmKV8ZEBWKlHGLY0=; b=GzpL6/xn1bjsinav+6k81KIihm7x6JnjZ0W5HVDcmbm2qCkmCGTVkQEn0G4TrUZx7t GR4gthnLg6cFLvYEymJOZjlWbYElWWVoUxTt70gQcNDImcdDT5NkRmOt2SquRReyUm6Q QiT95Kpg/C2ZlQSvQ42dsSlOz/FBb3/k1bXeorcqhHo58f9kU6elXYu+97C/p+bntIaU U3G5RrspQQECMgRMKSSgI+1GsRnjQTGH+pndAa2L7HDUKo3fiDn0gTk3CFrME6Rk3Rex K9gPcsk/Eeq1pV5jyBeb6+ldWaIdcLSHk31I8eY33dPQLXcCLQC/hKP6LbJJLUn51XhP D8MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=E8ebSa9c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f4-20020aa79d84000000b006c2d616b09bsi3476356pfq.346.2023.11.02.07.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 07:41:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=E8ebSa9c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id EB82782D878A; Thu, 2 Nov 2023 07:41:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230186AbjKBOli (ORCPT + 99 others); Thu, 2 Nov 2023 10:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbjKBOlg (ORCPT ); Thu, 2 Nov 2023 10:41:36 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B33813A for ; Thu, 2 Nov 2023 07:41:33 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-da03ef6fc30so1219681276.0 for ; Thu, 02 Nov 2023 07:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698936092; x=1699540892; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=xhBeRDHIuw2MhHJCiZzpmIP+VopsidfcOzvL++iqJMc=; b=E8ebSa9c6or9LYXHIbFKFTAuADYgYjM9eje8EFyHBw87GFEdLwCKcJ8i1m5xxy81u1 CRy05fuVNYjnG8S/xFRYsuF7mdsaYzuwSiFkg18oH0iky8DUUq5R6Z5dgpjX36yCBdD1 nkH2lDdLXHQXXHluGOv3deTIP/fInRgWG+/X2dyS3jabjNSq6MktO6nIU4sQfTNhsyxv z492XWb4v+voUQCfH2CXS+uivzWYdEjTDaxFPf70Xxr9agZjx6YdIJBoSoxp3pEvfIPX H7ufQX/vWv5ohN8/0DPI+udxnJG8E7NBGxZT66sCftP7Xj/OOJeV6NJvDIDZ1UP05ULr 3TvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698936092; x=1699540892; h=content-transfer-encoding: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=xhBeRDHIuw2MhHJCiZzpmIP+VopsidfcOzvL++iqJMc=; b=v/mTIugMtVhNiZkt8ykH6Xy7asHbLH2a+JGutFW708xIWIv8EOsmlp07f4y0uYsnrN ekRpuXkpyoK43eLZONc7zq2ksO12rjvmkeYW4egNRoYk/r6scYsBAcsnH3NZjn/b+2OK DVf8844R0V/MWSNZTfUWxbIdEj7OsJz27goR52YTLJOxZkvj2KSCXEuzm0uODmvVnimw N+FNnanpVfwHXZ1cHlsAj86hnz382/QabtFdH5is42IR5HaGJXNaLUlUxN83bMFH7/Uj LM5ogFB56t28S7lFZDlKHypF7BwncdTzscXY7DDmgBPOeQJ/8rzLGCB2usJ6BO6h6tie X6lg== X-Gm-Message-State: AOJu0YxQ5ilwH4y/iYB7h0aAyiNVBCfoQLz01fAr/KPHAOVZ1uXDW/jQ spw9F+EjSOClnwOdMg/AfqfgMmKjNuI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:2fce:0:b0:d9a:f3dc:7d19 with SMTP id v197-20020a252fce000000b00d9af3dc7d19mr331431ybv.11.1698936092597; Thu, 02 Nov 2023 07:41:32 -0700 (PDT) Date: Thu, 2 Nov 2023 07:41:30 -0700 In-Reply-To: Mime-Version: 1.0 References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-13-seanjc@google.com> Message-ID: Subject: Re: [PATCH v13 12/35] KVM: Prepare for handling only shared mappings in mmu_notifier events From: Sean Christopherson To: Fuad Tabba 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?Q?Micka=C3=ABl_Sala=C3=BCn?=" , 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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 02 Nov 2023 07:41:51 -0700 (PDT) On Thu, Nov 02, 2023, Fuad Tabba wrote: > Hi, >=20 > 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 only > > shared and only private mappings, and write up the existing mmu_notifie= r > > 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-state > > 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; >=20 > 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 app= lying it now to make their lives easier. But if only one needs the support, then= I completely agree this should be punted to whichever series needs it (this a= lso 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 non= sensical. 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 conf= usion or an unsafe default. I.e. I want zapping only private or only shared to r= equire the caller to explicitly set a non-zero value, which is how I ended up with "only_{private,shared}" as opposed to "process_{private,shared}".