Skip to contentSkip to conversation

add rdpmc intercept for SVM

PATCH In review Bernhard Kauer 2 participants 2 messages Dec 5, 2007 – Dec 7, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add rdpmc intercept for SVM

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

Index: target-i386/helper.c

helper.c +13 -0
@@ -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

op.c +5 -0
@@ -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

translate.c +4 -0
@@ -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;
#1 lore raw
Quoted 7 lines · Bernhard Kauer

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
<qemu_rdpmc.diff>

Sounds useful. Even though they are unimplemented, a VMM could still emulate them.