Message ID | 20250404154352.23078-5-kalyazin@amazon.com (mailing list archive) |
---|---|
State | New |
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 A0112C36010 for <linux-mm@archiver.kernel.org>; Fri, 4 Apr 2025 15:44:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12DE8280007; Fri, 4 Apr 2025 11:44:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08CE9280001; Fri, 4 Apr 2025 11:44:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E716A280007; Fri, 4 Apr 2025 11:44:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C1CD5280001 for <linux-mm@kvack.org>; Fri, 4 Apr 2025 11:44:54 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 825E3140474 for <linux-mm@kvack.org>; Fri, 4 Apr 2025 15:44:55 +0000 (UTC) X-FDA: 83296784550.19.83CED47 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by imf03.hostedemail.com (Postfix) with ESMTP id 934E520009 for <linux-mm@kvack.org>; Fri, 4 Apr 2025 15:44:53 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazon201209 header.b="c/dNBaBL"; spf=pass (imf03.hostedemail.com: domain of "prvs=182d669d3=kalyazin@amazon.co.uk" designates 72.21.196.25 as permitted sender) smtp.mailfrom="prvs=182d669d3=kalyazin@amazon.co.uk"; dmarc=pass (policy=quarantine) header.from=amazon.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743781493; 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:in-reply-to:references:references:dkim-signature; bh=Hs0vi6KJkVKWhslhiRZ4duAi0DhiXeUL0EGHDvOz7fs=; b=rzf5SUBAZ2DmVvK6/D4lHkvdQhX6DvA3WC8unRkBmpbaE75ptTo/eJ+saAwRuR5cs984Ss 2IWW/EAli8q9jSIyHg8gjrKI0HcE8whUO4Zk+ev/f7IY0Fe6qtH4iABGLN3US1jfukHzlu Reb9I4VDMFfFgpq8Ttwin8xMyxC5LXU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazon201209 header.b="c/dNBaBL"; spf=pass (imf03.hostedemail.com: domain of "prvs=182d669d3=kalyazin@amazon.co.uk" designates 72.21.196.25 as permitted sender) smtp.mailfrom="prvs=182d669d3=kalyazin@amazon.co.uk"; dmarc=pass (policy=quarantine) header.from=amazon.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743781493; a=rsa-sha256; cv=none; b=YPE9xdDx05TH9aaMXL23vpLMw2s8GAJNIr+k/UOQA4DabLmrvM9W470O/0czJZfZfD1Gng XSW/wazL8FdbWnyuPFy2VOrIcng1XVNw/APZCFozuFBSOVBMBh2dM3SAeDtB6n5S4W/Dqk 6v7Jw45AR1G24jK9+zJKKkwfGcJEIV8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1743781494; x=1775317494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Hs0vi6KJkVKWhslhiRZ4duAi0DhiXeUL0EGHDvOz7fs=; b=c/dNBaBLMi3PY/Qxhqidhrr0S7bhxqlEPoSl0iFs0PVmRj7RRmF8ugWE 2TcJ0IQorEiVAovonhDOTrsr/MuDeTXjwK8sc857X6tphBtgvVYg7Kw1m gXeFSehWv99Icj+knic8Vs64eSmSoAaeuoS+3ExO8XsJGXe72gFt9ABM4 8=; X-IronPort-AV: E=Sophos;i="6.15,188,1739836800"; d="scan'208";a="480424509" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2025 15:44:50 +0000 Received: from EX19MTAUWB002.ant.amazon.com [10.0.21.151:10114] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.51.140:2525] with esmtp (Farcaster) id 7694f073-a459-43df-b4a1-c487f31edac7; Fri, 4 Apr 2025 15:44:48 +0000 (UTC) X-Farcaster-Flow-ID: 7694f073-a459-43df-b4a1-c487f31edac7 Received: from EX19D020UWC003.ant.amazon.com (10.13.138.187) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Fri, 4 Apr 2025 15:44:48 +0000 Received: from EX19MTAUWA001.ant.amazon.com (10.250.64.204) by EX19D020UWC003.ant.amazon.com (10.13.138.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Fri, 4 Apr 2025 15:44:47 +0000 Received: from email-imr-corp-prod-pdx-all-2b-5ec155c2.us-west-2.amazon.com (10.25.36.214) by mail-relay.amazon.com (10.250.64.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14 via Frontend Transport; Fri, 4 Apr 2025 15:44:47 +0000 Received: from dev-dsk-kalyazin-1a-a12e27e2.eu-west-1.amazon.com (dev-dsk-kalyazin-1a-a12e27e2.eu-west-1.amazon.com [172.19.103.116]) by email-imr-corp-prod-pdx-all-2b-5ec155c2.us-west-2.amazon.com (Postfix) with ESMTPS id 68987402AD; Fri, 4 Apr 2025 15:44:44 +0000 (UTC) From: Nikita Kalyazin <kalyazin@amazon.com> To: <akpm@linux-foundation.org>, <pbonzini@redhat.com>, <shuah@kernel.org>, <viro@zeniv.linux.org.uk>, <brauner@kernel.org>, <muchun.song@linux.dev>, <hughd@google.com> CC: <kvm@vger.kernel.org>, <linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>, <linux-fsdevel@vger.kernel.org>, <jack@suse.cz>, <lorenzo.stoakes@oracle.com>, <Liam.Howlett@Oracle.com>, <jannh@google.com>, <ryan.roberts@arm.com>, <david@redhat.com>, <jthoughton@google.com>, <peterx@redhat.com>, <graf@amazon.de>, <jgowans@amazon.com>, <roypat@amazon.co.uk>, <derekmn@amazon.com>, <nsaenz@amazon.es>, <xmarcalx@amazon.com>, <kalyazin@amazon.com> Subject: [PATCH v3 4/6] KVM: guest_memfd: add support for userfaultfd minor Date: Fri, 4 Apr 2025 15:43:50 +0000 Message-ID: <20250404154352.23078-5-kalyazin@amazon.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250404154352.23078-1-kalyazin@amazon.com> References: <20250404154352.23078-1-kalyazin@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Rspamd-Queue-Id: 934E520009 X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature: i8fpmt8ukw69p93k63azmipjz8zb44q9 X-HE-Tag: 1743781493-570208 X-HE-Meta: U2FsdGVkX18qiEoa14DpuCxnc9CJf/bfCcvjxtMfeUEeskDkr6xejmEBnqoKKmZXJ/4ShdHSr/lRUVtoElKvvieZtnZVqyCHnC+fQ5ac83wPvKd24m7GlrELsqj+TvSizEGPkxS+AhdPil164KAzzM3DJK6W7CCZbMJf8SSegwxDpj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f9zK/HbMb7Q1BIMXynR9HPye+fD3SrCjGUMbyL/JgReflNO+kpKnVlHS1oYggfsW8z2D+zLTYpec/5fhxcdbQ= 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 |
KVM: guest_memfd: support for uffd minor
|
expand
|
diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c index fbf89e643add..096d89e7282d 100644 --- a/virt/kvm/guest_memfd.c +++ b/virt/kvm/guest_memfd.c @@ -4,6 +4,9 @@ #include <linux/kvm_host.h> #include <linux/pagemap.h> #include <linux/anon_inodes.h> +#ifdef CONFIG_KVM_PRIVATE_MEM +#include <linux/userfaultfd_k.h> +#endif /* CONFIG_KVM_PRIVATE_MEM */ #include "kvm_mm.h" @@ -380,6 +383,13 @@ static vm_fault_t kvm_gmem_fault(struct vm_fault *vmf) kvm_gmem_mark_prepared(folio); } + if (userfaultfd_minor(vmf->vma) && + !(vmf->flags & FAULT_FLAG_USERFAULT_CONTINUE)) { + folio_unlock(folio); + filemap_invalidate_unlock_shared(inode->i_mapping); + return handle_userfault(vmf, VM_UFFD_MINOR); + } + vmf->page = folio_file_page(folio, vmf->pgoff); out_folio:
Add support for sending a pagefault event if userfaultfd is registered. Only page minor event is currently supported. Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com> --- virt/kvm/guest_memfd.c | 10 ++++++++++ 1 file changed, 10 insertions(+)