hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/arch/um/kernel/skas/uaccess.c
....@@ -1,6 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3
- * Licensed under the GPL
44 */
55
66 #include <linux/err.h>
....@@ -10,13 +10,13 @@
1010 #include <linux/sched.h>
1111 #include <asm/current.h>
1212 #include <asm/page.h>
13
-#include <asm/pgtable.h>
1413 #include <kern_util.h>
1514 #include <os.h>
1615
1716 pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr)
1817 {
1918 pgd_t *pgd;
19
+ p4d_t *p4d;
2020 pud_t *pud;
2121 pmd_t *pmd;
2222
....@@ -27,7 +27,11 @@
2727 if (!pgd_present(*pgd))
2828 return NULL;
2929
30
- pud = pud_offset(pgd, addr);
30
+ p4d = p4d_offset(pgd, addr);
31
+ if (!p4d_present(*p4d))
32
+ return NULL;
33
+
34
+ pud = pud_offset(p4d, addr);
3135 if (!pud_present(*pud))
3236 return NULL;
3337
....@@ -59,30 +63,30 @@
5963 static int do_op_one_page(unsigned long addr, int len, int is_write,
6064 int (*op)(unsigned long addr, int len, void *arg), void *arg)
6165 {
62
- jmp_buf buf;
6366 struct page *page;
6467 pte_t *pte;
65
- int n, faulted;
68
+ int n;
6669
6770 pte = maybe_map(addr, is_write);
6871 if (pte == NULL)
6972 return -1;
7073
7174 page = pte_page(*pte);
75
+#ifdef CONFIG_64BIT
76
+ pagefault_disable();
77
+ addr = (unsigned long) page_address(page) +
78
+ (addr & ~PAGE_MASK);
79
+#else
7280 addr = (unsigned long) kmap_atomic(page) +
7381 (addr & ~PAGE_MASK);
82
+#endif
83
+ n = (*op)(addr, len, arg);
7484
75
- current->thread.fault_catcher = &buf;
76
-
77
- faulted = UML_SETJMP(&buf);
78
- if (faulted == 0)
79
- n = (*op)(addr, len, arg);
80
- else
81
- n = -1;
82
-
83
- current->thread.fault_catcher = NULL;
84
-
85
+#ifdef CONFIG_64BIT
86
+ pagefault_enable();
87
+#else
8588 kunmap_atomic((void *)addr);
89
+#endif
8690
8791 return n;
8892 }