From: wanghaibin <wanghaibin.wang@huawei.com> The current early init for the GIC is pretty silly. The data it initializes only matters for GICv3, which is guaranteed to be created via a kvm_create_device call. Given that, it is pointless to initialize the data early, before userspace can get a file descriptor and mess with it. Move everything to kvm_vgic_create(). Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: wanghaibin <wanghaibin.wang@huawei.com> --- arch/arm64/kvm/arm.c | 2 -- arch/arm64/kvm/vgic/vgic-init.c | 4 +++- include/kvm/arm_vgic.h | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index e59152ad5c4a..39c779084430 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -357,8 +357,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) if (ret) goto err_free_cpumask; - kvm_vgic_early_init(kvm); - kvm_timer_init_vm(kvm); /* The maximum number of VCPUs is limited by the host's GIC model */ diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c index 3e4be3c80290..52eac2530d54 100644 --- a/arch/arm64/kvm/vgic/vgic-init.c +++ b/arch/arm64/kvm/vgic/vgic-init.c @@ -55,7 +55,7 @@ * allocation or sizing information from userspace. vgic_init() called * kvm_vgic_dist_init() which takes care of the rest. */ -void kvm_vgic_early_init(struct kvm *kvm) +static void kvm_vgic_early_init(struct kvm *kvm) { struct vgic_dist *dist = &kvm->arch.vgic; #ifdef CONFIG_KVM_ARM_MULTI_LPI_TRANSLATE_CACHE @@ -146,6 +146,8 @@ int kvm_vgic_create(struct kvm *kvm, u32 type) else INIT_LIST_HEAD(&kvm->arch.vgic.rd_regions); + kvm_vgic_early_init(kvm); + out_unlock: mutex_unlock(&kvm->arch.config_lock); unlock_all_vcpus(kvm); diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 640507053c69..ad78351fa905 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -442,7 +442,6 @@ extern struct static_key_false vgic_v2_cpuif_trap; extern struct static_key_false vgic_v3_cpuif_trap; int kvm_set_legacy_vgic_v2_addr(struct kvm *kvm, struct kvm_arm_device_addr *dev_addr); -void kvm_vgic_early_init(struct kvm *kvm); int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu); int kvm_vgic_create(struct kvm *kvm, u32 type); void kvm_vgic_destroy(struct kvm *kvm); -- 2.33.0