Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp22897rwb; Mon, 26 Sep 2022 08:49:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5QzrtjtLsB4qQOmoy4Z2M4XzyjfZpDk7TjiUDPRCBIoDOBDquvmQ3H4KqO8qKtVB81j200 X-Received: by 2002:a17:902:f708:b0:178:9b70:310b with SMTP id h8-20020a170902f70800b001789b70310bmr21913844plo.65.1664207368155; Mon, 26 Sep 2022 08:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664207368; cv=none; d=google.com; s=arc-20160816; b=muieRKIc+t7MbT9DGo5p+Tal9hZJ1PMtuqmSPOTDwPJLfkpDxPeM2+djJyT3HgMPxs Pt63AhWhNNStFShAuRWiFnwZ2u+NnrqFnpAW585RxgjW77AG7igUSgsOyRUTY2XR1Es3 SuUgRrMHOjXxn9/o3o0+qPT51vAD4zuAmBi6YBL+ODvKPd+xg619W9zEKDcMuUk4nYrR HjfCe4p/df+Fl9XS1/8vUHtNK5998ZjqVtXistAgxpbxNm1wEt88nXX7RNdabkUj9ORJ 9GRW+qJ1p571b85t6jZCgBDZeHuurlu3Iu4p+/ynVXbe+LBpBvlP4aTN8ps3fI6czjr1 TMFg== 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:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=U9s768cVE6V+EGMPk6A6KyhxWsgDnVllkPNP7U3f9go=; b=zQuxiRqzNt8V0hggoxKRNF4FmcPiDGoXQCJ01x+PESqOIFRpVrv2lKX3nczRhhckuR U3t+T8tTULua9gwxHQW8cD9Gn5kH2RFFWCZUNvcuW4XxQMRLummAlsjZND6Xo7tMlHhQ w4FiqqIrUHykjUvlR/Or7WRBo22plWN3kMDHoPkqhAhcqmDjgIEyselxo3Fbei16wYxu gJdsrQO8n5vyFxdY8AcBxDxk88rF6KXTP5OD8nYUspdo52RvuZyT0imHiTFfkYVKvMW4 vV1IBPO43fjUeBm5dY21TSoGWoudlLhUlSvwNf0F7PmGfrlBlq4UwWetfuekxJXOIgk0 PEzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iSJSXIFx; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i25-20020a635419000000b0042a75aeeb93si17331752pgb.521.2022.09.26.08.49.14; Mon, 26 Sep 2022 08:49:28 -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=@intel.com header.s=Intel header.b=iSJSXIFx; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236582AbiIZPZa (ORCPT + 99 others); Mon, 26 Sep 2022 11:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236689AbiIZPYC (ORCPT ); Mon, 26 Sep 2022 11:24:02 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8A71E3D1; Mon, 26 Sep 2022 07:09:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664201389; x=1695737389; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=kLBWR5qEV1U14bOBHrdj86S+fx8bShjKVx0oSvRe47k=; b=iSJSXIFxmEPPzzhQPc8Aq8o5dPkLSD+Nk04JxvzeMf0ETHkKRtT0A/XG Gm9rZW/FMCZ9Mk/wygBAcheoEHj3qBZnldcy+azn0woWxgMdAQsZwKvO8 MLi9TTLwzijWvRScze04ZMZURRt5yGnWOpePaxRSApG18DSY5qNmBWohP qtNWnL9ywD6dZAw6KOnYG9tp1vYxaZqYryWbuEpULNd8Vm0TT52/ny4Rh sNB/QJF3GHrOVNqyv+j0j8bxw5rEh5EGvEZ0j/dNWIlPx0lECYVzHB/1+ 4YZlCpZzAPVkRG0nE+b6wfOh2nWNllXsxaRm0C1IVSsJfFvLQHuvUksCJ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="365068855" X-IronPort-AV: E=Sophos;i="5.93,346,1654585200"; d="scan'208";a="365068855" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2022 07:09:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10482"; a="651840417" X-IronPort-AV: E=Sophos;i="5.93,346,1654585200"; d="scan'208";a="651840417" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.193.75]) by orsmga008.jf.intel.com with ESMTP; 26 Sep 2022 07:09:28 -0700 Date: Mon, 26 Sep 2022 22:04:51 +0800 From: Chao Peng To: Fuad Tabba 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: <20220926140451.GA2658254@chaop.bj.intel.com> Reply-To: Chao Peng 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: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 Mon, Sep 26, 2022 at 11:26:45AM +0100, Fuad Tabba wrote: ... > > + > > +- KVM_MEM_PRIVATE can be set to indicate a new slot has private memory backed by > > + a file descirptor(fd) and the content of the private memory is invisible to > > s/descirptor/descriptor Thanks. ... > static long kvm_vm_ioctl(struct file *filp, > > unsigned int ioctl, unsigned long arg) > > { > > @@ -4645,14 +4672,20 @@ static long kvm_vm_ioctl(struct file *filp, > > break; > > } > > case KVM_SET_USER_MEMORY_REGION: { > > - struct kvm_userspace_memory_region kvm_userspace_mem; > > + struct kvm_user_mem_region mem; > > + unsigned long size = sizeof(struct kvm_userspace_memory_region); > > nit: should this be sizeof(struct mem)? That's more similar to the > existing code and makes it dependent on the size of mem regardless of > possible changes to its type in the future. Unluckily no, the size we need copy_from_user() depends on the flags, e.g. without KVM_MEM_PRIVATE, we can't safely copy that big size since the 'extended' part may not even exist. > > > + > > + kvm_sanity_check_user_mem_region_alias(); > > > > r = -EFAULT; > > - if (copy_from_user(&kvm_userspace_mem, argp, > > - sizeof(kvm_userspace_mem))) > > + if (copy_from_user(&mem, argp, size); > > It gets fixed in a future patch, but the ; should be a ). Good catch, thanks! Chao > > Cheers, > /fuad