aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrish Sadhukhan <[email protected]>2020-09-17 21:20:37 +0000
committerBorislav Petkov <[email protected]>2020-09-18 10:47:00 +0200
commit75d1cc0e05af579301ce4e49cf6399be4b4e6e76 (patch)
tree9f5f5e8e3cc8d5a99a4a0ff93d0fac01b5ac0812
parent5866e9205b47a983a77ebc8654949f696342f2ab (diff)
x86/mm/pat: Don't flush cache if hardware enforces cache coherency across encryption domnains
In some hardware implementations, coherency between the encrypted and unencrypted mappings of the same physical page is enforced. In such a system, it is not required for software to flush the page from all CPU caches in the system prior to changing the value of the C-bit for the page. So check that bit before flushing the cache. [ bp: Massage commit message. ] Suggested-by: Tom Lendacky <[email protected]> Signed-off-by: Krish Sadhukhan <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
-rw-r--r--arch/x86/mm/pat/set_memory.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index d1b2a889f035..40baa90e74f4 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -1999,7 +1999,7 @@ static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc)
/*
* Before changing the encryption attribute, we need to flush caches.
*/
- cpa_flush(&cpa, 1);
+ cpa_flush(&cpa, !this_cpu_has(X86_FEATURE_SME_COHERENT));
ret = __change_page_attr_set_clr(&cpa, 1);