Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6734503rwl; Mon, 9 Jan 2023 12:17:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXtkOU5vE7EPJ5BUhnSBrnGDuN94MQzf/YALVw02dzJ52ab14imS+2ApdT6LQox3tsjvLYPi X-Received: by 2002:aa7:8d41:0:b0:582:b7a7:de13 with SMTP id s1-20020aa78d41000000b00582b7a7de13mr23208968pfe.10.1673295455624; Mon, 09 Jan 2023 12:17:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673295455; cv=none; d=google.com; s=arc-20160816; b=vMg1us0yniEN1k7X/7WyyiOhfgZdFzQjXX9CgFLGt0BwQhpYmRdX01t2l39u5gVU4P XP+6CrcThFmA72IgcaUQttNURZigOGCV0jReu5qfrAdBiodXW6IEmG2oaThjD8jwhOTd k+WqzSvCgEIRgip6bcvi9xKLBQmx01SHUzT+88yRKtZJr0G7L5tfugIhVKQDHBqvZReR cTEL76zR1QyhowbDTxKlmE2vxn/QvitEhVxLWMY3ucf6ILHZnOqxUZ69GXd5j7XX0QCh aGGP1VaTx8fn5I8Qz75+zcquR8Zg/qoHsVkV+h12X9TA6TtiYYttC4HFj7NivBC+Qpkt N+ig== 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=MS9c8pSDmVucTZdPdHhH3mdXKbPND6bL5OXnhsaz428=; b=vNvw9mIpgOj8+Axf7j8HX0bVTvPWXdcCoRPmcnQYphkh+weJt0YJ7zJ2EcA63hulT9 Yt0B7pmu227XjYR10o3s3KHn1hT5kIj5To+OXKUk0PUahJoROdNU/EXxge+L3e9I8OkW m3UpXhllVuIFD3Ydu4AGu9MdSslL0HT0pdSg7IpFvbY007m9W2ymV3okIcc7C1lQ9KSV L3cwkWw3wiA2RizKQyhFWV/Gzf2QGCE09Pi0nfPcvV4pQ8F+uHosiq9loaks3JRnpUes 5E02tmgWJ/xALI8um7J5RuBv+cdKhKjF0SA/BktXxCeHG1yB09J7kMW3bfwg60S1polM 8fHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=sOIFmmww; 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 w186-20020a6230c3000000b0058954c5a9a3si1745950pfw.121.2023.01.09.12.17.28; Mon, 09 Jan 2023 12:17:35 -0800 (PST) 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=20210112 header.b=sOIFmmww; 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 S237474AbjAITcS (ORCPT + 53 others); Mon, 9 Jan 2023 14:32:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237472AbjAITcN (ORCPT ); Mon, 9 Jan 2023 14:32:13 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ED01164B3 for ; Mon, 9 Jan 2023 11:32:10 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id k19so6946170pfg.11 for ; Mon, 09 Jan 2023 11:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MS9c8pSDmVucTZdPdHhH3mdXKbPND6bL5OXnhsaz428=; b=sOIFmmww5t87chNqg4RrjKvRSK55mbJUfkLlDwVdXFzdUVNQpuL8j+67d+DkgdzGV/ cY+1zKjyGAv7inACtQNgX5uUKu4ApW+iH+DVN7GkXfrRLLF2Mvo9WifnFmurzCTgdAvo yO0VsoKDonS/b5FpljJp4kIUzSG1uLseP8M04BYadiPR3LnDKhEB8JDIFZ6XY2cYQ9Ip q/lAxkFfWGCi4n140C5isaU+LhXs1upwAI92uUGwcJ28pRBl0VFZtoKmw+InBC55cTsl h4qHQp+F6duxw8RJ/SXhE+ei/WHcJpuK0DK+gQrpAmJlxVZpoBxyR4o9mafVKF6RyDWB AG3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MS9c8pSDmVucTZdPdHhH3mdXKbPND6bL5OXnhsaz428=; b=g9Y50uwC0HKrwtL69dnyU27VjEsnTl6mj+Ck1N+3g+ZL2V7Z04T66hPgJtBMg1Q1Fz NISNrj0ALzxqQ9y+Qm0ZdYPemjqgSGey2K9fje5ZoImYWDGlDYLNHQ0yJk1cEcvMhC7x L0+gAVHkRfgRihLGHJZYNdfyAaa419VWS3Lk5HbKVdbxz7gByfqPDDJlqCvO/u/mqgCB iMdRoVzFV2Yn3i1CSr1T3u/Nfg2FwT43kV7TpAFf3CVVfZo5c+qrvhVmzIk0pR5tUJAP KYj/77ZjHRgm89l/yxSPfaLSm2t3bUJgEBCr/qAD60dLffMes9ml3Obunseos0Fmg8Gx PHbQ== X-Gm-Message-State: AFqh2kovYY+ExgVko4/WfkVYcIL4T/DLPO9pMgoxqpLxGcL+z8o/wcxM NxmGmOTjhdi2bZ8qpOjbiUDR7A== X-Received: by 2002:aa7:973c:0:b0:574:8995:c0d0 with SMTP id k28-20020aa7973c000000b005748995c0d0mr742042pfg.1.1673292729425; Mon, 09 Jan 2023 11:32:09 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id 194-20020a6214cb000000b005809d382016sm6429041pfu.74.2023.01.09.11.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 11:32:09 -0800 (PST) Date: Mon, 9 Jan 2023 19:32:05 +0000 From: Sean Christopherson To: Chao Peng Cc: Jarkko Sakkinen , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Arnd Bergmann , Naoya Horiguchi , Miaohe Lin , 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 , tabba@google.com, Michael Roth , mhocko@suse.com, wei.w.wang@intel.com Subject: Re: [PATCH v10 3/9] KVM: Extend the memslot to support fd-based private memory Message-ID: References: <20221202061347.1070246-1-chao.p.peng@linux.intel.com> <20221202061347.1070246-4-chao.p.peng@linux.intel.com> <20230106094000.GA2297836@chaop.bj.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230106094000.GA2297836@chaop.bj.intel.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 Fri, Jan 06, 2023, Chao Peng wrote: > On Thu, Jan 05, 2023 at 11:23:01AM +0000, Jarkko Sakkinen wrote: > > On Fri, Dec 02, 2022 at 02:13:41PM +0800, Chao Peng wrote: > > > To make future maintenance easy, internally use a binary compatible > > > alias struct kvm_user_mem_region to handle both the normal and the > > > '_ext' variants. > > > > Feels bit hacky IMHO, and more like a completely new feature than > > an extension. > > > > Why not just add a new ioctl? The commit message does not address > > the most essential design here. > > Yes, people can always choose to add a new ioctl for this kind of change > and the balance point here is we want to also avoid 'too many ioctls' if > the functionalities are similar. The '_ext' variant reuses all the > existing fields in the 'normal' variant and most importantly KVM > internally can reuse most of the code. I certainly can add some words in > the commit message to explain this design choice. After seeing the userspace side of this, I agree with Jarkko; overloading KVM_SET_USER_MEMORY_REGION is a hack. E.g. the size validation ends up being bogus, and userspace ends up abusing unions or implementing kvm_user_mem_region itself. It feels absolutely ridiculous, but I think the best option is to do: #define KVM_SET_USER_MEMORY_REGION2 _IOW(KVMIO, 0x49, \ struct kvm_userspace_memory_region2) /* for KVM_SET_USER_MEMORY_REGION2 */ struct kvm_user_mem_region2 { __u32 slot; __u32 flags; __u64 guest_phys_addr; __u64 memory_size; __u64 userspace_addr; __u64 restricted_offset; __u32 restricted_fd; __u32 pad1; __u64 pad2[14]; } And it's consistent with other KVM ioctls(), e.g. KVM_SET_CPUID2. Regarding the userspace side of things, please include Vishal's selftests in v11, it's impossible to properly review the uAPI changes without seeing the userspace side of things. I'm in the process of reviewing Vishal's v2[*], I'll try to massage it into a set of patches that you can incorporate into your series. [*] https://lore.kernel.org/all/20221205232341.4131240-1-vannapurve@google.com