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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B496AC5479D for ; Mon, 9 Jan 2023 19:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237583AbjAITcQ (ORCPT ); Mon, 9 Jan 2023 14:32:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237426AbjAITcN (ORCPT ); Mon, 9 Jan 2023 14:32:13 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EA98164A6 for ; Mon, 9 Jan 2023 11:32:10 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id h7so2763670pfq.4 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=waxTPnK688aFMwZxRpryc2cvJ8SCD/nv/zUb9+N0m8ESvSPsKkBv8Cvk9wefoJ8V22 5Qh7Drbe3WwnTnDdgzf7vaQ3P9F3B2pJLQx8pR9N3NrlBBZPfSm2Bz3XQRkhCNeJl5st abQHPMsrj8KhkPqtaj8gQLThySc6c6pcfp7IHboOHKlQBfOUENgGCFALJfRE3p9tRVBw lqfyNVriYceTqb9K+UvFR7poRDABILz3VYmPW0EviOHVRZwbx5qPEp082RoP7lKOae2z ap49mN201Gu9hFYBoUZHS3E1yf8zfH8hOIy6118LQdhPCUYgMb4Z971dX0K6gypRiaOf q6aQ== X-Gm-Message-State: AFqh2krg6bcjAqgiRAg/exK0eU24aYGUPXCegauyKciUYznrykIurnlK cGCbdBrP7LREcVcRDFFIDr52eA== X-Google-Smtp-Source: AMrXdXsOvwNIYYmxRZ1A4P2qL2M11DO9ETy3xVnstT6ROBE9IIpgFgsb6iMlmsjwANei+MKsQQb7Fw== 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> Precedence: bulk List-ID: X-Mailing-List: linux-api@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