target/i386: cleanup HLT helpers

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 <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2024-05-29 15:12:22 +02:00
parent 73fb7b3c49
commit 536032566b
4 changed files with 7 additions and 16 deletions

View File

@ -90,7 +90,7 @@ DEF_HELPER_2(vmsave, void, env, int)
DEF_HELPER_1(stgi, void, env) DEF_HELPER_1(stgi, void, env)
DEF_HELPER_1(clgi, 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(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(monitor, TCG_CALL_NO_WG, void, env, tl)
DEF_HELPER_FLAGS_2(mwait, TCG_CALL_NO_WG, noreturn, env, int) DEF_HELPER_FLAGS_2(mwait, TCG_CALL_NO_WG, noreturn, env, int)
DEF_HELPER_1(rdmsr, void, env) DEF_HELPER_1(rdmsr, void, env)

View File

@ -1496,7 +1496,7 @@ static const X86OpEntry opcodes_root[256] = {
[0xE7] = X86_OP_ENTRYrr(OUT, 0,v, I_unsigned,b), /* AX/EAX */ [0xE7] = X86_OP_ENTRYrr(OUT, 0,v, I_unsigned,b), /* AX/EAX */
[0xF1] = X86_OP_ENTRY0(INT1, svm(ICEBP)), [0xF1] = X86_OP_ENTRY0(INT1, svm(ICEBP)),
[0xF4] = X86_OP_ENTRY0(HLT, chk(cpl0)), [0xF4] = X86_OP_ENTRY0(HLT, chk(cpl0) svm(HLT)),
[0xF5] = X86_OP_ENTRY0(CMC), [0xF5] = X86_OP_ENTRY0(CMC),
[0xF6] = X86_OP_GROUP1(group3, E,b), [0xF6] = X86_OP_GROUP1(group3, E,b),
[0xF7] = X86_OP_GROUP1(group3, E,v), [0xF7] = X86_OP_GROUP1(group3, E,v),
@ -2539,7 +2539,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu)
/* /*
* Checks that result in #GP or VMEXIT come second. Intercepts are * 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 * exceptions if there is no memory operand). Exceptions are
* vm86 checks (INTn, IRET, PUSHF/POPF), RSM and XSETBV (!). * vm86 checks (INTn, IRET, PUSHF/POPF), RSM and XSETBV (!).
* *

View File

@ -1638,8 +1638,8 @@ static void gen_HLT(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{ {
#ifdef CONFIG_SYSTEM_ONLY #ifdef CONFIG_SYSTEM_ONLY
gen_update_cc_op(s); gen_update_cc_op(s);
gen_update_eip_cur(s); gen_update_eip_next(s);
gen_helper_hlt(tcg_env, cur_insn_len_i32(s)); gen_helper_hlt(tcg_env);
s->base.is_jmp = DISAS_NORETURN; s->base.is_jmp = DISAS_NORETURN;
#endif #endif
} }

View File

@ -516,8 +516,7 @@ void helper_flush_page(CPUX86State *env, target_ulong addr)
tlb_flush_page(env_cpu(env), addr); tlb_flush_page(env_cpu(env), addr);
} }
static G_NORETURN G_NORETURN void helper_hlt(CPUX86State *env)
void do_hlt(CPUX86State *env)
{ {
CPUState *cs = env_cpu(env); CPUState *cs = env_cpu(env);
@ -527,14 +526,6 @@ void do_hlt(CPUX86State *env)
cpu_loop_exit(cs); cpu_loop_exit(cs);
} }
G_NORETURN void helper_hlt(CPUX86State *env, int next_eip_addend)
{
cpu_svm_check_intercept_param(env, SVM_EXIT_HLT, 0, GETPC());
env->eip += next_eip_addend;
do_hlt(env);
}
void helper_monitor(CPUX86State *env, target_ulong ptr) void helper_monitor(CPUX86State *env, target_ulong ptr)
{ {
if ((uint32_t)env->regs[R_ECX] != 0) { if ((uint32_t)env->regs[R_ECX] != 0) {
@ -558,6 +549,6 @@ G_NORETURN void helper_mwait(CPUX86State *env, int next_eip_addend)
if (cs->cpu_index != 0 || CPU_NEXT(cs) != NULL) { if (cs->cpu_index != 0 || CPU_NEXT(cs) != NULL) {
do_pause(env); do_pause(env);
} else { } else {
do_hlt(env); helper_hlt(env);
} }
} }