Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1503292rwb; Wed, 26 Jul 2023 13:37:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlF1cq5hFKn8D2HD6YKShIoct3dyNT57U2tDkrjOpZyknuL1utl0/SFEw6PD25LbAKQmBXHd X-Received: by 2002:a2e:6a0f:0:b0:2b6:ad79:a4fb with SMTP id f15-20020a2e6a0f000000b002b6ad79a4fbmr146940ljc.1.1690403866853; Wed, 26 Jul 2023 13:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690403866; cv=none; d=google.com; s=arc-20160816; b=PbpFoITXqKUKl9gKlwW3By2rdqwIFkDzACUht44l4zdhGwQsvK4+9xEoE6gTWQ7kxx ORoB2MsuGHAhiasUdtt8qZNMju/2tn6N7A96SzHCx7juytbGSXxvLCuvO3aEQXkzg4lO pdf+Ufnfanhcb8Hs0Dy27DwkYHjtBUo5cmNU/hq9kqj3vT25wpMG2yfRFS8CGJsfihlA 6OiHQfqhDCL/lRkJNNpePEptUtlhHtJDQzTowewbL7zmoW0/w09SZ8QxSpbdXaz9Md6w ALMARPst6erzSLDzcrGjBDoDQB1/uxPYeCyuODL80or2jG1PPFtTnJ7NnU7DbD2ieedO hYZg== 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=JT2UHI+2Np7L7QsdeetNAkLhraffv5kgEdfCjKl11Yk=; fh=yZgtMoXNFnuI4MfkTsPfpDfOSSWp+dWDpypnVgOaj2s=; b=RWKmNPQKuHvjD/0QoKDiyasnY5OMjE1cUbSUEX42PDnYDMYVJSUf25Jd4+dFAiR5ir SaD3Qd+4aWDaQuUqlgrvQcaMzkO5znAE7g7fq743D/U070ziluczGmV2f+sNoONUIKUf lDmdeooV76uHDMd9EKQpucfkw++z6JFsJq9JUyo9Yh8jzjeumZOTykx8ySdP1TGik+6t HA/H3NVJtCPCS+X2grX9pj/z7iy2TidacMX3W7xLLXE6MBEIMTdFj/fHTlvlbgJrPdft UozD0bAcuZ3E5HmR7gLEySzIQ27qEYbmUzlTVhEDmJzuEyO6TYV96MpAfGNAZDUnIJNs IBsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=VVF1b7RU; 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 jt27-20020a170906dfdb00b0098e0a14c670si10010595ejc.619.2023.07.26.13.37.20; Wed, 26 Jul 2023 13:37:46 -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=VVF1b7RU; 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 S231940AbjGZT2R (ORCPT + 99 others); Wed, 26 Jul 2023 15:28:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232046AbjGZT2P (ORCPT ); Wed, 26 Jul 2023 15:28:15 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99AAC2D42 for ; Wed, 26 Jul 2023 12:28:13 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1bbbc4ae328so958835ad.1 for ; Wed, 26 Jul 2023 12:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690399693; x=1691004493; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=JT2UHI+2Np7L7QsdeetNAkLhraffv5kgEdfCjKl11Yk=; b=VVF1b7RUawi3/QYYQt22u1jH5OUH1Tf8XnLnE4b/agwXthOwpe69728aWprc+cBAPp m1NzpejyJPFn+J7cEl/k4Xfw7NV/DNs921DAj4mD25qN63m2UV8rxLRjeMa24TJWqXH7 YevHJEPTBXycw8cNMxRiQayY5davffRodPeaquNPMlG3yhTbW+l2TZNv0KoNxIAjUf1u vx7QnvYOOpb+Nn9iea9EFg+zAfgVPq5/2O4eLtzlraYz5aepPr1S1PEGRUkv/ClpXjx1 oD0KN8QbT88DXT6sIsMyGXbNhhlwFsmmZRUM0BDYakuaZeCUCb/tpsShC/zQA5q7Janp MXpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690399693; x=1691004493; 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=JT2UHI+2Np7L7QsdeetNAkLhraffv5kgEdfCjKl11Yk=; b=APZK3EBRIN8fWw6YSv12WySkRBtK0qJVA0ylwFLP8kHh3wMuSo2Ln725WV/ITneuf0 QgiLe5akFhh3cNFPuSGp1x9XQpHNv32DLRFKAOFxC4V8JOglPaHArKuTtheRrYwTJXbG vXSmEK4VB0YTrWaCKz+3O940q8ojYZwsQeiwwDNpn0uJkM3u2eXU0SLLuh7lJxxzxeEG DQn7ZI769SX//yEba6V43Rzu26Z+wTIPBIoOprQ08Z25jLyqoSF1REYgeKcqPvr+mTrs VQ68w27MnnDHxjz+s38lsWRqtX3syyWYAPHBgWNnlL3S6XEuNIV2sN5OgzkWlOzKwc8k tLLg== X-Gm-Message-State: ABy/qLaaTV1wXwKBb80tQocCs5tmBuJl2yYuia0Rjm9iMMdCbaCEzqkY eFHu4s3IOpf/EKNiDTcSt+ggS6VE2e4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:ce8b:b0:1b8:2055:fc1f with SMTP id f11-20020a170902ce8b00b001b82055fc1fmr13036plg.2.1690399693010; Wed, 26 Jul 2023 12:28:13 -0700 (PDT) Date: Wed, 26 Jul 2023 12:28:11 -0700 In-Reply-To: <8f7ea958-7caa-a185-10d2-900024aeddf0@quicinc.com> Mime-Version: 1.0 References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-13-seanjc@google.com> <8f7ea958-7caa-a185-10d2-900024aeddf0@quicinc.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: Elliot Berman 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 Wed, Jul 26, 2023, Elliot Berman wrote: > > > On 7/18/2023 4:44 PM, Sean Christopherson wrote: > > TODO > > > diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h > > index 6325d1d0e90f..15041aa7d9ae 100644 > > --- a/include/uapi/linux/magic.h > > +++ b/include/uapi/linux/magic.h > > @@ -101,5 +101,6 @@ > > #define DMA_BUF_MAGIC 0x444d4142 /* "DMAB" */ > > #define DEVMEM_MAGIC 0x454d444d /* "DMEM" */ > > #define SECRETMEM_MAGIC 0x5345434d /* "SECM" */ > > +#define GUEST_MEMORY_MAGIC 0x474d454d /* "GMEM" */ > > > Should this be: > > #define GUEST_MEMORY_KVM_MAGIC > > or KVM_GUEST_MEMORY_KVM_MAGIC? > > BALLOON_KVM_MAGIC is KVM-specific few lines above. Ah, good point. My preference would be either KVM_GUEST_MEMORY_MAGIC or KVM_GUEST_MEMFD_MAGIC. Though hopefully we don't actually need a dedicated filesystem, I _think_ it's unnecessary if we don't try to support userspace mounts. > --- > > Originally, I was planning to use the generic guest memfd infrastructure to > support Gunyah hypervisor, however I see that's probably not going to be > possible now that the guest memfd implementation is KVM-specific. I think > this is good for both KVM and Gunyah as there will be some Gunyah specifics > and some KVM specifics in each of implementation, as you mentioned in the > previous series. Yeah, that's where my headspace is at too. Sharing the actual uAPI, and even internal APIs to some extent, doesn't save all that much, e.g. wiring up an ioctl() is the easy part. Whereas I strongly suspect each hypervisor use case will want different semantics for the uAPI. > I'll go through series over next week or so and I'll try to find how much > similar Gunyah guest mem fd implementation would be and we can see if it's > better to pull whatever that ends up being into a common implementation? That would be awesome! > We could also agree to have completely divergent fd implementations like we > do for the UAPI. Thoughts? I'd like to avoid _completely_ divergent implementations, e.g. the majority of kvm_gmem_allocate() and __kvm_gmem_create() isn't KVM specific. I think there would be value in sharing the core allocation logic, even if the other details are different. Especially if we fully commit to not supporting migration or swap, and decide to use xarray directly to manage folios instead of bouncing through the filemap APIs. Thanks!