direct-io.hg

changeset 4641:793d5c557544

bitkeeper revision 1.1371 (42692d136tRflIX7G4VOXJLCJstFVw)

Hi folks,

arch/xen/x86_64/kernel/entry.S | 131
+++++++++++++++++++--------------
arch/xen/x86_64/kernel/process.c | 5 -
arch/xen/x86_64/kernel/traps.c | 3
arch/xen/x86_64/kernel/vsyscall.c | 2
include/asm-xen/asm-x86_64/hypercall.h | 5 -
include/asm-xen/asm-x86_64/system.h | 6 -
6 files changed, 88 insertions(+), 64 deletions(-)

Signed-off-by: Jun Nakajima <jun.nakajima@intel.com>

Attached contains bug fixes:
1. hang at floppy driver
2. hiccups at boot time
3. FP save/restore
4. cleanups in entry.S (critical section fixup, etc.)
5. time problem (temporarily disables vgettimeofday that uses TSC). I'm
not sure if we can use TSC-based vxtime in Xen. So we need some cleanups
there.

1 & 2 were simply fixed in process.c; xen_idle() is now identical to the
32-bit one.

I'm still working on failsafe_callback (because now I'm getting it), but
the system should be ready for broader ranges of people. Some config
seems to cause a panic in the hypervisor, and I'm also looking at it.
author kaf24@firebug.cl.cam.ac.uk
date Fri Apr 22 16:57:55 2005 +0000 (2005-04-22)
parents 3b8b51c4560c
children c7f1dee0ac34
files linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/process.c linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/traps.c linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/vsyscall.c linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/system.h
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S	Fri Apr 22 16:42:55 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S	Fri Apr 22 16:57:55 2005 +0000
     1.3 @@ -204,7 +204,7 @@ ENTRY(ret_from_fork)
     1.4  	jnz rff_trace
     1.5  rff_action:	
     1.6  	RESTORE_REST
     1.7 -	cmpl $__KERNEL_CS,CS-ARGOFFSET(%rsp)	# from kernel_thread?
     1.8 +	testl $3,CS-ARGOFFSET(%rsp)	# from kernel_thread?
     1.9  	je   int_ret_from_sys_call
    1.10  	testl $_TIF_IA32,threadinfo_flags(%rcx)
    1.11  	jnz  int_ret_from_sys_call
    1.12 @@ -268,12 +268,12 @@ ret_from_sys_call:
    1.13  	/* edi:	flagmask */
    1.14  sysret_check:		
    1.15  	GET_THREAD_INFO(%rcx)
    1.16 -        XEN_GET_VCPU_INFO(%r11)
    1.17 -        XEN_BLOCK_EVENTS(%r11)        
    1.18 +        XEN_GET_VCPU_INFO(%rsi)
    1.19 +        XEN_BLOCK_EVENTS(%rsi)        
    1.20  	movl threadinfo_flags(%rcx),%edx
    1.21  	andl %edi,%edx
    1.22  	jnz  sysret_careful 
    1.23 -        XEN_UNBLOCK_EVENTS(%r11)                
    1.24 +        XEN_UNBLOCK_EVENTS(%rsi)                
    1.25  	RESTORE_ARGS 0,8,0
    1.26          SWITCH_TO_USER ECF_IN_SYSCALL
    1.27  
    1.28 @@ -282,8 +282,8 @@ sysret_check:
    1.29  sysret_careful:
    1.30  	bt $TIF_NEED_RESCHED,%edx
    1.31  	jnc sysret_signal
    1.32 -        XEN_GET_VCPU_INFO(%r11)
    1.33 -        XEN_BLOCK_EVENTS(%r11)        
    1.34 +        XEN_GET_VCPU_INFO(%rsi)
    1.35 +        XEN_BLOCK_EVENTS(%rsi)        
    1.36  	pushq %rdi
    1.37  	call schedule
    1.38  	popq  %rdi
    1.39 @@ -292,8 +292,8 @@ sysret_careful:
    1.40  	/* Handle a signal */ 
    1.41  sysret_signal:
    1.42  /*	sti */
    1.43 -        XEN_GET_VCPU_INFO(%r11)
    1.44 -        XEN_UNBLOCK_EVENTS(%r11)        
    1.45 +        XEN_GET_VCPU_INFO(%rsi)
    1.46 +        XEN_UNBLOCK_EVENTS(%rsi)        
    1.47  	testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx
    1.48  	jz    1f
    1.49  
    1.50 @@ -334,8 +334,8 @@ badsys:
    1.51   * Has correct top of stack, but partial stack frame.
    1.52   */ 	
    1.53  ENTRY(int_ret_from_sys_call)	
    1.54 -        XEN_GET_VCPU_INFO(%r11)
    1.55 -        XEN_BLOCK_EVENTS(%r11)
    1.56 +        XEN_GET_VCPU_INFO(%rsi)
    1.57 +        XEN_BLOCK_EVENTS(%rsi)
    1.58  	testb $3,CS-ARGOFFSET(%rsp)
    1.59          jnz 1f
    1.60          /* Need to set the proper %ss (not NULL) for ring 3 iretq */
    1.61 @@ -358,8 +358,8 @@ int_careful:
    1.62  	bt $TIF_NEED_RESCHED,%edx
    1.63  	jnc  int_very_careful
    1.64  /*	sti */
    1.65 -        XEN_GET_VCPU_INFO(%r11)
    1.66 -        XEN_UNBLOCK_EVENTS(%r11)
    1.67 +        XEN_GET_VCPU_INFO(%rsi)
    1.68 +        XEN_UNBLOCK_EVENTS(%rsi)
    1.69  	pushq %rdi
    1.70  	call schedule
    1.71  	popq %rdi
    1.72 @@ -368,6 +368,8 @@ int_careful:
    1.73  	/* handle signals and tracing -- both require a full stack frame */
    1.74  int_very_careful:
    1.75  /*	sti */
    1.76 +        XEN_GET_VCPU_INFO(%rsi)
    1.77 +        XEN_UNBLOCK_EVENTS(%rsi)
    1.78  	SAVE_REST
    1.79  	/* Check for syscall exit trace */	
    1.80  	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edx
    1.81 @@ -510,26 +512,26 @@ retint_check:
    1.82  	jnz  retint_careful
    1.83  retint_restore_args:				
    1.84  	RESTORE_ARGS 0,8,0						
    1.85 -        testb $3,8(%rsp)                # check CS
    1.86 -        jnz  user_mode
    1.87 +	testb $3,8(%rsp)                # check CS
    1.88 +	jnz  user_mode
    1.89  kernel_mode:
    1.90          orb   $3,1*8(%rsp)
    1.91  	iretq
    1.92  user_mode:
    1.93 -        SWITCH_TO_USER 0                        
    1.94 +	SWITCH_TO_USER 0                        
    1.95  	
    1.96  	/* edi: workmask, edx: work */	
    1.97  retint_careful:
    1.98  	bt    $TIF_NEED_RESCHED,%edx
    1.99  	jnc   retint_signal
   1.100 -        XEN_GET_VCPU_INFO(%r11)
   1.101 -        XEN_UNBLOCK_EVENTS(%r11)
   1.102 +	XEN_GET_VCPU_INFO(%rsi)
   1.103 +	XEN_UNBLOCK_EVENTS(%rsi)
   1.104  /*	sti */        
   1.105  	pushq %rdi
   1.106  	call  schedule
   1.107  	popq %rdi		
   1.108 -        XEN_GET_VCPU_INFO(%r11)        
   1.109 -        XEN_BLOCK_EVENTS(%r11)		
   1.110 +	XEN_GET_VCPU_INFO(%rsi)        
   1.111 +	XEN_BLOCK_EVENTS(%rsi)		
   1.112  	GET_THREAD_INFO(%rcx)
   1.113  /*	cli */
   1.114  	jmp retint_check
   1.115 @@ -537,16 +539,16 @@ retint_careful:
   1.116  retint_signal:
   1.117  	testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx
   1.118  	jz    retint_restore_args
   1.119 -        XEN_GET_VCPU_INFO(%r11)
   1.120 -        XEN_UNBLOCK_EVENTS(%r11)
   1.121 +        XEN_GET_VCPU_INFO(%rsi)
   1.122 +        XEN_UNBLOCK_EVENTS(%rsi)
   1.123  	SAVE_REST
   1.124  	movq $-1,ORIG_RAX(%rsp) 			
   1.125  	xorq %rsi,%rsi		# oldset
   1.126  	movq %rsp,%rdi		# &pt_regs
   1.127  	call do_notify_resume
   1.128  	RESTORE_REST
   1.129 -        XEN_GET_VCPU_INFO(%r11)        
   1.130 -        XEN_BLOCK_EVENTS(%r11)		
   1.131 +        XEN_GET_VCPU_INFO(%rsi)        
   1.132 +        XEN_BLOCK_EVENTS(%rsi)		
   1.133  	movl $_TIF_NEED_RESCHED,%edi
   1.134  	GET_THREAD_INFO(%rcx)	
   1.135  	jmp retint_check
   1.136 @@ -564,11 +566,11 @@ retint_kernel:
   1.137  	jc   retint_restore_args
   1.138  	movl $PREEMPT_ACTIVE,threadinfo_preempt_count(%rcx)
   1.139  /*	sti */
   1.140 -        XEN_GET_VCPU_INFO(%r11)
   1.141 -        XEN_BLOCK_EVENTS(%r11)
   1.142 +	XEN_GET_VCPU_INFO(%rsi)
   1.143 +	XEN_UNBLOCK_EVENTS(%rsi)
   1.144  	call schedule
   1.145 -        XEN_GET_VCPU_INFO(%r11) /* %esi can be different */
   1.146 -        XEN_UNBLOCK_EVENTS(%r11)
   1.147 +	XEN_GET_VCPU_INFO(%rsi) /* %esi can be different */
   1.148 +	XEN_BLOCK_EVENTS(%rsi)
   1.149  /*	cli */
   1.150  	GET_THREAD_INFO(%rcx)
   1.151  	movl $0,threadinfo_preempt_count(%rcx) 
   1.152 @@ -796,7 +798,13 @@ scrit:	/**** START OF CRITICAL REGION **
   1.153  	jnz  14f			# process more events if necessary...
   1.154  	XEN_UNLOCK_VCPU_INFO_SMP(%rsi)
   1.155          RESTORE_REST
   1.156 -        jmp retint_restore_args
   1.157 +        RESTORE_ARGS 0,8,0
   1.158 +        testb $3,8(%rsp)                # check CS
   1.159 +        jnz  crit_user_mode
   1.160 +        orb   $3,1*8(%rsp)
   1.161 +        iretq
   1.162 +crit_user_mode:
   1.163 +        SWITCH_TO_USER 0 
   1.164          
   1.165  14:	XEN_LOCKED_BLOCK_EVENTS(%rsi)
   1.166  	XEN_UNLOCK_VCPU_INFO_SMP(%rsi)
   1.167 @@ -842,32 +850,47 @@ 17:	movq  %rdi,%rsp			# final %edi is to
   1.168  	jmp   11b
   1.169  
   1.170  critical_fixup_table:
   1.171 -	.word 0x0000,0x0000,0x0000,0x0000         # testb  $0xff,0x0(%rsi)
   1.172 -	.word 0x0000,0x0000                       # jne    ffffffff8010daa0 14f
   1.173 -	.word 0x0000,0x0000,0x0000,0x0000         # mov    (%rsp),%r15
   1.174 -	.word 0x0808,0x0808,0x0808,0x0808,0x0808  # mov    0x8(%rsp),%r14
   1.175 -	.word 0x1010,0x1010,0x1010,0x1010,0x1010  # mov    0x10(%rsp),%r13
   1.176 -	.word 0x1818,0x1818,0x1818,0x1818,0x1818  # mov    0x18(%rsp),%r12
   1.177 -	.word 0x2020,0x2020,0x2020,0x2020,0x2020  # mov    0x20(%rsp),%rbp
   1.178 -	.word 0x2828,0x2828,0x2828,0x2828,0x2828  # mov    0x28(%rsp),%rbx
   1.179 -	.word 0x3030,0x3030,0x3030,0x3030         # add    $0x30,%rsp
   1.180 -	.word 0x0030,0x0030,0x0030,0x0030,0x0030  # testb  $0x1,0x74(%rsp)
   1.181 -	.word 0x0030,0x0030,0x0030,0x0030,0x0030,0x0030 # jne    ffffffff8010d740 <user_mode>
   1.182 -	.word 0x0030,0x0030,0x0030,0x0030         # mov    (%rsp),%r11
   1.183 -	.word 0x0838,0x0838,0x0838,0x0838,0x0838  # mov    0x8(%rsp),%r10
   1.184 -	.word 0x1040,0x1040,0x1040,0x1040,0x1040  # mov    0x10(%rsp),%r9
   1.185 -	.word 0x1848,0x1848,0x1848,0x1848,0x1848  # mov    0x18(%rsp),%r8
   1.186 -	.word 0x2060,0x2060,0x2060,0x2060,0x2060  # mov    0x20(%rsp),%rax
   1.187 -	.word 0x2868,0x2868,0x2868,0x2868,0x2868  # mov    0x28(%rsp),%rcx
   1.188 -	.word 0x3070,0x3070,0x3070,0x3070,0x3070  # mov    0x30(%rsp),%rdx
   1.189 -	.word 0x3878,0x3878,0x3878,0x3878,0x3878  # mov    0x38(%rsp),%rsi
   1.190 -	.word 0x4080,0x4080,0x4080,0x4080,0x4080  # mov    0x40(%rsp),%rdi
   1.191 -	.word 0x4888,0x4888,0x4888,0x4888         # add    $0x50,%rsp
   1.192 -	.word 0x0000,0x0000                       # iretq
   1.193 -	.word 0x0000,0x0000,0x0000,0x0000         # movb   $0x1,0x1(%rsi)
   1.194 -	.word 0x0000,0x0000,0x0000                # mov    %rsp,%rdi
   1.195 -	.word 0x0000,0x0000,0x0000,0x0000,0x0000  # jmpq   11b
   1.196 - 
   1.197 +        .byte 0x00,0x00,0x00,0x00                 # testb  $0xff,0x0(%rsi)
   1.198 +        .byte 0x00,0x00,0x00,0x00,0x00,0x00       # jne    <crit_user_mode+0x42>
   1.199 +        .byte 0x00,0x00,0x00,0x00                 # mov    (%rsp),%r15
   1.200 +        .byte 0x00,0x00,0x00,0x00,0x00            # mov    0x8(%rsp),%r14
   1.201 +        .byte 0x00,0x00,0x00,0x00,0x00            # mov    0x10(%rsp),%r13
   1.202 +        .byte 0x00,0x00,0x00,0x00,0x00            # mov    0x18(%rsp),%r12
   1.203 +        .byte 0x00,0x00,0x00,0x00,0x00            # mov    0x20(%rsp),%rbp
   1.204 +        .byte 0x00,0x00,0x00,0x00,0x00            # mov    0x28(%rsp),%rbx
   1.205 +        .byte 0x00,0x00,0x00,0x00                 # add    $0x30,%rsp
   1.206 +        .byte 0x30,0x30,0x30,0x30                 # mov    (%rsp),%r11
   1.207 +        .byte 0x30,0x30,0x30,0x30,0x30            # mov    0x8(%rsp),%r10
   1.208 +        .byte 0x30,0x30,0x30,0x30,0x30            # mov    0x10(%rsp),%r9
   1.209 +        .byte 0x30,0x30,0x30,0x30,0x30            # mov    0x18(%rsp),%r8
   1.210 +        .byte 0x30,0x30,0x30,0x30,0x30            # mov    0x20(%rsp),%rax
   1.211 +        .byte 0x30,0x30,0x30,0x30,0x30            # mov    0x28(%rsp),%rcx
   1.212 +        .byte 0x30,0x30,0x30,0x30,0x30            # mov    0x30(%rsp),%rdx
   1.213 +        .byte 0x30,0x30,0x30,0x30,0x30            # mov    0x38(%rsp),%rsi
   1.214 +        .byte 0x30,0x30,0x30,0x30,0x30            # mov    0x40(%rsp),%rdi
   1.215 +        .byte 0x30,0x30,0x30,0x30                 # add    $0x50,%rsp
   1.216 +        .byte 0x80,0x80,0x80,0x80,0x80            # testb  $0x3,0x8(%rsp)
   1.217 +        .byte 0x80,0x80                           # jne    ffffffff8010dc25 <crit_user_mode>
   1.218 +        .byte 0x80,0x80,0x80,0x80                 # orb    $0x3,0x8(%rsp)
   1.219 +        .byte 0x80,0x80                           # iretq
   1.220 +                                                  # <crit_user_mode>:
   1.221 +        .byte 0x80,0x80,0x80,0x80,0x80,0x80,0x80  # movq   $0x0,%gs:0x60
   1.222 +        .byte 0x80,0x80,0x80,0x80,0x80
   1.223 +        .byte 0x80,0x80,0x80,0x80                 # sub    $0x20,%rsp
   1.224 +        .byte 0x60,0x60,0x60,0x60                 # mov    %rax,(%rsp)
   1.225 +        .byte 0x60,0x60,0x60,0x60,0x60            # mov    %r11,0x8(%rsp)
   1.226 +        .byte 0x60,0x60,0x60,0x60,0x60            # mov    %rcx,0x10(%rsp)
   1.227 +        .byte 0x60,0x60,0x60,0x60,0x60,0x60,0x60  # movq   $0x0,0x18(%rsp)
   1.228 +        .byte 0x60,0x60
   1.229 +        .byte 0x60,0x60,0x60,0x60,0x60,0x60,0x60  # movq   $0x33,0x28(%rsp)
   1.230 +        .byte 0x60,0x60
   1.231 +        .byte 0x60,0x60,0x60,0x60,0x60,0x60,0x60  # movq   $0x2b,0x40(%rsp)
   1.232 +        .byte 0x60,0x60        
   1.233 +        .byte 0x60,0x60,0x60,0x60,0x60,0x60,0x60  # mov    $0x17,%rax
   1.234 +        .byte 0x60,0x60                           # syscall
   1.235 +        .byte 0x60,0x60,0x60,0x60,0x60            # movb   $0x1,0x1(%rsi)
   1.236 +        .byte 0x60,0x60,0x60                      # mov    %rsp,%rdi
   1.237 +        .byte 0x60,0x60,0x60,0x60,0x60            # jmpq   <do_hypervisor_callback+0x20>
   1.238  # Hypervisor uses this for application faults while it executes.
   1.239  ENTRY(failsafe_callback)
   1.240          hlt         
     2.1 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/process.c	Fri Apr 22 16:42:55 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/process.c	Fri Apr 22 16:57:55 2005 +0000
     2.3 @@ -87,7 +87,9 @@ EXPORT_SYMBOL(enable_hlt);
     2.4  extern int set_timeout_timer(void);
     2.5  void xen_idle(void)
     2.6  {
     2.7 -	int cpu;
     2.8 +	int cpu;	
     2.9 +
    2.10 +	local_irq_disable();
    2.11  
    2.12  	cpu = smp_processor_id();
    2.13  	if (rcu_pending(cpu))
    2.14 @@ -102,7 +104,6 @@ void xen_idle(void)
    2.15  		local_irq_enable();
    2.16  		HYPERVISOR_yield();
    2.17  	}
    2.18 -        set_need_resched();
    2.19  }
    2.20  
    2.21  /*
     3.1 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/traps.c	Fri Apr 22 16:42:55 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/traps.c	Fri Apr 22 16:57:55 2005 +0000
     3.3 @@ -896,7 +896,8 @@ asmlinkage void __attribute__((weak)) sm
     3.4  asmlinkage void math_state_restore(void)
     3.5  {
     3.6  	struct task_struct *me = current;
     3.7 -	clts();			/* Allow maths ops (or we recurse) */
     3.8 +        
     3.9 +        /* clts(); */ /* 'clts' is done for us by Xen during virtual trap. */
    3.10  
    3.11  	if (!used_math())
    3.12  		init_fpu(me);
     4.1 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/vsyscall.c	Fri Apr 22 16:42:55 2005 +0000
     4.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/vsyscall.c	Fri Apr 22 16:57:55 2005 +0000
     4.3 @@ -182,7 +182,7 @@ static int __init vsyscall_init(void)
     4.4  	BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)));
     4.5  	map_vsyscall();
     4.6          map_vsyscall_user();    /* establish tranlation for user address space */
     4.7 -	sysctl_vsyscall = 1; 
     4.8 +	sysctl_vsyscall = 0;    /* TBD */
     4.9  
    4.10  	return 0;
    4.11  }
     5.1 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h	Fri Apr 22 16:42:55 2005 +0000
     5.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h	Fri Apr 22 16:57:55 2005 +0000
     5.3 @@ -138,12 +138,13 @@ HYPERVISOR_set_callbacks(
     5.4  
     5.5  static inline int
     5.6  HYPERVISOR_fpu_taskswitch(
     5.7 -    void)
     5.8 +    int set)
     5.9  {
    5.10      int ret;
    5.11      __asm__ __volatile__ (
    5.12          TRAP_INSTR
    5.13 -        : "=a" (ret) : "0" ((unsigned long)__HYPERVISOR_fpu_taskswitch) : __syscall_clobber );
    5.14 +        : "=a" (ret) : "0" ((unsigned long)__HYPERVISOR_fpu_taskswitch),
    5.15 +          "D" ((unsigned long) set) : __syscall_clobber );
    5.16  
    5.17      return ret;
    5.18  }
     6.1 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/system.h	Fri Apr 22 16:42:55 2005 +0000
     6.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/system.h	Fri Apr 22 16:57:55 2005 +0000
     6.3 @@ -144,8 +144,7 @@ struct alt_instr {
     6.4  /*
     6.5   * Clear and set 'TS' bit respectively
     6.6   */
     6.7 -#define clts() __asm__ __volatile__ ("clts")
     6.8 -
     6.9 +#define clts() (HYPERVISOR_fpu_taskswitch(0))
    6.10  static inline unsigned long read_cr0(void)
    6.11  { 
    6.12          BUG();
    6.13 @@ -170,8 +169,7 @@ static inline void write_cr4(unsigned lo
    6.14  { 
    6.15          BUG();
    6.16  } 
    6.17 -
    6.18 -#define stts() write_cr0(8 | read_cr0())
    6.19 +#define stts() (HYPERVISOR_fpu_taskswitch(1))
    6.20  
    6.21  #define wbinvd() \
    6.22  	__asm__ __volatile__ ("wbinvd": : :"memory");