diff options
author | Eric Auger <eric.auger@redhat.com> | 2018-05-22 03:55:13 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2018-05-25 07:29:27 -0400 |
commit | 5ec17fbac6713be82b90f54d5a31251803fd8de5 (patch) | |
tree | 8212423303cf7bedfd46500e406abf88d4b93530 /virt | |
parent | ccc27bf5be7b78f64b67902bf27f6ef484bedc2c (diff) |
KVM: arm/arm64: Remove kvm_vgic_vcpu_early_init
kvm_vgic_vcpu_early_init gets called after kvm_vgic_cpu_init which
is confusing. The call path is as follows:
kvm_vm_ioctl_create_vcpu
|_ kvm_arch_cpu_create
|_ kvm_vcpu_init
|_ kvm_arch_vcpu_init
|_ kvm_vgic_vcpu_init
|_ kvm_arch_vcpu_postcreate
|_ kvm_vgic_vcpu_early_init
Static initialization currently done in kvm_vgic_vcpu_early_init()
can be moved to kvm_vgic_vcpu_init(). So let's move the code and
remove kvm_vgic_vcpu_early_init(). kvm_arch_vcpu_postcreate() does
nothing.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/arm/arm.c | 1 | ||||
-rw-r--r-- | virt/kvm/arm/vgic/vgic-init.c | 80 |
2 files changed, 37 insertions, 44 deletions
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 39e777155e7c..126b98fbf9ba 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c | |||
@@ -292,7 +292,6 @@ out: | |||
292 | 292 | ||
293 | void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) | 293 | void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) |
294 | { | 294 | { |
295 | kvm_vgic_vcpu_early_init(vcpu); | ||
296 | } | 295 | } |
297 | 296 | ||
298 | void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) | 297 | void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) |
diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index 8901b2d8fca1..272af9704952 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c | |||
@@ -44,7 +44,7 @@ | |||
44 | * | 44 | * |
45 | * CPU Interface: | 45 | * CPU Interface: |
46 | * | 46 | * |
47 | * - kvm_vgic_vcpu_early_init(): initialization of static data that | 47 | * - kvm_vgic_vcpu_init(): initialization of static data that |
48 | * doesn't depend on any sizing information or emulation type. No | 48 | * doesn't depend on any sizing information or emulation type. No |
49 | * allocation is allowed there. | 49 | * allocation is allowed there. |
50 | */ | 50 | */ |
@@ -67,46 +67,6 @@ void kvm_vgic_early_init(struct kvm *kvm) | |||
67 | spin_lock_init(&dist->lpi_list_lock); | 67 | spin_lock_init(&dist->lpi_list_lock); |
68 | } | 68 | } |
69 | 69 | ||
70 | /** | ||
71 | * kvm_vgic_vcpu_early_init() - Initialize static VGIC VCPU data structures | ||
72 | * @vcpu: The VCPU whose VGIC data structures whould be initialized | ||
73 | * | ||
74 | * Only do initialization, but do not actually enable the VGIC CPU interface | ||
75 | * yet. | ||
76 | */ | ||
77 | void kvm_vgic_vcpu_early_init(struct kvm_vcpu *vcpu) | ||
78 | { | ||
79 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; | ||
80 | int i; | ||
81 | |||
82 | INIT_LIST_HEAD(&vgic_cpu->ap_list_head); | ||
83 | spin_lock_init(&vgic_cpu->ap_list_lock); | ||
84 | |||
85 | /* | ||
86 | * Enable and configure all SGIs to be edge-triggered and | ||
87 | * configure all PPIs as level-triggered. | ||
88 | */ | ||
89 | for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) { | ||
90 | struct vgic_irq *irq = &vgic_cpu->private_irqs[i]; | ||
91 | |||
92 | INIT_LIST_HEAD(&irq->ap_list); | ||
93 | spin_lock_init(&irq->irq_lock); | ||
94 | irq->intid = i; | ||
95 | irq->vcpu = NULL; | ||
96 | irq->target_vcpu = vcpu; | ||
97 | irq->targets = 1U << vcpu->vcpu_id; | ||
98 | kref_init(&irq->refcount); | ||
99 | if (vgic_irq_is_sgi(i)) { | ||
100 | /* SGIs */ | ||
101 | irq->enabled = 1; | ||
102 | irq->config = VGIC_CONFIG_EDGE; | ||
103 | } else { | ||
104 | /* PPIs */ | ||
105 | irq->config = VGIC_CONFIG_LEVEL; | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | |||
110 | /* CREATION */ | 70 | /* CREATION */ |
111 | 71 | ||
112 | /** | 72 | /** |
@@ -224,13 +184,47 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis) | |||
224 | } | 184 | } |
225 | 185 | ||
226 | /** | 186 | /** |
227 | * kvm_vgic_vcpu_init() - Register VCPU-specific KVM iodevs | 187 | * kvm_vgic_vcpu_init() - Initialize static VGIC VCPU data |
188 | * structures and register VCPU-specific KVM iodevs | ||
189 | * | ||
228 | * @vcpu: pointer to the VCPU being created and initialized | 190 | * @vcpu: pointer to the VCPU being created and initialized |
191 | * | ||
192 | * Only do initialization, but do not actually enable the | ||
193 | * VGIC CPU interface | ||
229 | */ | 194 | */ |
230 | int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) | 195 | int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) |
231 | { | 196 | { |
232 | int ret = 0; | 197 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; |
233 | struct vgic_dist *dist = &vcpu->kvm->arch.vgic; | 198 | struct vgic_dist *dist = &vcpu->kvm->arch.vgic; |
199 | int ret = 0; | ||
200 | int i; | ||
201 | |||
202 | INIT_LIST_HEAD(&vgic_cpu->ap_list_head); | ||
203 | spin_lock_init(&vgic_cpu->ap_list_lock); | ||
204 | |||
205 | /* | ||
206 | * Enable and configure all SGIs to be edge-triggered and | ||
207 | * configure all PPIs as level-triggered. | ||
208 | */ | ||
209 | for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) { | ||
210 | struct vgic_irq *irq = &vgic_cpu->private_irqs[i]; | ||
211 | |||
212 | INIT_LIST_HEAD(&irq->ap_list); | ||
213 | spin_lock_init(&irq->irq_lock); | ||
214 | irq->intid = i; | ||
215 | irq->vcpu = NULL; | ||
216 | irq->target_vcpu = vcpu; | ||
217 | irq->targets = 1U << vcpu->vcpu_id; | ||
218 | kref_init(&irq->refcount); | ||
219 | if (vgic_irq_is_sgi(i)) { | ||
220 | /* SGIs */ | ||
221 | irq->enabled = 1; | ||
222 | irq->config = VGIC_CONFIG_EDGE; | ||
223 | } else { | ||
224 | /* PPIs */ | ||
225 | irq->config = VGIC_CONFIG_LEVEL; | ||
226 | } | ||
227 | } | ||
234 | 228 | ||
235 | if (!irqchip_in_kernel(vcpu->kvm)) | 229 | if (!irqchip_in_kernel(vcpu->kvm)) |
236 | return 0; | 230 | return 0; |