Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp663257lqt; Fri, 19 Apr 2024 07:04:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVmpcU4JwAdoYna8eytanRDzv3c7q8C1B5v7nKzUM08lZFVWHux2mGgEKqTBBt3bKjVs3Cnt9HbY2BQMMEhtkVIlpcHdUdD7h2xW4opnQ== X-Google-Smtp-Source: AGHT+IEdcU3DMJcLsYWs64rh8QQePsvgKgJYtyU/+J9iGYdsRAmEIC3AY5JfY7Og70HuXrEAthyU X-Received: by 2002:ac8:5d02:0:b0:437:bec6:7349 with SMTP id f2-20020ac85d02000000b00437bec67349mr3196177qtx.58.1713535449091; Fri, 19 Apr 2024 07:04:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713535449; cv=pass; d=google.com; s=arc-20160816; b=hIzGZsTVCY+yITaubl04s/AfTsabYphpcdPAV4oUiGSB2HaQmqkriOiYWaiUYy4UIq L7jpIifZWCTpWSb1A4NZ7u7XUTtg+m32zlgVKxXI3X1FBhnlS06kHMPYM9cWIV3iD0fB gSWZVeTyV6IdzDpN5EMyxWKDlUnM28rhxIq6udGWu3aPyItrEpK13W+cLJxN42faSuq/ g+KJTv23bYcP1E453N+8F1pAvUgd5dha8Ew+aoFGbB4Zau5yahaJ1Yd/IZueCe1BTZaR lm4Br3Htjp9xRzEVOh8chbep//N4qFu4pHGFsUnUTExRDKtGyHig/x9tpupi5esPlug9 WIjg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dcEfHSyX3OufEZQDnQboNte9fuAGc5lrZ2vS828VuNQ=; fh=R7xUQPIMGYCGNZ/VoiFGCpRsfCEj1VrjW3GjSDyJsJQ=; b=nse6Yzydq0aqhgBJ6DRKMFX+5w/eB8almvT89yKVe5Pnp9K22BLdXA0Q4WOxLQE9ao a34ucb2GwiIvmbVlCOOYKwK//qGT/6bCyjWP/hkHS1ObOVQRvyKKVgRQex03E6wkvIDK 9kxttGa2c3e79/ysu5ILa0XHnRgH9MvBO7IVsDvKaVNIEZOXEfnKvsuOY3pwLWlTZygo fyOWqNfWVKkU3g7EMpSPTm8ZXLX0CV6+TDT7yezGyK/JhkcvLza5X7RKUlBuMxGasUW0 eHdWALtNtbRzUiFLx30S9kHFUnoH5cR3PUAZCFj3XCKyMbEE18ooTisVhdj2MQpAUhAM Lyjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="jYt/u8bH"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-151527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151527-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bp31-20020a05622a1b9f00b00434cc339a2esi3976971qtb.629.2024.04.19.07.04.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 07:04:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="jYt/u8bH"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-151527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151527-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 CDCC51C218ED for ; Fri, 19 Apr 2024 14:04:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED63D12EBD3; Fri, 19 Apr 2024 14:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jYt/u8bH" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 A3D2312D1E7; Fri, 19 Apr 2024 14:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535355; cv=none; b=FBJbKLO8JJjqxziLdt71erWqO8e4eHxAUs5gCdn/9N965BbTQbMqWrRKZ6HWBK4s41tVJZ3jXIAu6K9rk+Lt1VVvVR+fNMK2tfrixvPnzjMeekv2xlFcdmAS7x1m8ZjPzs5FeKGFJe07xvqcvrW0C+yr/HiKXna/A1YTkyaUa5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713535355; c=relaxed/simple; bh=Ja3+Ie6Jc53FYU2X0JbI5M6SoFSf4BFAJXi850lyzcs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KCbEp0IlSSgnWemGU6EcqLUNHuZR9XXVrRDkuqrM+mUPO0thq8xeCKilqQwVYma3mg8+6RR3QDEgoirnT2bnTTZbmBnPJu/aTbILxprBEkoSYs8bvzdjg7YwLNF6gXbLnMoaDxCr/Wp3mKQF6N4QyZXtGR2EfCEDnCxw78dsTA4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jYt/u8bH; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713535354; x=1745071354; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=Ja3+Ie6Jc53FYU2X0JbI5M6SoFSf4BFAJXi850lyzcs=; b=jYt/u8bHKQpXhXaH6JQ8OIdHlj9lIx2Qvdda8xHjUo0mbkOBPa3is1Dx ibbxPzRAQB31NS2AExOd16Z0eZi52ID+pwmWj4W7aDuCj8SLRHycnqAWA U5zvzKfLbw7IKq+G2HZfqkEd1O1ojxeUrES5zzY3w26/8fJc+iPS8WeKS QiKO15FmOH8xiM5yHtYD4pJV/UIs2ybEfDXGzGrF5rlrVVj/STAJ9dnPi 1sXsrF0S2ENkWmqKwwJ/+Kjiyz0SkbnAneoJua6mKMCpCQSm9QGPCanur Cxx03K6fXiIMjDiNslsR29sgiufqGDatlDg0uB3n8n4EMGjou33MR/PQF A==; X-CSE-ConnectionGUID: RGKXi6CeTA6+P9qngYevnA== X-CSE-MsgGUID: ZmTMDvHNSj+BFBU3WjOWSQ== X-IronPort-AV: E=McAfee;i="6600,9927,11049"; a="8997232" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="8997232" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2024 07:02:23 -0700 X-CSE-ConnectionGUID: ATRwipnzQiGvAK1Qji5L7A== X-CSE-MsgGUID: Tw7rUNNuTCqbe22QHc0+jQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="23366460" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmviesa009.fm.intel.com with ESMTP; 19 Apr 2024 07:02:20 -0700 Date: Fri, 19 Apr 2024 21:57:05 +0800 From: Xu Yilun To: Paolo Bonzini Cc: Sean Christopherson , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, isaku.yamahata@intel.com, xiaoyao.li@intel.com, binbin.wu@linux.intel.com, rick.p.edgecombe@intel.com Subject: Re: [PATCH 1/7] KVM: Document KVM_MAP_MEMORY ioctl Message-ID: References: <20240417153450.3608097-1-pbonzini@redhat.com> <20240417153450.3608097-2-pbonzini@redhat.com> 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 Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Apr 17, 2024 at 10:37:00PM +0200, Paolo Bonzini wrote: > On Wed, Apr 17, 2024 at 10:28 PM Sean Christopherson wrote: > > > > On Wed, Apr 17, 2024, Paolo Bonzini wrote: > > > +4.143 KVM_MAP_MEMORY > > > +------------------------ > > > + > > > +:Capability: KVM_CAP_MAP_MEMORY > > > +:Architectures: none > > > +:Type: vcpu ioctl > > > +:Parameters: struct kvm_map_memory (in/out) > > > +:Returns: 0 on success, < 0 on error The definition of *success* here doesn't align with below comments. Maybe replace success with a clearer definition, e.g. 0 when all or part of the pages are processed. < 0 when error and no page is processed. > > > + > > > +Errors: > > > + > > > + ========== =============================================================== > > > + EINVAL The specified `base_address` and `size` were invalid (e.g. not > > > + page aligned or outside the defined memory slots). > > > > "outside the memslots" should probably be -EFAULT, i.e. keep EINVAL for things > > that can _never_ succeed. > > > > > + EAGAIN The ioctl should be invoked again and no page was processed. > > > + EINTR An unmasked signal is pending and no page was processed. > > > > I'm guessing we'll want to handle large ranges, at which point we'll likely end > > up with EAGAIN and/or EINTR after processing at least one page. > > Yes, in that case you get a success (return value of 0), just like read(). [...] > > > > > +When the ioctl returns, the input values are updated to point to the > > > +remaining range. If `size` > 0 on return, the caller can just issue > > > +the ioctl again with the same `struct kvm_map_memory` argument. > > > > This is likely misleading. Unless KVM explicitly zeros size on *every* failure, > > a pedantic reading of this would suggest that userspace can retry and it should > > eventually succeed. > > Gotcha... KVM explicitly zeros size on every success, but never zeros > size on a failure. Thanks, Yilun