From: Fabrice Bellard <fabrice@bellard.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [4746] HLT, MWAIT and MONITOR insn fixes (initial patch by Alexander Graf)
Date: Wed, 18 Jun 2008 09:32:32 +0000 [thread overview]
Message-ID: <E1K8u1o-00024X-Ox@cvs.savannah.gnu.org> (raw)
Revision: 4746
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4746
Author: bellard
Date: 2008-06-18 09:32:32 +0000 (Wed, 18 Jun 2008)
Log Message:
-----------
HLT, MWAIT and MONITOR insn fixes (initial patch by Alexander Graf)
Modified Paths:
--------------
trunk/target-i386/helper.h
trunk/target-i386/op_helper.c
trunk/target-i386/translate.c
Modified: trunk/target-i386/helper.h
===================================================================
--- trunk/target-i386/helper.h 2008-06-18 01:58:52 UTC (rev 4745)
+++ trunk/target-i386/helper.h 2008-06-18 09:32:32 UTC (rev 4746)
@@ -60,9 +60,9 @@
DEF_HELPER(void, helper_syscall, (int next_eip_addend))
DEF_HELPER(void, helper_sysret, (int dflag))
#endif
-DEF_HELPER(void, helper_hlt, (void))
+DEF_HELPER(void, helper_hlt, (int next_eip_addend))
DEF_HELPER(void, helper_monitor, (target_ulong ptr))
-DEF_HELPER(void, helper_mwait, (void))
+DEF_HELPER(void, helper_mwait, (int next_eip_addend))
DEF_HELPER(void, helper_debug, (void))
DEF_HELPER(void, helper_raise_interrupt, (int intno, int next_eip_addend))
DEF_HELPER(void, helper_raise_exception, (int exception_index))
Modified: trunk/target-i386/op_helper.c
===================================================================
--- trunk/target-i386/op_helper.c 2008-06-18 01:58:52 UTC (rev 4745)
+++ trunk/target-i386/op_helper.c 2008-06-18 09:32:32 UTC (rev 4746)
@@ -4547,16 +4547,22 @@
}
#endif
-void helper_hlt(void)
+static void do_hlt(void)
{
- helper_svm_check_intercept_param(SVM_EXIT_HLT, 0);
-
env->hflags &= ~HF_INHIBIT_IRQ_MASK; /* needed if sti is just before */
env->halted = 1;
env->exception_index = EXCP_HLT;
cpu_loop_exit();
}
+void helper_hlt(int next_eip_addend)
+{
+ helper_svm_check_intercept_param(SVM_EXIT_HLT, 0);
+ EIP += next_eip_addend;
+
+ do_hlt();
+}
+
void helper_monitor(target_ulong ptr)
{
if ((uint32_t)ECX != 0)
@@ -4565,17 +4571,19 @@
helper_svm_check_intercept_param(SVM_EXIT_MONITOR, 0);
}
-void helper_mwait(void)
+void helper_mwait(int next_eip_addend)
{
if ((uint32_t)ECX != 0)
raise_exception(EXCP0D_GPF);
helper_svm_check_intercept_param(SVM_EXIT_MWAIT, 0);
+ EIP += next_eip_addend;
+
/* XXX: not complete but not completely erroneous */
if (env->cpu_index != 0 || env->next_cpu != NULL) {
/* more than one CPU: do not sleep because another CPU may
wake this one */
} else {
- helper_hlt();
+ do_hlt();
}
}
Modified: trunk/target-i386/translate.c
===================================================================
--- trunk/target-i386/translate.c 2008-06-18 01:58:52 UTC (rev 4745)
+++ trunk/target-i386/translate.c 2008-06-18 09:32:32 UTC (rev 4746)
@@ -6420,8 +6420,8 @@
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
- gen_jmp_im(s->pc - s->cs_base);
- tcg_gen_helper_0_0(helper_hlt);
+ gen_jmp_im(pc_start - s->cs_base);
+ tcg_gen_helper_0_1(helper_hlt, tcg_const_i32(s->pc - pc_start));
s->is_jmp = 3;
}
break;
@@ -6519,6 +6519,8 @@
if (!(s->cpuid_ext_features & CPUID_EXT_MONITOR) ||
s->cpl != 0)
goto illegal_op;
+ if (s->cc_op != CC_OP_DYNAMIC)
+ gen_op_set_cc_op(s->cc_op);
gen_jmp_im(pc_start - s->cs_base);
#ifdef TARGET_X86_64
if (s->aflag == 2) {
@@ -6541,8 +6543,8 @@
gen_op_set_cc_op(s->cc_op);
s->cc_op = CC_OP_DYNAMIC;
}
- gen_jmp_im(s->pc - s->cs_base);
- tcg_gen_helper_0_0(helper_mwait);
+ gen_jmp_im(pc_start - s->cs_base);
+ tcg_gen_helper_0_1(helper_mwait, tcg_const_i32(s->pc - pc_start));
gen_eob(s);
break;
default:
reply other threads:[~2008-06-18 9:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1K8u1o-00024X-Ox@cvs.savannah.gnu.org \
--to=fabrice@bellard.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).