Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9733883rwp; Thu, 20 Jul 2023 08:59:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlFDu449IQJTL9yYTQLirszIWmmtQQM7I2QlgPreN+3RyqM80odTwK753mGrqmCylQP9l4OJ X-Received: by 2002:aa7:d4c1:0:b0:51e:26a3:1bad with SMTP id t1-20020aa7d4c1000000b0051e26a31badmr5641411edr.16.1689868781939; Thu, 20 Jul 2023 08:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689868781; cv=none; d=google.com; s=arc-20160816; b=zu8nCZAVfJaolL9NVrz55cyumavfBjdPsCd2dGfL4cwB3/HWQvVHVvHmv65YMsfM3E DK6FLtuhPVYR7YPAeHi9JwqV4n9dfOUfac8ihIhpCKCoZwyPgPIpJLQYVp/wBvozOE7C LwvhLgG/YcYFFaTldMYgzxxBG2KWdSthPseJOxR36eUbtNfL7JJSi8J1l5i9skF/p68j xFkAE5LytRdSU09a7TZluV0Fwc2AV3ae0wLpZnX4r4FvmKwwA1XcgDYhnEsHgGJ0E2To IPczge9bDlg0NQMD7WGHqS8WFr/UKC+XswA9zdFXaQpdzORPqdAU2n0k0YDUwnFn+gTl btuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=jyO/GZcznauRS+IxFjefkQ411ageTxV8Pq4vykaVGvo=; fh=rA+Ko9v0V9Jfzej/2wEh1JRvK18On0jiMoTgR8zJcIE=; b=fgIHQqt+/CbxAw6NGZa/ywaRHynVeW6LQpeR1Yv+u4eebArE49P5mypp4XuVcx7KnN UZ9ieQThkvYMzlTC6UAyzQcjl3XXWNz7p19i7KiqzHq0K5tldoW8Aax81ADbEX8UyvZ4 bPdAEDHuodpA51bWoujUCGdgjDuOB9UQAlxPF9Lm4Va1FMhph07VXehq2+bTvHm6RpL4 XvgqsMDY1ppNKwCe6P50TbehHuvxSWllB6l5jCqAeoTcO0zIaCv58jxissZaS4f7SYfe J7QcSjDX00g+DrsvEgj89Z7Jq0ZsFBSDQ1ZDDE8gGQFDGpqfxjyxE0ixNIjTELLzaQJC vgjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=zTnr2gXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g26-20020a50ee1a000000b00521d18821aasi1011294eds.109.2023.07.20.08.59.17; Thu, 20 Jul 2023 08:59:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=zTnr2gXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232474AbjGTPPI (ORCPT + 99 others); Thu, 20 Jul 2023 11:15:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232505AbjGTPPA (ORCPT ); Thu, 20 Jul 2023 11:15:00 -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 597E8270F for ; Thu, 20 Jul 2023 08:14:50 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-cab7304dcccso778180276.3 for ; Thu, 20 Jul 2023 08:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689866089; x=1690470889; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jyO/GZcznauRS+IxFjefkQ411ageTxV8Pq4vykaVGvo=; b=zTnr2gXYIfqrhSL0WP50qLuqh3ZSH0gfVOnKmqwBvWYCge11/urc6Mcz48DQC5VeI6 s/bgjrFlzBMXd0PxaHBdxoR2ZqKrVqjnkCnhcQbbSnTvJYQ3aBe8wGkYdi1iCIBydfGh kDBro1Ztm9Xs7cfFTvZ7Ey8Gxe05PCCIDn4nx9L+2nwHbFPbro9d3jap/zFGaLY9lF26 GO0Vu5OUt+nUmBQOwJoSD8n40MC7ZQXlXpaj59Y1nIZxZy5/TzmEdTKZZXkcpmTSKYdO Y0fmzsgj8zCYsvUdMgpPWIv3Ur8RBp8NDUrrxEURomdLy8NcckIjCEtpSXTS4KS2mzFS 29+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689866089; x=1690470889; 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=jyO/GZcznauRS+IxFjefkQ411ageTxV8Pq4vykaVGvo=; b=S4bywP6UpCGbHJceMoHSmgHKXfm58ZNaN/RzsoEeu7mxzRrkx8R2lEpNrrqdSZk64O Xpklnc5JONg1FMnuAGHbecbdEzj+fiIt2PLcCX8zp3kkQhSg+8PosfRMRpsBvkgYMmUV iqj0hO2zLiX5t5U74ApaBeNKm0e+XskEWyUSdEcR0AkukDlTOn8hKjDxnXTDR+rBMN/e OnBI+AuNE3R4LoSNm9UCkrIS87DYvAgjG8roQtvb3BkN12OQGYjv5dwgjOWKuhZ7m1HJ y1dszvgCywPvDQkKFiz1a137RA9scJ9KdqH+dipzmAfCAYTv6s/1p+O5WYrwzrBhMu/E TZjw== X-Gm-Message-State: ABy/qLad3JXG8Ek1SOIrbivi1lXuwTJu8Ax6W5npgZlPPSZ4d84O/MnK UcpSrwLy+bypeB9Ak992+KPhP0zZdVs= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:a105:0:b0:c65:8983:ac2 with SMTP id z5-20020a25a105000000b00c6589830ac2mr17912ybh.5.1689866089303; Thu, 20 Jul 2023 08:14:49 -0700 (PDT) Date: Thu, 20 Jul 2023 08:14:47 -0700 In-Reply-To: <83eb5c50-7287-7845-ffc3-a7c58e638ea5@intel.com> Mime-Version: 1.0 References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-13-seanjc@google.com> <83eb5c50-7287-7845-ffc3-a7c58e638ea5@intel.com> Message-ID: Subject: Re: [RFC PATCH v11 12/29] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory From: Sean Christopherson To: Xiaoyao Li Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , 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-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Peng , Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , Vlastimil Babka , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 20, 2023, Xiaoyao Li wrote: > On 7/19/2023 7:44 AM, Sean Christopherson wrote: > > @@ -5134,6 +5167,16 @@ static long kvm_vm_ioctl(struct file *filp, > > case KVM_GET_STATS_FD: > > r = kvm_vm_ioctl_get_stats_fd(kvm); > > break; > > + case KVM_CREATE_GUEST_MEMFD: { > > + struct kvm_create_guest_memfd guest_memfd; > > + > > + r = -EFAULT; > > + if (copy_from_user(&guest_memfd, argp, sizeof(guest_memfd))) > > + goto out; > > + > > + r = kvm_gmem_create(kvm, &guest_memfd); > > + break; > > + } > > Does it need a new CAP to indicate the support of guest_memfd? Yeah, I meant to add that to the TODO list and forgot (obviously). > This is patch series introduces 3 new CAPs and it seems any one of them can > serve as the indicator of guest_memfd. > > +#define KVM_CAP_USER_MEMORY2 230 > +#define KVM_CAP_MEMORY_ATTRIBUTES 231 > +#define KVM_CAP_VM_TYPES 232 The number of new caps being added is the main why I didn't just add another one. On the other hand, we have room for a few billion caps, so one more isn't a big deal. So yeah, KVM_CAP_GUEST_MEMFD is probably the way to go.