qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] SVM: Trap on correct IP
Date: Wed, 18 Jun 2008 02:34:13 +0200	[thread overview]
Message-ID: <48585805.9070706@suse.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]

Hi,

Currently HLT always traps at the IP after the hlt instruction. SVM
requires its trap on the instruction's IP though, which breaks the
current implementation as soon as an HLT intercept occurs.

This patch does the SVM intercept with an IP value before the HLT
instruction.

Alex

Signed-off-by: Alexander Graf <agraf@suse.de>


[-- Attachment #2: qemu-svm-hlt.patch --]
[-- Type: text/x-patch, Size: 1783 bytes --]

Index: target-i386/helper.h
===================================================================
--- target-i386/helper.h	(revision 4744)
+++ target-i386/helper.h	(working copy)
@@ -60,7 +60,7 @@
 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_debug, (void))
Index: target-i386/op_helper.c
===================================================================
--- target-i386/op_helper.c	(revision 4744)
+++ target-i386/op_helper.c	(working copy)
@@ -4547,9 +4547,10 @@
 }
 #endif
 
-void helper_hlt(void)
+void helper_hlt(int next_eip_addend)
 {
     helper_svm_check_intercept_param(SVM_EXIT_HLT, 0);
+    EIP+=next_eip_addend;
     
     env->hflags &= ~HF_INHIBIT_IRQ_MASK; /* needed if sti is just before */
     env->halted = 1;
@@ -4575,7 +4576,7 @@
         /* more than one CPU: do not sleep because another CPU may
            wake this one */
     } else {
-        helper_hlt();
+        helper_hlt(0);
     }
 }
 
Index: target-i386/translate.c
===================================================================
--- target-i386/translate.c	(revision 4744)
+++ target-i386/translate.c	(working copy)
@@ -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;

             reply	other threads:[~2008-06-18  0:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-18  0:34 Alexander Graf [this message]
2008-06-18  4:59 ` [Qemu-devel] [PATCH] SVM: Trap on correct IP Alexander Graf
2008-06-18  9:41   ` Fabrice Bellard

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=48585805.9070706@suse.de \
    --to=agraf@suse.de \
    --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).