Message ID | 20250402160721.97596-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 19767C3601A for <linux-mm@archiver.kernel.org>; Wed, 2 Apr 2025 16:08:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5757528000A; Wed, 2 Apr 2025 12:08:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54B69280001; Wed, 2 Apr 2025 12:08:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39F2E28000A; Wed, 2 Apr 2025 12:08:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 12844280001 for <linux-mm@kvack.org>; Wed, 2 Apr 2025 12:08:29 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D5696161CEA for <linux-mm@kvack.org>; Wed, 2 Apr 2025 16:08:28 +0000 (UTC) X-FDA: 83289586296.15.3486E59 Received: from smtp-fw-80008.amazon.com (smtp-fw-80008.amazon.com [99.78.197.219]) by imf13.hostedemail.com (Postfix) with ESMTP id CE4A020011 for <linux-mm@kvack.org>; Wed, 2 Apr 2025 16:08:26 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazon201209 header.b=pecYHAsE; dmarc=pass (policy=quarantine) header.from=amazon.com; spf=pass (imf13.hostedemail.com: domain of "prvs=1800b2f01=kalyazin@amazon.co.uk" designates 99.78.197.219 as permitted sender) smtp.mailfrom="prvs=1800b2f01=kalyazin@amazon.co.uk" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743610107; a=rsa-sha256; cv=none; b=yS0buum41A65hm9zvGzhq7ScFofSFGfaRZCC/HqdfPJmZFFIrG+BzmvNZS7hQmpxjF0KtS oaBSFEtKzEsyas0GNBRhxEShLhTBLIRYhrM1tukqSpIR0kj85eKMEOEHvD8TSZSaks/J6I KMhpRy1jcmauY0jVDpi6DoFo3RwyFRg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazon201209 header.b=pecYHAsE; dmarc=pass (policy=quarantine) header.from=amazon.com; spf=pass (imf13.hostedemail.com: domain of "prvs=1800b2f01=kalyazin@amazon.co.uk" designates 99.78.197.219 as permitted sender) smtp.mailfrom="prvs=1800b2f01=kalyazin@amazon.co.uk" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743610107; 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=uKvQStBu+rMX8UPjQS1EH5XeuJ9x01oElWsxsBsndIY=; b=LQUpfuAgFJZVu2YqMQTYZf4nRUEH+HIwmhqP1EIcmz2z29uZi4h4mUKJVVXiGs+82r6qTz zANA4KbzkCMfZ3Nh6X1jT5GkYmT263UD5T4S/0qVrI/6jBamK8YgH9BWIpicdtllXzzaTm yvpHhf6JwCS1SaBxI9PSPNXPFWjVxJs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1743610106; x=1775146106; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uKvQStBu+rMX8UPjQS1EH5XeuJ9x01oElWsxsBsndIY=; b=pecYHAsEOZ3NB3UU0jDunX59FlbH7Eu2bQswo1PsWOPOkl2E05oHGJzx adsL3HYzp2R0Rz4exBpXK1awwzFzspkGOt/WXgv/jEPOONuXM3l+oyAcG iA8xSrlKsivIk/TnyYiaQmqoENbuhOosYXqrfRYAW0WyOgkKNEdF/ca3o k=; X-IronPort-AV: E=Sophos;i="6.15,182,1739836800"; d="scan'208";a="184231774" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.25.36.214]) by smtp-border-fw-80008.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2025 16:08:23 +0000 Received: from EX19MTAUWA002.ant.amazon.com [10.0.38.20:23064] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.4.91:2525] with esmtp (Farcaster) id 9fca53eb-8c49-414d-98bb-13cf3c17e564; Wed, 2 Apr 2025 16:08:23 +0000 (UTC) X-Farcaster-Flow-ID: 9fca53eb-8c49-414d-98bb-13cf3c17e564 Received: from EX19D020UWC002.ant.amazon.com (10.13.138.147) by EX19MTAUWA002.ant.amazon.com (10.250.64.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Wed, 2 Apr 2025 16:08:16 +0000 Received: from EX19MTAUWA001.ant.amazon.com (10.250.64.204) by EX19D020UWC002.ant.amazon.com (10.13.138.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Wed, 2 Apr 2025 16:08:15 +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; Wed, 2 Apr 2025 16:08:15 +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 3A4DA40BE5; Wed, 2 Apr 2025 16:08:13 +0000 (UTC) From: Nikita Kalyazin <kalyazin@amazon.com> To: <akpm@linux-foundation.org>, <pbonzini@redhat.com>, <shuah@kernel.org> CC: <kvm@vger.kernel.org>, <linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>, <lorenzo.stoakes@oracle.com>, <david@redhat.com>, <ryan.roberts@arm.com>, <quic_eberman@quicinc.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 v2 4/5] KVM: guest_memfd: add support for userfaultfd minor Date: Wed, 2 Apr 2025 16:07:20 +0000 Message-ID: <20250402160721.97596-5-kalyazin@amazon.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250402160721.97596-1-kalyazin@amazon.com> References: <20250402160721.97596-1-kalyazin@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Rspamd-Queue-Id: CE4A020011 X-Stat-Signature: 78364aawb9sehhcw9gbptarz8uakb4bu X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1743610106-960172 X-HE-Meta: U2FsdGVkX1/O3eAdSo2b9TvERYCVjGCrO/WeTeUMBIvDP/noPTiDlQa8myYQz68a4G0Sv5PJxyngITaAlEvM0oETH1g0vvEbSmrW5ANzUdyON+VoVe424W37KaOuf1Ro8ydLrbMPaWn3/CANo995K3DdpPM16uuatKjiu+JmgUxvzsV2vwmiXVYVqa6rpEcOhnWDpky0Or3G0N1kYNxjGil/8W6pQ1R/2RB+8vksyNtKwfc7fpy7JfvCEMr46i1F7r4LS/RnibNNWl8TQyHh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Q44R6Zu/Pmue20wEz0ADw9FwchrueLG1XMRrtGFrSi2v0mhsOV0Ylk397cuS2Zna+kMHvOoQd8oXt76aqOJ4Si/Kp2S/zZ3nxlCkCf6SHSzYLIPamsKPh4a6a095kf6jcWjePW/50ZRM2X4dqtZ7wTzioPiqfQHWUHCIlhWQ7odLHvtu0ZGTu0BQphw4F5oS0tLmeH1qRlLYvT5ybC9fUI66n00d+iPXDVmSu9vEyn3XDVW0= 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 26b1734b9623..92d3e6b51dc2 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_NO_USERFAULT_MINOR)) { + 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(+)