+static inline bool is_prot_ro(struct pg_state *st)
+{
+ if (st->level < 4) {
+ #ifdef CONFIG_ARM_LPAE
+ if ((st->current_prot &
+ (L_PMD_SECT_RDONLY | PMD_SECT_AP2)) ==
+ (L_PMD_SECT_RDONLY | PMD_SECT_AP2))
+ return true;
+ #elif __LINUX_ARM_ARCH__ >= 6
+ if ((st->current_prot &
+ (PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE)) ==
+ (PMD_SECT_APX | PMD_SECT_AP_WRITE))
+ return true;
+ #else
+ if ((st->current_prot &
+ (PMD_SECT_AP_READ | PMD_SECT_AP_WRITE)) == 0)
+ return true;
+ #endif
+ } else {
+ if ((st->current_prot & L_PTE_RDONLY) == L_PTE_RDONLY)
+ return true;
+ }
+
+ return false;
+}
+
+static inline bool is_prot_nx(struct pg_state *st)
+{
+ if (st->level < 4) {
+ if ((st->current_prot & PMD_SECT_XN) == PMD_SECT_XN)
+ return true;
+ } else {
+ if ((st->current_prot & L_PTE_XN) == L_PTE_XN)
+ return true;
+ }
+
+ return false;
+}