Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp273551lqi; Wed, 6 Mar 2024 17:29:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV1Gxhk62MGDyuxqfxX/DAdKmkPunYEDFGY1QL5aCXmVAoC4KTxtzhu/x0+0RTvAKqy56L15+uZpkYTrFf0LtgKeAiR7aXZW4QQGk/shw== X-Google-Smtp-Source: AGHT+IFBdPIHx/OIlMx37MwjnSHtbowU4vXPRbfMftfQTIOiDfk48RWEvvGaLZRUElhUgJuNBHSN X-Received: by 2002:ac8:7d96:0:b0:42e:fb6d:de88 with SMTP id c22-20020ac87d96000000b0042efb6dde88mr7557520qtd.31.1709774987507; Wed, 06 Mar 2024 17:29:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709774987; cv=pass; d=google.com; s=arc-20160816; b=mCqZ81Kz2Ss0wKG+kW7qwgWPQ7FWZVTY1Szo1ESwv3kCk/6xcbijubzgDopvNo8Vqa m5XIGWhwL3T1Ozme95DTERwyMisqfDuCQvh3KgUHwFUZDkeFE82WsBec98xafY5O6GzP NaOGOx4fFRAEq3ewxNmKCiNwJRm9p5SVxt3v+HV7pULknIU2ESarCeyotDaC+PIl5paj Q5+YFrQ4fn0LIPciW2EBTYvHSQBr0Q7g2EkzxHjW0QDR169T/N2IK/LyGvsIwdtvZbs3 lLcEVhlgfuRPLG7q8hUBKBdI4ixdoCEtzTwp1ELzPw0qVW/Nm6ThS5TQ7Wh/QQbh4oKa tzDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8nnIwqx6RLY9AbMQCkSa8uey/+aODFMNwvbUpm3iz6E=; fh=UgqpCNH9WwmosEfqySsUNEa2pBAicm1yju45jT3AJTg=; b=w6tj2t5E5xxLC8ulQxJdnOqn4gfJ4X2DnDdRQByn2wIK3ei2j9Qp0SJwVmrxf5Ay7d gZuePd7iC5Jjw4N8u1t/kjtEdO+y7KljUsVT8TP9yQ3Q+FtA06gcDviAGqNPuTIA3Jyv boWGB4/zFDV/LRArgXieZcxFo274n9PO3fmEy84NIHRpZP1TFKFjVbKwTwdpHtNlskEk HhQruOm0rlK/Y5g2ayQcJeGi1iKl1v8dcDOREPh2mLBpGQUo/LrN9kBNf5OwEhEMaBmy iQtzFA2/vdnPpWbQssHBQuOExldt8q7EXToH9GPWtxnxgh4NfM8stXFgyWBvz3jQJHkm eJYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="l/tX6S8n"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-94823-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94823-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 2-20020ac85942000000b0042ef6216ca1si7820309qtz.643.2024.03.06.17.29.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 17:29:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94823-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="l/tX6S8n"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-94823-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94823-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2498A1C21887 for ; Thu, 7 Mar 2024 01:29:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F5C84C98; Thu, 7 Mar 2024 01:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="l/tX6S8n" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 834F91391; Thu, 7 Mar 2024 01:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709774978; cv=none; b=G3tuKw+i8+KSsQCJDxzPL1maWy2N5+VkdDu1biI91V8UuSuc+18ko+3nfvff3FL5fx18zAJMAMsYwgvrV/pVvA+vlsDugK3+zm3z5eamlrYGFukCyEN/kK4UT4uGAjoJgUmGdfqkBoLth9dRa/FcK3Z/xeD2uhDWV/2mHdWgXD0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709774978; c=relaxed/simple; bh=+G3P5fZ1KtJkD5uP1P0r4wxS61wLtCc7RBBUY4HZWBM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gPVSNNGXBawPoroOzNFcuH96XnEhbh19Ft0ZZk3is8QuN0GqGnrD8kGo/3lE+YATgfXjUBdaRmJ04bpsKhqiSrSk6/Y+TL6M5BPFULMinf92cuK5QcQs7e6F9Aig0qtdLgJ9aUo+KEGWKcKpaFFQ04yjET7xDWBovol0YAH6bUA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=l/tX6S8n; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709774977; x=1741310977; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=+G3P5fZ1KtJkD5uP1P0r4wxS61wLtCc7RBBUY4HZWBM=; b=l/tX6S8nvIWkr6/VOLeSEvfF3KCA2JkqEMqCbL4zwR2rmjFYmkH4qKdw tmnp3IXwDyX09Bjww0Av1J3HMry4c6MpaYbb18+s/+ifNAycvjgqGYnPx ZbdshZw7O+OMcLOKsImsSmpPYJ3P1sM92gJM3Fu/uDkTkcb4qjuhmIH+O pVCCL+F83Nm5ASBEB1FwsmOK8LhjH/aauSlvRyI+nhQ6TqOVcLUG45X7e 2jeDHc7dcw3hJPrO4GKlewLQ0wXceIJjUyiSCQfZkwBet4U/61WujN4jw OfSd8i/LqG3gxnhlHfV1yUS/e3i3B8tUCcJlQ/zqQL5CNb4T50kRYF/pM w==; X-IronPort-AV: E=McAfee;i="6600,9927,11005"; a="15147516" X-IronPort-AV: E=Sophos;i="6.06,209,1705392000"; d="scan'208";a="15147516" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 17:29:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,209,1705392000"; d="scan'208";a="14533859" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 17:29:35 -0800 Date: Wed, 6 Mar 2024 17:29:34 -0800 From: Isaku Yamahata To: David Matlack Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, isaku.yamahata@gmail.com, linux-kernel@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Michael Roth , Federico Parola , isaku.yamahata@linux.intel.com Subject: Re: [RFC PATCH 1/8] KVM: Document KVM_MAP_MEMORY ioctl Message-ID: <20240307012934.GD368614@ls.amr.corp.intel.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Wed, Mar 06, 2024 at 04:43:51PM -0800, David Matlack wrote: > On 2024-03-01 09:28 AM, isaku.yamahata@intel.com wrote: > > From: Isaku Yamahata > > + > > + struct kvm_memory_mapping { > > + __u64 base_gfn; > > + __u64 nr_pages; > > + __u64 flags; > > + __u64 source; > > + }; > > + > > + /* For kvm_memory_mapping:: flags */ > > + #define KVM_MEMORY_MAPPING_FLAG_WRITE _BITULL(0) > > + #define KVM_MEMORY_MAPPING_FLAG_EXEC _BITULL(1) > > + #define KVM_MEMORY_MAPPING_FLAG_USER _BITULL(2) > > + #define KVM_MEMORY_MAPPING_FLAG_PRIVATE _BITULL(3) > > + > > +KVM_MAP_MEMORY populates guest memory in the underlying mapping. If source is > > +not zero and it's supported (depending on underlying technology), the guest > > +memory content is populated with the source. > > What does "populated with the source" mean? source is user pointer and the memory contents of source is copied into base_gfn. (and it will encrypted.) > > The flags field supports three > > +flags: KVM_MEMORY_MAPPING_FLAG_WRITE, KVM_MEMORY_MAPPING_FLAG_EXEC, and > > +KVM_MEMORY_MAPPING_FLAG_USER. > > There are 4 flags. Oops. Let me update it. KVM_MAP_MEMORY populates guest memory at the specified range (`base_gfn`, `nr_pages`) in the underlying mapping. `source` is an optional user pointer. If `source` is not NULL and the underlying technology supports it, the memory contents of `source` are copied into the guest memory. The backend may encrypt it. The `flags` field supports four flags: KVM_MEMORY_MAPPING_FLAG_WRITE, KVM_MEMORY_MAPPING_FLAG_EXEC, KVM_MEMORY_MAPPING_FLAG_USER, and KVM_MEMORY_MAPPING_FLAGS_PRIVATE. The first three correspond to the fault code for the KVM page fault to populate guest memory. write fault, fetch fault, and user fault. KVM_MEMORY_MAPPING_FLAGS_PRIVATE is applicable only for guest memory with guest_memfd. It is to populate guest memory with the memory attribute of KVM_MEMORY_ATTRIBUTE_PRIVATE set. When the ioctl returns, the input values are updated. If `nr_pages` is large, it may return -EAGAIN and update the values (`base_gfn` and `nr_pages`. `source` if not zero) to point to the remaining range. -- Isaku Yamahata