From nobody Mon Nov 25 06:25:04 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=1717485564; cv=none; d=zohomail.com; s=zohoarc; b=du+dV9sH6+e1NkjHrd4zQzXqtXRa5SOitK9bdO/JFU5A5nBptDQxjkzAQKh1QVJffv6+S0O+Oi7vVornYfHqgyHF2k7HDZr5vAUKRTL22rOjRNCRyyHEjuLuNC7Ba/AGLJFj5VDQBPnNA8PgIxOSh5NGcmx1GyYrsjG0jZ3M0IE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717485564; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=3+poIGky4GSqhFlE6pkBG1pa6bXFWkqUUf8ylZXVgw0=; b=hr3hiNMFR4/TyBv+oF0yDj6GnFha32FJir1N66wo3TboJdOqu/6GNvd2CzaJSlvnQ6RVUionCdJOid57HXiVZglHvJB3qEsUtLyT+9ER2f4/GmgHeMB94vquO3j9qe3GP1xxEGpiq7LlAPbM5s0Hs7nwAUkd/v5t2Abqa7fTA3w= 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 1717485564417899.0394465340104; Tue, 4 Jun 2024 00:19:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEORc-0003Bb-UP; Tue, 04 Jun 2024 03:18:56 -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 1sEORc-0003BI-7o for qemu-devel@nongnu.org; Tue, 04 Jun 2024 03:18:56 -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 1sEORa-0005cX-LG for qemu-devel@nongnu.org; Tue, 04 Jun 2024 03:18:55 -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-650-ze5qarTvPYCinkPjVbE8hQ-1; Tue, 04 Jun 2024 03:18:49 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-57a24dac048so2179637a12.0 for ; Tue, 04 Jun 2024 00:18:49 -0700 (PDT) Received: from avogadro.local ([151.81.115.112]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57a790f1c95sm1565969a12.50.2024.06.04.00.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 00:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717485533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3+poIGky4GSqhFlE6pkBG1pa6bXFWkqUUf8ylZXVgw0=; b=W20a+jufyofXBt+KDIkybKd/tsazj1Xlck8JMzJpo3jN2Eot6qBgfK+0mxhmBPabqzEd6+ 9oOe6C/sOg/teXeNl1A1b9LqpcYsjynb22lshNTQ7ovu/iTXWrC+GjAKwuup/nxpMiRFkD QjJLb1UoX40zDbL9MTlGPFRUWjPclJQ= X-MC-Unique: ze5qarTvPYCinkPjVbE8hQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717485527; x=1718090327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3+poIGky4GSqhFlE6pkBG1pa6bXFWkqUUf8ylZXVgw0=; b=GciWqtLOkx9d2NFvXYZUfVdIwt2obuihHFa2BQ9GbcSQ0o/67Gf/N0rxRs1n0/xHsR PRhdnMvAb5cnNoBTbyeYxU3/97Q2tc5vSbNRxIxhBcRL64HCGoIz13cFaBhxd2nNQyaE tkyLkk2ZjQAumfoc9/vgRXx7EhH9H4oXWua7uEV+G7eGVOpgTMzDz6frHTx6FY+GI2gA uCMlnmR5+vvpFn2EdPmG5C1JeMd8GRzpVoTJh5MWprTRn9Tuv6ZZm3bqdvGFSor7llrT 7uuaZ+8i3eoU6biqOV9jXddWrlGEuHQuIxqiY09/Wng36ps67/9je1PhsXXe63IKiqng FylQ== X-Gm-Message-State: AOJu0YwXc2gh4+7E+Mgxiu6wrT0BKWRbEUljS6PmBrvPiFwt2/JB4rtY BzAOsn/XAjEd7ZWtjmcX6FUMYXtXAQxMmwkf4mE80OHgW1Ci8xwWZ5uySp8yoA2lTXBUaInf0ZO 8cE4W0+XK78F8tMATRlJ7qclNgtRt8kNiNaqQv7BaGjW6gBI+R6KWKO869jgf86uO9ssAVSQ5Ct tQ8/pjYCIxkHrk1shDOYDTlkxxfn2drstEPYci X-Received: by 2002:a50:ba89:0:b0:57a:321f:cc4f with SMTP id 4fb4d7f45d1cf-57a3f55eb7emr7394309a12.19.1717485527376; Tue, 04 Jun 2024 00:18:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDlyGHizdRw6inPRoPSe2Ub88yvUi1oKW9DNURVkz2VD/rdI026ySJVII7f+mRWqCng5ft2w== X-Received: by 2002:a50:ba89:0:b0:57a:321f:cc4f with SMTP id 4fb4d7f45d1cf-57a3f55eb7emr7394293a12.19.1717485526957; Tue, 04 Jun 2024 00:18:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 03/11] target/i386: cleanup HLT helpers Date: Tue, 4 Jun 2024 09:18:25 +0200 Message-ID: <20240604071833.962574-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240604071833.962574-1-pbonzini@redhat.com> References: <20240604071833.962574-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: 1717485565425100006 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_hlt(). Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/helper.h | 2 +- target/i386/tcg/sysemu/misc_helper.c | 13 ++----------- target/i386/tcg/decode-new.c.inc | 4 ++-- target/i386/tcg/emit.c.inc | 4 ++-- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/target/i386/helper.h b/target/i386/helper.h index 8f291a5f66f..c244dbb4812 100644 --- a/target/i386/helper.h +++ b/target/i386/helper.h @@ -90,7 +90,7 @@ DEF_HELPER_2(vmsave, void, env, int) DEF_HELPER_1(stgi, void, env) DEF_HELPER_1(clgi, void, env) DEF_HELPER_FLAGS_2(flush_page, TCG_CALL_NO_RWG, void, env, tl) -DEF_HELPER_FLAGS_2(hlt, TCG_CALL_NO_WG, noreturn, env, int) +DEF_HELPER_FLAGS_1(hlt, TCG_CALL_NO_WG, noreturn, env) 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) diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/= misc_helper.c index edb7c3d8940..e41c88346cb 100644 --- a/target/i386/tcg/sysemu/misc_helper.c +++ b/target/i386/tcg/sysemu/misc_helper.c @@ -516,8 +516,7 @@ void helper_flush_page(CPUX86State *env, target_ulong a= ddr) tlb_flush_page(env_cpu(env), addr); } =20 -static G_NORETURN -void do_hlt(CPUX86State *env) +G_NORETURN void helper_hlt(CPUX86State *env) { CPUState *cs =3D env_cpu(env); =20 @@ -527,14 +526,6 @@ void do_hlt(CPUX86State *env) cpu_loop_exit(cs); } =20 -G_NORETURN void helper_hlt(CPUX86State *env, int next_eip_addend) -{ - cpu_svm_check_intercept_param(env, SVM_EXIT_HLT, 0, GETPC()); - env->eip +=3D next_eip_addend; - - do_hlt(env); -} - void helper_monitor(CPUX86State *env, target_ulong ptr) { if ((uint32_t)env->regs[R_ECX] !=3D 0) { @@ -558,6 +549,6 @@ G_NORETURN void helper_mwait(CPUX86State *env, int next= _eip_addend) if (cs->cpu_index !=3D 0 || CPU_NEXT(cs) !=3D NULL) { do_pause(env); } else { - do_hlt(env); + helper_hlt(env); } } diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 0ff0866e8f3..376d2bdabe1 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1496,7 +1496,7 @@ static const X86OpEntry opcodes_root[256] =3D { [0xE7] =3D X86_OP_ENTRYrr(OUT, 0,v, I_unsigned,b), /* AX/EAX */ =20 [0xF1] =3D X86_OP_ENTRY0(INT1, svm(ICEBP)), - [0xF4] =3D X86_OP_ENTRY0(HLT, chk(cpl0)), + [0xF4] =3D X86_OP_ENTRY0(HLT, chk(cpl0) svm(HLT)), [0xF5] =3D X86_OP_ENTRY0(CMC), [0xF6] =3D X86_OP_GROUP1(group3, E,b), [0xF7] =3D X86_OP_GROUP1(group3, E,v), @@ -2539,7 +2539,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) =20 /* * Checks that result in #GP or VMEXIT come second. Intercepts are - * generally checked after non-memory exceptions (i.e. before all + * generally checked after non-memory exceptions (i.e. after all * exceptions if there is no memory operand). Exceptions are * vm86 checks (INTn, IRET, PUSHF/POPF), RSM and XSETBV (!). * diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 36127d99943..2e94e8ec56f 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1638,8 +1638,8 @@ static void gen_HLT(DisasContext *s, CPUX86State *env= , X86DecodedInsn *decode) { #ifdef CONFIG_SYSTEM_ONLY gen_update_cc_op(s); - gen_update_eip_cur(s); - gen_helper_hlt(tcg_env, cur_insn_len_i32(s)); + gen_update_eip_next(s); + gen_helper_hlt(tcg_env); s->base.is_jmp =3D DISAS_NORETURN; #endif } --=20 2.45.1