From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 10C3C30E0E5 for ; Tue, 23 Jun 2026 09:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782206077; cv=none; b=p3qJO6fGPifXcvg5WbIC+ASRDo6bbz4wrN4egMIsNoVtNX2X7bXyvNq5H3i4x66kWfyP2mSutn0T/tPioM7mgds19V1edYaoFOIJRFfwSqc5yXbVL+UXp97+nLky395uWNjMVWHcI7lKSt2ajv1vkneDGghrsLuVEaZaKGNIHDQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782206077; c=relaxed/simple; bh=Jrc3/1n6ncWF3VtGjXxG0cjpZMrkrKJOMwZImn13ef8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kfcEZgaRDimrIinxh6Vh7qx3ZIt+2dQ+bAWGEf9699NT5vUlw9t4mgZpcIRiqG/5NY7MQdHFm4MYg9LfAWM2betWdVqf29W5Vp0K+gS7RgB9i9VXBO49KMCVy8NZfSQtNTAwuwIHxmaimoJh6c5gUvQy6H/N5Ng5f1M2MUChPCY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=B1HYBTv5; arc=none smtp.client-ip=198.175.65.18 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=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="B1HYBTv5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1782206074; x=1813742074; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Jrc3/1n6ncWF3VtGjXxG0cjpZMrkrKJOMwZImn13ef8=; b=B1HYBTv5zCc1yg03wjf7qw0TL8Nk5byljL4eqNNuyWCrmUSoYniENJ1M P1qUfgrPDhA+6rqxYza4LpljJxYeLBizrFdKu3LZAVu/R0Q/vxjZF+oHW +RpQTFwwBxd2mVtc4ftAcAluETznR6jsKhSdMnMLv5E3cII9BakePN6Ab YDox8bHtwc91R8RsG3M0PtOHe3JV4AsPl+urx70D5Xy5LoQjqF7Y3ApaE JKn3LeTgswUXffP6d0vl1KwJebY5VcNRUlS9/QeiF7WrysdqAu4eBa1YT f0gJWYilaK6F3cBw1uwr3pfvqSN5mCIEAV/vyahuOK5stqVWornyHhpZ/ A==; X-CSE-ConnectionGUID: RKfwoqvDReSyuqEBxq8Daw== X-CSE-MsgGUID: yCrnfO9QRgiY94Hw9kD3dA== X-IronPort-AV: E=McAfee;i="6800,10657,11825"; a="83035929" X-IronPort-AV: E=Sophos;i="6.24,220,1774335600"; d="scan'208";a="83035929" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2026 02:14:33 -0700 X-CSE-ConnectionGUID: yDliffaBQUauzjb87+herA== X-CSE-MsgGUID: hc/L1AFkR22qU5djSHzk5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,220,1774335600"; d="scan'208";a="245328315" Received: from unknown (HELO [10.238.2.81]) ([10.238.2.81]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2026 02:14:20 -0700 Message-ID: <058d1f8c-b718-47fe-a7c4-f13828993189@linux.intel.com> Date: Tue, 23 Jun 2026 17:14:18 +0800 Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 17/46] KVM: guest_memfd: Advertise KVM_SET_MEMORY_ATTRIBUTES2 ioctl To: ackerleytng@google.com Cc: aik@amd.com, andrew.jones@linux.dev, brauner@kernel.org, chao.p.peng@linux.intel.com, david@kernel.org, jmattson@google.com, jthoughton@google.com, michael.roth@amd.com, oupton@kernel.org, pankaj.gupta@amd.com, qperret@google.com, rick.p.edgecombe@intel.com, rientjes@google.com, shivankg@amd.com, steven.price@arm.com, tabba@google.com, willy@infradead.org, wyihan@google.com, yan.y.zhao@intel.com, forkloop@google.com, pratyush@kernel.org, suzuki.poulose@arm.com, aneesh.kumar@kernel.org, liam@infradead.org, Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Shuah Khan , Shuah Khan , Vishal Annapurve , Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Youngjun Park , Qi Zheng , Shakeel Butt , Kiryl Shutsemau , Baoquan He , Jason Gunthorpe , Vlastimil Babka , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev References: <20260618-gmem-inplace-conversion-v8-0-9d2959357853@google.com> <20260618-gmem-inplace-conversion-v8-17-9d2959357853@google.com> Content-Language: en-US From: Binbin Wu In-Reply-To: <20260618-gmem-inplace-conversion-v8-17-9d2959357853@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/19/2026 8:31 AM, Ackerley Tng via B4 Relay wrote: > From: Ackerley Tng > > Introduce KVM_CAP_GUEST_MEMFD_MEMORY_ATTRIBUTES to advertise the > availability of the KVM_SET_MEMORY_ATTRIBUTES2 ioctl. > > KVM_SET_MEMORY_ATTRIBUTES2 is a guest_memfd-scoped version of the existing > KVM_SET_MEMORY_ATTRIBUTES VM ioctl. It allows userspace to manage memory > attributes, such as KVM_MEMORY_ATTRIBUTE_PRIVATE, directly on a guest_memfd > file descriptor. > > This new version uses struct kvm_memory_attributes2, which adds an > error_offset field to the output. This allows KVM to return the specific > offset that triggered an error, which is especially useful for handling > EAGAIN results caused by transient page reference counts during attribute > conversions. > > Update the KVM API documentation to define the new ioctl and its behavior, > and add the necessary UAPI definitions and capability checks. > > Suggested-by: Sean Christopherson > Suggested-by: Michael Roth > Signed-off-by: Ackerley Tng Reviewed-by: Binbin Wu Two nits below. > > +4.145 KVM_SET_MEMORY_ATTRIBUTES2 > +--------------------------------- > + > +:Capability: KVM_CAP_GUEST_MEMFD_MEMORY_ATTRIBUTES > +:Architectures: all > +:Type: guest_memfd ioctl > +:Parameters: struct kvm_memory_attributes2 (in/out) > +:Returns: 0 on success, <0 on error > + > +Errors: > + > + ========== =============================================================== > + EINVAL The specified `offset` or `size` were invalid (e.g. not ^ was > + page aligned, causes an overflow, or size is zero). > + EFAULT The parameter address was invalid. > + EAGAIN Some page within requested range had unexpected refcounts. The > + offset of the page will be returned in `error_offset`. > + ENOMEM Ran out of memory trying to track private/shared state > + ========== =============================================================== [...] > + > +Set attributes for a range of offsets within a guest_memfd to > +KVM_MEMORY_ATTRIBUTE_PRIVATE to limit the specified guest_memfd backed > +memory range for guest_use. Even if KVM_CAP_GUEST_MEMFD_MMAP is ^ guest use > +supported, after a successful call to set > +KVM_MEMORY_ATTRIBUTE_PRIVATE, the requested range will not be mappable > +into host userspace and will only be mappable by the guest. > +