From patchwork Mon Feb 15 11:23:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 582850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 11519140761 for ; Mon, 15 Feb 2016 22:31:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=uM5XX9o+; dkim-atps=neutral Received: from localhost ([::1]:59317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVHNV-0002bC-Uf for incoming@patchwork.ozlabs.org; Mon, 15 Feb 2016 06:31:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVHGS-0008SS-A9 for qemu-devel@nongnu.org; Mon, 15 Feb 2016 06:24:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVHGP-0002wc-1w for qemu-devel@nongnu.org; Mon, 15 Feb 2016 06:24:24 -0500 Received: from mail-qg0-x232.google.com ([2607:f8b0:400d:c04::232]:34175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVHGO-0002wW-Ss for qemu-devel@nongnu.org; Mon, 15 Feb 2016 06:24:20 -0500 Received: by mail-qg0-x232.google.com with SMTP id b67so108012997qgb.1 for ; Mon, 15 Feb 2016 03:24:20 -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=idUxwnMX/7kd+/wqTDFUpHTs7mQw+bfezVe8TzZS72g=; b=uM5XX9o+KuBIP5yr/QXGBOP2Z9hxYXEAW4JaEgYd75NL0WUw2D812P3MQe/IccRVNU KlKWTo2OUPDEHMZRV9GBWhB4XWbFOJ+6lYN5TtFzzPHsV0HIA6wrgj+KqwRS0MTfNLd5 O7bcQshKQCvd1oj/BnxsQ8loamABCpTE7fChKY7F0eAXyQ8DQlXOnE5mILjjOhjWstai XORL5W9+sZfvnmJQEVgZkj8/ih9pNcshMzScADbcG1lvFhqxP0ZfY6ygJ4Fjld35Xdbo bF4FG8ae1okS0aYVbmSiI8NguDcdyF9IgI4dH+rpObGjn1Jpw1fDVSXV+Ut8O0Rh79QF AgCQ== 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=idUxwnMX/7kd+/wqTDFUpHTs7mQw+bfezVe8TzZS72g=; b=khyE56BQGZCbKcbyCOGt/ZeD1xugy8WqghJnPDl+U04MQMlXViRYf4YOvlTtbWZJda 5fl8MZy0EFTyWz/vuIeVYhbOOF08B+sJtC/h/fV5uG4EFN8P1CljuCIh+8ElJgzM32JS Ojw87Nlr5rLE2FouR5eau2Msb/vfA3+91EnlcrhI4MBrCVxgVzcP978kiI1wWssguuIC bmIWDS9dbqFYpAKHM7Gs5V+s84QB5sAl4uI9cNTti7zlA7PZqy755s9NxEO9NqUzldq2 eqb97k2dOLx0s16vf8CwZGxelhXKu6TaPNSkvSasl//+WU+TqqgTGiP88vA7+VPLvavQ /Ydg== X-Gm-Message-State: AG10YOS89960m+njUCH9lOt2nKR4UFbbR5inf5t/jZSU8Lr0rUN3qhgiR+mOlJh905/scw== X-Received: by 10.140.105.195 with SMTP id c61mr19294198qgf.40.1455535460572; Mon, 15 Feb 2016 03:24:20 -0800 (PST) Received: from bigtime.com ([103.226.32.154]) by smtp.gmail.com with ESMTPSA id 191sm10824296qhq.17.2016.02.15.03.24.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Feb 2016 03:24:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 15 Feb 2016 22:23:19 +1100 Message-Id: <1455535408-26566-8-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455535408-26566-1-git-send-email-rth@twiddle.net> References: <1455535408-26566-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:400d:c04::232 Cc: peter.maydell@linaro.org, pbonzini@redhat.com Subject: [Qemu-devel] [PULL 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 dc87e58..cb25354 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); } @@ -5147,8 +5169,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) { @@ -5215,8 +5236,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) { @@ -6752,8 +6772,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);