From patchwork Mon Aug 22 23:33:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 599230 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp2041099mae; Mon, 22 Aug 2022 16:51:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR7atfAHUbRv6ivxHIjwf4o1NN3oerQ4vTDKg3t4LTQaYJsKDwEDIS2d6RG0eJgJwafwc6Vv X-Received: by 2002:a05:622a:309:b0:344:c3f0:3773 with SMTP id q9-20020a05622a030900b00344c3f03773mr4282687qtw.121.1661212313240; Mon, 22 Aug 2022 16:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661212313; cv=none; d=google.com; s=arc-20160816; b=zAkvW1VC+BMofdoOHzNve/9JYzLTCdhYrQ+wjWmHQkZSXNlIMxp3tlHjcwug0FWC9t lgNFVvCRM4KpZGziWmzr9+uO5IorM77E/GUSqwsJcC6mr49VrRcg8QWsPA1LyaZPCMJl ox9JJ0rdMqRGPocfpiKJIDAcz5G2//jQAtb/gISvxpJN+G3KO83fiLDiYPb1o6mXbyr1 dChTgrPUaf9PpdfhBGGzuNzc9A+b3AmZJD8i73VzijtIf5PSSMEDOSTcY8VKRa1H8//m atd7ZbCYiuQ6LMaLQWqfhuOmOaa5YOSksB3WE8i3WHyYRN86QoZO5N58jmkuz+qIOHyj J6BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9Pm+6x2/2C6OfnomcGaCxiJb7v+oW6I+7rzdNDZUItE=; b=kmPWOaaOKkmvRZY8zhjb/f+k+A71TiquZTyVmTcjT4iX8T8lOWnYg2dC6HGd8omt3n dFHq9CYfwBj4h/J6HUhxmDkNANRPWXvg1JgzXZYkbIC0dD0wv1UT+rDWoM6l4Vj8hIf4 zpG4wufDY58+kic3KAw0QdZgbUARKb7DCgAJhUMNm3jRjHhvtTbD9dOkXmx7lBsHJx88 K+7l4md8pwLCOt8O5CkDD8kvm9EIwNqdfvDPJH/8P+n4LmawKYLk3R4MMJiG1+Nbt0Kg SP9VXOhOwxKcLnTDdjn9OYn2/6FbOyYoONwl3sC9/EtYHIwzoxMDtEaJwhnw4WBqsHDr uL5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w2BRFLPO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u5-20020ad45aa5000000b0046e741042b3si5620140qvg.196.2022.08.22.16.51.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Aug 2022 16:51:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w2BRFLPO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQHCy-0004vV-NT for patch@linaro.org; Mon, 22 Aug 2022 19:51:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQGvC-0005sp-Rm for qemu-devel@nongnu.org; Mon, 22 Aug 2022 19:33:30 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:38588) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQGvA-0007FP-Uy for qemu-devel@nongnu.org; Mon, 22 Aug 2022 19:33:30 -0400 Received: by mail-pl1-x634.google.com with SMTP id x19so11307802plc.5 for ; Mon, 22 Aug 2022 16:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc; bh=9Pm+6x2/2C6OfnomcGaCxiJb7v+oW6I+7rzdNDZUItE=; b=w2BRFLPOroefQMuUaXVcH1clm3+Xls/6wnYrmj1h3z01ssAv+4CSxdWbWAWMO/yVVl JWm7vjXvFY9vdahVajF6wV2JufTLR/IlNOanbu60SrcS75xF75i8egU3Xw+3VvZ4ibJ5 FhNQ1bUfVk14J19hI/oujqdW8nTO+qk3YC+DV9tkb3jFS5IYwIZmYEcGkW2WNylkoZTW yaXIjAW+mgyvErf4PW8YHEhbFbmaEXC6K5+iQMkI1f0yg7NUvbqp1wlKicMF9HcfSYh7 STVjH8403Q/0ELGdB+W07q5nvuxyTQJfWKWhgAZ6jpqpbmoBpknFg3eFiVt5EU5+3zEf utDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=9Pm+6x2/2C6OfnomcGaCxiJb7v+oW6I+7rzdNDZUItE=; b=ABXB7Mx+T5rmHy2U2jxEOboin5Pemeor6AFV3v9c6x/089UGEBtxDDEt3ye3rd0Z9P QMNvROYmLcwAehd2zauWdyzoOG2Nkd9zxnAcTnry/zOMsvY7PVnSt9t6npVzjcarcqVq mdOG0LgY+NkVjb6Qwg2jwRX5jd6RRl4914vh1mIn25Gu4CHb+LZlcjzq+k9MJBBopd5p GXIMC4hWeI/73463gmyJ3KaV30ygLPepHdfbJAExVcXStiLxlJm06mo3M9oYHe0JKqZK HbExRYTkU2jbE6YoP9hcUhe3bUgw2WbJS+SfQQvySvXbvBHaHtJxlUGLoIrxGp5XIsh9 NGtA== X-Gm-Message-State: ACgBeo2kiS+KNFgQ4FTdU97g2gscULdV0+vJZy0ypJTqe385ZsOfw8YO XaEJa64q420OmJQcRboplcoP8XU4Ym8mLA== X-Received: by 2002:a17:902:f641:b0:172:9642:1bf1 with SMTP id m1-20020a170902f64100b0017296421bf1mr22463313plg.36.1661211206518; Mon, 22 Aug 2022 16:33:26 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:c3f1:b74f:5edd:63af]) by smtp.gmail.com with ESMTPSA id 82-20020a621555000000b0053655af14easm5133124pfv.45.2022.08.22.16.33.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 16:33:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 05/22] target/i386: Create gen_update_eip_next Date: Mon, 22 Aug 2022 16:33:01 -0700 Message-Id: <20220822233318.1728621-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822233318.1728621-1-richard.henderson@linaro.org> References: <20220822233318.1728621-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Sync EIP before exiting a translation block. Replace all gen_jmp_im that use s->pc. Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 45 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 78b7641786..36883410e0 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -521,6 +521,11 @@ static void gen_update_eip_cur(DisasContext *s) gen_jmp_im(s, s->base.pc_next - s->cs_base); } +static void gen_update_eip_next(DisasContext *s) +{ + gen_jmp_im(s, s->pc - s->cs_base); +} + /* Compute SEG:REG into A0. SEG is selected from the override segment (OVR_SEG) and the default segment (DEF_SEG). OVR_SEG may be -1 to indicate no override. */ @@ -5562,7 +5567,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_pop_update(s, ot); /* Note that reg == R_SS in gen_movl_seg_T0 always sets is_jmp. */ if (s->base.is_jmp) { - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); if (reg == R_SS) { s->flags &= ~HF_TF_MASK; gen_eob_inhibit_irq(s, true); @@ -5577,7 +5582,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_movl_seg_T0(s, (b >> 3) & 7); gen_pop_update(s, ot); if (s->base.is_jmp) { - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } break; @@ -5628,7 +5633,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_movl_seg_T0(s, reg); /* Note that reg == R_SS in gen_movl_seg_T0 always sets is_jmp. */ if (s->base.is_jmp) { - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); if (reg == R_SS) { s->flags &= ~HF_TF_MASK; gen_eob_inhibit_irq(s, true); @@ -5835,7 +5840,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) /* then put the data */ gen_op_mov_reg_v(s, ot, reg, s->T1); if (s->base.is_jmp) { - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } break; @@ -6891,7 +6896,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_pop_update(s, ot); set_cc_op(s, CC_OP_EFLAGS); /* abort translation because TF/AC flag may change */ - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } break; @@ -7227,7 +7232,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) if (check_iopl(s)) { gen_helper_sti(cpu_env); /* interruptions are enabled only the first insn after sti */ - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob_inhibit_irq(s, true); } break; @@ -7303,7 +7308,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } gen_set_label(l3); - gen_jmp_im(s, next_eip); + gen_update_eip_next(s); tcg_gen_br(l2); gen_set_label(l1); @@ -7321,7 +7326,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_helper_rdmsr(cpu_env); } else { gen_helper_wrmsr(cpu_env); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } } @@ -7521,7 +7526,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_helper_clac(cpu_env); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; @@ -7531,7 +7536,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) goto illegal_op; } gen_helper_stac(cpu_env); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; @@ -7576,7 +7581,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_trunc_tl_i32(s->tmp2_i32, cpu_regs[R_ECX]); gen_helper_xsetbv(cpu_env, s->tmp2_i32, s->tmp1_i64); /* End TB because translation flags may change. */ - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; @@ -7638,7 +7643,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } gen_update_cc_op(s); gen_helper_stgi(cpu_env); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; @@ -7677,7 +7682,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_ext32u_tl(s->A0, cpu_regs[R_EAX]); } gen_helper_flush_page(cpu_env, s->A0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; @@ -7761,7 +7766,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_andi_tl(s->T1, s->T1, ~0xe); tcg_gen_or_tl(s->T0, s->T0, s->T1); gen_helper_write_crN(cpu_env, tcg_constant_i32(0), s->T0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; @@ -7772,7 +7777,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_INVLPG); gen_lea_modrm(env, s, modrm); gen_helper_flush_page(cpu_env, s->A0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; @@ -8172,7 +8177,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0 + reg); gen_op_mov_v_reg(s, ot, s->T0, rm); gen_helper_write_crN(cpu_env, tcg_constant_i32(reg), s->T0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } else { gen_svm_check_intercept(s, SVM_EXIT_READ_CR0 + reg); @@ -8207,7 +8212,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_op_mov_v_reg(s, ot, s->T0, rm); tcg_gen_movi_i32(s->tmp2_i32, reg); gen_helper_set_dr(cpu_env, s->tmp2_i32, s->T0); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } else { gen_svm_check_intercept(s, SVM_EXIT_READ_DR0 + reg); @@ -8222,7 +8227,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0); gen_helper_clts(cpu_env); /* abort block because static cpu state changed */ - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); } break; @@ -8320,7 +8325,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) /* XRSTOR is how MPX is enabled, which changes how we translate. Thus we need to end the TB. */ gen_update_cc_op(s); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_eob(s); break; @@ -8454,7 +8459,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) g_assert_not_reached(); #else gen_update_cc_op(s); - gen_jmp_im(s, s->pc - s->cs_base); + gen_update_eip_next(s); gen_helper_rsm(cpu_env); #endif /* CONFIG_USER_ONLY */ gen_eob(s);