From patchwork Mon Feb 20 14:53:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 9583085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6F016604A0 for ; Mon, 20 Feb 2017 15:31:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60E4A28434 for ; Mon, 20 Feb 2017 15:31:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53F8128477; Mon, 20 Feb 2017 15:31:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D51DD28434 for ; Mon, 20 Feb 2017 15:31:57 +0000 (UTC) Received: from localhost ([::1]:39220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfpwS-0001lY-Uc for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Feb 2017 10:31:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfpLq-0001kZ-4C for qemu-devel@nongnu.org; Mon, 20 Feb 2017 09:54:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cfpLn-0006tA-KL for qemu-devel@nongnu.org; Mon, 20 Feb 2017 09:54:06 -0500 Received: from mail-yb0-x243.google.com ([2607:f8b0:4002:c09::243]:36064) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cfpLn-0006t5-Ft for qemu-devel@nongnu.org; Mon, 20 Feb 2017 09:54:03 -0500 Received: by mail-yb0-x243.google.com with SMTP id d128so885866ybh.3 for ; Mon, 20 Feb 2017 06:54:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=N47v1Hi8r5shBusjAmBc8tkf3c0AXTDMe3lxbmLmMFg=; b=Z0+GCn5g92Yso9goCK4OEduZCE38ObBQIyEgSN0RLfjv90QmkBblBuW6Ye3zoElAx0 2e2P7T5/B5JjafpvJFmqvokWRNoA/Z7ua4QYEhJ+2HMEF9Fmg3H+UWAI02qRmw+WyGku Dow7Jcg5LLPPkvDyLZwPOf3Q1m1nHtNAi15NPsksGJNR+v5w+pO6QgW2C5ArhQucEkqH ohj95oIrBkQc8WLi/rIb9CfqSAAl0pdopeQmLbLyEcRgQfEZvS/Do9oHy0mdK3R+afTI 2Zw8mvgAaGnAee/XoVjYgLO0Y/CK/UBDs0axhnFHM/jSVPcoxoQrCWP++exoOINJsnhC Ft3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=N47v1Hi8r5shBusjAmBc8tkf3c0AXTDMe3lxbmLmMFg=; b=b+9TA26sUrQiCHYVVBxuBaMbwgsgllZwC+y2Up9qW4mIUQrMchGiPW9sQaJpvG2fR4 Z4SHZ6Y/bNDBnbbaba4IZR9x6c0GsQHUvgv8mB1sNXt7kjRE7QdMpBOcV90W+bncbd4q lysP1p2hAz7Uo/04SFAeZK6vVBsWFLyG3j8V4NQnBn/8x233I1AEXQV0bXSELE+UkOPQ zUUxOzOPyu/gBu2amiLZjqJHnd3C9MPyqVoUp0moWYZccCY4IOxiMqrhNql3vkuRt5Hu bLFJcw6vUg5lO9AmXma6i9ClloI+xnEHIJPqIEJfE1bGJ3HthS5E5/DTawcFVk+ksNqY 3DQA== X-Gm-Message-State: AMke39lLYITSYauOwsj7z+E5J59KoDxwKP20JMhVyf0RmO/Vop/uCbxBmpldo2Ml3tLxag== X-Received: by 10.37.170.49 with SMTP id s46mr15522818ybi.25.1487602442450; Mon, 20 Feb 2017 06:54:02 -0800 (PST) Received: from localhost.localdomain (c-73-207-178-95.hsd1.ga.comcast.net. [73.207.178.95]) by smtp.gmail.com with ESMTPSA id b143sm7174143ywh.47.2017.02.20.06.54.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Feb 2017 06:54:01 -0800 (PST) From: Pranith Kumar To: alex.bennee@linaro.org Date: Mon, 20 Feb 2017 09:53:35 -0500 Message-Id: <20170220145335.591-1-bobby.prani@gmail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c09::243 Subject: [Qemu-devel] [PATCH] mttcg: Set jmp_env to handle exit from tb_gen_code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP tb_gen_code() can exit execution using cpu_exit_loop() when it cannot allocate new tb's. To handle this, we need to properly set the jmp_env pointer ahead of calling tb_gen_code(). CC:Alex Bennée CC: Richard Henderson Signed-off-by: Pranith Kumar --- cpu-exec.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 97d79612d9..4b70988b24 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -236,23 +236,22 @@ static void cpu_exec_step(CPUState *cpu) cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); tb_lock(); - tb = tb_gen_code(cpu, pc, cs_base, flags, - 1 | CF_NOCACHE | CF_IGNORE_ICOUNT); - tb->orig_tb = NULL; - tb_unlock(); - - cc->cpu_exec_enter(cpu); - if (sigsetjmp(cpu->jmp_env, 0) == 0) { + tb = tb_gen_code(cpu, pc, cs_base, flags, + 1 | CF_NOCACHE | CF_IGNORE_ICOUNT); + tb->orig_tb = NULL; + tb_unlock(); + + cc->cpu_exec_enter(cpu); /* execute the generated code */ trace_exec_tb_nocache(tb, pc); cpu_tb_exec(cpu, tb); - } + cc->cpu_exec_exit(cpu); - cc->cpu_exec_exit(cpu); - tb_lock(); - tb_phys_invalidate(tb, -1); - tb_free(tb); + tb_lock(); + tb_phys_invalidate(tb, -1); + tb_free(tb); + } tb_unlock(); }