ia64/xen-unstable

changeset 10893:2e3b121662dc

[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@xensource.com>
author kfraser@localhost.localdomain
date Tue Aug 01 17:28:19 2006 +0100 (2006-08-01)
parents 0d2ba35c0cf2
children c8ee670ac87e
files tools/firmware/hvmloader/hvmloader.c xen/arch/x86/hvm/svm/svm.c xen/include/asm-x86/hvm/svm/vmmcall.h
line diff
     1.1 --- a/tools/firmware/hvmloader/hvmloader.c	Tue Aug 01 17:18:05 2006 +0100
     1.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Tue Aug 01 17:28:19 2006 +0100
     1.3 @@ -31,7 +31,7 @@
     1.4  #define	ROMBIOS_PHYSICAL_ADDRESS	0x000F0000
     1.5  
     1.6  /* invoke SVM's paged realmode support */
     1.7 -#define SVM_VMMCALL_RESET_TO_REALMODE	0x00000001
     1.8 +#define SVM_VMMCALL_RESET_TO_REALMODE	0x80000001
     1.9  
    1.10  /*
    1.11   * C runtime start off
    1.12 @@ -133,15 +133,15 @@ cirrus_check(void)
    1.13  	return inb(0x3C5) == 0x12;
    1.14  }
    1.15  
    1.16 -int 
    1.17 -vmmcall(int edi, int esi, int edx, int ecx, int ebx)
    1.18 +int
    1.19 +vmmcall(int function, int edi, int esi, int edx, int ecx, int ebx)
    1.20  {
    1.21          int eax;
    1.22  
    1.23          __asm__ __volatile__(
    1.24  		".byte 0x0F,0x01,0xD9"
    1.25                  : "=a" (eax)
    1.26 -		: "a"(0x58454E00), /* XEN\0 key */
    1.27 +		: "a"(function),
    1.28  		  "b"(ebx), "c"(ecx), "d"(edx), "D"(edi), "S"(esi)
    1.29  	);
    1.30          return eax;
    1.31 @@ -200,7 +200,7 @@ main(void)
    1.32  	if (check_amd()) {
    1.33  		/* AMD implies this is SVM */
    1.34                  puts("SVM go ...\n");
    1.35 -                vmmcall(SVM_VMMCALL_RESET_TO_REALMODE, 0, 0, 0, 0);
    1.36 +                vmmcall(SVM_VMMCALL_RESET_TO_REALMODE, 0, 0, 0, 0, 0);
    1.37  	} else {
    1.38  		puts("Loading VMXAssist ...\n");
    1.39  		memcpy((void *)VMXASSIST_PHYSICAL_ADDRESS,
     2.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Aug 01 17:18:05 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Aug 01 17:28:19 2006 +0100
     2.3 @@ -2349,33 +2349,41 @@ static int svm_do_vmmcall(struct vcpu *v
     2.4      inst_len = __get_instruction_length(vmcb, INSTR_VMCALL, NULL);
     2.5      ASSERT(inst_len > 0);
     2.6  
     2.7 -    /* VMMCALL sanity check */
     2.8 -    if (vmcb->cpl > get_vmmcall_cpl(regs->edi))
     2.9 +    if ( regs->eax & 0x80000000 )
    2.10      {
    2.11 -        printf("VMMCALL CPL check failed\n");
    2.12 -        return -1;
    2.13 -    }
    2.14 -
    2.15 -    /* handle the request */
    2.16 -    switch (regs->edi) 
    2.17 -    {
    2.18 -    case VMMCALL_RESET_TO_REALMODE:
    2.19 -        if (svm_do_vmmcall_reset_to_realmode(v, regs)) 
    2.20 +        /* VMMCALL sanity check */
    2.21 +        if ( vmcb->cpl > get_vmmcall_cpl(regs->edi) )
    2.22          {
    2.23 -            printf("svm_do_vmmcall_reset_to_realmode() failed\n");
    2.24 +            printf("VMMCALL CPL check failed\n");
    2.25              return -1;
    2.26          }
    2.27 -    
    2.28 -        /* since we just reset the VMCB, return without adjusting the eip */
    2.29 -        return 0;
    2.30 -    case VMMCALL_DEBUG:
    2.31 -        printf("DEBUG features not implemented yet\n");
    2.32 -        break;
    2.33 -    default:
    2.34 -    break;
    2.35 +
    2.36 +        /* handle the request */
    2.37 +        switch ( regs->eax )
    2.38 +        {
    2.39 +        case VMMCALL_RESET_TO_REALMODE:
    2.40 +            if ( svm_do_vmmcall_reset_to_realmode(v, regs) )
    2.41 +            {
    2.42 +                printf("svm_do_vmmcall_reset_to_realmode() failed\n");
    2.43 +                return -1;
    2.44 +            }
    2.45 +            /* since we just reset the VMCB, return without adjusting
    2.46 +             * the eip */
    2.47 +            return 0;
    2.48 +
    2.49 +        case VMMCALL_DEBUG:
    2.50 +            printf("DEBUG features not implemented yet\n");
    2.51 +            break;
    2.52 +        default:
    2.53 +            break;
    2.54 +        }
    2.55 +
    2.56 +        hvm_print_line(v, regs->eax); /* provides the current domain */
    2.57      }
    2.58 -
    2.59 -    hvm_print_line(v, regs->eax); /* provides the current domain */
    2.60 +    else
    2.61 +    {
    2.62 +        hvm_do_hypercall(regs);
    2.63 +    }
    2.64  
    2.65      __update_guest_eip(vmcb, inst_len);
    2.66      return 0;
     3.1 --- a/xen/include/asm-x86/hvm/svm/vmmcall.h	Tue Aug 01 17:18:05 2006 +0100
     3.2 +++ b/xen/include/asm-x86/hvm/svm/vmmcall.h	Tue Aug 01 17:28:19 2006 +0100
     3.3 @@ -23,11 +23,11 @@
     3.4  #define __ASM_X86_HVM_SVM_VMMCALL_H__
     3.5  
     3.6  /* VMMCALL command fields */
     3.7 -#define VMMCALL_CODE_CPL_MASK     0xC0000000
     3.8 -#define VMMCALL_CODE_MBZ_MASK     0x3FFF0000
     3.9 +#define VMMCALL_CODE_CPL_MASK     0x60000000
    3.10 +#define VMMCALL_CODE_MBZ_MASK     0x1FFF0000
    3.11  #define VMMCALL_CODE_COMMAND_MASK 0x0000FFFF
    3.12  
    3.13 -#define MAKE_VMMCALL_CODE(cpl,func) ((cpl << 30) | (func))
    3.14 +#define MAKE_VMMCALL_CODE(cpl,func) ((cpl << 29) | (func) | 0x80000000)
    3.15  
    3.16  /* CPL=0 VMMCALL Requests */
    3.17  #define VMMCALL_RESET_TO_REALMODE   MAKE_VMMCALL_CODE(0,1)
    3.18 @@ -38,7 +38,7 @@
    3.19  /* return the cpl required for the vmmcall cmd */
    3.20  static inline int get_vmmcall_cpl(int cmd)
    3.21  {
    3.22 -    return (cmd & VMMCALL_CODE_CPL_MASK) >> 30;
    3.23 +    return (cmd & VMMCALL_CODE_CPL_MASK) >> 29;
    3.24  }
    3.25  
    3.26  #endif /* __ASM_X86_HVM_SVM_VMMCALL_H__ */