Message ID | 20210323004912.35132-15-peterx@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=10Ky=IV=kvack.org=owner-linux-mm@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 936FFC433E0 for <linux-mm@archiver.kernel.org>; Tue, 23 Mar 2021 00:49:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 370196196C for <linux-mm@archiver.kernel.org>; Tue, 23 Mar 2021 00:49:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 370196196C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8E6126B0132; Mon, 22 Mar 2021 20:49:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 862896B0134; Mon, 22 Mar 2021 20:49:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F02C6B0135; Mon, 22 Mar 2021 20:49:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0252.hostedemail.com [216.40.44.252]) by kanga.kvack.org (Postfix) with ESMTP id 3CC136B0134 for <linux-mm@kvack.org>; Mon, 22 Mar 2021 20:49:44 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 06AFF8249980 for <linux-mm@kvack.org>; Tue, 23 Mar 2021 00:49:44 +0000 (UTC) X-FDA: 77949306288.22.D5AA9F6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 42F6EA0009CA for <linux-mm@kvack.org>; Tue, 23 Mar 2021 00:49:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616460582; h=from:from: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; bh=cKuTAK/coeu/o9lPtGRIHWod3LERVBmK315ziMrYcLI=; b=FjbuUcEalzW8GqGXb3GZXAZSQtbn0bCJMuf9ffQ8NJQE03Y9qKAH/YTYKNvwyOh6lJbufX YsMf5OaFwJUMgcmVlg8lUsDgQ9w1c1wJbtRftAPpN1yCyPH1eoO1kR8iAODrBwyD+4c7tZ QS+T1Yl8cSjmBPcGj9bG6rYlIfXkUsQ= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-602-t1kdNRq2NBq_qOs_i2H6_A-1; Mon, 22 Mar 2021 20:49:39 -0400 X-MC-Unique: t1kdNRq2NBq_qOs_i2H6_A-1 Received: by mail-qt1-f198.google.com with SMTP id h26so397598qtm.13 for <linux-mm@kvack.org>; Mon, 22 Mar 2021 17:49:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cKuTAK/coeu/o9lPtGRIHWod3LERVBmK315ziMrYcLI=; b=t8Xn59YD8cQKGMWkr1J/keSBJjuDlnV5lOB7Dw3JU8PKBeRG6u+Dm/G76W3i8+Vj5N +yq+z+5ce9O3+3sIYLoxf2C/bpmPeKA3zo44zLyl6a/GlqIC7C5f4NimJxA0IfbgafmK elCvW35u3LzlEJmXwa0Dd0xdyub7Bf8milZGDNrR94wX22LqxCsdo2toMqNEhXfbw/VO R857PZHX1f73I+q89Yjx2WC+7BhRuLYkzc7R+4yN0VP5EZJZrW9qceCWPQJpAGs8u+88 /ZJZrwUg7uiz0JIAqzTTmAEBtt5dV5LO74fb2EnIq3Oo0zIN0Pr4l9CNPEaoxvc1+BDN /nEw== X-Gm-Message-State: AOAM532dX37m4wzuf2uSxE+xZe/WkrbSvGJJ2RdXWtbjzgbCd5jJGa/P l073bYQn+d2o7RceGcblhobJphD9nlEMNid9KUUbmvxokVQUwKZI5HXxV/IJntiMDgDJ/hEmMme Jd9CivPnm+bw= X-Received: by 2002:a05:620a:1388:: with SMTP id k8mr2974993qki.224.1616460578814; Mon, 22 Mar 2021 17:49:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+wBwPeNPOsPise+7lL7dkN21Mn6lkzdRj7CMeozDPNGfvtHmM2/ikJDtiTyBJ8cbrfkFN1A== X-Received: by 2002:a05:620a:1388:: with SMTP id k8mr2974981qki.224.1616460578591; Mon, 22 Mar 2021 17:49:38 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-82-174-91-135-175.dsl.bell.ca. [174.91.135.175]) by smtp.gmail.com with ESMTPSA id n6sm5031793qtx.22.2021.03.22.17.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 17:49:38 -0700 (PDT) From: Peter Xu <peterx@redhat.com> To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: "Kirill A . Shutemov" <kirill@shutemov.name>, Jerome Glisse <jglisse@redhat.com>, Mike Kravetz <mike.kravetz@oracle.com>, Matthew Wilcox <willy@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, Axel Rasmussen <axelrasmussen@google.com>, Hugh Dickins <hughd@google.com>, peterx@redhat.com, Nadav Amit <nadav.amit@gmail.com>, Andrea Arcangeli <aarcange@redhat.com>, Mike Rapoport <rppt@linux.vnet.ibm.com> Subject: [PATCH 14/23] shmem/userfaultfd: Pass over uffd-wp special swap pte when fork() Date: Mon, 22 Mar 2021 20:49:03 -0400 Message-Id: <20210323004912.35132-15-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210323004912.35132-1-peterx@redhat.com> References: <20210323004912.35132-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="US-ASCII" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 42F6EA0009CA X-Stat-Signature: ude8pc7aqom3mdo4zf3khgesz5pupytf Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from="<peterx@redhat.com>"; helo=us-smtp-delivery-124.mimecast.com; client-ip=63.128.21.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616460582-259586 Content-Transfer-Encoding: quoted-printable 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> |
Series |
userfaultfd-wp: Support shmem and hugetlbfs
|
expand
|
diff --git a/mm/memory.c b/mm/memory.c index 8be28bcaa044..766946d3eab0 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -715,8 +715,21 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, unsigned long vm_flags = dst_vma->vm_flags; pte_t pte = *src_pte; struct page *page; - swp_entry_t entry = pte_to_swp_entry(pte); + swp_entry_t entry; + + if (unlikely(is_swap_special_pte(pte))) { + /* + * uffd-wp special swap pte is the only possibility for now. + * If dst vma is registered with uffd-wp, copy it over. + * Otherwise, ignore this pte as if it's a none pte would work. + */ + WARN_ON_ONCE(!pte_swp_uffd_wp_special(pte)); + if (userfaultfd_wp(dst_vma)) + set_pte_at(dst_mm, addr, dst_pte, pte); + return 0; + } + entry = pte_to_swp_entry(pte); if (likely(!non_swap_entry(entry))) { if (swap_duplicate(entry) < 0) return entry.val;
It should be handled similarly like other uffd-wp wr-protected ptes: we should pass it over when the dst_vma has VM_UFFD_WP armed, otherwise drop it. Signed-off-by: Peter Xu <peterx@redhat.com> --- mm/memory.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)