KVM: arm64: Ensure LRs are clear when they should be
We currently have some code to clear the list registers on GICv3, but we never call this code, because the caller got nuked when removing the old vgic. We also used to have a similar GICv2 part, but that got lost in the process too. Let's reintroduce the logic for GICv2 and call the logic when we initialize the use of hypervisors on the CPU, for example when first loading KVM or when exiting a low power state. Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
This commit is contained in:
Родитель
8b3405e345
Коммит
5b0d2cc280
|
@ -1124,6 +1124,9 @@ static void cpu_hyp_reinit(void)
|
|||
if (__hyp_get_vectors() == hyp_default_vectors)
|
||||
cpu_init_hyp_mode(NULL);
|
||||
}
|
||||
|
||||
if (vgic_present)
|
||||
kvm_vgic_init_cpu_hardware();
|
||||
}
|
||||
|
||||
static void cpu_hyp_reset(void)
|
||||
|
|
|
@ -295,6 +295,7 @@ void kvm_vgic_vcpu_early_init(struct kvm_vcpu *vcpu);
|
|||
void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu);
|
||||
int kvm_vgic_map_resources(struct kvm *kvm);
|
||||
int kvm_vgic_hyp_init(void);
|
||||
void kvm_vgic_init_cpu_hardware(void);
|
||||
|
||||
int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int intid,
|
||||
bool level);
|
||||
|
|
|
@ -391,6 +391,25 @@ static irqreturn_t vgic_maintenance_handler(int irq, void *data)
|
|||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* kvm_vgic_init_cpu_hardware - initialize the GIC VE hardware
|
||||
*
|
||||
* For a specific CPU, initialize the GIC VE hardware.
|
||||
*/
|
||||
void kvm_vgic_init_cpu_hardware(void)
|
||||
{
|
||||
BUG_ON(preemptible());
|
||||
|
||||
/*
|
||||
* We want to make sure the list registers start out clear so that we
|
||||
* only have the program the used registers.
|
||||
*/
|
||||
if (kvm_vgic_global_state.type == VGIC_V2)
|
||||
vgic_v2_init_lrs();
|
||||
else
|
||||
kvm_call_hyp(__vgic_v3_init_lrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* kvm_vgic_hyp_init: populates the kvm_vgic_global_state variable
|
||||
* according to the host GIC model. Accordingly calls either
|
||||
|
|
|
@ -36,6 +36,21 @@ static unsigned long *u64_to_bitmask(u64 *val)
|
|||
return (unsigned long *)val;
|
||||
}
|
||||
|
||||
static inline void vgic_v2_write_lr(int lr, u32 val)
|
||||
{
|
||||
void __iomem *base = kvm_vgic_global_state.vctrl_base;
|
||||
|
||||
writel_relaxed(val, base + GICH_LR0 + (lr * 4));
|
||||
}
|
||||
|
||||
void vgic_v2_init_lrs(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < kvm_vgic_global_state.nr_lr; i++)
|
||||
vgic_v2_write_lr(i, 0);
|
||||
}
|
||||
|
||||
void vgic_v2_process_maintenance(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
struct vgic_v2_cpu_if *cpuif = &vcpu->arch.vgic_cpu.vgic_v2;
|
||||
|
|
|
@ -130,6 +130,8 @@ int vgic_v2_map_resources(struct kvm *kvm);
|
|||
int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address,
|
||||
enum vgic_type);
|
||||
|
||||
void vgic_v2_init_lrs(void);
|
||||
|
||||
static inline void vgic_get_irq_kref(struct vgic_irq *irq)
|
||||
{
|
||||
if (irq->intid < VGIC_MIN_LPI)
|
||||
|
|
Загрузка…
Ссылка в новой задаче