WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [HVM][SVM] Change the calling convention

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [HVM][SVM] Change the calling convention for SVM VMMCALLs so
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 01 Aug 2006 19:20:28 +0000
Delivery-date: Tue, 01 Aug 2006 12:24:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 2e3b121662dc71c192d8af584c9f6497139feed1
# Parent  0d2ba35c0cf2403af80338fdadd67f52cb549d70
[HVM][SVM] Change the calling convention for SVM VMMCALLs so
that they don't conflict with the hypercall calling convention.
Signed-off-by: Steven Smith <ssmith@xxxxxxxxxxxxx>
---
 tools/firmware/hvmloader/hvmloader.c  |   10 ++---
 xen/arch/x86/hvm/svm/svm.c            |   58 +++++++++++++++++++---------------
 xen/include/asm-x86/hvm/svm/vmmcall.h |    8 ++--
 3 files changed, 42 insertions(+), 34 deletions(-)

diff -r 0d2ba35c0cf2 -r 2e3b121662dc tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Tue Aug 01 17:18:05 2006 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Tue Aug 01 17:28:19 2006 +0100
@@ -31,7 +31,7 @@
 #define        ROMBIOS_PHYSICAL_ADDRESS        0x000F0000
 
 /* invoke SVM's paged realmode support */
-#define SVM_VMMCALL_RESET_TO_REALMODE  0x00000001
+#define SVM_VMMCALL_RESET_TO_REALMODE  0x80000001
 
 /*
  * C runtime start off
@@ -133,15 +133,15 @@ cirrus_check(void)
        return inb(0x3C5) == 0x12;
 }
 
-int 
-vmmcall(int edi, int esi, int edx, int ecx, int ebx)
+int
+vmmcall(int function, int edi, int esi, int edx, int ecx, int ebx)
 {
         int eax;
 
         __asm__ __volatile__(
                ".byte 0x0F,0x01,0xD9"
                 : "=a" (eax)
-               : "a"(0x58454E00), /* XEN\0 key */
+               : "a"(function),
                  "b"(ebx), "c"(ecx), "d"(edx), "D"(edi), "S"(esi)
        );
         return eax;
@@ -200,7 +200,7 @@ main(void)
        if (check_amd()) {
                /* AMD implies this is SVM */
                 puts("SVM go ...\n");
-                vmmcall(SVM_VMMCALL_RESET_TO_REALMODE, 0, 0, 0, 0);
+                vmmcall(SVM_VMMCALL_RESET_TO_REALMODE, 0, 0, 0, 0, 0);
        } else {
                puts("Loading VMXAssist ...\n");
                memcpy((void *)VMXASSIST_PHYSICAL_ADDRESS,
diff -r 0d2ba35c0cf2 -r 2e3b121662dc xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Tue Aug 01 17:18:05 2006 +0100
+++ b/xen/arch/x86/hvm/svm/svm.c        Tue Aug 01 17:28:19 2006 +0100
@@ -2349,33 +2349,41 @@ static int svm_do_vmmcall(struct vcpu *v
     inst_len = __get_instruction_length(vmcb, INSTR_VMCALL, NULL);
     ASSERT(inst_len > 0);
 
-    /* VMMCALL sanity check */
-    if (vmcb->cpl > get_vmmcall_cpl(regs->edi))
-    {
-        printf("VMMCALL CPL check failed\n");
-        return -1;
-    }
-
-    /* handle the request */
-    switch (regs->edi) 
-    {
-    case VMMCALL_RESET_TO_REALMODE:
-        if (svm_do_vmmcall_reset_to_realmode(v, regs)) 
-        {
-            printf("svm_do_vmmcall_reset_to_realmode() failed\n");
+    if ( regs->eax & 0x80000000 )
+    {
+        /* VMMCALL sanity check */
+        if ( vmcb->cpl > get_vmmcall_cpl(regs->edi) )
+        {
+            printf("VMMCALL CPL check failed\n");
             return -1;
         }
-    
-        /* since we just reset the VMCB, return without adjusting the eip */
-        return 0;
-    case VMMCALL_DEBUG:
-        printf("DEBUG features not implemented yet\n");
-        break;
-    default:
-    break;
-    }
-
-    hvm_print_line(v, regs->eax); /* provides the current domain */
+
+        /* handle the request */
+        switch ( regs->eax )
+        {
+        case VMMCALL_RESET_TO_REALMODE:
+            if ( svm_do_vmmcall_reset_to_realmode(v, regs) )
+            {
+                printf("svm_do_vmmcall_reset_to_realmode() failed\n");
+                return -1;
+            }
+            /* since we just reset the VMCB, return without adjusting
+             * the eip */
+            return 0;
+
+        case VMMCALL_DEBUG:
+            printf("DEBUG features not implemented yet\n");
+            break;
+        default:
+            break;
+        }
+
+        hvm_print_line(v, regs->eax); /* provides the current domain */
+    }
+    else
+    {
+        hvm_do_hypercall(regs);
+    }
 
     __update_guest_eip(vmcb, inst_len);
     return 0;
diff -r 0d2ba35c0cf2 -r 2e3b121662dc xen/include/asm-x86/hvm/svm/vmmcall.h
--- a/xen/include/asm-x86/hvm/svm/vmmcall.h     Tue Aug 01 17:18:05 2006 +0100
+++ b/xen/include/asm-x86/hvm/svm/vmmcall.h     Tue Aug 01 17:28:19 2006 +0100
@@ -23,11 +23,11 @@
 #define __ASM_X86_HVM_SVM_VMMCALL_H__
 
 /* VMMCALL command fields */
-#define VMMCALL_CODE_CPL_MASK     0xC0000000
-#define VMMCALL_CODE_MBZ_MASK     0x3FFF0000
+#define VMMCALL_CODE_CPL_MASK     0x60000000
+#define VMMCALL_CODE_MBZ_MASK     0x1FFF0000
 #define VMMCALL_CODE_COMMAND_MASK 0x0000FFFF
 
-#define MAKE_VMMCALL_CODE(cpl,func) ((cpl << 30) | (func))
+#define MAKE_VMMCALL_CODE(cpl,func) ((cpl << 29) | (func) | 0x80000000)
 
 /* CPL=0 VMMCALL Requests */
 #define VMMCALL_RESET_TO_REALMODE   MAKE_VMMCALL_CODE(0,1)
@@ -38,7 +38,7 @@
 /* return the cpl required for the vmmcall cmd */
 static inline int get_vmmcall_cpl(int cmd)
 {
-    return (cmd & VMMCALL_CODE_CPL_MASK) >> 30;
+    return (cmd & VMMCALL_CODE_CPL_MASK) >> 29;
 }
 
 #endif /* __ASM_X86_HVM_SVM_VMMCALL_H__ */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [HVM][SVM] Change the calling convention for SVM VMMCALLs so, Xen patchbot-unstable <=