diff mbox

[RFC/PATCH,1/1] s390/kvm: Fix BUG in include/linux/kvm_host.h:745

Message ID 1357658590-9123-2-git-send-email-borntraeger@de.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christian Borntraeger Jan. 8, 2013, 3:23 p.m. UTC
commit b080935c8638e08134629d0a9ebdf35669bec14d
    kvm: Directly account vtime to system on guest switch

also removed the irq_disable/enable around kvm guest switch, which
is correct in itself. Unfortunately, there is a BUG ON that (correctly)
checks for preemptible to cover the call to rcu later on.
(Introduced with commit 8fa2206821953a50a3a02ea33fcfb3ced2fd9997
    KVM: make guest mode entry to be rcu quiescent state)

This check might trigger depending on the kernel config.
Lets make sure that no preemption happens during kvm_guest_enter.
We can enable preemption again after the call to
rcu_virt_note_context_switch returns.

Please note that we continue to run s390 guests with interrupts
enabled.

CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Frederic Weisbecker Jan. 8, 2013, 4:12 p.m. UTC | #1
2013/1/8 Christian Borntraeger <borntraeger@de.ibm.com>:
> commit b080935c8638e08134629d0a9ebdf35669bec14d
>     kvm: Directly account vtime to system on guest switch
>
> also removed the irq_disable/enable around kvm guest switch, which
> is correct in itself. Unfortunately, there is a BUG ON that (correctly)
> checks for preemptible to cover the call to rcu later on.
> (Introduced with commit 8fa2206821953a50a3a02ea33fcfb3ced2fd9997
>     KVM: make guest mode entry to be rcu quiescent state)
>
> This check might trigger depending on the kernel config.
> Lets make sure that no preemption happens during kvm_guest_enter.
> We can enable preemption again after the call to
> rcu_virt_note_context_switch returns.
>
> Please note that we continue to run s390 guests with interrupts
> enabled.
>
> CC: Frederic Weisbecker <fweisbec@gmail.com>
> CC: Gleb Natapov <gleb@redhat.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  arch/s390/kvm/kvm-s390.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index c9011bf..f090e81 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -613,7 +613,9 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
>                 kvm_s390_deliver_pending_interrupts(vcpu);
>
>         vcpu->arch.sie_block->icptcode = 0;
> +       preempt_disable();
>         kvm_guest_enter();
> +       preempt_enable();

Sorry for the issue.

The fix looks good to me, thanks!

Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcelo Tosatti Jan. 10, 2013, 7:53 p.m. UTC | #2
On Tue, Jan 08, 2013 at 04:23:10PM +0100, Christian Borntraeger wrote:
> commit b080935c8638e08134629d0a9ebdf35669bec14d
>     kvm: Directly account vtime to system on guest switch
> 
> also removed the irq_disable/enable around kvm guest switch, which
> is correct in itself. Unfortunately, there is a BUG ON that (correctly)
> checks for preemptible to cover the call to rcu later on.
> (Introduced with commit 8fa2206821953a50a3a02ea33fcfb3ced2fd9997
>     KVM: make guest mode entry to be rcu quiescent state)
> 
> This check might trigger depending on the kernel config.
> Lets make sure that no preemption happens during kvm_guest_enter.
> We can enable preemption again after the call to
> rcu_virt_note_context_switch returns.
> 
> Please note that we continue to run s390 guests with interrupts
> enabled.
> 
> CC: Frederic Weisbecker <fweisbec@gmail.com>
> CC: Gleb Natapov <gleb@redhat.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>

Applied, thanks.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index c9011bf..f090e81 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -613,7 +613,9 @@  static int __vcpu_run(struct kvm_vcpu *vcpu)
 		kvm_s390_deliver_pending_interrupts(vcpu);
 
 	vcpu->arch.sie_block->icptcode = 0;
+	preempt_disable();
 	kvm_guest_enter();
+	preempt_enable();
 	VCPU_EVENT(vcpu, 6, "entering sie flags %x",
 		   atomic_read(&vcpu->arch.sie_block->cpuflags));
 	trace_kvm_s390_sie_enter(vcpu,