@@ -271,18 +271,23 @@ static inline enum pte_flush_type pte_flags_flush_type(unsigned long oldflags,
* dirty/access bit if needed without a fault.
*/
const pteval_t flush_on_clear = _PAGE_DIRTY | _PAGE_PRESENT |
- _PAGE_ACCESSED;
+ _PAGE_ACCESSED | _PAGE_RW;
+ const pteval_t flush_on_set = _PAGE_NX;
+ const pteval_t flush_on_set_relaxed = _PAGE_RW;
+ const pteval_t flush_on_clear_relaxed = _PAGE_NX;
const pteval_t software_flags = _PAGE_SOFTW1 | _PAGE_SOFTW2 |
_PAGE_SOFTW3 | _PAGE_SOFTW4;
- const pteval_t flush_on_change = _PAGE_RW | _PAGE_USER | _PAGE_PWT |
+ const pteval_t flush_on_change = _PAGE_USER | _PAGE_PWT |
_PAGE_PCD | _PAGE_PSE | _PAGE_GLOBAL | _PAGE_PAT |
_PAGE_PAT_LARGE | _PAGE_PKEY_BIT0 | _PAGE_PKEY_BIT1 |
- _PAGE_PKEY_BIT2 | _PAGE_PKEY_BIT3 | _PAGE_NX;
+ _PAGE_PKEY_BIT2 | _PAGE_PKEY_BIT3;
unsigned long diff = oldflags ^ newflags;
BUILD_BUG_ON(flush_on_clear & software_flags);
BUILD_BUG_ON(flush_on_clear & flush_on_change);
BUILD_BUG_ON(flush_on_change & software_flags);
+ BUILD_BUG_ON(flush_on_change & flush_on_clear_relaxed);
+ BUILD_BUG_ON(flush_on_change & flush_on_set_relaxed);
/* Ignore software flags */
diff &= ~software_flags;
@@ -301,9 +306,16 @@ static inline enum pte_flush_type pte_flags_flush_type(unsigned long oldflags,
if (diff & flush_on_change)
return PTE_FLUSH_STRICT;
+ if (diff & oldflags & flush_on_clear_relaxed)
+ return PTE_FLUSH_RELAXED;
+
+ if (diff & newflags & flush_on_set_relaxed)
+ return PTE_FLUSH_RELAXED;
+
/* Ensure there are no flags that were left behind */
if (IS_ENABLED(CONFIG_DEBUG_VM) &&
- (diff & ~(flush_on_clear | software_flags | flush_on_change))) {
+ (diff & ~(flush_on_clear | flush_on_set |
+ software_flags | flush_on_change))) {
VM_WARN_ON_ONCE(1);
return PTE_FLUSH_STRICT;
}