userfaultfd.c (651a88798412e216f337d70181127e847f00a4b7) | userfaultfd.c (5c041f5d1f23d3a172dd0db3215634c484b4acd6) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * fs/userfaultfd.c 4 * 5 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org> 6 * Copyright (C) 2008-2009 Red Hat, Inc. 7 * Copyright (C) 2015 Red Hat, Inc. 8 * --- 15 unchanged lines hidden (view full) --- 24#include <linux/bug.h> 25#include <linux/anon_inodes.h> 26#include <linux/syscalls.h> 27#include <linux/userfaultfd_k.h> 28#include <linux/mempolicy.h> 29#include <linux/ioctl.h> 30#include <linux/security.h> 31#include <linux/hugetlb.h> | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * fs/userfaultfd.c 4 * 5 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org> 6 * Copyright (C) 2008-2009 Red Hat, Inc. 7 * Copyright (C) 2015 Red Hat, Inc. 8 * --- 15 unchanged lines hidden (view full) --- 24#include <linux/bug.h> 25#include <linux/anon_inodes.h> 26#include <linux/syscalls.h> 27#include <linux/userfaultfd_k.h> 28#include <linux/mempolicy.h> 29#include <linux/ioctl.h> 30#include <linux/security.h> 31#include <linux/hugetlb.h> |
32#include <linux/swapops.h> |
|
32 33int sysctl_unprivileged_userfaultfd __read_mostly; 34 35static struct kmem_cache *userfaultfd_ctx_cachep __read_mostly; 36 37/* 38 * Start with fault_pending_wqh and fault_wqh so they're more likely 39 * to be in the same cacheline. --- 204 unchanged lines hidden (view full) --- 244 if (!ptep) 245 goto out; 246 247 ret = false; 248 pte = huge_ptep_get(ptep); 249 250 /* 251 * Lockless access: we're in a wait_event so it's ok if it | 33 34int sysctl_unprivileged_userfaultfd __read_mostly; 35 36static struct kmem_cache *userfaultfd_ctx_cachep __read_mostly; 37 38/* 39 * Start with fault_pending_wqh and fault_wqh so they're more likely 40 * to be in the same cacheline. --- 204 unchanged lines hidden (view full) --- 245 if (!ptep) 246 goto out; 247 248 ret = false; 249 pte = huge_ptep_get(ptep); 250 251 /* 252 * Lockless access: we're in a wait_event so it's ok if it |
252 * changes under us. | 253 * changes under us. PTE markers should be handled the same as none 254 * ptes here. |
253 */ | 255 */ |
254 if (huge_pte_none(pte)) | 256 if (huge_pte_none_mostly(pte)) |
255 ret = true; 256 if (!huge_pte_write(pte) && (reason & VM_UFFD_WP)) 257 ret = true; 258out: 259 return ret; 260} 261#else 262static inline bool userfaultfd_huge_must_wait(struct userfaultfd_ctx *ctx, --- 62 unchanged lines hidden (view full) --- 325 326 /* 327 * the pmd is stable (as in !pmd_trans_unstable) so we can re-read it 328 * and use the standard pte_offset_map() instead of parsing _pmd. 329 */ 330 pte = pte_offset_map(pmd, address); 331 /* 332 * Lockless access: we're in a wait_event so it's ok if it | 257 ret = true; 258 if (!huge_pte_write(pte) && (reason & VM_UFFD_WP)) 259 ret = true; 260out: 261 return ret; 262} 263#else 264static inline bool userfaultfd_huge_must_wait(struct userfaultfd_ctx *ctx, --- 62 unchanged lines hidden (view full) --- 327 328 /* 329 * the pmd is stable (as in !pmd_trans_unstable) so we can re-read it 330 * and use the standard pte_offset_map() instead of parsing _pmd. 331 */ 332 pte = pte_offset_map(pmd, address); 333 /* 334 * Lockless access: we're in a wait_event so it's ok if it |
333 * changes under us. | 335 * changes under us. PTE markers should be handled the same as none 336 * ptes here. |
334 */ | 337 */ |
335 if (pte_none(*pte)) | 338 if (pte_none_mostly(*pte)) |
336 ret = true; 337 if (!pte_write(*pte) && (reason & VM_UFFD_WP)) 338 ret = true; 339 pte_unmap(pte); 340 341out: 342 return ret; 343} --- 1779 unchanged lines hidden --- | 339 ret = true; 340 if (!pte_write(*pte) && (reason & VM_UFFD_WP)) 341 ret = true; 342 pte_unmap(pte); 343 344out: 345 return ret; 346} --- 1779 unchanged lines hidden --- |