From patchwork Tue Feb 9 17:43:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 8264431 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0213F9F3CD for ; Tue, 9 Feb 2016 17:47:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3AC77201B4 for ; Tue, 9 Feb 2016 17:47:07 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 63C4120154 for ; Tue, 9 Feb 2016 17:47:06 +0000 (UTC) Received: from localhost ([::1]:58852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTCNV-00029j-SX for patchwork-qemu-devel@patchwork.kernel.org; Tue, 09 Feb 2016 12:47:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTCLR-0007Qx-Kq for qemu-devel@nongnu.org; Tue, 09 Feb 2016 12:44:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTCLN-0000m7-He for qemu-devel@nongnu.org; Tue, 09 Feb 2016 12:44:57 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:33140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTCLN-0000lx-7d for qemu-devel@nongnu.org; Tue, 09 Feb 2016 12:44:53 -0500 Received: by mail-pf0-x244.google.com with SMTP id c10so9892274pfc.0 for ; Tue, 09 Feb 2016 09:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5ofgBtnpZo6yhonzCV6BvUxrN1wl1oRnDS3VisSbAwE=; b=j4d25YiAlOckNMR4Y/2dhUxkiEktMkGGA3dJFZRHv9GRc6sNwwTQZ9x93C1MruFu9k eRGi+yBMPXLlL+g9DSG12iiRovke7KX4yL9IAJmGW4VPNqTL7zOSEy0vmrQFHS4GN2hC 1KedB6DTUzr1kHOsBtD8ZeRNr225LAQZm5UvGwKdOXCdeJMIl6Gz8NKEkXszleSDhfUK DPSD7XsvRNtXANuGjArhhCNv1qfIdpTbIG9b5hgAY5pKjRQc+tN3zHz3qVYzozBZ6eIU MA4qNHB+3uXN6/J6Q5DGWRxHffjE1kO+b0x3TlFWZXjllBxSUWXxVcwnlxgU8v0TcXgd gcKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5ofgBtnpZo6yhonzCV6BvUxrN1wl1oRnDS3VisSbAwE=; b=iMq7lI0WKrT+qUiywkJKaPkGY5vAXjgkS8PwpZQ7lgkTqpPgNFb3Fyav1Vq64uLrR9 6tPCfiUCQefbnre8272KmYM3EJcCcqd1OIPLr3Do2f6tu8Np3/27YIlieMJ+ARPjm9OX 7JO7MUwdfD2zA+kHxvA8BuUkSVexVq7pe1p1HNZ1YbOPEFSgDcmKjX5AGnj1xX8q/Kyr bewzq2wNBiBWCmyGALAIwqvkWx1+g0vnPHpXDtWjsxIu/KxG7nK6or/epwHSQwW+sXom mnY9cHY1CaNdooqKvaUgWPUC4CjcRqYmNgB8ST8Cbc8HcJCIWLqfbm8XuJwF8gL8K4g5 Aulw== X-Gm-Message-State: AG10YORKGjDzKwP80AeaS5cDdwo9H5x/2JbIi6Co7GAp4BqzIWXT2i7MB3IHpjt7QVVlgg== X-Received: by 10.98.10.139 with SMTP id 11mr26091611pfk.87.1455039892584; Tue, 09 Feb 2016 09:44:52 -0800 (PST) Received: from bigtime.com (alanje.lnk.telstra.net. [120.151.179.201]) by smtp.gmail.com with ESMTPSA id pu3sm52144740pac.9.2016.02.09.09.44.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2016 09:44:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 10 Feb 2016 04:43:43 +1100 Message-Id: <1455039832-9133-8-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455039832-9133-1-git-send-email-rth@twiddle.net> References: <1455039832-9133-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::244 Cc: pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 07/16] target-i386: Perform set/reset_inhibit_irq inline X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With helpers that can be reused for other things. Signed-off-by: Richard Henderson --- target-i386/cc_helper.c | 10 ---------- target-i386/helper.h | 2 -- target-i386/translate.c | 37 ++++++++++++++++++++++++++++--------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/target-i386/cc_helper.c b/target-i386/cc_helper.c index 99a3b54..83af223 100644 --- a/target-i386/cc_helper.c +++ b/target-i386/cc_helper.c @@ -383,13 +383,3 @@ void helper_sti_vm(CPUX86State *env) } } #endif - -void helper_set_inhibit_irq(CPUX86State *env) -{ - env->hflags |= HF_INHIBIT_IRQ_MASK; -} - -void helper_reset_inhibit_irq(CPUX86State *env) -{ - env->hflags &= ~HF_INHIBIT_IRQ_MASK; -} diff --git a/target-i386/helper.h b/target-i386/helper.h index 9a83955..14a5041 100644 --- a/target-i386/helper.h +++ b/target-i386/helper.h @@ -62,8 +62,6 @@ DEF_HELPER_1(cli, void, env) DEF_HELPER_1(sti, void, env) DEF_HELPER_1(clac, void, env) DEF_HELPER_1(stac, void, env) -DEF_HELPER_1(set_inhibit_irq, void, env) -DEF_HELPER_1(reset_inhibit_irq, void, env) DEF_HELPER_3(boundw, void, env, tl, int) DEF_HELPER_3(boundl, void, env, tl, int) DEF_HELPER_1(rsm, void, env) diff --git a/target-i386/translate.c b/target-i386/translate.c index 77a82aa..3971541 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -2391,14 +2391,36 @@ static void gen_debug(DisasContext *s, target_ulong cur_eip) s->is_jmp = DISAS_TB_JUMP; } +static void gen_set_hflag(DisasContext *s, uint32_t mask) +{ + if ((s->flags & mask) == 0) { + TCGv_i32 t = tcg_temp_new_i32(); + tcg_gen_ld_i32(t, cpu_env, offsetof(CPUX86State, hflags)); + tcg_gen_ori_i32(t, t, mask); + tcg_gen_st_i32(t, cpu_env, offsetof(CPUX86State, hflags)); + tcg_temp_free_i32(t); + s->flags |= mask; + } +} + +static void gen_reset_hflag(DisasContext *s, uint32_t mask) +{ + if (s->flags & mask) { + TCGv_i32 t = tcg_temp_new_i32(); + tcg_gen_ld_i32(t, cpu_env, offsetof(CPUX86State, hflags)); + tcg_gen_andi_i32(t, t, ~mask); + tcg_gen_st_i32(t, cpu_env, offsetof(CPUX86State, hflags)); + tcg_temp_free_i32(t); + s->flags &= ~mask; + } +} + /* generate a generic end of block. Trace exception is also generated if needed */ static void gen_eob(DisasContext *s) { gen_update_cc_op(s); - if (s->tb->flags & HF_INHIBIT_IRQ_MASK) { - gen_helper_reset_inhibit_irq(cpu_env); - } + gen_reset_hflag(s, HF_INHIBIT_IRQ_MASK); if (s->tb->flags & HF_RF_MASK) { gen_helper_reset_rf(cpu_env); } @@ -5146,8 +5168,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, /* if reg == SS, inhibit interrupts/trace. */ /* If several instructions disable interrupts, only the _first_ does it */ - if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK)) - gen_helper_set_inhibit_irq(cpu_env); + gen_set_hflag(s, HF_INHIBIT_IRQ_MASK); s->tf = 0; } if (s->is_jmp) { @@ -5214,8 +5235,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, /* if reg == SS, inhibit interrupts/trace */ /* If several instructions disable interrupts, only the _first_ does it */ - if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK)) - gen_helper_set_inhibit_irq(cpu_env); + gen_set_hflag(s, HF_INHIBIT_IRQ_MASK); s->tf = 0; } if (s->is_jmp) { @@ -6751,8 +6771,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, /* interruptions are enabled only the first insn after sti */ /* If several instructions disable interrupts, only the _first_ does it */ - if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK)) - gen_helper_set_inhibit_irq(cpu_env); + gen_set_hflag(s, HF_INHIBIT_IRQ_MASK); /* give a chance to handle pending irqs */ gen_jmp_im(s->pc - s->cs_base); gen_eob(s);