From d4772b152b2ab5b1d5ad8a1fe5544f92942158c3 Mon Sep 17 00:00:00 2001 From: Mostafa Saleh Date: Thu, 9 May 2024 13:59:07 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Pad IOMMU structs for KMI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit KMI is going to be frozen soon, so add padding in IOMMU structs as it can be helpful to update the driver without changing the ABI. The updated structs are: kvm_iommu_ops: kvm_iommu_driver: reserve 8 qwords, this is only instantiated once, and the most likely one to change, as it implements the callbacks between the IOMMU code and the hypervisor module. kvm_iommu_driver: reserve 8 qwords, this is only instantiated once, this implements the callbacks between the IOMMU code and the kernel module. kvm_hyp_iommu: reserve 4 qwords, instantiated once per-iommu. kvm_hyp_iommu_domain: reserve 2 qwords, this is the most instantiated struct, so we don’t add a lot of padding. iommu_iotlb_gather: reserve 2 qwords, in case we need to add hypervisor specific logic in the future. io_pgtable_ops: reserve 4 qwords, instantiated once per iommu domain. Bug: 357781595 Bug: 384432312 Change-Id: I1c5c9e0dd4fe1b422c8a20e23df6b9e10f646071 Signed-off-by: Mostafa Saleh --- arch/arm64/include/asm/kvm_host.h | 9 +++++++++ arch/arm64/kvm/hyp/include/nvhe/iommu.h | 8 ++++++++ include/kvm/iommu.h | 6 ++++++ include/linux/io-pgtable.h | 5 +++++ include/linux/iommu.h | 3 +++ 5 files changed, 31 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index e9270ad581a9..519ac79305cf 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -11,6 +11,7 @@ #ifndef __ARM64_KVM_HOST_H__ #define __ARM64_KVM_HOST_H__ +#include #include #include #include @@ -1667,6 +1668,14 @@ struct kvm_iommu_driver { int (*init_driver)(void); void (*remove_driver)(void); pkvm_handle_t (*get_iommu_id)(struct device *dev); + ANDROID_KABI_RESERVE(1); + ANDROID_KABI_RESERVE(2); + ANDROID_KABI_RESERVE(3); + ANDROID_KABI_RESERVE(4); + ANDROID_KABI_RESERVE(5); + ANDROID_KABI_RESERVE(6); + ANDROID_KABI_RESERVE(7); + ANDROID_KABI_RESERVE(8); }; struct kvm_iommu_ops; diff --git a/arch/arm64/kvm/hyp/include/nvhe/iommu.h b/arch/arm64/kvm/hyp/include/nvhe/iommu.h index 523555df2829..fc02ab6fa26d 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/iommu.h +++ b/arch/arm64/kvm/hyp/include/nvhe/iommu.h @@ -64,6 +64,14 @@ struct kvm_iommu_ops { phys_addr_t start, phys_addr_t end, int prot); int (*suspend)(struct kvm_hyp_iommu *iommu); int (*resume)(struct kvm_hyp_iommu *iommu); + ANDROID_KABI_RESERVE(1); + ANDROID_KABI_RESERVE(2); + ANDROID_KABI_RESERVE(3); + ANDROID_KABI_RESERVE(4); + ANDROID_KABI_RESERVE(5); + ANDROID_KABI_RESERVE(6); + ANDROID_KABI_RESERVE(7); + ANDROID_KABI_RESERVE(8); }; int kvm_iommu_init(struct kvm_iommu_ops *ops, diff --git a/include/kvm/iommu.h b/include/kvm/iommu.h index 6bf1b5fca58b..041182c60956 100644 --- a/include/kvm/iommu.h +++ b/include/kvm/iommu.h @@ -24,6 +24,8 @@ struct kvm_hyp_iommu_domain { atomic_t refs; pkvm_handle_t domain_id; void *priv; + ANDROID_KABI_RESERVE(1); + ANDROID_KABI_RESERVE(2); }; extern void **kvm_nvhe_sym(kvm_hyp_iommu_domains); @@ -63,6 +65,10 @@ struct kvm_hyp_iommu { #endif struct kvm_power_domain power_domain; bool power_is_off; + ANDROID_KABI_RESERVE(1); + ANDROID_KABI_RESERVE(2); + ANDROID_KABI_RESERVE(3); + ANDROID_KABI_RESERVE(4); }; #endif /* __KVM_IOMMU_H */ diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index ce0aed9c87d2..9c271f545a67 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -2,6 +2,7 @@ #ifndef __IO_PGTABLE_H #define __IO_PGTABLE_H +#include #include #include @@ -237,6 +238,10 @@ struct io_pgtable_ops { unsigned long iova, size_t size, unsigned long flags, struct iommu_dirty_bitmap *dirty); + ANDROID_KABI_RESERVE(1); + ANDROID_KABI_RESERVE(2); + ANDROID_KABI_RESERVE(3); + ANDROID_KABI_RESERVE(4); }; /** diff --git a/include/linux/iommu.h b/include/linux/iommu.h index c75877044185..81afe99fbb3b 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -7,6 +7,7 @@ #ifndef __LINUX_IOMMU_H #define __LINUX_IOMMU_H +#include #include #include #include @@ -348,6 +349,8 @@ struct iommu_iotlb_gather { size_t pgsize; struct list_head freelist; bool queued; + ANDROID_KABI_RESERVE(1); + ANDROID_KABI_RESERVE(2); }; /**