pageattr.c (1ac731c529cd4d6adbce134754b51ff7d822b145) pageattr.c (acfa60dbe03802d6afd28401aa47801270e82021)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
4 */
5#include <linux/kernel.h>
6#include <linux/mm.h>
7#include <linux/module.h>
8#include <linux/sched.h>

--- 15 unchanged lines hidden (view full) ---

24{
25 /*
26 * rodata_full and DEBUG_PAGEALLOC require linear map to be
27 * mapped at page granularity, so that it is possible to
28 * protect/unprotect single pages.
29 *
30 * KFENCE pool requires page-granular mapping if initialized late.
31 */
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
4 */
5#include <linux/kernel.h>
6#include <linux/mm.h>
7#include <linux/module.h>
8#include <linux/sched.h>

--- 15 unchanged lines hidden (view full) ---

24{
25 /*
26 * rodata_full and DEBUG_PAGEALLOC require linear map to be
27 * mapped at page granularity, so that it is possible to
28 * protect/unprotect single pages.
29 *
30 * KFENCE pool requires page-granular mapping if initialized late.
31 */
32 return (rodata_enabled && rodata_full) || debug_pagealloc_enabled() ||
33 arm64_kfence_can_set_direct_map();
32 return rodata_full || debug_pagealloc_enabled() ||
33 arm64_kfence_can_set_direct_map();
34}
35
36static int change_page_range(pte_t *ptep, unsigned long addr, void *data)
37{
38 struct page_change_data *cdata = data;
39 pte_t pte = READ_ONCE(*ptep);
40
41 pte = clear_pte_bit(pte, cdata->clear_mask);

--- 58 unchanged lines hidden (view full) ---

100
101 if (!numpages)
102 return 0;
103
104 /*
105 * If we are manipulating read-only permissions, apply the same
106 * change to the linear mapping of the pages that back this VM area.
107 */
34}
35
36static int change_page_range(pte_t *ptep, unsigned long addr, void *data)
37{
38 struct page_change_data *cdata = data;
39 pte_t pte = READ_ONCE(*ptep);
40
41 pte = clear_pte_bit(pte, cdata->clear_mask);

--- 58 unchanged lines hidden (view full) ---

100
101 if (!numpages)
102 return 0;
103
104 /*
105 * If we are manipulating read-only permissions, apply the same
106 * change to the linear mapping of the pages that back this VM area.
107 */
108 if (rodata_enabled &&
109 rodata_full && (pgprot_val(set_mask) == PTE_RDONLY ||
108 if (rodata_full && (pgprot_val(set_mask) == PTE_RDONLY ||
110 pgprot_val(clear_mask) == PTE_RDONLY)) {
111 for (i = 0; i < area->nr_pages; i++) {
112 __change_memory_common((u64)page_address(area->pages[i]),
113 PAGE_SIZE, set_mask, clear_mask);
114 }
115 }
116
117 /*

--- 133 unchanged lines hidden ---
109 pgprot_val(clear_mask) == PTE_RDONLY)) {
110 for (i = 0; i < area->nr_pages; i++) {
111 __change_memory_common((u64)page_address(area->pages[i]),
112 PAGE_SIZE, set_mask, clear_mask);
113 }
114 }
115
116 /*

--- 133 unchanged lines hidden ---