2 * Copyright IBM Corp. 2011
3 * Author(s): Jan Glauber <jang@linux.vnet.ibm.com>
5 #include <linux/module.h>
7 #include <linux/hugetlb.h>
8 #include <asm/pgtable.h>
10 static void change_page_attr(unsigned long addr
, int numpages
,
19 for (i
= 0; i
< numpages
; i
++) {
20 pgdp
= pgd_offset(&init_mm
, addr
);
21 pudp
= pud_offset(pgdp
, addr
);
22 pmdp
= pmd_offset(pudp
, addr
);
23 if (pmd_huge(*pmdp
)) {
27 ptep
= pte_offset_kernel(pmdp
, addr
);
31 __ptep_ipte(addr
, ptep
);
37 int set_memory_ro(unsigned long addr
, int numpages
)
39 change_page_attr(addr
, numpages
, pte_wrprotect
);
42 EXPORT_SYMBOL_GPL(set_memory_ro
);
44 int set_memory_rw(unsigned long addr
, int numpages
)
46 change_page_attr(addr
, numpages
, pte_mkwrite
);
49 EXPORT_SYMBOL_GPL(set_memory_rw
);
52 int set_memory_nx(unsigned long addr
, int numpages
)
56 EXPORT_SYMBOL_GPL(set_memory_nx
);
58 int set_memory_x(unsigned long addr
, int numpages
)