| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
|---|
| 3 | | - * Licensed under the GPL |
|---|
| 4 | 4 | */ |
|---|
| 5 | 5 | |
|---|
| 6 | 6 | #include <linux/err.h> |
|---|
| .. | .. |
|---|
| 10 | 10 | #include <linux/sched.h> |
|---|
| 11 | 11 | #include <asm/current.h> |
|---|
| 12 | 12 | #include <asm/page.h> |
|---|
| 13 | | -#include <asm/pgtable.h> |
|---|
| 14 | 13 | #include <kern_util.h> |
|---|
| 15 | 14 | #include <os.h> |
|---|
| 16 | 15 | |
|---|
| 17 | 16 | pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr) |
|---|
| 18 | 17 | { |
|---|
| 19 | 18 | pgd_t *pgd; |
|---|
| 19 | + p4d_t *p4d; |
|---|
| 20 | 20 | pud_t *pud; |
|---|
| 21 | 21 | pmd_t *pmd; |
|---|
| 22 | 22 | |
|---|
| .. | .. |
|---|
| 27 | 27 | if (!pgd_present(*pgd)) |
|---|
| 28 | 28 | return NULL; |
|---|
| 29 | 29 | |
|---|
| 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); |
|---|
| 31 | 35 | if (!pud_present(*pud)) |
|---|
| 32 | 36 | return NULL; |
|---|
| 33 | 37 | |
|---|
| .. | .. |
|---|
| 59 | 63 | static int do_op_one_page(unsigned long addr, int len, int is_write, |
|---|
| 60 | 64 | int (*op)(unsigned long addr, int len, void *arg), void *arg) |
|---|
| 61 | 65 | { |
|---|
| 62 | | - jmp_buf buf; |
|---|
| 63 | 66 | struct page *page; |
|---|
| 64 | 67 | pte_t *pte; |
|---|
| 65 | | - int n, faulted; |
|---|
| 68 | + int n; |
|---|
| 66 | 69 | |
|---|
| 67 | 70 | pte = maybe_map(addr, is_write); |
|---|
| 68 | 71 | if (pte == NULL) |
|---|
| 69 | 72 | return -1; |
|---|
| 70 | 73 | |
|---|
| 71 | 74 | page = pte_page(*pte); |
|---|
| 75 | +#ifdef CONFIG_64BIT |
|---|
| 76 | + pagefault_disable(); |
|---|
| 77 | + addr = (unsigned long) page_address(page) + |
|---|
| 78 | + (addr & ~PAGE_MASK); |
|---|
| 79 | +#else |
|---|
| 72 | 80 | addr = (unsigned long) kmap_atomic(page) + |
|---|
| 73 | 81 | (addr & ~PAGE_MASK); |
|---|
| 82 | +#endif |
|---|
| 83 | + n = (*op)(addr, len, arg); |
|---|
| 74 | 84 | |
|---|
| 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 |
|---|
| 85 | 88 | kunmap_atomic((void *)addr); |
|---|
| 89 | +#endif |
|---|
| 86 | 90 | |
|---|
| 87 | 91 | return n; |
|---|
| 88 | 92 | } |
|---|