From: Alexander Graf Subject: Re: [PATCH 1/4] KVM: PPC: Book3s: PR: Disable preemption in vcpu_run Date: Sat, 10 Dec 2011 00:18:41 +0100 Message-ID: <9FD32B52-754D-494D-8478-CAD3FDFAB586@suse.de> References: <1323444412-18482-1-git-send-email-agraf@suse.de> <1323444412-18482-2-git-send-email-agraf@suse.de> <4EE25149.7010109@freescale.com> Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: , =?iso-8859-1?Q?J=F6rg_Sommer?= , KVM list To: Scott Wood Return-path: In-Reply-To: <4EE25149.7010109@freescale.com> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 09.12.2011, at 19:19, Scott Wood wrote: > On 12/09/2011 09:26 AM, Alexander Graf wrote: >> When entering the guest, we want to make sure we're not getting pree= mpted >> away, so let's disable preemption on entry, but enable it again whil= e handling >> guest exits. >>=20 >> Reported-by: J=F6rg Sommer >> Signed-off-by: Alexander Graf >> --- >> arch/powerpc/kvm/book3s_pr.c | 7 +++++++ >> 1 files changed, 7 insertions(+), 0 deletions(-) >>=20 >> diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_= pr.c >> index 726512b..8e4f800 100644 >> --- a/arch/powerpc/kvm/book3s_pr.c >> +++ b/arch/powerpc/kvm/book3s_pr.c >> @@ -519,6 +519,7 @@ int kvmppc_handle_exit(struct kvm_run *run, stru= ct kvm_vcpu *vcpu, >> run->ready_for_interrupt_injection =3D 1; >>=20 >> trace_kvm_book3s_exit(exit_nr, vcpu); >> + preempt_enable(); >> kvm_resched(vcpu); >> switch (exit_nr) { >> case BOOK3S_INTERRUPT_INST_STORAGE: >> @@ -763,6 +764,8 @@ program_interrupt: >> run->exit_reason =3D KVM_EXIT_INTR; >> r =3D -EINTR; >> } else { >> + preempt_disable(); >> + >> /* In case an interrupt came in that was triggered >> * from userspace (like DEC), we need to check what >> * to inject now! */ >=20 > Shouldn't you really have interrupts disabled here, as booke does? Ah, thanks for the reminder. Yeah, we probably want to disable interrup= ts in parallel to checking for signals (basically from one signal check= point to world switch). I'm just not 100% sure how to easily sync the = C and asm code on the first entry though. Doing local_irq_disable in C = and undoing it in asm could become ugly with lazy interrupt disabling. Alex