[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <03f60f3a-bb50-9210-8352-da16cca322b9@redhat.com>
Date: Fri, 2 Aug 2019 11:03:45 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Anup Patel <Anup.Patel@....com>,
Palmer Dabbelt <palmer@...ive.com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Radim K <rkrcmar@...hat.com>
Cc: Daniel Lezcano <daniel.lezcano@...aro.org>,
Thomas Gleixner <tglx@...utronix.de>,
Atish Patra <Atish.Patra@....com>,
Alistair Francis <Alistair.Francis@....com>,
Damien Le Moal <Damien.LeMoal@....com>,
Christoph Hellwig <hch@...radead.org>,
Anup Patel <anup@...infault.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH v2 07/19] RISC-V: KVM: Implement
KVM_GET_ONE_REG/KVM_SET_ONE_REG ioctls
On 02/08/19 09:47, Anup Patel wrote:
> + if (reg_num == KVM_REG_RISCV_CSR_REG(sip))
> + kvm_riscv_vcpu_flush_interrupts(vcpu, false);
Not updating the vsip CSR here can cause an interrupt to be lost, if the
next call to kvm_riscv_vcpu_flush_interrupts finds a zero mask.
You could add a new field vcpu->vsip_shadow that is updated every time
CSR_VSIP is written (including kvm_arch_vcpu_load) with a function like
void kvm_riscv_update_vsip(struct kvm_vcpu *vcpu)
{
if (vcpu->vsip_shadow != vcpu->arch.guest_csr.vsip) {
csr_write(CSR_VSIP, vcpu->arch.guest_csr.vsip);
vcpu->vsip_shadow = vcpu->arch.guest_csr.vsip;
}
}
And just call this unconditionally from kvm_vcpu_ioctl_run. The cost is
just a memory load per VS-mode entry, it should hardly be measurable.
Paolo
Powered by blists - more mailing lists