ia64/xen-unstable

changeset 3650:8c6281ec8860

bitkeeper revision 1.1159.212.87 (4203b25aTB_XSOA2G0yxgrj0ey-vIA)

Defined per-CPU SYSCALL entry point for hypercalls. We enter the DOM0
kernel and can receive hypercalls. Now probably need to fix the
user-access (uaccess.h) functions and macros.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Fri Feb 04 17:35:22 2005 +0000 (2005-02-04)
parents 715c644ba9ef
children 393483ae9f62 32d29625d39b
files xen/arch/x86/setup.c xen/arch/x86/traps.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/entry.S xen/arch/x86/x86_64/traps.c xen/include/asm-x86/x86_64/asm_defns.h
line diff
     1.1 --- a/xen/arch/x86/setup.c	Fri Feb 04 15:27:09 2005 +0000
     1.2 +++ b/xen/arch/x86/setup.c	Fri Feb 04 17:35:22 2005 +0000
     1.3 @@ -298,6 +298,7 @@ void __init identify_cpu(struct cpuinfo_
     1.4  unsigned long cpu_initialized;
     1.5  void __init cpu_init(void)
     1.6  {
     1.7 +    extern void percpu_traps_init(void);
     1.8      int nr = smp_processor_id();
     1.9      struct tss_struct *t = &init_tss[nr];
    1.10  
    1.11 @@ -335,6 +336,8 @@ void __init cpu_init(void)
    1.12      CD(0); CD(1); CD(2); CD(3); /* no db4 and db5 */; CD(6); CD(7);
    1.13  #undef CD
    1.14  
    1.15 +    percpu_traps_init();
    1.16 +
    1.17      /* Install correct page table. */
    1.18      write_ptbase(&current->mm);
    1.19  
     2.1 --- a/xen/arch/x86/traps.c	Fri Feb 04 15:27:09 2005 +0000
     2.2 +++ b/xen/arch/x86/traps.c	Fri Feb 04 17:35:22 2005 +0000
     2.3 @@ -470,7 +470,7 @@ asmlinkage int do_general_protection(str
     2.4      unsigned long fixup;
     2.5  
     2.6      DEBUGGER_trap_entry(TRAP_gp_fault, regs);
     2.7 -    
     2.8 +
     2.9      if ( regs->error_code & 1 )
    2.10          goto hardware_gp;
    2.11  
    2.12 @@ -732,8 +732,6 @@ void __init trap_init(void)
    2.13  
    2.14  #if defined(__i386__)
    2.15      _set_gate(idt_table+HYPERCALL_VECTOR, 14, 1, &hypercall);
    2.16 -#elif defined(__x86_64__)
    2.17 -    _set_gate(idt_table+HYPERCALL_VECTOR, 14, 3, &hypercall);
    2.18  #endif
    2.19  
    2.20      /* CPU0 uses the master IDT. */
     3.1 --- a/xen/arch/x86/x86_32/traps.c	Fri Feb 04 15:27:09 2005 +0000
     3.2 +++ b/xen/arch/x86/x86_32/traps.c	Fri Feb 04 17:35:22 2005 +0000
     3.3 @@ -196,6 +196,10 @@ void __init doublefault_init(void)
     3.4      set_task_gate(TRAP_double_fault, __DOUBLEFAULT_TSS_ENTRY<<3);
     3.5  }
     3.6  
     3.7 +void __init percpu_traps_init(void)
     3.8 +{
     3.9 +}
    3.10 +
    3.11  long set_fast_trap(struct exec_domain *p, int idx)
    3.12  {
    3.13      trap_info_t *ti;
     4.1 --- a/xen/arch/x86/x86_64/entry.S	Fri Feb 04 15:27:09 2005 +0000
     4.2 +++ b/xen/arch/x86/x86_64/entry.S	Fri Feb 04 17:35:22 2005 +0000
     4.3 @@ -12,25 +12,27 @@
     4.4  #include <public/xen.h>
     4.5  
     4.6  ENTRY(hypercall)
     4.7 -        iret
     4.8 -
     4.9 +        movl  $0x0833,8(%rsp)
    4.10 +        pushq %r11
    4.11 +        pushq $0x082b
    4.12 +        pushq %rcx
    4.13 +        pushq $0
    4.14 +        SAVE_ALL
    4.15 +	andq  $(NR_hypercalls-1),%rax
    4.16 +        leaq  SYMBOL_NAME(exception_table)(%rip),%rcx
    4.17 +        callq *(%rcx,%rax,8)
    4.18 +        RESTORE_ALL
    4.19 +        addq  $8,%rsp
    4.20 +        popq  %rcx
    4.21 +        addq  $8,%rsp
    4.22 +        popq  %r11
    4.23 +        cli
    4.24 +        popq  %rsp
    4.25 +        sysretq
    4.26 +        
    4.27  ENTRY(ret_from_intr)
    4.28  restore_all_xen:
    4.29 -        popq  %r15
    4.30 -        popq  %r14
    4.31 -        popq  %r13
    4.32 -        popq  %r12
    4.33 -        popq  %rbp
    4.34 -        popq  %rbx
    4.35 -        popq  %r11
    4.36 -        popq  %r10
    4.37 -        popq  %r9
    4.38 -        popq  %r8
    4.39 -        popq  %rax
    4.40 -        popq  %rcx
    4.41 -        popq  %rdx
    4.42 -        popq  %rsi
    4.43 -        popq  %rdi
    4.44 +        RESTORE_ALL
    4.45          addq  $8,%rsp
    4.46          iretq
    4.47  
    4.48 @@ -156,3 +158,33 @@ ENTRY(exception_table)
    4.49          .quad SYMBOL_NAME(do_alignment_check)
    4.50          .quad SYMBOL_NAME(do_machine_check)
    4.51          .quad SYMBOL_NAME(do_simd_coprocessor_error)
    4.52 +
    4.53 +ENTRY(hypercall_table)
    4.54 +        .quad SYMBOL_NAME(do_set_trap_table)     /*  0 */
    4.55 +        .quad SYMBOL_NAME(do_mmu_update)
    4.56 +        .quad SYMBOL_NAME(do_set_gdt)
    4.57 +        .quad SYMBOL_NAME(do_stack_switch)
    4.58 +        .quad SYMBOL_NAME(do_set_callbacks)
    4.59 +        .quad SYMBOL_NAME(do_fpu_taskswitch)     /*  5 */
    4.60 +        .quad SYMBOL_NAME(do_sched_op)
    4.61 +        .quad SYMBOL_NAME(do_dom0_op)
    4.62 +        .quad SYMBOL_NAME(do_set_debugreg)
    4.63 +        .quad SYMBOL_NAME(do_get_debugreg)
    4.64 +        .quad SYMBOL_NAME(do_update_descriptor)  /* 10 */
    4.65 +        .quad SYMBOL_NAME(do_ni_hypercall) # do_set_fast_trap
    4.66 +        .quad SYMBOL_NAME(do_dom_mem_op)
    4.67 +        .quad SYMBOL_NAME(do_multicall)
    4.68 +        .quad SYMBOL_NAME(do_update_va_mapping)
    4.69 +        .quad SYMBOL_NAME(do_set_timer_op)       /* 15 */
    4.70 +        .quad SYMBOL_NAME(do_event_channel_op)
    4.71 +        .quad SYMBOL_NAME(do_xen_version)
    4.72 +        .quad SYMBOL_NAME(do_console_io)
    4.73 +        .quad SYMBOL_NAME(do_physdev_op)
    4.74 +        .quad SYMBOL_NAME(do_grant_table_op)     /* 20 */
    4.75 +        .quad SYMBOL_NAME(do_vm_assist)
    4.76 +        .quad SYMBOL_NAME(do_update_va_mapping_otherdomain)
    4.77 +        .quad SYMBOL_NAME(do_ni_hypercall) # do_switch_vm86
    4.78 +        .quad SYMBOL_NAME(do_boot_vcpu)
    4.79 +        .rept NR_hypercalls-((.-hypercall_table)/4)
    4.80 +        .quad SYMBOL_NAME(do_ni_hypercall)
    4.81 +        .endr
     5.1 --- a/xen/arch/x86/x86_64/traps.c	Fri Feb 04 15:27:09 2005 +0000
     5.2 +++ b/xen/arch/x86/x86_64/traps.c	Fri Feb 04 17:35:22 2005 +0000
     5.3 @@ -7,6 +7,8 @@
     5.4  #include <xen/mm.h>
     5.5  #include <xen/irq.h>
     5.6  #include <xen/console.h>
     5.7 +#include <xen/sched.h>
     5.8 +#include <asm/msr.h>
     5.9  
    5.10  static int kstack_depth_to_print = 8*20;
    5.11  
    5.12 @@ -176,6 +178,33 @@ void __init doublefault_init(void)
    5.13      idt_table[TRAP_double_fault].a |= 1UL << 32; /* IST1 */
    5.14  }
    5.15  
    5.16 +asmlinkage void hypercall(void);
    5.17 +void __init percpu_traps_init(void)
    5.18 +{
    5.19 +    char *stack_top = (char *)get_stack_top();
    5.20 +    char *stack     = (char *)((unsigned long)stack_top & ~(STACK_SIZE - 1));
    5.21 +
    5.22 +    /* movq %rsp, saversp(%rip) */
    5.23 +    stack[0] = 0x48;
    5.24 +    stack[1] = 0x89;
    5.25 +    stack[2] = 0x25;
    5.26 +    *(u32 *)&stack[3] = (stack_top - &stack[7]) - 16;
    5.27 +
    5.28 +    /* leaq saversp(%rip), %rsp */
    5.29 +    stack[7] = 0x48;
    5.30 +    stack[8] = 0x8d;
    5.31 +    stack[9] = 0x25;
    5.32 +    *(u32 *)&stack[10] = (stack_top - &stack[14]) - 16;
    5.33 +
    5.34 +    /* jmp hypercall */
    5.35 +    stack[14] = 0xe9;
    5.36 +    *(u32 *)&stack[15] = (char *)hypercall - &stack[19];
    5.37 +
    5.38 +    wrmsr(MSR_STAR,  0, (FLAT_RING3_CS64<<16) | __HYPERVISOR_CS); 
    5.39 +    wrmsr(MSR_LSTAR, (unsigned long)stack, ((unsigned long)stack>>32)); 
    5.40 +    wrmsr(MSR_SYSCALL_MASK, 0xFFFFFFFFU, 0U);
    5.41 +}
    5.42 +
    5.43  void *decode_reg(struct xen_regs *regs, u8 b)
    5.44  {
    5.45      switch ( b )
     6.1 --- a/xen/include/asm-x86/x86_64/asm_defns.h	Fri Feb 04 15:27:09 2005 +0000
     6.2 +++ b/xen/include/asm-x86/x86_64/asm_defns.h	Fri Feb 04 17:35:22 2005 +0000
     6.3 @@ -22,6 +22,23 @@
     6.4          "pushq %r14;" \
     6.5          "pushq %r15;"
     6.6  
     6.7 +#define RESTORE_ALL \
     6.8 +        "popq  %r15;" \
     6.9 +        "popq  %r14;" \
    6.10 +        "popq  %r13;" \
    6.11 +        "popq  %r12;" \
    6.12 +        "popq  %rbp;" \
    6.13 +        "popq  %rbx;" \
    6.14 +        "popq  %r11;" \
    6.15 +        "popq  %r10;" \
    6.16 +        "popq  %r9;" \
    6.17 +        "popq  %r8;" \
    6.18 +        "popq  %rax;" \
    6.19 +        "popq  %rcx;" \
    6.20 +        "popq  %rdx;" \
    6.21 +        "popq  %rsi;" \
    6.22 +        "popq  %rdi;"
    6.23 +
    6.24  #else
    6.25  
    6.26  #define SAVE_ALL \
    6.27 @@ -42,6 +59,23 @@
    6.28          pushq %r14; \
    6.29          pushq %r15;
    6.30  
    6.31 +#define RESTORE_ALL \
    6.32 +        popq  %r15; \
    6.33 +        popq  %r14; \
    6.34 +        popq  %r13; \
    6.35 +        popq  %r12; \
    6.36 +        popq  %rbp; \
    6.37 +        popq  %rbx; \
    6.38 +        popq  %r11; \
    6.39 +        popq  %r10; \
    6.40 +        popq  %r9; \
    6.41 +        popq  %r8; \
    6.42 +        popq  %rax; \
    6.43 +        popq  %rcx; \
    6.44 +        popq  %rdx; \
    6.45 +        popq  %rsi; \
    6.46 +        popq  %rdi;
    6.47 +
    6.48  #endif
    6.49  
    6.50  #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)