return spte;
}
-static u64 make_spte_executable(u64 spte)
+static u64 change_spte_executable(u64 spte, u8 access)
{
- return modify_spte_protections(spte, shadow_x_mask, shadow_nx_mask);
-}
+ u64 set, clear;
-static u64 make_spte_nonexecutable(u64 spte)
-{
- return modify_spte_protections(spte, shadow_nx_mask, shadow_x_mask);
+ if (access & ACC_EXEC_MASK)
+ set = shadow_x_mask;
+ else
+ set = shadow_nx_mask;
+ clear = set ^ (shadow_nx_mask | shadow_x_mask);
+ return modify_spte_protections(spte, set, clear);
}
/*
* the page executable as the NX hugepage mitigation no longer
* applies.
*/
- if ((role.access & ACC_EXEC_MASK) && is_nx_huge_page_enabled(kvm))
- child_spte = make_spte_executable(child_spte);
+ if (is_nx_huge_page_enabled(kvm))
+ child_spte = change_spte_executable(child_spte, role.access);
}
return child_spte;
huge_spte &= KVM_HPAGE_MASK(level) | ~PAGE_MASK;
if (is_nx_huge_page_enabled(kvm))
- huge_spte = make_spte_nonexecutable(huge_spte);
+ huge_spte = change_spte_executable(huge_spte, 0);
return huge_spte;
}