qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bernhard Kauer <kauer@os.inf.tu-dresden.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] add rdpmc intercept for SVM
Date: Wed, 5 Dec 2007 20:44:19 +0100	[thread overview]
Message-ID: <20071205194419.GA18291@chrom.inf.tu-dresden.de> (raw)

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

The attached patch adds an SVM intercept for rdpmc to qemu,
thus allowing a VMM to virtualize them. Please note that 
performance counters are currently unimplemented in qemu.


	Bernhard Kauer

[-- Attachment #2: qemu_rdpmc.diff --]
[-- Type: text/x-diff, Size: 1241 bytes --]

Index: target-i386/helper.c
--- target-i386/helper.c	18 Nov 2007 01:44:38 -0000	1.95
+++ target-i386/helper.c	5 Dec 2007 19:31:31 -0000
@@ -2743,6 +2816,19 @@
     EDX = (uint32_t)(val >> 32);
 }
 
+void helper_rdpmc()
+{
+  if ((env->cr[4] & CR4_PCE_MASK) && ((env->hflags & HF_CPL_MASK) != 0)) {
+    raise_exception(EXCP0D_GPF);
+  }
+  
+  if (!svm_check_intercept_param(SVM_EXIT_RDPMC, 0))
+    {
+      // currently unimplemented
+      raise_exception_err(EXCP06_ILLOP, 0);
+    }
+}
+
 #if defined(CONFIG_USER_ONLY)
 void helper_wrmsr(void)
 {
Index: target-i386/op.c
--- target-i386/op.c	23 Sep 2007 15:28:04 -0000	1.51
+++ target-i386/op.c	5 Dec 2007 19:31:32 -0000
@@ -953,6 +953,11 @@
     helper_rdtsc();
 }
 
+void OPPROTO op_rdpmc(void)
+{
+    helper_rdpmc();
+}
+
 void OPPROTO op_cpuid(void)
 {
     helper_cpuid();
Index: target-i386/translate.c
--- target-i386/translate.c	8 Nov 2007 14:25:03 -0000	1.74
+++ target-i386/translate.c	5 Dec 2007 19:31:38 -0000
@@ -5653,5 +5653,9 @@
         gen_op_rdtsc();
         break;
+    case 0x133: /* rdpmc */
+        gen_jmp_im(pc_start - s->cs_base);
+        gen_op_rdpmc();
+        break;
     case 0x134: /* sysenter */
         if (CODE64(s))
             goto illegal_op;

             reply	other threads:[~2007-12-05 19:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-05 19:44 Bernhard Kauer [this message]
2007-12-07 13:14 ` [Qemu-devel] [PATCH] add rdpmc intercept for SVM Alexander Graf

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=20071205194419.GA18291@chrom.inf.tu-dresden.de \
    --to=kauer@os.inf.tu-dresden.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).