[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221220072743.3039060-11-shiyn.lin@gmail.com>
Date: Tue, 20 Dec 2022 15:27:39 +0800
From: Chih-En Lin <shiyn.lin@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Qi Zheng <zhengqi.arch@...edance.com>,
David Hildenbrand <david@...hat.com>,
Matthew Wilcox <willy@...radead.org>,
Christophe Leroy <christophe.leroy@...roup.eu>,
John Hubbard <jhubbard@...dia.com>,
Nadav Amit <namit@...are.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Yang Shi <shy828301@...il.com>, Peter Xu <peterx@...hat.com>,
Zach O'Keefe <zokeefe@...gle.com>,
"Liam R . Howlett" <Liam.Howlett@...cle.com>,
Alex Sierra <alex.sierra@....com>,
Xianting Tian <xianting.tian@...ux.alibaba.com>,
Colin Cross <ccross@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Barry Song <baohua@...nel.org>,
Pasha Tatashin <pasha.tatashin@...een.com>,
Suleiman Souhlal <suleiman@...gle.com>,
Brian Geffon <bgeffon@...gle.com>, Yu Zhao <yuzhao@...gle.com>,
Tong Tiangen <tongtiangen@...wei.com>,
Liu Shixin <liushixin2@...wei.com>,
Li kunyu <kunyu@...china.com>,
Anshuman Khandual <anshuman.khandual@....com>,
Vlastimil Babka <vbabka@...e.cz>,
Hugh Dickins <hughd@...gle.com>,
Minchan Kim <minchan@...nel.org>,
Miaohe Lin <linmiaohe@...wei.com>,
Gautam Menghani <gautammenghani201@...il.com>,
Catalin Marinas <catalin.marinas@....com>,
Mark Brown <broonie@...nel.org>, Will Deacon <will@...nel.org>,
"Eric W . Biederman" <ebiederm@...ssion.com>,
Thomas Gleixner <tglx@...utronix.de>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Andy Lutomirski <luto@...nel.org>,
Fenghua Yu <fenghua.yu@...el.com>,
Barret Rhoden <brho@...gle.com>,
Davidlohr Bueso <dave@...olabs.net>,
"Jason A . Donenfeld" <Jason@...c4.com>,
Dinglan Peng <peng301@...due.edu>,
Pedro Fonseca <pfonseca@...due.edu>,
Jim Huang <jserv@...s.ncku.edu.tw>,
Huichun Feng <foxhoundsk.tw@...il.com>,
Chih-En Lin <shiyn.lin@...il.com>
Subject: [PATCH v3 10/14] mm/userfaultfd: Support COW PTE
If uffd fills the zeropage or installs to COW-ed PTE, break it first.
Signed-off-by: Chih-En Lin <shiyn.lin@...il.com>
---
mm/userfaultfd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index 650ab6cfd5f49..4ee21c0d42d90 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -69,6 +69,9 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd,
struct inode *inode;
pgoff_t offset, max_off;
+ if (break_cow_pte(dst_vma, dst_pmd, dst_addr) < 0)
+ return -ENOMEM;
+
_dst_pte = mk_pte(page, dst_vma->vm_page_prot);
_dst_pte = pte_mkdirty(_dst_pte);
if (page_in_cache && !vm_shared)
@@ -227,6 +230,9 @@ static int mfill_zeropage_pte(struct mm_struct *dst_mm,
pgoff_t offset, max_off;
struct inode *inode;
+ if (break_cow_pte(dst_vma, dst_pmd, dst_addr) < 0)
+ return -ENOMEM;
+
_dst_pte = pte_mkspecial(pfn_pte(my_zero_pfn(dst_addr),
dst_vma->vm_page_prot));
dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl);
--
2.37.3
Powered by blists - more mailing lists