The architecture implementations now clear memory during successful private-to-shared transitions. Make the no-encryption generic fallback clear the supplied range too.
Signed-off-by: Aneesh Kumar K.V (Arm) aneesh.kumar@kernel.org --- include/linux/set_memory.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/set_memory.h b/include/linux/set_memory.h index 27c32fbabfec..43ab0d62b87e 100644 --- a/include/linux/set_memory.h +++ b/include/linux/set_memory.h @@ -5,6 +5,10 @@ #ifndef _LINUX_SET_MEMORY_H_ #define _LINUX_SET_MEMORY_H_
+#include <linux/string.h> + +#include <asm/page.h> + /** * DOC: Kernel page table permissions * @@ -21,7 +25,8 @@ * * When an architecture does not implement these APIs they succeed without * doing anything, so a return value of 0 does not mean that the permissions - * were actually changed. + * were actually changed. set_memory_decrypted() also clears the range, + * including when no encryption change is needed. * * Callers that depend on the permissions being applied must ensure that the * architecture supports the required operation for the target addresses. The @@ -186,6 +191,7 @@ static inline int set_memory_encrypted(unsigned long addr, int numpages)
static inline int set_memory_decrypted(unsigned long addr, int numpages) { + memset((void *)addr, 0, (size_t)numpages << PAGE_SHIFT); return 0; } #endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */