From 15e65b4a22a08667343b22679c5e792b2c3041a7 Mon Sep 17 00:00:00 2001 From: Quentin Perret Date: Thu, 17 Nov 2022 17:22:34 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Issue CMOs when tearing down shadow pages On the guest teardown path, pKVM will zero the pages used to back the guest shadow data structures before returning them to the host as they may contain secrets (e.g. in the vCPU registers). However, the zeroing is done using a cacheable alias, and CMOs are missing, hence giving the host a potential opportunity to read the original content of the shadow structs from memory. Fix this by issuing CMOs after zeroing the pages. Bug: 259551298 Change-Id: Id696d47d16e4c3fd870cb70b792eeb7f2282fc78 Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/nvhe/pkvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index d43ccfd72e04..cc2612937e7e 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -798,6 +798,7 @@ static void teardown_donated_memory(struct kvm_hyp_memcache *mc, void *addr, void *start; memset(addr, 0, size); + kvm_flush_dcache_to_poc(addr, size); for (start = addr; start < addr + size; start += PAGE_SIZE) push_hyp_memcache(mc, start, hyp_virt_to_phys);