hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/arch/arm64/mm/copypage.c
....@@ -1,37 +1,46 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Based on arch/arm/mm/copypage.c
34 *
45 * Copyright (C) 2002 Deep Blue Solutions Ltd, All Rights Reserved.
56 * Copyright (C) 2012 ARM Ltd.
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
187 */
198
9
+#include <linux/bitops.h>
2010 #include <linux/mm.h>
2111
2212 #include <asm/page.h>
2313 #include <asm/cacheflush.h>
14
+#include <asm/cpufeature.h>
15
+#include <asm/mte.h>
2416
25
-void __cpu_copy_user_page(void *kto, const void *kfrom, unsigned long vaddr)
17
+void copy_highpage(struct page *to, struct page *from)
2618 {
27
- struct page *page = virt_to_page(kto);
19
+ void *kto = page_address(to);
20
+ void *kfrom = page_address(from);
21
+
2822 copy_page(kto, kfrom);
29
- flush_dcache_page(page);
30
-}
31
-EXPORT_SYMBOL_GPL(__cpu_copy_user_page);
3223
33
-void __cpu_clear_user_page(void *kaddr, unsigned long vaddr)
34
-{
35
- clear_page(kaddr);
24
+ if (system_supports_mte() && test_bit(PG_mte_tagged, &from->flags)) {
25
+ set_bit(PG_mte_tagged, &to->flags);
26
+ page_kasan_tag_reset(to);
27
+ /*
28
+ * We need smp_wmb() in between setting the flags and clearing the
29
+ * tags because if another thread reads page->flags and builds a
30
+ * tagged address out of it, there is an actual dependency to the
31
+ * memory access, but on the current thread we do not guarantee that
32
+ * the new page->flags are visible before the tags were updated.
33
+ */
34
+ smp_wmb();
35
+ mte_copy_page_tags(kto, kfrom);
36
+ }
3637 }
37
-EXPORT_SYMBOL_GPL(__cpu_clear_user_page);
38
+EXPORT_SYMBOL(copy_highpage);
39
+
40
+void copy_user_highpage(struct page *to, struct page *from,
41
+ unsigned long vaddr, struct vm_area_struct *vma)
42
+{
43
+ copy_highpage(to, from);
44
+ flush_dcache_page(to);
45
+}
46
+EXPORT_SYMBOL_GPL(copy_user_highpage);