From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgDst-0000I8-6F for qemu-devel@nongnu.org; Sat, 03 Sep 2016 12:33:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgDsf-00065k-00 for qemu-devel@nongnu.org; Sat, 03 Sep 2016 12:33:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50531) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgDse-00065U-NV for qemu-devel@nongnu.org; Sat, 03 Sep 2016 12:33:20 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u83GXDIr039734 for ; Sat, 3 Sep 2016 12:33:20 -0400 Received: from e28smtp03.in.ibm.com (e28smtp03.in.ibm.com [125.16.236.3]) by mx0a-001b2d01.pphosted.com with ESMTP id 257tkmmsur-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sat, 03 Sep 2016 12:33:19 -0400 Received: from localhost by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 3 Sep 2016 22:03:16 +0530 From: Nikunj A Dadhania In-Reply-To: <73c88737-b7ca-47f2-ccdf-0d0a030da3f0@redhat.com> References: <1472797976-24210-1-git-send-email-nikunj@linux.vnet.ibm.com> <1472797976-24210-2-git-send-email-nikunj@linux.vnet.ibm.com> <73c88737-b7ca-47f2-ccdf-0d0a030da3f0@redhat.com> Date: Sat, 03 Sep 2016 22:03:07 +0530 MIME-Version: 1.0 Content-Type: text/plain Message-Id: <874m5x3pvg.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> Subject: Re: [Qemu-devel] [PATCH RFC 1/4] spapr-hcall: take iothread lock during handler call List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth , qemu-ppc@nongnu.org, alex.bennee@linaro.org, david@gibson.dropbear.id.au, rth@twiddle.net Cc: qemu-devel@nongnu.org Thomas Huth writes: > On 02.09.2016 08:32, Nikunj A Dadhania wrote: >> Signed-off-by: Nikunj A Dadhania >> --- >> hw/ppc/spapr_hcall.c | 11 +++++++++-- >> 1 file changed, 9 insertions(+), 2 deletions(-) >> >> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c >> index e5eca67..daea7a0 100644 >> --- a/hw/ppc/spapr_hcall.c >> +++ b/hw/ppc/spapr_hcall.c >> @@ -1075,20 +1075,27 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ulong opcode, >> target_ulong *args) >> { >> sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); >> + target_ulong ret; >> >> if ((opcode <= MAX_HCALL_OPCODE) >> && ((opcode & 0x3) == 0)) { >> spapr_hcall_fn fn = papr_hypercall_table[opcode / 4]; >> >> if (fn) { >> - return fn(cpu, spapr, opcode, args); >> + qemu_mutex_lock_iothread(); >> + ret = fn(cpu, spapr, opcode, args); >> + qemu_mutex_unlock_iothread(); >> + return ret; >> } >> } else if ((opcode >= KVMPPC_HCALL_BASE) && >> (opcode <= KVMPPC_HCALL_MAX)) { >> spapr_hcall_fn fn = kvmppc_hypercall_table[opcode - KVMPPC_HCALL_BASE]; >> >> if (fn) { >> - return fn(cpu, spapr, opcode, args); >> + qemu_mutex_lock_iothread(); >> + ret = fn(cpu, spapr, opcode, args); >> + qemu_mutex_unlock_iothread(); >> + return ret; >> } >> } > > I think this will cause a deadlock when running on KVM since the lock is > already taken in kvm_arch_handle_exit() - which calls spapr_hypercall()! Ouch, havent tried this branch yet on KVM :( Will change to emulation only as suggested in my previous mails. Regards, Nikunj