From nobody Tue Sep 16 17:18:33 2025 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717835796; cv=none; d=zohomail.com; s=zohoarc; b=fg+kzcCmqfbkBfbHm+1Z21wwUK0BW/HKv2LzxbY4Ig524b2i6cjkWM94NBSmPVUWFuzRNDBr/9yRFo1yi/LOqU8w49z2l62YNrvQ5otYAF8S4bwKOhl4bu8QqxIVPAbYOAaNbRO3p9HJ50ep+r+5+SThPtJpquef9KtH32szNKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717835796; 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=1ZXg5/L7nPPJRmwWi/bRL++Ow5ed1vgkGFx1Ql7WL3I=; b=drz0qM5KgNPe3NE7JFZfccZ7QeOw2waXIY2+g1mwMT1uNZjXN6Czuo8O8QtzhbMTjNP+nHjOE8BthLwYAYC00bj0Jd1i8wArpf/nYQKDsrtQ259J0soxAtcFtU9Vg0StOQnXazU1tkr5kxLd4s8/2c/dTs3G77oErsduv8vnMcc= 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+importer2=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 171783579611558.20500899226647; Sat, 8 Jun 2024 01:36:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFrX8-0000Wi-2f; Sat, 08 Jun 2024 04:34: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 1sFrX4-0000UF-8w for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:34:39 -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 1sFrX2-0008G7-3u for qemu-devel@nongnu.org; Sat, 08 Jun 2024 04:34:38 -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-218-GKuY5RmpMXakumNlVb2lfQ-1; Sat, 08 Jun 2024 04:34:30 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57c5216e486so816695a12.0 for ; Sat, 08 Jun 2024 01:34:30 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae102c7esm3930956a12.45.2024.06.08.01.34.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 01:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717835673; 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=1ZXg5/L7nPPJRmwWi/bRL++Ow5ed1vgkGFx1Ql7WL3I=; b=jCvdx4o3SrXnjZduAyePVYW++kdiQ0pLqk41HoRnL/DLaeTtUlsDEdoQYHcSktYCyKYRto wHSjnzFljnpNPFAGS8bxTUDQHsEHoBO7zryGSWdo5OFRpuqDOwlNU3usoYyZUrwEMcaVxT aDuwMqdDT68rHTmp/aZDcJUgJllN5U8= X-MC-Unique: GKuY5RmpMXakumNlVb2lfQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717835669; x=1718440469; 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=1ZXg5/L7nPPJRmwWi/bRL++Ow5ed1vgkGFx1Ql7WL3I=; b=F7Maaw7mxd5wL2Rya4aRL/6sfExF1CSklNVbYyyn/XBk2/O121+DK9JoRNhVECCE8d MNYKuNmGX5/NAG+nXSWGw3EFnyeA9puaY+C9/SdQ5yqVKteLpdMxvN4XYl6O25qGB/6m SAROuv54BAGGFiSs01RD4OOj8Z009leDFQcamIE30Pfxk6WIh7FVZxd9QmOpBGzsVENj hvkTqqkGi4P8ZH7Y284nUqkmZBf71nxI0NIwetzitVTQF+yqVo5qSfIQdOpdnvpa293K LZzoffPUySl+CQn1vdHP/uuElEmOEMNuKMaUS2sLg78lFtGSHjO32IoOkXGiBIBnachA HGKw== X-Gm-Message-State: AOJu0YzS8cwByLAtHI7d7McIayF5vvwb8+QNKBU8gnlSNlYDCwgGVcjc GMyt72bahBXpMMl/Jkoekz9jNiTjXFC5Db6c+93zZP382uJ3VKw6QkqDVxp/ikxL+ZnbOi9TYBv 0xWq9q+AH7Qh32LX6Nci+hYe0SYDn/5GpwdyPED+ZNCQsTMmZ4odJw9Dc0sNRSvmwkeg3uEuJVD Ohgvweqn5Y9tnslJGE8ETcn2HTutlHWrZJW5HX X-Received: by 2002:a50:d61b:0:b0:57c:41e1:6e59 with SMTP id 4fb4d7f45d1cf-57c50924b9bmr3004373a12.23.1717835668909; Sat, 08 Jun 2024 01:34:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF335a0HmK8kKOQbYU2x9BhmnyqUpOUwWyWpPBso3bkWBahxyny/BxxU7UnFdNGtHIwSkEB2w== X-Received: by 2002:a50:d61b:0:b0:57c:41e1:6e59 with SMTP id 4fb4d7f45d1cf-57c50924b9bmr3004362a12.23.1717835668432; Sat, 08 Jun 2024 01:34:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/42] target/i386: cleanup PAUSE helpers Date: Sat, 8 Jun 2024 10:33:37 +0200 Message-ID: <20240608083415.2769160-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240608083415.2769160-1-pbonzini@redhat.com> References: <20240608083415.2769160-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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717835796315100009 Content-Type: text/plain; charset="utf-8" Use decode.c's support for intercepts, doing the check in TCG-generated code rather than the helper. This is cleaner because it allows removing the eip_addend argument to helper_pause(), even though it adds a bit of bloat for opcode 0x90's new decoding function. Signed-off-by: Paolo Bonzini --- target/i386/helper.h | 2 +- target/i386/tcg/helper-tcg.h | 1 - target/i386/tcg/misc_helper.c | 10 +--------- target/i386/tcg/sysemu/misc_helper.c | 2 +- target/i386/tcg/decode-new.c.inc | 15 ++++++++++++++- target/i386/tcg/emit.c.inc | 20 ++++++++------------ 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/target/i386/helper.h b/target/i386/helper.h index c244dbb4812..2f46cffabd8 100644 --- a/target/i386/helper.h +++ b/target/i386/helper.h @@ -53,7 +53,7 @@ DEF_HELPER_1(sysenter, void, env) DEF_HELPER_2(sysexit, void, env, int) DEF_HELPER_2(syscall, void, env, int) DEF_HELPER_2(sysret, void, env, int) -DEF_HELPER_FLAGS_2(pause, TCG_CALL_NO_WG, noreturn, env, int) +DEF_HELPER_FLAGS_1(pause, TCG_CALL_NO_WG, noreturn, env) DEF_HELPER_FLAGS_3(raise_interrupt, TCG_CALL_NO_WG, noreturn, env, int, in= t) DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, int) DEF_HELPER_FLAGS_1(icebp, TCG_CALL_NO_WG, noreturn, env) diff --git a/target/i386/tcg/helper-tcg.h b/target/i386/tcg/helper-tcg.h index eb6a4926a43..15d6c6f8b4f 100644 --- a/target/i386/tcg/helper-tcg.h +++ b/target/i386/tcg/helper-tcg.h @@ -91,7 +91,6 @@ extern const uint8_t parity_table[256]; =20 /* misc_helper.c */ void cpu_load_eflags(CPUX86State *env, int eflags, int update_mask); -G_NORETURN void do_pause(CPUX86State *env); =20 /* sysemu/svm_helper.c */ #ifndef CONFIG_USER_ONLY diff --git a/target/i386/tcg/misc_helper.c b/target/i386/tcg/misc_helper.c index b0f0f7b893b..8316d42ffcd 100644 --- a/target/i386/tcg/misc_helper.c +++ b/target/i386/tcg/misc_helper.c @@ -88,7 +88,7 @@ G_NORETURN void helper_rdpmc(CPUX86State *env) raise_exception_err(env, EXCP06_ILLOP, 0); } =20 -G_NORETURN void do_pause(CPUX86State *env) +G_NORETURN void helper_pause(CPUX86State *env) { CPUState *cs =3D env_cpu(env); =20 @@ -97,14 +97,6 @@ G_NORETURN void do_pause(CPUX86State *env) cpu_loop_exit(cs); } =20 -G_NORETURN void helper_pause(CPUX86State *env, int next_eip_addend) -{ - cpu_svm_check_intercept_param(env, SVM_EXIT_PAUSE, 0, GETPC()); - env->eip +=3D next_eip_addend; - - do_pause(env); -} - uint64_t helper_rdpkru(CPUX86State *env, uint32_t ecx) { if ((env->cr[4] & CR4_PKE_MASK) =3D=3D 0) { diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/= misc_helper.c index e41c88346cb..093cc2d0f90 100644 --- a/target/i386/tcg/sysemu/misc_helper.c +++ b/target/i386/tcg/sysemu/misc_helper.c @@ -547,7 +547,7 @@ G_NORETURN void helper_mwait(CPUX86State *env, int next= _eip_addend) =20 /* XXX: not complete but not completely erroneous */ if (cs->cpu_index !=3D 0 || CPU_NEXT(cs) !=3D NULL) { - do_pause(env); + helper_pause(env); } else { helper_hlt(env); } diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 376d2bdabe1..c2d8da8d14e 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1359,6 +1359,19 @@ static void decode_group11(DisasContext *s, CPUX86St= ate *env, X86OpEntry *entry, } } =20 +static void decode_90(DisasContext *s, CPUX86State *env, X86OpEntry *entry= , uint8_t *b) +{ + static X86OpEntry pause =3D X86_OP_ENTRY0(PAUSE, svm(PAUSE)); + static X86OpEntry nop =3D X86_OP_ENTRY0(NOP); + static X86OpEntry xchg_ax =3D X86_OP_ENTRY2(XCHG, 0,v, LoBits,v); + + if (REX_B(s)) { + *entry =3D xchg_ax; + } else { + *entry =3D (s->prefix & PREFIX_REPZ) ? pause : nop; + } +} + static const X86OpEntry opcodes_root[256] =3D { [0x00] =3D X86_OP_ENTRY2(ADD, E,b, G,b, lock), [0x01] =3D X86_OP_ENTRY2(ADD, E,v, G,v, lock), @@ -1441,7 +1454,7 @@ static const X86OpEntry opcodes_root[256] =3D { [0x86] =3D X86_OP_ENTRY2(XCHG, E,b, G,b, xchg), [0x87] =3D X86_OP_ENTRY2(XCHG, E,v, G,v, xchg), =20 - [0x90] =3D X86_OP_ENTRY2(XCHG, 0,v, LoBits,v), + [0x90] =3D X86_OP_GROUP0(90), [0x91] =3D X86_OP_ENTRY2(XCHG, 0,v, LoBits,v), [0x92] =3D X86_OP_ENTRY2(XCHG, 0,v, LoBits,v), [0x93] =3D X86_OP_ENTRY2(XCHG, 0,v, LoBits,v), diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 2e94e8ec56f..f90f3d3c589 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -2350,6 +2350,14 @@ static void gen_PANDN(DisasContext *s, CPUX86State *= env, X86DecodedInsn *decode) decode->op[1].offset, vec_len, vec_len); } =20 +static void gen_PAUSE(DisasContext *s, CPUX86State *env, X86DecodedInsn *d= ecode) +{ + gen_update_cc_op(s); + gen_update_eip_next(s); + gen_helper_pause(tcg_env); + s->base.is_jmp =3D DISAS_NORETURN; +} + static void gen_PCMPESTRI(DisasContext *s, CPUX86State *env, X86DecodedIns= n *decode) { TCGv_i32 imm =3D tcg_constant8u_i32(decode->immediate); @@ -4014,18 +4022,6 @@ static void gen_WAIT(DisasContext *s, CPUX86State *e= nv, X86DecodedInsn *decode) =20 static void gen_XCHG(DisasContext *s, CPUX86State *env, X86DecodedInsn *de= code) { - if (decode->b =3D=3D 0x90 && !REX_B(s)) { - if (s->prefix & PREFIX_REPZ) { - gen_update_cc_op(s); - gen_update_eip_cur(s); - gen_helper_pause(tcg_env, cur_insn_len_i32(s)); - s->base.is_jmp =3D DISAS_NORETURN; - } - /* No writeback. */ - decode->op[0].unit =3D X86_OP_SKIP; - return; - } - if (s->prefix & PREFIX_LOCK) { tcg_gen_atomic_xchg_tl(s->T0, s->A0, s->T1, s->mem_index, decode->op[0].ot | MO_LE); --=20 2.45.1