From patchwork Fri Apr 13 13:30:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 10340073 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 456FE60153 for ; Fri, 13 Apr 2018 13:32:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08D4828849 for ; Fri, 13 Apr 2018 13:32:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07952288AE; Fri, 13 Apr 2018 13:32:15 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 6A1A1288A9 for ; Fri, 13 Apr 2018 13:31:57 +0000 (UTC) Received: from localhost ([::1]:53850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6yo0-0005L6-KW for patchwork-qemu-devel@patchwork.kernel.org; Fri, 13 Apr 2018 09:31:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6ymv-0004gH-CL for qemu-devel@nongnu.org; Fri, 13 Apr 2018 09:30:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6yms-0005lb-9K for qemu-devel@nongnu.org; Fri, 13 Apr 2018 09:30:49 -0400 Received: from mail.ispras.ru ([83.149.199.45]:58818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6ymr-0005l4-W8 for qemu-devel@nongnu.org; Fri, 13 Apr 2018 09:30:46 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 87D96540081; Fri, 13 Apr 2018 16:30:44 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Fri, 13 Apr 2018 16:30:41 +0300 Message-ID: <20180413133041.29509.59064.stgit@pasha-VirtualBox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH v2] m68: fix exception stack frame for 68000 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: maria.klimushenkova@ispras.ru, dovgaluk@ispras.ru, laurent@vivier.eu, pavel.dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 68000 CPUs do not save format in the exception stack frame. This patch adds feature checking to prevent format saving for 68000. m68k_ret() already includes this modification, this patch fixes the exception processing function too. Signed-off-by: Pavel Dovgalyuk Reviewed-by: Laurent Vivier --- v2: - moved switch under the condition (suggested by Laurent Vivier) --- target/m68k/op_helper.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 3a7f7f2..8d09ed9 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -287,22 +287,25 @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp, uint16_t format, uint16_t sr, uint32_t addr, uint32_t retaddr) { - CPUState *cs = CPU(m68k_env_get_cpu(env)); - switch (format) { - case 4: - *sp -= 4; - cpu_stl_kernel(env, *sp, env->pc); - *sp -= 4; - cpu_stl_kernel(env, *sp, addr); - break; - case 3: - case 2: - *sp -= 4; - cpu_stl_kernel(env, *sp, addr); - break; + if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) { + /* all except 68000 */ + CPUState *cs = CPU(m68k_env_get_cpu(env)); + switch (format) { + case 4: + *sp -= 4; + cpu_stl_kernel(env, *sp, env->pc); + *sp -= 4; + cpu_stl_kernel(env, *sp, addr); + break; + case 3: + case 2: + *sp -= 4; + cpu_stl_kernel(env, *sp, addr); + break; + } + *sp -= 2; + cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2)); } - *sp -= 2; - cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2)); *sp -= 4; cpu_stl_kernel(env, *sp, retaddr); *sp -= 2;