[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] NextRIPS support for forthcoming AMD processors



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1224179148 -3600
# Node ID 6bf61b830153010d9f3a551811469a7fbfddf023
# Parent  dc61548aa4792aa274a207cae27a3d0a8b62bd73
NextRIPS support for forthcoming AMD processors

Future versions of AMD processors will support a feature called
NextRIPS or Next RIP Save.  This feature causes the processor
to store the next sequential RIP of a guest in the VMCB on
most instruction interrupts.  The hypervisor can use this
information to determine how much memory to read to determine
the intercepted instruction, modestly improving performance.
The following patch implements support for this feature.

Signed-off-by: Mark Langsdorf <mark.langsdorf@xxxxxxx>
---
 xen/arch/x86/hvm/svm/emulate.c     |   30 ++++++++++++++++++++++++++++++
 xen/include/asm-x86/hvm/svm/vmcb.h |    4 +++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff -r dc61548aa479 -r 6bf61b830153 xen/arch/x86/hvm/svm/emulate.c
--- a/xen/arch/x86/hvm/svm/emulate.c    Thu Oct 16 18:36:43 2008 +0100
+++ b/xen/arch/x86/hvm/svm/emulate.c    Thu Oct 16 18:45:48 2008 +0100
@@ -61,6 +61,33 @@ static unsigned long svm_rip2pointer(str
     return p;
 }
 
+static unsigned long svm_nextrip_insn_length(struct vcpu *v)
+{
+    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+
+    if ( !cpu_has_svm_nrips || (vmcb->nextrip <= vmcb->rip) )
+        return 0;
+
+    switch ( vmcb->exitcode )
+    {
+    case VMEXIT_CR0_READ... VMEXIT_DR15_WRITE:
+        /* faults due to instruction intercepts */
+        /* (exitcodes 84-95) are reserved */
+    case VMEXIT_IDTR_READ ... VMEXIT_TR_WRITE:
+    case VMEXIT_RDTSC ... VMEXIT_SWINT:
+    case VMEXIT_INVD ... VMEXIT_INVLPGA:
+    case VMEXIT_VMRUN ...  VMEXIT_MWAIT_CONDITIONAL:
+    case VMEXIT_IOIO:
+        /* ...and the rest of the #VMEXITs */
+    case VMEXIT_CR0_SEL_WRITE:
+    case VMEXIT_MSR:
+    case VMEXIT_EXCEPTION_BP:
+        return vmcb->nextrip - vmcb->rip;
+    }
+  
+    return 0;
+}
+
 /* First byte: Length. Following bytes: Opcode bytes. */
 #define MAKE_INSTR(nm, ...) static const u8 OPCODE_##nm[] = { __VA_ARGS__ }
 MAKE_INSTR(INVD,   2, 0x0f, 0x08);
@@ -118,6 +145,9 @@ int __get_instruction_length_from_list(s
     unsigned long fetch_addr;
     unsigned int fetch_len;
 
+    if ( (inst_len = svm_nextrip_insn_length(v)) != 0 )
+        return inst_len;
+
     /* Fetch up to the next page break; we'll fetch from the next page
      * later if we have to. */
     fetch_addr = svm_rip2pointer(v);
diff -r dc61548aa479 -r 6bf61b830153 xen/include/asm-x86/hvm/svm/vmcb.h
--- a/xen/include/asm-x86/hvm/svm/vmcb.h        Thu Oct 16 18:36:43 2008 +0100
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h        Thu Oct 16 18:45:48 2008 +0100
@@ -393,7 +393,9 @@ struct vmcb_struct {
     eventinj_t  eventinj;       /* offset 0xA8 */
     u64 h_cr3;                  /* offset 0xB0 */
     lbrctrl_t lbr_control;      /* offset 0xB8 */
-    u64 res09[104];             /* offset 0xC0 pad to save area */
+    u64 res09;                  /* offset 0xC0 */
+    u64 nextrip;                /* offset 0xC8 */
+    u64 res10a[102];            /* offset 0xD0 pad to save area */
 
     svm_segment_register_t es;      /* offset 1024 */
     svm_segment_register_t cs;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.