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/cacheflush.h>
9 #include <asm/pgtable.h>
11 static void change_page_attr(unsigned long addr
, int numpages
,
20 for (i
= 0; i
< numpages
; i
++) {
21 pgdp
= pgd_offset(&init_mm
, addr
);
22 pudp
= pud_offset(pgdp
, addr
);
23 pmdp
= pmd_offset(pudp
, addr
);
24 if (pmd_huge(*pmdp
)) {
28 ptep
= pte_offset_kernel(pmdp
, addr
);
32 __ptep_ipte(addr
, ptep
);
38 int set_memory_ro(unsigned long addr
, int numpages
)
40 change_page_attr(addr
, numpages
, pte_wrprotect
);
43 EXPORT_SYMBOL_GPL(set_memory_ro
);
45 int set_memory_rw(unsigned long addr
, int numpages
)
47 change_page_attr(addr
, numpages
, pte_mkwrite
);
50 EXPORT_SYMBOL_GPL(set_memory_rw
);
53 int set_memory_nx(unsigned long addr
, int numpages
)
57 EXPORT_SYMBOL_GPL(set_memory_nx
);
59 int set_memory_x(unsigned long addr
, int numpages
)