Message ID | 20240805-guest-memfd-lib-v1-0-e5a29a4ff5d7@quicinc.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEA5DC3DA7F for <linux-mm@archiver.kernel.org>; Mon, 5 Aug 2024 18:35:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71F346B009A; Mon, 5 Aug 2024 14:35:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67D426B009C; Mon, 5 Aug 2024 14:35:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ADF26B009D; Mon, 5 Aug 2024 14:35:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 26D436B009A for <linux-mm@kvack.org>; Mon, 5 Aug 2024 14:35:38 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CDA851C0CA2 for <linux-mm@kvack.org>; Mon, 5 Aug 2024 18:35:37 +0000 (UTC) X-FDA: 82419045114.07.9617887 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf04.hostedemail.com (Postfix) with ESMTP id ABD2B40015 for <linux-mm@kvack.org>; Mon, 5 Aug 2024 18:35:35 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=LRkRIKQx; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf04.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722882890; a=rsa-sha256; cv=none; b=py7nFK8YMnnCAsK1pxPKiDlUvKD7VRqZ1dYVuQsyzjx29A6CT7f30x2hIrfwKtGcn8MG91 BeI4UAQ4tkTVFTRUg9AAZ5rOLRw9Bf3gLJwlvG5X+OdgXqolFj3ZEJlBW5GY0iXZloXmOk Ma2Lr5inKxp7Kyw6gr/pgCaK8yo+Yrk= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=LRkRIKQx; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf04.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722882890; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=r1Jd5ecBU1I1wroHu3btrYE6ziJSo4C5naGxUPxOtXY=; b=jFzAinRlQFGzQjwbNKkS5F4QD3Sr/43TWuGVBbd/yw0LOgbF66ZWsaFgBMTIrhRv2w5iXL TLjV19GBz/16pkAJuF1+L9qW+KzRt5ffceNhVG19Sq0A58CircWowKAjsz0FXAQSWGk+Ci Zkv0XBM+HcEhXLHXyIXYytBwHXLbZdY= Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 475BBeYv021385; Mon, 5 Aug 2024 18:35:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=r1Jd5ecBU1I1wroHu3btrY E6ziJSo4C5naGxUPxOtXY=; b=LRkRIKQxkuxOp5y88KdgvjnEmrtEwJVWEtZM57 +083NUsvEeaCGC7eKS0PxZcTuuVO3htoMAzE/340ZHNaqPo65yYQMQzBoA14MRQ/ U1WfcRLOZtgGvg1WtlRU9fel8AnoTknmJlotV31MzTYYjM3AQgHnO6XkiPBR1xaS 5MsrDJAdLkXhQQk2fYp82s429C9PzucPRoY8z6738/suHI1TF1MXouTWuSWMk9g0 MXcWGdwPNImZ6469/0EXoGD1g1z3KFsEm9ovxe6mBGTcy+7IwXUB8dW5EYA871T9 qQMtkgwZY25EofZZx6SmwzZDtJh0xUOuEG0NvjoQVTHV7NFw== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 40scmtvywa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Aug 2024 18:35:31 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 475IZDPw029432 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 5 Aug 2024 18:35:13 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 5 Aug 2024 11:35:13 -0700 From: Elliot Berman <quic_eberman@quicinc.com> Subject: [PATCH RFC 0/4] mm: Introduce guest_memfd library Date: Mon, 5 Aug 2024 11:34:46 -0700 Message-ID: <20240805-guest-memfd-lib-v1-0-e5a29a4ff5d7@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAEYbsWYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDcyMj3fTS1OIS3dzU3LQU3ZzMJF0TU9M0IxNDQ9MUEzMloK6CotS0zAq widFKQW7OSrG1tQANa8cfZgAAAA== To: Andrew Morton <akpm@linux-foundation.org>, Paolo Bonzini <pbonzini@redhat.com>, Sean Christopherson <seanjc@google.com>, Fuad Tabba <tabba@google.com>, David Hildenbrand <david@redhat.com>, Patrick Roy <roypat@amazon.co.uk>, <qperret@google.com>, Ackerley Tng <ackerleytng@google.com> CC: <linux-coco@lists.linux.dev>, <linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>, <kvm@vger.kernel.org>, Elliot Berman <quic_eberman@quicinc.com> X-Mailer: b4 0.13.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: -UsEeCYgAlnHOpTqQsok4USDujEu93kb X-Proofpoint-GUID: -UsEeCYgAlnHOpTqQsok4USDujEu93kb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-05_07,2024-08-02_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 spamscore=0 mlxlogscore=448 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408050133 X-Rspamd-Queue-Id: ABD2B40015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 6epd1ydxoty4nxrkks35duyoc883hmfq X-HE-Tag: 1722882935-11327 X-HE-Meta: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XmrQOBDpBCGXLmIO9jQlW1PPpc4jZg3QOmn3HYpMh7mvS3xFlq4GuoxknVftACkgxzzpEDWqwivweuLSRkenVegrwtfa/46TdPbci7UlS3EefJWWYXs11yaT1Z4jF4O9UXc6V2URV+QAad0a5yzSQARywkMZ1J6MIhfjzNrV++aCYxwc7oVwvQ8/3c+UM8wmt7jPC1UCjaDsVSJx47dVXBsFMoLE76hIw5qgxtxjtCb2Zmic1n6xRFAIkKWsuRMt4keK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series | mm: Introduce guest_memfd library | expand |
In preparation for adding more features to KVM's guest_memfd, refactor and introduce a library which abstracts some of the core-mm decisions about managing folios associated with the file. The goal of the refactor serves two purposes: 1. Provide an easier way to reason about memory in guest_memfd. With KVM supporting multiple confidentiality models (TDX, SEV-SNP, pKVM, ARM CCA), and coming support for allowing kernel and userspace to access this memory, it seems necessary to create a stronger abstraction between core-mm concerns and hypervisor concerns. 2. Provide a common implementation for other hypervisors (Gunyah) to use. To create a guest_memfd, the owner provides operations to attempt to unmap the folio and check whether a folio is accessible to the host. The owner can call guest_memfd_make_inaccessible() to ensure Linux doesn't have the folio mapped. The series first introduces a guest_memfd library based on the current KVM (next) implementation, then adds few features needed for Gunyah and arm64 pKVM. The Gunyah usage of the series will be posted sepately shortly after sending this series. I'll work with Fuad on using the guest_memfd library for arm64 pKVM based on the feedback received. I've not yet investigated deeply whether having the guest_memfd library helps live migration. I'd appreciate any input on that part. Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> --- Elliot Berman (4): mm: Introduce guest_memfd kvm: Convert to use mm/guest_memfd mm: guest_memfd: Add option to remove guest private memory from direct map mm: guest_memfd: Add ability for mmap'ing pages include/linux/guest_memfd.h | 59 ++++++ mm/Kconfig | 3 + mm/Makefile | 1 + mm/guest_memfd.c | 427 ++++++++++++++++++++++++++++++++++++++++++++ virt/kvm/Kconfig | 1 + virt/kvm/guest_memfd.c | 299 +++++-------------------------- virt/kvm/kvm_main.c | 2 - virt/kvm/kvm_mm.h | 6 - 8 files changed, 539 insertions(+), 259 deletions(-) --- base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b change-id: 20240722-guest-memfd-lib-455f24115d46 Best regards,