ia64/xen-unstable

changeset 1556:31d1b1eaf5b5

bitkeeper revision 1.1009 (40d9af71XYel47d3OgJeM2BPw2UUqA)

Shorten the hypercall table.
author kaf24@scramble.cl.cam.ac.uk
date Wed Jun 23 16:27:29 2004 +0000 (2004-06-23)
parents 3ec9f0898ed8
children e848e1d5ecd8
files xen/arch/x86/entry.S xen/arch/x86/io_apic.c xen/arch/x86/irq.c xen/arch/x86/traps.c xen/common/kernel.c xen/include/asm-x86/config.h xen/include/asm-x86/irq.h xen/include/asm-x86/x86_64/ptrace.h
line diff
     1.1 --- a/xen/arch/x86/entry.S	Wed Jun 23 16:07:38 2004 +0000
     1.2 +++ b/xen/arch/x86/entry.S	Wed Jun 23 16:27:29 2004 +0000
     1.3 @@ -1,37 +1,14 @@
     1.4  /*
     1.5 - *  linux/arch/i386/entry.S
     1.6 + * Hypercall and fault low-level handling routines.
     1.7   *
     1.8 - *  Copyright (C) 1991, 1992  Linus Torvalds
     1.9 + * Copyright (c) 2002-2004, K A Fraser
    1.10 + * Copyright (c) 1991, 1992 Linus Torvalds
    1.11   */
    1.12  
    1.13  /*
    1.14 - * entry.S contains the system-call and fault low-level handling routines.
    1.15 - * This also contains the timer-interrupt handler, as well as all interrupts
    1.16 - * and faults that can result in a task-switch.
    1.17 + * The idea for callbacks from monitor -> guest OS
    1.18 + * ===============================================
    1.19   *
    1.20 - * Stack layout in 'ret_from_system_call':
    1.21 - *	 0(%esp) - %ebx
    1.22 - *	 4(%esp) - %ecx
    1.23 - *	 8(%esp) - %edx
    1.24 - *       C(%esp) - %esi
    1.25 - *	10(%esp) - %edi
    1.26 - *	14(%esp) - %ebp
    1.27 - *	18(%esp) - %eax
    1.28 - *	1C(%esp) - %ds
    1.29 - *	20(%esp) - %es
    1.30 - *	24(%esp) - %fs
    1.31 - *	28(%esp) - %gs
    1.32 - *	2C(%esp) - orig_eax
    1.33 - *	30(%esp) - %eip
    1.34 - *	34(%esp) - %cs
    1.35 - *	38(%esp) - %eflags
    1.36 - *	3C(%esp) - %oldesp
    1.37 - *	40(%esp) - %oldss
    1.38 - *
    1.39 - * "current" is in register %ebx during any slow entries.
    1.40 - */
    1.41 -/* The idea for callbacks from monitor -> guest OS.
    1.42 - * 
    1.43   * First, we require that all callbacks (either via a supplied
    1.44   * interrupt-descriptor-table, or via the special event or failsafe callbacks
    1.45   * in the shared-info-structure) are to ring 1. This just makes life easier,
    1.46 @@ -127,8 +104,6 @@ GTBF_TRAP_CR2    =  4
    1.47  CF_MASK		= 0x00000001
    1.48  IF_MASK		= 0x00000200
    1.49  NT_MASK		= 0x00004000
    1.50 -
    1.51 -
    1.52          
    1.53  #define SAVE_ALL_NOSEGREGS \
    1.54          cld; \
    1.55 @@ -166,7 +141,7 @@ ENTRY(continue_nonidle_task)
    1.56          ALIGN
    1.57  /*
    1.58   * HYPERVISOR_multicall(call_list, nr_calls)
    1.59 - *   Execute a list of 'nr_calls' system calls, pointed at by 'call_list'.
    1.60 + *   Execute a list of 'nr_calls' hypercalls, pointed at by 'call_list'.
    1.61   *   This is fairly easy except that:
    1.62   *   1. We may fault reading the call list, and must patch that up; and
    1.63   *   2. We cannot recursively call HYPERVISOR_multicall, or a malicious
    1.64 @@ -193,8 +168,8 @@ multicall_fault5:
    1.65          pushl 4(%ebx)       # args[0]
    1.66  multicall_fault6: 
    1.67          movl  (%ebx),%eax   # op
    1.68 -        andl  $255,%eax
    1.69 -        call  *SYMBOL_NAME(hypervisor_call_table)(,%eax,4)
    1.70 +        andl  $(NR_hypercalls-1),%eax
    1.71 +        call  *SYMBOL_NAME(hypercall_table)(,%eax,4)
    1.72  multicall_return_from_call:
    1.73  multicall_fault7:
    1.74          movl  %eax,24(%ebx) # args[5] == result
    1.75 @@ -204,7 +179,7 @@ multicall_fault7:
    1.76          loop  multicall_loop
    1.77          popl  %ebx
    1.78          xorl  %eax,%eax
    1.79 -        jmp   ret_from_hypervisor_call
    1.80 +        jmp   ret_from_hypercall
    1.81  
    1.82  .section __ex_table,"a"
    1.83          .align 4
    1.84 @@ -231,7 +206,7 @@ multicall_fixup1:
    1.85          addl  $4,%esp
    1.86          popl  %ebx
    1.87          movl  $-EFAULT,%eax
    1.88 -        jmp   ret_from_hypervisor_call
    1.89 +        jmp   ret_from_hypercall
    1.90  .previous        
    1.91                  
    1.92          ALIGN
    1.93 @@ -342,14 +317,14 @@ restore_all_xen:
    1.94          iret
    1.95  
    1.96          ALIGN
    1.97 -ENTRY(hypervisor_call)
    1.98 +ENTRY(hypercall)
    1.99          pushl %eax			# save orig_eax
   1.100  	SAVE_ALL
   1.101  	GET_CURRENT(%ebx)
   1.102 -	andl $255,%eax
   1.103 -	call *SYMBOL_NAME(hypervisor_call_table)(,%eax,4)
   1.104 +	andl $(NR_hypercalls-1),%eax
   1.105 +	call *SYMBOL_NAME(hypercall_table)(,%eax,4)
   1.106  
   1.107 -ret_from_hypervisor_call:
   1.108 +ret_from_hypercall:
   1.109          movl %eax,EAX(%esp)		# save the return value
   1.110  
   1.111  test_all_events:
   1.112 @@ -694,7 +669,7 @@ nmi_io_err:
   1.113          jmp  SYMBOL_NAME(io_check_error)                        
   1.114          
   1.115  .data
   1.116 -ENTRY(hypervisor_call_table)
   1.117 +ENTRY(hypercall_table)
   1.118          .long SYMBOL_NAME(do_set_trap_table)     /*  0 */
   1.119          .long SYMBOL_NAME(do_mmu_update)
   1.120          .long SYMBOL_NAME(do_set_gdt)
   1.121 @@ -716,6 +691,6 @@ ENTRY(hypervisor_call_table)
   1.122          .long SYMBOL_NAME(do_console_io)
   1.123          .long SYMBOL_NAME(do_physdev_op)
   1.124          .long SYMBOL_NAME(do_update_va_mapping_otherdomain) /* 20 */
   1.125 -        .rept NR_syscalls-((.-hypervisor_call_table)/4)
   1.126 -        .long SYMBOL_NAME(do_ni_syscall)
   1.127 +        .rept NR_hypercalls-((.-hypercall_table)/4)
   1.128 +        .long SYMBOL_NAME(do_ni_hypercall)
   1.129          .endr
     2.1 --- a/xen/arch/x86/io_apic.c	Wed Jun 23 16:07:38 2004 +0000
     2.2 +++ b/xen/arch/x86/io_apic.c	Wed Jun 23 16:27:29 2004 +0000
     2.3 @@ -623,9 +623,9 @@ static int __init assign_irq_vector(int 
     2.4  next:
     2.5  	current_vector += 8;
     2.6  
     2.7 -        /* XXX Skip the guestOS -> Xen syscall vector! XXX */
     2.8 -	if (current_vector == HYPERVISOR_CALL_VECTOR) goto next;
     2.9 -        /* XXX Skip the Linux/BSD fast-trap vector! XXX */
    2.10 +        /* Skip the hypercall vector. */
    2.11 +	if (current_vector == HYPERCALL_VECTOR) goto next;
    2.12 +        /* Skip the Linux/BSD fast-trap vector. */
    2.13          if (current_vector == 0x80) goto next;
    2.14  
    2.15  	if (current_vector > FIRST_SYSTEM_VECTOR) {
     3.1 --- a/xen/arch/x86/irq.c	Wed Jun 23 16:07:38 2004 +0000
     3.2 +++ b/xen/arch/x86/irq.c	Wed Jun 23 16:27:29 2004 +0000
     3.3 @@ -89,7 +89,7 @@ void enable_irq(unsigned int irq)
     3.4  
     3.5  asmlinkage void do_IRQ(struct pt_regs regs)
     3.6  {       
     3.7 -    unsigned int      irq = regs.orig_eax & 0xff;
     3.8 +    unsigned int      irq = regs.orig_eax;
     3.9      irq_desc_t       *desc = &irq_desc[irq];
    3.10      struct irqaction *action;
    3.11  
     4.1 --- a/xen/arch/x86/traps.c	Wed Jun 23 16:07:38 2004 +0000
     4.2 +++ b/xen/arch/x86/traps.c	Wed Jun 23 16:27:29 2004 +0000
     4.3 @@ -66,7 +66,7 @@ struct guest_trap_bounce {
     4.4  static struct tss_struct doublefault_tss;
     4.5  static unsigned char doublefault_stack[DOUBLEFAULT_STACK_SIZE];
     4.6  
     4.7 -asmlinkage int hypervisor_call(void);
     4.8 +asmlinkage int hypercall(void);
     4.9  asmlinkage void lcall7(void);
    4.10  asmlinkage void lcall27(void);
    4.11  
    4.12 @@ -718,7 +718,7 @@ void __init trap_init(void)
    4.13      set_intr_gate(19,&simd_coprocessor_error);
    4.14  
    4.15      /* Only ring 1 can access monitor services. */
    4.16 -    _set_gate(idt_table+HYPERVISOR_CALL_VECTOR,14,1,&hypervisor_call);
    4.17 +    _set_gate(idt_table+HYPERCALL_VECTOR,14,1,&hypercall);
    4.18  
    4.19      /* CPU0 uses the master IDT. */
    4.20      idt_tables[0] = idt_table;
     5.1 --- a/xen/common/kernel.c	Wed Jun 23 16:07:38 2004 +0000
     5.2 +++ b/xen/common/kernel.c	Wed Jun 23 16:27:29 2004 +0000
     5.3 @@ -279,7 +279,7 @@ void cmain(unsigned long magic, multiboo
     5.4  }
     5.5  
     5.6  /*
     5.7 - * Simple syscalls.
     5.8 + * Simple hypercalls.
     5.9   */
    5.10  
    5.11  long do_xen_version(int cmd)
    5.12 @@ -289,8 +289,8 @@ long do_xen_version(int cmd)
    5.13      return (XEN_VERSION<<16) | (XEN_SUBVERSION);
    5.14  }
    5.15  
    5.16 -long do_ni_syscall(void)
    5.17 +long do_ni_hypercall(void)
    5.18  {
    5.19 -    /* No-op syscall. */
    5.20 +    /* No-op hypercall. */
    5.21      return -ENOSYS;
    5.22  }
     6.1 --- a/xen/include/asm-x86/config.h	Wed Jun 23 16:07:38 2004 +0000
     6.2 +++ b/xen/include/asm-x86/config.h	Wed Jun 23 16:27:29 2004 +0000
     6.3 @@ -80,7 +80,7 @@
     6.4  
     6.5  #define barrier() __asm__ __volatile__("": : :"memory")
     6.6  
     6.7 -#define NR_syscalls 256
     6.8 +#define NR_hypercalls 32
     6.9  
    6.10  #ifndef NDEBUG
    6.11  #define MEMORY_GUARD
     7.1 --- a/xen/include/asm-x86/irq.h	Wed Jun 23 16:07:38 2004 +0000
     7.2 +++ b/xen/include/asm-x86/irq.h	Wed Jun 23 16:27:29 2004 +0000
     7.3 @@ -18,7 +18,7 @@ extern void enable_irq(unsigned int);
     7.4  
     7.5  #define NR_IRQS (256 - FIRST_EXTERNAL_VECTOR)
     7.6  
     7.7 -#define HYPERVISOR_CALL_VECTOR	0x82
     7.8 +#define HYPERCALL_VECTOR	0x82
     7.9  
    7.10  /*
    7.11   * Vectors 0x30-0x3f are used for ISA interrupts.
    7.12 @@ -44,7 +44,7 @@ extern void enable_irq(unsigned int);
    7.13  /*
    7.14   * First APIC vector available to drivers: (vectors 0x40-0xee)
    7.15   * we start at 0x41 to spread out vectors evenly between priority
    7.16 - * levels. (0x82 is the syscall vector)
    7.17 + * levels. (0x82 is the hypercall vector)
    7.18   */
    7.19  #define FIRST_DEVICE_VECTOR	0x41
    7.20  #define FIRST_SYSTEM_VECTOR	0xef
    7.21 @@ -108,12 +108,6 @@ extern char _stext, _etext;
    7.22  #define IRQ_NAME2(nr) nr##_interrupt(void)
    7.23  #define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr)
    7.24  
    7.25 -/*
    7.26 - *	SMP has a few special interrupts for IPI messages
    7.27 - */
    7.28 -
    7.29 -	/* there is a second layer of macro just to get the symbolic
    7.30 -	   name for the vector evaluated. This change is for RTLinux */
    7.31  #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
    7.32  #define XBUILD_SMP_INTERRUPT(x,v)\
    7.33  asmlinkage void x(void); \
    7.34 @@ -121,7 +115,7 @@ asmlinkage void call_##x(void); \
    7.35  __asm__( \
    7.36  "\n"__ALIGN_STR"\n" \
    7.37  SYMBOL_NAME_STR(x) ":\n\t" \
    7.38 -	"pushl $"#v"-256\n\t" \
    7.39 +	"pushl $"#v"\n\t" \
    7.40  	SAVE_ALL \
    7.41  	SYMBOL_NAME_STR(call_##x)":\n\t" \
    7.42  	"call "SYMBOL_NAME_STR(smp_##x)"\n\t" \
    7.43 @@ -134,7 +128,7 @@ asmlinkage void call_##x(void); \
    7.44  __asm__( \
    7.45  "\n"__ALIGN_STR"\n" \
    7.46  SYMBOL_NAME_STR(x) ":\n\t" \
    7.47 -	"pushl $"#v"-256\n\t" \
    7.48 +	"pushl $"#v"\n\t" \
    7.49  	SAVE_ALL \
    7.50  	"movl %esp,%eax\n\t" \
    7.51  	"pushl %eax\n\t" \
    7.52 @@ -153,22 +147,12 @@ asmlinkage void call_do_IRQ(void); \
    7.53  	"call " SYMBOL_NAME_STR(do_IRQ) "\n\t" \
    7.54  	"jmp ret_from_intr\n");
    7.55  
    7.56 -/* 
    7.57 - * subtle. orig_eax is used by the signal code to distinct between
    7.58 - * system calls and interrupted 'random user-space'. Thus we have
    7.59 - * to put a negative value into orig_eax here. (the problem is that
    7.60 - * both system calls and IRQs want to have small integer numbers in
    7.61 - * orig_eax, and the syscall code has won the optimization conflict ;)
    7.62 - *
    7.63 - * Subtle as a pigs ear.  VY
    7.64 - */
    7.65 -
    7.66  #define BUILD_IRQ(nr) \
    7.67  asmlinkage void IRQ_NAME(nr); \
    7.68  __asm__( \
    7.69  "\n"__ALIGN_STR"\n" \
    7.70  SYMBOL_NAME_STR(IRQ) #nr "_interrupt:\n\t" \
    7.71 -	"pushl $"#nr"-256\n\t" \
    7.72 +	"pushl $"#nr"\n\t" \
    7.73  	"jmp common_interrupt");
    7.74  
    7.75  extern unsigned long prof_cpu_mask;
    7.76 @@ -178,13 +162,12 @@ extern unsigned long prof_shift;
    7.77  
    7.78  #include <xen/irq.h>
    7.79  
    7.80 +static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
    7.81 +{
    7.82  #if defined(CONFIG_X86_IO_APIC)
    7.83 -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {
    7.84          if (IO_APIC_IRQ(i))
    7.85                  send_IPI_self(IO_APIC_VECTOR(i));
    7.86 +#endif
    7.87  }
    7.88 -#else
    7.89 -static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {}
    7.90 -#endif
    7.91  
    7.92  #endif /* _ASM_HW_IRQ_H */
     8.1 --- a/xen/include/asm-x86/x86_64/ptrace.h	Wed Jun 23 16:07:38 2004 +0000
     8.2 +++ b/xen/include/asm-x86/x86_64/ptrace.h	Wed Jun 23 16:27:29 2004 +0000
     8.3 @@ -8,7 +8,7 @@
     8.4  #define R12 24
     8.5  #define RBP 36
     8.6  #define RBX 40
     8.7 -/* arguments: interrupts/non tracing syscalls only save upto here*/
     8.8 +/* arguments: interrupts/hypercalls only save upto here*/
     8.9  #define R11 48
    8.10  #define R10 56	
    8.11  #define R9 64
    8.12 @@ -20,7 +20,7 @@
    8.13  #define RDI 112
    8.14  #define ORIG_RAX 120       /* = ERROR */ 
    8.15  /* end of arguments */ 	
    8.16 -/* cpu exception frame or undefined in case of fast syscall. */
    8.17 +/* cpu exception frame or undefined in case of fast hypercall. */
    8.18  #define RIP 128
    8.19  #define CS 136
    8.20  #define EFLAGS 144
    8.21 @@ -50,7 +50,7 @@ struct pt_regs {
    8.22  	unsigned long r12;
    8.23  	unsigned long rbp;
    8.24  	unsigned long rbx;
    8.25 -/* arguments: non interrupts/non tracing syscalls only save upto here*/
    8.26 +/* arguments: non interrupts/hypercalls only save upto here*/
    8.27   	unsigned long r11;
    8.28  	unsigned long r10;	
    8.29  	unsigned long r9;