ANDROID: KVM: arm64: iommu: Snapshot host stage-2

Snapshot the host stage-2 in the idmapped domain, this is done
differently from the Android14:

- Instead of assuming that the page table maps all the memory and
  the snapshot function would only unmap the donated pages, now the
  polarity is the opposite, where the page table is assumed to be
  empty and the snapshot function would map all host memory, so this
  slower, but done only once at boot, and that won't require the
  module to know the memory map.

- Instead of calling snapshot at init, now it is exported to modules,
  as some IOMMUs as SMMUv3 doens't know the format of the page table
  until the device is attached.

Bug: 357781595
Bug: 384432312
Change-Id: I82dbf273eebc4e5c588c230a3a9bb18ef7b468ea
Signed-off-by: Mostafa Saleh <smostafa@google.com>
This commit is contained in:
Mostafa Saleh
2023-09-25 11:42:57 +00:00
parent 09a2d1b37e
commit b2e3ad4708
6 changed files with 102 additions and 2 deletions
+11
View File
@@ -9,6 +9,17 @@
#include <nvhe/spinlock.h>
#endif
/*
* Domain ID for identity mapped domain that the host can attach
* to get the same mapping available to the CPU page table.
*/
#define KVM_IOMMU_DOMAIN_IDMAP_ID 0
/* Used in alloc_domain type argument. */
#define KVM_IOMMU_DOMAIN_IDMAP_TYPE 0
#define KVM_IOMMU_DOMAIN_NR_START (KVM_IOMMU_DOMAIN_IDMAP_ID + 1)
struct kvm_hyp_iommu_domain {
atomic_t refs;
pkvm_handle_t domain_id;