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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98E9FC4332F for ; Thu, 2 Nov 2023 14:57:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E4778002D; Thu, 2 Nov 2023 10:57:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 293FF8D000F; Thu, 2 Nov 2023 10:57:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15CBC8002D; Thu, 2 Nov 2023 10:57:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 072B08D000F for ; Thu, 2 Nov 2023 10:57:50 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BB007A0F7D for ; Thu, 2 Nov 2023 14:57:49 +0000 (UTC) X-FDA: 81413318658.30.B62546C Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf26.hostedemail.com (Postfix) with ESMTP id E7D3D140013 for ; Thu, 2 Nov 2023 14:57:47 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=N4KieR8N; spf=pass (imf26.hostedemail.com: domain of tabba@google.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=tabba@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698937068; a=rsa-sha256; cv=none; b=e/KnRV4WaFJP9u8QrNOV4NelMYztL8cs5rHiMMaOCx4QKqJxGZOQe4s9tpTmqaLOhDMoI6 eAVxTU5g8Jar5CwEsasRtO3YsEmI2BnjfpgqcnoNUd8Xquc+XXdTNQ2G732KuMdF0fq9Vo mbcKnPXRbKqaMVBOmaVOSUMkKebTJD8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=N4KieR8N; spf=pass (imf26.hostedemail.com: domain of tabba@google.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=tabba@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698937068; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oO6y6W0Hx2JX7rhY2F9inSHXy5EHTr89TCOrnU0rbjw=; b=ijH8z6q2anCA0x47G2pJaGoxDOVxQG0o2QUvDxWsH79QdAV+xFdecfpGpnIhkuNK1HhNk8 ZqTviy6UvNMLl94t5DkXBwL6iTav1GArD8mapO5i1o+Yt8MEw/HaziQINmmU627FsNVWNM bAjoSw8a8+mL85BypBpATQA0pGhJWK4= Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-66d0252578aso6103166d6.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=kvack.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=N4KieR8NFobs5IU9ed+sQkspKpP+vZxhLYH7Us5e/RYfNHvTMBW4/+YlNLkFTNaiWq gpDukfRUdbt4q+C82rDbm1wkdp1NFGd51K62qQFk0pHs0OHg0gzBSp8txMj5kt0nKB+T bj2iAW5Gc0E5Wqez7YFpj1evtSbdxcnGYH8Fzcy0siuCkDzP2WNJzVEjY97UfN6DN4JJ vts7R8rxzL5jTMkXvQW4txLfoyX+Y05uKPo3s51UKRdG9BgyDe/KwmtaMpkkJoRVOcta 858uwsmbaxFHCYWIY8bhMnh4ScgHmoSQ9dWK6kSSVupzgfeOyTxMseO5y4r1Z//LINy7 rAPg== 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=maE2rPr7gT6SSZR91rdkb654vt2e1hJFVobiAUEkzGDBDOtz3apPwNagBDvwcNytp6 Ofzgn0XNWtDJaflQynVMObTTBxLAOtUx/wqsDuewhp3psQswYsLxIqRAxNVGdozoCVc9 Cc5ylGHb8XwievRFiB3WNMlFnMgYDer2JJIv8Zk94a0I+2UFtIzd79xpyImgl5/4vWPM Rt1dJMcaSQFmnn0RfYmcAlBdwlNnnWNl2fZuNGT5/HQ2r3iGHSpCxghEBSuUN3h5xi6X XcEd+DVHApB5qD7PCyPo/Octmy6oKGv8qYNywvwe6LMJi7tq8YTQZMk4rNKT5Ix8Nr06 hq/A== X-Gm-Message-State: AOJu0YyLZmTI1HrjTlbN0eZ8bpm2KE6A0ykbY71JbYMeMYw3RpBgeUov ozoYu7t9FZCRRhrb7NeS7b8hAXoIdmJj4xOxDl1c+w== 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) 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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E7D3D140013 X-Stat-Signature: 3eobtdp9mj34ibmkecretdw7jtd74ggt X-Rspam-User: X-HE-Tag: 1698937067-99564 X-HE-Meta: U2FsdGVkX1/PDb1QYelK+qI3vqRbHfo3d3TjCuSmgouClzJjjyW8mjFTuyf+EGBWQrT91KYfDE9qHPmTCyL20rkXKuLpIjE3R4SXzA3kO4BGdFgUoJYRTFHYumVLbXbRqDIs6EQr4nzVBG0gDb7NwxDRFzYoCoR1FBVKyzvvxwGHQGxGjLEg5aBWzVfmVFpkXZb/24plwklle0+XL5LqOJmdJPAMamQmOP1swe/karCr/IYyw6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89qBwxVINZpQocrfKr0bqCXs8i/7B0WJDJ6HS9JoSOIDCrf8a80h0nidYn54OwwduHNr0c1/fw0jHhBcxu+JtDAuFA3BHg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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