x86: pte_atomic_update should not return flipped

KPTI gymnastics need to be abstracted away from callers to
page_map_set().

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-12-09 10:10:39 -08:00 committed by Andrew Boie
commit 2a139ee95d

View file

@ -861,6 +861,13 @@ static inline pentry_t pte_atomic_update(pentry_t *pte, pentry_t update_val,
new_val = pte_finalize_value(new_val, user_table);
} while (atomic_pte_cas(pte, old_val, new_val) == false);
#ifdef CONFIG_X86_KPTI
if (is_flipped_pte(old_val)) {
/* Page was flipped for KPTI. Un-flip it */
old_val = ~old_val;
}
#endif /* CONFIG_X86_KPTI */
return old_val;
}