Skip to content

Commit 75d1cc0

Browse files
Krish Sadhukhansuryasaimadhu
authored andcommitted
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 <thomas.lendacky@amd.com> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20200917212038.5090-3-krish.sadhukhan@oracle.com
1 parent 5866e92 commit 75d1cc0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/mm/pat/set_memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,7 +1999,7 @@ static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc)
19991999
/*
20002000
* Before changing the encryption attribute, we need to flush caches.
20012001
*/
2002-
cpa_flush(&cpa, 1);
2002+
cpa_flush(&cpa, !this_cpu_has(X86_FEATURE_SME_COHERENT));
20032003

20042004
ret = __change_page_attr_set_clr(&cpa, 1);
20052005

0 commit comments

Comments
 (0)