Re: [PATCH v9 20/22] RISC-V: KVM: Fix race-condition in kvm_riscv_vcpu_sync_interrupts()

From: Paolo Bonzini
Date: Mon Oct 21 2019 - 13:27:17 EST


On 16/10/19 18:12, Anup Patel wrote:
> + /* Read current VSIP and VSIE CSRs */
> + vsip = csr_read(CSR_VSIP);
> + csr->vsie = csr_read(CSR_VSIE);
> +
> + /* Sync-up VSIP.SSIP bit changes does by Guest */
> + if ((csr->vsip ^ vsip) & (1UL << IRQ_S_SOFT)) {
> + if (!test_and_set_bit(IRQ_S_SOFT, &v->irqs_pending_mask)) {
> + if (vsip & (1UL << IRQ_S_SOFT))
> + set_bit(IRQ_S_SOFT, &v->irqs_pending);
> + else
> + clear_bit(IRQ_S_SOFT, &v->irqs_pending);
> + }

Looks good, but I wonder if this could just be "csr->vsip =
csr_read(CSR_VSIP)", which will be fixed up by flush_interrupts on the
next entry.

Paolo