mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
KVM: arm/arm64: Get rid of vcpu->arch.irq_lines
We currently have a separate read-modify-write of the HCR_EL2 on entry to the guest for the sole purpose of setting the VF and VI bits, if set. Since this is most rarely the case (only when using userspace IRQ chip and interrupts are in flight), let's get rid of this operation and instead modify the bits in the vcpu->arch.hcr[_el2] directly when needed. Acked-by: Marc Zyngier <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Julien Thierry <[email protected]> Signed-off-by: Christoffer Dall <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
This commit is contained in:
parent
35a84dec00
commit
3df59d8dd3
10 changed files with 16 additions and 37 deletions
|
|
@ -420,7 +420,8 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
|
|||
*/
|
||||
int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
|
||||
{
|
||||
return ((!!v->arch.irq_lines || kvm_vgic_vcpu_pending_irq(v))
|
||||
bool irq_lines = *vcpu_hcr(v) & (HCR_VI | HCR_VF);
|
||||
return ((irq_lines || kvm_vgic_vcpu_pending_irq(v))
|
||||
&& !v->arch.power_off && !v->arch.pause);
|
||||
}
|
||||
|
||||
|
|
@ -814,18 +815,18 @@ static int vcpu_interrupt_line(struct kvm_vcpu *vcpu, int number, bool level)
|
|||
{
|
||||
int bit_index;
|
||||
bool set;
|
||||
unsigned long *ptr;
|
||||
unsigned long *hcr;
|
||||
|
||||
if (number == KVM_ARM_IRQ_CPU_IRQ)
|
||||
bit_index = __ffs(HCR_VI);
|
||||
else /* KVM_ARM_IRQ_CPU_FIQ */
|
||||
bit_index = __ffs(HCR_VF);
|
||||
|
||||
ptr = (unsigned long *)&vcpu->arch.irq_lines;
|
||||
hcr = vcpu_hcr(vcpu);
|
||||
if (level)
|
||||
set = test_and_set_bit(bit_index, ptr);
|
||||
set = test_and_set_bit(bit_index, hcr);
|
||||
else
|
||||
set = test_and_clear_bit(bit_index, ptr);
|
||||
set = test_and_clear_bit(bit_index, hcr);
|
||||
|
||||
/*
|
||||
* If we didn't change anything, no need to wake up or kick other CPUs
|
||||
|
|
|
|||
|
|
@ -2035,7 +2035,7 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
|
|||
*/
|
||||
void kvm_set_way_flush(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
unsigned long hcr = vcpu_get_hcr(vcpu);
|
||||
unsigned long hcr = *vcpu_hcr(vcpu);
|
||||
|
||||
/*
|
||||
* If this is the first time we do a S/W operation
|
||||
|
|
@ -2050,7 +2050,7 @@ void kvm_set_way_flush(struct kvm_vcpu *vcpu)
|
|||
trace_kvm_set_way_flush(*vcpu_pc(vcpu),
|
||||
vcpu_has_cache_enabled(vcpu));
|
||||
stage2_flush_vm(vcpu->kvm);
|
||||
vcpu_set_hcr(vcpu, hcr | HCR_TVM);
|
||||
*vcpu_hcr(vcpu) = hcr | HCR_TVM;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2068,7 +2068,7 @@ void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled)
|
|||
|
||||
/* Caches are now on, stop trapping VM ops (until a S/W op) */
|
||||
if (now_enabled)
|
||||
vcpu_set_hcr(vcpu, vcpu_get_hcr(vcpu) & ~HCR_TVM);
|
||||
*vcpu_hcr(vcpu) &= ~HCR_TVM;
|
||||
|
||||
trace_kvm_toggle_cache(*vcpu_pc(vcpu), was_enabled, now_enabled);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue