Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp1292782rbe; Fri, 1 Mar 2024 09:36:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6hxw5mR4v6MqhG3iH0S9M41kPXtmYEDpgyXyD1fFqyTqCDwcotX9AfYNJRztqyS/VSl6vJJ6yERpB0efAeeXlKOXHSxtP29hI24/1cw== X-Google-Smtp-Source: AGHT+IFf+TmcznZbT/ud6a9l2rRSjcmnmnXMYlDI7bR8GeFWgg6Vabj4Pgwgpd+2IqiCWR+Ujur/ X-Received: by 2002:a17:906:c459:b0:a44:b9df:f345 with SMTP id ck25-20020a170906c45900b00a44b9dff345mr786953ejb.76.1709314616299; Fri, 01 Mar 2024 09:36:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709314616; cv=pass; d=google.com; s=arc-20160816; b=NKZMfAOwDRYkQMj922w0F8mFT6aH69OY+4GGWoa7D91Kf9urZ67fLeTNEkxaZZbrcA qX4PsArf8VZM0U+7KjSCQt/86sc94gbf9jNC6SYf42StnewG+5Li0U5I9I8dV59tglgb tJunUSc5n2gHIQUMjWoPWjv8gI2QRSuxamstezCeFQnwCGdCSFU8YF79iVweA2Pxi8ml /zYQBI/Yf1iMXPfWQoPQWg+Ur0/khs/gQZ6HV/Xx8cpiv6qMflBci/+Z204wcRgtVQBS m1s3aSJkxAy1/TtfKqM/z6jaY+41OCmC1sIUDs29Kjx/g6iGWzNkfxCJho4+ea2zxTUo pCVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XjnQIdqpBadyD7NWtadLLqs2Tn/NbwWzXRhxOz+afmM=; fh=niAehSMJk0S9tiAUu7wa5Eiw/RfVXqQX6b/Xpcsvz74=; b=GRme+oEERzCamQy0//+fIlG6LyL3JM8xQPfjdQrvWP1fiEMMsNIWGjNQt6xvNmTeld gI2MdtsPuIO+GZEoMNJ6fTvbvGtmQkOa1o6HNFGVzjvxmCJpABMpbOYRR8Q6lI22j2Vp k8ouIYcMCEPP4LRQXgcejBb9yCoCmvNwsJQbKkuWWQDJGnlasPn/35sJ0MbLTXt8wgwI COUKXoAcFqmiQqAkzRW2hu8lu6sk1xuCRkZbvOVvOxWgmycJh1A58q295EdOWiF4ngj/ blRqPjrmkLZyw0lkH3Y6Ny1qRqjCpSu1txF2A9pBrK/WAqwAbGqc+b+HJzlpwlHcqV5K YI+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UlWLgrlm; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-88825-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88825-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dx17-20020a170906a85100b00a42e99a7381si1633829ejb.6.2024.03.01.09.36.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 09:36:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88825-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UlWLgrlm; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-88825-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88825-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7FE431F25F8C for ; Fri, 1 Mar 2024 17:30:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74B5D17758; Fri, 1 Mar 2024 17:29:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UlWLgrlm" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 73F285C9C; Fri, 1 Mar 2024 17:29:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709314185; cv=none; b=ABfXioAJ79p1ccdInbbgiAazYP20spCBQvMZa4S55sO2ARqxC401UxdF9S6UnZE2kDpJosAKgI9mKCxxDKoAq0KqTICiBlv/C43N512CiPMtnDQgKs75HC0KIg8KJXZ7zdYwC24sgprrQSMiT5OIbCzGFAr376mLEkL2qdVYpn8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709314185; c=relaxed/simple; bh=xhAmNSgq/jNSfhesY71o3ouQLTaGpDQEc7g/WrW05mQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IgtjmitrE/fBiKQaVHb92vNZZTTMxsJCAg9jqT0urcPAPYRhMBFdlTmZNfHcPF1SYYmz7g/8XlTWUacR9WV4AUb38E869trn+vV9uguI0t9fjkFWt3LzIlU4xj8mpZ0koLSmk7I5MSCgKU11IbMF2MB4s9lZW/C/2RRkAG9M2vY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UlWLgrlm; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=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=1709314183; x=1740850183; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xhAmNSgq/jNSfhesY71o3ouQLTaGpDQEc7g/WrW05mQ=; b=UlWLgrlm8LifINGPWfu408Yq3EElAdzbVvETQFv4XX3N4I+WlCHkeEfx ccgukcz/LVy1uN7FZhbXC+8SHowPsRj3apogfMxIMmwPxbTEE9/6rMFcA K+P9yXHxFPzN1CvSppQJlvo0U/8pe2ID5hpt137eMM/7lqMOGPCR+20xX hp3wc3YM8wIr/oG6vR6+W8pbFndqd3G5TZdPyK7NeCn5kWwYE76TskidS EkQkRvdkuT3f9I66rkHLhgABAbrWeC+oDD7P302j7vchrga1+FMivhlPD ospIIOuCdpIPCbiulV7wDao9dArSuOeMDg3PsGtCYMDX8XVfPlXm18gj6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,11000"; a="6812378" X-IronPort-AV: E=Sophos;i="6.06,196,1705392000"; d="scan'208";a="6812378" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 09:29:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,196,1705392000"; d="scan'208";a="12946517" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 09:29:23 -0800 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, linux-kernel@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Michael Roth , David Matlack , Federico Parola Subject: [RFC PATCH 1/8] KVM: Document KVM_MAP_MEMORY ioctl Date: Fri, 1 Mar 2024 09:28:43 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Isaku Yamahata Adds documentation of KVM_MAP_MEMORY ioctl. It pre-populates guest memory. And potentially do initialized memory contents with encryption and measurement depending on underlying technology. Suggested-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- Documentation/virt/kvm/api.rst | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 0b5a33ee71ee..33d2b63f7dbf 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -6352,6 +6352,42 @@ a single guest_memfd file, but the bound ranges must not overlap). See KVM_SET_USER_MEMORY_REGION2 for additional details. +4.143 KVM_MAP_MEMORY +------------------------ + +:Capability: KVM_CAP_MAP_MEMORY +:Architectures: none +:Type: vcpu ioctl +:Parameters: struct kvm_memory_mapping(in/out) +:Returns: 0 on success, <0 on error + +KVM_MAP_MEMORY populates guest memory without running vcpu. + +:: + + 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. The flags field supports three +flags: KVM_MEMORY_MAPPING_FLAG_WRITE, KVM_MEMORY_MAPPING_FLAG_EXEC, and +KVM_MEMORY_MAPPING_FLAG_USER. Which corresponds to fault code for kvm page +fault to populate guest memory. write fault, fetch fault and user fault. +When it returned, the input is 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 the remaining range. + 5. The kvm_run structure ======================== -- 2.25.1