]> git.baikalelectronics.ru Git - kernel.git/commit
irqchip/gic-v4: Wait for GICR_VPENDBASER.Dirty to clear before descheduling
authorMarc Zyngier <maz@kernel.org>
Thu, 17 Mar 2022 09:49:02 +0000 (09:49 +0000)
committerMarc Zyngier <maz@kernel.org>
Tue, 5 Apr 2022 15:33:13 +0000 (16:33 +0100)
commitd433af0f7604c3de26d0b4f2b48bc068dfe04bf5
treec8faa04942b674ff973e59afb75c0b37378972a4
parentd58f08e5dc9af234e8bd68210dee7696779059bf
irqchip/gic-v4: Wait for GICR_VPENDBASER.Dirty to clear before descheduling

The way KVM drives GICv4.{0,1} is as follows:
- vcpu_load() makes the VPE resident, instructing the RD to start
  scanning for interrupts
- just before entering the guest, we check that the RD has finished
  scanning and that we can start running the vcpu
- on preemption, we deschedule the VPE by making it invalid on
  the RD

However, we are preemptible between the first two steps. If it so
happens *and* that the RD was still scanning, we nonetheless write
to the GICR_VPENDBASER register while Dirty is set, and bad things
happen (we're in UNPRED land).

This affects both the 4.0 and 4.1 implementations.

Make sure Dirty is cleared before performing the deschedule,
meaning that its_clear_vpend_valid() becomes a sort of full VPE
residency barrier.

Reported-by: Jingyi Wang <wangjingyi11@huawei.com>
Tested-by: Nianyao Tang <tangnianyao@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Fixes: fa04ce397abc ("KVM: arm64: Delay the polling of the GICR_VPENDBASER.Dirty bit")
Link: https://lore.kernel.org/r/4aae10ba-b39a-5f84-754b-69c2eb0a2c03@huawei.com
drivers/irqchip/irq-gic-v3-its.c