KVM: arm64: Issue CMOs when tearing down guest s2 pages
authorQuentin Perret <qperret@google.com>
Tue, 23 Apr 2024 15:05:13 +0000 (16:05 +0100)
committerMarc Zyngier <maz@kernel.org>
Wed, 1 May 2024 15:46:58 +0000 (16:46 +0100)
On the guest teardown path, pKVM will zero the pages used to back
the guest 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 guest structs from memory.

Fix this by issuing CMOs after zeroing the pages.

Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Fuad Tabba <tabba@google.com>
Acked-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240423150538.2103045-6-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/hyp/nvhe/pkvm.c

index 492b7fc2c0c7312bf8ef9fa78a1a3fb1018f29d7..315d4ebe1d6af5772d2c4306222c516d5221968c 100644 (file)
@@ -441,6 +441,7 @@ static void *map_donated_memory(unsigned long host_va, size_t size)
 
 static void __unmap_donated_memory(void *va, size_t size)
 {
+       kvm_flush_dcache_to_poc(va, size);
        WARN_ON(__pkvm_hyp_donate_host(hyp_virt_to_pfn(va),
                                       PAGE_ALIGN(size) >> PAGE_SHIFT));
 }