From d2efcdcb2b1874ad0d701cdb6d9ae4517fc0e117 Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Tue, 29 Jun 2021 19:14:45 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Add 'host_smc_handler' to kvm_iommu_ops IOMMU drivers need to intercept power management SMCs between the host and EL3. Add a hook to hyp's 'handle_host_smc'. Test: builds, boots Bug: 190463801 Signed-off-by: David Brazdil Change-Id: Ief42370ac371f6b3b87a0d46c00acfffece47052 --- arch/arm64/include/asm/kvm_hyp.h | 1 + arch/arm64/kvm/hyp/nvhe/hyp-main.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h index d9158d8d9f5e..70bf7ae3a642 100644 --- a/arch/arm64/include/asm/kvm_hyp.h +++ b/arch/arm64/include/asm/kvm_hyp.h @@ -126,6 +126,7 @@ extern u64 kvm_nvhe_sym(id_aa64mmfr2_el1_sys_val); struct kvm_iommu_ops { int (*init)(void); + bool (*host_smc_handler)(struct kvm_cpu_context *host_ctxt); }; extern struct kvm_iommu_ops kvm_iommu_ops; diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index 321ae7c07b05..75ce2547cd6e 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -246,6 +246,8 @@ static void handle_host_smc(struct kvm_cpu_context *host_ctxt) bool handled; handled = kvm_host_psci_handler(host_ctxt); + if (!handled && kvm_iommu_ops.host_smc_handler) + handled = kvm_iommu_ops.host_smc_handler(host_ctxt); if (!handled) default_host_smc_handler(host_ctxt);