From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836148; cv=none; d=zohomail.com; s=zohoarc; b=BYoLgJsFQrrP+WohDj9QvLmaWDXadIrYab9VFznVb3mIH5MScrwZKgQ5udSuBhoTWXk5TZFtJpB4ExUzWGF9xXzB6nCNKeGJULEeF37T+PzJQ6sb7S/7uU4uzkZi54TJwiZus+K24LL63HcrOBEaT1wEIV1I6knYWFRayPzMVmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836148; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=FUECajQPWPjmtofPoacZp7afQ8fFlVYlsYwwwxPFylo=; b=HrGOWCqBzB0zewOu7IStdNNHQilGFdOaFBqHh47sGwrA8cpeElLZxALJ1c2oGv5rLOu2BtAxXBOXuEK8SsOD1J0HZhWqIljhEh/QfG4/fTYljfiSRQxfKhis/hzVLZUXyYvNEf8gzwIARa/ENXh0X+pVcxXEVXHdBJ/t2NpzTeI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836148376602.6953105113654; Sat, 8 Jun 2024 01:42:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrdl-0001Km-Em; Sat, 08 Jun 2024 04:41:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdk-0001KL-Cc for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdg-0001Mu-BH for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:32 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-65-Bd77afk0NzukvNyBiGYNMg-1; Sat, 08 Jun 2024 04:41:24 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a6e8aa42033so64101666b.1 for ; Sat, 08 Jun 2024 01:41:24 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80581870sm355982066b.25.2024.06.08.01.41.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FUECajQPWPjmtofPoacZp7afQ8fFlVYlsYwwwxPFylo=; b=MGQPsrcITrQgFrvc9Ib/a5QLD/B3SbpHSRkl5r5zT5pWbc8ditv3Q8gaLd6dduATHYR4cY ovwxCrGMg8Xl3bK3o8BAmi0fwN5oKtiuR+blvsC6zqM+o8cTYiyktzb0/RhRbXNbUW4f+n nraYgXEAna19ThymSs0qC+xpomVX7wM= X-MC-Unique: Bd77afk0NzukvNyBiGYNMg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836082; x=1718440882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FUECajQPWPjmtofPoacZp7afQ8fFlVYlsYwwwxPFylo=; b=HR2cmmKUglBHI7OxErAxA9vRf7cPg1IK2xIw7qgUQEKhW0Ng10cL+h2zVckzxegYAV kFhm2KS2HLbmlC70XjyjG1Ar9XJRX0SY6bZPbFb+S8vtJdeV8SV5ENWyb3dvha/7e1BD 80BbikzxQF6/if/T/uKyyniJwgatqIjs2z5sSGkKPLqkzcKPXMIv/U7+ATRMjJY5iiQV GJ+l4wyGmfv76McGYE+Li4+QeARXTGx1DW1lrTf3ha3vtMFZPtClzreRDNC8LBCeCciO hdqsebtUTu7cSN85GjCVDhGQn+rmUTPzt1V8LSVDhlnNoDXBwaSwLNJPnzcgNPwbVJRm wJVg== X-Gm-Message-State: AOJu0YzRMBCo4kDjTCupYuUNPY82heC8LWCo7WhwJ/U//IO8HzcRZC8W LBNDHI/YN2Ng80UD/c7Rje4BcIxIM32FD2gI/iDE/9ouMEJXNKPlbJJBAlj8yy/gz5Hj3nABBwg EuDeYMxZwVBBVMmIkIlOZotpkVgoZtd/tHe+dkr+rLBwql6bntjeQdn3p29bQ2cXHDh7zXjF7SK YGD1Ksm0VpDa0HoT8knVSmdkMfSa4Kd6zisjrE X-Received: by 2002:a17:906:3ad7:b0:a6e:feae:e1df with SMTP id a640c23a62f3a-a6efeaee390mr69237866b.21.1717836081459; Sat, 08 Jun 2024 01:41:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5U8goNXZW7okamGbHQzfli7AU7hwCmR1CeXmJNbT+GvQ5QTT0ZbSfxDMta3qvvpBbMgVIyg== X-Received: by 2002:a17:906:3ad7:b0:a6e:feae:e1df with SMTP id a640c23a62f3a-a6efeaee390mr69235666b.21.1717836080076; Sat, 08 Jun 2024 01:41:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 01/25] target/i386: remove CPUX86State argument from generator functions Date: Sat, 8 Jun 2024 10:40:49 +0200 Message-ID: <20240608084113.2770363-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836150194100005 Content-Type: text/plain; charset="utf-8" CPUX86State argument would only be used to fetch bytes, but that has to be done before the generator function is called. So remove it, and all temptation together with it. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.h | 2 +- target/i386/tcg/decode-new.c.inc | 4 +- target/i386/tcg/emit.c.inc | 572 +++++++++++++++---------------- 3 files changed, 289 insertions(+), 289 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index 1f90cf96407..f704698575f 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -245,7 +245,7 @@ typedef struct X86DecodedInsn X86DecodedInsn; typedef void (*X86DecodeFunc)(DisasContext *s, CPUX86State *env, X86OpEntr= y *entry, uint8_t *b); =20 /* Code generation function. */ -typedef void (*X86GenFunc)(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode); +typedef void (*X86GenFunc)(DisasContext *s, X86DecodedInsn *decode); =20 struct X86OpEntry { /* Based on the is_decode flags. */ diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index c2d8da8d14e..e7d88020481 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -2590,7 +2590,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) } if (s->prefix & PREFIX_LOCK) { gen_load(s, &decode, 2, s->T1); - decode.e.gen(s, env, &decode); + decode.e.gen(s, &decode); } else { if (decode.op[0].unit =3D=3D X86_OP_MMX) { compute_mmx_offset(&decode.op[0]); @@ -2599,7 +2599,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) } gen_load(s, &decode, 1, s->T0); gen_load(s, &decode, 2, s->T1); - decode.e.gen(s, env, &decode); + decode.e.gen(s, &decode); gen_writeback(s, &decode, 0, s->T0); } =20 diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 4be3d9a6fba..df7597c7e2f 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -60,8 +60,8 @@ typedef void (*SSEFunc_0_eppppii)(TCGv_ptr env, TCGv_ptr = reg_a, TCGv_ptr reg_b, TCGv_ptr reg_c, TCGv_ptr reg_d, TCGv_i32= even, TCGv_i32 odd); =20 -static void gen_JMP_m(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode); -static void gen_JMP(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode); +static void gen_JMP_m(DisasContext *s, X86DecodedInsn *decode); +static void gen_JMP(DisasContext *s, X86DecodedInsn *decode); =20 static inline TCGv_i32 tcg_constant8u_i32(uint8_t val) { @@ -446,7 +446,7 @@ static const SSEFunc_0_epp fns_3dnow[] =3D { [0xbf] =3D gen_helper_pavgusb, }; =20 -static void gen_3dnow(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_3dnow(DisasContext *s, X86DecodedInsn *decode) { uint8_t b =3D decode->immediate; SSEFunc_0_epp fn =3D b < ARRAY_SIZE(fns_3dnow) ? fns_3dnow[b] : NULL; @@ -479,7 +479,7 @@ static void gen_3dnow(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) * f3 =3D v*ss Vss, Hss, Wps * f2 =3D v*sd Vsd, Hsd, Wps */ -static inline void gen_unary_fp_sse(DisasContext *s, CPUX86State *env, X86= DecodedInsn *decode, +static inline void gen_unary_fp_sse(DisasContext *s, X86DecodedInsn *decod= e, SSEFunc_0_epp pd_xmm, SSEFunc_0_epp ps_xmm, SSEFunc_0_epp pd_ymm, SSEFunc_0_epp ps_ymm, SSEFunc_0_eppp sd, SSEFunc_0_eppp ss) @@ -504,9 +504,9 @@ static inline void gen_unary_fp_sse(DisasContext *s, CP= UX86State *env, X86Decode } } #define UNARY_FP_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_unary_fp_sse(s, env, decode, = \ + gen_unary_fp_sse(s, decode, = \ gen_helper_##lname##pd_xmm, = \ gen_helper_##lname##ps_xmm, = \ gen_helper_##lname##pd_ymm, = \ @@ -522,7 +522,7 @@ UNARY_FP_SSE(VSQRT, sqrt) * f3 =3D v*ss Vss, Hss, Wps * f2 =3D v*sd Vsd, Hsd, Wps */ -static inline void gen_fp_sse(DisasContext *s, CPUX86State *env, X86Decode= dInsn *decode, +static inline void gen_fp_sse(DisasContext *s, X86DecodedInsn *decode, SSEFunc_0_eppp pd_xmm, SSEFunc_0_eppp ps_xmm, SSEFunc_0_eppp pd_ymm, SSEFunc_0_eppp ps_ymm, SSEFunc_0_eppp sd, SSEFunc_0_eppp ss) @@ -543,9 +543,9 @@ static inline void gen_fp_sse(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn } =20 #define FP_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_fp_sse(s, env, decode, = \ + gen_fp_sse(s, decode, = \ gen_helper_##lname##pd_xmm, = \ gen_helper_##lname##ps_xmm, = \ gen_helper_##lname##pd_ymm, = \ @@ -561,7 +561,7 @@ FP_SSE(VDIV, div) FP_SSE(VMAX, max) =20 #define FMA_SSE_PACKED(uname, ptr0, ptr1, ptr2, even, odd) = \ -static void gen_##uname##Px(DisasContext *s, CPUX86State *env, X86DecodedI= nsn *decode) \ +static void gen_##uname##Px(DisasContext *s, X86DecodedInsn *decode) = \ { = \ SSEFunc_0_eppppii xmm =3D s->vex_w ? gen_helper_fma4pd_xmm : gen_helpe= r_fma4ps_xmm; \ SSEFunc_0_eppppii ymm =3D s->vex_w ? gen_helper_fma4pd_ymm : gen_helpe= r_fma4ps_ymm; \ @@ -574,7 +574,7 @@ static void gen_##uname##Px(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *d =20 #define FMA_SSE(uname, ptr0, ptr1, ptr2, flags) = \ FMA_SSE_PACKED(uname, ptr0, ptr1, ptr2, flags, flags) = \ -static void gen_##uname##Sx(DisasContext *s, CPUX86State *env, X86DecodedI= nsn *decode) \ +static void gen_##uname##Sx(DisasContext *s, X86DecodedInsn *decode) = \ { = \ SSEFunc_0_eppppi fn =3D s->vex_w ? gen_helper_fma4sd : gen_helper_fma4= ss; \ = \ @@ -607,10 +607,10 @@ FMA_SSE_PACKED(VFMSUBADD213, OP_PTR1, OP_PTR0, OP_PTR= 2, 0, float_muladd_negate_c FMA_SSE_PACKED(VFMSUBADD132, OP_PTR0, OP_PTR2, OP_PTR1, 0, float_muladd_ne= gate_c) =20 #define FP_UNPACK_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ /* PS maps to the DQ integer instruction, PD maps to QDQ. */ = \ - gen_fp_sse(s, env, decode, = \ + gen_fp_sse(s, decode, = \ gen_helper_##lname##qdq_xmm, = \ gen_helper_##lname##dq_xmm, = \ gen_helper_##lname##qdq_ymm, = \ @@ -624,7 +624,7 @@ FP_UNPACK_SSE(VUNPCKHPx, punpckh) * 00 =3D v*ps Vps, Wpd * f3 =3D v*ss Vss, Wps */ -static inline void gen_unary_fp32_sse(DisasContext *s, CPUX86State *env, X= 86DecodedInsn *decode, +static inline void gen_unary_fp32_sse(DisasContext *s, X86DecodedInsn *dec= ode, SSEFunc_0_epp ps_xmm, SSEFunc_0_epp ps_ymm, SSEFunc_0_eppp ss) @@ -649,9 +649,9 @@ illegal_op: gen_illegal_opcode(s); } #define UNARY_FP32_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_unary_fp32_sse(s, env, decode, = \ + gen_unary_fp32_sse(s, decode, = \ gen_helper_##lname##ps_xmm, = \ gen_helper_##lname##ps_ymm, = \ gen_helper_##lname##ss); = \ @@ -663,7 +663,7 @@ UNARY_FP32_SSE(VRCP, rcp) * 66 =3D v*pd Vpd, Hpd, Wpd * f2 =3D v*ps Vps, Hps, Wps */ -static inline void gen_horizontal_fp_sse(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode, +static inline void gen_horizontal_fp_sse(DisasContext *s, X86DecodedInsn *= decode, SSEFunc_0_eppp pd_xmm, SSEFunc_0_= eppp ps_xmm, SSEFunc_0_eppp pd_ymm, SSEFunc_0_= eppp ps_ymm) { @@ -674,9 +674,9 @@ static inline void gen_horizontal_fp_sse(DisasContext *= s, CPUX86State *env, X86D fn(tcg_env, OP_PTR0, OP_PTR1, OP_PTR2); } #define HORIZONTAL_FP_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_horizontal_fp_sse(s, env, decode, = \ + gen_horizontal_fp_sse(s, decode, = \ gen_helper_##lname##pd_xmm, gen_helper_##lname##= ps_xmm, \ gen_helper_##lname##pd_ymm, gen_helper_##lname##= ps_ymm); \ } @@ -684,7 +684,7 @@ HORIZONTAL_FP_SSE(VHADD, hadd) HORIZONTAL_FP_SSE(VHSUB, hsub) HORIZONTAL_FP_SSE(VADDSUB, addsub) =20 -static inline void gen_ternary_sse(DisasContext *s, CPUX86State *env, X86D= ecodedInsn *decode, +static inline void gen_ternary_sse(DisasContext *s, X86DecodedInsn *decode, int op3, SSEFunc_0_epppp xmm, SSEFunc_0= _epppp ymm) { SSEFunc_0_epppp fn =3D s->vex_l ? ymm : xmm; @@ -695,21 +695,21 @@ static inline void gen_ternary_sse(DisasContext *s, C= PUX86State *env, X86Decoded fn(tcg_env, OP_PTR0, OP_PTR1, OP_PTR2, ptr3); } #define TERNARY_SSE(uname, uvname, lname) = \ -static void gen_##uvname(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) \ +static void gen_##uvname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_ternary_sse(s, env, decode, (uint8_t)decode->immediate >> 4, = \ + gen_ternary_sse(s, decode, (uint8_t)decode->immediate >> 4, = \ gen_helper_##lname##_xmm, gen_helper_##lname##_ymm); = \ } = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_ternary_sse(s, env, decode, 0, = \ + gen_ternary_sse(s, decode, 0, = \ gen_helper_##lname##_xmm, gen_helper_##lname##_ymm); = \ } TERNARY_SSE(BLENDVPS, VBLENDVPS, blendvps) TERNARY_SSE(BLENDVPD, VBLENDVPD, blendvpd) TERNARY_SSE(PBLENDVB, VPBLENDVB, pblendvb) =20 -static inline void gen_binary_imm_sse(DisasContext *s, CPUX86State *env, X= 86DecodedInsn *decode, +static inline void gen_binary_imm_sse(DisasContext *s, X86DecodedInsn *dec= ode, SSEFunc_0_epppi xmm, SSEFunc_0_epppi= ymm) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); @@ -721,9 +721,9 @@ static inline void gen_binary_imm_sse(DisasContext *s, = CPUX86State *env, X86Deco } =20 #define BINARY_IMM_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_binary_imm_sse(s, env, decode, = \ + gen_binary_imm_sse(s, decode, = \ gen_helper_##lname##_xmm, = \ gen_helper_##lname##_ymm); = \ } @@ -739,7 +739,7 @@ BINARY_IMM_SSE(PCLMULQDQ, pclmulqdq) =20 =20 #define UNARY_INT_GVEC(uname, func, ...) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ int vec_len =3D vector_len(s, decode); = \ = \ @@ -757,7 +757,7 @@ UNARY_INT_GVEC(VPBROADCASTQ, tcg_gen_gvec_dup_mem, MO= _64) =20 =20 #define BINARY_INT_GVEC(uname, func, ...) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ int vec_len =3D vector_len(s, decode); = \ = \ @@ -816,7 +816,7 @@ BINARY_INT_GVEC(PXOR, tcg_gen_gvec_xor, MO_64) * These are really the same encoding, because 1) V is the same as P when = VEX.V * is not present 2) P and Q are the same as H and W apart from MM/XMM */ -static inline void gen_binary_int_sse(DisasContext *s, CPUX86State *env, X= 86DecodedInsn *decode, +static inline void gen_binary_int_sse(DisasContext *s, X86DecodedInsn *dec= ode, SSEFunc_0_eppp mmx, SSEFunc_0_eppp x= mm, SSEFunc_0_eppp ymm) { assert(!!mmx =3D=3D !!(decode->e.special =3D=3D X86_SPECIAL_MMX)); @@ -837,9 +837,9 @@ static inline void gen_binary_int_sse(DisasContext *s, = CPUX86State *env, X86Deco =20 =20 #define BINARY_INT_MMX(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_binary_int_sse(s, env, decode, = \ + gen_binary_int_sse(s, decode, = \ gen_helper_##lname##_mmx, = \ gen_helper_##lname##_xmm, = \ gen_helper_##lname##_ymm); = \ @@ -886,9 +886,9 @@ BINARY_INT_MMX(PMULHRSW, pmulhrsw) =20 /* Instructions with no MMX equivalent. */ #define BINARY_INT_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_binary_int_sse(s, env, decode, = \ + gen_binary_int_sse(s, decode, = \ NULL, = \ gen_helper_##lname##_xmm, = \ gen_helper_##lname##_ymm); = \ @@ -911,7 +911,7 @@ BINARY_INT_SSE(VAESENC, aesenc) BINARY_INT_SSE(VAESENCLAST, aesenclast) =20 #define UNARY_CMP_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ if (!s->vex_l) { = \ gen_helper_##lname##_xmm(tcg_env, OP_PTR1, OP_PTR2); = \ @@ -924,7 +924,7 @@ UNARY_CMP_SSE(VPTEST, ptest) UNARY_CMP_SSE(VTESTPS, vtestps) UNARY_CMP_SSE(VTESTPD, vtestpd) =20 -static inline void gen_unary_int_sse(DisasContext *s, CPUX86State *env, X8= 6DecodedInsn *decode, +static inline void gen_unary_int_sse(DisasContext *s, X86DecodedInsn *deco= de, SSEFunc_0_epp xmm, SSEFunc_0_epp ymm) { if (!s->vex_l) { @@ -935,9 +935,9 @@ static inline void gen_unary_int_sse(DisasContext *s, C= PUX86State *env, X86Decod } =20 #define UNARY_INT_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_unary_int_sse(s, env, decode, = \ + gen_unary_int_sse(s, decode, = \ gen_helper_##lname##_xmm, = \ gen_helper_##lname##_ymm); = \ } @@ -969,7 +969,7 @@ UNARY_INT_SSE(VCVTTPS2DQ, cvttps2dq) UNARY_INT_SSE(VCVTPH2PS, cvtph2ps) =20 =20 -static inline void gen_unary_imm_sse(DisasContext *s, CPUX86State *env, X8= 6DecodedInsn *decode, +static inline void gen_unary_imm_sse(DisasContext *s, X86DecodedInsn *deco= de, SSEFunc_0_ppi xmm, SSEFunc_0_ppi ymm) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); @@ -981,9 +981,9 @@ static inline void gen_unary_imm_sse(DisasContext *s, C= PUX86State *env, X86Decod } =20 #define UNARY_IMM_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_unary_imm_sse(s, env, decode, = \ + gen_unary_imm_sse(s, decode, = \ gen_helper_##lname##_xmm, = \ gen_helper_##lname##_ymm); = \ } @@ -996,7 +996,7 @@ UNARY_IMM_SSE(VPERMQ, vpermq) UNARY_IMM_SSE(VPERMILPS_i, vpermilps_imm) UNARY_IMM_SSE(VPERMILPD_i, vpermilpd_imm) =20 -static inline void gen_unary_imm_fp_sse(DisasContext *s, CPUX86State *env,= X86DecodedInsn *decode, +static inline void gen_unary_imm_fp_sse(DisasContext *s, X86DecodedInsn *d= ecode, SSEFunc_0_eppi xmm, SSEFunc_0_eppi= ymm) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); @@ -1008,9 +1008,9 @@ static inline void gen_unary_imm_fp_sse(DisasContext = *s, CPUX86State *env, X86De } =20 #define UNARY_IMM_FP_SSE(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_unary_imm_fp_sse(s, env, decode, = \ + gen_unary_imm_fp_sse(s, decode, = \ gen_helper_##lname##_xmm, = \ gen_helper_##lname##_ymm); = \ } @@ -1018,7 +1018,7 @@ static void gen_##uname(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod UNARY_IMM_FP_SSE(VROUNDPS, roundps) UNARY_IMM_FP_SSE(VROUNDPD, roundpd) =20 -static inline void gen_vexw_avx(DisasContext *s, CPUX86State *env, X86Deco= dedInsn *decode, +static inline void gen_vexw_avx(DisasContext *s, X86DecodedInsn *decode, SSEFunc_0_eppp d_xmm, SSEFunc_0_eppp q_xmm, SSEFunc_0_eppp d_ymm, SSEFunc_0_eppp q_ymm) { @@ -1030,9 +1030,9 @@ static inline void gen_vexw_avx(DisasContext *s, CPUX= 86State *env, X86DecodedIns =20 /* VEX.W affects whether to operate on 32- or 64-bit elements. */ #define VEXW_AVX(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_vexw_avx(s, env, decode, = \ + gen_vexw_avx(s, decode, = \ gen_helper_##lname##d_xmm, gen_helper_##lname##q_xmm, = \ gen_helper_##lname##d_ymm, gen_helper_##lname##q_ymm); = \ } @@ -1042,7 +1042,7 @@ VEXW_AVX(VPSRAV, vpsrav) VEXW_AVX(VPMASKMOV, vpmaskmov) =20 /* Same as above, but with extra arguments to the helper. */ -static inline void gen_vsib_avx(DisasContext *s, CPUX86State *env, X86Deco= dedInsn *decode, +static inline void gen_vsib_avx(DisasContext *s, X86DecodedInsn *decode, SSEFunc_0_epppti d_xmm, SSEFunc_0_epppti q= _xmm, SSEFunc_0_epppti d_ymm, SSEFunc_0_epppti q= _ymm) { @@ -1066,29 +1066,29 @@ static inline void gen_vsib_avx(DisasContext *s, CP= UX86State *env, X86DecodedIns } } #define VSIB_AVX(uname, lname) = \ -static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) \ +static void gen_##uname(DisasContext *s, X86DecodedInsn *decode) = \ { = \ - gen_vsib_avx(s, env, decode, = \ + gen_vsib_avx(s, decode, = \ gen_helper_##lname##d_xmm, gen_helper_##lname##q_xmm, = \ gen_helper_##lname##d_ymm, gen_helper_##lname##q_ymm); = \ } VSIB_AVX(VPGATHERD, vpgatherd) VSIB_AVX(VPGATHERQ, vpgatherq) =20 -static void gen_AAA(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_AAA(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); gen_helper_aaa(tcg_env); assume_cc_op(s, CC_OP_EFLAGS); } =20 -static void gen_AAD(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_AAD(DisasContext *s, X86DecodedInsn *decode) { gen_helper_aad(s->T0, s->T0, s->T1); prepare_update1_cc(decode, s, CC_OP_LOGICB); } =20 -static void gen_AAM(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_AAM(DisasContext *s, X86DecodedInsn *decode) { if (decode->immediate =3D=3D 0) { gen_exception(s, EXCP00_DIVZ); @@ -1098,14 +1098,14 @@ static void gen_AAM(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) } } =20 -static void gen_AAS(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_AAS(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); gen_helper_aas(tcg_env); assume_cc_op(s, CC_OP_EFLAGS); } =20 -static void gen_ADC(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_ADC(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; TCGv c_in =3D tcg_temp_new(); @@ -1123,7 +1123,7 @@ static void gen_ADC(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) } =20 /* ADCX/ADOX do not have memory operands and can use set_cc_op. */ -static void gen_ADCOX(DisasContext *s, CPUX86State *env, MemOp ot, int cc_= op) +static void gen_ADCOX(DisasContext *s, MemOp ot, int cc_op) { int opposite_cc_op; TCGv carry_in =3D NULL; @@ -1170,12 +1170,12 @@ static void gen_ADCOX(DisasContext *s, CPUX86State = *env, MemOp ot, int cc_op) } } =20 -static void gen_ADCX(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_ADCX(DisasContext *s, X86DecodedInsn *decode) { - gen_ADCOX(s, env, decode->op[0].ot, CC_OP_ADCX); + gen_ADCOX(s, decode->op[0].ot, CC_OP_ADCX); } =20 -static void gen_ADD(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_ADD(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; =20 @@ -1188,12 +1188,12 @@ static void gen_ADD(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) prepare_update2_cc(decode, s, CC_OP_ADDB + ot); } =20 -static void gen_ADOX(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_ADOX(DisasContext *s, X86DecodedInsn *decode) { - gen_ADCOX(s, env, decode->op[0].ot, CC_OP_ADOX); + gen_ADCOX(s, decode->op[0].ot, CC_OP_ADOX); } =20 -static void gen_AND(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_AND(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; =20 @@ -1206,7 +1206,7 @@ static void gen_AND(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) prepare_update1_cc(decode, s, CC_OP_LOGICB + ot); } =20 -static void gen_ANDN(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_ANDN(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 @@ -1214,7 +1214,7 @@ static void gen_ANDN(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) prepare_update1_cc(decode, s, CC_OP_LOGICB + ot); } =20 -static void gen_ARPL(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_ARPL(DisasContext *s, X86DecodedInsn *decode) { TCGv zf =3D tcg_temp_new(); TCGv flags =3D tcg_temp_new(); @@ -1235,7 +1235,7 @@ static void gen_ARPL(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) decode->cc_op =3D CC_OP_EFLAGS; } =20 -static void gen_BEXTR(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_BEXTR(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; TCGv bound =3D tcg_constant_tl(ot =3D=3D MO_64 ? 63 : 31); @@ -1264,7 +1264,7 @@ static void gen_BEXTR(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) } =20 /* BLSI do not have memory operands and can use set_cc_op. */ -static void gen_BLSI(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_BLSI(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 @@ -1276,7 +1276,7 @@ static void gen_BLSI(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } =20 /* BLSMSK do not have memory operands and can use set_cc_op. */ -static void gen_BLSMSK(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_BLSMSK(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 @@ -1288,7 +1288,7 @@ static void gen_BLSMSK(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode } =20 /* BLSR do not have memory operands and can use set_cc_op. */ -static void gen_BLSR(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_BLSR(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 @@ -1299,7 +1299,7 @@ static void gen_BLSR(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) set_cc_op(s, CC_OP_BMILGB + ot); } =20 -static void gen_BOUND(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_BOUND(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 op =3D tcg_temp_new_i32(); tcg_gen_trunc_tl_i32(op, s->T0); @@ -1310,7 +1310,7 @@ static void gen_BOUND(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) } } =20 -static void gen_BSWAP(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_BSWAP(DisasContext *s, X86DecodedInsn *decode) { #ifdef TARGET_X86_64 if (s->dflag =3D=3D MO_64) { @@ -1321,7 +1321,7 @@ static void gen_BSWAP(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) tcg_gen_bswap32_tl(s->T0, s->T0, TCG_BSWAP_OZ); } =20 -static void gen_BZHI(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_BZHI(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; TCGv bound =3D tcg_constant_tl(ot =3D=3D MO_64 ? 63 : 31); @@ -1341,24 +1341,24 @@ static void gen_BZHI(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) prepare_update2_cc(decode, s, CC_OP_BMILGB + ot); } =20 -static void gen_CALL(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_CALL(DisasContext *s, X86DecodedInsn *decode) { gen_push_v(s, eip_next_tl(s)); - gen_JMP(s, env, decode); + gen_JMP(s, decode); } =20 -static void gen_CALL_m(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_CALL_m(DisasContext *s, X86DecodedInsn *decode) { gen_push_v(s, eip_next_tl(s)); - gen_JMP_m(s, env, decode); + gen_JMP_m(s, decode); } =20 -static void gen_CALLF(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_CALLF(DisasContext *s, X86DecodedInsn *decode) { gen_far_call(s); } =20 -static void gen_CALLF_m(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_CALLF_m(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; =20 @@ -1368,41 +1368,41 @@ static void gen_CALLF_m(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *decod gen_far_call(s); } =20 -static void gen_CBW(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_CBW(DisasContext *s, X86DecodedInsn *decode) { MemOp src_ot =3D decode->op[0].ot - 1; =20 tcg_gen_ext_tl(s->T0, s->T0, src_ot | MO_SIGN); } =20 -static void gen_CLC(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_CLC(DisasContext *s, X86DecodedInsn *decode) { gen_compute_eflags(s); tcg_gen_andi_tl(cpu_cc_src, cpu_cc_src, ~CC_C); } =20 -static void gen_CLD(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_CLD(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_st_i32(tcg_constant_i32(1), tcg_env, offsetof(CPUX86State, df)= ); } =20 -static void gen_CLI(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_CLI(DisasContext *s, X86DecodedInsn *decode) { gen_reset_eflags(s, IF_MASK); } =20 -static void gen_CMC(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_CMC(DisasContext *s, X86DecodedInsn *decode) { gen_compute_eflags(s); tcg_gen_xori_tl(cpu_cc_src, cpu_cc_src, CC_C); } =20 -static void gen_CMOVcc(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_CMOVcc(DisasContext *s, X86DecodedInsn *decode) { gen_cmovcc1(s, decode->b & 0xf, s->T0, s->T1); } =20 -static void gen_CMPccXADD(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_CMPccXADD(DisasContext *s, X86DecodedInsn *decode) { TCGLabel *label_top =3D gen_new_label(); TCGLabel *label_bottom =3D gen_new_label(); @@ -1505,7 +1505,7 @@ static void gen_CMPccXADD(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *dec decode->cc_op =3D CC_OP_SUBB + ot; } =20 -static void gen_CMPS(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_CMPS(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) { @@ -1515,7 +1515,7 @@ static void gen_CMPS(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_CRC32(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_CRC32(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; =20 @@ -1523,7 +1523,7 @@ static void gen_CRC32(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) gen_helper_crc32(s->T0, s->tmp2_i32, s->T1, tcg_constant_i32(8 << ot)); } =20 -static void gen_CVTPI2Px(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_CVTPI2Px(DisasContext *s, X86DecodedInsn *decode) { gen_helper_enter_mmx(tcg_env); if (s->prefix & PREFIX_DATA) { @@ -1533,7 +1533,7 @@ static void gen_CVTPI2Px(DisasContext *s, CPUX86State= *env, X86DecodedInsn *deco } } =20 -static void gen_CVTPx2PI(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_CVTPx2PI(DisasContext *s, X86DecodedInsn *decode) { gen_helper_enter_mmx(tcg_env); if (s->prefix & PREFIX_DATA) { @@ -1543,7 +1543,7 @@ static void gen_CVTPx2PI(DisasContext *s, CPUX86State= *env, X86DecodedInsn *deco } } =20 -static void gen_CVTTPx2PI(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_CVTTPx2PI(DisasContext *s, X86DecodedInsn *decode) { gen_helper_enter_mmx(tcg_env); if (s->prefix & PREFIX_DATA) { @@ -1553,28 +1553,28 @@ static void gen_CVTTPx2PI(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *dec } } =20 -static void gen_CWD(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_CWD(DisasContext *s, X86DecodedInsn *decode) { int shift =3D 8 << decode->op[0].ot; =20 tcg_gen_sextract_tl(s->T0, s->T0, shift - 1, 1); } =20 -static void gen_DAA(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_DAA(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); gen_helper_daa(tcg_env); assume_cc_op(s, CC_OP_EFLAGS); } =20 -static void gen_DAS(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_DAS(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); gen_helper_das(tcg_env); assume_cc_op(s, CC_OP_EFLAGS); } =20 -static void gen_DEC(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_DEC(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; =20 @@ -1588,7 +1588,7 @@ static void gen_DEC(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) prepare_update_cc_incdec(decode, s, CC_OP_DECB + ot); } =20 -static void gen_DIV(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_DIV(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; =20 @@ -1611,17 +1611,17 @@ static void gen_DIV(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) } } =20 -static void gen_EMMS(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_EMMS(DisasContext *s, X86DecodedInsn *decode) { gen_helper_emms(tcg_env); } =20 -static void gen_ENTER(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_ENTER(DisasContext *s, X86DecodedInsn *decode) { gen_enter(s, decode->op[1].imm, decode->op[2].imm); } =20 -static void gen_EXTRQ_i(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_EXTRQ_i(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 length =3D tcg_constant_i32(decode->immediate & 63); TCGv_i32 index =3D tcg_constant_i32((decode->immediate >> 8) & 63); @@ -1629,12 +1629,12 @@ static void gen_EXTRQ_i(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *decod gen_helper_extrq_i(tcg_env, OP_PTR0, index, length); } =20 -static void gen_EXTRQ_r(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_EXTRQ_r(DisasContext *s, X86DecodedInsn *decode) { gen_helper_extrq_r(tcg_env, OP_PTR0, OP_PTR2); } =20 -static void gen_HLT(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_HLT(DisasContext *s, X86DecodedInsn *decode) { #ifdef CONFIG_SYSTEM_ONLY gen_update_cc_op(s); @@ -1644,7 +1644,7 @@ static void gen_HLT(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) #endif } =20 -static void gen_IDIV(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_IDIV(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; =20 @@ -1667,7 +1667,7 @@ static void gen_IDIV(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_IMUL3(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_IMUL3(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; TCGv cc_src_rhs; @@ -1730,7 +1730,7 @@ static void gen_IMUL3(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) prepare_update2_cc(decode, s, CC_OP_MULB + ot); } =20 -static void gen_IMUL(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_IMUL(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; TCGv cc_src_rhs; @@ -1788,7 +1788,7 @@ static void gen_IMUL(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) prepare_update2_cc(decode, s, CC_OP_MULB + ot); } =20 -static void gen_IN(DisasContext *s, CPUX86State *env, X86DecodedInsn *deco= de) +static void gen_IN(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; TCGv_i32 port =3D tcg_temp_new_i32(); @@ -1804,7 +1804,7 @@ static void gen_IN(DisasContext *s, CPUX86State *env,= X86DecodedInsn *decode) gen_bpt_io(s, port, ot); } =20 -static void gen_INC(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_INC(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; =20 @@ -1818,7 +1818,7 @@ static void gen_INC(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) prepare_update_cc_incdec(decode, s, CC_OP_INCB + ot); } =20 -static void gen_INS(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_INS(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; TCGv_i32 port =3D tcg_temp_new_i32(); @@ -1838,7 +1838,7 @@ static void gen_INS(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) } } =20 -static void gen_INSERTQ_i(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_INSERTQ_i(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 length =3D tcg_constant_i32(decode->immediate & 63); TCGv_i32 index =3D tcg_constant_i32((decode->immediate >> 8) & 63); @@ -1846,17 +1846,17 @@ static void gen_INSERTQ_i(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *dec gen_helper_insertq_i(tcg_env, OP_PTR0, OP_PTR1, index, length); } =20 -static void gen_INSERTQ_r(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_INSERTQ_r(DisasContext *s, X86DecodedInsn *decode) { gen_helper_insertq_r(tcg_env, OP_PTR0, OP_PTR2); } =20 -static void gen_INT(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_INT(DisasContext *s, X86DecodedInsn *decode) { gen_interrupt(s, decode->immediate); } =20 -static void gen_INT1(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_INT1(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); gen_update_eip_next(s); @@ -1864,19 +1864,19 @@ static void gen_INT1(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) s->base.is_jmp =3D DISAS_NORETURN; } =20 -static void gen_INT3(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_INT3(DisasContext *s, X86DecodedInsn *decode) { gen_interrupt(s, EXCP03_INT3); } =20 -static void gen_INTO(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_INTO(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); gen_update_eip_cur(s); gen_helper_into(tcg_env, cur_insn_len_i32(s)); } =20 -static void gen_IRET(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_IRET(DisasContext *s, X86DecodedInsn *decode) { if (!PE(s) || VM86(s)) { gen_helper_iret_real(tcg_env, tcg_constant_i32(s->dflag - 1)); @@ -1888,13 +1888,13 @@ static void gen_IRET(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) s->base.is_jmp =3D DISAS_EOB_ONLY; } =20 -static void gen_Jcc(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_Jcc(DisasContext *s, X86DecodedInsn *decode) { gen_bnd_jmp(s); gen_jcc(s, decode->b & 0xf, decode->immediate); } =20 -static void gen_JCXZ(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_JCXZ(DisasContext *s, X86DecodedInsn *decode) { TCGLabel *taken =3D gen_new_label(); =20 @@ -1903,25 +1903,25 @@ static void gen_JCXZ(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) gen_conditional_jump_labels(s, decode->immediate, NULL, taken); } =20 -static void gen_JMP(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_JMP(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); gen_jmp_rel(s, s->dflag, decode->immediate, 0); } =20 -static void gen_JMP_m(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_JMP_m(DisasContext *s, X86DecodedInsn *decode) { gen_op_jmp_v(s, s->T0); gen_bnd_jmp(s); s->base.is_jmp =3D DISAS_JUMP; } =20 -static void gen_JMPF(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_JMPF(DisasContext *s, X86DecodedInsn *decode) { gen_far_jmp(s); } =20 -static void gen_JMPF_m(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_JMPF_m(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; =20 @@ -1931,7 +1931,7 @@ static void gen_JMPF_m(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode gen_far_jmp(s); } =20 -static void gen_LAHF(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_LAHF(DisasContext *s, X86DecodedInsn *decode) { if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM)) { return gen_illegal_opcode(s); @@ -1942,13 +1942,13 @@ static void gen_LAHF(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) tcg_gen_deposit_tl(cpu_regs[R_EAX], cpu_regs[R_EAX], s->T0, 8, 8); } =20 -static void gen_LDMXCSR(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_LDMXCSR(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T1); gen_helper_ldmxcsr(tcg_env, s->tmp2_i32); } =20 -static void gen_lxx_seg(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode, int seg) +static void gen_lxx_seg(DisasContext *s, X86DecodedInsn *decode, int seg) { MemOp ot =3D decode->op[0].ot; =20 @@ -1960,37 +1960,37 @@ static void gen_lxx_seg(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *decod gen_movl_seg(s, seg, s->T1); } =20 -static void gen_LDS(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_LDS(DisasContext *s, X86DecodedInsn *decode) { - gen_lxx_seg(s, env, decode, R_DS); + gen_lxx_seg(s, decode, R_DS); } =20 -static void gen_LEA(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_LEA(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_mov_tl(s->T0, s->A0); } =20 -static void gen_LEAVE(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_LEAVE(DisasContext *s, X86DecodedInsn *decode) { gen_leave(s); } =20 -static void gen_LES(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_LES(DisasContext *s, X86DecodedInsn *decode) { - gen_lxx_seg(s, env, decode, R_ES); + gen_lxx_seg(s, decode, R_ES); } =20 -static void gen_LFS(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_LFS(DisasContext *s, X86DecodedInsn *decode) { - gen_lxx_seg(s, env, decode, R_FS); + gen_lxx_seg(s, decode, R_FS); } =20 -static void gen_LGS(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_LGS(DisasContext *s, X86DecodedInsn *decode) { - gen_lxx_seg(s, env, decode, R_GS); + gen_lxx_seg(s, decode, R_GS); } =20 -static void gen_LODS(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_LODS(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) { @@ -2000,7 +2000,7 @@ static void gen_LODS(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_LOOP(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_LOOP(DisasContext *s, X86DecodedInsn *decode) { TCGLabel *taken =3D gen_new_label(); =20 @@ -2010,7 +2010,7 @@ static void gen_LOOP(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) gen_conditional_jump_labels(s, decode->immediate, NULL, taken); } =20 -static void gen_LOOPE(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_LOOPE(DisasContext *s, X86DecodedInsn *decode) { TCGLabel *taken =3D gen_new_label(); TCGLabel *not_taken =3D gen_new_label(); @@ -2022,7 +2022,7 @@ static void gen_LOOPE(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) gen_conditional_jump_labels(s, decode->immediate, not_taken, taken); } =20 -static void gen_LOOPNE(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_LOOPNE(DisasContext *s, X86DecodedInsn *decode) { TCGLabel *taken =3D gen_new_label(); TCGLabel *not_taken =3D gen_new_label(); @@ -2034,18 +2034,18 @@ static void gen_LOOPNE(DisasContext *s, CPUX86State= *env, X86DecodedInsn *decode gen_conditional_jump_labels(s, decode->immediate, not_taken, taken); } =20 -static void gen_LSS(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_LSS(DisasContext *s, X86DecodedInsn *decode) { - gen_lxx_seg(s, env, decode, R_SS); + gen_lxx_seg(s, decode, R_SS); } =20 -static void gen_MOV(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_MOV(DisasContext *s, X86DecodedInsn *decode) { /* nothing to do! */ } #define gen_NOP gen_MOV =20 -static void gen_MASKMOV(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_MASKMOV(DisasContext *s, X86DecodedInsn *decode) { gen_lea_v_seg(s, cpu_regs[R_EDI], R_DS, s->override); =20 @@ -2056,7 +2056,7 @@ static void gen_MASKMOV(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod } } =20 -static void gen_MOVBE(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_MOVBE(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 @@ -2068,7 +2068,7 @@ static void gen_MOVBE(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) } } =20 -static void gen_MOVD_from(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_MOVD_from(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; =20 @@ -2086,7 +2086,7 @@ static void gen_MOVD_from(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *dec } } =20 -static void gen_MOVD_to(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_MOVD_to(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; int vec_len =3D vector_len(s, decode); @@ -2108,12 +2108,12 @@ static void gen_MOVD_to(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *decod } } =20 -static void gen_MOVDQ(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_MOVDQ(DisasContext *s, X86DecodedInsn *decode) { gen_store_sse(s, decode, decode->op[2].offset); } =20 -static void gen_MOVMSK(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_MOVMSK(DisasContext *s, X86DecodedInsn *decode) { typeof(gen_helper_movmskps_ymm) *ps, *pd, *fn; ps =3D s->vex_l ? gen_helper_movmskps_ymm : gen_helper_movmskps_xmm; @@ -2123,7 +2123,7 @@ static void gen_MOVMSK(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode tcg_gen_extu_i32_tl(s->T0, s->tmp2_i32); } =20 -static void gen_MOVQ(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_MOVQ(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); int lo_ofs =3D vector_elem_offset(&decode->op[0], MO_64, 0); @@ -2145,14 +2145,14 @@ static void gen_MOVQ(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) } } =20 -static void gen_MOVq_dq(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_MOVq_dq(DisasContext *s, X86DecodedInsn *decode) { gen_helper_enter_mmx(tcg_env); /* Otherwise the same as any other movq. */ - return gen_MOVQ(s, env, decode); + return gen_MOVQ(s, decode); } =20 -static void gen_MOVS(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_MOVS(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) { @@ -2162,7 +2162,7 @@ static void gen_MOVS(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_MUL(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_MUL(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; =20 @@ -2213,7 +2213,7 @@ static void gen_MUL(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) decode->cc_op =3D CC_OP_MULB + ot; } =20 -static void gen_MULX(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_MULX(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 @@ -2239,7 +2239,7 @@ static void gen_MULX(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_NEG(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_NEG(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; TCGv oldv =3D tcg_temp_new(); @@ -2266,7 +2266,7 @@ static void gen_NEG(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) decode->cc_op =3D CC_OP_SUBB + ot; } =20 -static void gen_NOT(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_NOT(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 @@ -2279,7 +2279,7 @@ static void gen_NOT(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) } } =20 -static void gen_OR(DisasContext *s, CPUX86State *env, X86DecodedInsn *deco= de) +static void gen_OR(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; =20 @@ -2292,7 +2292,7 @@ static void gen_OR(DisasContext *s, CPUX86State *env,= X86DecodedInsn *decode) prepare_update1_cc(decode, s, CC_OP_LOGICB + ot); } =20 -static void gen_OUT(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_OUT(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; TCGv_i32 port =3D tcg_temp_new_i32(); @@ -2309,7 +2309,7 @@ static void gen_OUT(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) gen_bpt_io(s, port, ot); } =20 -static void gen_OUTS(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_OUTS(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; TCGv_i32 port =3D tcg_temp_new_i32(); @@ -2328,7 +2328,7 @@ static void gen_OUTS(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_PALIGNR(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_PALIGNR(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); if (!(s->prefix & PREFIX_DATA)) { @@ -2340,7 +2340,7 @@ static void gen_PALIGNR(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod } } =20 -static void gen_PANDN(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_PANDN(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -2350,7 +2350,7 @@ static void gen_PANDN(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) decode->op[1].offset, vec_len, vec_len); } =20 -static void gen_PAUSE(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_PAUSE(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); gen_update_eip_next(s); @@ -2358,14 +2358,14 @@ static void gen_PAUSE(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decode) s->base.is_jmp =3D DISAS_NORETURN; } =20 -static void gen_PCMPESTRI(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_PCMPESTRI(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); gen_helper_pcmpestri_xmm(tcg_env, OP_PTR1, OP_PTR2, imm); assume_cc_op(s, CC_OP_EFLAGS); } =20 -static void gen_PCMPESTRM(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_PCMPESTRM(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); gen_helper_pcmpestrm_xmm(tcg_env, OP_PTR1, OP_PTR2, imm); @@ -2376,14 +2376,14 @@ static void gen_PCMPESTRM(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *dec } } =20 -static void gen_PCMPISTRI(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_PCMPISTRI(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); gen_helper_pcmpistri_xmm(tcg_env, OP_PTR1, OP_PTR2, imm); assume_cc_op(s, CC_OP_EFLAGS); } =20 -static void gen_PCMPISTRM(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_PCMPISTRM(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); gen_helper_pcmpistrm_xmm(tcg_env, OP_PTR1, OP_PTR2, imm); @@ -2394,17 +2394,17 @@ static void gen_PCMPISTRM(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *dec } } =20 -static void gen_PDEP(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_PDEP(DisasContext *s, X86DecodedInsn *decode) { gen_helper_pdep(s->T0, s->T0, s->T1); } =20 -static void gen_PEXT(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_PEXT(DisasContext *s, X86DecodedInsn *decode) { gen_helper_pext(s->T0, s->T0, s->T1); } =20 -static inline void gen_pextr(DisasContext *s, CPUX86State *env, X86Decoded= Insn *decode, MemOp ot) +static inline void gen_pextr(DisasContext *s, X86DecodedInsn *decode, MemO= p ot) { int vec_len =3D vector_len(s, decode); int mask =3D (vec_len >> ot) - 1; @@ -2430,23 +2430,23 @@ static inline void gen_pextr(DisasContext *s, CPUX8= 6State *env, X86DecodedInsn * } } =20 -static void gen_PEXTRB(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_PEXTRB(DisasContext *s, X86DecodedInsn *decode) { - gen_pextr(s, env, decode, MO_8); + gen_pextr(s, decode, MO_8); } =20 -static void gen_PEXTRW(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_PEXTRW(DisasContext *s, X86DecodedInsn *decode) { - gen_pextr(s, env, decode, MO_16); + gen_pextr(s, decode, MO_16); } =20 -static void gen_PEXTR(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_PEXTR(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; - gen_pextr(s, env, decode, ot); + gen_pextr(s, decode, ot); } =20 -static inline void gen_pinsr(DisasContext *s, CPUX86State *env, X86Decoded= Insn *decode, MemOp ot) +static inline void gen_pinsr(DisasContext *s, X86DecodedInsn *decode, MemO= p ot) { int vec_len =3D vector_len(s, decode); int mask =3D (vec_len >> ot) - 1; @@ -2477,19 +2477,19 @@ static inline void gen_pinsr(DisasContext *s, CPUX8= 6State *env, X86DecodedInsn * } } =20 -static void gen_PINSRB(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_PINSRB(DisasContext *s, X86DecodedInsn *decode) { - gen_pinsr(s, env, decode, MO_8); + gen_pinsr(s, decode, MO_8); } =20 -static void gen_PINSRW(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_PINSRW(DisasContext *s, X86DecodedInsn *decode) { - gen_pinsr(s, env, decode, MO_16); + gen_pinsr(s, decode, MO_16); } =20 -static void gen_PINSR(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_PINSR(DisasContext *s, X86DecodedInsn *decode) { - gen_pinsr(s, env, decode, decode->op[2].ot); + gen_pinsr(s, decode, decode->op[2].ot); } =20 static void gen_pmovmskb_i64(TCGv_i64 d, TCGv_i64 s) @@ -2529,7 +2529,7 @@ static void gen_pmovmskb_vec(unsigned vece, TCGv_vec = d, TCGv_vec s) tcg_gen_or_vec(vece, d, d, t); } =20 -static void gen_PMOVMSKB(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_PMOVMSKB(DisasContext *s, X86DecodedInsn *decode) { static const TCGOpcode vecop_list[] =3D { INDEX_op_shli_vec, 0 }; static const GVecGen2 g =3D { @@ -2573,7 +2573,7 @@ static void gen_PMOVMSKB(DisasContext *s, CPUX86State= *env, X86DecodedInsn *deco } } =20 -static void gen_POP(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_POP(DisasContext *s, X86DecodedInsn *decode) { X86DecodedOp *op =3D &decode->op[0]; MemOp ot =3D gen_pop_T0(s); @@ -2587,12 +2587,12 @@ static void gen_POP(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) gen_pop_update(s, ot); } =20 -static void gen_POPA(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_POPA(DisasContext *s, X86DecodedInsn *decode) { gen_popa(s); } =20 -static void gen_POPF(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_POPF(DisasContext *s, X86DecodedInsn *decode) { MemOp ot; int mask =3D TF_MASK | AC_MASK | ID_MASK | NT_MASK; @@ -2614,13 +2614,13 @@ static void gen_POPF(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) s->base.is_jmp =3D DISAS_EOB_NEXT; } =20 -static void gen_PSHUFW(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_PSHUFW(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); gen_helper_pshufw_mmx(OP_PTR0, OP_PTR1, imm); } =20 -static void gen_PSRLW_i(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_PSRLW_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -2633,7 +2633,7 @@ static void gen_PSRLW_i(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod } } =20 -static void gen_PSLLW_i(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_PSLLW_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -2646,7 +2646,7 @@ static void gen_PSLLW_i(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod } } =20 -static void gen_PSRAW_i(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_PSRAW_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -2658,7 +2658,7 @@ static void gen_PSRAW_i(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod decode->immediate, vec_len, vec_len); } =20 -static void gen_PSRLD_i(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_PSRLD_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -2671,7 +2671,7 @@ static void gen_PSRLD_i(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod } } =20 -static void gen_PSLLD_i(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_PSLLD_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -2684,7 +2684,7 @@ static void gen_PSLLD_i(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod } } =20 -static void gen_PSRAD_i(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_PSRAD_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -2696,7 +2696,7 @@ static void gen_PSRAD_i(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod decode->immediate, vec_len, vec_len); } =20 -static void gen_PSRLQ_i(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_PSRLQ_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -2709,7 +2709,7 @@ static void gen_PSRLQ_i(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod } } =20 -static void gen_PSLLQ_i(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_PSLLQ_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -2736,7 +2736,7 @@ static TCGv_ptr make_imm8u_xmm_vec(uint8_t imm, int v= ec_len) return ptr; } =20 -static void gen_PSRLDQ_i(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_PSRLDQ_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); TCGv_ptr imm_vec =3D make_imm8u_xmm_vec(decode->immediate, vec_len); @@ -2748,7 +2748,7 @@ static void gen_PSRLDQ_i(DisasContext *s, CPUX86State= *env, X86DecodedInsn *deco } } =20 -static void gen_PSLLDQ_i(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_PSLLDQ_i(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); TCGv_ptr imm_vec =3D make_imm8u_xmm_vec(decode->immediate, vec_len); @@ -2760,17 +2760,17 @@ static void gen_PSLLDQ_i(DisasContext *s, CPUX86Sta= te *env, X86DecodedInsn *deco } } =20 -static void gen_PUSH(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_PUSH(DisasContext *s, X86DecodedInsn *decode) { gen_push_v(s, s->T1); } =20 -static void gen_PUSHA(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_PUSHA(DisasContext *s, X86DecodedInsn *decode) { gen_pusha(s); } =20 -static void gen_PUSHF(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_PUSHF(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); gen_helper_read_eflags(s->T0, tcg_env); @@ -2967,7 +2967,7 @@ static void gen_rotc_mod(MemOp ot, TCGv count) * length - count, because (length-1) - (count-1) can be computed with * a XOR, and that is commutative unlike subtraction. */ -static void gen_RCL(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_RCL(DisasContext *s, X86DecodedInsn *decode) { bool have_1bit_cin, can_be_zero; TCGv count; @@ -3019,7 +3019,7 @@ static void gen_RCL(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) } } =20 -static void gen_RCR(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_RCR(DisasContext *s, X86DecodedInsn *decode) { bool have_1bit_cin, can_be_zero; TCGv count; @@ -3072,7 +3072,7 @@ static void gen_RCR(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) } } =20 -static void gen_RET(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_RET(DisasContext *s, X86DecodedInsn *decode) { int16_t adjust =3D decode->e.op2 =3D=3D X86_TYPE_I ? decode->immediate= : 0; =20 @@ -3083,7 +3083,7 @@ static void gen_RET(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) s->base.is_jmp =3D DISAS_JUMP; } =20 -static void gen_RETF(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_RETF(DisasContext *s, X86DecodedInsn *decode) { int16_t adjust =3D decode->e.op2 =3D=3D X86_TYPE_I ? decode->immediate= : 0; =20 @@ -3154,7 +3154,7 @@ static void gen_rot_carry(X86DecodedInsn *decode, TCG= v result, } } =20 -static void gen_ROL(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_ROL(DisasContext *s, X86DecodedInsn *decode) { bool can_be_zero; TCGv count; @@ -3182,7 +3182,7 @@ static void gen_ROL(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) gen_rot_overflow(decode, s->T0, old, can_be_zero, count); } =20 -static void gen_ROR(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_ROR(DisasContext *s, X86DecodedInsn *decode) { bool can_be_zero; TCGv count; @@ -3211,7 +3211,7 @@ static void gen_ROR(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) gen_rot_overflow(decode, s->T0, old, can_be_zero, count); } =20 -static void gen_RORX(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_RORX(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; int mask =3D ot =3D=3D MO_64 ? 63 : 31; @@ -3235,7 +3235,7 @@ static void gen_RORX(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_SAHF(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_SAHF(DisasContext *s, X86DecodedInsn *decode) { if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM)) { return gen_illegal_opcode(s); @@ -3247,7 +3247,7 @@ static void gen_SAHF(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, s->T0); } =20 -static void gen_SALC(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_SALC(DisasContext *s, X86DecodedInsn *decode) { gen_compute_eflags_c(s, s->T0); tcg_gen_neg_tl(s->T0, s->T0); @@ -3283,7 +3283,7 @@ static void gen_shift_dynamic_flags(DisasContext *s, = X86DecodedInsn *decode, TCG old_cc_op, tcg_constant_i32(cc_op)); } =20 -static void gen_SAR(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_SAR(DisasContext *s, X86DecodedInsn *decode) { bool can_be_zero; TCGv count; @@ -3305,7 +3305,7 @@ static void gen_SAR(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) } } =20 -static void gen_SARX(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_SARX(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; int mask; @@ -3315,7 +3315,7 @@ static void gen_SARX(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) tcg_gen_sar_tl(s->T0, s->T0, s->T1); } =20 -static void gen_SBB(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_SBB(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; TCGv c_in =3D tcg_temp_new(); @@ -3337,7 +3337,7 @@ static void gen_SBB(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) prepare_update3_cc(decode, s, CC_OP_SBBB + ot, c_in); } =20 -static void gen_SCAS(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_SCAS(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) { @@ -3347,27 +3347,27 @@ static void gen_SCAS(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) } } =20 -static void gen_SETcc(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_SETcc(DisasContext *s, X86DecodedInsn *decode) { gen_setcc1(s, decode->b & 0xf, s->T0); } =20 -static void gen_SHA1NEXTE(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_SHA1NEXTE(DisasContext *s, X86DecodedInsn *decode) { gen_helper_sha1nexte(OP_PTR0, OP_PTR1, OP_PTR2); } =20 -static void gen_SHA1MSG1(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_SHA1MSG1(DisasContext *s, X86DecodedInsn *decode) { gen_helper_sha1msg1(OP_PTR0, OP_PTR1, OP_PTR2); } =20 -static void gen_SHA1MSG2(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_SHA1MSG2(DisasContext *s, X86DecodedInsn *decode) { gen_helper_sha1msg2(OP_PTR0, OP_PTR1, OP_PTR2); } =20 -static void gen_SHA1RNDS4(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_SHA1RNDS4(DisasContext *s, X86DecodedInsn *decode) { switch(decode->immediate & 3) { case 0: @@ -3385,17 +3385,17 @@ static void gen_SHA1RNDS4(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *dec } } =20 -static void gen_SHA256MSG1(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_SHA256MSG1(DisasContext *s, X86DecodedInsn *decode) { gen_helper_sha256msg1(OP_PTR0, OP_PTR1, OP_PTR2); } =20 -static void gen_SHA256MSG2(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_SHA256MSG2(DisasContext *s, X86DecodedInsn *decode) { gen_helper_sha256msg2(OP_PTR0, OP_PTR1, OP_PTR2); } =20 -static void gen_SHA256RNDS2(DisasContext *s, CPUX86State *env, X86DecodedI= nsn *decode) +static void gen_SHA256RNDS2(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 wk0 =3D tcg_temp_new_i32(); TCGv_i32 wk1 =3D tcg_temp_new_i32(); @@ -3406,7 +3406,7 @@ static void gen_SHA256RNDS2(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *d gen_helper_sha256rnds2(OP_PTR0, OP_PTR1, OP_PTR2, wk0, wk1); } =20 -static void gen_SHL(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_SHL(DisasContext *s, X86DecodedInsn *decode) { bool can_be_zero; TCGv count; @@ -3428,7 +3428,7 @@ static void gen_SHL(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) } } =20 -static void gen_SHLX(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_SHLX(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; int mask; @@ -3438,7 +3438,7 @@ static void gen_SHLX(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) tcg_gen_shl_tl(s->T0, s->T0, s->T1); } =20 -static void gen_SHR(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_SHR(DisasContext *s, X86DecodedInsn *decode) { bool can_be_zero; TCGv count; @@ -3460,7 +3460,7 @@ static void gen_SHR(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) } } =20 -static void gen_SHRX(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_SHRX(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; int mask; @@ -3470,37 +3470,37 @@ static void gen_SHRX(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) tcg_gen_shr_tl(s->T0, s->T0, s->T1); } =20 -static void gen_STC(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_STC(DisasContext *s, X86DecodedInsn *decode) { gen_compute_eflags(s); tcg_gen_ori_tl(cpu_cc_src, cpu_cc_src, CC_C); } =20 -static void gen_STD(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_STD(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_st_i32(tcg_constant_i32(-1), tcg_env, offsetof(CPUX86State, df= )); } =20 -static void gen_STI(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_STI(DisasContext *s, X86DecodedInsn *decode) { gen_set_eflags(s, IF_MASK); s->base.is_jmp =3D DISAS_EOB_INHIBIT_IRQ; } =20 -static void gen_VAESKEYGEN(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_VAESKEYGEN(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); assert(!s->vex_l); gen_helper_aeskeygenassist_xmm(tcg_env, OP_PTR0, OP_PTR1, imm); } =20 -static void gen_STMXCSR(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_STMXCSR(DisasContext *s, X86DecodedInsn *decode) { gen_helper_update_mxcsr(tcg_env); tcg_gen_ld32u_tl(s->T0, tcg_env, offsetof(CPUX86State, mxcsr)); } =20 -static void gen_STOS(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_STOS(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) { @@ -3510,7 +3510,7 @@ static void gen_STOS(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_SUB(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_SUB(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[1].ot; =20 @@ -3526,12 +3526,12 @@ static void gen_SUB(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) prepare_update2_cc(decode, s, CC_OP_SUBB + ot); } =20 -static void gen_UD(DisasContext *s, CPUX86State *env, X86DecodedInsn *deco= de) +static void gen_UD(DisasContext *s, X86DecodedInsn *decode) { gen_illegal_opcode(s); } =20 -static void gen_VAESIMC(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_VAESIMC(DisasContext *s, X86DecodedInsn *decode) { assert(!s->vex_l); gen_helper_aesimc_xmm(tcg_env, OP_PTR0, OP_PTR2); @@ -3586,7 +3586,7 @@ static const SSEFunc_0_eppp gen_helper_cmp_funcs[32][= 6] =3D { }; #undef SSE_CMP =20 -static void gen_VCMP(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_VCMP(DisasContext *s, X86DecodedInsn *decode) { int index =3D decode->immediate & (s->prefix & PREFIX_VEX ? 31 : 7); int b =3D @@ -3597,7 +3597,7 @@ static void gen_VCMP(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) gen_helper_cmp_funcs[index][b](tcg_env, OP_PTR0, OP_PTR1, OP_PTR2); } =20 -static void gen_VCOMI(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_VCOMI(DisasContext *s, X86DecodedInsn *decode) { SSEFunc_0_epp fn; fn =3D s->prefix & PREFIX_DATA ? gen_helper_comisd : gen_helper_comiss; @@ -3605,7 +3605,7 @@ static void gen_VCOMI(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) assume_cc_op(s, CC_OP_EFLAGS); } =20 -static void gen_VCVTPD2PS(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VCVTPD2PS(DisasContext *s, X86DecodedInsn *decode) { if (s->vex_l) { gen_helper_cvtpd2ps_ymm(tcg_env, OP_PTR0, OP_PTR2); @@ -3614,7 +3614,7 @@ static void gen_VCVTPD2PS(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *dec } } =20 -static void gen_VCVTPS2PD(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VCVTPS2PD(DisasContext *s, X86DecodedInsn *decode) { if (s->vex_l) { gen_helper_cvtps2pd_ymm(tcg_env, OP_PTR0, OP_PTR2); @@ -3623,9 +3623,9 @@ static void gen_VCVTPS2PD(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *dec } } =20 -static void gen_VCVTPS2PH(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VCVTPS2PH(DisasContext *s, X86DecodedInsn *decode) { - gen_unary_imm_fp_sse(s, env, decode, + gen_unary_imm_fp_sse(s, decode, gen_helper_cvtps2ph_xmm, gen_helper_cvtps2ph_ymm); /* @@ -3637,17 +3637,17 @@ static void gen_VCVTPS2PH(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *dec } } =20 -static void gen_VCVTSD2SS(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VCVTSD2SS(DisasContext *s, X86DecodedInsn *decode) { gen_helper_cvtsd2ss(tcg_env, OP_PTR0, OP_PTR1, OP_PTR2); } =20 -static void gen_VCVTSS2SD(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VCVTSS2SD(DisasContext *s, X86DecodedInsn *decode) { gen_helper_cvtss2sd(tcg_env, OP_PTR0, OP_PTR1, OP_PTR2); } =20 -static void gen_VCVTSI2Sx(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VCVTSI2Sx(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); TCGv_i32 in; @@ -3677,7 +3677,7 @@ static void gen_VCVTSI2Sx(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *dec } } =20 -static inline void gen_VCVTtSx2SI(DisasContext *s, CPUX86State *env, X86De= codedInsn *decode, +static inline void gen_VCVTtSx2SI(DisasContext *s, X86DecodedInsn *decode, SSEFunc_i_ep ss2si, SSEFunc_l_ep ss2sq, SSEFunc_i_ep sd2si, SSEFunc_l_ep sd2sq) { @@ -3715,21 +3715,21 @@ static inline void gen_VCVTtSx2SI(DisasContext *s, = CPUX86State *env, X86DecodedI #define gen_helper_cvttsd2sq NULL #endif =20 -static void gen_VCVTSx2SI(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VCVTSx2SI(DisasContext *s, X86DecodedInsn *decode) { - gen_VCVTtSx2SI(s, env, decode, + gen_VCVTtSx2SI(s, decode, gen_helper_cvtss2si, gen_helper_cvtss2sq, gen_helper_cvtsd2si, gen_helper_cvtsd2sq); } =20 -static void gen_VCVTTSx2SI(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_VCVTTSx2SI(DisasContext *s, X86DecodedInsn *decode) { - gen_VCVTtSx2SI(s, env, decode, + gen_VCVTtSx2SI(s, decode, gen_helper_cvttss2si, gen_helper_cvttss2sq, gen_helper_cvttsd2si, gen_helper_cvttsd2sq); } =20 -static void gen_VEXTRACTx128(DisasContext *s, CPUX86State *env, X86Decoded= Insn *decode) +static void gen_VEXTRACTx128(DisasContext *s, X86DecodedInsn *decode) { int mask =3D decode->immediate & 1; int src_ofs =3D vector_elem_offset(&decode->op[1], MO_128, mask); @@ -3741,12 +3741,12 @@ static void gen_VEXTRACTx128(DisasContext *s, CPUX8= 6State *env, X86DecodedInsn * } } =20 -static void gen_VEXTRACTPS(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_VEXTRACTPS(DisasContext *s, X86DecodedInsn *decode) { - gen_pextr(s, env, decode, MO_32); + gen_pextr(s, decode, MO_32); } =20 -static void gen_vinsertps(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_vinsertps(DisasContext *s, X86DecodedInsn *decode) { int val =3D decode->immediate; int dest_word =3D (val >> 4) & 3; @@ -3779,21 +3779,21 @@ static void gen_vinsertps(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *dec } } =20 -static void gen_VINSERTPS_r(DisasContext *s, CPUX86State *env, X86DecodedI= nsn *decode) +static void gen_VINSERTPS_r(DisasContext *s, X86DecodedInsn *decode) { int val =3D decode->immediate; tcg_gen_ld_i32(s->tmp2_i32, tcg_env, vector_elem_offset(&decode->op[2], MO_32, (val >> 6) & = 3)); - gen_vinsertps(s, env, decode); + gen_vinsertps(s, decode); } =20 -static void gen_VINSERTPS_m(DisasContext *s, CPUX86State *env, X86DecodedI= nsn *decode) +static void gen_VINSERTPS_m(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_qemu_ld_i32(s->tmp2_i32, s->A0, s->mem_index, MO_LEUL); - gen_vinsertps(s, env, decode); + gen_vinsertps(s, decode); } =20 -static void gen_VINSERTx128(DisasContext *s, CPUX86State *env, X86DecodedI= nsn *decode) +static void gen_VINSERTx128(DisasContext *s, X86DecodedInsn *decode) { int mask =3D decode->immediate & 1; tcg_gen_gvec_mov(MO_64, @@ -3804,7 +3804,7 @@ static void gen_VINSERTx128(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *d decode->op[1].offset + offsetof(YMMReg, YMM_X(!mask))= , 16, 16); } =20 -static inline void gen_maskmov(DisasContext *s, CPUX86State *env, X86Decod= edInsn *decode, +static inline void gen_maskmov(DisasContext *s, X86DecodedInsn *decode, SSEFunc_0_eppt xmm, SSEFunc_0_eppt ymm) { if (!s->vex_l) { @@ -3814,17 +3814,17 @@ static inline void gen_maskmov(DisasContext *s, CPU= X86State *env, X86DecodedInsn } } =20 -static void gen_VMASKMOVPD_st(DisasContext *s, CPUX86State *env, X86Decode= dInsn *decode) +static void gen_VMASKMOVPD_st(DisasContext *s, X86DecodedInsn *decode) { - gen_maskmov(s, env, decode, gen_helper_vpmaskmovq_st_xmm, gen_helper_v= pmaskmovq_st_ymm); + gen_maskmov(s, decode, gen_helper_vpmaskmovq_st_xmm, gen_helper_vpmask= movq_st_ymm); } =20 -static void gen_VMASKMOVPS_st(DisasContext *s, CPUX86State *env, X86Decode= dInsn *decode) +static void gen_VMASKMOVPS_st(DisasContext *s, X86DecodedInsn *decode) { - gen_maskmov(s, env, decode, gen_helper_vpmaskmovd_st_xmm, gen_helper_v= pmaskmovd_st_ymm); + gen_maskmov(s, decode, gen_helper_vpmaskmovd_st_xmm, gen_helper_vpmask= movd_st_ymm); } =20 -static void gen_VMOVHPx_ld(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_VMOVHPx_ld(DisasContext *s, X86DecodedInsn *decode) { gen_ldq_env_A0(s, decode->op[0].offset + offsetof(XMMReg, XMM_Q(1))); if (decode->op[0].offset !=3D decode->op[1].offset) { @@ -3833,12 +3833,12 @@ static void gen_VMOVHPx_ld(DisasContext *s, CPUX86S= tate *env, X86DecodedInsn *de } } =20 -static void gen_VMOVHPx_st(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_VMOVHPx_st(DisasContext *s, X86DecodedInsn *decode) { gen_stq_env_A0(s, decode->op[2].offset + offsetof(XMMReg, XMM_Q(1))); } =20 -static void gen_VMOVHPx(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_VMOVHPx(DisasContext *s, X86DecodedInsn *decode) { if (decode->op[0].offset !=3D decode->op[2].offset) { tcg_gen_ld_i64(s->tmp1_i64, tcg_env, decode->op[2].offset + offset= of(XMMReg, XMM_Q(1))); @@ -3850,7 +3850,7 @@ static void gen_VMOVHPx(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod } } =20 -static void gen_VMOVHLPS(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_VMOVHLPS(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_ld_i64(s->tmp1_i64, tcg_env, decode->op[2].offset + offsetof(X= MMReg, XMM_Q(1))); tcg_gen_st_i64(s->tmp1_i64, tcg_env, decode->op[0].offset + offsetof(X= MMReg, XMM_Q(0))); @@ -3860,7 +3860,7 @@ static void gen_VMOVHLPS(DisasContext *s, CPUX86State= *env, X86DecodedInsn *deco } } =20 -static void gen_VMOVLHPS(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_VMOVLHPS(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_ld_i64(s->tmp1_i64, tcg_env, decode->op[2].offset); tcg_gen_st_i64(s->tmp1_i64, tcg_env, decode->op[0].offset + offsetof(X= MMReg, XMM_Q(1))); @@ -3875,7 +3875,7 @@ static void gen_VMOVLHPS(DisasContext *s, CPUX86State= *env, X86DecodedInsn *deco * Use a gvec move to move everything above the bottom 64 bits. */ =20 -static void gen_VMOVLPx(DisasContext *s, CPUX86State *env, X86DecodedInsn = *decode) +static void gen_VMOVLPx(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -3884,7 +3884,7 @@ static void gen_VMOVLPx(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decod tcg_gen_st_i64(s->tmp1_i64, tcg_env, decode->op[0].offset + offsetof(X= MMReg, XMM_Q(0))); } =20 -static void gen_VMOVLPx_ld(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_VMOVLPx_ld(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -3893,13 +3893,13 @@ static void gen_VMOVLPx_ld(DisasContext *s, CPUX86S= tate *env, X86DecodedInsn *de tcg_gen_st_i64(s->tmp1_i64, OP_PTR0, offsetof(ZMMReg, ZMM_Q(0))); } =20 -static void gen_VMOVLPx_st(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_VMOVLPx_st(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_ld_i64(s->tmp1_i64, OP_PTR2, offsetof(ZMMReg, ZMM_Q(0))); tcg_gen_qemu_st_i64(s->tmp1_i64, s->A0, s->mem_index, MO_LEUQ); } =20 -static void gen_VMOVSD_ld(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VMOVSD_ld(DisasContext *s, X86DecodedInsn *decode) { TCGv_i64 zero =3D tcg_constant_i64(0); =20 @@ -3908,7 +3908,7 @@ static void gen_VMOVSD_ld(DisasContext *s, CPUX86Stat= e *env, X86DecodedInsn *dec tcg_gen_st_i64(s->tmp1_i64, OP_PTR0, offsetof(ZMMReg, ZMM_Q(0))); } =20 -static void gen_VMOVSS(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_VMOVSS(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -3917,7 +3917,7 @@ static void gen_VMOVSS(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode tcg_gen_st_i32(s->tmp2_i32, OP_PTR0, offsetof(ZMMReg, ZMM_L(0))); } =20 -static void gen_VMOVSS_ld(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VMOVSS_ld(DisasContext *s, X86DecodedInsn *decode) { int vec_len =3D vector_len(s, decode); =20 @@ -3926,55 +3926,55 @@ static void gen_VMOVSS_ld(DisasContext *s, CPUX86St= ate *env, X86DecodedInsn *dec tcg_gen_st_i32(s->tmp2_i32, OP_PTR0, offsetof(ZMMReg, ZMM_L(0))); } =20 -static void gen_VMOVSS_st(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) +static void gen_VMOVSS_st(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_ld_i32(s->tmp2_i32, OP_PTR2, offsetof(ZMMReg, ZMM_L(0))); tcg_gen_qemu_st_i32(s->tmp2_i32, s->A0, s->mem_index, MO_LEUL); } =20 -static void gen_VPMASKMOV_st(DisasContext *s, CPUX86State *env, X86Decoded= Insn *decode) +static void gen_VPMASKMOV_st(DisasContext *s, X86DecodedInsn *decode) { if (s->vex_w) { - gen_VMASKMOVPD_st(s, env, decode); + gen_VMASKMOVPD_st(s, decode); } else { - gen_VMASKMOVPS_st(s, env, decode); + gen_VMASKMOVPS_st(s, decode); } } =20 -static void gen_VPERMD(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_VPERMD(DisasContext *s, X86DecodedInsn *decode) { assert(s->vex_l); gen_helper_vpermd_ymm(OP_PTR0, OP_PTR1, OP_PTR2); } =20 -static void gen_VPERM2x128(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_VPERM2x128(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); assert(s->vex_l); gen_helper_vpermdq_ymm(OP_PTR0, OP_PTR1, OP_PTR2, imm); } =20 -static void gen_VPHMINPOSUW(DisasContext *s, CPUX86State *env, X86DecodedI= nsn *decode) +static void gen_VPHMINPOSUW(DisasContext *s, X86DecodedInsn *decode) { assert(!s->vex_l); gen_helper_phminposuw_xmm(tcg_env, OP_PTR0, OP_PTR2); } =20 -static void gen_VROUNDSD(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_VROUNDSD(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); assert(!s->vex_l); gen_helper_roundsd_xmm(tcg_env, OP_PTR0, OP_PTR1, OP_PTR2, imm); } =20 -static void gen_VROUNDSS(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_VROUNDSS(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); assert(!s->vex_l); gen_helper_roundss_xmm(tcg_env, OP_PTR0, OP_PTR1, OP_PTR2, imm); } =20 -static void gen_VSHUF(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +static void gen_VSHUF(DisasContext *s, X86DecodedInsn *decode) { TCGv_i32 imm =3D tcg_constant_i32(decode->immediate); SSEFunc_0_pppi ps, pd, fn; @@ -3984,7 +3984,7 @@ static void gen_VSHUF(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) fn(OP_PTR0, OP_PTR1, OP_PTR2, imm); } =20 -static void gen_VUCOMI(DisasContext *s, CPUX86State *env, X86DecodedInsn *= decode) +static void gen_VUCOMI(DisasContext *s, X86DecodedInsn *decode) { SSEFunc_0_epp fn; fn =3D s->prefix & PREFIX_DATA ? gen_helper_ucomisd : gen_helper_ucomi= ss; @@ -3992,7 +3992,7 @@ static void gen_VUCOMI(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode assume_cc_op(s, CC_OP_EFLAGS); } =20 -static void gen_VZEROALL(DisasContext *s, CPUX86State *env, X86DecodedInsn= *decode) +static void gen_VZEROALL(DisasContext *s, X86DecodedInsn *decode) { TCGv_ptr ptr =3D tcg_temp_new_ptr(); =20 @@ -4001,7 +4001,7 @@ static void gen_VZEROALL(DisasContext *s, CPUX86State= *env, X86DecodedInsn *deco tcg_constant_ptr(CPU_NB_REGS * sizeof(ZMMReg))); } =20 -static void gen_VZEROUPPER(DisasContext *s, CPUX86State *env, X86DecodedIn= sn *decode) +static void gen_VZEROUPPER(DisasContext *s, X86DecodedInsn *decode) { int i; =20 @@ -4011,7 +4011,7 @@ static void gen_VZEROUPPER(DisasContext *s, CPUX86Sta= te *env, X86DecodedInsn *de } } =20 -static void gen_WAIT(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_WAIT(DisasContext *s, X86DecodedInsn *decode) { if ((s->flags & (HF_MP_MASK | HF_TS_MASK)) =3D=3D (HF_MP_MASK | HF_TS_= MASK)) { gen_NM_exception(s); @@ -4022,7 +4022,7 @@ static void gen_WAIT(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_XCHG(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_XCHG(DisasContext *s, X86DecodedInsn *decode) { if (s->prefix & PREFIX_LOCK) { tcg_gen_atomic_xchg_tl(s->T0, s->A0, s->T1, @@ -4036,7 +4036,7 @@ static void gen_XCHG(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) } } =20 -static void gen_XLAT(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) +static void gen_XLAT(DisasContext *s, X86DecodedInsn *decode) { /* AL is already zero-extended into s->T0. */ tcg_gen_add_tl(s->A0, cpu_regs[R_EBX], s->T0); @@ -4044,7 +4044,7 @@ static void gen_XLAT(DisasContext *s, CPUX86State *en= v, X86DecodedInsn *decode) gen_op_ld_v(s, MO_8, s->T0, s->A0); } =20 -static void gen_XOR(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec= ode) +static void gen_XOR(DisasContext *s, X86DecodedInsn *decode) { /* special case XOR reg, reg */ if (decode->op[1].unit =3D=3D X86_OP_INT && --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836181; cv=none; d=zohomail.com; s=zohoarc; b=Tj9OGjFOjEfmp+IH3FYV4r9Ez4cJtAc6sMCmXrPSci0bpqqgw1EpyIramB7oU5sG9p7r9g5k2kNMIBKKa+8AcRkUbCFfQiXPK39m2H8XelJHj9iO5Q9v5VCyWX0aPe6PLw+FPwtMVYiUtms2PygBtgpXK3tV4zbL2QO1VdsZaHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836181; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=66RZMatbGR6oA18ZOL7a6HEImIegaXx8KnES6s66OmA=; b=C8QZi9RHTl2srboB0EPIx2SVnfn9rCGz/lPU2HHAiC/Mu/hNQRgL79FklwhZH9JHfikVfNJduhvBY8xxO/OVE6v2v9N/XSubTYn5NiEWan5IbfGs573EyCeisWHEwV4Mf2kmew0SQNzXX5d/8PSvyx8f3c+VufPq4+f8emsac0g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836181521520.9304086592279; Sat, 8 Jun 2024 01:43:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrdj-0001K9-QQ; Sat, 08 Jun 2024 04:41:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdi-0001Jf-Hc for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdg-0001N0-Tb for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:30 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-22-MmjRsU54MLuT2dtIGw7klg-1; Sat, 08 Jun 2024 04:41:26 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-579c69260bbso1393094a12.0 for ; Sat, 08 Jun 2024 01:41:25 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aadf9d064sm3931626a12.10.2024.06.08.01.41.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=66RZMatbGR6oA18ZOL7a6HEImIegaXx8KnES6s66OmA=; b=b5zkt0IqZptrxjRLz6yJKJJqjgYuoo9PCDxqUqwZwVQmVhE/Qe5YXqY3/NaGsQ3HRPBA7V ncCDN9nY4LyHBdzhCFQEEeWu6JzeNcdRG33Z3z5ozVd4XuAcHCKNQwBrkOKmiap2WivfO3 ZBRTfhUVpcc0XWN26401lHIAK0ToScc= X-MC-Unique: MmjRsU54MLuT2dtIGw7klg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836083; x=1718440883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=66RZMatbGR6oA18ZOL7a6HEImIegaXx8KnES6s66OmA=; b=DZMnQuxiINEw+daxHg3/Z2xzVDz07O36FhL5UFj1jgDhuzM0o2pnWDG+xMQVHqSAbv kVR0nQuArL3+ZCFSN6BhNr3a1I1GEfF+7Q8AVYWzVY3b3YAOfvNnsZxx8d7UBhYiXrNp FYVQxCwbEoaQIQ/+YH/coGRRxdgxSDjrIEj8V3lixX5v4A6395IZBpvWttYKL+LzPQeL zoViBFDYTWdh/yC/KLJD2Lp+PdtvWxYVLPeznjLBidh9fR0TSZTJWfr3HvDspAsntp38 r3M0se4IAfsxYop0TmrZitCXdKe8PmEOdSsQWercG3BmwpX137uLRPT0jEuaBlS8zolj r1fQ== X-Gm-Message-State: AOJu0YynEsMi1k9gctJzTFy1OGZ+C0pd09afcaUcpLxJqGGASjDRl2l0 O2f1MhFs5W3/9mt1MztaMly3mAusOcR3P1fc2NRASTFOs4TLWVtWldnMWsUJGTdrW+YWW2CbSc7 cAklYN08jRHRL+GJ/1izdXXCTpInt2cmZ83rqZ4yywtrkdQbkC1MnAj4t6VRhksgboieHfGFSJX La9kzXfJCyzlX/5zMvPuf/cd4iodU0Hshq00pL X-Received: by 2002:a50:9308:0:b0:57c:6ba4:3d89 with SMTP id 4fb4d7f45d1cf-57c6ba4400cmr720272a12.40.1717836083021; Sat, 08 Jun 2024 01:41:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTp2rekmeKG0Q7LFZ5oRGO+gUbnu5OnxCzHuM1FmltYKTYw98BFVUHVjzFdS2Za8s7isC9iw== X-Received: by 2002:a50:9308:0:b0:57c:6ba4:3d89 with SMTP id 4fb4d7f45d1cf-57c6ba4400cmr720262a12.40.1717836082546; Sat, 08 Jun 2024 01:41:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 02/25] target/i386: rewrite flags writeback for ADCX/ADOX Date: Sat, 8 Jun 2024 10:40:50 +0200 Message-ID: <20240608084113.2770363-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836182212100009 Content-Type: text/plain; charset="utf-8" Avoid using set_cc_op() in preparation for implementing APX; treat CC_OP_EFLAGS similar to the case where we have the "opposite" cc_op (CC_OP_ADOX for ADCX and CC_OP_ADCX for ADOX), except the resulting cc_op is not CC_OP_ADCOX. This is written easily as two "if"s, whose conditions are both false for CC_OP_EFLAGS, both true for CC_OP_ADCOX, and one each true for CC_OP_ADCX/ADOX. The new logic also makes it easy to drop usage of tmp0. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/cpu.h | 9 +++--- target/i386/tcg/emit.c.inc | 61 ++++++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 8fe28b67e0f..ee873a0ed84 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1260,6 +1260,8 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWo= rd w, /* Use a clearer name for this. */ #define CPU_INTERRUPT_INIT CPU_INTERRUPT_RESET =20 +#define CC_OP_HAS_EFLAGS(op) ((op) >=3D CC_OP_EFLAGS && (op) <=3D CC_OP_AD= COX) + /* Instead of computing the condition codes after each x86 instruction, * QEMU just stores one operand (called CC_SRC), the result * (called CC_DST) and the type of operation (called CC_OP). When the @@ -1270,6 +1272,9 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWo= rd w, typedef enum { CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ CC_OP_EFLAGS, /* all cc are explicitly computed, CC_SRC =3D flags */ + CC_OP_ADCX, /* CC_DST =3D C, CC_SRC =3D rest. */ + CC_OP_ADOX, /* CC_DST =3D O, CC_SRC =3D rest. */ + CC_OP_ADCOX, /* CC_DST =3D C, CC_SRC2 =3D O, CC_SRC =3D rest. */ =20 CC_OP_MULB, /* modify all flags, C, O =3D (CC_SRC !=3D 0) */ CC_OP_MULW, @@ -1326,10 +1331,6 @@ typedef enum { CC_OP_BMILGL, CC_OP_BMILGQ, =20 - CC_OP_ADCX, /* CC_DST =3D C, CC_SRC =3D rest. */ - CC_OP_ADOX, /* CC_DST =3D O, CC_SRC =3D rest. */ - CC_OP_ADCOX, /* CC_DST =3D C, CC_SRC2 =3D O, CC_SRC =3D rest. */ - CC_OP_CLR, /* Z set, all other flags clear. */ CC_OP_POPCNT, /* Z via CC_SRC, all other flags clear. */ =20 diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index df7597c7e2f..2041ea9d04a 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1122,24 +1122,41 @@ static void gen_ADC(DisasContext *s, X86DecodedInsn= *decode) prepare_update3_cc(decode, s, CC_OP_ADCB + ot, c_in); } =20 -/* ADCX/ADOX do not have memory operands and can use set_cc_op. */ -static void gen_ADCOX(DisasContext *s, MemOp ot, int cc_op) +static void gen_ADCOX(DisasContext *s, X86DecodedInsn *decode, int cc_op) { - int opposite_cc_op; + MemOp ot =3D decode->op[0].ot; TCGv carry_in =3D NULL; - TCGv carry_out =3D (cc_op =3D=3D CC_OP_ADCX ? cpu_cc_dst : cpu_cc_src2= ); + TCGv *carry_out =3D (cc_op =3D=3D CC_OP_ADCX ? &decode->cc_dst : &deco= de->cc_src2); TCGv zero; =20 - if (cc_op =3D=3D s->cc_op || s->cc_op =3D=3D CC_OP_ADCOX) { - /* Re-use the carry-out from a previous round. */ - carry_in =3D carry_out; - } else { - /* We don't have a carry-in, get it out of EFLAGS. */ - if (s->cc_op !=3D CC_OP_ADCX && s->cc_op !=3D CC_OP_ADOX) { - gen_compute_eflags(s); + decode->cc_op =3D cc_op; + *carry_out =3D tcg_temp_new(); + if (CC_OP_HAS_EFLAGS(s->cc_op)) { + decode->cc_src =3D cpu_cc_src; + + /* Re-use the carry-out from a previous round? */ + if (s->cc_op =3D=3D cc_op || s->cc_op =3D=3D CC_OP_ADCOX) { + carry_in =3D (cc_op =3D=3D CC_OP_ADCX ? cpu_cc_dst : cpu_cc_sr= c2); } - carry_in =3D s->tmp0; - tcg_gen_extract_tl(carry_in, cpu_cc_src, + + /* Preserve the opposite carry from previous rounds? */ + if (s->cc_op !=3D cc_op && s->cc_op !=3D CC_OP_EFLAGS) { + decode->cc_op =3D CC_OP_ADCOX; + if (carry_out =3D=3D &decode->cc_dst) { + decode->cc_src2 =3D cpu_cc_src2; + } else { + decode->cc_dst =3D cpu_cc_dst; + } + } + } else { + decode->cc_src =3D tcg_temp_new(); + gen_mov_eflags(s, decode->cc_src); + } + + if (!carry_in) { + /* Get carry_in out of EFLAGS. */ + carry_in =3D tcg_temp_new(); + tcg_gen_extract_tl(carry_in, decode->cc_src, ctz32(cc_op =3D=3D CC_OP_ADCX ? CC_C : CC_O), 1); } =20 @@ -1151,28 +1168,20 @@ static void gen_ADCOX(DisasContext *s, MemOp ot, in= t cc_op) tcg_gen_ext32u_tl(s->T1, s->T1); tcg_gen_add_i64(s->T0, s->T0, s->T1); tcg_gen_add_i64(s->T0, s->T0, carry_in); - tcg_gen_shri_i64(carry_out, s->T0, 32); + tcg_gen_shri_i64(*carry_out, s->T0, 32); break; #endif default: zero =3D tcg_constant_tl(0); - tcg_gen_add2_tl(s->T0, carry_out, s->T0, zero, carry_in, zero); - tcg_gen_add2_tl(s->T0, carry_out, s->T0, carry_out, s->T1, zero); + tcg_gen_add2_tl(s->T0, *carry_out, s->T0, zero, carry_in, zero); + tcg_gen_add2_tl(s->T0, *carry_out, s->T0, *carry_out, s->T1, zero); break; } - - opposite_cc_op =3D cc_op =3D=3D CC_OP_ADCX ? CC_OP_ADOX : CC_OP_ADCX; - if (s->cc_op =3D=3D CC_OP_ADCOX || s->cc_op =3D=3D opposite_cc_op) { - /* Merge with the carry-out from the opposite instruction. */ - set_cc_op(s, CC_OP_ADCOX); - } else { - set_cc_op(s, cc_op); - } } =20 static void gen_ADCX(DisasContext *s, X86DecodedInsn *decode) { - gen_ADCOX(s, decode->op[0].ot, CC_OP_ADCX); + gen_ADCOX(s, decode, CC_OP_ADCX); } =20 static void gen_ADD(DisasContext *s, X86DecodedInsn *decode) @@ -1190,7 +1199,7 @@ static void gen_ADD(DisasContext *s, X86DecodedInsn *= decode) =20 static void gen_ADOX(DisasContext *s, X86DecodedInsn *decode) { - gen_ADCOX(s, decode->op[0].ot, CC_OP_ADOX); + gen_ADCOX(s, decode, CC_OP_ADOX); } =20 static void gen_AND(DisasContext *s, X86DecodedInsn *decode) --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836149; cv=none; d=zohomail.com; s=zohoarc; b=bTy1Bb6/6tePB3CsPHQJc1YI/X2Mh+JauwuO2BJEfVEoygYJeb762v8bhPPz+r3PEPQHLwrXrcg1E8lfRPG3m4MoviMbA5kgUeLEVTSjZnAjO0yBab8D8Z15SK/5m+nkt04LsaYhQOQ8fOhZ3lyrGd1QfBCU0gnTXNGZqojGmWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836149; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=+S5LnfQa8HuliJcdgec0NytFwCbzBU9w1gslYMiuR1g=; b=F7l1fFhqy8yBKjupweG7ZUNnJLhE1veZjsTkFr7Oc6Bqx2lx9RYjkv6PeY1xQuGF2EQdMWgEFooszPV48a8+T3x9+fjF1U2c1Ildau/7sjfTLUGSjvLK+FuNl0W6fcq+dosQbZAS6RJtIcGoHZpZRA+0VpCn6ngtSloBnYTbJVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836149862460.82224501412634; Sat, 8 Jun 2024 01:42:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrdm-0001L4-BX; Sat, 08 Jun 2024 04:41:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdl-0001KV-4D for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdj-0001NE-Gz for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:32 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-63-V23OToHLP42egWjbC6Jupg-1; Sat, 08 Jun 2024 04:41:29 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a6efe561b04so24403066b.3 for ; Sat, 08 Jun 2024 01:41:29 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6eff899fbbsm59005066b.212.2024.06.08.01.41.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+S5LnfQa8HuliJcdgec0NytFwCbzBU9w1gslYMiuR1g=; b=Hh8RbKGbuhNitAVll9CSsPJ8c2deM1R2Vpw04ndI+Z0C6gAhPeVVjGOMELGI3Gl1ev1jcP QPdU3mOL0Svprgc1NTTJhF4w5N9JpRR3Jee1R5nH22DXY1hbM1VcyTGah9GEbAEuz9uYU/ OpVk4G8+Icjfsori7PUmlsuAlOiCC/E= X-MC-Unique: V23OToHLP42egWjbC6Jupg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836087; x=1718440887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+S5LnfQa8HuliJcdgec0NytFwCbzBU9w1gslYMiuR1g=; b=urCAjPMpS31A9Ob/RyNS4IQFmN1z5mkAz7oX3zAr28/os90GnVzB0tU+r+8VGpJY6f G31oaECD/ASBSh83dFnpMr+RymAvYFD2YSBlhmN3SEYIBuhaaNe6nhFjQxVvyk/8k10y 7jaPw96e7dQ0KCt9dmI3JeVjboe+AfAvm5amPJtBBVCeuJkcQBnE2lktVtoD5SuFXDBy ytN1JIM2p1PA0m8cusVwkTlyub1H67eW0luUk0gdsaqQR4ctea58icY5wgN+9YlQPgqO POmPEIX4nUePLxtDvLB+JDPNuzrCO/DeqderpOX2DA5kqheKB4sZ8gm3nE+8ZXxOkQD/ L5Xw== X-Gm-Message-State: AOJu0YxwXqgoOGbhsu2oE+jEBaI0yPkNmwUYkbZxOBHw9k4hSBs8Sjpm c4bO7yfDyWSKWvVx0wwYs268bAwUe+JoaDY5mPEqzTvlMa+th8KFl3IYrZ3a7tMjQBlne6XUFyg +F6AyMIyQgbNRyARo7bKBNf8j07/B2hrk/sjIkm3tdkQoGVlWtaZxbZYUQ6LSC05nN1mUXZKZz2 FQyK1IbKoY5G+StvVvPMtV3y6atHe/dDJA9qp9 X-Received: by 2002:a17:907:bb88:b0:a63:cd85:4d7b with SMTP id a640c23a62f3a-a6cdb00066fmr282583766b.62.1717836087189; Sat, 08 Jun 2024 01:41:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHWeSRnnMPsCh19PhVvwzrWfzYSw6Ve4+4X9m8BQ16gZHV/W9jTQhnUsdb4CeciiN97SvL8A== X-Received: by 2002:a17:907:bb88:b0:a63:cd85:4d7b with SMTP id a640c23a62f3a-a6cdb00066fmr282582666b.62.1717836086838; Sat, 08 Jun 2024 01:41:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 03/25] target/i386: put BLS* input in T1, use generic flag writeback Date: Sat, 8 Jun 2024 10:40:51 +0200 Message-ID: <20240608084113.2770363-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836150109100003 Content-Type: text/plain; charset="utf-8" This makes for easier cpu_cc_* setup, and not using set_cc_op() should come in handy if QEMU ever implements APX. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.c.inc | 4 ++-- target/i386/tcg/emit.c.inc | 24 +++++++++--------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index e7d88020481..380fb793531 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -633,7 +633,7 @@ static const X86OpEntry opcodes_0F38_F0toFF[16][5] =3D { {}, }, [3] =3D { - X86_OP_GROUP3(group17, B,y, E,y, None,None, vex13 cpuid(BMI1)), + X86_OP_GROUP3(group17, B,y, None,None, E,y, vex13 cpuid(BMI1)), {}, {}, {}, @@ -2604,7 +2604,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) } =20 /* - * Write back flags after last memory access. Some newer ALU instruct= ions, as + * Write back flags after last memory access. Some older ALU instruct= ions, as * well as SSE instructions, write flags in the gen_* function, but th= at can * cause incorrect tracking of CC_OP for instructions that write to bo= th memory * and flags. diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 2041ea9d04a..a25b3dfc6b5 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1272,40 +1272,34 @@ static void gen_BEXTR(DisasContext *s, X86DecodedIn= sn *decode) prepare_update1_cc(decode, s, CC_OP_LOGICB + ot); } =20 -/* BLSI do not have memory operands and can use set_cc_op. */ static void gen_BLSI(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 - tcg_gen_mov_tl(cpu_cc_src, s->T0); - tcg_gen_neg_tl(s->T1, s->T0); + /* input in T1, which is ready for prepare_update2_cc */ + tcg_gen_neg_tl(s->T0, s->T1); tcg_gen_and_tl(s->T0, s->T0, s->T1); - tcg_gen_mov_tl(cpu_cc_dst, s->T0); - set_cc_op(s, CC_OP_BMILGB + ot); + prepare_update2_cc(decode, s, CC_OP_BMILGB + ot); } =20 -/* BLSMSK do not have memory operands and can use set_cc_op. */ static void gen_BLSMSK(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 - tcg_gen_mov_tl(cpu_cc_src, s->T0); - tcg_gen_subi_tl(s->T1, s->T0, 1); + /* input in T1, which is ready for prepare_update2_cc */ + tcg_gen_subi_tl(s->T0, s->T1, 1); tcg_gen_xor_tl(s->T0, s->T0, s->T1); - tcg_gen_mov_tl(cpu_cc_dst, s->T0); - set_cc_op(s, CC_OP_BMILGB + ot); + prepare_update2_cc(decode, s, CC_OP_BMILGB + ot); } =20 -/* BLSR do not have memory operands and can use set_cc_op. */ static void gen_BLSR(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; =20 - tcg_gen_mov_tl(cpu_cc_src, s->T0); - tcg_gen_subi_tl(s->T1, s->T0, 1); + /* input in T1, which is ready for prepare_update2_cc */ + tcg_gen_subi_tl(s->T0, s->T1, 1); tcg_gen_and_tl(s->T0, s->T0, s->T1); - tcg_gen_mov_tl(cpu_cc_dst, s->T0); - set_cc_op(s, CC_OP_BMILGB + ot); + prepare_update2_cc(decode, s, CC_OP_BMILGB + ot); } =20 static void gen_BOUND(DisasContext *s, X86DecodedInsn *decode) --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836196; cv=none; d=zohomail.com; s=zohoarc; b=FXIJ20Tc2kB9duMIxsHa8gtCOUNNx0yfIEKqDuIbFEhASLtcvcr2oyNnkkocFNXAk4/uh+vkpwYFeSak1CUtoYoPsMRNib7DJ/Vmga/NUVYp+PVh5cTUR+Ul4aP3UEasbf+RVHOWIq7seVfUKO9ZtCxjhdUihF9z5eQVGy2EWrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836196; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=XQBZ8GvZ/crfzzxMzVV9Zyom9WUbzygMuYT9aDLTYug=; b=TqG6+CD6fdJQ48GNXNDmrjJ6SiuC5yDpoGlQZqplVGmLhZ1jQd6m/Z+xbnuI4PyGAIOL1YogdYeuvgC4iF96x4PaZolHaDLR5g4b4j+hvtSn/VWH/wYFnByniMcWeqM6qoObsLNBsbQ7tm3BGNi8td4FsRwdb5WTNxy3lhsf64Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836196497765.1111934531107; Sat, 8 Jun 2024 01:43:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrdq-0001PF-Jh; Sat, 08 Jun 2024 04:41:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdp-0001O0-In for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdn-0001NW-Uf for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:37 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-CFlBGzS6NQKKwd7NKX5d3Q-1; Sat, 08 Jun 2024 04:41:33 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a6ef6ac6e0aso46643366b.0 for ; Sat, 08 Jun 2024 01:41:33 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c805c9662sm355893066b.51.2024.06.08.01.41.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XQBZ8GvZ/crfzzxMzVV9Zyom9WUbzygMuYT9aDLTYug=; b=M4okDIz44bRiS4jXa77mEkLy+GrJHKNoDaZC63Ikzqn6Z1nV+Hg1RYWC0k48Iu2wO3xZra 0nnvGHt/3aJnjL7RxTNsrcqlZhZ+PvEutjyMgqoFZnzLnOjj6UMkgGV9c9Xui60whBfEy5 WHswO+7RYE1rKAN+2obUbdwHyShqXNY= X-MC-Unique: CFlBGzS6NQKKwd7NKX5d3Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836091; x=1718440891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XQBZ8GvZ/crfzzxMzVV9Zyom9WUbzygMuYT9aDLTYug=; b=bDYt/8D2BHsXkhgEp1C5iLH9Tc6gYmnqg4vNqikz7wffl49vrb3ZyhFjZwtonN+fe5 +1mAd6yW/j4dwkTStPbSAzemqAqf9CPzMN9+0KQu1/sDMoKFqTW6RiHS/Cn6KCy/4k4a WzcZ6BHS8NXny3DlDI8ipY9G69CZc+wjtVswZd/8CYqy7/23h1JN2PfBts5z97rDERVh R040E14XsCGxQLtgHTT249u2Hu4LQTxTaSBDrfXpn94+yTSdMpPmsKNqjZfLNKbcQxcU 21H9l3HO74wfDxsMjuvgyOUq8dlo4UCOjGczowW6sMjTfhPf5dN+Yz6WCKCT7+LoVj4w eFIw== X-Gm-Message-State: AOJu0YzlC6InM6jmiWxwG/PKhZmIZOCLx+2hyYoaNQ5SHLK23BE6GyiW pce/vZasM75QIF8D42iV+628DaasQtLa+HDPPOH4n9vzG4lAp5ZF2GyQFRyRvu1lm+5ODL1h6eO VnO0LgiOfepyFRqS5xJwnH7QOY7qY0ieD7nVEtzo/+0zof1ySDo6rvIfPbFdSZTwRmdXbkYtz+n QVwmrndXYoP0FjBl66DA9Z2z4lIxdu5dGvxspc X-Received: by 2002:a17:906:f58b:b0:a55:8f2a:950d with SMTP id a640c23a62f3a-a6cd56111d7mr379509966b.16.1717836091244; Sat, 08 Jun 2024 01:41:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOo9Fj/DJGoiKps1F1sFyEpY1f/8rp/5ACPDRLIVfaYCiOcYFJlaYI9wwSHhc8MoalsYMHdQ== X-Received: by 2002:a17:906:f58b:b0:a55:8f2a:950d with SMTP id a640c23a62f3a-a6cd56111d7mr379508866b.16.1717836090803; Sat, 08 Jun 2024 01:41:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 04/25] target/i386: change X86_ENTRYr to use T0 Date: Sat, 8 Jun 2024 10:40:52 +0200 Message-ID: <20240608084113.2770363-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836198216100003 Content-Type: text/plain; charset="utf-8" I am not sure why I made it use T1. It is a bit more symmetric with respect to X86_ENTRYwr (which uses T0 for the "w"ritten operand and T1 for the "r"ead operand), but it is also less flexible because it does not let you apply zextT0/sextT0. Signed-off-by: Paolo Bonzini Acked-by: Richard Henderson --- target/i386/tcg/decode-new.c.inc | 6 +++--- target/i386/tcg/emit.c.inc | 34 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 380fb793531..f9d3e2577b2 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -186,7 +186,7 @@ #define X86_OP_ENTRYw(op, op0, s0, ...) \ X86_OP_ENTRY3(op, op0, s0, None, None, None, None, ## __VA_ARGS__) #define X86_OP_ENTRYr(op, op0, s0, ...) \ - X86_OP_ENTRY3(op, None, None, None, None, op0, s0, ## __VA_ARGS__) + X86_OP_ENTRY3(op, None, None, op0, s0, None, None, ## __VA_ARGS__) #define X86_OP_ENTRY1(op, op0, s0, ...) \ X86_OP_ENTRY3(op, op0, s0, 2op, s0, None, None, ## __VA_ARGS__) #define X86_OP_ENTRY0(op, ...) \ @@ -1335,9 +1335,9 @@ static void decode_group4_5(DisasContext *s, CPUX86St= ate *env, X86OpEntry *entry /* 0xff */ [0x08] =3D X86_OP_ENTRY1(INC, E,v, l= ock), [0x09] =3D X86_OP_ENTRY1(DEC, E,v, l= ock), - [0x0a] =3D X86_OP_ENTRY3(CALL_m, None, None, E,f64, None, None, z= extT0), + [0x0a] =3D X86_OP_ENTRYr(CALL_m, E,f64, z= extT0), [0x0b] =3D X86_OP_ENTRYr(CALLF_m, M,p), - [0x0c] =3D X86_OP_ENTRY3(JMP_m, None, None, E,f64, None, None, z= extT0), + [0x0c] =3D X86_OP_ENTRYr(JMP_m, E,f64, z= extT0), [0x0d] =3D X86_OP_ENTRYr(JMPF_m, M,p), [0x0e] =3D X86_OP_ENTRYr(PUSH, E,f64), }; diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index a25b3dfc6b5..797e6e81406 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1363,7 +1363,7 @@ static void gen_CALLF(DisasContext *s, X86DecodedInsn= *decode) =20 static void gen_CALLF_m(DisasContext *s, X86DecodedInsn *decode) { - MemOp ot =3D decode->op[2].ot; + MemOp ot =3D decode->op[1].ot; =20 gen_op_ld_v(s, ot, s->T0, s->A0); gen_add_A0_im(s, 1 << ot); @@ -1593,22 +1593,22 @@ static void gen_DEC(DisasContext *s, X86DecodedInsn= *decode) =20 static void gen_DIV(DisasContext *s, X86DecodedInsn *decode) { - MemOp ot =3D decode->op[2].ot; + MemOp ot =3D decode->op[1].ot; =20 switch(ot) { case MO_8: - gen_helper_divb_AL(tcg_env, s->T1); + gen_helper_divb_AL(tcg_env, s->T0); break; case MO_16: - gen_helper_divw_AX(tcg_env, s->T1); + gen_helper_divw_AX(tcg_env, s->T0); break; default: case MO_32: - gen_helper_divl_EAX(tcg_env, s->T1); + gen_helper_divl_EAX(tcg_env, s->T0); break; #ifdef TARGET_X86_64 case MO_64: - gen_helper_divq_EAX(tcg_env, s->T1); + gen_helper_divq_EAX(tcg_env, s->T0); break; #endif } @@ -1649,22 +1649,22 @@ static void gen_HLT(DisasContext *s, X86DecodedInsn= *decode) =20 static void gen_IDIV(DisasContext *s, X86DecodedInsn *decode) { - MemOp ot =3D decode->op[2].ot; + MemOp ot =3D decode->op[1].ot; =20 switch(ot) { case MO_8: - gen_helper_idivb_AL(tcg_env, s->T1); + gen_helper_idivb_AL(tcg_env, s->T0); break; case MO_16: - gen_helper_idivw_AX(tcg_env, s->T1); + gen_helper_idivw_AX(tcg_env, s->T0); break; default: case MO_32: - gen_helper_idivl_EAX(tcg_env, s->T1); + gen_helper_idivl_EAX(tcg_env, s->T0); break; #ifdef TARGET_X86_64 case MO_64: - gen_helper_idivq_EAX(tcg_env, s->T1); + gen_helper_idivq_EAX(tcg_env, s->T0); break; #endif } @@ -1926,7 +1926,7 @@ static void gen_JMPF(DisasContext *s, X86DecodedInsn = *decode) =20 static void gen_JMPF_m(DisasContext *s, X86DecodedInsn *decode) { - MemOp ot =3D decode->op[2].ot; + MemOp ot =3D decode->op[1].ot; =20 gen_op_ld_v(s, ot, s->T0, s->A0); gen_add_A0_im(s, 1 << ot); @@ -1947,7 +1947,7 @@ static void gen_LAHF(DisasContext *s, X86DecodedInsn = *decode) =20 static void gen_LDMXCSR(DisasContext *s, X86DecodedInsn *decode) { - tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T1); + tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0); gen_helper_ldmxcsr(tcg_env, s->tmp2_i32); } =20 @@ -1995,7 +1995,7 @@ static void gen_LGS(DisasContext *s, X86DecodedInsn *= decode) =20 static void gen_LODS(DisasContext *s, X86DecodedInsn *decode) { - MemOp ot =3D decode->op[2].ot; + MemOp ot =3D decode->op[1].ot; if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) { gen_repz(s, ot, gen_lods); } else { @@ -2765,7 +2765,7 @@ static void gen_PSLLDQ_i(DisasContext *s, X86DecodedI= nsn *decode) =20 static void gen_PUSH(DisasContext *s, X86DecodedInsn *decode) { - gen_push_v(s, s->T1); + gen_push_v(s, s->T0); } =20 static void gen_PUSHA(DisasContext *s, X86DecodedInsn *decode) @@ -3077,7 +3077,7 @@ static void gen_RCR(DisasContext *s, X86DecodedInsn *= decode) =20 static void gen_RET(DisasContext *s, X86DecodedInsn *decode) { - int16_t adjust =3D decode->e.op2 =3D=3D X86_TYPE_I ? decode->immediate= : 0; + int16_t adjust =3D decode->e.op1 =3D=3D X86_TYPE_I ? decode->immediate= : 0; =20 MemOp ot =3D gen_pop_T0(s); gen_stack_update(s, adjust + (1 << ot)); @@ -3088,7 +3088,7 @@ static void gen_RET(DisasContext *s, X86DecodedInsn *= decode) =20 static void gen_RETF(DisasContext *s, X86DecodedInsn *decode) { - int16_t adjust =3D decode->e.op2 =3D=3D X86_TYPE_I ? decode->immediate= : 0; + int16_t adjust =3D decode->e.op1 =3D=3D X86_TYPE_I ? decode->immediate= : 0; =20 if (!PE(s) || VM86(s)) { gen_lea_ss_ofs(s, s->A0, cpu_regs[R_ESP], 0); --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836248; cv=none; d=zohomail.com; s=zohoarc; b=KakloZrlLZJQv6IJfJ+/REMwJ1PnFRRMPpGt1t8mi2BgKcpUySV6+hMp4xOAlWnIAhKqsy7a3SZtnTB5fzgMmLVtMnYTqk8DCBnRadhhFrxBHdS+1dMs8Dh6EbqXMM0NxbHibw5+zBH9mw/J/4DZdZ4ktC/K9guPSO5VRSGVB5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836248; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=uMwm5EoQWR8WwwQOBghJk+ePxHBVZNeMzC33/BhJzSI=; b=JewUs+1FLuc6w99tgMZMGzJDc0cqd0MgKpv1oM5u9EPrv2usa7PUUzQraS6pNhfUbi5M5cmuCEZPff+qr8jJoh+/NeuRyNdQCRN5i2btBmrg9tpDaadt9GEYMj8s5zYtG7oNFFO8nS50DIoEBj/pKsxr+lBBeQX33aFEGEDNcnc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836248097771.3333996419492; Sat, 8 Jun 2024 01:44:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrdu-0001Wu-TI; Sat, 08 Jun 2024 04:41:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrds-0001St-Ql for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdr-0001Ng-4u for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:40 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-463-COt33wvdOqWvKEDzA5UGqQ-1; Sat, 08 Jun 2024 04:41:36 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a6f0f008f9aso2540166b.3 for ; Sat, 08 Jun 2024 01:41:36 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae0ca5e3sm3937038a12.25.2024.06.08.01.41.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836098; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uMwm5EoQWR8WwwQOBghJk+ePxHBVZNeMzC33/BhJzSI=; b=V7xXG90ZFcpP40DRzZXKtupjGY/Ko6Kli/+FF3B7G5CbyY3Si38+7i5KazxzTzv1qCVvNu ywE4sw7U60Qm3jNw4yambFUG2zZ/0/72t7rk4N9qDwP37qOGPVXKcSuqCxLSNjDLpXxzre tUq53NZKno8a1ExgtITYzgiHVxkm3aQ= X-MC-Unique: COt33wvdOqWvKEDzA5UGqQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836095; x=1718440895; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uMwm5EoQWR8WwwQOBghJk+ePxHBVZNeMzC33/BhJzSI=; b=Dwx4jBNmg9iYYJ7vFmR7xEQKE4APNXVZZPdojKiSUsitguzDQWxVMmiHTfh4Y9hnyD GgHPzpJzgKI2JhtqhSs7X5yyAxi5Vd3CBEZmQHZ1YCq0VKeQjnFfA3UafK2PWPBGKZpu QQ1zJJqAjcxfiLMT7muGOeHllNJz99Fg4+UOAoPNHYnfuQgYit2Waqb42xznmQZG/erL 5TXLWkjZgGtGryRGANu+z4xA/U//HCIkhje7kQQEL2dPXxmrBlTemr+SLkWmDBc6ZSEb mZ+GzDEVlkmzSi1EdeEuL6sM85uO/6r2PANtWSztHiww43sMDOWS7h7CPEFSe/DLvt1s 8u0w== X-Gm-Message-State: AOJu0YyBl/ZjhMVhog/TtdONa+jF+vOiqzA5DGBa1qYcmGnKtjjz8Gts RPFOzfBeXqoZdVR5tjAfSxhxLghNaZiPnCdJiy77n4w2NvVdT913MpcK0mlkYRy2N/2Whuynb2T 9vwF41TklkYoyfaYiYLTSuKAK2qMdUr8Nl7Aig/y7tvg2rS+bo6w+3pg3ouEEU60/cywOVID9A7 A9y4DUZR8S2iQRrUm+czGlmUONyuNjQ62rsw0O X-Received: by 2002:a50:d7ca:0:b0:578:638e:3683 with SMTP id 4fb4d7f45d1cf-57c50861ae8mr3510745a12.5.1717836094823; Sat, 08 Jun 2024 01:41:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLQ+iKIHvNgnv55Yco+FipE5yyOJ/2Pz4LC+niCyi2r1u6X7QaSd0tbDEz7YxulKizGSQ9kg== X-Received: by 2002:a50:d7ca:0:b0:578:638e:3683 with SMTP id 4fb4d7f45d1cf-57c50861ae8mr3510740a12.5.1717836094394; Sat, 08 Jun 2024 01:41:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 05/25] target/i386: change X86_ENTRYwr to use T0, use it for moves Date: Sat, 8 Jun 2024 10:40:53 +0200 Message-ID: <20240608084113.2770363-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836248340100001 Content-Type: text/plain; charset="utf-8" Just like X86_ENTRYr, X86_ENTRYwr is easily changed to use only T0. In this case, the motivation is to use it for the MOV instruction family. The case when you need to preserve the input value is the odd one, as it is used basically only for BLS* instructions. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.c.inc | 48 ++++++++++++++++---------------- target/i386/tcg/emit.c.inc | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index f9d3e2577b2..d41002e2f5c 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -180,7 +180,7 @@ #define X86_OP_ENTRYrr(op, op0, s0, op1, s1, ...) \ X86_OP_ENTRY3(op, None, None, op0, s0, op1, s1, ## __VA_ARGS__) #define X86_OP_ENTRYwr(op, op0, s0, op1, s1, ...) \ - X86_OP_ENTRY3(op, op0, s0, None, None, op1, s1, ## __VA_ARGS__) + X86_OP_ENTRY3(op, op0, s0, op1, s1, None, None, ## __VA_ARGS__) #define X86_OP_ENTRY2(op, op0, s0, op1, s1, ...) \ X86_OP_ENTRY3(op, op0, s0, 2op, s0, op1, s1, ## __VA_ARGS__) #define X86_OP_ENTRYw(op, op0, s0, ...) \ @@ -612,15 +612,15 @@ static const X86OpEntry opcodes_0F38_00toEF[240] =3D { /* five rows for no prefix, 66, F3, F2, 66+F2 */ static const X86OpEntry opcodes_0F38_F0toFF[16][5] =3D { [0] =3D { - X86_OP_ENTRY3(MOVBE, G,y, M,y, None,None, cpuid(MOVBE)), - X86_OP_ENTRY3(MOVBE, G,w, M,w, None,None, cpuid(MOVBE)), + X86_OP_ENTRYwr(MOVBE, G,y, M,y, cpuid(MOVBE)), + X86_OP_ENTRYwr(MOVBE, G,w, M,w, cpuid(MOVBE)), {}, X86_OP_ENTRY2(CRC32, G,d, E,b, cpuid(SSE42)), X86_OP_ENTRY2(CRC32, G,d, E,b, cpuid(SSE42)), }, [1] =3D { - X86_OP_ENTRY3(MOVBE, M,y, G,y, None,None, cpuid(MOVBE)), - X86_OP_ENTRY3(MOVBE, M,w, G,w, None,None, cpuid(MOVBE)), + X86_OP_ENTRYwr(MOVBE, M,y, G,y, cpuid(MOVBE)), + X86_OP_ENTRYwr(MOVBE, M,w, G,w, cpuid(MOVBE)), {}, X86_OP_ENTRY2(CRC32, G,d, E,y, cpuid(SSE42)), X86_OP_ENTRY2(CRC32, G,d, E,w, cpuid(SSE42)), @@ -1586,18 +1586,18 @@ static const X86OpEntry opcodes_root[256] =3D { [0x7E] =3D X86_OP_ENTRYr(Jcc, J,b), [0x7F] =3D X86_OP_ENTRYr(Jcc, J,b), =20 - [0x88] =3D X86_OP_ENTRY3(MOV, E,b, G,b, None, None), - [0x89] =3D X86_OP_ENTRY3(MOV, E,v, G,v, None, None), - [0x8A] =3D X86_OP_ENTRY3(MOV, G,b, E,b, None, None), - [0x8B] =3D X86_OP_ENTRY3(MOV, G,v, E,v, None, None), - /* Missing in Table A-2: memory destination is always 16-bit. */ - [0x8C] =3D X86_OP_ENTRY3(MOV, E,v, S,w, None, None, op0_Mw), - [0x8D] =3D X86_OP_ENTRY3(LEA, G,v, M,v, None, None, noseg), - [0x8E] =3D X86_OP_ENTRY3(MOV, S,w, E,w, None, None), + [0x88] =3D X86_OP_ENTRYwr(MOV, E,b, G,b), + [0x89] =3D X86_OP_ENTRYwr(MOV, E,v, G,v), + [0x8A] =3D X86_OP_ENTRYwr(MOV, G,b, E,b), + [0x8B] =3D X86_OP_ENTRYwr(MOV, G,v, E,v), + /* Missing in Table A-2: memory destination is always 16-bit. */ + [0x8C] =3D X86_OP_ENTRYwr(MOV, E,v, S,w, op0_Mw), + [0x8D] =3D X86_OP_ENTRYwr(LEA, G,v, M,v, noseg), + [0x8E] =3D X86_OP_ENTRYwr(MOV, S,w, E,w), [0x8F] =3D X86_OP_GROUPw(group1A, E,v), =20 [0x98] =3D X86_OP_ENTRY1(CBW, 0,v), /* rAX */ - [0x99] =3D X86_OP_ENTRY3(CWD, 2,v, 0,v, None, None), /* rDX, rAX */ + [0x99] =3D X86_OP_ENTRYwr(CWD, 2,v, 0,v), /* rDX, rAX */ [0x9A] =3D X86_OP_ENTRYrr(CALLF, I_unsigned,p, I_unsigned,w, chk(i64)), [0x9B] =3D X86_OP_ENTRY0(WAIT), [0x9C] =3D X86_OP_ENTRY0(PUSHF, chk(vm86_iopl) svm(PUSHF)), @@ -1607,22 +1607,22 @@ static const X86OpEntry opcodes_root[256] =3D { =20 [0xA8] =3D X86_OP_ENTRYrr(AND, 0,b, I,b), /* AL, Ib */ [0xA9] =3D X86_OP_ENTRYrr(AND, 0,v, I,z), /* rAX, Iz */ - [0xAA] =3D X86_OP_ENTRY3(STOS, Y,b, 0,b, None, None), - [0xAB] =3D X86_OP_ENTRY3(STOS, Y,v, 0,v, None, None), + [0xAA] =3D X86_OP_ENTRYwr(STOS, Y,b, 0,b), + [0xAB] =3D X86_OP_ENTRYwr(STOS, Y,v, 0,v), /* Manual writeback because REP LODS (!) has to write EAX/RAX after ev= ery LODS. */ [0xAC] =3D X86_OP_ENTRYr(LODS, X,b), [0xAD] =3D X86_OP_ENTRYr(LODS, X,v), [0xAE] =3D X86_OP_ENTRYrr(SCAS, 0,b, Y,b), [0xAF] =3D X86_OP_ENTRYrr(SCAS, 0,v, Y,v), =20 - [0xB8] =3D X86_OP_ENTRY3(MOV, LoBits,v, I,v, None, None), - [0xB9] =3D X86_OP_ENTRY3(MOV, LoBits,v, I,v, None, None), - [0xBA] =3D X86_OP_ENTRY3(MOV, LoBits,v, I,v, None, None), - [0xBB] =3D X86_OP_ENTRY3(MOV, LoBits,v, I,v, None, None), - [0xBC] =3D X86_OP_ENTRY3(MOV, LoBits,v, I,v, None, None), - [0xBD] =3D X86_OP_ENTRY3(MOV, LoBits,v, I,v, None, None), - [0xBE] =3D X86_OP_ENTRY3(MOV, LoBits,v, I,v, None, None), - [0xBF] =3D X86_OP_ENTRY3(MOV, LoBits,v, I,v, None, None), + [0xB8] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), + [0xB9] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), + [0xBA] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), + [0xBB] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), + [0xBC] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), + [0xBD] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), + [0xBE] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), + [0xBF] =3D X86_OP_ENTRYwr(MOV, LoBits,v, I,v), =20 [0xC8] =3D X86_OP_ENTRYrr(ENTER, I,w, I,b), [0xC9] =3D X86_OP_ENTRY1(LEAVE, A,d64), diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 797e6e81406..78d89db57cd 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1796,7 +1796,7 @@ static void gen_IN(DisasContext *s, X86DecodedInsn *d= ecode) MemOp ot =3D decode->op[0].ot; TCGv_i32 port =3D tcg_temp_new_i32(); =20 - tcg_gen_trunc_tl_i32(port, s->T1); + tcg_gen_trunc_tl_i32(port, s->T0); tcg_gen_ext16u_i32(port, port); if (!gen_check_io(s, ot, port, SVM_IOIO_TYPE_MASK)) { return; --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836186; cv=none; d=zohomail.com; s=zohoarc; b=F64qlIZX/+sf6lASkBAi3vJoz3N3XQdfXl/fxE2VooxaCoe78NTCA03vJD9DHFsnmiZWr82PoVgQllCQPbirBTvjNwipSBJHJ+bq7bOo/LvnAKBZi1Jk0gwrymAx60RUtC9hnX7xkl9oAOyAx7GT20EfvHTPFu8hgeAnJJEWXlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836186; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=fmgaGjuxT+Z57Hwfs56i25kjDBhaRWZGViu+jJkHY1Q=; b=bC5L+hjI78j+NNuHDozOSexu6rHhCMfe45irM095PBpC3pm45ZEYgf83B0LeNfCFc9HyB7kISYrZ3oPumiYlzzVNh1/TNGVbFqgEy83sua6iPlmgKgLBjdKW8k9jMUMkOP9VvV3tUAHlmq8Ud+vLff8+iX6HVwPto8XnGP42NOo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836186555316.24140680636947; Sat, 8 Jun 2024 01:43:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrdx-0001aG-Fs; Sat, 08 Jun 2024 04:41:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdw-0001Zv-OM for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdv-0001PK-5F for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:44 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-CSEiywRIPvafn6J45I0g_w-1; Sat, 08 Jun 2024 04:41:40 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57a941a787dso1704786a12.3 for ; Sat, 08 Jun 2024 01:41:40 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aadf9ea35sm3933883a12.15.2024.06.08.01.41.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fmgaGjuxT+Z57Hwfs56i25kjDBhaRWZGViu+jJkHY1Q=; b=IjxExIvILZACOgVEIn5QvPbHMI6/X5KmEUdI/ppeH6JoOVD9OolXyNh8Aay53aOCg7L2Im mFbNwcuRDpWYUhCNv6hUG/kyNiQHzVkRotL2vJw+EF4aB3rtekkfMhm+tPmkLxvixBODF3 Z2ZaYEkqaQu/6egeyH8uhG8V0KEunko= X-MC-Unique: CSEiywRIPvafn6J45I0g_w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836098; x=1718440898; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fmgaGjuxT+Z57Hwfs56i25kjDBhaRWZGViu+jJkHY1Q=; b=pyvxGNbXH/ADlwgtVLWoBLMA/EmyT422U551PQiCKYGLLh1vogDc8rEgn5bfYE0XHT HJmXQr+ADZT7T/fD1lFFVi7T1WX+0/ka1jf8I9kFK35Y0/tgj7u3yrHrMcqAAvNtxtWZ fwbd10sZKT651WYz/bzWnbQHSxyB8bsafz+jidTNUsg3qvL87zpeHUMa952uhEPm5vBs WgkAc5in5ux2qLOc36tpF6GBIHiB4pcyI6RmbWhz9PtsBrtH99X+hhKFzl9vOLCigfsJ D0NO8BhWUcCGVmpoL0p+jje+0nUYoWhXDP04GetWETNzksLSZDwUR3KYYLHgOBzwCvgP 84Qw== X-Gm-Message-State: AOJu0YwM4rC0iy6A/NsiqwjhGIysWZ+cwKiV2I0Gu2AvyB4lfFpkG1ww cFmFk9Zf+OAQn6WRGQYDQMUcMviMWLaOr6rBaeZlzhlZQAnH5i+t9KrDis0DermRPRhE4tb+eSA mcurMk4+PrKyiIxltt/HKHJq9RxJJpX/6smNAJAH3O0o+SsNgOidGmLKnA5rB3dpKE+kGt0+ps7 IbVx3PdXVmXSXbCnJPzioP7QNngotwFKsOPmH/ X-Received: by 2002:a50:999d:0:b0:57c:6ae2:abda with SMTP id 4fb4d7f45d1cf-57c6ae2ac5emr958752a12.5.1717836098568; Sat, 08 Jun 2024 01:41:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtPBRVPIVg1VplbYgGKRR7OWdY7gPae0j4Jklq5Qqnkg6NVMximxER/voEp98RguNYPvgdJA== X-Received: by 2002:a50:999d:0:b0:57c:6ae2:abda with SMTP id 4fb4d7f45d1cf-57c6ae2ac5emr958744a12.5.1717836098193; Sat, 08 Jun 2024 01:41:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 06/25] target/i386: replace NoSeg special with NoLoadEA Date: Sat, 8 Jun 2024 10:40:54 +0200 Message-ID: <20240608084113.2770363-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836188185100003 Content-Type: text/plain; charset="utf-8" This is a bit more generic, as it can be applied to MPX as well. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.h | 5 +++-- target/i386/tcg/decode-new.c.inc | 12 ++++-------- target/i386/tcg/emit.c.inc | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index f704698575f..46a96b220d0 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -170,8 +170,9 @@ typedef enum X86InsnSpecial { /* Always locked if it has a memory operand (XCHG) */ X86_SPECIAL_Locked, =20 - /* Do not apply segment base to effective address */ - X86_SPECIAL_NoSeg, + /* Do not load effective address in s->A0 */ + X86_SPECIAL_NoLoadEA, + /* * Rd/Mb or Rd/Mw in the manual: register operand 0 is treated as 32 b= its * (and writeback zero-extends it to 64 bits if applicable). PREFIX_D= ATA diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index d41002e2f5c..4f5fcdb88dd 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -193,7 +193,7 @@ X86_OP_ENTRY3(op, None, None, None, None, None, None, ## __VA_ARGS__) =20 #define cpuid(feat) .cpuid =3D X86_FEAT_##feat, -#define noseg .special =3D X86_SPECIAL_NoSeg, +#define nolea .special =3D X86_SPECIAL_NoLoadEA, #define xchg .special =3D X86_SPECIAL_Locked, #define lock .special =3D X86_SPECIAL_HasLock, #define mmx .special =3D X86_SPECIAL_MMX, @@ -1592,7 +1592,7 @@ static const X86OpEntry opcodes_root[256] =3D { [0x8B] =3D X86_OP_ENTRYwr(MOV, G,v, E,v), /* Missing in Table A-2: memory destination is always 16-bit. */ [0x8C] =3D X86_OP_ENTRYwr(MOV, E,v, S,w, op0_Mw), - [0x8D] =3D X86_OP_ENTRYwr(LEA, G,v, M,v, noseg), + [0x8D] =3D X86_OP_ENTRYwr(LEA, G,v, M,v, nolea), [0x8E] =3D X86_OP_ENTRYwr(MOV, S,w, E,w), [0x8F] =3D X86_OP_GROUPw(group1A, E,v), =20 @@ -2524,11 +2524,6 @@ static void disas_insn(DisasContext *s, CPUState *cp= u) assert(decode.op[1].unit =3D=3D X86_OP_INT); break; =20 - case X86_SPECIAL_NoSeg: - decode.mem.def_seg =3D -1; - s->override =3D -1; - break; - case X86_SPECIAL_Op0_Mw: assert(decode.op[0].unit =3D=3D X86_OP_INT); if (decode.op[0].has_ea) { @@ -2585,7 +2580,8 @@ static void disas_insn(DisasContext *s, CPUState *cpu) gen_helper_enter_mmx(tcg_env); } =20 - if (decode.op[0].has_ea || decode.op[1].has_ea || decode.op[2].has_ea)= { + if (decode.e.special !=3D X86_SPECIAL_NoLoadEA && + (decode.op[0].has_ea || decode.op[1].has_ea || decode.op[2].has_ea= )) { gen_load_ea(s, &decode.mem, decode.e.vex_class =3D=3D 12); } if (s->prefix & PREFIX_LOCK) { diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 78d89db57cd..e6521632edd 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1970,7 +1970,8 @@ static void gen_LDS(DisasContext *s, X86DecodedInsn *= decode) =20 static void gen_LEA(DisasContext *s, X86DecodedInsn *decode) { - tcg_gen_mov_tl(s->T0, s->A0); + TCGv ea =3D gen_lea_modrm_1(s, decode->mem, false); + gen_lea_v_seg_dest(s, s->aflag, s->T0, ea, -1, -1); } =20 static void gen_LEAVE(DisasContext *s, X86DecodedInsn *decode) --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836206; cv=none; d=zohomail.com; s=zohoarc; b=SRUCnNglH1cVIgw5Gzonqpi2u9Sd9vANob77KlGhABRHijod6axfIHb+/2z/H1Bus81jfya4g2ydQQuIFUNwAzVGTkzHegfaYFIdQKDLi4NsSHReMB2S9Dcx+QHyRf90NymaxD+THMmjdQBLAjhDJs8AG9P3LzupKLTe/phT4RE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836206; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Tmei8Ud98thhW3S+3Sbrm0GZGeeq0Z4E37bpCj2oG9w=; b=Tq66ARP0soOjyjRVdul3+r26VyHpSi/XylcLL0YSugly5bAiC5sl8Z8NuXB/3t1Gy7l8xHvrcJSFxVMOv6sDgrpNd3q94lfU1Nvm2sf+A4TeRV7hLFeorJ/AiPn02ze39/QXAWKlatyxtQUAo3lwCrlx5KSjv/JeozFt028+tCc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171783620655260.326360525285736; Sat, 8 Jun 2024 01:43:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFre3-0001bn-4U; Sat, 08 Jun 2024 04:41:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFre1-0001bR-B4 for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrdz-0001Pf-Vh for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:49 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-H8K5jnjdNPaNFWMp2eM8vA-1; Sat, 08 Jun 2024 04:41:43 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a6ef7afd90aso38131166b.2 for ; Sat, 08 Jun 2024 01:41:43 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6e2e1d4cb8sm181511766b.5.2024.06.08.01.41.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836107; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tmei8Ud98thhW3S+3Sbrm0GZGeeq0Z4E37bpCj2oG9w=; b=YZK4duIvqqhgdWs9KsimiDIXyYEY3stjbSHIi9DqxP3OnKgcOjSG4UfegqPuEI98DtYXA+ f67fpBsa61NKoy6DEncEYuXSEYvjU469maoLe2sbPug7jd3qP/BLal4qUZSWozbq/U0l/7 6uG6y6iR/Uv5FlqSvsvLjwy1GSfmHcE= X-MC-Unique: H8K5jnjdNPaNFWMp2eM8vA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836101; x=1718440901; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tmei8Ud98thhW3S+3Sbrm0GZGeeq0Z4E37bpCj2oG9w=; b=K1/ymJh9onTSBOjo6hSeZRwjINXD3N93H33/qptDW7A16vAZBs8b+8VDxYQ5oefTqA UyT439rWTbWLF046Bb7TupbarTXYNyRgXfjI0x50JID7sTswsh7Cn1PQEEa3WcmamNJ6 sO8wte0bdDZi/cFFdQSayuK+o9gidYTkfRSiQlTKXHjJRiZRsrzCN8bUXrf8QMtyYLTF azZFJaHcNJS5Ax53TPASs9oSFXT4Y0IRqeEnyVdiX0bZY7s61ZW5U6h213wRMrG6tBA8 BHNVuf4wxQr0LTT5bvu+NpwzGu8GURTQWA20n7daMN2IGVdLtBXoPy7FzOcD6zW04/KJ 0Y7g== X-Gm-Message-State: AOJu0YxD0bcYFg4cKiJpj07ZDCnPJlnqMYOST7ANsnZg/K1VJN1mw2LN JJcxGgJjblhR1SxUFXkra+8wwdYeC4HOA4rPOQ40T2d/lgjGpMBI70h2fYmIgQq1Lzrz/DxE82V 1RU/Vo5WZ/rUTLiO4AzB3gJSMlwNgExe+meunWRWNuvNz1bI1Dl2hsZ9lEdSh7LqwOoQn7q+HEB tgW0fe6Ydue4jSfrTbuP0iH76VFp5M0Zae6upu X-Received: by 2002:a17:906:ca59:b0:a5c:df6b:a9b5 with SMTP id a640c23a62f3a-a6cdaa0f720mr312370966b.59.1717836101707; Sat, 08 Jun 2024 01:41:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3eZMLGu62byei2ER2J7juCPPkdqdDpUMuCXTiqE+uyOTmdpGXkBAzzgx9VWA16CrDi4SYFg== X-Received: by 2002:a17:906:ca59:b0:a5c:df6b:a9b5 with SMTP id a640c23a62f3a-a6cdaa0f720mr312370366b.59.1717836101351; Sat, 08 Jun 2024 01:41:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 07/25] target/i386: fix processing of intercept 0 (read CR0) Date: Sat, 8 Jun 2024 10:40:55 +0200 Message-ID: <20240608084113.2770363-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836208245100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.h | 1 + target/i386/tcg/decode-new.c.inc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index 46a96b220d0..8465717ea21 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -272,6 +272,7 @@ struct X86OpEntry { unsigned valid_prefix:16; unsigned check:16; unsigned intercept:8; + bool has_intercept:1; bool is_decode:1; }; =20 diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 4f5fcdb88dd..cd925fe3589 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -221,7 +221,7 @@ #define vex13 .vex_class =3D 13, =20 #define chk(a) .check =3D X86_CHECK_##a, -#define svm(a) .intercept =3D SVM_EXIT_##a, +#define svm(a) .intercept =3D SVM_EXIT_##a, .has_intercept =3D true, =20 #define avx2_256 .vex_special =3D X86_VEX_AVX2_256, =20 @@ -2559,7 +2559,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) goto gp_fault; } } - if (decode.e.intercept && unlikely(GUEST(s))) { + if (decode.e.has_intercept && unlikely(GUEST(s))) { gen_helper_svm_check_intercept(tcg_env, tcg_constant_i32(decode.e.intercept= )); } --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836138; cv=none; d=zohomail.com; s=zohoarc; b=ntwWFsIjI4e9k2pNA2aRdItjpBp+AyRecp+ersRA6mQpWGrSdNh/VIpvgdG8sr3vJBI4zk3YI/JMPdrfJHky3zqD+8h/BDGrKDMJavnwUYPZqOhUyMl4MgqDsA2annBe1DR8ap/XET0+OOYEPFUfLwlHV/vlkcQSHRtOD/Dd9qk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836138; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=wTQuU78l9PNh3Ee02W3G2foh2NBLKBu2TnRb8Cyqwnk=; b=D+MkdGlRbSWbrayfZVGhxqEtG0d2J/W37ePkFwsNNzKXFWNoQ+Kq5jg8EzD5RlHanTleCqqnTTG0x5C35bWxfxGwZtvOkpXwVRN+InpA4LlxV0VJH/t+Yd4wIhcXPhx2nPG3tehC3ADgNVBucnPSmR75KVHnmWa0BKFjV0m5bus= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836138032331.05893445078414; Sat, 8 Jun 2024 01:42:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFre6-0001d1-MD; Sat, 08 Jun 2024 04:41:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFre5-0001cp-UQ for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFre4-0001Pw-32 for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:53 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-xkQ-7v5oN7St0IoViFaEXQ-1; Sat, 08 Jun 2024 04:41:47 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a6ef7afd90aso38133366b.2 for ; Sat, 08 Jun 2024 01:41:47 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f0f5ee702sm5224666b.52.2024.06.08.01.41.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wTQuU78l9PNh3Ee02W3G2foh2NBLKBu2TnRb8Cyqwnk=; b=Z7p4Zg1plCmxoUMZHWIpMOtmCcREEJ62amvSHPO1YWELgy670+tU3yOanHUlaspFhXKEHw IdBJqO1iELZfDkHTctblNEPU0b42wt/x8WuXup1grn6IRBHI07gb+/f6SoFkg+6EJyJM3T xic8eQImixy8faCCwO87CRUR7zBDSz4= X-MC-Unique: xkQ-7v5oN7St0IoViFaEXQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836105; x=1718440905; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wTQuU78l9PNh3Ee02W3G2foh2NBLKBu2TnRb8Cyqwnk=; b=H2zsqJcaPB9N9sKH8gCh9fcwKw5ZbA+YL6aoEDm5G3WQBlGRONCoq425eC3JIGvAvP KtfSU806qB/mo3DmwNar6JhRyg4h7jCXTa4GjqfAhz5IxMvA/gClbNA035l5MmrQKcOA QzZLOAkcMfTNtRhPVem7kzq5is8yFjAj93tH586UVRVT8ToiTiDtK4p59xYpQIu8DiL7 TTJqA/nbGlCLYAFnNKjUAYvrpR0IQ6hVGY1IuUkeYiMVLVgUasU3otiwnWlOLy+fJDXo Knp8YJsPT7z4eVxZkEFyW8BXQ9YYpSYroKHF5se5kfDzsuXjYcuij7V6mz/mv76KtOv4 cLNw== X-Gm-Message-State: AOJu0Yz3OxDnW+XM8k8a+6W/DXRwTLbVib0jsDWWuR0lDqFh1I7TDs0X +bvIPNjHIEXDarQ5rC9owXprTWLtVo4EOTtQu+jGvODPWbRIuCIGHVpenq7PkAwZjGVj9Okkwjs yfdR01N+JEx4fpkAaRsfzFyEEkbJUY3KtJn1VeiJJ1aSUMT3BOfLySxGGz7I+DZY/0opA4AHQcA JdCxh7ZeeNuHo3KDjhxkaI+NyR/1JIMUHZpTaA X-Received: by 2002:a17:906:d053:b0:a68:e920:e68b with SMTP id a640c23a62f3a-a6cd6665c58mr304132266b.25.1717836105091; Sat, 08 Jun 2024 01:41:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoc0gny/LhebrgdWo31YLPP5nbX06n8/Axz58Jcg44802UOr0hFgM9tRK2zmVnuLFQ8SBuXQ== X-Received: by 2002:a17:906:d053:b0:a68:e920:e68b with SMTP id a640c23a62f3a-a6cd6665c58mr304131466b.25.1717836104625; Sat, 08 Jun 2024 01:41:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 08/25] target/i386: convert MOV from/to CR and DR to new decoder Date: Sat, 8 Jun 2024 10:40:56 +0200 Message-ID: <20240608084113.2770363-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836140082100003 Content-Type: text/plain; charset="utf-8" Complete implementation of C and D operand types, then the operations are just MOVs. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 79 -------------------------------- target/i386/tcg/decode-new.c.inc | 53 +++++++++++++++++++-- target/i386/tcg/emit.c.inc | 20 +++++++- 3 files changed, 68 insertions(+), 84 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index fcba9c155f9..4958f4c45d5 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -247,9 +247,6 @@ STUB_HELPER(outb, TCGv_env env, TCGv_i32 port, TCGv_i32= val) STUB_HELPER(outw, TCGv_env env, TCGv_i32 port, TCGv_i32 val) STUB_HELPER(outl, TCGv_env env, TCGv_i32 port, TCGv_i32 val) STUB_HELPER(rdmsr, TCGv_env env) -STUB_HELPER(read_crN, TCGv ret, TCGv_env env, TCGv_i32 reg) -STUB_HELPER(get_dr, TCGv ret, TCGv_env env, TCGv_i32 reg) -STUB_HELPER(set_dr, TCGv_env env, TCGv_i32 reg, TCGv val) STUB_HELPER(stgi, TCGv_env env) STUB_HELPER(svm_check_intercept, TCGv_env env, TCGv_i32 type) STUB_HELPER(vmload, TCGv_env env, TCGv_i32 aflag) @@ -4192,82 +4189,6 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) gen_nop_modrm(env, s, modrm); break; =20 - case 0x120: /* mov reg, crN */ - case 0x122: /* mov crN, reg */ - if (!check_cpl0(s)) { - break; - } - modrm =3D x86_ldub_code(env, s); - /* - * Ignore the mod bits (assume (modrm&0xc0)=3D=3D0xc0). - * AMD documentation (24594.pdf) and testing of Intel 386 and 486 - * processors all show that the mod bits are assumed to be 1's, - * regardless of actual values. - */ - rm =3D (modrm & 7) | REX_B(s); - reg =3D ((modrm >> 3) & 7) | REX_R(s); - switch (reg) { - case 0: - if ((prefixes & PREFIX_LOCK) && - (s->cpuid_ext3_features & CPUID_EXT3_CR8LEG)) { - reg =3D 8; - } - break; - case 2: - case 3: - case 4: - case 8: - break; - default: - goto unknown_op; - } - ot =3D (CODE64(s) ? MO_64 : MO_32); - - translator_io_start(&s->base); - if (b & 2) { - gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0 + reg); - gen_op_mov_v_reg(s, ot, s->T0, rm); - gen_helper_write_crN(tcg_env, tcg_constant_i32(reg), s->T0); - s->base.is_jmp =3D DISAS_EOB_NEXT; - } else { - gen_svm_check_intercept(s, SVM_EXIT_READ_CR0 + reg); - gen_helper_read_crN(s->T0, tcg_env, tcg_constant_i32(reg)); - gen_op_mov_reg_v(s, ot, rm, s->T0); - } - break; - - case 0x121: /* mov reg, drN */ - case 0x123: /* mov drN, reg */ - if (check_cpl0(s)) { - modrm =3D x86_ldub_code(env, s); - /* Ignore the mod bits (assume (modrm&0xc0)=3D=3D0xc0). - * AMD documentation (24594.pdf) and testing of - * intel 386 and 486 processors all show that the mod bits - * are assumed to be 1's, regardless of actual values. - */ - rm =3D (modrm & 7) | REX_B(s); - reg =3D ((modrm >> 3) & 7) | REX_R(s); - if (CODE64(s)) - ot =3D MO_64; - else - ot =3D MO_32; - if (reg >=3D 8) { - goto illegal_op; - } - if (b & 2) { - gen_svm_check_intercept(s, SVM_EXIT_WRITE_DR0 + reg); - gen_op_mov_v_reg(s, ot, s->T0, rm); - tcg_gen_movi_i32(s->tmp2_i32, reg); - gen_helper_set_dr(tcg_env, s->tmp2_i32, s->T0); - s->base.is_jmp =3D DISAS_EOB_NEXT; - } else { - gen_svm_check_intercept(s, SVM_EXIT_READ_DR0 + reg); - tcg_gen_movi_i32(s->tmp2_i32, reg); - gen_helper_get_dr(s->T0, tcg_env, s->tmp2_i32); - gen_op_mov_reg_v(s, ot, rm, s->T0); - } - } - break; case 0x106: /* clts */ if (check_cpl0(s)) { gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0); diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index cd925fe3589..4c567911f41 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -151,6 +151,8 @@ X86_OP_GROUP3(op, op0, s0, 2op, s0, op1, s1, ## __VA_ARGS__) #define X86_OP_GROUPw(op, op0, s0, ...) \ X86_OP_GROUP3(op, op0, s0, None, None, None, None, ## __VA_ARGS__) +#define X86_OP_GROUPwr(op, op0, s0, op1, s1, ...) \ + X86_OP_GROUP3(op, op0, s0, op1, s1, None, None, ## __VA_ARGS__) #define X86_OP_GROUP0(op, ...) \ X86_OP_GROUP3(op, None, None, None, None, None, None, ## __VA_ARGS__) =20 @@ -985,6 +987,24 @@ static void decode_0FE6(DisasContext *s, CPUX86State *= env, X86OpEntry *entry, ui *entry =3D *decode_by_prefix(s, opcodes_0FE6); } =20 +/* These are a bit weird, so group all the pre-decode tweaks here. */ +static void decode_MOV_CR_DR(DisasContext *s, CPUX86State *env, X86OpEntry= *entry, uint8_t *b) +{ + /* No 16-bit mode. */ + s->dflag =3D MO_32; + + /* + * Ignore the mod bits (assume (modrm&0xc0)=3D=3D0xc0). + * AMD documentation (24594.pdf) and testing of Intel 386 and 486 + * processors all show that the mod bits are assumed to be 1's, + * regardless of actual values. + */ + get_modrm(s, env); + s->modrm |=3D 0xC0; + + entry->gen =3D gen_MOV; +} + static const X86OpEntry opcodes_0F[256] =3D { [0x0E] =3D X86_OP_ENTRY0(EMMS, cpuid(3DNO= W)), /* femms */ /* @@ -1004,6 +1024,11 @@ static const X86OpEntry opcodes_0F[256] =3D { /* Incorrectly listed as Mq,Vq in the manual */ [0x17] =3D X86_OP_ENTRY3(VMOVHPx_st, M,q, None,None, V,dq, vex5 p_00_= 66), =20 + [0x20] =3D X86_OP_GROUPwr(MOV_CR_DR, R,y, C,y, chk(cpl0) svm(READ_CR= 0)), + [0x21] =3D X86_OP_GROUPwr(MOV_CR_DR, R,y, D,y, chk(cpl0) svm(READ_DR= 0)), + [0x22] =3D X86_OP_GROUPwr(MOV_CR_DR, C,y, R,y, zextT0 chk(cpl0) svm(= WRITE_CR0)), + [0x23] =3D X86_OP_GROUPwr(MOV_CR_DR, D,y, R,y, zextT0 chk(cpl0) svm(= WRITE_DR0)), + [0x40] =3D X86_OP_ENTRY2(CMOVcc, G,v, E,v, cpuid(CMOV)), [0x41] =3D X86_OP_ENTRY2(CMOVcc, G,v, E,v, cpuid(CMOV)), [0x42] =3D X86_OP_ENTRY2(CMOVcc, G,v, E,v, cpuid(CMOV)), @@ -1802,11 +1827,34 @@ static bool decode_op(DisasContext *s, CPUX86State = *env, X86DecodedInsn *decode, =20 case X86_TYPE_C: /* REG in the modrm byte selects a control register = */ op->unit =3D X86_OP_CR; - goto get_reg; + op->n =3D ((get_modrm(s, env) >> 3) & 7) | REX_R(s); + if (op->n =3D=3D 0 && (s->prefix & PREFIX_LOCK) && + (s->cpuid_ext3_features & CPUID_EXT3_CR8LEG)) { + op->n =3D 8; + s->prefix &=3D ~PREFIX_LOCK; + } + if (op->n !=3D 0 && op->n !=3D 2 && op->n !=3D 3 && op->n !=3D 4 &= & op->n !=3D 8) { + return false; + } + if (decode->e.intercept) { + decode->e.intercept +=3D op->n; + } + break; =20 case X86_TYPE_D: /* REG in the modrm byte selects a debug register */ op->unit =3D X86_OP_DR; - goto get_reg; + op->n =3D ((get_modrm(s, env) >> 3) & 7) | REX_R(s); + if (op->n >=3D 8) { + /* + * illegal opcode. The DR4 and DR5 case is checked in the gen= erated + * code instead, to save on hflags bits. + */ + return false; + } + if (decode->e.intercept) { + decode->e.intercept +=3D op->n; + } + break; =20 case X86_TYPE_G: /* REG in the modrm byte selects a GPR */ op->unit =3D X86_OP_INT; @@ -2431,7 +2479,6 @@ static void disas_insn(DisasContext *s, CPUState *cpu) case 0x00 ... 0x03: /* mostly privileged instructions */ case 0x05 ... 0x09: case 0x1a ... 0x1b: /* MPX */ - case 0x20 ... 0x23: /* mov from/to CR and DR */ case 0x30 ... 0x35: /* more privileged instructions */ case 0xa2 ... 0xa5: /* CPUID, BT, SHLD */ case 0xaa ... 0xae: /* RSM, SHRD, grp15 */ diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index e6521632edd..bcb6bccbd75 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -242,12 +242,19 @@ static void gen_load(DisasContext *s, X86DecodedInsn = *decode, int opn, TCGv v) tcg_gen_ld32u_tl(v, tcg_env, offsetof(CPUX86State,segs[op->n].selector)); break; +#ifndef CONFIG_USER_ONLY case X86_OP_CR: - tcg_gen_ld_tl(v, tcg_env, offsetof(CPUX86State, cr[op->n])); + if (op->n =3D=3D 8) { + gen_helper_read_crN(v, tcg_env, tcg_constant_i32(op->n)); + } else { + tcg_gen_ld_tl(v, tcg_env, offsetof(CPUX86State, cr[op->n])); + } break; case X86_OP_DR: - tcg_gen_ld_tl(v, tcg_env, offsetof(CPUX86State, dr[op->n])); + /* CR4.DE tested in the helper. */ + gen_helper_get_dr(v, tcg_env, tcg_constant_i32(op->n)); break; +#endif case X86_OP_INT: if (op->has_ea) { if (v =3D=3D s->T0 && decode->e.special =3D=3D X86_SPECIAL_SEx= tT0) { @@ -343,8 +350,17 @@ static void gen_writeback(DisasContext *s, X86DecodedI= nsn *decode, int opn, TCGv 16, 16, 0); } break; +#ifndef CONFIG_USER_ONLY case X86_OP_CR: + gen_helper_write_crN(tcg_env, tcg_constant_i32(op->n), v); + s->base.is_jmp =3D DISAS_EOB_NEXT; + break; case X86_OP_DR: + /* CR4.DE tested in the helper. */ + gen_helper_set_dr(tcg_env, tcg_constant_i32(op->n), v); + s->base.is_jmp =3D DISAS_EOB_NEXT; + break; +#endif default: g_assert_not_reached(); } --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836145; cv=none; d=zohomail.com; s=zohoarc; b=E5leUC9pDDIExXXViHWCdHctRfUnZtbKuJwqV6z/+KI8ogtmObyhm1omDLIlQzTKNFBtClPbnf9E89aPWp2+P3dXQ6yiDKBOtaFfkpR22eqJT0pDfnYMRp8skw3jnEeIV0h4QlaKdxE/IAUxy0ARmEDKKqe+xuBCn15sBFWYzjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836145; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Z1J3/JD1dn7MgaT8Ll/a2KX3nRmtx9rCL7vpXkttTP8=; b=Fn4791LzTKdbqqXUI0WTuSksbyUUC80mxMlkaRJx2CYmd/4tgiCGY5rI15svYgBEwk0AirLJgYIRGa1hZ4gZL2CIvO64/6tReUyHkOKQLzcrRman7c6KAcjGCLdvcSaTy0oqoY3JOv9HCb6v0k4dq4aIvbwl81cz7qIlJIyv/+k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836145088650.8793635495484; Sat, 8 Jun 2024 01:42:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFre9-0001hN-8k; Sat, 08 Jun 2024 04:41:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFre7-0001dT-Io for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFre5-0001Q5-PS for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:55 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-281-iJ6EVuG9PEShWwTDHqYEtQ-1; Sat, 08 Jun 2024 04:41:50 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a6c72164f46so151784166b.1 for ; Sat, 08 Jun 2024 01:41:50 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f0cdfb226sm26713866b.151.2024.06.08.01.41.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z1J3/JD1dn7MgaT8Ll/a2KX3nRmtx9rCL7vpXkttTP8=; b=g2shNsR8O7z8hMuRgEejcXPZo3Jw2/SPHM2pdmSQuoWw/iRA5GscwFSspx5CR63rZOXhZ7 xBhJFM0zx7x6YYPRTtE8y6HDHawTQXXktCkirkbWE/f4l5CaYQBmcEvXJp1ZfFvhkAqffG B2kILyVydLedgleFmo1DHZckEEVVcIM= X-MC-Unique: iJ6EVuG9PEShWwTDHqYEtQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836108; x=1718440908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z1J3/JD1dn7MgaT8Ll/a2KX3nRmtx9rCL7vpXkttTP8=; b=slCtIbE02nG5jloOSl2fn9XgXF0QDbfTCLNviqM891Jr9NKIYLME7CcrovuiNRMt7L dDUI8v5ioAsFLgM6LpjYrMBvFyT8ZlaoOIkAppZum/Y2InKAtBZXmiMCHSJ/qoHv0CsM Muc8+uiK511Z9Kd3hYWne104zYC1nJA3lvVm3yTJ7lgxkllfyMLcS/BpyEbOSzjwQPUL nXj71gZtzHo6iY8R6LIMCQXafjNtBNVhnRMTTv4mM0XDwPWQXqXWnMESc3egcVFovt1p do32mA8BjSnkMXkSWBwCnKGVnsxJBel6pH3gwQJ78kYRJsDg6CEyUAJBP4BpF/zXQXlc tw7g== X-Gm-Message-State: AOJu0YyI12w+aAhbaHGjZKTQRDtOw9GwtWfhTGGMdA0qXwIlLpBY//j6 MwyB6IzLsBtBHbfuYQ8XLcERxemigLsAhdD6+Y26Up60VEdWWeHxpCzkB0cfeHXbwWhkxkw+q7Y ayzH+k1sq8lIkEXPboG8jb9hJ66LgesYNfblih5nlbvnxmMWph9W1kW1CttXrjQp5tEOPDmzh96 LCbRElsl1Cm6iP4xScKV+oc+HiSGGl1F1ZMi16 X-Received: by 2002:a17:906:6953:b0:a68:be21:8dca with SMTP id a640c23a62f3a-a6cd561a934mr301993166b.10.1717836108513; Sat, 08 Jun 2024 01:41:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3vHcAzvdhy79AqHo6t6sYrYmDKux2gq77OmDRSzwflzUCiN6eps7a8lSpYK2EYyKnbGXhtA== X-Received: by 2002:a17:906:6953:b0:a68:be21:8dca with SMTP id a640c23a62f3a-a6cd561a934mr301992266b.10.1717836107958; Sat, 08 Jun 2024 01:41:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 09/25] target/i386: fix bad sorting of entries in the 0F table Date: Sat, 8 Jun 2024 10:40:57 +0200 Message-ID: <20240608084113.2770363-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836146168100007 Content-Type: text/plain; charset="utf-8" Aesthetic change only. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.c.inc | 93 ++++++++++++++++---------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 4c567911f41..4e745f10dd8 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1006,14 +1006,6 @@ static void decode_MOV_CR_DR(DisasContext *s, CPUX86= State *env, X86OpEntry *entr } =20 static const X86OpEntry opcodes_0F[256] =3D { - [0x0E] =3D X86_OP_ENTRY0(EMMS, cpuid(3DNO= W)), /* femms */ - /* - * 3DNow!'s opcode byte comes *after* modrm and displacements, making = it - * more like an Ib operand. Dispatch to the right helper in a single = gen_* - * function. - */ - [0x0F] =3D X86_OP_ENTRY3(3dnow, P,q, Q,q, I,b, cpuid(3DNO= W)), - [0x10] =3D X86_OP_GROUP0(0F10), [0x11] =3D X86_OP_GROUP0(0F11), [0x12] =3D X86_OP_GROUP0(0F12), @@ -1086,8 +1078,54 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xa0] =3D X86_OP_ENTRYr(PUSH, FS, w), [0xa1] =3D X86_OP_ENTRYw(POP, FS, w), =20 + [0xb2] =3D X86_OP_ENTRY3(LSS, G,v, EM,p, None, None), + [0xb4] =3D X86_OP_ENTRY3(LFS, G,v, EM,p, None, None), + [0xb5] =3D X86_OP_ENTRY3(LGS, G,v, EM,p, None, None), + [0xb6] =3D X86_OP_ENTRY3(MOV, G,v, E,b, None, None, zextT0), /* MOV= ZX */ + [0xb7] =3D X86_OP_ENTRY3(MOV, G,v, E,w, None, None, zextT0), /* MOV= ZX */ + + [0xc2] =3D X86_OP_ENTRY4(VCMP, V,x, H,x, W,x, vex2_rep3 p_= 00_66_f3_f2), + [0xc3] =3D X86_OP_ENTRY3(MOV, EM,y,G,y, None,None, cpuid(SSE2))= , /* MOVNTI */ + [0xc4] =3D X86_OP_ENTRY4(PINSRW, V,dq,H,dq,E,w, vex5 mmx p_0= 0_66), + [0xc5] =3D X86_OP_ENTRY3(PEXTRW, G,d, U,dq,I,b, vex5 mmx p_0= 0_66), + [0xc6] =3D X86_OP_ENTRY4(VSHUF, V,x, H,x, W,x, vex4 p_00_66= ), + + [0xd0] =3D X86_OP_ENTRY3(VADDSUB, V,x, H,x, W,x, vex2 cpuid(S= SE3) p_66_f2), + [0xd1] =3D X86_OP_ENTRY3(PSRLW_r, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xd2] =3D X86_OP_ENTRY3(PSRLD_r, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xd3] =3D X86_OP_ENTRY3(PSRLQ_r, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xd4] =3D X86_OP_ENTRY3(PADDQ, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xd5] =3D X86_OP_ENTRY3(PMULLW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xd6] =3D X86_OP_GROUP0(0FD6), + [0xd7] =3D X86_OP_ENTRY3(PMOVMSKB, G,d, None,None, U,x, vex7 mmx avx= 2_256 p_00_66), + + [0xe0] =3D X86_OP_ENTRY3(PAVGB, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xe1] =3D X86_OP_ENTRY3(PSRAW_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), + [0xe2] =3D X86_OP_ENTRY3(PSRAD_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), + [0xe3] =3D X86_OP_ENTRY3(PAVGW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xe4] =3D X86_OP_ENTRY3(PMULHUW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xe5] =3D X86_OP_ENTRY3(PMULHW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xe6] =3D X86_OP_GROUP0(0FE6), + [0xe7] =3D X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex1 mmx p_0= 0_66), /* MOVNTQ/MOVNTDQ */ + + [0xf0] =3D X86_OP_ENTRY3(MOVDQ, V,x, None,None, WM,x, vex4_unal cp= uid(SSE3) p_f2), /* LDDQU */ + [0xf1] =3D X86_OP_ENTRY3(PSLLW_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), + [0xf2] =3D X86_OP_ENTRY3(PSLLD_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), + [0xf3] =3D X86_OP_ENTRY3(PSLLQ_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), + [0xf4] =3D X86_OP_ENTRY3(PMULUDQ, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xf5] =3D X86_OP_ENTRY3(PMADDWD, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xf6] =3D X86_OP_ENTRY3(PSADBW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), + [0xf7] =3D X86_OP_ENTRY3(MASKMOV, None,None, V,dq, U,dq, vex4_unal av= x2_256 mmx p_00_66), + [0x0b] =3D X86_OP_ENTRY0(UD), /* UD2 */ [0x0d] =3D X86_OP_ENTRY1(NOP, M,v), /* 3DNow! prefetch */ + [0x0e] =3D X86_OP_ENTRY0(EMMS, cpuid(3DNO= W)), /* femms */ + /* + * 3DNow!'s opcode byte comes *after* modrm and displacements, making = it + * more like an Ib operand. Dispatch to the right helper in a single = gen_* + * function. + */ + [0x0f] =3D X86_OP_ENTRY3(3dnow, P,q, Q,q, I,b, cpuid(3DNO= W)), =20 [0x18] =3D X86_OP_ENTRY1(NOP, nop,v), /* prefetch/reserved NOP */ [0x19] =3D X86_OP_ENTRY1(NOP, nop,v), /* reserved NOP */ @@ -1169,23 +1207,11 @@ static const X86OpEntry opcodes_0F[256] =3D { */ [0xaf] =3D X86_OP_ENTRY3(IMUL3, G,v, E,v, 2op,v, sextT0), =20 - [0xb2] =3D X86_OP_ENTRY3(LSS, G,v, EM,p, None, None), - [0xb4] =3D X86_OP_ENTRY3(LFS, G,v, EM,p, None, None), - [0xb5] =3D X86_OP_ENTRY3(LGS, G,v, EM,p, None, None), - [0xb6] =3D X86_OP_ENTRY3(MOV, G,v, E,b, None, None, zextT0), /* MOV= ZX */ - [0xb7] =3D X86_OP_ENTRY3(MOV, G,v, E,w, None, None, zextT0), /* MOV= ZX */ - /* decoded as modrm, which is visible as a difference between page fau= lt and #UD */ [0xb9] =3D X86_OP_ENTRYr(UD, nop,v), /* UD1= */ [0xbe] =3D X86_OP_ENTRY3(MOV, G,v, E,b, None, None, sextT0), /* MOV= SX */ [0xbf] =3D X86_OP_ENTRY3(MOV, G,v, E,w, None, None, sextT0), /* MOV= SX */ =20 - [0xc2] =3D X86_OP_ENTRY4(VCMP, V,x, H,x, W,x, vex2_rep3 p_= 00_66_f3_f2), - [0xc3] =3D X86_OP_ENTRY3(MOV, EM,y,G,y, None,None, cpuid(SSE2))= , /* MOVNTI */ - [0xc4] =3D X86_OP_ENTRY4(PINSRW, V,dq,H,dq,E,w, vex5 mmx p_0= 0_66), - [0xc5] =3D X86_OP_ENTRY3(PEXTRW, G,d, U,dq,I,b, vex5 mmx p_0= 0_66), - [0xc6] =3D X86_OP_ENTRY4(VSHUF, V,x, H,x, W,x, vex4 p_00_66= ), - [0xc8] =3D X86_OP_ENTRY1(BSWAP, LoBits,y), [0xc9] =3D X86_OP_ENTRY1(BSWAP, LoBits,y), [0xca] =3D X86_OP_ENTRY1(BSWAP, LoBits,y), @@ -1195,33 +1221,6 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xce] =3D X86_OP_ENTRY1(BSWAP, LoBits,y), [0xcf] =3D X86_OP_ENTRY1(BSWAP, LoBits,y), =20 - [0xd0] =3D X86_OP_ENTRY3(VADDSUB, V,x, H,x, W,x, vex2 cpuid(S= SE3) p_66_f2), - [0xd1] =3D X86_OP_ENTRY3(PSRLW_r, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xd2] =3D X86_OP_ENTRY3(PSRLD_r, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xd3] =3D X86_OP_ENTRY3(PSRLQ_r, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xd4] =3D X86_OP_ENTRY3(PADDQ, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xd5] =3D X86_OP_ENTRY3(PMULLW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xd6] =3D X86_OP_GROUP0(0FD6), - [0xd7] =3D X86_OP_ENTRY3(PMOVMSKB, G,d, None,None, U,x, vex7 mmx avx= 2_256 p_00_66), - - [0xe0] =3D X86_OP_ENTRY3(PAVGB, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xe1] =3D X86_OP_ENTRY3(PSRAW_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), - [0xe2] =3D X86_OP_ENTRY3(PSRAD_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), - [0xe3] =3D X86_OP_ENTRY3(PAVGW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xe4] =3D X86_OP_ENTRY3(PMULHUW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xe5] =3D X86_OP_ENTRY3(PMULHW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xe6] =3D X86_OP_GROUP0(0FE6), - [0xe7] =3D X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex1 mmx p_0= 0_66), /* MOVNTQ/MOVNTDQ */ - - [0xf0] =3D X86_OP_ENTRY3(MOVDQ, V,x, None,None, WM,x, vex4_unal cp= uid(SSE3) p_f2), /* LDDQU */ - [0xf1] =3D X86_OP_ENTRY3(PSLLW_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), - [0xf2] =3D X86_OP_ENTRY3(PSLLD_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), - [0xf3] =3D X86_OP_ENTRY3(PSLLQ_r, V,x, H,x, W,x, vex7 mmx avx= 2_256 p_00_66), - [0xf4] =3D X86_OP_ENTRY3(PMULUDQ, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xf5] =3D X86_OP_ENTRY3(PMADDWD, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xf6] =3D X86_OP_ENTRY3(PSADBW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), - [0xf7] =3D X86_OP_ENTRY3(MASKMOV, None,None, V,dq, U,dq, vex4_unal av= x2_256 mmx p_00_66), - /* Incorrectly missing from 2-17 */ [0xd8] =3D X86_OP_ENTRY3(PSUBUSB, V,x, H,x, W,x, vex4 mmx avx2_256 p= _00_66), [0xd9] =3D X86_OP_ENTRY3(PSUBUSW, V,x, H,x, W,x, vex4 mmx avx2_256 p= _00_66), --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836223; cv=none; d=zohomail.com; s=zohoarc; b=RWmRZt27YXDbkXEpugN42rCk9wb0pmYtjEUYZSk40y7SNmXtC5NbehMZnyHthu9IbStxBNpGZBMa4SSLv/kAScQ5kZnASwzYWMn/x+/4+bTYYZZIpK49N9blXrWjqVycZKx0SP7a8LOwaVW5U332jMJtosA1KMkhb01IiR1azGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836223; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=W18pK6MAK/k3fK9GqH6QBkkFhAdqUYPQviFu3MzipCA=; b=a5A3SsyPWMduhNcWT4WQq83SM9C6JwFWKm8cu8ake75rgIZ7Zj4cyNECBrIt77t0vR4+vYWfZ3kkBabV49J4qcWdskVi9dA41euy51Ir57TAOuVvl+mNF2hkPL+Rzm/T11ecaqdX4BndgUst/AFMmiAOVgvujjhViU4qbVkn7xg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836223175102.78534758129967; Sat, 8 Jun 2024 01:43:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFreD-0002Aa-II; Sat, 08 Jun 2024 04:42:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreB-0001v0-O1 for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFre9-0001QW-CF for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:41:59 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-368-XV9v3fXCO-G3bcrYKFPYzA-1; Sat, 08 Jun 2024 04:41:54 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57a32f2f782so1175991a12.1 for ; Sat, 08 Jun 2024 01:41:54 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae23404fsm3933332a12.89.2024.06.08.01.41.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W18pK6MAK/k3fK9GqH6QBkkFhAdqUYPQviFu3MzipCA=; b=BuO4u77oN3jUM0loK893EhT3IRChzNX0SmS4Eo+Fd6gYwVunyTzMgFSfMwVz4beD0VYmm1 nPhIV6dkLLJg4Ya1LC52sivi0OGxqk7aXtcJNdoQnhK8UGhwis6BUq7C9uT6RQAYMXQ7It 9Y5POqosSrQByf+AZq7oYucOBUEVAvY= X-MC-Unique: XV9v3fXCO-G3bcrYKFPYzA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836112; x=1718440912; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W18pK6MAK/k3fK9GqH6QBkkFhAdqUYPQviFu3MzipCA=; b=TfO5sv1Ak4uNfJnd8dchvx/MENdI+ByfexLH1OSvo8aM8QiSipM/iXkxIVwQTawsW8 +bsYSbHSY673IlPStEaFlUkT/6CfE1EWDe58LmDnLRPFf9R9pLQbp3qc9CcTjAqhotlD hvYJ6i7tOZKNmwCmahCoPk4gwL2wdzVwR+0kwLSOYGoxP62M5uLclak5JwEkcZunwWAS 4DbfHyNU5sEU5uZSwYuQ+D/Xaq7bLNz0KFum/3+LzPl6N7I+GHFn8vaC2WXz00zCq01Q PYvoZ7r4iDt5Zi4GXJsZajP5aX08LTYixwegVuDmPieqRu4N240oXO5KCvwpmteGVz/b 8Phw== X-Gm-Message-State: AOJu0Yyk+T+rJjfRqX31+XGEJW0Yb9q1l/04gj6PJEcc81J7gL+MiHMu pOiLL/eW8OpUStTW14/bqdxPDsTkqe+fAYdxitMIAtbhrKyN48eq5McuBMxO+JRFNT+b0syxBbg 9RWmooEcZpP0fG9t78h9gQxXFow7NvpDH3kMARsOM/DZDBIQQSdiwCDHkh9UrdP0mdk+RDU7GLl csVgIko/2F3Cq/tEX7m4xlDgwHwdmVll0qXgm4 X-Received: by 2002:a50:9eab:0:b0:573:555e:6d89 with SMTP id 4fb4d7f45d1cf-57c508274c6mr3079695a12.1.1717836112040; Sat, 08 Jun 2024 01:41:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHejmg/gKC4HsyDiTBPYAslKdBmNK8HRTu+TYbaCzZ702VH+Y4hXGsWkm4J/epszELuwO7iPw== X-Received: by 2002:a50:9eab:0:b0:573:555e:6d89 with SMTP id 4fb4d7f45d1cf-57c508274c6mr3079683a12.1.1717836111409; Sat, 08 Jun 2024 01:41:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 10/25] target/i386: finish converting 0F AE to the new decoder Date: Sat, 8 Jun 2024 10:40:58 +0200 Message-ID: <20240608084113.2770363-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836224332100007 Content-Type: text/plain; charset="utf-8" This is already partly implemented due to VLDMXCSR and VSTMXCSR; finish the job. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.h | 7 ++ target/i386/tcg/translate.c | 188 ------------------------------- target/i386/tcg/decode-new.c.inc | 48 +++++++- target/i386/tcg/emit.c.inc | 80 +++++++++++++ 4 files changed, 129 insertions(+), 194 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index 8465717ea21..5577f7509aa 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -108,10 +108,15 @@ typedef enum X86CPUIDFeature { X86_FEAT_AVX2, X86_FEAT_BMI1, X86_FEAT_BMI2, + X86_FEAT_CLFLUSH, + X86_FEAT_CLFLUSHOPT, + X86_FEAT_CLWB, X86_FEAT_CMOV, X86_FEAT_CMPCCXADD, X86_FEAT_F16C, X86_FEAT_FMA, + X86_FEAT_FSGSBASE, + X86_FEAT_FXSR, X86_FEAT_MOVBE, X86_FEAT_PCLMULQDQ, X86_FEAT_SHA_NI, @@ -122,6 +127,8 @@ typedef enum X86CPUIDFeature { X86_FEAT_SSE41, X86_FEAT_SSE42, X86_FEAT_SSE4A, + X86_FEAT_XSAVE, + X86_FEAT_XSAVEOPT, } X86CPUIDFeature; =20 /* Execution flags */ diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 4958f4c45d5..ebae745ecba 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -4197,194 +4197,6 @@ static void disas_insn_old(DisasContext *s, CPUStat= e *cpu, int b) s->base.is_jmp =3D DISAS_EOB_NEXT; } break; - /* MMX/3DNow!/SSE/SSE2/SSE3/SSSE3/SSE4 support */ - case 0x1ae: - modrm =3D x86_ldub_code(env, s); - switch (modrm) { - CASE_MODRM_MEM_OP(0): /* fxsave */ - if (!(s->cpuid_features & CPUID_FXSR) - || (prefixes & PREFIX_LOCK)) { - goto illegal_op; - } - if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) { - gen_exception(s, EXCP07_PREX); - break; - } - gen_lea_modrm(env, s, modrm); - gen_helper_fxsave(tcg_env, s->A0); - break; - - CASE_MODRM_MEM_OP(1): /* fxrstor */ - if (!(s->cpuid_features & CPUID_FXSR) - || (prefixes & PREFIX_LOCK)) { - goto illegal_op; - } - if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) { - gen_exception(s, EXCP07_PREX); - break; - } - gen_lea_modrm(env, s, modrm); - gen_helper_fxrstor(tcg_env, s->A0); - break; - - CASE_MODRM_MEM_OP(2): /* ldmxcsr */ - if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK)) { - goto illegal_op; - } - if (s->flags & HF_TS_MASK) { - gen_exception(s, EXCP07_PREX); - break; - } - gen_lea_modrm(env, s, modrm); - tcg_gen_qemu_ld_i32(s->tmp2_i32, s->A0, s->mem_index, MO_LEUL); - gen_helper_ldmxcsr(tcg_env, s->tmp2_i32); - break; - - CASE_MODRM_MEM_OP(3): /* stmxcsr */ - if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK)) { - goto illegal_op; - } - if (s->flags & HF_TS_MASK) { - gen_exception(s, EXCP07_PREX); - break; - } - gen_helper_update_mxcsr(tcg_env); - gen_lea_modrm(env, s, modrm); - tcg_gen_ld32u_tl(s->T0, tcg_env, offsetof(CPUX86State, mxcsr)); - gen_op_st_v(s, MO_32, s->T0, s->A0); - break; - - CASE_MODRM_MEM_OP(4): /* xsave */ - if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) =3D=3D 0 - || (prefixes & (PREFIX_LOCK | PREFIX_DATA - | PREFIX_REPZ | PREFIX_REPNZ))) { - goto illegal_op; - } - gen_lea_modrm(env, s, modrm); - tcg_gen_concat_tl_i64(s->tmp1_i64, cpu_regs[R_EAX], - cpu_regs[R_EDX]); - gen_helper_xsave(tcg_env, s->A0, s->tmp1_i64); - break; - - CASE_MODRM_MEM_OP(5): /* xrstor */ - if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) =3D=3D 0 - || (prefixes & (PREFIX_LOCK | PREFIX_DATA - | PREFIX_REPZ | PREFIX_REPNZ))) { - goto illegal_op; - } - gen_lea_modrm(env, s, modrm); - tcg_gen_concat_tl_i64(s->tmp1_i64, cpu_regs[R_EAX], - cpu_regs[R_EDX]); - gen_helper_xrstor(tcg_env, s->A0, s->tmp1_i64); - /* XRSTOR is how MPX is enabled, which changes how - we translate. Thus we need to end the TB. */ - s->base.is_jmp =3D DISAS_EOB_NEXT; - break; - - CASE_MODRM_MEM_OP(6): /* xsaveopt / clwb */ - if (prefixes & PREFIX_LOCK) { - goto illegal_op; - } - if (prefixes & PREFIX_DATA) { - /* clwb */ - if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_CLWB)) { - goto illegal_op; - } - gen_nop_modrm(env, s, modrm); - } else { - /* xsaveopt */ - if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) =3D=3D 0 - || (s->cpuid_xsave_features & CPUID_XSAVE_XSAVEOPT) = =3D=3D 0 - || (prefixes & (PREFIX_REPZ | PREFIX_REPNZ))) { - goto illegal_op; - } - gen_lea_modrm(env, s, modrm); - tcg_gen_concat_tl_i64(s->tmp1_i64, cpu_regs[R_EAX], - cpu_regs[R_EDX]); - gen_helper_xsaveopt(tcg_env, s->A0, s->tmp1_i64); - } - break; - - CASE_MODRM_MEM_OP(7): /* clflush / clflushopt */ - if (prefixes & PREFIX_LOCK) { - goto illegal_op; - } - if (prefixes & PREFIX_DATA) { - /* clflushopt */ - if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_CLFLUSHOPT= )) { - goto illegal_op; - } - } else { - /* clflush */ - if ((s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) - || !(s->cpuid_features & CPUID_CLFLUSH)) { - goto illegal_op; - } - } - gen_nop_modrm(env, s, modrm); - break; - - case 0xc0 ... 0xc7: /* rdfsbase (f3 0f ae /0) */ - case 0xc8 ... 0xcf: /* rdgsbase (f3 0f ae /1) */ - case 0xd0 ... 0xd7: /* wrfsbase (f3 0f ae /2) */ - case 0xd8 ... 0xdf: /* wrgsbase (f3 0f ae /3) */ - if (CODE64(s) - && (prefixes & PREFIX_REPZ) - && !(prefixes & PREFIX_LOCK) - && (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_FSGSBASE)) { - TCGv base, treg, src, dst; - - /* Preserve hflags bits by testing CR4 at runtime. */ - tcg_gen_movi_i32(s->tmp2_i32, CR4_FSGSBASE_MASK); - gen_helper_cr4_testbit(tcg_env, s->tmp2_i32); - - base =3D cpu_seg_base[modrm & 8 ? R_GS : R_FS]; - treg =3D cpu_regs[(modrm & 7) | REX_B(s)]; - - if (modrm & 0x10) { - /* wr*base */ - dst =3D base, src =3D treg; - } else { - /* rd*base */ - dst =3D treg, src =3D base; - } - - if (s->dflag =3D=3D MO_32) { - tcg_gen_ext32u_tl(dst, src); - } else { - tcg_gen_mov_tl(dst, src); - } - break; - } - goto unknown_op; - - case 0xf8 ... 0xff: /* sfence */ - if (!(s->cpuid_features & CPUID_SSE) - || (prefixes & PREFIX_LOCK)) { - goto illegal_op; - } - tcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC); - break; - case 0xe8 ... 0xef: /* lfence */ - if (!(s->cpuid_features & CPUID_SSE) - || (prefixes & PREFIX_LOCK)) { - goto illegal_op; - } - tcg_gen_mb(TCG_MO_LD_LD | TCG_BAR_SC); - break; - case 0xf0 ... 0xf7: /* mfence */ - if (!(s->cpuid_features & CPUID_SSE2) - || (prefixes & PREFIX_LOCK)) { - goto illegal_op; - } - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); - break; - - default: - goto unknown_op; - } - break; - case 0x1aa: /* rsm */ gen_svm_check_intercept(s, SVM_EXIT_RSM); if (!(s->flags & HF_SMM_MASK)) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 4e745f10dd8..1c6fa39c3eb 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -269,20 +269,41 @@ static inline const X86OpEntry *decode_by_prefix(Disa= sContext *s, const X86OpEnt =20 static void decode_group15(DisasContext *s, CPUX86State *env, X86OpEntry *= entry, uint8_t *b) { - /* only includes ldmxcsr and stmxcsr, because they have AVX variants. = */ static const X86OpEntry group15_reg[8] =3D { + [0] =3D X86_OP_ENTRYw(RDxxBASE, R,y, cpuid(FSGSBASE) chk(o64) p_= f3), + [1] =3D X86_OP_ENTRYw(RDxxBASE, R,y, cpuid(FSGSBASE) chk(o64) p_= f3), + [2] =3D X86_OP_ENTRYr(WRxxBASE, R,y, cpuid(FSGSBASE) chk(o64) p_= f3 zextT0), + [3] =3D X86_OP_ENTRYr(WRxxBASE, R,y, cpuid(FSGSBASE) chk(o64) p_= f3 zextT0), + [5] =3D X86_OP_ENTRY0(LFENCE, cpuid(SSE2) p_00), + [6] =3D X86_OP_ENTRY0(MFENCE, cpuid(SSE2) p_00), + [7] =3D X86_OP_ENTRY0(SFENCE, cpuid(SSE2) p_00), }; =20 static const X86OpEntry group15_mem[8] =3D { - [2] =3D X86_OP_ENTRYr(LDMXCSR, E,d, vex5 chk(VEX128)), - [3] =3D X86_OP_ENTRYw(STMXCSR, E,d, vex5 chk(VEX128)), + [0] =3D X86_OP_ENTRYw(FXSAVE, M,y, cpuid(FXSR) p_00), + [1] =3D X86_OP_ENTRYr(FXRSTOR, M,y, cpuid(FXSR) p_00), + [2] =3D X86_OP_ENTRYr(LDMXCSR, E,d, vex5 chk(VEX128) p_00), + [3] =3D X86_OP_ENTRYw(STMXCSR, E,d, vex5 chk(VEX128) p_00), + [4] =3D X86_OP_ENTRYw(XSAVE, M,y, cpuid(XSAVE) p_00), + [5] =3D X86_OP_ENTRYr(XRSTOR, M,y, cpuid(XSAVE) p_00), + [6] =3D X86_OP_ENTRYw(XSAVEOPT, M,b, cpuid(XSAVEOPT) p_00), + [7] =3D X86_OP_ENTRYw(NOP, M,b, cpuid(CLFLUSH) p_00), + }; + + static const X86OpEntry group15_mem_66[8] =3D { + [6] =3D X86_OP_ENTRYw(NOP, M,b, cpuid(CLWB)), + [7] =3D X86_OP_ENTRYw(NOP, M,b, cpuid(CLFLUSHOPT)), }; =20 uint8_t modrm =3D get_modrm(s, env); + int op =3D (modrm >> 3) & 7; + if ((modrm >> 6) =3D=3D 3) { - *entry =3D group15_reg[(modrm >> 3) & 7]; + *entry =3D group15_reg[op]; + } else if (s->prefix & PREFIX_DATA) { + *entry =3D group15_mem_66[op]; } else { - *entry =3D group15_mem[(modrm >> 3) & 7]; + *entry =3D group15_mem[op]; } } =20 @@ -2094,6 +2115,10 @@ static bool has_cpuid_feature(DisasContext *s, X86CP= UIDFeature cpuid) return true; case X86_FEAT_CMOV: return (s->cpuid_features & CPUID_CMOV); + case X86_FEAT_CLFLUSH: + return (s->cpuid_features & CPUID_CLFLUSH); + case X86_FEAT_FXSR: + return (s->cpuid_features & CPUID_FXSR); case X86_FEAT_F16C: return (s->cpuid_ext_features & CPUID_EXT_F16C); case X86_FEAT_FMA: @@ -2127,6 +2152,8 @@ static bool has_cpuid_feature(DisasContext *s, X86CPU= IDFeature cpuid) =20 case X86_FEAT_AVX: return (s->cpuid_ext_features & CPUID_EXT_AVX); + case X86_FEAT_XSAVE: + return (s->cpuid_ext_features & CPUID_EXT_XSAVE); =20 case X86_FEAT_3DNOW: return (s->cpuid_ext2_features & CPUID_EXT2_3DNOW); @@ -2141,11 +2168,20 @@ static bool has_cpuid_feature(DisasContext *s, X86C= PUIDFeature cpuid) return (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_BMI2); case X86_FEAT_AVX2: return (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_AVX2); + case X86_FEAT_CLFLUSHOPT: + return (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_CLFLUSHOPT); + case X86_FEAT_CLWB: + return (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_CLWB); + case X86_FEAT_FSGSBASE: + return (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_FSGSBASE); case X86_FEAT_SHA_NI: return (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_SHA_NI); =20 case X86_FEAT_CMPCCXADD: return (s->cpuid_7_1_eax_features & CPUID_7_1_EAX_CMPCCXADD); + + case X86_FEAT_XSAVEOPT: + return (s->cpuid_xsave_features & CPUID_XSAVE_XSAVEOPT); } g_assert_not_reached(); } @@ -2480,7 +2516,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) case 0x1a ... 0x1b: /* MPX */ case 0x30 ... 0x35: /* more privileged instructions */ case 0xa2 ... 0xa5: /* CPUID, BT, SHLD */ - case 0xaa ... 0xae: /* RSM, SHRD, grp15 */ + case 0xaa ... 0xad: /* RSM, SHRD */ case 0xb0 ... 0xb1: /* cmpxchg */ case 0xb3: /* btr */ case 0xb8: /* integer ops */ diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index bcb6bccbd75..5ca3764e006 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1653,6 +1653,22 @@ static void gen_EXTRQ_r(DisasContext *s, X86DecodedI= nsn *decode) gen_helper_extrq_r(tcg_env, OP_PTR0, OP_PTR2); } =20 +static void gen_FXRSTOR(DisasContext *s, X86DecodedInsn *decode) +{ + if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) { + gen_NM_exception(s); + } + gen_helper_fxrstor(tcg_env, s->A0); +} + +static void gen_FXSAVE(DisasContext *s, X86DecodedInsn *decode) +{ + if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) { + gen_NM_exception(s); + } + gen_helper_fxsave(tcg_env, s->A0); +} + static void gen_HLT(DisasContext *s, X86DecodedInsn *decode) { #ifdef CONFIG_SYSTEM_ONLY @@ -2000,6 +2016,11 @@ static void gen_LES(DisasContext *s, X86DecodedInsn = *decode) gen_lxx_seg(s, decode, R_ES); } =20 +static void gen_LFENCE(DisasContext *s, X86DecodedInsn *decode) +{ + tcg_gen_mb(TCG_MO_LD_LD | TCG_BAR_SC); +} + static void gen_LFS(DisasContext *s, X86DecodedInsn *decode) { gen_lxx_seg(s, decode, R_FS); @@ -2059,6 +2080,11 @@ static void gen_LSS(DisasContext *s, X86DecodedInsn = *decode) gen_lxx_seg(s, decode, R_SS); } =20 +static void gen_MFENCE(DisasContext *s, X86DecodedInsn *decode) +{ + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); +} + static void gen_MOV(DisasContext *s, X86DecodedInsn *decode) { /* nothing to do! */ @@ -3092,6 +3118,15 @@ static void gen_RCR(DisasContext *s, X86DecodedInsn = *decode) } } =20 +static void gen_RDxxBASE(DisasContext *s, X86DecodedInsn *decode) +{ + TCGv base =3D cpu_seg_base[s->modrm & 8 ? R_GS : R_FS]; + + /* Preserve hflags bits by testing CR4 at runtime. */ + gen_helper_cr4_testbit(tcg_env, tcg_constant_i32(CR4_FSGSBASE_MASK)); + tcg_gen_mov_tl(s->T0, base); +} + static void gen_RET(DisasContext *s, X86DecodedInsn *decode) { int16_t adjust =3D decode->e.op1 =3D=3D X86_TYPE_I ? decode->immediate= : 0; @@ -3372,6 +3407,11 @@ static void gen_SETcc(DisasContext *s, X86DecodedIns= n *decode) gen_setcc1(s, decode->b & 0xf, s->T0); } =20 +static void gen_SFENCE(DisasContext *s, X86DecodedInsn *decode) +{ + tcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC); +} + static void gen_SHA1NEXTE(DisasContext *s, X86DecodedInsn *decode) { gen_helper_sha1nexte(OP_PTR0, OP_PTR1, OP_PTR2); @@ -4042,6 +4082,15 @@ static void gen_WAIT(DisasContext *s, X86DecodedInsn= *decode) } } =20 +static void gen_WRxxBASE(DisasContext *s, X86DecodedInsn *decode) +{ + TCGv base =3D cpu_seg_base[s->modrm & 8 ? R_GS : R_FS]; + + /* Preserve hflags bits by testing CR4 at runtime. */ + gen_helper_cr4_testbit(tcg_env, tcg_constant_i32(CR4_FSGSBASE_MASK)); + tcg_gen_mov_tl(base, s->T0); +} + static void gen_XCHG(DisasContext *s, X86DecodedInsn *decode) { if (s->prefix & PREFIX_LOCK) { @@ -4084,3 +4133,34 @@ static void gen_XOR(DisasContext *s, X86DecodedInsn = *decode) prepare_update1_cc(decode, s, CC_OP_LOGICB + ot); } } + +static void gen_XRSTOR(DisasContext *s, X86DecodedInsn *decode) +{ + TCGv_i64 features =3D tcg_temp_new_i64(); + + tcg_gen_concat_tl_i64(features, cpu_regs[R_EAX], cpu_regs[R_EDX]); + gen_helper_xrstor(tcg_env, s->A0, features); + if (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_MPX) { + /* + * XRSTOR is how MPX is enabled, which changes how + * we translate. Thus we need to end the TB. + */ + s->base.is_jmp =3D DISAS_EOB_NEXT; + } +} + +static void gen_XSAVE(DisasContext *s, X86DecodedInsn *decode) +{ + TCGv_i64 features =3D tcg_temp_new_i64(); + + tcg_gen_concat_tl_i64(features, cpu_regs[R_EAX], cpu_regs[R_EDX]); + gen_helper_xsave(tcg_env, s->A0, features); +} + +static void gen_XSAVEOPT(DisasContext *s, X86DecodedInsn *decode) +{ + TCGv_i64 features =3D tcg_temp_new_i64(); + + tcg_gen_concat_tl_i64(features, cpu_regs[R_EAX], cpu_regs[R_EDX]); + gen_helper_xsave(tcg_env, s->A0, features); +} --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836142; cv=none; d=zohomail.com; s=zohoarc; b=eRuQVQXJomP37Czae+kqGuzcUNgNdOqju1kE4L/Ddd7fuza+9ucrfN7u/fmjs6GFqvdxJbTGQyexYbZgaYbLlRVl/K8GGrVf+tCvxcK3dwHLUgsmJhXRSAcJ276ZqayNBMdY2C7SBxyjX32nIFeLFh/1GlLAxmhOrkzKGfvEPLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836142; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=29vDyAjFlT0oHHuzdskRtBwuTNaHeAQJUG9MkDRPFew=; b=Ge25nf8r7TevDHSrOSHIVL3COPwV0ZFSJqd3VBPSgS0ZEtUg/PYC+bOzh5ij+scpDhHJbfCS8ocjNJs5Uc0zHOqADO4xbnoa+alBdgcPg7UN0Z2L0Js7UfXjGHLkhpD28Z9bk4sF0NBnNIGWxeB72Fi0vaTql711YMBovgZ+tSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836142590407.8761400887918; Sat, 8 Jun 2024 01:42:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFreK-0002y1-OS; Sat, 08 Jun 2024 04:42:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreI-0002sj-Lc for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreG-0001R1-Pk for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:06 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-s6FfGkXwMYC6v_vXAHJhAg-1; Sat, 08 Jun 2024 04:41:58 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a68ce1ac733so157603866b.3 for ; Sat, 08 Jun 2024 01:41:57 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80581716sm359752466b.19.2024.06.08.01.41.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=29vDyAjFlT0oHHuzdskRtBwuTNaHeAQJUG9MkDRPFew=; b=IpAhcWCtiaXUW0ZMXJcQy+UdpcZcAipObvjGEYsCtTgjamrzgS0Ttr8anlymPOcNhZTKfQ bNopdKNaQDDBN+kGh6IV06cnCsv1qZ88PMPrnYsZav6QJ2MLsqSA6ZWFx/epi1PMCQpLMJ ibSOKuU5qregOlPk7wXqLiiIn/DYrhc= X-MC-Unique: s6FfGkXwMYC6v_vXAHJhAg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836116; x=1718440916; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=29vDyAjFlT0oHHuzdskRtBwuTNaHeAQJUG9MkDRPFew=; b=cOVxjVw+O4IfZT0CvYFM0nyPB0IV6QS2oZDG0E3C02vXBYvW8yXyLqLz3g+YR4diUj 60U2VsEuPNizx48k+wEfEO/hOoXrtULTZxjx3Y20aPOyVeKgvyyBH+4LpFpnNQh35Xpu W9ZUBVIFMJXJEJ938lHW59oXApbS+5r7YtL3Tw/Rzdwp7XwuSyXwxnrtorXJs2gVh5TW oly2RZ27oLugNG3DxyZH3YLDTc/NHxPKVOJKBxRfax5IZpFXzUk9nzCKjsI7++Ck/FHS +rBYq3IDBRP19Mi6nUAE+zhPamJdcj+3NNNsxORMDn4Hs6S961cYkRxVw8OtLF/HsY6h GXSg== X-Gm-Message-State: AOJu0YwKWe/566I3Ye2ndsIx5wLmyzRqHWDKgGGD0LECuxkPjfMJl10F uKdJLKicfvc2SpcCIJAfRlcyxIfBXgQlptSjsf5mZsMDCIVhuvSl2SUnKaX6wBvzsxxbgXDDNH1 9ck8cWIt832P5+N91YE3rZOH99iqoKly0t9k0K8rb4OEyPX9KhZCukv/3GAEE1sQbIkNELWLF+U G7V2Zq7adiTyZ+ST7l1LRnQisvBs2vEBcgv0nJ X-Received: by 2002:a17:906:2894:b0:a6f:cae:b141 with SMTP id a640c23a62f3a-a6f0caeb662mr34090266b.2.1717836116018; Sat, 08 Jun 2024 01:41:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTTre6JdsYJKv0cStu2DXFEeBDLgmNMJj3iyIkJEw5Q145TN5oHW5EtfTDf/n3zWzZYM7OcA== X-Received: by 2002:a17:906:2894:b0:a6f:cae:b141 with SMTP id a640c23a62f3a-a6f0caeb662mr34088666b.2.1717836115221; Sat, 08 Jun 2024 01:41:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 11/25] target/i386: replace read_crN helper with read_cr8 Date: Sat, 8 Jun 2024 10:40:59 +0200 Message-ID: <20240608084113.2770363-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836144086100003 Content-Type: text/plain; charset="utf-8" All other control registers are stored plainly in CPUX86State. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/helper.h | 2 +- target/i386/tcg/sysemu/misc_helper.c | 20 +++++--------------- target/i386/tcg/emit.c.inc | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/target/i386/helper.h b/target/i386/helper.h index 2f46cffabd8..eeb8df56eaa 100644 --- a/target/i386/helper.h +++ b/target/i386/helper.h @@ -95,7 +95,7 @@ DEF_HELPER_FLAGS_2(monitor, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_FLAGS_2(mwait, TCG_CALL_NO_WG, noreturn, env, int) DEF_HELPER_1(rdmsr, void, env) DEF_HELPER_1(wrmsr, void, env) -DEF_HELPER_FLAGS_2(read_crN, TCG_CALL_NO_RWG, tl, env, int) +DEF_HELPER_FLAGS_1(read_cr8, TCG_CALL_NO_RWG, tl, env) DEF_HELPER_FLAGS_3(write_crN, TCG_CALL_NO_RWG, void, env, int, tl) #endif /* !CONFIG_USER_ONLY */ =20 diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/= misc_helper.c index 7fa0c5a06de..094aa56a20d 100644 --- a/target/i386/tcg/sysemu/misc_helper.c +++ b/target/i386/tcg/sysemu/misc_helper.c @@ -63,23 +63,13 @@ target_ulong helper_inl(CPUX86State *env, uint32_t port) cpu_get_mem_attrs(env), NULL); } =20 -target_ulong helper_read_crN(CPUX86State *env, int reg) +target_ulong helper_read_cr8(CPUX86State *env) { - target_ulong val; - - switch (reg) { - default: - val =3D env->cr[reg]; - break; - case 8: - if (!(env->hflags2 & HF2_VINTR_MASK)) { - val =3D cpu_get_apic_tpr(env_archcpu(env)->apic_state); - } else { - val =3D env->int_ctl & V_TPR_MASK; - } - break; + if (!(env->hflags2 & HF2_VINTR_MASK)) { + return cpu_get_apic_tpr(env_archcpu(env)->apic_state); + } else { + return env->int_ctl & V_TPR_MASK; } - return val; } =20 void helper_write_crN(CPUX86State *env, int reg, target_ulong t0) diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 5ca3764e006..709ef7b0cb2 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -245,7 +245,7 @@ static void gen_load(DisasContext *s, X86DecodedInsn *d= ecode, int opn, TCGv v) #ifndef CONFIG_USER_ONLY case X86_OP_CR: if (op->n =3D=3D 8) { - gen_helper_read_crN(v, tcg_env, tcg_constant_i32(op->n)); + gen_helper_read_cr8(v, tcg_env); } else { tcg_gen_ld_tl(v, tcg_env, offsetof(CPUX86State, cr[op->n])); } --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836188; cv=none; d=zohomail.com; s=zohoarc; b=TxokLuxX8hBDEt0xktrVSkLUvBt0+b9oXICDshhjPKoxjtLja66B/7BpP8mdkZruLwm7tgf+pgqRaVhdUXlaxAXe+RXe0ermb8D8N5eggLiZqcukPGix9gMVQkJNzyadfRRfyRGYBt5WVI5SAL8HGa1cPwT+uAkHnOO0nC2/eqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836188; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=YUHTlJC/b6fqf2H4PcUhXB3c6Og29MZO04uYtYnBckQ=; b=PVYBJpz24I39oB7iG2R9c2u51i8BNxpyiarUhLj4RDRqR+n7rMHl+gZx6oXIUcP7mQtZhYoKcPshvLmVs3EKvmRCNSvruOJDTvHc3TC6RmlLm8YxqOt1WgY+I3B+vnN6V7vRtl0Dzmv43+VAZdPycXXwdO7yHZxIkn3onxZVYh4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836188786539.6917235385985; Sat, 8 Jun 2024 01:43:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFreJ-0002vq-JU; Sat, 08 Jun 2024 04:42:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreI-0002rp-Hm for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreG-0001R3-Oo for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:06 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-Kv1c3SOZM5S8bUG2RmMNlQ-1; Sat, 08 Jun 2024 04:42:01 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-57c5216e486so819149a12.0 for ; Sat, 08 Jun 2024 01:42:01 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae13faccsm3971676a12.54.2024.06.08.01.41.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YUHTlJC/b6fqf2H4PcUhXB3c6Og29MZO04uYtYnBckQ=; b=BOqCDiJKPHBfNBNJiD0bTZDiIFS5TciV3c0o5oHjW0O6c2kehEhwI+j0t40MEt7K+VtA3s uy7CPUCT/Aim3BxaXlh1AmEUCxT1RDrze/hRcusuF7/IDCgVlccUami1Y0WmucQ1L41gVb rpKaiyDA9yIFd2Eoa4Ku3kSbBbOz+Jk= X-MC-Unique: Kv1c3SOZM5S8bUG2RmMNlQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836119; x=1718440919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YUHTlJC/b6fqf2H4PcUhXB3c6Og29MZO04uYtYnBckQ=; b=VKlH1rhm3o5O8bsGJyxn9BJh5KNPFw/Y1DENea642lWHFWaLI7lwBC8rAZ8y4PeQJP aN6NKGd5YS+p5pfV70UYpSAtDuinv2zgPz4HPXJXj3FNOtguKOCpvcGSjUnlNSFZJ6fr /gwLAf1Pc9qdjQwn3sJZJcMz4l7dOOUAiIgd1aOgsoxgdhzylHZDn6Q/43+EsqEdYJkG 76oc3aaBlyfMJUPpcMS3IiinVA3PJTRcnoJ8cZrtywsgsC+d7FLCCU11QFzH6sXYVm4s zLYLb0cuF3q8DRoCknzudK4W58ujX53xE/6BJ2pG6IHabttX6xX5H2OIApKnlUK0t53D 4DWQ== X-Gm-Message-State: AOJu0YwC4ZC+34DNaNs0PvWMoIDekaOdFfw4xe1vooeydHbSIJV5zIHT ga/BDr+4IBngPLCIh0S0LZS+HSIWzEUVTVA0X7QqHVjm9H7ss4pBL0AVncHv2TjsYWP2kI2q6YC Ym3sb+vFe3pcOC6VC0bETN5zskJ88EGDEPC3vKt4C7M5Pv1KqX33oxAOMuj9ZpxdVYOjtPqc85x BbPJzTfAsxtlLFYwK5+bVh9LCSmb5HAIVNegkG X-Received: by 2002:a50:cc9a:0:b0:578:5851:b0da with SMTP id 4fb4d7f45d1cf-57c5099a2famr2796338a12.36.1717836119035; Sat, 08 Jun 2024 01:41:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtvJth3KNOtWifwme71r7PA2RpVzYxTh/153YSn2uMDXEiPCPVuhW3IOCJU8HT//zFiFce2Q== X-Received: by 2002:a50:cc9a:0:b0:578:5851:b0da with SMTP id 4fb4d7f45d1cf-57c5099a2famr2796329a12.36.1717836118734; Sat, 08 Jun 2024 01:41:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 12/25] target/i386: split X86_CHECK_prot into PE and VM86 checks Date: Sat, 8 Jun 2024 10:41:00 +0200 Message-ID: <20240608084113.2770363-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836190207100009 Content-Type: text/plain; charset="utf-8" SYSENTER is allowed in VM86 mode, but not in real mode. Split the check so that PE and !VM86 are covered by separate bits. Signed-off-by: Paolo Bonzini Acked-by: Richard Henderson --- target/i386/tcg/decode-new.h | 8 ++++++-- target/i386/tcg/decode-new.c.inc | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index 5577f7509aa..b46a9a0ccb3 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -149,8 +149,8 @@ typedef enum X86InsnCheck { X86_CHECK_i64 =3D 1, X86_CHECK_o64 =3D 2, =20 - /* Fault outside protected mode */ - X86_CHECK_prot =3D 4, + /* Fault in vm86 mode */ + X86_CHECK_no_vm86 =3D 4, =20 /* Privileged instruction checks */ X86_CHECK_cpl0 =3D 8, @@ -166,6 +166,10 @@ typedef enum X86InsnCheck { =20 /* Fault if VEX.W=3D0 */ X86_CHECK_W1 =3D 256, + + /* Fault outside protected mode, possibly including vm86 mode */ + X86_CHECK_prot_or_vm86 =3D 512, + X86_CHECK_prot =3D X86_CHECK_prot_or_vm86 | X86_CHECK_no_vm86, } X86InsnCheck; =20 typedef enum X86InsnSpecial { diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 1c6fa39c3eb..f02f7c62647 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -2558,8 +2558,13 @@ static void disas_insn(DisasContext *s, CPUState *cp= u) goto illegal_op; } } - if (decode.e.check & X86_CHECK_prot) { - if (!PE(s) || VM86(s)) { + if (decode.e.check & X86_CHECK_prot_or_vm86) { + if (!PE(s)) { + goto illegal_op; + } + } + if (decode.e.check & X86_CHECK_no_vm86) { + if (VM86(s)) { goto illegal_op; } } --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836188; cv=none; d=zohomail.com; s=zohoarc; b=lhecVJ4lJ9XZ2Nfq2Gm/q7GkZdgxfsZjPJvf749zARsLcVXEXP+S4dvy0KcO6KDSKbhO1i8D3eNR6Rgjd3+P77q3v+8YSHrYFPgRgEPhou1Y5qfwRZ/1NcYT5kIM1dkMRgCSuTveNMJw85elTzPH4LeJOIbxHFLC46XQaJwJgGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836188; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=xaC9zXQghkzg308gTiDQiaWk/1nHtPfFkf86Owt8Y1w=; b=gXdg7Kn/4txf5ZXR/d1zdTJAwHr/07RTPGOMcdqRzJZeva8rIrT+4f+5QcRga55PE6whTwOzZPMt8yUg5kcQxH3UYu6PgU5jBUay6tAMJQv6sQ/RUH1+G3hADu7yKmZkMp3iK50d/Im6/jLC7snuFuTsLiLUzdp+gnxneH5/9ms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836188464548.4456132157753; Sat, 8 Jun 2024 01:43:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFreO-0003JD-9F; Sat, 08 Jun 2024 04:42:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreN-0003Ap-1G for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreK-0001RN-4x for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:10 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-_lNV8iuuOI-uIuRoIvMTTw-1; Sat, 08 Jun 2024 04:42:06 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57c5ea606bbso589466a12.2 for ; Sat, 08 Jun 2024 01:42:05 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57c7156e6c2sm254408a12.9.2024.06.08.01.41.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xaC9zXQghkzg308gTiDQiaWk/1nHtPfFkf86Owt8Y1w=; b=EKUN1JWHzdjIXmjgesvN+8y034yNvg3r7rm/aAXdheXZF3NdF8C1bzlrC3wPF4CrnhI1sf sfmitR+9EuQH4dsx3IGroz8m0a8Pbc9ZeNSI3KWZIV1Gclzh3LAUZJcIYHL/6+ueIAWKYa ocRj0nLIcwx7cRBQkW6RkZGL9eJtBRQ= X-MC-Unique: _lNV8iuuOI-uIuRoIvMTTw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836123; x=1718440923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xaC9zXQghkzg308gTiDQiaWk/1nHtPfFkf86Owt8Y1w=; b=bambRSTGBOiUxjyOrrylrlq+ilLJPCUFj85ZR276xn5uwdX48bwGrlJXWzm52w9q2e gI0lhJWD23ga2f+QR875USQlWrAeCtwrEUWx7c6Qb0Wf7MpWLZnpmQM8YZoeD0CGDURa qfTVavuoQm94rpJfxMEzpBNJ2nGoHVuC6vpHR3+x76EjW+4kXQai7tZRiTUjzCMCGxLf ekAOnVk/CIKFhBNytQilq/4BqWilAT9X3nvKi9eKNu43ZuqrYvXd4i8nJDk+CtCcew0L W69U1956/m+bbbgzMDl1PY2mJD1BdOt5f0xvWDNhhKm2YkpcJFa5ZCVTjuKnAavCBGY/ PSSw== X-Gm-Message-State: AOJu0Yz1OcW8tuG17zywBxEUbFX3RQ2YJsXMIyJx+evDVYpJnmigVMzT YpxjxlIfm1loS6rYx38N58IFb8BDmNiiVUT83nkh1bwN0rjnyBJjLoDbmqcTwgAh0sFMnpkypDo osx7OHyJ+ltr6SJnBur6VasEwLzXkfwpwaF/bBmJR+wlup3phmckFYEsa0bccXdamDvW6+x5D9Q GO/n/zGscIJ8xp8OXiYmi7JFSn5OnJaUbe1y9n X-Received: by 2002:a50:ab4b:0:b0:579:c8cb:ec3d with SMTP id 4fb4d7f45d1cf-57c509992b4mr2769355a12.37.1717836123004; Sat, 08 Jun 2024 01:42:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzpj4GdYSkVyZaRVRRuEjsSa8mmoXx3GvFovkhKYzY9FRikRYiGDxCYCIVo2orShySTW5w4g== X-Received: by 2002:a50:ab4b:0:b0:579:c8cb:ec3d with SMTP id 4fb4d7f45d1cf-57c509992b4mr2769341a12.37.1717836122096; Sat, 08 Jun 2024 01:42:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 13/25] target/i386: convert non-grouped, helper-based 2-byte opcodes Date: Sat, 8 Jun 2024 10:41:01 +0200 Message-ID: <20240608084113.2770363-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836190261100011 Content-Type: text/plain; charset="utf-8" These have very simple generators and no need for complex group decoding. Apart from LAR/LSL which are simplified to use gen_op_deposit_reg_v and movcond, the code is generally lifted from translate.c into the generators. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.h | 7 ++ target/i386/tcg/seg_helper.c | 16 ++-- target/i386/tcg/translate.c | 148 ------------------------------ target/i386/tcg/decode-new.c.inc | 48 +++++++--- target/i386/tcg/emit.c.inc | 151 +++++++++++++++++++++++++++++++ 5 files changed, 202 insertions(+), 168 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index b46a9a0ccb3..c9f958bb0e5 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -170,6 +170,13 @@ typedef enum X86InsnCheck { /* Fault outside protected mode, possibly including vm86 mode */ X86_CHECK_prot_or_vm86 =3D 512, X86_CHECK_prot =3D X86_CHECK_prot_or_vm86 | X86_CHECK_no_vm86, + + /* Fault outside SMM */ + X86_CHECK_smm =3D 1024, + + /* Vendor-specific checks for Intel/AMD differences */ + X86_CHECK_i64_amd =3D 2048, + X86_CHECK_o64_intel =3D 4096, } X86InsnCheck; =20 typedef enum X86InsnSpecial { diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 715db1f2326..aee3d19f29b 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -2265,11 +2265,11 @@ void helper_sysexit(CPUX86State *env, int dflag) target_ulong helper_lsl(CPUX86State *env, target_ulong selector1) { unsigned int limit; - uint32_t e1, e2, eflags, selector; + uint32_t e1, e2, selector; int rpl, dpl, cpl, type; =20 selector =3D selector1 & 0xffff; - eflags =3D cpu_cc_compute_all(env); + assert(CC_OP =3D=3D CC_OP_EFLAGS); if ((selector & 0xfffc) =3D=3D 0) { goto fail; } @@ -2301,22 +2301,22 @@ target_ulong helper_lsl(CPUX86State *env, target_ul= ong selector1) } if (dpl < cpl || dpl < rpl) { fail: - CC_SRC =3D eflags & ~CC_Z; + CC_SRC &=3D ~CC_Z; return 0; } } limit =3D get_seg_limit(e1, e2); - CC_SRC =3D eflags | CC_Z; + CC_SRC |=3D CC_Z; return limit; } =20 target_ulong helper_lar(CPUX86State *env, target_ulong selector1) { - uint32_t e1, e2, eflags, selector; + uint32_t e1, e2, selector; int rpl, dpl, cpl, type; =20 selector =3D selector1 & 0xffff; - eflags =3D cpu_cc_compute_all(env); + assert(CC_OP =3D=3D CC_OP_EFLAGS); if ((selector & 0xfffc) =3D=3D 0) { goto fail; } @@ -2351,11 +2351,11 @@ target_ulong helper_lar(CPUX86State *env, target_ul= ong selector1) } if (dpl < cpl || dpl < rpl) { fail: - CC_SRC =3D eflags & ~CC_Z; + CC_SRC &=3D ~CC_Z; return 0; } } - CC_SRC =3D eflags | CC_Z; + CC_SRC |=3D CC_Z; return e2 & 0x00f0ff00; } =20 diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index ebae745ecba..4b2f7488022 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -246,7 +246,6 @@ STUB_HELPER(mwait, TCGv_env env, TCGv_i32 pc_ofs) STUB_HELPER(outb, TCGv_env env, TCGv_i32 port, TCGv_i32 val) STUB_HELPER(outw, TCGv_env env, TCGv_i32 port, TCGv_i32 val) STUB_HELPER(outl, TCGv_env env, TCGv_i32 port, TCGv_i32 val) -STUB_HELPER(rdmsr, TCGv_env env) STUB_HELPER(stgi, TCGv_env env) STUB_HELPER(svm_check_intercept, TCGv_env env, TCGv_i32 type) STUB_HELPER(vmload, TCGv_env env, TCGv_i32 aflag) @@ -254,7 +253,6 @@ STUB_HELPER(vmmcall, TCGv_env env) STUB_HELPER(vmrun, TCGv_env env, TCGv_i32 aflag, TCGv_i32 pc_ofs) STUB_HELPER(vmsave, TCGv_env env, TCGv_i32 aflag) STUB_HELPER(write_crN, TCGv_env env, TCGv_i32 reg, TCGv val) -STUB_HELPER(wrmsr, TCGv_env env) #endif =20 static void gen_jmp_rel(DisasContext *s, MemOp ot, int diff, int tb_num); @@ -3470,97 +3468,6 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) } gen_op_mov_reg_v(s, ot, reg, s->T0); break; - case 0x130: /* wrmsr */ - case 0x132: /* rdmsr */ - if (check_cpl0(s)) { - gen_update_cc_op(s); - gen_update_eip_cur(s); - if (b & 2) { - gen_helper_rdmsr(tcg_env); - } else { - gen_helper_wrmsr(tcg_env); - s->base.is_jmp =3D DISAS_EOB_NEXT; - } - } - break; - case 0x131: /* rdtsc */ - gen_update_cc_op(s); - gen_update_eip_cur(s); - translator_io_start(&s->base); - gen_helper_rdtsc(tcg_env); - break; - case 0x133: /* rdpmc */ - gen_update_cc_op(s); - gen_update_eip_cur(s); - gen_helper_rdpmc(tcg_env); - s->base.is_jmp =3D DISAS_NORETURN; - break; - case 0x134: /* sysenter */ - /* For AMD SYSENTER is not valid in long mode */ - if (LMA(s) && env->cpuid_vendor1 !=3D CPUID_VENDOR_INTEL_1) { - goto illegal_op; - } - if (!PE(s)) { - gen_exception_gpf(s); - } else { - gen_helper_sysenter(tcg_env); - s->base.is_jmp =3D DISAS_EOB_ONLY; - } - break; - case 0x135: /* sysexit */ - /* For AMD SYSEXIT is not valid in long mode */ - if (LMA(s) && env->cpuid_vendor1 !=3D CPUID_VENDOR_INTEL_1) { - goto illegal_op; - } - if (!PE(s) || CPL(s) !=3D 0) { - gen_exception_gpf(s); - } else { - gen_helper_sysexit(tcg_env, tcg_constant_i32(dflag - 1)); - s->base.is_jmp =3D DISAS_EOB_ONLY; - } - break; - case 0x105: /* syscall */ - /* For Intel SYSCALL is only valid in long mode */ - if (!LMA(s) && env->cpuid_vendor1 =3D=3D CPUID_VENDOR_INTEL_1) { - goto illegal_op; - } - gen_update_cc_op(s); - gen_update_eip_cur(s); - gen_helper_syscall(tcg_env, cur_insn_len_i32(s)); - /* condition codes are modified only in long mode */ - if (LMA(s)) { - assume_cc_op(s, CC_OP_EFLAGS); - } - /* TF handling for the syscall insn is different. The TF bit is c= hecked - after the syscall insn completes. This allows #DB to not be - generated after one has entered CPL0 if TF is set in FMASK. */ - s->base.is_jmp =3D DISAS_EOB_RECHECK_TF; - break; - case 0x107: /* sysret */ - /* For Intel SYSRET is only valid in long mode */ - if (!LMA(s) && env->cpuid_vendor1 =3D=3D CPUID_VENDOR_INTEL_1) { - goto illegal_op; - } - if (!PE(s) || CPL(s) !=3D 0) { - gen_exception_gpf(s); - } else { - gen_helper_sysret(tcg_env, tcg_constant_i32(dflag - 1)); - /* condition codes are modified only in long mode */ - if (LMA(s)) { - assume_cc_op(s, CC_OP_EFLAGS); - } - /* TF handling for the sysret insn is different. The TF bit is - checked after the sysret insn completes. This allows #DB to= be - generated "as if" the syscall insn in userspace has just - completed. */ - s->base.is_jmp =3D DISAS_EOB_RECHECK_TF; - } - break; - case 0x1a2: /* cpuid */ - gen_update_cc_op(s); - gen_update_eip_cur(s); - gen_helper_cpuid(tcg_env); - break; case 0x100: modrm =3D x86_ldub_code(env, s); mod =3D (modrm >> 6) & 3; @@ -3964,39 +3871,6 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) } break; =20 - case 0x108: /* invd */ - case 0x109: /* wbinvd; wbnoinvd with REPZ prefix */ - if (check_cpl0(s)) { - gen_svm_check_intercept(s, (b & 1) ? SVM_EXIT_WBINVD : SVM_EXI= T_INVD); - /* nothing to do */ - } - break; - case 0x102: /* lar */ - case 0x103: /* lsl */ - { - TCGLabel *label1; - TCGv t0; - if (!PE(s) || VM86(s)) - goto illegal_op; - ot =3D dflag !=3D MO_16 ? MO_32 : MO_16; - modrm =3D x86_ldub_code(env, s); - reg =3D ((modrm >> 3) & 7) | REX_R(s); - gen_ld_modrm(env, s, modrm, MO_16); - t0 =3D tcg_temp_new(); - gen_update_cc_op(s); - if (b =3D=3D 0x102) { - gen_helper_lar(t0, tcg_env, s->T0); - } else { - gen_helper_lsl(t0, tcg_env, s->T0); - } - tcg_gen_andi_tl(s->tmp0, cpu_cc_src, CC_Z); - label1 =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, s->tmp0, 0, label1); - gen_op_mov_reg_v(s, ot, reg, t0); - gen_set_label(label1); - set_cc_op(s, CC_OP_EFLAGS); - } - break; case 0x11a: modrm =3D x86_ldub_code(env, s); if (s->flags & HF_MPX_EN_MASK) { @@ -4188,28 +4062,6 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) } gen_nop_modrm(env, s, modrm); break; - - case 0x106: /* clts */ - if (check_cpl0(s)) { - gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0); - gen_helper_clts(tcg_env); - /* abort block because static cpu state changed */ - s->base.is_jmp =3D DISAS_EOB_NEXT; - } - break; - case 0x1aa: /* rsm */ - gen_svm_check_intercept(s, SVM_EXIT_RSM); - if (!(s->flags & HF_SMM_MASK)) - goto illegal_op; -#ifdef CONFIG_USER_ONLY - /* we should not be in SMM mode */ - g_assert_not_reached(); -#else - gen_helper_rsm(tcg_env); - assume_cc_op(s, CC_OP_EFLAGS); -#endif /* CONFIG_USER_ONLY */ - s->base.is_jmp =3D DISAS_EOB_ONLY; - break; case 0x1b8: /* SSE4.2 popcnt */ if ((prefixes & (PREFIX_REPZ | PREFIX_LOCK | PREFIX_REPNZ)) !=3D PREFIX_REPZ) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index f02f7c62647..1db9d1e2bc3 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -223,6 +223,8 @@ #define vex13 .vex_class =3D 13, =20 #define chk(a) .check =3D X86_CHECK_##a, +#define chk2(a, b) .check =3D X86_CHECK_##a | X86_CHECK_##b, +#define chk3(a, b, c) .check =3D X86_CHECK_##a | X86_CHECK_##b | X86_CHECK= _##c, #define svm(a) .intercept =3D SVM_EXIT_##a, .has_intercept =3D true, =20 #define avx2_256 .vex_special =3D X86_VEX_AVX2_256, @@ -1027,6 +1029,12 @@ static void decode_MOV_CR_DR(DisasContext *s, CPUX86= State *env, X86OpEntry *entr } =20 static const X86OpEntry opcodes_0F[256] =3D { + [0x02] =3D X86_OP_ENTRYwr(LAR, G,v, E,w, chk(prot)), + [0x03] =3D X86_OP_ENTRYwr(LSL, G,v, E,w, chk(prot)), + [0x05] =3D X86_OP_ENTRY0(SYSCALL, chk(o64_in= tel)), + [0x06] =3D X86_OP_ENTRY0(CLTS, chk(cpl0) = svm(WRITE_CR0)), + [0x07] =3D X86_OP_ENTRY0(SYSRET, chk3(o64_i= ntel, prot, cpl0)), + [0x10] =3D X86_OP_GROUP0(0F10), [0x11] =3D X86_OP_GROUP0(0F11), [0x12] =3D X86_OP_GROUP0(0F12), @@ -1042,6 +1050,13 @@ static const X86OpEntry opcodes_0F[256] =3D { [0x22] =3D X86_OP_GROUPwr(MOV_CR_DR, C,y, R,y, zextT0 chk(cpl0) svm(= WRITE_CR0)), [0x23] =3D X86_OP_GROUPwr(MOV_CR_DR, D,y, R,y, zextT0 chk(cpl0) svm(= WRITE_DR0)), =20 + [0x30] =3D X86_OP_ENTRY0(WRMSR, chk(cpl0)), + [0x31] =3D X86_OP_ENTRY0(RDTSC), + [0x32] =3D X86_OP_ENTRY0(RDMSR, chk(cpl0)), + [0x33] =3D X86_OP_ENTRY0(RDPMC), + [0x34] =3D X86_OP_ENTRY0(SYSENTER, chk2(i64_a= md, prot_or_vm86)), + [0x35] =3D X86_OP_ENTRY0(SYSEXIT, chk3(i64_a= md, prot, cpl0)), + [0x40] =3D X86_OP_ENTRY2(CMOVcc, G,v, E,v, cpuid(CMOV)), [0x41] =3D X86_OP_ENTRY2(CMOVcc, G,v, E,v, cpuid(CMOV)), [0x42] =3D X86_OP_ENTRY2(CMOVcc, G,v, E,v, cpuid(CMOV)), @@ -1098,6 +1113,7 @@ static const X86OpEntry opcodes_0F[256] =3D { =20 [0xa0] =3D X86_OP_ENTRYr(PUSH, FS, w), [0xa1] =3D X86_OP_ENTRYw(POP, FS, w), + [0xa2] =3D X86_OP_ENTRY0(CPUID), =20 [0xb2] =3D X86_OP_ENTRY3(LSS, G,v, EM,p, None, None), [0xb4] =3D X86_OP_ENTRY3(LFS, G,v, EM,p, None, None), @@ -1138,6 +1154,8 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xf6] =3D X86_OP_ENTRY3(PSADBW, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), [0xf7] =3D X86_OP_ENTRY3(MASKMOV, None,None, V,dq, U,dq, vex4_unal av= x2_256 mmx p_00_66), =20 + [0x08] =3D X86_OP_ENTRY0(NOP, svm(INVD)), + [0x09] =3D X86_OP_ENTRY0(NOP, svm(WBINVD)), [0x0b] =3D X86_OP_ENTRY0(UD), /* UD2 */ [0x0d] =3D X86_OP_ENTRY1(NOP, M,v), /* 3DNow! prefetch */ [0x0e] =3D X86_OP_ENTRY0(EMMS, cpuid(3DNO= W)), /* femms */ @@ -1221,6 +1239,7 @@ static const X86OpEntry opcodes_0F[256] =3D { =20 [0xa8] =3D X86_OP_ENTRYr(PUSH, GS, w), [0xa9] =3D X86_OP_ENTRYw(POP, GS, w), + [0xaa] =3D X86_OP_ENTRY0(RSM, chk(smm) svm(RSM)), [0xae] =3D X86_OP_GROUP0(group15), /* * It's slightly more efficient to put Ev operand in T0 and allow gen_= IMUL3 @@ -2511,12 +2530,10 @@ static void disas_insn(DisasContext *s, CPUState *c= pu) if (b =3D=3D 0x0f) { b =3D x86_ldub_code(env, s); switch (b) { - case 0x00 ... 0x03: /* mostly privileged instructions */ - case 0x05 ... 0x09: + case 0x00 ... 0x01: /* mostly privileged instructions */ case 0x1a ... 0x1b: /* MPX */ - case 0x30 ... 0x35: /* more privileged instructions */ - case 0xa2 ... 0xa5: /* CPUID, BT, SHLD */ - case 0xaa ... 0xad: /* RSM, SHRD */ + case 0xa3 ... 0xa5: /* BT, SHLD */ + case 0xab ... 0xad: /* BTS, SHRD */ case 0xb0 ... 0xb1: /* cmpxchg */ case 0xb3: /* btr */ case 0xb8: /* integer ops */ @@ -2548,13 +2565,18 @@ static void disas_insn(DisasContext *s, CPUState *c= pu) =20 /* Checks that result in #UD come first. */ if (decode.e.check) { - if (decode.e.check & X86_CHECK_i64) { - if (CODE64(s)) { + if (CODE64(s)) { + if (decode.e.check & X86_CHECK_i64) { goto illegal_op; } - } - if (decode.e.check & X86_CHECK_o64) { - if (!CODE64(s)) { + if ((decode.e.check & X86_CHECK_i64_amd) && env->cpuid_vendor1= !=3D CPUID_VENDOR_INTEL_1) { + goto illegal_op; + } + } else { + if (decode.e.check & X86_CHECK_o64) { + goto illegal_op; + } + if ((decode.e.check & X86_CHECK_o64_intel) && env->cpuid_vendo= r1 =3D=3D CPUID_VENDOR_INTEL_1) { goto illegal_op; } } @@ -2638,8 +2660,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) * exceptions if there is no memory operand). Exceptions are * vm86 checks (INTn, IRET, PUSHF/POPF), RSM and XSETBV (!). * - * RSM and XSETBV will be handled in the gen_* functions - * instead of using chk(). + * XSETBV will check for CPL0 in the gen_* function instead of using c= hk(). */ if (decode.e.check & X86_CHECK_cpl0) { if (CPL(s) !=3D 0) { @@ -2651,6 +2672,9 @@ static void disas_insn(DisasContext *s, CPUState *cpu) tcg_constant_i32(decode.e.intercept= )); } if (decode.e.check) { + if ((decode.e.check & X86_CHECK_smm) && !(s->flags & HF_SMM_MASK))= { + goto illegal_op; + } if ((decode.e.check & X86_CHECK_vm86_iopl) && VM86(s)) { if (IOPL(s) < 3) { goto gp_fault; diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 709ef7b0cb2..f788e1fa4c8 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1410,6 +1410,13 @@ static void gen_CLI(DisasContext *s, X86DecodedInsn = *decode) gen_reset_eflags(s, IF_MASK); } =20 +static void gen_CLTS(DisasContext *s, X86DecodedInsn *decode) +{ + gen_helper_clts(tcg_env); + /* abort block because static cpu state changed */ + s->base.is_jmp =3D DISAS_EOB_NEXT; +} + static void gen_CMC(DisasContext *s, X86DecodedInsn *decode) { gen_compute_eflags(s); @@ -1534,6 +1541,13 @@ static void gen_CMPS(DisasContext *s, X86DecodedInsn= *decode) } } =20 +static void gen_CPUID(DisasContext *s, X86DecodedInsn *decode) +{ + gen_update_cc_op(s); + gen_update_eip_cur(s); + gen_helper_cpuid(tcg_env); +} + static void gen_CRC32(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[2].ot; @@ -1977,6 +1991,23 @@ static void gen_LAHF(DisasContext *s, X86DecodedInsn= *decode) tcg_gen_deposit_tl(cpu_regs[R_EAX], cpu_regs[R_EAX], s->T0, 8, 8); } =20 +static void gen_LAR(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[0].ot; + TCGv result =3D tcg_temp_new(); + TCGv dest; + + gen_compute_eflags(s); + gen_update_cc_op(s); + gen_helper_lar(result, tcg_env, s->T0); + + /* Perform writeback here to skip it if ZF=3D0. */ + decode->op[0].unit =3D X86_OP_SKIP; + dest =3D gen_op_deposit_reg_v(s, ot, decode->op[0].n, result, result); + tcg_gen_movcond_tl(TCG_COND_TSTNE, dest, cpu_cc_src, tcg_constant_tl(C= C_Z), + result, dest); +} + static void gen_LDMXCSR(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0); @@ -2075,6 +2106,23 @@ static void gen_LOOPNE(DisasContext *s, X86DecodedIn= sn *decode) gen_conditional_jump_labels(s, decode->immediate, not_taken, taken); } =20 +static void gen_LSL(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[0].ot; + TCGv result =3D tcg_temp_new(); + TCGv dest; + + gen_compute_eflags(s); + gen_update_cc_op(s); + gen_helper_lsl(result, tcg_env, s->T0); + + /* Perform writeback here to skip it if ZF=3D0. */ + decode->op[0].unit =3D X86_OP_SKIP; + dest =3D gen_op_deposit_reg_v(s, ot, decode->op[0].n, result, result); + tcg_gen_movcond_tl(TCG_COND_TSTNE, dest, cpu_cc_src, tcg_constant_tl(C= C_Z), + result, dest); +} + static void gen_LSS(DisasContext *s, X86DecodedInsn *decode) { gen_lxx_seg(s, decode, R_SS); @@ -3118,6 +3166,41 @@ static void gen_RCR(DisasContext *s, X86DecodedInsn = *decode) } } =20 +#ifdef CONFIG_USER_ONLY +static void gen_unreachable(DisasContext *s, X86DecodedInsn *decode) +{ + g_assert_not_reached(); +} +#endif + +#ifndef CONFIG_USER_ONLY +static void gen_RDMSR(DisasContext *s, X86DecodedInsn *decode) +{ + gen_update_cc_op(s); + gen_update_eip_cur(s); + gen_helper_rdmsr(tcg_env); +} +#else +#define gen_RDMSR gen_unreachable +#endif + +static void gen_RDPMC(DisasContext *s, X86DecodedInsn *decode) +{ + gen_update_cc_op(s); + gen_update_eip_cur(s); + translator_io_start(&s->base); + gen_helper_rdpmc(tcg_env); + s->base.is_jmp =3D DISAS_NORETURN; +} + +static void gen_RDTSC(DisasContext *s, X86DecodedInsn *decode) +{ + gen_update_cc_op(s); + gen_update_eip_cur(s); + translator_io_start(&s->base); + gen_helper_rdtsc(tcg_env); +} + static void gen_RDxxBASE(DisasContext *s, X86DecodedInsn *decode) { TCGv base =3D cpu_seg_base[s->modrm & 8 ? R_GS : R_FS]; @@ -3290,6 +3373,17 @@ static void gen_RORX(DisasContext *s, X86DecodedInsn= *decode) } } =20 +#ifndef CONFIG_USER_ONLY +static void gen_RSM(DisasContext *s, X86DecodedInsn *decode) +{ + gen_helper_rsm(tcg_env); + assume_cc_op(s, CC_OP_EFLAGS); + s->base.is_jmp =3D DISAS_EOB_ONLY; +} +#else +#define gen_RSM gen_UD +#endif + static void gen_SAHF(DisasContext *s, X86DecodedInsn *decode) { if (CODE64(s) && !(s->cpuid_ext3_features & CPUID_EXT3_LAHF_LM)) { @@ -3586,6 +3680,51 @@ static void gen_SUB(DisasContext *s, X86DecodedInsn = *decode) prepare_update2_cc(decode, s, CC_OP_SUBB + ot); } =20 +static void gen_SYSCALL(DisasContext *s, X86DecodedInsn *decode) +{ + gen_update_cc_op(s); + gen_update_eip_cur(s); + gen_helper_syscall(tcg_env, cur_insn_len_i32(s)); + if (LMA(s)) { + assume_cc_op(s, CC_OP_EFLAGS); + } + + /* + * TF handling for the syscall insn is different. The TF bit is checked + * after the syscall insn completes. This allows #DB to not be + * generated after one has entered CPL0 if TF is set in FMASK. + */ + s->base.is_jmp =3D DISAS_EOB_RECHECK_TF; +} + +static void gen_SYSENTER(DisasContext *s, X86DecodedInsn *decode) +{ + gen_helper_sysenter(tcg_env); + s->base.is_jmp =3D DISAS_EOB_ONLY; +} + +static void gen_SYSEXIT(DisasContext *s, X86DecodedInsn *decode) +{ + gen_helper_sysexit(tcg_env, tcg_constant_i32(s->dflag - 1)); + s->base.is_jmp =3D DISAS_EOB_ONLY; +} + +static void gen_SYSRET(DisasContext *s, X86DecodedInsn *decode) +{ + gen_helper_sysret(tcg_env, tcg_constant_i32(s->dflag - 1)); + if (LMA(s)) { + assume_cc_op(s, CC_OP_EFLAGS); + } + + /* + * TF handling for the sysret insn is different. The TF bit is checked + * after the sysret insn completes. This allows #DB to be + * generated "as if" the syscall insn in userspace has just + * completed. + */ + s->base.is_jmp =3D DISAS_EOB_RECHECK_TF; +} + static void gen_UD(DisasContext *s, X86DecodedInsn *decode) { gen_illegal_opcode(s); @@ -4082,6 +4221,18 @@ static void gen_WAIT(DisasContext *s, X86DecodedInsn= *decode) } } =20 +#ifndef CONFIG_USER_ONLY +static void gen_WRMSR(DisasContext *s, X86DecodedInsn *decode) +{ + gen_update_cc_op(s); + gen_update_eip_cur(s); + gen_helper_wrmsr(tcg_env); + s->base.is_jmp =3D DISAS_EOB_NEXT; +} +#else +#define gen_WRMSR gen_unreachable +#endif + static void gen_WRxxBASE(DisasContext *s, X86DecodedInsn *decode) { TCGv base =3D cpu_seg_base[s->modrm & 8 ? R_GS : R_FS]; --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836150; cv=none; d=zohomail.com; s=zohoarc; b=XgORGZKH5M5KLHqqHP45brDAG4bU0LnGfVefQGlQ9znR/cr2FwilW93CM1MhZzk3axjHULn8f89v9RsXTyZMD24Ffnr5lVNr2QvqBXZxfLYaOddtOlvp56tIyuJl9OVZl1irZpFx1USiiYK6lLr+tvnyCv6z0L4pePYFBhGQ+YY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836150; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=a1zoM1nm/tsACsUwP9/+h6Y84eJY8dzq5Oyco8ZwLKg=; b=jXQH9yMmH4BBUNSQkLFITszIL+gWPjOUEqLHEqlYeADWnPMQHqXeUKnY1xx6Iu2uBYSXGTGsQpPScT/Zd8+XRb3TKt37XNGglBRcsuV0X0QqSJGGJmmfCAp3v+q0mT6eJqtrxiYqI8Z+rWcVoiAFKs07fBr7kya3UACSEEDhXaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836150930874.2212517569084; Sat, 8 Jun 2024 01:42:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFreQ-0003Rf-Vz; Sat, 08 Jun 2024 04:42:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreP-0003PT-Ra for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreN-0001RY-FO for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:13 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-526-Vk2vTNWTOBiNzvIcu8hWEw-1; Sat, 08 Jun 2024 04:42:07 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a6def6e9ef2so114245166b.0 for ; Sat, 08 Jun 2024 01:42:07 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c805ccb1csm356676066b.80.2024.06.08.01.42.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a1zoM1nm/tsACsUwP9/+h6Y84eJY8dzq5Oyco8ZwLKg=; b=f5Nd5m7xBHEY6SleZ59gdGem6J2jGBpiJt+9Ioux44m80c6EeumxDdKvJZItY1eGoyUqDS gbAQS92ApAsnOxd5sba9GwFSIZs+IHTYskaf5E7BYO4hwwmoIoyaDJ1oDNlkys6SfUvICx Ush13rdR50PaW4p8D/5vUvUGljrV3Lw= X-MC-Unique: Vk2vTNWTOBiNzvIcu8hWEw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836125; x=1718440925; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a1zoM1nm/tsACsUwP9/+h6Y84eJY8dzq5Oyco8ZwLKg=; b=OeD7V8Skzi4kVii1lvV0fd/WA/Hp9ViNB31BpXr6m4XFoRgt2Z6EXgZuQvhF09hHqa nEYzfHL7aiW7sWk+t4+Z0MJsBkFprC8PxxxKGsiaro97Y4NnRuS8vJWKvXtaZi2UWpFU B6oxA/f/1NpMhpei3uY396tXCe4iS3iFQrGiCKlSaJScwsWFiZ2qJRNDXZvd/FtB3xjj G7l5bZUKM6P4iwJNWGKKs1MFMC/BBlRAA/kfYASwfKF3EnY4whbbzkKMksz2hJ3uBggS npjmgwXx155P6gmi9PmCG02gZ6rXfj4iVpKxndmt+6hdiQlM3RxLGdUEDQxy0PZrJNRK 0izA== X-Gm-Message-State: AOJu0YxJit0MjZYoA7T0cY3W3tgCer/xU6SCHNP4oBhnLQHmbwqx2Coa NXpw0sRNpPZdDcpVa+ZXAessUXsnjk9TIiFiCqO/WTs3cf6hWnlGKXfEGBy4MUGXLLsMiKyuKNI 1sR+jyuMUMUjKdDs5o2+Lmm0kKyVLE7tu6bzxhcCHpetTgAtloQMUpt0aT37HRrj2ubimEKIsxT hVTP4rCsWtHlaLtdwe6ZW6bSG81yFBkfiapjxQ X-Received: by 2002:a17:906:4a52:b0:a6e:f99b:cd57 with SMTP id a640c23a62f3a-a6ef99bce17mr121058566b.34.1717836124989; Sat, 08 Jun 2024 01:42:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzKwnGViOYIDuEblDXq7maaj8YDFCs9PD24jWd5pvo3NdSM6AaGKTJ5zpanlwROuvUOuUjBQ== X-Received: by 2002:a17:906:4a52:b0:a6e:f99b:cd57 with SMTP id a640c23a62f3a-a6ef99bce17mr121057766b.34.1717836124355; Sat, 08 Jun 2024 01:42:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 14/25] target/i386: convert bit test instructions to new decoder Date: Sat, 8 Jun 2024 10:41:02 +0200 Message-ID: <20240608084113.2770363-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836152196100011 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 3 + target/i386/tcg/translate.c | 147 +------------------------------ target/i386/tcg/decode-new.c.inc | 45 +++++++--- target/i386/tcg/emit.c.inc | 130 ++++++++++++++++++++++++++- 4 files changed, 166 insertions(+), 159 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index c9f958bb0e5..f781bb5bbec 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -188,6 +188,9 @@ typedef enum X86InsnSpecial { /* Always locked if it has a memory operand (XCHG) */ X86_SPECIAL_Locked, =20 + /* Like HasLock, but also operand 2 provides bit displacement into mem= ory. */ + X86_SPECIAL_BitTest, + /* Do not load effective address in s->A0 */ X86_SPECIAL_NoLoadEA, =20 diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 4b2f7488022..c3843092350 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -729,11 +729,6 @@ static void gen_extu(MemOp ot, TCGv reg) gen_ext_tl(reg, reg, ot, false); } =20 -static void gen_exts(MemOp ot, TCGv reg) -{ - gen_ext_tl(reg, reg, ot, true); -} - static void gen_op_j_ecx(DisasContext *s, TCGCond cond, TCGLabel *label1) { TCGv tmp =3D gen_ext_tl(NULL, cpu_regs[R_ECX], s->aflag, false); @@ -3078,7 +3073,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) MemOp dflag =3D s->dflag; int shift; MemOp ot; - int modrm, reg, rm, mod, op, opreg, val; + int modrm, reg, rm, mod, op, opreg; =20 /* now check op code */ switch (b) { @@ -3278,146 +3273,6 @@ static void disas_insn_old(DisasContext *s, CPUStat= e *cpu, int b) gen_shiftd_rm_T1(s, ot, opreg, op, cpu_regs[R_ECX]); } break; - - /************************/ - /* bit operations */ - case 0x1ba: /* bt/bts/btr/btc Gv, im */ - ot =3D dflag; - modrm =3D x86_ldub_code(env, s); - op =3D (modrm >> 3) & 7; - mod =3D (modrm >> 6) & 3; - rm =3D (modrm & 7) | REX_B(s); - if (mod !=3D 3) { - s->rip_offset =3D 1; - gen_lea_modrm(env, s, modrm); - if (!(s->prefix & PREFIX_LOCK)) { - gen_op_ld_v(s, ot, s->T0, s->A0); - } - } else { - gen_op_mov_v_reg(s, ot, s->T0, rm); - } - /* load shift */ - val =3D x86_ldub_code(env, s); - tcg_gen_movi_tl(s->T1, val); - if (op < 4) - goto unknown_op; - op -=3D 4; - goto bt_op; - case 0x1a3: /* bt Gv, Ev */ - op =3D 0; - goto do_btx; - case 0x1ab: /* bts */ - op =3D 1; - goto do_btx; - case 0x1b3: /* btr */ - op =3D 2; - goto do_btx; - case 0x1bb: /* btc */ - op =3D 3; - do_btx: - ot =3D dflag; - modrm =3D x86_ldub_code(env, s); - reg =3D ((modrm >> 3) & 7) | REX_R(s); - mod =3D (modrm >> 6) & 3; - rm =3D (modrm & 7) | REX_B(s); - gen_op_mov_v_reg(s, MO_32, s->T1, reg); - if (mod !=3D 3) { - AddressParts a =3D gen_lea_modrm_0(env, s, modrm); - /* specific case: we need to add a displacement */ - gen_exts(ot, s->T1); - tcg_gen_sari_tl(s->tmp0, s->T1, 3 + ot); - tcg_gen_shli_tl(s->tmp0, s->tmp0, ot); - tcg_gen_add_tl(s->A0, gen_lea_modrm_1(s, a, false), s->tmp0); - gen_lea_v_seg(s, s->A0, a.def_seg, s->override); - if (!(s->prefix & PREFIX_LOCK)) { - gen_op_ld_v(s, ot, s->T0, s->A0); - } - } else { - gen_op_mov_v_reg(s, ot, s->T0, rm); - } - bt_op: - tcg_gen_andi_tl(s->T1, s->T1, (1 << (3 + ot)) - 1); - tcg_gen_movi_tl(s->tmp0, 1); - tcg_gen_shl_tl(s->tmp0, s->tmp0, s->T1); - if (s->prefix & PREFIX_LOCK) { - switch (op) { - case 0: /* bt */ - /* Needs no atomic ops; we suppressed the normal - memory load for LOCK above so do it now. */ - gen_op_ld_v(s, ot, s->T0, s->A0); - break; - case 1: /* bts */ - tcg_gen_atomic_fetch_or_tl(s->T0, s->A0, s->tmp0, - s->mem_index, ot | MO_LE); - break; - case 2: /* btr */ - tcg_gen_not_tl(s->tmp0, s->tmp0); - tcg_gen_atomic_fetch_and_tl(s->T0, s->A0, s->tmp0, - s->mem_index, ot | MO_LE); - break; - default: - case 3: /* btc */ - tcg_gen_atomic_fetch_xor_tl(s->T0, s->A0, s->tmp0, - s->mem_index, ot | MO_LE); - break; - } - tcg_gen_shr_tl(s->tmp4, s->T0, s->T1); - } else { - tcg_gen_shr_tl(s->tmp4, s->T0, s->T1); - switch (op) { - case 0: /* bt */ - /* Data already loaded; nothing to do. */ - break; - case 1: /* bts */ - tcg_gen_or_tl(s->T0, s->T0, s->tmp0); - break; - case 2: /* btr */ - tcg_gen_andc_tl(s->T0, s->T0, s->tmp0); - break; - default: - case 3: /* btc */ - tcg_gen_xor_tl(s->T0, s->T0, s->tmp0); - break; - } - if (op !=3D 0) { - if (mod !=3D 3) { - gen_op_st_v(s, ot, s->T0, s->A0); - } else { - gen_op_mov_reg_v(s, ot, rm, s->T0); - } - } - } - - /* Delay all CC updates until after the store above. Note that - C is the result of the test, Z is unchanged, and the others - are all undefined. */ - switch (s->cc_op) { - case CC_OP_MULB ... CC_OP_MULQ: - case CC_OP_ADDB ... CC_OP_ADDQ: - case CC_OP_ADCB ... CC_OP_ADCQ: - case CC_OP_SUBB ... CC_OP_SUBQ: - case CC_OP_SBBB ... CC_OP_SBBQ: - case CC_OP_LOGICB ... CC_OP_LOGICQ: - case CC_OP_INCB ... CC_OP_INCQ: - case CC_OP_DECB ... CC_OP_DECQ: - case CC_OP_SHLB ... CC_OP_SHLQ: - case CC_OP_SARB ... CC_OP_SARQ: - case CC_OP_BMILGB ... CC_OP_BMILGQ: - /* Z was going to be computed from the non-zero status of CC_D= ST. - We can get that same Z value (and the new C value) by leavi= ng - CC_DST alone, setting CC_SRC, and using a CC_OP_SAR of the - same width. */ - tcg_gen_mov_tl(cpu_cc_src, s->tmp4); - set_cc_op(s, ((s->cc_op - CC_OP_MULB) & 3) + CC_OP_SARB); - break; - default: - /* Otherwise, generate EFLAGS and replace the C bit. */ - gen_compute_eflags(s); - tcg_gen_deposit_tl(cpu_cc_src, cpu_cc_src, s->tmp4, - ctz32(CC_C), 1); - break; - } - break; case 0x1bc: /* bsf / tzcnt */ case 0x1bd: /* bsr / lzcnt */ ot =3D dflag; diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 1db9d1e2bc3..af142d6911a 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -205,6 +205,7 @@ #define sextT0 .special =3D X86_SPECIAL_SExtT0, #define zextT0 .special =3D X86_SPECIAL_ZExtT0, #define op0_Mw .special =3D X86_SPECIAL_Op0_Mw, +#define btEvGv .special =3D X86_SPECIAL_BitTest, =20 #define vex1 .vex_class =3D 1, #define vex1_rep3 .vex_class =3D 1, .vex_special =3D X86_VEX_REPScalar, @@ -269,6 +270,24 @@ static inline const X86OpEntry *decode_by_prefix(Disas= Context *s, const X86OpEnt } } =20 +static void decode_group8(DisasContext *s, CPUX86State *env, X86OpEntry *e= ntry, uint8_t *b) +{ + static const X86GenFunc group8_gen[8] =3D { + NULL, NULL, NULL, NULL, + gen_BT, gen_BTS, gen_BTR, gen_BTC, + }; + int op =3D (get_modrm(s, env) >> 3) & 7; + entry->gen =3D group8_gen[op]; + if (op =3D=3D 4) { + /* prevent writeback and LOCK for BT */ + entry->op1 =3D entry->op0; + entry->op0 =3D X86_TYPE_None; + entry->s0 =3D X86_SIZE_None; + } else { + entry->special =3D X86_SPECIAL_HasLock; + } +} + static void decode_group15(DisasContext *s, CPUX86State *env, X86OpEntry *= entry, uint8_t *b) { static const X86OpEntry group15_reg[8] =3D { @@ -1114,8 +1133,10 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xa0] =3D X86_OP_ENTRYr(PUSH, FS, w), [0xa1] =3D X86_OP_ENTRYw(POP, FS, w), [0xa2] =3D X86_OP_ENTRY0(CPUID), + [0xa3] =3D X86_OP_ENTRYrr(BT, E,v, G,v, btEvGv), =20 [0xb2] =3D X86_OP_ENTRY3(LSS, G,v, EM,p, None, None), + [0xb3] =3D X86_OP_ENTRY2(BTR, E,v, G,v, btEvGv), [0xb4] =3D X86_OP_ENTRY3(LFS, G,v, EM,p, None, None), [0xb5] =3D X86_OP_ENTRY3(LGS, G,v, EM,p, None, None), [0xb6] =3D X86_OP_ENTRY3(MOV, G,v, E,b, None, None, zextT0), /* MOV= ZX */ @@ -1240,6 +1261,7 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xa8] =3D X86_OP_ENTRYr(PUSH, GS, w), [0xa9] =3D X86_OP_ENTRYw(POP, GS, w), [0xaa] =3D X86_OP_ENTRY0(RSM, chk(smm) svm(RSM)), + [0xab] =3D X86_OP_ENTRY2(BTS, E,v, G,v, btEvGv), [0xae] =3D X86_OP_GROUP0(group15), /* * It's slightly more efficient to put Ev operand in T0 and allow gen_= IMUL3 @@ -1249,6 +1271,8 @@ static const X86OpEntry opcodes_0F[256] =3D { =20 /* decoded as modrm, which is visible as a difference between page fau= lt and #UD */ [0xb9] =3D X86_OP_ENTRYr(UD, nop,v), /* UD1= */ + [0xba] =3D X86_OP_GROUP2(group8, E,v, I,b), + [0xbb] =3D X86_OP_ENTRY2(BTC, E,v, G,v, btEvGv), [0xbe] =3D X86_OP_ENTRY3(MOV, G,v, E,b, None, None, sextT0), /* MOV= SX */ [0xbf] =3D X86_OP_ENTRY3(MOV, G,v, E,w, None, None, sextT0), /* MOV= SX */ =20 @@ -2359,6 +2383,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) CPUX86State *env =3D cpu_env(cpu); X86DecodedInsn decode; X86DecodeFunc decode_func =3D decode_root; + bool accept_lock =3D false; uint8_t cc_live, b; =20 s->pc =3D s->base.pc_next; @@ -2532,12 +2557,11 @@ static void disas_insn(DisasContext *s, CPUState *c= pu) switch (b) { case 0x00 ... 0x01: /* mostly privileged instructions */ case 0x1a ... 0x1b: /* MPX */ - case 0xa3 ... 0xa5: /* BT, SHLD */ - case 0xab ... 0xad: /* BTS, SHRD */ + case 0xa4 ... 0xa5: /* SHLD */ + case 0xac ... 0xad: /* SHRD */ case 0xb0 ... 0xb1: /* cmpxchg */ - case 0xb3: /* btr */ - case 0xb8: /* integer ops */ - case 0xba ... 0xbd: /* integer ops */ + case 0xb8: /* POPCNT */ + case 0xbc ... 0xbd: /* LZCNT/TZCNT */ case 0xc0 ... 0xc1: /* xadd */ case 0xc7: /* grp9 */ disas_insn_old(s, cpu, b + 0x100); @@ -2600,9 +2624,10 @@ static void disas_insn(DisasContext *s, CPUState *cp= u) if (decode.op[0].has_ea) { s->prefix |=3D PREFIX_LOCK; } - decode.e.special =3D X86_SPECIAL_HasLock; /* fallthrough */ case X86_SPECIAL_HasLock: + case X86_SPECIAL_BitTest: + accept_lock =3D decode.op[0].has_ea; break; =20 case X86_SPECIAL_Op0_Rd: @@ -2644,10 +2669,8 @@ static void disas_insn(DisasContext *s, CPUState *cp= u) break; } =20 - if (s->prefix & PREFIX_LOCK) { - if (decode.e.special !=3D X86_SPECIAL_HasLock || !decode.op[0].has= _ea) { - goto illegal_op; - } + if ((s->prefix & PREFIX_LOCK) && !accept_lock) { + goto illegal_op; } =20 if (!validate_vex(s, &decode)) { @@ -2693,7 +2716,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) =20 if (decode.e.special !=3D X86_SPECIAL_NoLoadEA && (decode.op[0].has_ea || decode.op[1].has_ea || decode.op[2].has_ea= )) { - gen_load_ea(s, &decode.mem, decode.e.vex_class =3D=3D 12); + gen_load_ea(s, &decode); } if (s->prefix & PREFIX_LOCK) { gen_load(s, &decode, 2, s->T1); diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index f788e1fa4c8..41398e5130c 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -73,9 +73,25 @@ static void gen_NM_exception(DisasContext *s) gen_exception(s, EXCP07_PREX); } =20 -static void gen_load_ea(DisasContext *s, AddressParts *mem, bool is_vsib) +static void gen_load_ea(DisasContext *s, X86DecodedInsn *decode) { - TCGv ea =3D gen_lea_modrm_1(s, *mem, is_vsib); + AddressParts *mem =3D &decode->mem; + TCGv ea; + + ea =3D gen_lea_modrm_1(s, *mem, decode->e.vex_class =3D=3D 12); + if (decode->e.special =3D=3D X86_SPECIAL_BitTest) { + int oplen =3D 3 + decode->op[0].ot; + int poslen =3D 8 << decode->op[2].ot; + TCGv ofs =3D tcg_temp_new(); + + /* Extract memory displacement from T1. */ + assert (decode->op[2].unit =3D=3D X86_OP_INT); + tcg_gen_sextract_tl(ofs, s->T1, oplen, poslen - oplen); + + tcg_gen_add_tl(s->A0, ea, ofs); + ea =3D s->A0; + } + gen_lea_v_seg(s, ea, mem->def_seg, s->override); } =20 @@ -1340,6 +1356,116 @@ static void gen_BSWAP(DisasContext *s, X86DecodedIn= sn *decode) tcg_gen_bswap32_tl(s->T0, s->T0, TCG_BSWAP_OZ); } =20 +static TCGv gen_bt_mask(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[1].ot; + TCGv mask =3D tcg_temp_new(); + + tcg_gen_andi_tl(s->T1, s->T1, (8 << ot) - 1); + tcg_gen_shl_tl(mask, tcg_constant_tl(1), s->T1); + return mask; +} + +/* Expects truncated bit index in s->T1, 1 << s->T1 in MASK. */ +static void gen_bt_flags(DisasContext *s, X86DecodedInsn *decode, TCGv src= , TCGv mask) +{ + /* + * C is the result of the test, Z is unchanged, and the others + * are all undefined. + */ + switch (s->cc_op) { + case CC_OP_MULB ... CC_OP_MULQ: + case CC_OP_ADDB ... CC_OP_ADDQ: + case CC_OP_ADCB ... CC_OP_ADCQ: + case CC_OP_SUBB ... CC_OP_SUBQ: + case CC_OP_SBBB ... CC_OP_SBBQ: + case CC_OP_LOGICB ... CC_OP_LOGICQ: + case CC_OP_INCB ... CC_OP_INCQ: + case CC_OP_DECB ... CC_OP_DECQ: + case CC_OP_SHLB ... CC_OP_SHLQ: + case CC_OP_SARB ... CC_OP_SARQ: + case CC_OP_BMILGB ... CC_OP_BMILGQ: + /* + * Z was going to be computed from the non-zero status of CC_DST. + * We can get that same Z value (and the new C value) by leaving + * CC_DST alone, setting CC_SRC, and using a CC_OP_SAR of the + * same width. + */ + decode->cc_src =3D tcg_temp_new(); + decode->cc_dst =3D cpu_cc_dst; + decode->cc_op =3D ((s->cc_op - CC_OP_MULB) & 3) + CC_OP_SARB; + tcg_gen_shr_tl(decode->cc_src, src, s->T1); + break; + + default: + /* Otherwise, generate EFLAGS and replace the C bit. */ + decode->cc_src =3D tcg_temp_new(); + decode->cc_dst =3D tcg_temp_new(); + decode->cc_op =3D CC_OP_ADCX; + + gen_mov_eflags(s, decode->cc_src); + tcg_gen_setcond_tl(TCG_COND_TSTNE, decode->cc_dst, src, mask); + break; + } +} + +static void gen_BT(DisasContext *s, X86DecodedInsn *decode) +{ + TCGv mask =3D gen_bt_mask(s, decode); + + gen_bt_flags(s, decode, s->T0, mask); +} + +static void gen_BTC(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[0].ot; + TCGv old =3D tcg_temp_new(); + TCGv mask =3D gen_bt_mask(s, decode); + + if (s->prefix & PREFIX_LOCK) { + tcg_gen_atomic_fetch_xor_tl(old, s->A0, mask, s->mem_index, ot | M= O_LE); + } else { + tcg_gen_mov_tl(old, s->T0); + tcg_gen_xor_tl(s->T0, s->T0, mask); + } + + gen_bt_flags(s, decode, old, mask); +} + +static void gen_BTR(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[0].ot; + TCGv old =3D tcg_temp_new(); + TCGv mask =3D gen_bt_mask(s, decode); + + if (s->prefix & PREFIX_LOCK) { + TCGv maskc =3D tcg_temp_new(); + tcg_gen_not_tl(maskc, mask); + tcg_gen_atomic_fetch_and_tl(old, s->A0, maskc, s->mem_index, ot | = MO_LE); + } else { + tcg_gen_mov_tl(old, s->T0); + tcg_gen_andc_tl(s->T0, s->T0, mask); + } + + gen_bt_flags(s, decode, old, mask); +} + +static void gen_BTS(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[0].ot; + TCGv old =3D tcg_temp_new(); + TCGv mask =3D gen_bt_mask(s, decode); + + if (s->prefix & PREFIX_LOCK) { + tcg_gen_atomic_fetch_or_tl(old, s->A0, mask, s->mem_index, ot | MO= _LE); + } else { + tcg_gen_mov_tl(old, s->T0); + tcg_gen_or_tl(s->T0, s->T0, mask); + } + + gen_bt_flags(s, decode, old, mask); +} + static void gen_BZHI(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836207; cv=none; d=zohomail.com; s=zohoarc; b=YVytg0IZa4N2mIsWW3wDtWdZsS0LU1p/BlfTikczrAhhA1oHylsq39/Dl1ZIug2S7vQDhCgF524yDhljLGJImwBOQFwvWA8+kMaJepaxgyi2RwGQhtIXnEzOcNMppLY+kav+u0i5Cw4ROCa5cxkmkUbnbEKekim3hN/VOzU46g0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836207; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=rJcH5tshX4nsRNYSBtlqLleRQ0annTdItK+uyAnqpkA=; b=Lj4ku9nG/bp8CICQf5LxMrmMjTVz7IGudvINQjfFFjyUpkBoa99rz0Hc0r6tgMinPbuNC5y4Yhk7p36QJQQ0bh+A2eg7U44EggREPiPIdt38RK3qvyGaeJ+T50ICOr/1GXdoQ8LZH8CmLZqr2n98l8DVPQWzdj3EJom6D8XfxeE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836207430155.21985448151906; Sat, 8 Jun 2024 01:43:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFreT-0003Vv-1L; Sat, 08 Jun 2024 04:42:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreR-0003Rz-Hl for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreP-0001Rw-Vo for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:15 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-hd9OSoOaNtetRTmTr5zVGQ-1; Sat, 08 Jun 2024 04:42:11 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a6ef8d9d3efso16457466b.2 for ; Sat, 08 Jun 2024 01:42:11 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c805d0ba8sm352223766b.85.2024.06.08.01.42.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rJcH5tshX4nsRNYSBtlqLleRQ0annTdItK+uyAnqpkA=; b=SFhKFP5wO+UzBjHMIys3plweRuDFQR1XzUPWry5s0srjBmvvPepKUjK7HxaSlqablQeL1Z n0FZIEbqG8dctkFornIrksZDCvX2ZeZPIf/gogOGSsdQDDtCXgCMf7NSHrqahp3XReU++T VyJqF6bUkc25N6xpPmBD0Tgg5ySPK2U= X-MC-Unique: hd9OSoOaNtetRTmTr5zVGQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836129; x=1718440929; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rJcH5tshX4nsRNYSBtlqLleRQ0annTdItK+uyAnqpkA=; b=XuQfpzGsYQI028tSKQNqbGV/gAHB7WJf27wzDVbOZ3mCJOlIiiL/2+MksWFLYOZhJH iP7EtIyYWyNxNboG6Oi25TaOHKeFM5WUKNO+OMZxxHOJqt990+VX5l1UxXwnjlStfhXW fwhp4CUNOgL2ZUznkL/f0abjHNGW2M9fhYUMB0EEWFOYP3/QX9ssBHztHI+/vVJFIYSu nqBm0ioXlxK9QzAYcYOuLRUCi9GdMxNqWPittF2VzTQKWHBHWj4otx4o04Hb2KPKOQ9J TdwfTmMDOd1uCSSNA2gEeBTjEq0PJq9FNYFiZY7740LXYsopYrNLryM3+WqrFQBbTUd3 u+Nw== X-Gm-Message-State: AOJu0YwpMC/mKtKDZrGJDpKG81WB9p63aKVlJT9COlPDuFtwHv0U0XQj W9WP4SNaO1ZEZA5+avvfZ/bs+ccductnQt7jVDry35I/s1TILoQj4VjWzx8iB4qkZ34dKVcGhmJ oZPqOC06fgmGs0G7yqVG52ii6KiImN9jnMl+tiFcS+gPmiFZgJvC0kM6f5pC7u+Xl4Cfw6zMssh F8Mi5Mfx9zdVK6jN4vy9L+UN0b5h+S5BnCqTVO X-Received: by 2002:a17:906:b313:b0:a6e:2a67:789f with SMTP id a640c23a62f3a-a6e2a677a24mr215074966b.40.1717836129144; Sat, 08 Jun 2024 01:42:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG84wibuR6pFAitspADx3et4dNex5WEK3nOdESsZCnSIZWhzYRDua5Xuc+GARVjWEaZowtYZQ== X-Received: by 2002:a17:906:b313:b0:a6e:2a67:789f with SMTP id a640c23a62f3a-a6e2a677a24mr215073466b.40.1717836128611; Sat, 08 Jun 2024 01:42:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 15/25] target/i386: pull load/writeback out of gen_shiftd_rm_T1 Date: Sat, 8 Jun 2024 10:41:03 +0200 Message-ID: <20240608084113.2770363-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836208256100006 Content-Type: text/plain; charset="utf-8" Use gen_ld_modrm/gen_st_modrm, moving them and gen_shift_flags to the caller. This way, gen_shiftd_rm_T1 becomes something that the new decoder can call. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 55 ++++++++++--------------------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index c3843092350..416db2f3b0e 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -535,15 +535,6 @@ static inline void gen_op_st_v(DisasContext *s, int id= x, TCGv t0, TCGv a0) tcg_gen_qemu_st_tl(t0, a0, s->mem_index, idx | MO_LE); } =20 -static inline void gen_op_st_rm_T0_A0(DisasContext *s, int idx, int d) -{ - if (d =3D=3D OR_TMP0) { - gen_op_st_v(s, idx, s->T0, s->A0); - } else { - gen_op_mov_reg_v(s, idx, d, s->T0); - } -} - static void gen_update_eip_next(DisasContext *s) { assert(s->pc_save !=3D -1); @@ -1481,19 +1472,12 @@ static void gen_shift_flags(DisasContext *s, MemOp = ot, TCGv result, } =20 /* XXX: add faster immediate case */ -static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, int op1, +static TCGv gen_shiftd_rm_T1(DisasContext *s, MemOp ot, bool is_right, TCGv count_in) { target_ulong mask =3D (ot =3D=3D MO_64 ? 63 : 31); TCGv count; =20 - /* load */ - if (op1 =3D=3D OR_TMP0) { - gen_op_ld_v(s, ot, s->T0, s->A0); - } else { - gen_op_mov_v_reg(s, ot, s->T0, op1); - } - count =3D tcg_temp_new(); tcg_gen_andi_tl(count, count_in, mask); =20 @@ -1558,10 +1542,7 @@ static void gen_shiftd_rm_T1(DisasContext *s, MemOp = ot, int op1, break; } =20 - /* store */ - gen_op_st_rm_T0_A0(s, ot, op1); - - gen_shift_flags(s, ot, s->T0, s->tmp0, count, is_right); + return count; } =20 #define X86_MAX_INSN_LENGTH 15 @@ -3071,9 +3052,9 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) CPUX86State *env =3D cpu_env(cpu); int prefixes =3D s->prefix; MemOp dflag =3D s->dflag; - int shift; + TCGv shift; MemOp ot; - int modrm, reg, rm, mod, op, opreg; + int modrm, reg, rm, mod, op; =20 /* now check op code */ switch (b) { @@ -3239,39 +3220,31 @@ static void disas_insn_old(DisasContext *s, CPUStat= e *cpu, int b) /* shifts */ case 0x1a4: /* shld imm */ op =3D 0; - shift =3D 1; + shift =3D NULL; goto do_shiftd; case 0x1a5: /* shld cl */ op =3D 0; - shift =3D 0; + shift =3D cpu_regs[R_ECX]; goto do_shiftd; case 0x1ac: /* shrd imm */ op =3D 1; - shift =3D 1; + shift =3D NULL; goto do_shiftd; case 0x1ad: /* shrd cl */ op =3D 1; - shift =3D 0; + shift =3D cpu_regs[R_ECX]; do_shiftd: ot =3D dflag; modrm =3D x86_ldub_code(env, s); - mod =3D (modrm >> 6) & 3; - rm =3D (modrm & 7) | REX_B(s); reg =3D ((modrm >> 3) & 7) | REX_R(s); - if (mod !=3D 3) { - gen_lea_modrm(env, s, modrm); - opreg =3D OR_TMP0; - } else { - opreg =3D rm; + gen_ld_modrm(env, s, modrm, ot); + if (!shift) { + shift =3D tcg_constant_tl(x86_ldub_code(env, s)); } gen_op_mov_v_reg(s, ot, s->T1, reg); - - if (shift) { - TCGv imm =3D tcg_constant_tl(x86_ldub_code(env, s)); - gen_shiftd_rm_T1(s, ot, opreg, op, imm); - } else { - gen_shiftd_rm_T1(s, ot, opreg, op, cpu_regs[R_ECX]); - } + shift =3D gen_shiftd_rm_T1(s, ot, op, shift); + gen_st_modrm(env, s, modrm, ot); + gen_shift_flags(s, ot, s->T0, s->tmp0, shift, op); break; case 0x1bc: /* bsf / tzcnt */ case 0x1bd: /* bsr / lzcnt */ --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836162; cv=none; d=zohomail.com; s=zohoarc; b=l2r82Z+ug41iAxGjhTCFEjQfAw/9ILRF/UCnkKJ+/BrYqWKaZXmlW0dO+NjPWZ2QbxAJwg5nEql0rihwq1LBA/6Sl1s6LWXevn+QwKWmW7nWB/ke2p1x7DffRinr2gF0bojPTLVDyu1dnGhSPIqV/bL207cViTHEvCG6QhYy9j0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836162; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=e54zIwB4ZotLZ75Nya5oaHP5znOGdXyOL0dXOi/s3BY=; b=RlZV/6iZ/ZvJ/2lAdS0pxYL1IkIgpArUWao/Cq0Wl1XKCxcoUPeq73vgbH/wL7V9MTCiLwHEtSTAVE1psQGFSBWe5cU7tRmVb7QPPfoL+db5qobEkBuGLNU8E5jTo419lLr+h3ateCFZbFS+oHULgPA3EbVXpa7LiKPTdAdTrnQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836162035257.2790533079756; Sat, 8 Jun 2024 01:42:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFreY-0003lX-SX; Sat, 08 Jun 2024 04:42:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreX-0003iI-QW for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreW-0001Vi-2U for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:21 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-pJgg61V4PwCiUZPLE0re_w-1; Sat, 08 Jun 2024 04:42:14 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-57c6979daf7so180439a12.1 for ; Sat, 08 Jun 2024 01:42:14 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae0ffbf8sm3981249a12.39.2024.06.08.01.42.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e54zIwB4ZotLZ75Nya5oaHP5znOGdXyOL0dXOi/s3BY=; b=OAfe4r1d29QgFMGiFzaMpID9OL+ls99iC+kcjt28N76YWbHKi1aBOsaPzzKgbU3BttkHee KRr4886po6JUxB6fHr81zds5/27CEbfPHTpr6g+4L/H0trSAPXNIIBrZCjwXqb1CSYKziL DBO+/81052tqn5OluF62R3fT6sXcY7g= X-MC-Unique: pJgg61V4PwCiUZPLE0re_w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836132; x=1718440932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e54zIwB4ZotLZ75Nya5oaHP5znOGdXyOL0dXOi/s3BY=; b=tfaK6V4Rl4iV+gAgGasN7GqAHAYMP5/XpcslD5/4AyQqc+1Lz0E+ueRYfwgld2r2mp 11HnKfN5Grzn5sXdnMc0OfTyFAtllf4bsJ2cWMPH86Yfxnb9Jjxvcur6W455OQrbYE9v pmH8rZqKgTjB6GVp6JB/smgTMFF+8SVEeTyBh4GJqY/9WCmRdrJLw/ckXuRRs/q9d7CJ 4v1aMleSajKNnCp4E0IyHhiDxmGDOyosS31o8VtTyhkqFrOykDdxA6zRqSqc1Y0je9Uq GpdjYa4MMX644n1bfjZZp2bbU1a8dm8bifvlG+Hs7wThd9RW7tLLKaAri6LCipGze9DN sTGQ== X-Gm-Message-State: AOJu0YxflcqbS2cnomy/2ctvbLlAv3w0dBeQ862RlJ/nN2H0pdiWtQUk RSvaXRsss9BKGPiSmk+oa1HxUbk0/BadI0M9i/1m/k6TR+yDyxGxkN72FO+hYslkGcLdt/UYPCF pUPdP4jFR6GMwD3PtcLSta9cCap+7Yl7TJN1NuglUEBCqWRKvE4gBNFb8h143TZWfOrNwyLJGyz c4bBe1pa47O35uCyeV5bayi3qonN8oQxuvvWaw X-Received: by 2002:a50:cd56:0:b0:57a:31c6:69cf with SMTP id 4fb4d7f45d1cf-57c50990d57mr2461490a12.28.1717836132329; Sat, 08 Jun 2024 01:42:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoEa/m+uBJrPOHWW9ztTd/5V4IWDSpV3aUNNXUADrJAueF/31IVE3psJdy5ZIldLel4XBZHw== X-Received: by 2002:a50:cd56:0:b0:57a:31c6:69cf with SMTP id 4fb4d7f45d1cf-57c50990d57mr2461481a12.28.1717836131850; Sat, 08 Jun 2024 01:42:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 16/25] target/i386: adapt gen_shift_count for SHLD/SHRD Date: Sat, 8 Jun 2024 10:41:04 +0200 Message-ID: <20240608084113.2770363-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836164145100003 Content-Type: text/plain; charset="utf-8" SHLD/SHRD can have 3 register operands - s->T0, s->T1 and either 1 or CL - and therefore decode->op[2] is taken by the low part of the register being shifted. Pass X86_OP_* to gen_shift_count from its current callers and hardcode cpu_regs[R_ECX] as the shift count. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/emit.c.inc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 41398e5130c..2e73b41cd3e 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -2998,16 +2998,16 @@ static void gen_PUSHF(DisasContext *s, X86DecodedIn= sn *decode) } =20 static MemOp gen_shift_count(DisasContext *s, X86DecodedInsn *decode, - bool *can_be_zero, TCGv *count) + bool *can_be_zero, TCGv *count, int unit) { MemOp ot =3D decode->op[0].ot; int mask =3D (ot <=3D MO_32 ? 0x1f : 0x3f); =20 *can_be_zero =3D false; - switch (decode->op[2].unit) { + switch (unit) { case X86_OP_INT: *count =3D tcg_temp_new(); - tcg_gen_andi_tl(*count, s->T1, mask); + tcg_gen_andi_tl(*count, cpu_regs[R_ECX], mask); *can_be_zero =3D true; break; =20 @@ -3192,7 +3192,7 @@ static void gen_RCL(DisasContext *s, X86DecodedInsn *= decode) bool have_1bit_cin, can_be_zero; TCGv count; TCGLabel *zero_label =3D NULL; - MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count); + MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count, decode->= op[2].unit); TCGv low, high, low_count; =20 if (!count) { @@ -3244,7 +3244,7 @@ static void gen_RCR(DisasContext *s, X86DecodedInsn *= decode) bool have_1bit_cin, can_be_zero; TCGv count; TCGLabel *zero_label =3D NULL; - MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count); + MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count, decode->= op[2].unit); TCGv low, high, high_count; =20 if (!count) { @@ -3422,7 +3422,7 @@ static void gen_ROL(DisasContext *s, X86DecodedInsn *= decode) { bool can_be_zero; TCGv count; - MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count); + MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count, decode->= op[2].unit); TCGv_i32 temp32, count32; TCGv old =3D tcg_temp_new(); =20 @@ -3450,7 +3450,7 @@ static void gen_ROR(DisasContext *s, X86DecodedInsn *= decode) { bool can_be_zero; TCGv count; - MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count); + MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count, decode->= op[2].unit); TCGv_i32 temp32, count32; TCGv old =3D tcg_temp_new(); =20 @@ -3562,7 +3562,7 @@ static void gen_SAR(DisasContext *s, X86DecodedInsn *= decode) { bool can_be_zero; TCGv count; - MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count); + MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count, decode->= op[2].unit); =20 if (!count) { return; @@ -3690,7 +3690,7 @@ static void gen_SHL(DisasContext *s, X86DecodedInsn *= decode) { bool can_be_zero; TCGv count; - MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count); + MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count, decode->= op[2].unit); =20 if (!count) { return; @@ -3722,7 +3722,7 @@ static void gen_SHR(DisasContext *s, X86DecodedInsn *= decode) { bool can_be_zero; TCGv count; - MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count); + MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count, decode->= op[2].unit); =20 if (!count) { return; --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836252; cv=none; d=zohomail.com; s=zohoarc; b=VDQ7JbUbtcEd480gWY37kLBDnyOdzSHhFFrBlLvT+klKqgRxRU3FVEmOpLNJVUehw3bEjPLmBqe4dPrQyTwzdGXvP0jL+rfGfsQBvEu8WYREq+og4n4Ph8MdJOEoTHpemswEhY33fj2PwruXA2K7BCoXZsqFgcy3TcahFDbm1nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836252; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=KqQr6s8YF4T1reb4LtsrDO+vhMKW4F9sm8J1z/+at7M=; b=XnU+XJcuuWh8wGkHmQXoieVcmJHBwHpO49tyTXe7+do12JzIy7PXPP0sqwqyfv3P/ukCnv/j9aW/FdKdSuikJpWfSCZPqeYMEEOX3D+jKUVCjVM03fdYRon8QOIojGY+uD5ekl9NwUEQRzOgAFNc2g+kGEK5TL1ZsCkPAQ6Ey9A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836252440779.4790182700008; Sat, 8 Jun 2024 01:44:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFreZ-0003lj-0a; Sat, 08 Jun 2024 04:42:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreY-0003kK-96 for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreW-0001Vn-Dq for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:22 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-512-6-iJQbNWO9OORV52j-skEw-1; Sat, 08 Jun 2024 04:42:17 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a68e85d466dso182092966b.1 for ; Sat, 08 Jun 2024 01:42:17 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c806ebc96sm354335866b.138.2024.06.08.01.42.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KqQr6s8YF4T1reb4LtsrDO+vhMKW4F9sm8J1z/+at7M=; b=N3cjeEpAy7z7dXhopZYGzS0GyZ1uDW0xkz1Q+cL9aPgu+ycYuqhBOsm4/RUwRqdvoW6DUk Z/4iCAiyF8LnciMEUJyv6hmsEjSwl6AdO15qHZHPPP98FLI1jUUEaM7QILEkoykASSAMEv r+q5MWvGVs7Cwc/4cHMWGxSD9d8YOAk= X-MC-Unique: 6-iJQbNWO9OORV52j-skEw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836135; x=1718440935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KqQr6s8YF4T1reb4LtsrDO+vhMKW4F9sm8J1z/+at7M=; b=ssC4OM//tKsmy+9rU9bWY4YuszQei9ShH3L0eX8RQWsm5EPtH3ANLDrVGg2O566/fq KZI9BBTi3/kdlgT8o4WOOQSw8ItJuCd4BNcy5CQFQCO9rwUOKp1xmg5ioPPzH1ikzK5x rjH5cyOaSx9Q/607+2i3WZhUc25+DrYX2fQrAsNy25fs3HGHri3zZzyDA9bInpoYI+yc HYFeqB0sWC1p6FxAvqMde8OUZKyI2I+794oaSU8nB5pV7j81izH9kNdTxMBnoStdskTG OGlyYZXt/UE6ZnioH6BYXw6untNBDjBgdfgWNb/0kAVLH197kuUuX4bwwRycvB6UZ21w qEGA== X-Gm-Message-State: AOJu0YxxnQY76kFti51fhsmjRvxXESVKIpqgv5i3G3NHSPqY6xG+1Jc3 rBxA4IYBtJMZ75MJLD46RhmBOIPA/5MUk+OjJklyuGCyTPRD2wo4H/00R++K8dw3UwhrzZXrdwT dqcG5jN6F7OJBoihzWQMOjzoaZT8i2f6het1yU1YC5a3z3DF9rce0juF40F7058GEPZApm1ZA8t IemgMbXFeiCmxK+YWpK53YrgOpadvvCQQ3IsCV X-Received: by 2002:a17:906:3285:b0:a68:2f99:a3da with SMTP id a640c23a62f3a-a6cd5612575mr297921766b.16.1717836135582; Sat, 08 Jun 2024 01:42:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFb8qM+V5BVgSKQuqQfuyfV/Lv3ZSadlaP06qzp+/h/dBVXWbOZm477wS+bk21U32rGdewWMQ== X-Received: by 2002:a17:906:3285:b0:a68:2f99:a3da with SMTP id a640c23a62f3a-a6cd5612575mr297920766b.16.1717836135122; Sat, 08 Jun 2024 01:42:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 17/25] target/i386: convert SHLD/SHRD to new decoder Date: Sat, 8 Jun 2024 10:41:05 +0200 Message-ID: <20240608084113.2770363-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836254403100007 Content-Type: text/plain; charset="utf-8" Use the same flag generation code as SHL and SHR, but use the existing gen_shiftd_rm_T1 function to compute the result as well as CC_SRC. Decoding-wise, SHLD/SHRD by immediate count as a 4 operand instruction because s->T0 and s->T1 actually occupy three op slots. The infrastructure used by opcodes in the 0F 3A table works fine. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 83 +------------------------------- target/i386/tcg/decode-new.c.inc | 6 ++- target/i386/tcg/emit.c.inc | 42 ++++++++++++++++ 3 files changed, 48 insertions(+), 83 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 416db2f3b0e..1e9036eb6e3 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1429,57 +1429,11 @@ static bool check_cpl0(DisasContext *s) return false; } =20 -static void gen_shift_flags(DisasContext *s, MemOp ot, TCGv result, - TCGv shm1, TCGv count, bool is_right) -{ - TCGv_i32 z32, s32, oldop; - TCGv z_tl; - - /* Store the results into the CC variables. If we know that the - variable must be dead, store unconditionally. Otherwise we'll - need to not disrupt the current contents. */ - z_tl =3D tcg_constant_tl(0); - if (cc_op_live[s->cc_op] & USES_CC_DST) { - tcg_gen_movcond_tl(TCG_COND_NE, cpu_cc_dst, count, z_tl, - result, cpu_cc_dst); - } else { - tcg_gen_mov_tl(cpu_cc_dst, result); - } - if (cc_op_live[s->cc_op] & USES_CC_SRC) { - tcg_gen_movcond_tl(TCG_COND_NE, cpu_cc_src, count, z_tl, - shm1, cpu_cc_src); - } else { - tcg_gen_mov_tl(cpu_cc_src, shm1); - } - - /* Get the two potential CC_OP values into temporaries. */ - tcg_gen_movi_i32(s->tmp2_i32, (is_right ? CC_OP_SARB : CC_OP_SHLB) + o= t); - if (s->cc_op =3D=3D CC_OP_DYNAMIC) { - oldop =3D cpu_cc_op; - } else { - tcg_gen_movi_i32(s->tmp3_i32, s->cc_op); - oldop =3D s->tmp3_i32; - } - - /* Conditionally store the CC_OP value. */ - z32 =3D tcg_constant_i32(0); - s32 =3D tcg_temp_new_i32(); - tcg_gen_trunc_tl_i32(s32, count); - tcg_gen_movcond_i32(TCG_COND_NE, cpu_cc_op, s32, z32, s->tmp2_i32, old= op); - - /* The CC_OP value is no longer predictable. */ - set_cc_op(s, CC_OP_DYNAMIC); -} - /* XXX: add faster immediate case */ -static TCGv gen_shiftd_rm_T1(DisasContext *s, MemOp ot, - bool is_right, TCGv count_in) +static void gen_shiftd_rm_T1(DisasContext *s, MemOp ot, + bool is_right, TCGv count) { target_ulong mask =3D (ot =3D=3D MO_64 ? 63 : 31); - TCGv count; - - count =3D tcg_temp_new(); - tcg_gen_andi_tl(count, count_in, mask); =20 switch (ot) { case MO_16: @@ -1541,8 +1495,6 @@ static TCGv gen_shiftd_rm_T1(DisasContext *s, MemOp o= t, tcg_gen_or_tl(s->T0, s->T0, s->T1); break; } - - return count; } =20 #define X86_MAX_INSN_LENGTH 15 @@ -3052,7 +3004,6 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) CPUX86State *env =3D cpu_env(cpu); int prefixes =3D s->prefix; MemOp dflag =3D s->dflag; - TCGv shift; MemOp ot; int modrm, reg, rm, mod, op; =20 @@ -3216,36 +3167,6 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) } break; =20 - /**************************/ - /* shifts */ - case 0x1a4: /* shld imm */ - op =3D 0; - shift =3D NULL; - goto do_shiftd; - case 0x1a5: /* shld cl */ - op =3D 0; - shift =3D cpu_regs[R_ECX]; - goto do_shiftd; - case 0x1ac: /* shrd imm */ - op =3D 1; - shift =3D NULL; - goto do_shiftd; - case 0x1ad: /* shrd cl */ - op =3D 1; - shift =3D cpu_regs[R_ECX]; - do_shiftd: - ot =3D dflag; - modrm =3D x86_ldub_code(env, s); - reg =3D ((modrm >> 3) & 7) | REX_R(s); - gen_ld_modrm(env, s, modrm, ot); - if (!shift) { - shift =3D tcg_constant_tl(x86_ldub_code(env, s)); - } - gen_op_mov_v_reg(s, ot, s->T1, reg); - shift =3D gen_shiftd_rm_T1(s, ot, op, shift); - gen_st_modrm(env, s, modrm, ot); - gen_shift_flags(s, ot, s->T0, s->tmp0, shift, op); - break; case 0x1bc: /* bsf / tzcnt */ case 0x1bd: /* bsr / lzcnt */ ot =3D dflag; diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index af142d6911a..bd9e7cd4df9 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1134,6 +1134,8 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xa1] =3D X86_OP_ENTRYw(POP, FS, w), [0xa2] =3D X86_OP_ENTRY0(CPUID), [0xa3] =3D X86_OP_ENTRYrr(BT, E,v, G,v, btEvGv), + [0xa4] =3D X86_OP_ENTRY4(SHLD, E,v, 2op,v, G,v), + [0xa5] =3D X86_OP_ENTRY3(SHLD, E,v, 2op,v, G,v), =20 [0xb2] =3D X86_OP_ENTRY3(LSS, G,v, EM,p, None, None), [0xb3] =3D X86_OP_ENTRY2(BTR, E,v, G,v, btEvGv), @@ -1262,6 +1264,8 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xa9] =3D X86_OP_ENTRYw(POP, GS, w), [0xaa] =3D X86_OP_ENTRY0(RSM, chk(smm) svm(RSM)), [0xab] =3D X86_OP_ENTRY2(BTS, E,v, G,v, btEvGv), + [0xac] =3D X86_OP_ENTRY4(SHRD, E,v, 2op,v, G,v), + [0xad] =3D X86_OP_ENTRY3(SHRD, E,v, 2op,v, G,v), [0xae] =3D X86_OP_GROUP0(group15), /* * It's slightly more efficient to put Ev operand in T0 and allow gen_= IMUL3 @@ -2557,8 +2561,6 @@ static void disas_insn(DisasContext *s, CPUState *cpu) switch (b) { case 0x00 ... 0x01: /* mostly privileged instructions */ case 0x1a ... 0x1b: /* MPX */ - case 0xa4 ... 0xa5: /* SHLD */ - case 0xac ... 0xad: /* SHRD */ case 0xb0 ... 0xb1: /* cmpxchg */ case 0xb8: /* POPCNT */ case 0xbc ... 0xbd: /* LZCNT/TZCNT */ diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 2e73b41cd3e..aabc86669c2 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -3708,6 +3708,27 @@ static void gen_SHL(DisasContext *s, X86DecodedInsn = *decode) } } =20 +static void gen_SHLD(DisasContext *s, X86DecodedInsn *decode) +{ + bool can_be_zero; + TCGv count; + int unit =3D decode->e.op3 =3D=3D X86_TYPE_I ? X86_OP_IMM : X86_OP_INT; + MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count, unit); + + if (!count) { + return; + } + + decode->cc_dst =3D s->T0; + decode->cc_src =3D s->tmp0; + gen_shiftd_rm_T1(s, ot, false, count); + if (can_be_zero) { + gen_shift_dynamic_flags(s, decode, count, CC_OP_SHLB + ot); + } else { + decode->cc_op =3D CC_OP_SHLB + ot; + } +} + static void gen_SHLX(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; @@ -3740,6 +3761,27 @@ static void gen_SHR(DisasContext *s, X86DecodedInsn = *decode) } } =20 +static void gen_SHRD(DisasContext *s, X86DecodedInsn *decode) +{ + bool can_be_zero; + TCGv count; + int unit =3D decode->e.op3 =3D=3D X86_TYPE_I ? X86_OP_IMM : X86_OP_INT; + MemOp ot =3D gen_shift_count(s, decode, &can_be_zero, &count, unit); + + if (!count) { + return; + } + + decode->cc_dst =3D s->T0; + decode->cc_src =3D s->tmp0; + gen_shiftd_rm_T1(s, ot, true, count); + if (can_be_zero) { + gen_shift_dynamic_flags(s, decode, count, CC_OP_SARB + ot); + } else { + decode->cc_op =3D CC_OP_SARB + ot; + } +} + static void gen_SHRX(DisasContext *s, X86DecodedInsn *decode) { MemOp ot =3D decode->op[0].ot; --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836178; cv=none; d=zohomail.com; s=zohoarc; b=FGM0G9iRMRC4X+jOOc6EkMkwi6tR7DIr7cJzNaqvaIIR3wAR9D0J9RGLO56rgy1JkPo+DslMvtSy8wP/vI/dl+TIJdiUS8TUMElFk3pyYqMKLbryAFwJU2zQ6xfxJQSHEa5QzVajewRHACFr1bkT5Rz7LIlQql7Qw40pIxNz/4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836178; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=X99Zvon7rz5LxH+M+wyJV2JT9phIGzq0GVfDGJaCxAQ=; b=PiPwWq5LIuDjgTCDPBbe9BhAqOrnSmm5oNgB30+HqZZVlF+D1eeyDQz2fMnhvdxhEX+R/DIo2HDUEv61RSrr1+340AZDYpAml6BRQszWxa/d+u7ZZutahtPrd8lmfVUiZGqaTdM6lR6edrophCNE/wnkjU1r4jd8zpDQUE4+lk8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836178964110.63016136228646; Sat, 8 Jun 2024 01:42:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFref-00042X-QT; Sat, 08 Jun 2024 04:42:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFred-0003vL-Oa for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreZ-0001Xo-RV for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:25 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-jMCKSKB6Mj2YyyyhjP4Ebw-1; Sat, 08 Jun 2024 04:42:21 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a6efe561b04so24448366b.3 for ; Sat, 08 Jun 2024 01:42:21 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6ef53f789esm145589166b.165.2024.06.08.01.42.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X99Zvon7rz5LxH+M+wyJV2JT9phIGzq0GVfDGJaCxAQ=; b=Q3194lInO9oOytAv/bG7qUPzeNfCo0nJK4thyD2BjuOARgNkwOb5d9dYXJX97SeAqRZVzx 2YNJpGhUX7rYOojdpytGrKjhZNqKC+iHHaAQU2IMnZipM4h8MhDLUcRwdB4knFBG2w6cIt ZmXLZJ5+iwPSQP/7Xrmp/5cQWWi5yy0= X-MC-Unique: jMCKSKB6Mj2YyyyhjP4Ebw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836139; x=1718440939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X99Zvon7rz5LxH+M+wyJV2JT9phIGzq0GVfDGJaCxAQ=; b=CU75hT3JD5NitApgl0wf4wE0cBKiTzo/r115TPeQyjWc+FfsvXjtbmYpuZ2HdlDewj XkHoGxuTiTksBE1l3c3BAsQjdt5B/+/YVIAnYaKdo4tb3ua3PUSJzcnnkT2OrXOdYkBf ld8Y6uCGlfyjvchAsg0mWQpjHBJF5SsjHKiCh5PHt/ml9ggnZjv6sI8aLUjDKUPiY0SN tgFAqOb2ps26OiIWAjoSOKNmO3UBs2K5e2coZIaL5GtznGdvBNRWzB45GqKgq7rm/Aw6 HVXbf6TTTWgvW+8ZvaxFgVV8CtBTaNi7SUvqkvOxKuNdgcO8DtiGffonsmNVIWpHOGH+ T0Dg== X-Gm-Message-State: AOJu0YzkbMGKfZV0IEBhu1j/ZfCkU5iHP86cf/m2AvDU8AzqvvUQkBno BNw5bldc1ZElEImA4WMiOJ/oHEpoaLmmiIg0sTLNJtbblc5LezBiBe9/J4KF8Q2eH1IoOH3jq05 PMZ5kICEHLbI+cHN3v7fGl5GCsUXcqynj1+HGkY3DD1HeIjJN/FYsuNkoSVSF48lzNju3+q9yBK R4/JRBX5snDqv7aWjqL3lOPPtMno3Od/HaxkD7 X-Received: by 2002:a17:907:1006:b0:a6e:f52a:c34f with SMTP id a640c23a62f3a-a6ef52ac3fbmr181944366b.18.1717836139068; Sat, 08 Jun 2024 01:42:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcHin+7WqEcc/9cbTaCaCCUP4hiN0rNNa1Zdx310nIUnaA3PuflJ8f52OeIfbwzGl2s44yKQ== X-Received: by 2002:a17:907:1006:b0:a6e:f52a:c34f with SMTP id a640c23a62f3a-a6ef52ac3fbmr181943166b.18.1717836138448; Sat, 08 Jun 2024 01:42:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 18/25] target/i386: convert LZCNT/TZCNT/BSF/BSR/POPCNT to new decoder Date: Sat, 8 Jun 2024 10:41:06 +0200 Message-ID: <20240608084113.2770363-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836180284100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.h | 1 + target/i386/tcg/translate.c | 74 ---------------------------- target/i386/tcg/decode-new.c.inc | 51 +++++++++++++++++++- target/i386/tcg/emit.c.inc | 82 ++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 76 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index f781bb5bbec..13be23145a8 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -119,6 +119,7 @@ typedef enum X86CPUIDFeature { X86_FEAT_FXSR, X86_FEAT_MOVBE, X86_FEAT_PCLMULQDQ, + X86_FEAT_POPCNT, X86_FEAT_SHA_NI, X86_FEAT_SSE, X86_FEAT_SSE2, diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 1e9036eb6e3..a9cf1332b43 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -818,11 +818,6 @@ static void gen_movs(DisasContext *s, MemOp ot) gen_op_add_reg(s, s->aflag, R_EDI, dshift); } =20 -static void gen_op_update1_cc(DisasContext *s) -{ - tcg_gen_mov_tl(cpu_cc_dst, s->T0); -} - static void gen_op_update2_cc(DisasContext *s) { tcg_gen_mov_tl(cpu_cc_src, s->T1); @@ -3167,56 +3162,6 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) } break; =20 - case 0x1bc: /* bsf / tzcnt */ - case 0x1bd: /* bsr / lzcnt */ - ot =3D dflag; - modrm =3D x86_ldub_code(env, s); - reg =3D ((modrm >> 3) & 7) | REX_R(s); - gen_ld_modrm(env, s, modrm, ot); - gen_extu(ot, s->T0); - - /* Note that lzcnt and tzcnt are in different extensions. */ - if ((prefixes & PREFIX_REPZ) - && (b & 1 - ? s->cpuid_ext3_features & CPUID_EXT3_ABM - : s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_BMI1)) { - int size =3D 8 << ot; - /* For lzcnt/tzcnt, C bit is defined related to the input. */ - tcg_gen_mov_tl(cpu_cc_src, s->T0); - if (b & 1) { - /* For lzcnt, reduce the target_ulong result by the - number of zeros that we expect to find at the top. */ - tcg_gen_clzi_tl(s->T0, s->T0, TARGET_LONG_BITS); - tcg_gen_subi_tl(s->T0, s->T0, TARGET_LONG_BITS - size); - } else { - /* For tzcnt, a zero input must return the operand size. = */ - tcg_gen_ctzi_tl(s->T0, s->T0, size); - } - /* For lzcnt/tzcnt, Z bit is defined related to the result. */ - gen_op_update1_cc(s); - set_cc_op(s, CC_OP_BMILGB + ot); - } else { - /* For bsr/bsf, only the Z bit is defined and it is related - to the input and not the result. */ - tcg_gen_mov_tl(cpu_cc_dst, s->T0); - set_cc_op(s, CC_OP_LOGICB + ot); - - /* ??? The manual says that the output is undefined when the - input is zero, but real hardware leaves it unchanged, and - real programs appear to depend on that. Accomplish this - by passing the output as the value to return upon zero. */ - if (b & 1) { - /* For bsr, return the bit index of the first 1 bit, - not the count of leading zeros. */ - tcg_gen_xori_tl(s->T1, cpu_regs[reg], TARGET_LONG_BITS - 1= ); - tcg_gen_clz_tl(s->T0, s->T0, s->T1); - tcg_gen_xori_tl(s->T0, s->T0, TARGET_LONG_BITS - 1); - } else { - tcg_gen_ctz_tl(s->T0, s->T0, cpu_regs[reg]); - } - } - gen_op_mov_reg_v(s, ot, reg, s->T0); - break; case 0x100: modrm =3D x86_ldub_code(env, s); mod =3D (modrm >> 6) & 3; @@ -3811,25 +3756,6 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) } gen_nop_modrm(env, s, modrm); break; - case 0x1b8: /* SSE4.2 popcnt */ - if ((prefixes & (PREFIX_REPZ | PREFIX_LOCK | PREFIX_REPNZ)) !=3D - PREFIX_REPZ) - goto illegal_op; - if (!(s->cpuid_ext_features & CPUID_EXT_POPCNT)) - goto illegal_op; - - modrm =3D x86_ldub_code(env, s); - reg =3D ((modrm >> 3) & 7) | REX_R(s); - - ot =3D dflag; - gen_ld_modrm(env, s, modrm, ot); - gen_extu(ot, s->T0); - tcg_gen_mov_tl(cpu_cc_src, s->T0); - tcg_gen_ctpop_tl(s->T0, s->T0); - gen_op_mov_reg_v(s, ot, reg, s->T0); - - set_cc_op(s, CC_OP_POPCNT); - break; default: g_assert_not_reached(); } diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index bd9e7cd4df9..64ec731bf4a 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -469,6 +469,50 @@ static void decode_0F7F(DisasContext *s, CPUX86State *= env, X86OpEntry *entry, ui *entry =3D *decode_by_prefix(s, opcodes_0F7F); } =20 +static void decode_0FB8(DisasContext *s, CPUX86State *env, X86OpEntry *ent= ry, uint8_t *b) +{ + static const X86OpEntry popcnt =3D + X86_OP_ENTRYwr(POPCNT, G,v, E,v, cpuid(POPCNT) zextT0); + + if (s->prefix & PREFIX_REPZ) { + *entry =3D popcnt; + } else { + memset(entry, 0, sizeof(*entry)); + } +} + +static void decode_0FBC(DisasContext *s, CPUX86State *env, X86OpEntry *ent= ry, uint8_t *b) +{ + /* For BSF, pass 2op as the third operand so that we can use zextT0 */ + static const X86OpEntry opcodes_0FBC[4] =3D { + X86_OP_ENTRY3(BSF, G,v, E,v, 2op,v, zextT0), + X86_OP_ENTRY3(BSF, G,v, E,v, 2op,v, zextT0), /* 0x66 */ + X86_OP_ENTRYwr(TZCNT, G,v, E,v, zextT0), /* 0xf3 */ + X86_OP_ENTRY3(BSF, G,v, E,v, 2op,v, zextT0), /* 0xf2 */ + }; + if (!(s->cpuid_ext3_features & CPUID_EXT3_ABM)) { + *entry =3D opcodes_0FBC[0]; + } else { + *entry =3D *decode_by_prefix(s, opcodes_0FBC); + } +} + +static void decode_0FBD(DisasContext *s, CPUX86State *env, X86OpEntry *ent= ry, uint8_t *b) +{ + /* For BSR, pass 2op as the third operand so that we can use zextT0 */ + static const X86OpEntry opcodes_0FBD[4] =3D { + X86_OP_ENTRY3(BSR, G,v, E,v, 2op,v, zextT0), + X86_OP_ENTRY3(BSR, G,v, E,v, 2op,v, zextT0), /* 0x66 */ + X86_OP_ENTRYwr(LZCNT, G,v, E,v, zextT0), /* 0xf3 */ + X86_OP_ENTRY3(BSR, G,v, E,v, 2op,v, zextT0), /* 0xf2 */ + }; + if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_BMI1)) { + *entry =3D opcodes_0FBD[0]; + } else { + *entry =3D *decode_by_prefix(s, opcodes_0FBD); + } +} + static void decode_0FD6(DisasContext *s, CPUX86State *env, X86OpEntry *ent= ry, uint8_t *b) { static const X86OpEntry movq[4] =3D { @@ -1273,10 +1317,13 @@ static const X86OpEntry opcodes_0F[256] =3D { */ [0xaf] =3D X86_OP_ENTRY3(IMUL3, G,v, E,v, 2op,v, sextT0), =20 + [0xb8] =3D X86_OP_GROUP0(0FB8), /* decoded as modrm, which is visible as a difference between page fau= lt and #UD */ [0xb9] =3D X86_OP_ENTRYr(UD, nop,v), /* UD1= */ [0xba] =3D X86_OP_GROUP2(group8, E,v, I,b), [0xbb] =3D X86_OP_ENTRY2(BTC, E,v, G,v, btEvGv), + [0xbc] =3D X86_OP_GROUP0(0FBC), + [0xbd] =3D X86_OP_GROUP0(0FBD), [0xbe] =3D X86_OP_ENTRY3(MOV, G,v, E,b, None, None, sextT0), /* MOV= SX */ [0xbf] =3D X86_OP_ENTRY3(MOV, G,v, E,w, None, None, sextT0), /* MOV= SX */ =20 @@ -2174,6 +2221,8 @@ static bool has_cpuid_feature(DisasContext *s, X86CPU= IDFeature cpuid) return (s->cpuid_ext_features & CPUID_EXT_MOVBE); case X86_FEAT_PCLMULQDQ: return (s->cpuid_ext_features & CPUID_EXT_PCLMULQDQ); + case X86_FEAT_POPCNT: + return (s->cpuid_ext_features & CPUID_EXT_POPCNT); case X86_FEAT_SSE: return (s->cpuid_features & CPUID_SSE); case X86_FEAT_SSE2: @@ -2562,8 +2611,6 @@ static void disas_insn(DisasContext *s, CPUState *cpu) case 0x00 ... 0x01: /* mostly privileged instructions */ case 0x1a ... 0x1b: /* MPX */ case 0xb0 ... 0xb1: /* cmpxchg */ - case 0xb8: /* POPCNT */ - case 0xbc ... 0xbd: /* LZCNT/TZCNT */ case 0xc0 ... 0xc1: /* xadd */ case 0xc7: /* grp9 */ disas_insn_old(s, cpu, b + 0x100); diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index aabc86669c2..2fbf2a5ce8c 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1345,6 +1345,47 @@ static void gen_BOUND(DisasContext *s, X86DecodedIns= n *decode) } } =20 +/* Non-standard convention - on entry T0 is zero-extended input, T1 is the= output. */ +static void gen_BSF(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[0].ot; + + /* Only the Z bit is defined and it is related to the input. */ + decode->cc_dst =3D tcg_temp_new(); + decode->cc_op =3D CC_OP_LOGICB + ot; + tcg_gen_mov_tl(decode->cc_dst, s->T0); + + /* + * The manual says that the output is undefined when the + * input is zero, but real hardware leaves it unchanged, and + * real programs appear to depend on that. Accomplish this + * by passing the output as the value to return upon zero. + */ + tcg_gen_ctz_tl(s->T0, s->T0, s->T1); +} + +/* Non-standard convention - on entry T0 is zero-extended input, T1 is the= output. */ +static void gen_BSR(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[0].ot; + + /* Only the Z bit is defined and it is related to the input. */ + decode->cc_dst =3D tcg_temp_new(); + decode->cc_op =3D CC_OP_LOGICB + ot; + tcg_gen_mov_tl(decode->cc_dst, s->T0); + + /* + * The manual says that the output is undefined when the + * input is zero, but real hardware leaves it unchanged, and + * real programs appear to depend on that. Accomplish this + * by passing the output as the value to return upon zero. + * Plus, return the bit index of the first 1 bit. + */ + tcg_gen_xori_tl(s->T1, s->T1, TARGET_LONG_BITS - 1); + tcg_gen_clz_tl(s->T0, s->T0, s->T1); + tcg_gen_xori_tl(s->T0, s->T0, TARGET_LONG_BITS - 1); +} + static void gen_BSWAP(DisasContext *s, X86DecodedInsn *decode) { #ifdef TARGET_X86_64 @@ -2254,6 +2295,24 @@ static void gen_LSS(DisasContext *s, X86DecodedInsn = *decode) gen_lxx_seg(s, decode, R_SS); } =20 +static void gen_LZCNT(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[0].ot; + + /* C bit (cc_src) is defined related to the input. */ + decode->cc_src =3D tcg_temp_new(); + decode->cc_dst =3D s->T0; + decode->cc_op =3D CC_OP_BMILGB + ot; + tcg_gen_mov_tl(decode->cc_src, s->T0); + + /* + * Reduce the target_ulong result by the number of zeros that + * we expect to find at the top. + */ + tcg_gen_clzi_tl(s->T0, s->T0, TARGET_LONG_BITS); + tcg_gen_subi_tl(s->T0, s->T0, TARGET_LONG_BITS - (8 << ot)); +} + static void gen_MFENCE(DisasContext *s, X86DecodedInsn *decode) { tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); @@ -2812,6 +2871,15 @@ static void gen_POPA(DisasContext *s, X86DecodedInsn= *decode) gen_popa(s); } =20 +static void gen_POPCNT(DisasContext *s, X86DecodedInsn *decode) +{ + decode->cc_src =3D tcg_temp_new(); + decode->cc_op =3D CC_OP_POPCNT; + + tcg_gen_mov_tl(decode->cc_src, s->T0); + tcg_gen_ctpop_tl(s->T0, s->T0); +} + static void gen_POPF(DisasContext *s, X86DecodedInsn *decode) { MemOp ot; @@ -3893,6 +3961,20 @@ static void gen_SYSRET(DisasContext *s, X86DecodedIn= sn *decode) s->base.is_jmp =3D DISAS_EOB_RECHECK_TF; } =20 +static void gen_TZCNT(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[0].ot; + + /* C bit (cc_src) is defined related to the input. */ + decode->cc_src =3D tcg_temp_new(); + decode->cc_dst =3D s->T0; + decode->cc_op =3D CC_OP_BMILGB + ot; + tcg_gen_mov_tl(decode->cc_src, s->T0); + + /* A zero input returns the operand size. */ + tcg_gen_ctzi_tl(s->T0, s->T0, 8 << ot); +} + static void gen_UD(DisasContext *s, X86DecodedInsn *decode) { gen_illegal_opcode(s); --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836154; cv=none; d=zohomail.com; s=zohoarc; b=caN3VXxdZeyondZOFwjGScNp4HiuQim/cEo9e8yGDiTjs84W9LvGBuTgu+q2R9i2Er4TuNElDPnuC8sESezWOaqFPJNkY90WKDUuImFpKQKfX3CF/03O83XHWylDaRCy4MNRgKTYvr/t2X8+hhwjUHOWOOSw7WpLW/jK8qje4xg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836154; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=jYrEQWcxDBQQFmBcc6ABlYJsEPy9UqCkZtpsfzq2g7k=; b=SnXT2F5USx8uw10iMaqVFKJcwSCvWZzWJx7zXTzMHT4K7KTO7y4IlZtYSZSP/BAyxN1bA+Fl7Y7wscC0rW+gKCdUcf1tsd7hqPg3feg7V0buMTtM7XV5ZSyRIaFqgCbEiZhAc7n5iA5C46yDYhE9Uc57p8XerkNS9iATc8fDg8E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836154414513.2415813551909; Sat, 8 Jun 2024 01:42:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFreg-00045j-EL; Sat, 08 Jun 2024 04:42:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFref-00040O-6J for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFred-0001Y7-Gl for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:28 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-Y2g9pHlCOtmnxatd-RnypA-1; Sat, 08 Jun 2024 04:42:24 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a6f0ed4c213so4378466b.3 for ; Sat, 08 Jun 2024 01:42:24 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6efae62543sm92067466b.187.2024.06.08.01.42.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jYrEQWcxDBQQFmBcc6ABlYJsEPy9UqCkZtpsfzq2g7k=; b=Yppwdqq3YG9RvfR0wIfs9D+2/nDtXH4Vzj6NHCdawshFEEcI6odIPOw+VWIerh/P02NXkn h3+J/rEBLEA5GH15jH43YIKcyaVFwHQxK//oCflwFWkH6n9pboH7vS2H8N7XDNCONj6AHn 5FCgOuAn0nz6pCOYrCA+dsmbmPU+jpk= X-MC-Unique: Y2g9pHlCOtmnxatd-RnypA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836143; x=1718440943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jYrEQWcxDBQQFmBcc6ABlYJsEPy9UqCkZtpsfzq2g7k=; b=q9EMEdq9l0dw8CDtumoPFtwm2vrXILImcrGnDlZRFNYE2NuQgWVM8iNPrmgSSL1VIr iu9keBr7Af7einzSix9KoNUe+tjFP1InFeqMYbFFVC34Qj9PZbYAQ5VRVvU2S5wKTFKW NyCEhew6D3Ilwe5KsAU08vi0XOabSdm32WEzbgkJB7Y6A2DJtF3lU3EzmB3UpbEq0bTu mdTlPKClL7TGnGKm0meY27nesPC5+5eTAWO3uLul0QPPL4m6x++ZU4oRf3DnfyYKn2sv D+xpdj9QfF/TOYdleV0TYikx2J5jr6wNAHjWig3c02tqgBkA+pCcSaFbzHK50M0aUszf m46Q== X-Gm-Message-State: AOJu0Yx1/7E6jXfR5rZMB1ZdXWvna36WjkFE40rznEYRZoBlPmy49+LV QaT5YxVZ/bxnqSjKstWtVpVW3GVSr/qAf7ESfZSzBNIerX8rnaVoY4pcfIdLy3Qk+gJ5rkmiC2w 57CAEKAcuajsBMtCfAC2DN3iDJCz7/1iBeHUrfznJNKyRkls10fahAL3WjzZ4UgrikSDnxws74Y Bc4BV+0ZdZrNff/EEkN1zSeeUkHPNwYeuNNZTM X-Received: by 2002:a17:906:4914:b0:a62:c238:b229 with SMTP id a640c23a62f3a-a6cdb9d57c7mr383519366b.74.1717836142683; Sat, 08 Jun 2024 01:42:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/VDKWBzglee1m31xUtXloBLGDKmFs0mY/XTPCtZ72wbUsby1MpQ3SY7ezvuYek6GQTl/ypQ== X-Received: by 2002:a17:906:4914:b0:a62:c238:b229 with SMTP id a640c23a62f3a-a6cdb9d57c7mr383518066b.74.1717836142077; Sat, 08 Jun 2024 01:42:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 19/25] target/i386: convert XADD to new decoder Date: Sat, 8 Jun 2024 10:41:07 +0200 Message-ID: <20240608084113.2770363-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836156111100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Acked-by: Richard Henderson --- target/i386/tcg/translate.c | 35 -------------------------------- target/i386/tcg/decode-new.c.inc | 3 ++- target/i386/tcg/emit.c.inc | 24 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index a9cf1332b43..7a63c927c1f 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -818,12 +818,6 @@ static void gen_movs(DisasContext *s, MemOp ot) gen_op_add_reg(s, s->aflag, R_EDI, dshift); } =20 -static void gen_op_update2_cc(DisasContext *s) -{ - tcg_gen_mov_tl(cpu_cc_src, s->T1); - tcg_gen_mov_tl(cpu_cc_dst, s->T0); -} - /* compute all eflags to reg */ static void gen_mov_eflags(DisasContext *s, TCGv reg) { @@ -3006,35 +3000,6 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) switch (b) { /**************************/ /* arith & logic */ - case 0x1c0: - case 0x1c1: /* xadd Ev, Gv */ - ot =3D mo_b_d(b, dflag); - modrm =3D x86_ldub_code(env, s); - reg =3D ((modrm >> 3) & 7) | REX_R(s); - mod =3D (modrm >> 6) & 3; - gen_op_mov_v_reg(s, ot, s->T0, reg); - if (mod =3D=3D 3) { - rm =3D (modrm & 7) | REX_B(s); - gen_op_mov_v_reg(s, ot, s->T1, rm); - tcg_gen_add_tl(s->T0, s->T0, s->T1); - gen_op_mov_reg_v(s, ot, reg, s->T1); - gen_op_mov_reg_v(s, ot, rm, s->T0); - } else { - gen_lea_modrm(env, s, modrm); - if (s->prefix & PREFIX_LOCK) { - tcg_gen_atomic_fetch_add_tl(s->T1, s->A0, s->T0, - s->mem_index, ot | MO_LE); - tcg_gen_add_tl(s->T0, s->T0, s->T1); - } else { - gen_op_ld_v(s, ot, s->T1, s->A0); - tcg_gen_add_tl(s->T0, s->T0, s->T1); - gen_op_st_v(s, ot, s->T0, s->A0); - } - gen_op_mov_reg_v(s, ot, reg, s->T1); - } - gen_op_update2_cc(s); - set_cc_op(s, CC_OP_ADDB + ot); - break; case 0x1b0: case 0x1b1: /* cmpxchg Ev, Gv */ { diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 64ec731bf4a..11ecd1c6c1d 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1188,6 +1188,8 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xb6] =3D X86_OP_ENTRY3(MOV, G,v, E,b, None, None, zextT0), /* MOV= ZX */ [0xb7] =3D X86_OP_ENTRY3(MOV, G,v, E,w, None, None, zextT0), /* MOV= ZX */ =20 + [0xc0] =3D X86_OP_ENTRY2(XADD, E,b, G,b, lock), + [0xc1] =3D X86_OP_ENTRY2(XADD, E,v, G,v, lock), [0xc2] =3D X86_OP_ENTRY4(VCMP, V,x, H,x, W,x, vex2_rep3 p_= 00_66_f3_f2), [0xc3] =3D X86_OP_ENTRY3(MOV, EM,y,G,y, None,None, cpuid(SSE2))= , /* MOVNTI */ [0xc4] =3D X86_OP_ENTRY4(PINSRW, V,dq,H,dq,E,w, vex5 mmx p_0= 0_66), @@ -2611,7 +2613,6 @@ static void disas_insn(DisasContext *s, CPUState *cpu) case 0x00 ... 0x01: /* mostly privileged instructions */ case 0x1a ... 0x1b: /* MPX */ case 0xb0 ... 0xb1: /* cmpxchg */ - case 0xc0 ... 0xc1: /* xadd */ case 0xc7: /* grp9 */ disas_insn_old(s, cpu, b + 0x100); return; diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 2fbf2a5ce8c..42e41a7a87c 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -4492,6 +4492,30 @@ static void gen_WRxxBASE(DisasContext *s, X86Decoded= Insn *decode) tcg_gen_mov_tl(base, s->T0); } =20 +static void gen_XADD(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[1].ot; + + decode->cc_dst =3D tcg_temp_new(); + decode->cc_src =3D s->T1; + decode->cc_op =3D CC_OP_ADDB + ot; + + if (s->prefix & PREFIX_LOCK) { + tcg_gen_atomic_fetch_add_tl(s->T0, s->A0, s->T1, s->mem_index, ot = | MO_LE); + tcg_gen_add_tl(decode->cc_dst, s->T0, s->T1); + } else { + tcg_gen_add_tl(decode->cc_dst, s->T0, s->T1); + /* + * NOTE: writing memory first is important for MMU exceptions, + * but "new result" wins for XADD AX, AX. + */ + gen_writeback(s, decode, 0, decode->cc_dst); + } + if (decode->op[0].has_ea || decode->op[2].n !=3D decode->op[0].n) { + gen_writeback(s, decode, 2, s->T0); + } +} + static void gen_XCHG(DisasContext *s, X86DecodedInsn *decode) { if (s->prefix & PREFIX_LOCK) { --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836157; cv=none; d=zohomail.com; s=zohoarc; b=FP/WpEF2XzUt+k51+RHDGenP3ma8hDpACZ9mbbfQ/AYdwLOcRSI8Bk5o1UYPJ9kn7r4/LxIKVNz0YcwF/1dXmUzhHJZNVs7lCNB9+BKqzOmuxqJ6rfbMcPN3WgUwXvLDV00do5B24PRqlEv8KPnMpYBtV0A6F0eGOjELsPsFkdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836157; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=XW36JikV1vaIpwUTwftCWapesqtWR9fALEpfLU1nVko=; b=IMRWB6JuSilbjRVBqKgwE6peigWMBLX/cQsteQFAexpgLFaPBWFWa11tf5Y54CdNa5OKsZuYu4vA0HtI04Co+9gYwPe2UZJCRBPkpP+MJo1ZHmZCkyS1Wdvlo7A3IQy5FSUs1BrQ7nYQv0Kdg5g0mZ8GeHZN7RabMQhD8H8P2HQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836157126574.511947634125; Sat, 8 Jun 2024 01:42:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrek-0004YE-OU; Sat, 08 Jun 2024 04:42:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrei-0004JH-V2 for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFreg-0001YU-U9 for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:32 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-231-jtMqDDtvMYqDvhBgJ8xXCA-1; Sat, 08 Jun 2024 04:42:28 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a6ef729b8a7so45199266b.1 for ; Sat, 08 Jun 2024 01:42:27 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae0ca9besm3951043a12.27.2024.06.08.01.42.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836150; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XW36JikV1vaIpwUTwftCWapesqtWR9fALEpfLU1nVko=; b=VVkkg6Eog7RhTybA/vfgnUzcA5/fAxDQM1KQLUT2ZZSD0ySXDdW0VELLsWizWkp3PLLXFC oxvNxgX7j6H9tStM5r6Scl2n3/lJOyUW5oVqJaqwI+g6PMUa+BE/H66npQzmoIJlzrXXPm R3dPiVjLIinEvbfa1PDZIorlBoy4Jss= X-MC-Unique: jtMqDDtvMYqDvhBgJ8xXCA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836146; x=1718440946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XW36JikV1vaIpwUTwftCWapesqtWR9fALEpfLU1nVko=; b=uK4QGx2vQ/RNEoMRDoA5OnuSMHlfJWJ9wICbXVEjOtRCGyNQlmXLXZLHgg7pn11Blz 7bwDHxsR/GlCM7MpxIw08aZShPQdekfpDm1Tjv+UFzlrlxzQNkGm7qjsijwat8PtNjNf RZ1dXCnlb6O/fBG5RbGKNNcGr/p7WrsccktKzOptldwNYATvpDwSpuBhY1kB3GwFUUAF H3puggL/aHvnhSQ9BrebpavfB+FEhi+g1XHEIUmFlyoEDMs/i7m8dTuDEvVSNH1sCKqI P6WTb/AypXaPm9opGWhF6Nql99uTUGCfymSW2G+kvvfl+NXqPzlH8rq0mPVBGMPR7Lxh r4eA== X-Gm-Message-State: AOJu0YwB5gkaD29tZecxy4Z6tZaf4yQMAb5X9FvmsqU6vOS8FEkQWG2Y 5zCZN1aRH7vaBubNNVMDVglHnzJl9huRjgIV3ikR/T8cuUHAqDNXpGabrAWJPbl4YXMIbJRR+oR lTDHsjQvvzQk48HdcYn8jfxuenPMiNleEYROZETqmQaAgjXxCHRa5RgwlN+bii7AtxI2ngKHVV4 1wlCJdA/fUGkYVdBx9bE678YUnRmcLIVP1x3za X-Received: by 2002:a50:99d4:0:b0:57c:61df:fe68 with SMTP id 4fb4d7f45d1cf-57c61dfffafmr1411784a12.17.1717836145911; Sat, 08 Jun 2024 01:42:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvhYL/W+uvwVIeXsyuYe+3HTqrHgGWHq0+xmLkQ7vNm7RP2YlX5OI9QnZ48dak0ZvlF61uzA== X-Received: by 2002:a50:99d4:0:b0:57c:61df:fe68 with SMTP id 4fb4d7f45d1cf-57c61dfffafmr1411774a12.17.1717836145408; Sat, 08 Jun 2024 01:42:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 20/25] target/i386: convert CMPXCHG to new decoder Date: Sat, 8 Jun 2024 10:41:08 +0200 Message-ID: <20240608084113.2770363-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836158156100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 79 -------------------------------- target/i386/tcg/decode-new.c.inc | 3 +- target/i386/tcg/emit.c.inc | 51 +++++++++++++++++++++ 3 files changed, 53 insertions(+), 80 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 7a63c927c1f..1f76339130a 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -434,13 +434,6 @@ static inline MemOp mo_stacksize(DisasContext *s) return CODE64(s) ? MO_64 : SS32(s) ? MO_32 : MO_16; } =20 -/* Select size 8 if lsb of B is clear, else OT. Used for decoding - byte vs word opcodes. */ -static inline MemOp mo_b_d(int b, MemOp ot) -{ - return b & 1 ? ot : MO_8; -} - /* Compute the result of writing t0 to the OT-sized register REG. * * If DEST is NULL, store the result into the register and return the @@ -715,11 +708,6 @@ static TCGv gen_ext_tl(TCGv dst, TCGv src, MemOp size,= bool sign) return dst; } =20 -static void gen_extu(MemOp ot, TCGv reg) -{ - gen_ext_tl(reg, reg, ot, false); -} - static void gen_op_j_ecx(DisasContext *s, TCGCond cond, TCGLabel *label1) { TCGv tmp =3D gen_ext_tl(NULL, cpu_regs[R_ECX], s->aflag, false); @@ -2998,73 +2986,6 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) =20 /* now check op code */ switch (b) { - /**************************/ - /* arith & logic */ - case 0x1b0: - case 0x1b1: /* cmpxchg Ev, Gv */ - { - TCGv oldv, newv, cmpv, dest; - - ot =3D mo_b_d(b, dflag); - modrm =3D x86_ldub_code(env, s); - reg =3D ((modrm >> 3) & 7) | REX_R(s); - mod =3D (modrm >> 6) & 3; - oldv =3D tcg_temp_new(); - newv =3D tcg_temp_new(); - cmpv =3D tcg_temp_new(); - gen_op_mov_v_reg(s, ot, newv, reg); - tcg_gen_mov_tl(cmpv, cpu_regs[R_EAX]); - gen_extu(ot, cmpv); - if (s->prefix & PREFIX_LOCK) { - if (mod =3D=3D 3) { - goto illegal_op; - } - gen_lea_modrm(env, s, modrm); - tcg_gen_atomic_cmpxchg_tl(oldv, s->A0, cmpv, newv, - s->mem_index, ot | MO_LE); - } else { - if (mod =3D=3D 3) { - rm =3D (modrm & 7) | REX_B(s); - gen_op_mov_v_reg(s, ot, oldv, rm); - gen_extu(ot, oldv); - - /* - * Unlike the memory case, where "the destination oper= and receives - * a write cycle without regard to the result of the c= omparison", - * rm must not be touched altogether if the write fail= s, including - * not zero-extending it on 64-bit processors. So, pr= ecompute - * the result of a successful writeback and perform th= e movcond - * directly on cpu_regs. Also need to write accumulat= or first, in - * case rm is part of RAX too. - */ - dest =3D gen_op_deposit_reg_v(s, ot, rm, newv, newv); - tcg_gen_movcond_tl(TCG_COND_EQ, dest, oldv, cmpv, newv= , dest); - } else { - gen_lea_modrm(env, s, modrm); - gen_op_ld_v(s, ot, oldv, s->A0); - - /* - * Perform an unconditional store cycle like physical = cpu; - * must be before changing accumulator to ensure - * idempotency if the store faults and the instruction - * is restarted - */ - tcg_gen_movcond_tl(TCG_COND_EQ, newv, oldv, cmpv, newv= , oldv); - gen_op_st_v(s, ot, newv, s->A0); - } - } - /* - * Write EAX only if the cmpxchg fails; reuse newv as the destination, - * since it's dead here. - */ - dest =3D gen_op_deposit_reg_v(s, ot, R_EAX, newv, oldv); - tcg_gen_movcond_tl(TCG_COND_EQ, dest, oldv, cmpv, dest, newv); - tcg_gen_mov_tl(cpu_cc_src, oldv); - tcg_gen_mov_tl(s->cc_srcT, cmpv); - tcg_gen_sub_tl(cpu_cc_dst, cmpv, oldv); - set_cc_op(s, CC_OP_SUBB + ot); - } - break; case 0x1c7: /* cmpxchg8b */ modrm =3D x86_ldub_code(env, s); mod =3D (modrm >> 6) & 3; diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 11ecd1c6c1d..00ffaeb0763 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1181,6 +1181,8 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xa4] =3D X86_OP_ENTRY4(SHLD, E,v, 2op,v, G,v), [0xa5] =3D X86_OP_ENTRY3(SHLD, E,v, 2op,v, G,v), =20 + [0xb0] =3D X86_OP_ENTRY2(CMPXCHG,E,b, G,b, lock), + [0xb1] =3D X86_OP_ENTRY2(CMPXCHG,E,v, G,v, lock), [0xb2] =3D X86_OP_ENTRY3(LSS, G,v, EM,p, None, None), [0xb3] =3D X86_OP_ENTRY2(BTR, E,v, G,v, btEvGv), [0xb4] =3D X86_OP_ENTRY3(LFS, G,v, EM,p, None, None), @@ -2612,7 +2614,6 @@ static void disas_insn(DisasContext *s, CPUState *cpu) switch (b) { case 0x00 ... 0x01: /* mostly privileged instructions */ case 0x1a ... 0x1b: /* MPX */ - case 0xb0 ... 0xb1: /* cmpxchg */ case 0xc7: /* grp9 */ disas_insn_old(s, cpu, b + 0x100); return; diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 42e41a7a87c..857d270d247 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1708,6 +1708,57 @@ static void gen_CMPS(DisasContext *s, X86DecodedInsn= *decode) } } =20 +static void gen_CMPXCHG(DisasContext *s, X86DecodedInsn *decode) +{ + MemOp ot =3D decode->op[2].ot; + TCGv cmpv =3D tcg_temp_new(); + TCGv oldv =3D tcg_temp_new(); + TCGv newv =3D tcg_temp_new(); + TCGv dest; + + tcg_gen_ext_tl(cmpv, cpu_regs[R_EAX], ot); + tcg_gen_ext_tl(newv, s->T1, ot); + if (s->prefix & PREFIX_LOCK) { + tcg_gen_atomic_cmpxchg_tl(oldv, s->A0, cmpv, newv, + s->mem_index, ot | MO_LE); + } else { + tcg_gen_ext_tl(oldv, s->T0, ot); + if (decode->op[0].has_ea) { + /* + * Perform an unconditional store cycle like physical cpu; + * must be before changing accumulator to ensure + * idempotency if the store faults and the instruction + * is restarted + */ + tcg_gen_movcond_tl(TCG_COND_EQ, newv, oldv, cmpv, newv, oldv); + gen_op_st_v(s, ot, newv, s->A0); + } else { + /* + * Unlike the memory case, where "the destination operand rece= ives + * a write cycle without regard to the result of the compariso= n", + * rm must not be touched altogether if the write fails, inclu= ding + * not zero-extending it on 64-bit processors. So, precompute + * the result of a successful writeback and perform the movcond + * directly on cpu_regs. In case rm is part of RAX, note that= this + * movcond and the one below are mutually exclusive is execute= d. + */ + dest =3D gen_op_deposit_reg_v(s, ot, decode->op[0].n, newv, ne= wv); + tcg_gen_movcond_tl(TCG_COND_EQ, dest, oldv, cmpv, newv, dest); + } + decode->op[0].unit =3D X86_OP_SKIP; + } + + /* Write RAX only if the cmpxchg fails. */ + dest =3D gen_op_deposit_reg_v(s, ot, R_EAX, s->T0, oldv); + tcg_gen_movcond_tl(TCG_COND_NE, dest, oldv, cmpv, s->T0, dest); + + tcg_gen_mov_tl(s->cc_srcT, cmpv); + tcg_gen_sub_tl(cmpv, cmpv, oldv); + decode->cc_dst =3D cmpv; + decode->cc_src =3D oldv; + decode->cc_op =3D CC_OP_SUBB + ot; +} + static void gen_CPUID(DisasContext *s, X86DecodedInsn *decode) { gen_update_cc_op(s); --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836232; cv=none; d=zohomail.com; s=zohoarc; b=A3LQHYa8x8LZUzY7Ykjg/Gabd+GrCA4RlM8K2SKR/hsWPByJX1YshRH9+63g5JgE1/7+R0OUtfLcMxj90CJMWBSRtA1TLOWHX8WZxYvXBgFjSJtqF9oqB9EHepCB2ksbyhIrUojwFbnCwYhhOVJWvkLH6jXxiakbu5oA+7WY5Ts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836232; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=TJ30UM1qppgnTle3MP4hBsO/8VPGYAabM3E2aRdM+2o=; b=MjDAhO2CTp1/RoLQHCjTQkUoBmDm24KktWa04KldSUxrjPU33kJE1+Z0oM1um+57rxS7R+ZnsYu+zK9J/nGbr917zvaUNU48kYbd4Jq2oLxMzTbc+NbzPIZNomKPZDCLbsIz6ZR+FFgubfWTPAMOzZtsa88bdoP1ywek/GV7dPQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171783623226944.83736501834153; Sat, 8 Jun 2024 01:43:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrer-0005Oh-1i; Sat, 08 Jun 2024 04:42:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFren-0004xy-DD for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrek-0001Ym-BF for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:37 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-xAv-EJwiMTWqMF8S9gwYKg-1; Sat, 08 Jun 2024 04:42:32 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a6ef8d9d3efso16462666b.2 for ; Sat, 08 Jun 2024 01:42:31 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f0d7b35d5sm23485466b.192.2024.06.08.01.42.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TJ30UM1qppgnTle3MP4hBsO/8VPGYAabM3E2aRdM+2o=; b=YgMLFtenwtFOkm/2ruUCRwVKSO8uMEG3wwyd2HgxDIRjDJI1mZ4uBoPoStLsClyzxVk3Cp YqlHZ3AvFONdPM4MxSomJxJCTTxIZHcKExJKmPzzL5sZB2rOf0SlduP2lXr2v/0Gu9hcQd dD+ojTRMqj+leElwWJGii+8mO/KJESY= X-MC-Unique: xAv-EJwiMTWqMF8S9gwYKg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836150; x=1718440950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TJ30UM1qppgnTle3MP4hBsO/8VPGYAabM3E2aRdM+2o=; b=OIxtrqs7jmV9xk9lUi1K1MSGnhO6/b7QR9EgrV//jWA5nfoEsiv780kcReMCL/9oa7 +/fKA2N4t58oIAuUIgFKTTPtyWkBY7cYvDkg2u/7Mf9WmFTejSplXSgvHh3loPRald+V LVXc1FqTtik1ZXy+loCUkvREWNELTVzZFM7MffnJagxNNiTe2Yn5LZW2rFQyE5vqChNg 3q/Ek7mAP8q0RFIvS25Z0cF9LQRriEbE0HMS4Q0/6Gug8Im1A8llHI+Dwryl+R2Gf1R0 jPDgivWbzv8HGI2/sTXZjywkUVDeoacLCYXe/JSLTDV6i3E4ZSiMn2xJEqI2yfzECIr6 svfw== X-Gm-Message-State: AOJu0Yx+qKZlxR3hCbbxzostgxLPedbO2xALRHd0xzhaFDx01u9GS3f4 WnG0gdl+nievkYlhUaCVVDMtqhfeJFE0K0qBkJF1QemqIABAH89UTB05G9h/3ARu5oPA35eAlHG KwiNXmsTHB9XVWc5EqG4kSQsJsVTwEwku+w7QhbBMserlY4EU4iclrDtVI7fnk2NeBsJm/bV9ER 9Mh97XVaRSdAg5aC6TRwvLDSyMyfRhu82hqjvm X-Received: by 2002:a17:906:ae46:b0:a6f:b50:5e26 with SMTP id a640c23a62f3a-a6f0b505f39mr45320966b.54.1717836149461; Sat, 08 Jun 2024 01:42:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcuhgkxgFgX055B7dAnCuZt2KCw16efyQ2PNA0mW3KBmeKmbwf9oCRJsIvkpmy4AkJZkuoyQ== X-Received: by 2002:a17:906:ae46:b0:a6f:b50:5e26 with SMTP id a640c23a62f3a-a6f0b505f39mr45319366b.54.1717836148761; Sat, 08 Jun 2024 01:42:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 21/25] target/i386: decode address before going back to translate.c Date: Sat, 8 Jun 2024 10:41:09 +0200 Message-ID: <20240608084113.2770363-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836234373100003 Content-Type: text/plain; charset="utf-8" There are now relatively few unconverted opcodes in translate.c (there are 13 of them including 8 for x87), and all of them have the same format with a mod/rm byte and no immediate. A good next step is to remove the early bail out to disas_insn_x87/disas_insn_old, instead giving these legacy translator functions the same prototype as the other gen_* functions. To do this, the X86DecodeInsn can be passed down to the places that used to fetch address bytes from the instruction stream. To make sure that everything is done cleanly, the CPUX86State* argument is removed. As part of the unification, the gen_lea_modrm() name is now free, so rename gen_load_ea() to gen_lea_modrm(). This is as good a name and it makes the changes to translate.c easier to review. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.h | 14 ++- target/i386/tcg/translate.c | 152 +++++++++++++------------------ target/i386/tcg/decode-new.c.inc | 44 ++++----- target/i386/tcg/emit.c.inc | 2 +- 4 files changed, 94 insertions(+), 118 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index 13be23145a8..5d82136a287 100644 --- a/target/i386/tcg/decode-new.h +++ b/target/i386/tcg/decode-new.h @@ -263,12 +263,13 @@ typedef enum X86VEXSpecial { =20 typedef struct X86OpEntry X86OpEntry; typedef struct X86DecodedInsn X86DecodedInsn; +struct DisasContext; =20 /* Decode function for multibyte opcodes. */ -typedef void (*X86DecodeFunc)(DisasContext *s, CPUX86State *env, X86OpEntr= y *entry, uint8_t *b); +typedef void (*X86DecodeFunc)(struct DisasContext *s, CPUX86State *env, X8= 6OpEntry *entry, uint8_t *b); =20 /* Code generation function. */ -typedef void (*X86GenFunc)(DisasContext *s, X86DecodedInsn *decode); +typedef void (*X86GenFunc)(struct DisasContext *s, X86DecodedInsn *decode); =20 struct X86OpEntry { /* Based on the is_decode flags. */ @@ -315,6 +316,14 @@ typedef struct X86DecodedOp { }; } X86DecodedOp; =20 +typedef struct AddressParts { + int def_seg; + int base; + int index; + int scale; + target_long disp; +} AddressParts; + struct X86DecodedInsn { X86OpEntry e; X86DecodedOp op[3]; @@ -332,3 +341,4 @@ struct X86DecodedInsn { uint8_t b; }; =20 +static void gen_lea_modrm(struct DisasContext *s, X86DecodedInsn *decode); diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 1f76339130a..1bca4043a5c 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -29,6 +29,7 @@ #include "exec/helper-proto.h" #include "exec/helper-gen.h" #include "helper-tcg.h" +#include "decode-new.h" =20 #include "exec/log.h" =20 @@ -1527,14 +1528,6 @@ static inline uint64_t x86_ldq_code(CPUX86State *env= , DisasContext *s) =20 /* Decompose an address. */ =20 -typedef struct AddressParts { - int def_seg; - int base; - int index; - int scale; - target_long disp; -} AddressParts; - static AddressParts gen_lea_modrm_0(CPUX86State *env, DisasContext *s, int modrm) { @@ -1693,24 +1686,11 @@ static TCGv gen_lea_modrm_1(DisasContext *s, Addres= sParts a, bool is_vsib) return ea; } =20 -static void gen_lea_modrm(CPUX86State *env, DisasContext *s, int modrm) -{ - AddressParts a =3D gen_lea_modrm_0(env, s, modrm); - TCGv ea =3D gen_lea_modrm_1(s, a, false); - gen_lea_v_seg(s, ea, a.def_seg, s->override); -} - -static void gen_nop_modrm(CPUX86State *env, DisasContext *s, int modrm) -{ - (void)gen_lea_modrm_0(env, s, modrm); -} - /* Used for BNDCL, BNDCU, BNDCN. */ -static void gen_bndck(CPUX86State *env, DisasContext *s, int modrm, +static void gen_bndck(DisasContext *s, X86DecodedInsn *decode, TCGCond cond, TCGv_i64 bndv) { - AddressParts a =3D gen_lea_modrm_0(env, s, modrm); - TCGv ea =3D gen_lea_modrm_1(s, a, false); + TCGv ea =3D gen_lea_modrm_1(s, decode->mem, false); =20 tcg_gen_extu_tl_i64(s->tmp1_i64, ea); if (!CODE64(s)) { @@ -1722,8 +1702,9 @@ static void gen_bndck(CPUX86State *env, DisasContext = *s, int modrm, } =20 /* generate modrm load of memory or register. */ -static void gen_ld_modrm(CPUX86State *env, DisasContext *s, int modrm, Mem= Op ot) +static void gen_ld_modrm(DisasContext *s, X86DecodedInsn *decode, MemOp ot) { + int modrm =3D s->modrm; int mod, rm; =20 mod =3D (modrm >> 6) & 3; @@ -1731,14 +1712,15 @@ static void gen_ld_modrm(CPUX86State *env, DisasCon= text *s, int modrm, MemOp ot) if (mod =3D=3D 3) { gen_op_mov_v_reg(s, ot, s->T0, rm); } else { - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); gen_op_ld_v(s, ot, s->T0, s->A0); } } =20 /* generate modrm store of memory or register. */ -static void gen_st_modrm(CPUX86State *env, DisasContext *s, int modrm, Mem= Op ot) +static void gen_st_modrm(DisasContext *s, X86DecodedInsn *decode, MemOp ot) { + int modrm =3D s->modrm; int mod, rm; =20 mod =3D (modrm >> 6) & 3; @@ -1746,7 +1728,7 @@ static void gen_st_modrm(CPUX86State *env, DisasConte= xt *s, int modrm, MemOp ot) if (mod =3D=3D 3) { gen_op_mov_reg_v(s, ot, rm, s->T0); } else { - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); gen_op_st_v(s, ot, s->T0, s->A0); } } @@ -2314,12 +2296,12 @@ static void gen_sty_env_A0(DisasContext *s, int off= set, bool align) tcg_gen_qemu_st_i128(t, s->tmp0, mem_index, mop); } =20 -static void gen_cmpxchg8b(DisasContext *s, CPUX86State *env, int modrm) +static void gen_cmpxchg8b(DisasContext *s, X86DecodedInsn *decode) { TCGv_i64 cmp, val, old; TCGv Z; =20 - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); =20 cmp =3D tcg_temp_new_i64(); val =3D tcg_temp_new_i64(); @@ -2368,13 +2350,13 @@ static void gen_cmpxchg8b(DisasContext *s, CPUX86St= ate *env, int modrm) } =20 #ifdef TARGET_X86_64 -static void gen_cmpxchg16b(DisasContext *s, CPUX86State *env, int modrm) +static void gen_cmpxchg16b(DisasContext *s, X86DecodedInsn *decode) { MemOp mop =3D MO_TE | MO_128 | MO_ALIGN; TCGv_i64 t0, t1; TCGv_i128 cmp, val; =20 - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); =20 cmp =3D tcg_temp_new_i128(); val =3D tcg_temp_new_i128(); @@ -2412,31 +2394,32 @@ static void gen_cmpxchg16b(DisasContext *s, CPUX86S= tate *env, int modrm) } #endif =20 -static bool disas_insn_x87(DisasContext *s, CPUState *cpu, int b) +#include "emit.c.inc" + +static void gen_x87(DisasContext *s, X86DecodedInsn *decode) { - CPUX86State *env =3D cpu_env(cpu); bool update_fip =3D true; - int modrm, mod, rm, op; + int b =3D decode->b; + int modrm =3D s->modrm; + int mod, rm, op; =20 if (s->flags & (HF_EM_MASK | HF_TS_MASK)) { /* if CR0.EM or CR0.TS are set, generate an FPU exception */ /* XXX: what to do if illegal op ? */ gen_exception(s, EXCP07_PREX); - return true; + return; } - modrm =3D x86_ldub_code(env, s); mod =3D (modrm >> 6) & 3; rm =3D modrm & 7; op =3D ((b & 7) << 3) | ((modrm >> 3) & 7); if (mod !=3D 3) { /* memory op */ - AddressParts a =3D gen_lea_modrm_0(env, s, modrm); - TCGv ea =3D gen_lea_modrm_1(s, a, false); + TCGv ea =3D gen_lea_modrm_1(s, decode->mem, false); TCGv last_addr =3D tcg_temp_new(); bool update_fdp =3D true; =20 tcg_gen_mov_tl(last_addr, ea); - gen_lea_v_seg(s, ea, a.def_seg, s->override); + gen_lea_v_seg(s, ea, decode->mem.def_seg, s->override); =20 switch (op) { case 0x00 ... 0x07: /* fxxxs */ @@ -2626,11 +2609,11 @@ static bool disas_insn_x87(DisasContext *s, CPUStat= e *cpu, int b) gen_helper_fpop(tcg_env); break; default: - return false; + goto illegal_op; } =20 if (update_fdp) { - int last_seg =3D s->override >=3D 0 ? s->override : a.def_seg; + int last_seg =3D s->override >=3D 0 ? s->override : decode->me= m.def_seg; =20 tcg_gen_ld_i32(s->tmp2_i32, tcg_env, offsetof(CPUX86State, @@ -2667,7 +2650,7 @@ static bool disas_insn_x87(DisasContext *s, CPUState = *cpu, int b) update_fip =3D false; break; default: - return false; + goto illegal_op; } break; case 0x0c: /* grp d9/4 */ @@ -2686,7 +2669,7 @@ static bool disas_insn_x87(DisasContext *s, CPUState = *cpu, int b) gen_helper_fxam_ST0(tcg_env); break; default: - return false; + goto illegal_op; } break; case 0x0d: /* grp d9/5 */ @@ -2721,7 +2704,7 @@ static bool disas_insn_x87(DisasContext *s, CPUState = *cpu, int b) gen_helper_fldz_ST0(tcg_env); break; default: - return false; + goto illegal_op; } } break; @@ -2823,7 +2806,7 @@ static bool disas_insn_x87(DisasContext *s, CPUState = *cpu, int b) gen_helper_fpop(tcg_env); break; default: - return false; + goto illegal_op; } break; case 0x1c: @@ -2843,7 +2826,7 @@ static bool disas_insn_x87(DisasContext *s, CPUState = *cpu, int b) case 4: /* fsetpm (287 only, just do nop here) */ break; default: - return false; + goto illegal_op; } break; case 0x1d: /* fucomi */ @@ -2895,7 +2878,7 @@ static bool disas_insn_x87(DisasContext *s, CPUState = *cpu, int b) gen_helper_fpop(tcg_env); break; default: - return false; + goto illegal_op; } break; case 0x38: /* ffreep sti, undocumented op */ @@ -2910,7 +2893,7 @@ static bool disas_insn_x87(DisasContext *s, CPUState = *cpu, int b) gen_op_mov_reg_v(s, MO_16, R_EAX, s->T0); break; default: - return false; + goto illegal_op; } break; case 0x3d: /* fucomip */ @@ -2957,7 +2940,7 @@ static bool disas_insn_x87(DisasContext *s, CPUState = *cpu, int b) } break; default: - return false; + goto illegal_op; } } =20 @@ -2969,25 +2952,24 @@ static bool disas_insn_x87(DisasContext *s, CPUStat= e *cpu, int b) tcg_gen_st_tl(eip_cur_tl(s), tcg_env, offsetof(CPUX86State, fpip)); } - return true; + return; =20 illegal_op: gen_illegal_opcode(s); - return true; } =20 -static void disas_insn_old(DisasContext *s, CPUState *cpu, int b) +static void gen_multi0F(DisasContext *s, X86DecodedInsn *decode) { - CPUX86State *env =3D cpu_env(cpu); int prefixes =3D s->prefix; MemOp dflag =3D s->dflag; + int b =3D decode->b + 0x100; + int modrm =3D s->modrm; MemOp ot; - int modrm, reg, rm, mod, op; + int reg, rm, mod, op; =20 /* now check op code */ switch (b) { case 0x1c7: /* cmpxchg8b */ - modrm =3D x86_ldub_code(env, s); mod =3D (modrm >> 6) & 3; switch ((modrm >> 3) & 7) { case 1: /* CMPXCHG8, CMPXCHG16 */ @@ -2999,14 +2981,14 @@ static void disas_insn_old(DisasContext *s, CPUStat= e *cpu, int b) if (!(s->cpuid_ext_features & CPUID_EXT_CX16)) { goto illegal_op; } - gen_cmpxchg16b(s, env, modrm); + gen_cmpxchg16b(s, decode); break; } #endif if (!(s->cpuid_features & CPUID_CX8)) { goto illegal_op; } - gen_cmpxchg8b(s, env, modrm); + gen_cmpxchg8b(s, decode); break; =20 case 7: /* RDSEED, RDPID with f3 prefix */ @@ -3049,7 +3031,6 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) break; =20 case 0x100: - modrm =3D x86_ldub_code(env, s); mod =3D (modrm >> 6) & 3; op =3D (modrm >> 3) & 7; switch(op) { @@ -3063,14 +3044,14 @@ static void disas_insn_old(DisasContext *s, CPUStat= e *cpu, int b) tcg_gen_ld32u_tl(s->T0, tcg_env, offsetof(CPUX86State, ldt.selector)); ot =3D mod =3D=3D 3 ? dflag : MO_16; - gen_st_modrm(env, s, modrm, ot); + gen_st_modrm(s, decode, ot); break; case 2: /* lldt */ if (!PE(s) || VM86(s)) goto illegal_op; if (check_cpl0(s)) { gen_svm_check_intercept(s, SVM_EXIT_LDTR_WRITE); - gen_ld_modrm(env, s, modrm, MO_16); + gen_ld_modrm(s, decode, MO_16); tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0); gen_helper_lldt(tcg_env, s->tmp2_i32); } @@ -3085,14 +3066,14 @@ static void disas_insn_old(DisasContext *s, CPUStat= e *cpu, int b) tcg_gen_ld32u_tl(s->T0, tcg_env, offsetof(CPUX86State, tr.selector)); ot =3D mod =3D=3D 3 ? dflag : MO_16; - gen_st_modrm(env, s, modrm, ot); + gen_st_modrm(s, decode, ot); break; case 3: /* ltr */ if (!PE(s) || VM86(s)) goto illegal_op; if (check_cpl0(s)) { gen_svm_check_intercept(s, SVM_EXIT_TR_WRITE); - gen_ld_modrm(env, s, modrm, MO_16); + gen_ld_modrm(s, decode, MO_16); tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0); gen_helper_ltr(tcg_env, s->tmp2_i32); } @@ -3101,7 +3082,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) case 5: /* verw */ if (!PE(s) || VM86(s)) goto illegal_op; - gen_ld_modrm(env, s, modrm, MO_16); + gen_ld_modrm(s, decode, MO_16); gen_update_cc_op(s); if (op =3D=3D 4) { gen_helper_verr(tcg_env, s->T0); @@ -3111,19 +3092,18 @@ static void disas_insn_old(DisasContext *s, CPUStat= e *cpu, int b) assume_cc_op(s, CC_OP_EFLAGS); break; default: - goto unknown_op; + goto illegal_op; } break; =20 case 0x101: - modrm =3D x86_ldub_code(env, s); switch (modrm) { CASE_MODRM_MEM_OP(0): /* sgdt */ if (s->flags & HF_UMIP_MASK && !check_cpl0(s)) { break; } gen_svm_check_intercept(s, SVM_EXIT_GDTR_READ); - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); tcg_gen_ld32u_tl(s->T0, tcg_env, offsetof(CPUX86State, gdt.limit)); gen_op_st_v(s, MO_16, s->T0, s->A0); @@ -3179,7 +3159,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) break; } gen_svm_check_intercept(s, SVM_EXIT_IDTR_READ); - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); tcg_gen_ld32u_tl(s->T0, tcg_env, offsetof(CPUX86State, idt.lim= it)); gen_op_st_v(s, MO_16, s->T0, s->A0); gen_add_A0_im(s, 2); @@ -3329,7 +3309,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) break; } gen_svm_check_intercept(s, SVM_EXIT_GDTR_WRITE); - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); gen_op_ld_v(s, MO_16, s->T1, s->A0); gen_add_A0_im(s, 2); gen_op_ld_v(s, CODE64(s) + MO_32, s->T0, s->A0); @@ -3345,7 +3325,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) break; } gen_svm_check_intercept(s, SVM_EXIT_IDTR_WRITE); - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); gen_op_ld_v(s, MO_16, s->T1, s->A0); gen_add_A0_im(s, 2); gen_op_ld_v(s, CODE64(s) + MO_32, s->T0, s->A0); @@ -3369,7 +3349,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) */ mod =3D (modrm >> 6) & 3; ot =3D (mod !=3D 3 ? MO_16 : s->dflag); - gen_st_modrm(env, s, modrm, ot); + gen_st_modrm(s, decode, ot); break; case 0xee: /* rdpkru */ if (s->prefix & (PREFIX_LOCK | PREFIX_DATA @@ -3396,7 +3376,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) break; } gen_svm_check_intercept(s, SVM_EXIT_WRITE_CR0); - gen_ld_modrm(env, s, modrm, MO_16); + gen_ld_modrm(s, decode, MO_16); /* * Only the 4 lower bits of CR0 are modified. * PE cannot be set to zero if already set to one. @@ -3414,7 +3394,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) break; } gen_svm_check_intercept(s, SVM_EXIT_INVLPG); - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); gen_helper_flush_page(tcg_env, s->A0); s->base.is_jmp =3D DISAS_EOB_NEXT; break; @@ -3447,12 +3427,11 @@ static void disas_insn_old(DisasContext *s, CPUStat= e *cpu, int b) break; =20 default: - goto unknown_op; + goto illegal_op; } break; =20 case 0x11a: - modrm =3D x86_ldub_code(env, s); if (s->flags & HF_MPX_EN_MASK) { mod =3D (modrm >> 6) & 3; reg =3D ((modrm >> 3) & 7) | REX_R(s); @@ -3463,7 +3442,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) || s->aflag =3D=3D MO_16) { goto illegal_op; } - gen_bndck(env, s, modrm, TCG_COND_LTU, cpu_bndl[reg]); + gen_bndck(s, decode, TCG_COND_LTU, cpu_bndl[reg]); } else if (prefixes & PREFIX_REPNZ) { /* bndcu */ if (reg >=3D 4 @@ -3473,7 +3452,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) } TCGv_i64 notu =3D tcg_temp_new_i64(); tcg_gen_not_i64(notu, cpu_bndu[reg]); - gen_bndck(env, s, modrm, TCG_COND_GTU, notu); + gen_bndck(s, decode, TCG_COND_GTU, notu); } else if (prefixes & PREFIX_DATA) { /* bndmov -- from reg/mem */ if (reg >=3D 4 || s->aflag =3D=3D MO_16) { @@ -3489,7 +3468,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) tcg_gen_mov_i64(cpu_bndu[reg], cpu_bndu[reg2]); } } else { - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); if (CODE64(s)) { tcg_gen_qemu_ld_i64(cpu_bndl[reg], s->A0, s->mem_index, MO_LEUQ); @@ -3508,7 +3487,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) } } else if (mod !=3D 3) { /* bndldx */ - AddressParts a =3D gen_lea_modrm_0(env, s, modrm); + AddressParts a =3D decode->mem; if (reg >=3D 4 || (prefixes & PREFIX_LOCK) || s->aflag =3D=3D MO_16 @@ -3538,10 +3517,8 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) gen_set_hflag(s, HF_MPX_IU_MASK); } } - gen_nop_modrm(env, s, modrm); break; case 0x11b: - modrm =3D x86_ldub_code(env, s); if (s->flags & HF_MPX_EN_MASK) { mod =3D (modrm >> 6) & 3; reg =3D ((modrm >> 3) & 7) | REX_R(s); @@ -3552,7 +3529,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) || s->aflag =3D=3D MO_16) { goto illegal_op; } - AddressParts a =3D gen_lea_modrm_0(env, s, modrm); + AddressParts a =3D decode->mem; if (a.base >=3D 0) { tcg_gen_extu_tl_i64(cpu_bndl[reg], cpu_regs[a.base]); if (!CODE64(s)) { @@ -3565,7 +3542,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) /* rip-relative generates #ud */ goto illegal_op; } - tcg_gen_not_tl(s->A0, gen_lea_modrm_1(s, a, false)); + tcg_gen_not_tl(s->A0, gen_lea_modrm_1(s, decode->mem, fals= e)); if (!CODE64(s)) { tcg_gen_ext32u_tl(s->A0, s->A0); } @@ -3580,7 +3557,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) || s->aflag =3D=3D MO_16) { goto illegal_op; } - gen_bndck(env, s, modrm, TCG_COND_GTU, cpu_bndu[reg]); + gen_bndck(s, decode, TCG_COND_GTU, cpu_bndu[reg]); } else if (prefixes & PREFIX_DATA) { /* bndmov -- to reg/mem */ if (reg >=3D 4 || s->aflag =3D=3D MO_16) { @@ -3596,7 +3573,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) tcg_gen_mov_i64(cpu_bndu[reg2], cpu_bndu[reg]); } } else { - gen_lea_modrm(env, s, modrm); + gen_lea_modrm(s, decode); if (CODE64(s)) { tcg_gen_qemu_st_i64(cpu_bndl[reg], s->A0, s->mem_index, MO_LEUQ); @@ -3613,7 +3590,7 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) } } else if (mod !=3D 3) { /* bndstx */ - AddressParts a =3D gen_lea_modrm_0(env, s, modrm); + AddressParts a =3D decode->mem; if (reg >=3D 4 || (prefixes & PREFIX_LOCK) || s->aflag =3D=3D MO_16 @@ -3640,7 +3617,6 @@ static void disas_insn_old(DisasContext *s, CPUState = *cpu, int b) } } } - gen_nop_modrm(env, s, modrm); break; default: g_assert_not_reached(); @@ -3649,12 +3625,8 @@ static void disas_insn_old(DisasContext *s, CPUState= *cpu, int b) illegal_op: gen_illegal_opcode(s); return; - unknown_op: - gen_unknown_opcode(env, s); } =20 -#include "decode-new.h" -#include "emit.c.inc" #include "decode-new.c.inc" =20 void tcg_x86_init(void) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 00ffaeb0763..d75d242e552 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1092,6 +1092,8 @@ static void decode_MOV_CR_DR(DisasContext *s, CPUX86S= tate *env, X86OpEntry *entr } =20 static const X86OpEntry opcodes_0F[256] =3D { + [0x00] =3D X86_OP_ENTRY1(multi0F, nop,v, nolea), /*= unconverted */ + [0x01] =3D X86_OP_ENTRY1(multi0F, nop,v, nolea), /*= unconverted */ [0x02] =3D X86_OP_ENTRYwr(LAR, G,v, E,w, chk(prot)), [0x03] =3D X86_OP_ENTRYwr(LSL, G,v, E,w, chk(prot)), [0x05] =3D X86_OP_ENTRY0(SYSCALL, chk(o64_in= tel)), @@ -1197,6 +1199,7 @@ static const X86OpEntry opcodes_0F[256] =3D { [0xc4] =3D X86_OP_ENTRY4(PINSRW, V,dq,H,dq,E,w, vex5 mmx p_0= 0_66), [0xc5] =3D X86_OP_ENTRY3(PEXTRW, G,d, U,dq,I,b, vex5 mmx p_0= 0_66), [0xc6] =3D X86_OP_ENTRY4(VSHUF, V,x, H,x, W,x, vex4 p_00_66= ), + [0xc7] =3D X86_OP_ENTRY1(multi0F, nop,v, nolea), /* u= nconverted */ =20 [0xd0] =3D X86_OP_ENTRY3(VADDSUB, V,x, H,x, W,x, vex2 cpuid(S= SE3) p_66_f2), [0xd1] =3D X86_OP_ENTRY3(PSRLW_r, V,x, H,x, W,x, vex4 mmx avx= 2_256 p_00_66), @@ -1239,6 +1242,8 @@ static const X86OpEntry opcodes_0F[256] =3D { =20 [0x18] =3D X86_OP_ENTRY1(NOP, nop,v), /* prefetch/reserved NOP */ [0x19] =3D X86_OP_ENTRY1(NOP, nop,v), /* reserved NOP */ + [0x1a] =3D X86_OP_ENTRY1(multi0F, nop,v, nolea), /* unconverted MPX */ + [0x1b] =3D X86_OP_ENTRY1(multi0F, nop,v, nolea), /* unconverted MPX */ [0x1c] =3D X86_OP_ENTRY1(NOP, nop,v), /* reserved NOP */ [0x1d] =3D X86_OP_ENTRY1(NOP, nop,v), /* reserved NOP */ [0x1e] =3D X86_OP_ENTRY1(NOP, nop,v), /* reserved NOP */ @@ -1776,6 +1781,19 @@ static const X86OpEntry opcodes_root[256] =3D { [0xCE] =3D X86_OP_ENTRY0(INTO), [0xCF] =3D X86_OP_ENTRY0(IRET, chk(vm86_iopl) svm(IRET)), =20 + /* + * x87 is nolea because it needs the address without segment base, + * in order to store it in fdp. + */ + [0xD8] =3D X86_OP_ENTRY1(x87, nop,v, nolea), + [0xD9] =3D X86_OP_ENTRY1(x87, nop,v, nolea), + [0xDA] =3D X86_OP_ENTRY1(x87, nop,v, nolea), + [0xDB] =3D X86_OP_ENTRY1(x87, nop,v, nolea), + [0xDC] =3D X86_OP_ENTRY1(x87, nop,v, nolea), + [0xDD] =3D X86_OP_ENTRY1(x87, nop,v, nolea), + [0xDE] =3D X86_OP_ENTRY1(x87, nop,v, nolea), + [0xDF] =3D X86_OP_ENTRY1(x87, nop,v, nolea), + [0xE8] =3D X86_OP_ENTRYr(CALL, J,z_f64), [0xE9] =3D X86_OP_ENTRYr(JMP, J,z_f64), [0xEA] =3D X86_OP_ENTRYrr(JMPF, I_unsigned,p, I_unsigned,w, chk(i64)), @@ -2600,30 +2618,6 @@ static void disas_insn(DisasContext *s, CPUState *cp= u) } } =20 - /* Go back to old decoder for unconverted opcodes. */ - if (!(s->prefix & PREFIX_VEX)) { - if ((b & ~7) =3D=3D 0xd8) { - if (!disas_insn_x87(s, cpu, b)) { - goto unknown_op; - } - return; - } - - if (b =3D=3D 0x0f) { - b =3D x86_ldub_code(env, s); - switch (b) { - case 0x00 ... 0x01: /* mostly privileged instructions */ - case 0x1a ... 0x1b: /* MPX */ - case 0xc7: /* grp9 */ - disas_insn_old(s, cpu, b + 0x100); - return; - default: - decode_func =3D do_decode_0F; - break; - } - } - } - memset(&decode, 0, sizeof(decode)); decode.cc_op =3D -1; decode.b =3D b; @@ -2767,7 +2761,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) =20 if (decode.e.special !=3D X86_SPECIAL_NoLoadEA && (decode.op[0].has_ea || decode.op[1].has_ea || decode.op[2].has_ea= )) { - gen_load_ea(s, &decode); + gen_lea_modrm(s, &decode); } if (s->prefix & PREFIX_LOCK) { gen_load(s, &decode, 2, s->T1); diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 857d270d247..9234dde6e58 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -73,7 +73,7 @@ static void gen_NM_exception(DisasContext *s) gen_exception(s, EXCP07_PREX); } =20 -static void gen_load_ea(DisasContext *s, X86DecodedInsn *decode) +static void gen_lea_modrm(DisasContext *s, X86DecodedInsn *decode) { AddressParts *mem =3D &decode->mem; TCGv ea; --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836253; cv=none; d=zohomail.com; s=zohoarc; b=NlT27Afpao/AcrklWX12Z0klyc8WI9GGNkpclzhA0HDOuHf/WMcpdjPbsbMpAf7kB4yStwVwJpFZfsHaA1OS3hf7Y4y0+iWgLdawcrpobqF9KKZzGRjEW+r31KMEIeNifHtScxAMhzGrdMp9FxtTTEhuMJJxiwaizTDs5BBaSm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836253; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=gnPxP++vBG+ZmU6itBpqXWD3WTi6urAUaIoEJnFoGfc=; b=P7sqpM7Bp9yJ36sDYxb6QAqOcWq39qBvwz9UnRG8Qiajfhn1adn85nlCgjFOzXMIGoA7XhTWfG2juVIOMkiJCZRwWLiH0/ZekOsjrGV0OnFgNBy9vz/BapKnCEYNbEdzuyxJhXY/XGUxojMEVoWf/1AEOra7t0T1eQbLw0kL12U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836253313600.2819226385482; Sat, 8 Jun 2024 01:44:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFres-0005Xe-B1; Sat, 08 Jun 2024 04:42:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrep-0005J5-As for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFren-0001Yu-Ce for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:38 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-141-ntAH_1tsODG4h6L2nQqvVA-1; Sat, 08 Jun 2024 04:42:35 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a6f0d8b466dso8388666b.2 for ; Sat, 08 Jun 2024 01:42:35 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57c67432820sm1291473a12.75.2024.06.08.01.42.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836156; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gnPxP++vBG+ZmU6itBpqXWD3WTi6urAUaIoEJnFoGfc=; b=hIXYgJ46cTgCsP2b3nNDwdg/DT7qVYHGnUHgonbebnOpoCFPOjE46HPwu1l9IzjWAgMVA7 Q3+q26LvgJNmcao/wRMPp4E/35cZxe8LYyX6Ki4x3ZR2bk/2fkcNrvNxtXZwnGopFXzDyV 8QBWvV4FaPiwZD+lb2xeg3ikf9+QIsk= X-MC-Unique: ntAH_1tsODG4h6L2nQqvVA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836153; x=1718440953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gnPxP++vBG+ZmU6itBpqXWD3WTi6urAUaIoEJnFoGfc=; b=h4T43qIUoBmePGsbJBOxmYYhP+56rQQpypEtD5+uQzsx9Jtu/fK/IHfKJP1f7755Nd /rIXYp2DiByqDDZXZdB3vZbNFTXTzKVPVTJiJ2r00NbjYoGDoXnL+q+bUh+CW7hzSJDv FljD49KGTJcp20Ubo48X8nejhZhtBHEXzDQFBK4RQOC70nu/4GVHOKTcbrgLBGf7X8ee ynSBH2w68tDqcvG37pSUF+2GMpsKi+kTu4UnbcU8MJf8CEMeC9h/6CJ3PrvRn5dbhUYY ZV4pheLHHUzUgta+JFWkCJHvMKGIVrr63q74ZEdI+5o4l40qb0vUbajDLE9OiZzKzkMU sdDA== X-Gm-Message-State: AOJu0YzQWhFX+497waaYRWAEkKqmRgS7ogwnGoGajpb4j2UEMDI3vdOq JicsOEZmH33zYhMQ6RzH9qjPGPb6Y5UiWHLKwtdLaAy2Re/hIr2M/QtsX7jipFXQ4gRA0j9l6Yr X3Yi5xW0t4WaW0x+6DyYkPmH+YI9xxRqo/hZrmiTDj9Zss8frFxp9VL37mVH9tZFrgt4iNv6UdM kI/XvBkXVUPg9xqSOa7FuVSZXRkR62SNwQ3HMH X-Received: by 2002:a50:d4d2:0:b0:579:d673:4e67 with SMTP id 4fb4d7f45d1cf-57c509a023emr3380251a12.26.1717836152985; Sat, 08 Jun 2024 01:42:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAVsFMmDT00e3howiiP1j4Z1ZVL2kVvc16pNJotTyJx2mZUcCAJ6BLM6vffM4WrZ52mrkMaA== X-Received: by 2002:a50:d4d2:0:b0:579:d673:4e67 with SMTP id 4fb4d7f45d1cf-57c509a023emr3380243a12.26.1717836152658; Sat, 08 Jun 2024 01:42:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 22/25] target/i386: list instructions still in translate.c Date: Sat, 8 Jun 2024 10:41:10 +0200 Message-ID: <20240608084113.2770363-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836254369100005 Content-Type: text/plain; charset="utf-8" Group them so that it is easier to figure out which two-byte opcodes to tackle together. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/decode-new.c.inc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index d75d242e552..7463cf87f1a 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -129,6 +129,24 @@ * * (^) these are the two cases in which Intel and AMD disagree on the * primary exception class + * + * Instructions still in translate.c + * --------------------------------- + * x87: + * 0xD8 - 0xDF + * + * privileged/system: + * 0x0F 0x00 group 6 (SLDT, STR, LLDT, LTR, VERR, VERW) + * 0x0F 0x01 group 7 (SGDT, SIDT, LGDT, LIDT, SMSW, LMSW, INV= LPG, + * MONITOR, MWAIT, CLAC, STAC, XGETBV, XSE= TBV, + * SWAPGS, RDTSCP) + * + * MPX: + * 0x0F 0x1A BNDLDX, BNDMOV, BNDCL, BNDCU + * 0x0F 0x1B BNDSTX, BNDMOV, BNDMK, BNDCN + + * integer ops - atomic: + * 0x0F 0xC7 group 9 (CMPXCHG8B/CMPXCHG16B; also RDRAND, RDSE= ED, RDPID) */ =20 #define X86_OP_NONE { 0 }, --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836175; cv=none; d=zohomail.com; s=zohoarc; b=VmgWS/iSlUsCFcvTO/Z5Q2CHsSM+fESONmWlGcDf2KxxMVlQOJGpVIbOQbFBchNKcFcXi0qzFPmLWNanlrAOXHvxgYFl8hFFMqK05YGMNS3Plo0rKJ8ZLhRGKA23fEUEIBoxl/JUCy9/rueBFKoarSxlng2xuoMEj76jFETJY0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836175; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=dsXxfg6KJYeTLs0rcYYWAUKjN6thGDY6LKdrDrsYTIE=; b=mS2uFgy6H3XtBO2HxUgcNJ/6DcuwjvipJMYjLs/fcGgsWrJDDSzWbe2Ib4b93dhvPaQFY0smthh8yC8nb1UNRJLM89z8NsvWTJHF8DxHpZHULqcbG750GNub+vOF+iGJf2rPG26ibz/gvfDZ0N95Z1aQZArycJnPp7HA24cC6sU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836175925799.1544607575536; Sat, 8 Jun 2024 01:42:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrez-0006Hf-JZ; Sat, 08 Jun 2024 04:42:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrex-00064z-F5 for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrev-0001an-NZ for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:47 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-y0htr_QWPbCxYaIjNf6FOQ-1; Sat, 08 Jun 2024 04:42:40 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a6efac81377so29411366b.2 for ; Sat, 08 Jun 2024 01:42:39 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae0db916sm3950555a12.35.2024.06.08.01.42.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dsXxfg6KJYeTLs0rcYYWAUKjN6thGDY6LKdrDrsYTIE=; b=dJPjDTPMUtU2m3nNJk0BKWC0qZNiCf9xH6cEMorVrCOgjamLg0wM2Dx1p8ezQ+zO8heOGF YFaAMvxvviyX6/Azfr2hXDSiyFwsXWZGZ9SEdCtvvaIil/rsk8iEiTmqTbl5XDj8hx5XYk gbpo2oQU2m7GfryIA+bq+ruFI5WESJw= X-MC-Unique: y0htr_QWPbCxYaIjNf6FOQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836156; x=1718440956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dsXxfg6KJYeTLs0rcYYWAUKjN6thGDY6LKdrDrsYTIE=; b=Sb/GvHrckHhK7x3qt9uQH6h9wBsnQ8rPWw4aOI9Du3MtnRlqL0z0I6JpsQTDu1ZQh0 yyodp0T/7SX9e3BMk5gjrnVIUn+KynX3jeRNC+dR+4ZASiHJx08OxStDziVo1/6FY884 BzTbL9UE0HRjD0jk3k/8GW1fS+S19hwbIujemUlxtrm+Mp9dY+iHPkG8VI+txEdQPbUq BbEA5+sOxql+wlXDo/49Rb1rWQicRf0Suimzl6nvmbwLlpZL1FFNzDGK1rdRaIuYSmII UamagCaz7WdxmLkPi2+lkTEJq9RiYwwPkOPcGhXgvFR7nKdf/Iu5V09+XaRVmThQyB/f HmRA== X-Gm-Message-State: AOJu0YwNbt3QZ14vZBbJtgmKL01hviLnFmM/PQIrvk1PFE4uPvJgcYL8 p7CKsKYMlYvIdZe5GEf/0JnHBG+VlbCARu5xlyvnjDFe/Ykv0fSGp5F3cx8CxHvAX0MfeSCLuBa mUOlERR+vgZ++PqZC6zz90NkPIO01QlJdP1pgNzhlFJ95/6GtcLYjZp9L3p6gSm604pDU5MFt0L SMtgtre32nnQ0OnrGHmmuk9VUfyZYV8NAJjbsB X-Received: by 2002:a50:999d:0:b0:57c:6ae2:abda with SMTP id 4fb4d7f45d1cf-57c6ae2ac5emr959964a12.5.1717836156152; Sat, 08 Jun 2024 01:42:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGH6lacvikIHqBfLWvLSsEWT/BDDFmbD2D/kbm8esJfiKG5YkEFOu4raCmDMaiSkBq1Q+JSSQ== X-Received: by 2002:a50:999d:0:b0:57c:6ae2:abda with SMTP id 4fb4d7f45d1cf-57c6ae2ac5emr959951a12.5.1717836155811; Sat, 08 Jun 2024 01:42:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 23/25] target/i386: assert that cc_op* and pc_save are preserved Date: Sat, 8 Jun 2024 10:41:11 +0200 Message-ID: <20240608084113.2770363-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836176168100001 Content-Type: text/plain; charset="utf-8" Now all decoding has been done before any code generation. There is no need anymore to save and restore cc_op* and pc_save but, for the time being, assert that this is indeed the case. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 1bca4043a5c..67f2e792166 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -3834,15 +3834,9 @@ static void i386_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cpu) case 2: /* Restore state that may affect the next instruction. */ dc->pc =3D dc->base.pc_next; - /* - * TODO: These save/restore can be removed after the table-based - * decoder is complete; we will be decoding the insn completely - * before any code generation that might affect these variables. - */ - dc->cc_op_dirty =3D orig_cc_op_dirty; - dc->cc_op =3D orig_cc_op; - dc->pc_save =3D orig_pc_save; - /* END TODO */ + assert(dc->cc_op_dirty =3D=3D orig_cc_op_dirty); + assert(dc->cc_op =3D=3D orig_cc_op); + assert(dc->pc_save =3D=3D orig_pc_save); dc->base.num_insns--; tcg_remove_ops_after(dc->prev_insn_end); dc->base.insn_start =3D dc->prev_insn_start; --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836221; cv=none; d=zohomail.com; s=zohoarc; b=kLWskWIEcErPX3FSybJjebl5UbVntwJfMDSfQJb9eHXz619kiHTG3r7UzLTiuwYhmSKZ/aQEpf1mI1ihut0zxflBdJTZO1GxL2Lllkdx8SsrzaRT+uKW41B7mmA6wHB67AbvivXE04Z8w2YXJP43ob3LeGJ20PLRL88or3qDN5s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836221; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=4qJBuQ9HZXGNf8JTO/g0NQ+CxbpXs5W1hSQD+PtrFIA=; b=D8x8T5BrhUR21ItcsYpTp6nQ4TyLAHFvq3PFBIPAvLVkUyTfeKf1Wo/Ct/TMyn4MmNOsZK7nfmShlktFzRlPYHb6skyaeqpcPRcwLwcvnlekfso6kBBMYsNc5h581JH2/Dv448aXliZXQYKY/KnOGz8U1f+QArS8peUDszcj5x4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171783622160813.12288324162978; Sat, 8 Jun 2024 01:43:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrff-0002BI-Cy; Sat, 08 Jun 2024 04:43:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrfd-00028Q-NB for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:43:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrfc-0001hL-3u for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:43:29 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-438-j8tSaxubMjiOAI1KdZdmGw-1; Sat, 08 Jun 2024 04:42:45 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a6f0d8b466dso8390166b.2 for ; Sat, 08 Jun 2024 01:42:41 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80581cd9sm359603566b.16.2024.06.08.01.42.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4qJBuQ9HZXGNf8JTO/g0NQ+CxbpXs5W1hSQD+PtrFIA=; b=BIO24zOXk1O4+LYu1cFD5omnClP+MH3QFRRhR9Qrx8zzjM0coR+kWHyoMJ1GLHfyTDFf89 oyIxEtC24H90IJR/BcNrBoeMw8+UGDpVgddkEWROGzeUW9Ndz2mA/qfjdriwq8VvXqzs1E ifvRs20/VUI8waSpPuNgV5quYCy26vs= X-MC-Unique: j8tSaxubMjiOAI1KdZdmGw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836160; x=1718440960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4qJBuQ9HZXGNf8JTO/g0NQ+CxbpXs5W1hSQD+PtrFIA=; b=WxIcNLjWlRyzCzjTK2EoV+h+Lp0MQDlGB3nDXjthci0G9UtPA6irkwWjGPCIQD1heo 1YQRdNVaArTZp/E84Zn6UQHQjqy+wIoTheH7456gugVarOxdJLKJk/Uuj/ypLM7cL+tr mES8z1+wJ+l7ArvBg/jKdz0rpGHdq/eCAHXNBJMDRe4sQwosVXkSEDV4oeoc43pTZtR2 6DKnzvTEXYNJ1DKAGMjNi7QviAf4NatLIoJuIpxKoM7x/0f4Go9JOnsA3IV94YxWtZBJ FlzTJtOnp5Pr/vb63yiBB16A7laQZedQeUlL4FfOZPmEYLoMNMt5zgHwPwcOzZj8e3oY 2qIA== X-Gm-Message-State: AOJu0YxzmZTfjb7yvDohpC4ld/tY2+fDBh2oqJlT0ZS6Fump5c4DIb4s Htbr23d7mlEq/HpXLD4NBH7okt9dySCsFwJKR6jotXl0nHYBmca/LAwnkzAgA7zgshTixsEK9aQ ZkTvWE0tJ7z2BoQI8GomxSO0289JKLFKvRPSh/n7wBOHgCmxXwx/HuQBtpWbISyfpIAWO6D6GBY HEYSLt0rvJ6lMWbd/TXZPDM5RDCJlUEJ5M1MRK X-Received: by 2002:a50:9550:0:b0:57c:5bdd:178d with SMTP id 4fb4d7f45d1cf-57c5bdd19acmr3061172a12.6.1717836159943; Sat, 08 Jun 2024 01:42:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLIH0PdmDrQu7GMBeGfQYbTcjKXaoBUIsNl1AJk7gwZrfL/Aw3PZNkWkPRdOSgtXbmchuKdQ== X-Received: by 2002:a50:9550:0:b0:57c:5bdd:178d with SMTP id 4fb4d7f45d1cf-57c5bdd19acmr3061155a12.6.1717836159471; Sat, 08 Jun 2024 01:42:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 24/25] target/i386: do not check PREFIX_LOCK in old-style decoder Date: Sat, 8 Jun 2024 10:41:12 +0200 Message-ID: <20240608084113.2770363-25-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836222547100003 Content-Type: text/plain; charset="utf-8" It is already checked before getting there. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 67f2e792166..ee5ef3ccbc6 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -2993,7 +2993,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) =20 case 7: /* RDSEED, RDPID with f3 prefix */ if (mod !=3D 3 || - (s->prefix & (PREFIX_LOCK | PREFIX_REPNZ))) { + (s->prefix & PREFIX_REPNZ)) { goto illegal_op; } if (s->prefix & PREFIX_REPZ) { @@ -3013,7 +3013,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) =20 case 6: /* RDRAND */ if (mod !=3D 3 || - (s->prefix & (PREFIX_LOCK | PREFIX_REPZ | PREFIX_REPNZ)) || + (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) || !(s->cpuid_ext_features & CPUID_EXT_RDRAND)) { goto illegal_op; } @@ -3173,8 +3173,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) =20 case 0xd0: /* xgetbv */ if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) =3D=3D 0 - || (s->prefix & (PREFIX_LOCK | PREFIX_DATA - | PREFIX_REPZ | PREFIX_REPNZ))) { + || (s->prefix & (PREFIX_DATA | PREFIX_REPZ | PREFIX_REPNZ)= )) { goto illegal_op; } tcg_gen_trunc_tl_i32(s->tmp2_i32, cpu_regs[R_ECX]); @@ -3184,8 +3183,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) =20 case 0xd1: /* xsetbv */ if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) =3D=3D 0 - || (s->prefix & (PREFIX_LOCK | PREFIX_DATA - | PREFIX_REPZ | PREFIX_REPNZ))) { + || (s->prefix & (PREFIX_DATA | PREFIX_REPZ | PREFIX_REPNZ)= )) { goto illegal_op; } gen_svm_check_intercept(s, SVM_EXIT_XSETBV); @@ -3352,8 +3350,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) gen_st_modrm(s, decode, ot); break; case 0xee: /* rdpkru */ - if (s->prefix & (PREFIX_LOCK | PREFIX_DATA - | PREFIX_REPZ | PREFIX_REPNZ)) { + if (s->prefix & (PREFIX_DATA | PREFIX_REPZ | PREFIX_REPNZ)) { goto illegal_op; } tcg_gen_trunc_tl_i32(s->tmp2_i32, cpu_regs[R_ECX]); @@ -3361,8 +3358,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) tcg_gen_extr_i64_tl(cpu_regs[R_EAX], cpu_regs[R_EDX], s->tmp1_= i64); break; case 0xef: /* wrpkru */ - if (s->prefix & (PREFIX_LOCK | PREFIX_DATA - | PREFIX_REPZ | PREFIX_REPNZ)) { + if (s->prefix & (PREFIX_DATA | PREFIX_REPZ | PREFIX_REPNZ)) { goto illegal_op; } tcg_gen_concat_tl_i64(s->tmp1_i64, cpu_regs[R_EAX], @@ -3438,7 +3434,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) if (prefixes & PREFIX_REPZ) { /* bndcl */ if (reg >=3D 4 - || (prefixes & PREFIX_LOCK) || s->aflag =3D=3D MO_16) { goto illegal_op; } @@ -3446,7 +3441,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) } else if (prefixes & PREFIX_REPNZ) { /* bndcu */ if (reg >=3D 4 - || (prefixes & PREFIX_LOCK) || s->aflag =3D=3D MO_16) { goto illegal_op; } @@ -3460,7 +3454,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) } if (mod =3D=3D 3) { int reg2 =3D (modrm & 7) | REX_B(s); - if (reg2 >=3D 4 || (prefixes & PREFIX_LOCK)) { + if (reg2 >=3D 4) { goto illegal_op; } if (s->flags & HF_MPX_IU_MASK) { @@ -3489,7 +3483,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) /* bndldx */ AddressParts a =3D decode->mem; if (reg >=3D 4 - || (prefixes & PREFIX_LOCK) || s->aflag =3D=3D MO_16 || a.base < -1) { goto illegal_op; @@ -3525,7 +3518,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) if (mod !=3D 3 && (prefixes & PREFIX_REPZ)) { /* bndmk */ if (reg >=3D 4 - || (prefixes & PREFIX_LOCK) || s->aflag =3D=3D MO_16) { goto illegal_op; } @@ -3553,7 +3545,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) } else if (prefixes & PREFIX_REPNZ) { /* bndcn */ if (reg >=3D 4 - || (prefixes & PREFIX_LOCK) || s->aflag =3D=3D MO_16) { goto illegal_op; } @@ -3565,7 +3556,7 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) } if (mod =3D=3D 3) { int reg2 =3D (modrm & 7) | REX_B(s); - if (reg2 >=3D 4 || (prefixes & PREFIX_LOCK)) { + if (reg2 >=3D 4) { goto illegal_op; } if (s->flags & HF_MPX_IU_MASK) { @@ -3592,7 +3583,6 @@ static void gen_multi0F(DisasContext *s, X86DecodedIn= sn *decode) /* bndstx */ AddressParts a =3D decode->mem; if (reg >=3D 4 - || (prefixes & PREFIX_LOCK) || s->aflag =3D=3D MO_16 || a.base < -1) { goto illegal_op; --=20 2.45.1 From nobody Mon Nov 25 02:23:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717836243; cv=none; d=zohomail.com; s=zohoarc; b=MtxDuZjtBapEEsn3iv0aI9WCVmcf5AcaUuHtBVTJ9p6Wd60713lSDir1e6r+xEPuKkl4Dsw9t8Fn+ZmbFe9wAY8Q6fF5IXOA6rrA6x+um0aBpPaF7XZ365//aTxwWjHTlbyUSDATEP+fXJuWFh1TTs2AlubQooC9VZuLMeq2WVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717836243; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=y89oAmpMMJpJrCJMrNComgRidKETfKFzJFsG8GNQjw0=; b=kElq8mX+tQogxDTgfyitg5sEwj18TyT+RsRsZfi8/j3rZrajACRGIxSfj0ojilG6kO0zll6YN6uG9lSlOGWbxVaR6w5v6EecOPSRaSaBgOi+THHzPBUXYRjFzSmdjO1pJKWj38jcVg1Uh/BHIkALiKmu5kaIH+Jjo1OXdjznoNA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717836243960101.35007468796516; Sat, 8 Jun 2024 01:44:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrf4-0006Vy-Jf; Sat, 08 Jun 2024 04:42:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrf0-0006Lg-88 for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sFrey-0001b1-Ig for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:42:49 -0400 Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-qKlgK2_wOe6vSR6V2kiEBQ-1; Sat, 08 Jun 2024 04:42:45 -0400 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-52c091e4413so574408e87.2 for ; Sat, 08 Jun 2024 01:42:45 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c805cccfesm356672866b.86.2024.06.08.01.42.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717836167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y89oAmpMMJpJrCJMrNComgRidKETfKFzJFsG8GNQjw0=; b=gjQ8Y6V0wbr+wgYokAiCVDCsNlHOtaRzLbt0Y6U2bUSKIbNLQHtWeBzFmL7soFJ+E/oIAX rx9BNOLWSNSbbe0j8TMQOvZPOpraauud6vv4OhMYbFXaDUjRGgmgWROivyOpt+TEkxUNCt EQ81Y531KJc+HV6Ps8Qqwc4JOVIUfTc= X-MC-Unique: qKlgK2_wOe6vSR6V2kiEBQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717836163; x=1718440963; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y89oAmpMMJpJrCJMrNComgRidKETfKFzJFsG8GNQjw0=; b=Kz0gVyzmivGO1DrodzYK31alMN9cOhFS4vrfy7evRRMHvQX+bjqGXQl8AjSEqf0Tsz nQWwerWatslJvo1Z6i3GsvYp2Dev0xrh1MrmjoFV/bfVoGRLdatmCjO+tQFTRIuL4mt6 +oHyP6ffdoYj3v7SzWMreYeKzQa70HSuTLNK8ADPiUMO93BpwIxw695dwrIeV1Y3dpeY vjVE/XYaBYh6/BtmOEn+t+p90T7gPd0/d2tcq6xRldfRoGn6IzLXEqvHT1+EFZJQAudN 6PogzjoY9HalhMgTeqp1Pk1G9gsrppnWd6SNGEzWYXcWqw2C9TITUlBH64JcoX1jH6pR 9dwQ== X-Gm-Message-State: AOJu0Yx869HI48AYNXuBZZhEusa/IQTc/GxvyIYH3VT+l5rZjNQP48F+ v5ObTr1Dpm5j8pEWAuZhX3varvUsTlER7vsO33tGXsqMAwkcpN4Bn0wwm32aBDljF3bnwPe1aAO wMX0ki6nd+bpwNXB85lpTgqHC/07SReQ6CU/4j7hDNmcLQcdrfCQ17IONmx8zDAOSM6lPknEie3 EDO02OAJHq8npKyyJNTFO1Q26UHx3dVjcD4rdD X-Received: by 2002:a05:6512:3d29:b0:52b:959c:1dc7 with SMTP id 2adb3069b0e04-52bb9fc5eadmr4604719e87.42.1717836163154; Sat, 08 Jun 2024 01:42:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKHrz81WP2xiFpiVddh0eh54+736GE4evfMlYCqo2TTlegcY2tLEND4G4PFazZ2nfu0BgaAA== X-Received: by 2002:a05:6512:3d29:b0:52b:959c:1dc7 with SMTP id 2adb3069b0e04-52bb9fc5eadmr4604705e87.42.1717836162695; Sat, 08 Jun 2024 01:42:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 25/25] target/i386: remove gen_ext_tl Date: Sat, 8 Jun 2024 10:41:13 +0200 Message-ID: <20240608084113.2770363-26-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608084113.2770363-1-pbonzini@redhat.com> References: <20240608084113.2770363-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717836244349100001 Content-Type: text/plain; charset="utf-8" With the introduction of tcg_gen_ext_tl, most uses can be converted directly because they do not have a NULL destination. tcg_gen_ext_tl is able to drop no-ops like "tcg_gen_ext_tl(tcgv, tcgv, MO_TL)" just fine, and the only thi= ng that gen_ext_tl was adding on top was avoiding the creation of a useless temporary. This can be done in the only place where it matters, which is gen_op_j_ecx. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 41 +++++++++++++++---------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index ee5ef3ccbc6..8089b502628 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -697,23 +697,16 @@ static inline TCGv gen_compute_Dshift(DisasContext *s= , MemOp ot) return dshift; }; =20 -static TCGv gen_ext_tl(TCGv dst, TCGv src, MemOp size, bool sign) -{ - if (size =3D=3D MO_TL) { - return src; - } - if (!dst) { - dst =3D tcg_temp_new(); - } - tcg_gen_ext_tl(dst, src, size | (sign ? MO_SIGN : 0)); - return dst; -} - static void gen_op_j_ecx(DisasContext *s, TCGCond cond, TCGLabel *label1) { - TCGv tmp =3D gen_ext_tl(NULL, cpu_regs[R_ECX], s->aflag, false); - - tcg_gen_brcondi_tl(cond, tmp, 0, label1); + TCGv lhs; + if (s->aflag =3D=3D MO_TL) { + lhs =3D cpu_regs[R_ECX]; + } else { + lhs =3D tcg_temp_new(); + tcg_gen_ext_tl(lhs, cpu_regs[R_ECX], s->aflag); + } + tcg_gen_brcondi_tl(cond, lhs, 0, label1); } =20 static inline void gen_op_jz_ecx(DisasContext *s, TCGLabel *label1) @@ -886,16 +879,16 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s= , TCGv reg) case CC_OP_SUBB ... CC_OP_SUBQ: /* (DATA_TYPE)CC_SRCT < (DATA_TYPE)CC_SRC */ size =3D s->cc_op - CC_OP_SUBB; - gen_ext_tl(s->cc_srcT, s->cc_srcT, size, false); - gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); + tcg_gen_ext_tl(s->cc_srcT, s->cc_srcT, size); + tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size); return (CCPrepare) { .cond =3D TCG_COND_LTU, .reg =3D s->cc_srcT, .reg2 =3D cpu_cc_src, .use_reg2 =3D true }; =20 case CC_OP_ADDB ... CC_OP_ADDQ: /* (DATA_TYPE)CC_DST < (DATA_TYPE)CC_SRC */ size =3D s->cc_op - CC_OP_ADDB; - gen_ext_tl(cpu_cc_dst, cpu_cc_dst, size, false); - gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); + tcg_gen_ext_tl(cpu_cc_dst, cpu_cc_dst, size); + tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size); return (CCPrepare) { .cond =3D TCG_COND_LTU, .reg =3D cpu_cc_dst, .reg2 =3D cpu_cc_src, .use_reg2 =3D true }; =20 @@ -920,7 +913,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, = TCGv reg) =20 case CC_OP_BMILGB ... CC_OP_BMILGQ: size =3D s->cc_op - CC_OP_BMILGB; - gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); + tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size); return (CCPrepare) { .cond =3D TCG_COND_EQ, .reg =3D cpu_cc_src }; =20 case CC_OP_ADCX: @@ -1048,8 +1041,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int = b, TCGv reg) size =3D s->cc_op - CC_OP_SUBB; switch (jcc_op) { case JCC_BE: - gen_ext_tl(s->cc_srcT, s->cc_srcT, size, false); - gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); + tcg_gen_ext_tl(s->cc_srcT, s->cc_srcT, size); + tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size); cc =3D (CCPrepare) { .cond =3D TCG_COND_LEU, .reg =3D s->cc_sr= cT, .reg2 =3D cpu_cc_src, .use_reg2 =3D true }; break; @@ -1059,8 +1052,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int = b, TCGv reg) case JCC_LE: cond =3D TCG_COND_LE; fast_jcc_l: - gen_ext_tl(s->cc_srcT, s->cc_srcT, size, true); - gen_ext_tl(cpu_cc_src, cpu_cc_src, size, true); + tcg_gen_ext_tl(s->cc_srcT, s->cc_srcT, size | MO_SIGN); + tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size | MO_SIGN); cc =3D (CCPrepare) { .cond =3D cond, .reg =3D s->cc_srcT, .reg2 =3D cpu_cc_src, .use_reg2 =3D true }; break; --=20 2.45.1