Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1080429rwb; Thu, 6 Oct 2022 08:13:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6C4Pbu5tdZEB+HzG4RNtNgeCeI45Yuz3y0VGGtppQ7R8F06GRmeMR72L9IZotTvZYViCLC X-Received: by 2002:a17:907:b17:b0:78b:b909:e91a with SMTP id h23-20020a1709070b1700b0078bb909e91amr222020ejl.687.1665069212890; Thu, 06 Oct 2022 08:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665069212; cv=none; d=google.com; s=arc-20160816; b=is4As98RAEs9P6LFSElm6EZZtxV7m2iuY5iI487lA5nteaeqD0bPkMceZ5nxRNqZ3H +UnlKgOWfkzPfv4aAsraxpX8c+BY7u3tpRquUc8uxIGD4S7NKS/Dx/ViqMBPzdkLEGeK eVKw3JDvcXbTDA5KwbvwqzEjVpqMqFOPWVDvS4zeGGCNiMEOSKs0hdaFbYm6xQbFEJHs HwdC4MoOADnM9fU7+WXMkxQrKRQRlesRFJ6F/y1P22bv82nCTT/OY0m1CbyJqYXBcF1E fhVCDptGMAJcKHWcMZUQYhYRo1pizZq/X0L1Qf+NG10WMmN3gihfkjvBASxsaIJZy0nq OeIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KRmbNv01TeRK66Si5Qfa4ra7p8rBTGX9T0XbN2LBkC0=; b=0roqL6wkzv3QcEAK1pwe+TABDNHdk6EMKQxDPh3RHyxUeNpOmOd4cZzYjug/8YphYV bTCwoEtr9ERz52OT53GK62RgDgQXBtcOMuc/wewZ5OEq4rOfLp6/EhJQOksA3tr1q2sP yCsvGp8/fww6yv7QJtY8hnL6R7uwB07xsG12ryZlIL4Ghzissl7YSDgdFMb0MqVJTXNh 4391HkJkB1KnSdUox2VV2LzXfcipTqvXeFQl3MY/U/43j/4rUWuS6aeGs6Ntvo55RTCk TlIPv5p6b6qTTkZ4PCYqiBKwPu5MtIqFihYDzOHw+5iHkdAG56zKUqB6rzQfkb1TjujB wmGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DDoMTX6M; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e5-20020a17090658c500b0077afe48c791si20013929ejs.538.2022.10.06.08.12.56; Thu, 06 Oct 2022 08:13:32 -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=@kernel.org header.s=k20201202 header.b=DDoMTX6M; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231660AbiJFO6L (ORCPT + 99 others); Thu, 6 Oct 2022 10:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230240AbiJFO6I (ORCPT ); Thu, 6 Oct 2022 10:58:08 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A29A1B0B3C; Thu, 6 Oct 2022 07:58:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 07F7FCE167D; Thu, 6 Oct 2022 14:58:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0517C433D6; Thu, 6 Oct 2022 14:58:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665068284; bh=RXFhbjUEgArTx+F4zk5xpYjaKPlDHCDpb+OAY/+J95w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DDoMTX6Mmge49xaH/Vf5qGs8klHW630VPsGgLM9+rj8RQP0JHyiHH1uczV+b1R4eR 37mGDnn/YEoya/uO44EFk31UHV1p6PNcV0Vy+zXZmhY8UWa6Tli2sQX7eKSvMhk/bQ WE6Q59ypwNyBMj2o8/le4Po0t1AibRVXGwyP8VOyi31XeJPyDSOKVtYbT0Me5TjbVc e6dC8MmxQL8IuMlafX5xmn2+S8RswUwiq5FpgRmaM3wy9qU6nBVGLxHWXFFDhsy4JS n2vkyUsGfyQbB67wXJD6MtcBFZCO3uv8vw8Cu6jrwr1HCPgxfxepmXSMpOxXVVaVvd AlmTRLMGWJbbA== Date: Thu, 6 Oct 2022 17:58:00 +0300 From: Jarkko Sakkinen To: Chao Peng Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song , wei.w.wang@intel.com Subject: Re: [PATCH v8 2/8] KVM: Extend the memslot to support fd-based private memory Message-ID: References: <20220915142913.2213336-1-chao.p.peng@linux.intel.com> <20220915142913.2213336-3-chao.p.peng@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220915142913.2213336-3-chao.p.peng@linux.intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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, Sep 15, 2022 at 10:29:07PM +0800, Chao Peng wrote: > This new extension, indicated by the new flag KVM_MEM_PRIVATE, adds two > additional KVM memslot fields private_fd/private_offset to allow > userspace to specify that guest private memory provided from the > private_fd and guest_phys_addr mapped at the private_offset of the > private_fd, spanning a range of memory_size. > > The extended memslot can still have the userspace_addr(hva). When use, a > single memslot can maintain both private memory through private > fd(private_fd/private_offset) and shared memory through > hva(userspace_addr). Whether the private or shared part is visible to > guest is maintained by other KVM code. What is anyway the appeal of private_offset field, instead of having just 1:1 association between regions and files, i.e. one memfd per region? If this was the case, then an extended struct would not be needed in the first place. A simple union inside the existing struct would do: union { __u64 userspace_addr, __u64 private_fd, }; BR, Jarkko