• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/arch/tile/kernel/
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 *   This program is free software; you can redistribute it and/or
5 *   modify it under the terms of the GNU General Public License
6 *   as published by the Free Software Foundation, version 2.
7 *
8 *   This program is distributed in the hope that it will be useful, but
9 *   WITHOUT ANY WARRANTY; without even the implied warranty of
10 *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 *   NON INFRINGEMENT.  See the GNU General Public License for
12 *   more details.
13 */
14
15#include <linux/sched.h>
16#include <linux/preempt.h>
17#include <linux/module.h>
18#include <linux/fs.h>
19#include <linux/kprobes.h>
20#include <linux/elfcore.h>
21#include <linux/tick.h>
22#include <linux/init.h>
23#include <linux/mm.h>
24#include <linux/compat.h>
25#include <linux/hardirq.h>
26#include <linux/syscalls.h>
27#include <linux/kernel.h>
28#include <asm/system.h>
29#include <asm/stack.h>
30#include <asm/homecache.h>
31#include <asm/syscalls.h>
32#ifdef CONFIG_HARDWALL
33#include <asm/hardwall.h>
34#endif
35#include <arch/chip.h>
36#include <arch/abi.h>
37
38
39/*
40 * Use the (x86) "idle=poll" option to prefer low latency when leaving the
41 * idle loop over low power while in the idle loop, e.g. if we have
42 * one thread per core and we want to get threads out of futex waits fast.
43 */
44static int no_idle_nap;
45static int __init idle_setup(char *str)
46{
47	if (!str)
48		return -EINVAL;
49
50	if (!strcmp(str, "poll")) {
51		pr_info("using polling idle threads.\n");
52		no_idle_nap = 1;
53	} else if (!strcmp(str, "halt"))
54		no_idle_nap = 0;
55	else
56		return -1;
57
58	return 0;
59}
60early_param("idle", idle_setup);
61
62/*
63 * The idle thread. There's no useful work to be
64 * done, so just try to conserve power and have a
65 * low exit latency (ie sit in a loop waiting for
66 * somebody to say that they'd like to reschedule)
67 */
68void cpu_idle(void)
69{
70	int cpu = smp_processor_id();
71
72
73	current_thread_info()->status |= TS_POLLING;
74
75	if (no_idle_nap) {
76		while (1) {
77			while (!need_resched())
78				cpu_relax();
79			schedule();
80		}
81	}
82
83	/* endless idle loop with no priority at all */
84	while (1) {
85		tick_nohz_stop_sched_tick(1);
86		while (!need_resched()) {
87			if (cpu_is_offline(cpu))
88				BUG();  /* no HOTPLUG_CPU */
89
90			local_irq_disable();
91			__get_cpu_var(irq_stat).idle_timestamp = jiffies;
92			current_thread_info()->status &= ~TS_POLLING;
93			/*
94			 * TS_POLLING-cleared state must be visible before we
95			 * test NEED_RESCHED:
96			 */
97			smp_mb();
98
99			if (!need_resched())
100				_cpu_idle();
101			else
102				local_irq_enable();
103			current_thread_info()->status |= TS_POLLING;
104		}
105		tick_nohz_restart_sched_tick();
106		preempt_enable_no_resched();
107		schedule();
108		preempt_disable();
109	}
110}
111
112struct thread_info *alloc_thread_info(struct task_struct *task)
113{
114	struct page *page;
115	gfp_t flags = GFP_KERNEL;
116
117#ifdef CONFIG_DEBUG_STACK_USAGE
118	flags |= __GFP_ZERO;
119#endif
120
121	page = alloc_pages(flags, THREAD_SIZE_ORDER);
122	if (!page)
123		return NULL;
124
125	return (struct thread_info *)page_address(page);
126}
127
128/*
129 * Free a thread_info node, and all of its derivative
130 * data structures.
131 */
132void free_thread_info(struct thread_info *info)
133{
134	struct single_step_state *step_state = info->step_state;
135
136#ifdef CONFIG_HARDWALL
137	/*
138	 * We free a thread_info from the context of the task that has
139	 * been scheduled next, so the original task is already dead.
140	 * Calling deactivate here just frees up the data structures.
141	 * If the task we're freeing held the last reference to a
142	 * hardwall fd, it would have been released prior to this point
143	 * anyway via exit_files(), and "hardwall" would be NULL by now.
144	 */
145	if (info->task->thread.hardwall)
146		hardwall_deactivate(info->task);
147#endif
148
149	if (step_state) {
150
151		kfree(step_state);
152	}
153
154	free_page((unsigned long)info);
155}
156
157static void save_arch_state(struct thread_struct *t);
158
159int copy_thread(unsigned long clone_flags, unsigned long sp,
160		unsigned long stack_size,
161		struct task_struct *p, struct pt_regs *regs)
162{
163	struct pt_regs *childregs;
164	unsigned long ksp;
165
166	/*
167	 * When creating a new kernel thread we pass sp as zero.
168	 * Assign it to a reasonable value now that we have the stack.
169	 */
170	if (sp == 0 && regs->ex1 == PL_ICS_EX1(KERNEL_PL, 0))
171		sp = KSTK_TOP(p);
172
173	/*
174	 * Do not clone step state from the parent; each thread
175	 * must make its own lazily.
176	 */
177	task_thread_info(p)->step_state = NULL;
178
179	/*
180	 * Start new thread in ret_from_fork so it schedules properly
181	 * and then return from interrupt like the parent.
182	 */
183	p->thread.pc = (unsigned long) ret_from_fork;
184
185	/* Save user stack top pointer so we can ID the stack vm area later. */
186	p->thread.usp0 = sp;
187
188	/* Record the pid of the process that created this one. */
189	p->thread.creator_pid = current->pid;
190
191	/*
192	 * Copy the registers onto the kernel stack so the
193	 * return-from-interrupt code will reload it into registers.
194	 */
195	childregs = task_pt_regs(p);
196	*childregs = *regs;
197	childregs->regs[0] = 0;         /* return value is zero */
198	childregs->sp = sp;  /* override with new user stack pointer */
199
200	/*
201	 * If CLONE_SETTLS is set, set "tp" in the new task to "r4",
202	 * which is passed in as arg #5 to sys_clone().
203	 */
204	if (clone_flags & CLONE_SETTLS)
205		childregs->tp = regs->regs[4];
206
207	/*
208	 * Copy the callee-saved registers from the passed pt_regs struct
209	 * into the context-switch callee-saved registers area.
210	 * We have to restore the callee-saved registers since we may
211	 * be cloning a userspace task with userspace register state,
212	 * and we won't be unwinding the same kernel frames to restore them.
213	 * Zero out the C ABI save area to mark the top of the stack.
214	 */
215	ksp = (unsigned long) childregs;
216	ksp -= C_ABI_SAVE_AREA_SIZE;   /* interrupt-entry save area */
217	((long *)ksp)[0] = ((long *)ksp)[1] = 0;
218	ksp -= CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long);
219	memcpy((void *)ksp, &regs->regs[CALLEE_SAVED_FIRST_REG],
220	       CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long));
221	ksp -= C_ABI_SAVE_AREA_SIZE;   /* __switch_to() save area */
222	((long *)ksp)[0] = ((long *)ksp)[1] = 0;
223	p->thread.ksp = ksp;
224
225#if CHIP_HAS_TILE_DMA()
226	/*
227	 * No DMA in the new thread.  We model this on the fact that
228	 * fork() clears the pending signals, alarms, and aio for the child.
229	 */
230	memset(&p->thread.tile_dma_state, 0, sizeof(struct tile_dma_state));
231	memset(&p->thread.dma_async_tlb, 0, sizeof(struct async_tlb));
232#endif
233
234#if CHIP_HAS_SN_PROC()
235	/* Likewise, the new thread is not running static processor code. */
236	p->thread.sn_proc_running = 0;
237	memset(&p->thread.sn_async_tlb, 0, sizeof(struct async_tlb));
238#endif
239
240#if CHIP_HAS_PROC_STATUS_SPR()
241	/* New thread has its miscellaneous processor state bits clear. */
242	p->thread.proc_status = 0;
243#endif
244
245#ifdef CONFIG_HARDWALL
246	/* New thread does not own any networks. */
247	p->thread.hardwall = NULL;
248#endif
249
250
251	/*
252	 * Start the new thread with the current architecture state
253	 * (user interrupt masks, etc.).
254	 */
255	save_arch_state(&p->thread);
256
257	return 0;
258}
259
260/*
261 * Return "current" if it looks plausible, or else a pointer to a dummy.
262 * This can be helpful if we are just trying to emit a clean panic.
263 */
264struct task_struct *validate_current(void)
265{
266	static struct task_struct corrupt = { .comm = "<corrupt>" };
267	struct task_struct *tsk = current;
268	if (unlikely((unsigned long)tsk < PAGE_OFFSET ||
269		     (void *)tsk > high_memory ||
270		     ((unsigned long)tsk & (__alignof__(*tsk) - 1)) != 0)) {
271		pr_err("Corrupt 'current' %p (sp %#lx)\n", tsk, stack_pointer);
272		tsk = &corrupt;
273	}
274	return tsk;
275}
276
277/* Take and return the pointer to the previous task, for schedule_tail(). */
278struct task_struct *sim_notify_fork(struct task_struct *prev)
279{
280	struct task_struct *tsk = current;
281	__insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_FORK_PARENT |
282		     (tsk->thread.creator_pid << _SIM_CONTROL_OPERATOR_BITS));
283	__insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_FORK |
284		     (tsk->pid << _SIM_CONTROL_OPERATOR_BITS));
285	return prev;
286}
287
288int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
289{
290	struct pt_regs *ptregs = task_pt_regs(tsk);
291	elf_core_copy_regs(regs, ptregs);
292	return 1;
293}
294
295#if CHIP_HAS_TILE_DMA()
296
297/* Allow user processes to access the DMA SPRs */
298void grant_dma_mpls(void)
299{
300	__insn_mtspr(SPR_MPL_DMA_CPL_SET_0, 1);
301	__insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_0, 1);
302}
303
304/* Forbid user processes from accessing the DMA SPRs */
305void restrict_dma_mpls(void)
306{
307	__insn_mtspr(SPR_MPL_DMA_CPL_SET_1, 1);
308	__insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_1, 1);
309}
310
311/* Pause the DMA engine, then save off its state registers. */
312static void save_tile_dma_state(struct tile_dma_state *dma)
313{
314	unsigned long state = __insn_mfspr(SPR_DMA_USER_STATUS);
315	unsigned long post_suspend_state;
316
317	/* If we're running, suspend the engine. */
318	if ((state & DMA_STATUS_MASK) == SPR_DMA_STATUS__RUNNING_MASK)
319		__insn_mtspr(SPR_DMA_CTR, SPR_DMA_CTR__SUSPEND_MASK);
320
321	/*
322	 * Wait for the engine to idle, then save regs.  Note that we
323	 * want to record the "running" bit from before suspension,
324	 * and the "done" bit from after, so that we can properly
325	 * distinguish a case where the user suspended the engine from
326	 * the case where the kernel suspended as part of the context
327	 * swap.
328	 */
329	do {
330		post_suspend_state = __insn_mfspr(SPR_DMA_USER_STATUS);
331	} while (post_suspend_state & SPR_DMA_STATUS__BUSY_MASK);
332
333	dma->src = __insn_mfspr(SPR_DMA_SRC_ADDR);
334	dma->src_chunk = __insn_mfspr(SPR_DMA_SRC_CHUNK_ADDR);
335	dma->dest = __insn_mfspr(SPR_DMA_DST_ADDR);
336	dma->dest_chunk = __insn_mfspr(SPR_DMA_DST_CHUNK_ADDR);
337	dma->strides = __insn_mfspr(SPR_DMA_STRIDE);
338	dma->chunk_size = __insn_mfspr(SPR_DMA_CHUNK_SIZE);
339	dma->byte = __insn_mfspr(SPR_DMA_BYTE);
340	dma->status = (state & SPR_DMA_STATUS__RUNNING_MASK) |
341		(post_suspend_state & SPR_DMA_STATUS__DONE_MASK);
342}
343
344/* Restart a DMA that was running before we were context-switched out. */
345static void restore_tile_dma_state(struct thread_struct *t)
346{
347	const struct tile_dma_state *dma = &t->tile_dma_state;
348
349	/*
350	 * The only way to restore the done bit is to run a zero
351	 * length transaction.
352	 */
353	if ((dma->status & SPR_DMA_STATUS__DONE_MASK) &&
354	    !(__insn_mfspr(SPR_DMA_USER_STATUS) & SPR_DMA_STATUS__DONE_MASK)) {
355		__insn_mtspr(SPR_DMA_BYTE, 0);
356		__insn_mtspr(SPR_DMA_CTR, SPR_DMA_CTR__REQUEST_MASK);
357		while (__insn_mfspr(SPR_DMA_USER_STATUS) &
358		       SPR_DMA_STATUS__BUSY_MASK)
359			;
360	}
361
362	__insn_mtspr(SPR_DMA_SRC_ADDR, dma->src);
363	__insn_mtspr(SPR_DMA_SRC_CHUNK_ADDR, dma->src_chunk);
364	__insn_mtspr(SPR_DMA_DST_ADDR, dma->dest);
365	__insn_mtspr(SPR_DMA_DST_CHUNK_ADDR, dma->dest_chunk);
366	__insn_mtspr(SPR_DMA_STRIDE, dma->strides);
367	__insn_mtspr(SPR_DMA_CHUNK_SIZE, dma->chunk_size);
368	__insn_mtspr(SPR_DMA_BYTE, dma->byte);
369
370	/*
371	 * Restart the engine if we were running and not done.
372	 * Clear a pending async DMA fault that we were waiting on return
373	 * to user space to execute, since we expect the DMA engine
374	 * to regenerate those faults for us now.  Note that we don't
375	 * try to clear the TIF_ASYNC_TLB flag, since it's relatively
376	 * harmless if set, and it covers both DMA and the SN processor.
377	 */
378	if ((dma->status & DMA_STATUS_MASK) == SPR_DMA_STATUS__RUNNING_MASK) {
379		t->dma_async_tlb.fault_num = 0;
380		__insn_mtspr(SPR_DMA_CTR, SPR_DMA_CTR__REQUEST_MASK);
381	}
382}
383
384#endif
385
386static void save_arch_state(struct thread_struct *t)
387{
388#if CHIP_HAS_SPLIT_INTR_MASK()
389	t->interrupt_mask = __insn_mfspr(SPR_INTERRUPT_MASK_0_0) |
390		((u64)__insn_mfspr(SPR_INTERRUPT_MASK_0_1) << 32);
391#else
392	t->interrupt_mask = __insn_mfspr(SPR_INTERRUPT_MASK_0);
393#endif
394	t->ex_context[0] = __insn_mfspr(SPR_EX_CONTEXT_0_0);
395	t->ex_context[1] = __insn_mfspr(SPR_EX_CONTEXT_0_1);
396	t->system_save[0] = __insn_mfspr(SPR_SYSTEM_SAVE_0_0);
397	t->system_save[1] = __insn_mfspr(SPR_SYSTEM_SAVE_0_1);
398	t->system_save[2] = __insn_mfspr(SPR_SYSTEM_SAVE_0_2);
399	t->system_save[3] = __insn_mfspr(SPR_SYSTEM_SAVE_0_3);
400	t->intctrl_0 = __insn_mfspr(SPR_INTCTRL_0_STATUS);
401#if CHIP_HAS_PROC_STATUS_SPR()
402	t->proc_status = __insn_mfspr(SPR_PROC_STATUS);
403#endif
404#if !CHIP_HAS_FIXED_INTVEC_BASE()
405	t->interrupt_vector_base = __insn_mfspr(SPR_INTERRUPT_VECTOR_BASE_0);
406#endif
407#if CHIP_HAS_TILE_RTF_HWM()
408	t->tile_rtf_hwm = __insn_mfspr(SPR_TILE_RTF_HWM);
409#endif
410#if CHIP_HAS_DSTREAM_PF()
411	t->dstream_pf = __insn_mfspr(SPR_DSTREAM_PF);
412#endif
413}
414
415static void restore_arch_state(const struct thread_struct *t)
416{
417#if CHIP_HAS_SPLIT_INTR_MASK()
418	__insn_mtspr(SPR_INTERRUPT_MASK_0_0, (u32) t->interrupt_mask);
419	__insn_mtspr(SPR_INTERRUPT_MASK_0_1, t->interrupt_mask >> 32);
420#else
421	__insn_mtspr(SPR_INTERRUPT_MASK_0, t->interrupt_mask);
422#endif
423	__insn_mtspr(SPR_EX_CONTEXT_0_0, t->ex_context[0]);
424	__insn_mtspr(SPR_EX_CONTEXT_0_1, t->ex_context[1]);
425	__insn_mtspr(SPR_SYSTEM_SAVE_0_0, t->system_save[0]);
426	__insn_mtspr(SPR_SYSTEM_SAVE_0_1, t->system_save[1]);
427	__insn_mtspr(SPR_SYSTEM_SAVE_0_2, t->system_save[2]);
428	__insn_mtspr(SPR_SYSTEM_SAVE_0_3, t->system_save[3]);
429	__insn_mtspr(SPR_INTCTRL_0_STATUS, t->intctrl_0);
430#if CHIP_HAS_PROC_STATUS_SPR()
431	__insn_mtspr(SPR_PROC_STATUS, t->proc_status);
432#endif
433#if !CHIP_HAS_FIXED_INTVEC_BASE()
434	__insn_mtspr(SPR_INTERRUPT_VECTOR_BASE_0, t->interrupt_vector_base);
435#endif
436#if CHIP_HAS_TILE_RTF_HWM()
437	__insn_mtspr(SPR_TILE_RTF_HWM, t->tile_rtf_hwm);
438#endif
439#if CHIP_HAS_DSTREAM_PF()
440	__insn_mtspr(SPR_DSTREAM_PF, t->dstream_pf);
441#endif
442}
443
444
445void _prepare_arch_switch(struct task_struct *next)
446{
447#if CHIP_HAS_SN_PROC()
448	int snctl;
449#endif
450#if CHIP_HAS_TILE_DMA()
451	struct tile_dma_state *dma = &current->thread.tile_dma_state;
452	if (dma->enabled)
453		save_tile_dma_state(dma);
454#endif
455#if CHIP_HAS_SN_PROC()
456	/*
457	 * Suspend the static network processor if it was running.
458	 * We do not suspend the fabric itself, just like we don't
459	 * try to suspend the UDN.
460	 */
461	snctl = __insn_mfspr(SPR_SNCTL);
462	current->thread.sn_proc_running =
463		(snctl & SPR_SNCTL__FRZPROC_MASK) == 0;
464	if (current->thread.sn_proc_running)
465		__insn_mtspr(SPR_SNCTL, snctl | SPR_SNCTL__FRZPROC_MASK);
466#endif
467}
468
469
470struct task_struct *__sched _switch_to(struct task_struct *prev,
471				       struct task_struct *next)
472{
473	/* DMA state is already saved; save off other arch state. */
474	save_arch_state(&prev->thread);
475
476#if CHIP_HAS_TILE_DMA()
477	/*
478	 * Restore DMA in new task if desired.
479	 * Note that it is only safe to restart here since interrupts
480	 * are disabled, so we can't take any DMATLB miss or access
481	 * interrupts before we have finished switching stacks.
482	 */
483	if (next->thread.tile_dma_state.enabled) {
484		restore_tile_dma_state(&next->thread);
485		grant_dma_mpls();
486	} else {
487		restrict_dma_mpls();
488	}
489#endif
490
491	/* Restore other arch state. */
492	restore_arch_state(&next->thread);
493
494#if CHIP_HAS_SN_PROC()
495	/*
496	 * Restart static network processor in the new process
497	 * if it was running before.
498	 */
499	if (next->thread.sn_proc_running) {
500		int snctl = __insn_mfspr(SPR_SNCTL);
501		__insn_mtspr(SPR_SNCTL, snctl & ~SPR_SNCTL__FRZPROC_MASK);
502	}
503#endif
504
505#ifdef CONFIG_HARDWALL
506	/* Enable or disable access to the network registers appropriately. */
507	if (prev->thread.hardwall != NULL) {
508		if (next->thread.hardwall == NULL)
509			restrict_network_mpls();
510	} else if (next->thread.hardwall != NULL) {
511		grant_network_mpls();
512	}
513#endif
514
515	/*
516	 * Switch kernel SP, PC, and callee-saved registers.
517	 * In the context of the new task, return the old task pointer
518	 * (i.e. the task that actually called __switch_to).
519	 * Pass the value to use for SYSTEM_SAVE_1_0 when we reset our sp.
520	 */
521	return __switch_to(prev, next, next_current_ksp0(next));
522}
523
524long _sys_fork(struct pt_regs *regs)
525{
526	return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL);
527}
528
529long _sys_clone(unsigned long clone_flags, unsigned long newsp,
530		void __user *parent_tidptr, void __user *child_tidptr,
531		struct pt_regs *regs)
532{
533	if (!newsp)
534		newsp = regs->sp;
535	return do_fork(clone_flags, newsp, regs, 0,
536		       parent_tidptr, child_tidptr);
537}
538
539long _sys_vfork(struct pt_regs *regs)
540{
541	return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp,
542		       regs, 0, NULL, NULL);
543}
544
545/*
546 * sys_execve() executes a new program.
547 */
548long _sys_execve(const char __user *path,
549		 const char __user *const __user *argv,
550		 const char __user *const __user *envp, struct pt_regs *regs)
551{
552	long error;
553	char *filename;
554
555	filename = getname(path);
556	error = PTR_ERR(filename);
557	if (IS_ERR(filename))
558		goto out;
559	error = do_execve(filename, argv, envp, regs);
560	putname(filename);
561out:
562	return error;
563}
564
565#ifdef CONFIG_COMPAT
566long _compat_sys_execve(const char __user *path,
567			const compat_uptr_t __user *argv,
568			const compat_uptr_t __user *envp, struct pt_regs *regs)
569{
570	long error;
571	char *filename;
572
573	filename = getname(path);
574	error = PTR_ERR(filename);
575	if (IS_ERR(filename))
576		goto out;
577	error = compat_do_execve(filename, argv, envp, regs);
578	putname(filename);
579out:
580	return error;
581}
582#endif
583
584unsigned long get_wchan(struct task_struct *p)
585{
586	struct KBacktraceIterator kbt;
587
588	if (!p || p == current || p->state == TASK_RUNNING)
589		return 0;
590
591	for (KBacktraceIterator_init(&kbt, p, NULL);
592	     !KBacktraceIterator_end(&kbt);
593	     KBacktraceIterator_next(&kbt)) {
594		if (!in_sched_functions(kbt.it.pc))
595			return kbt.it.pc;
596	}
597
598	return 0;
599}
600
601/*
602 * We pass in lr as zero (cleared in kernel_thread) and the caller
603 * part of the backtrace ABI on the stack also zeroed (in copy_thread)
604 * so that backtraces will stop with this function.
605 * Note that we don't use r0, since copy_thread() clears it.
606 */
607static void start_kernel_thread(int dummy, int (*fn)(int), int arg)
608{
609	do_exit(fn(arg));
610}
611
612/*
613 * Create a kernel thread
614 */
615int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
616{
617	struct pt_regs regs;
618
619	memset(&regs, 0, sizeof(regs));
620	regs.ex1 = PL_ICS_EX1(KERNEL_PL, 0);  /* run at kernel PL, no ICS */
621	regs.pc = (long) start_kernel_thread;
622	regs.flags = PT_FLAGS_CALLER_SAVES;   /* need to restore r1 and r2 */
623	regs.regs[1] = (long) fn;             /* function pointer */
624	regs.regs[2] = (long) arg;            /* parameter register */
625
626	/* Ok, create the new process.. */
627	return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs,
628		       0, NULL, NULL);
629}
630EXPORT_SYMBOL(kernel_thread);
631
632/* Flush thread state. */
633void flush_thread(void)
634{
635	/* Nothing */
636}
637
638/*
639 * Free current thread data structures etc..
640 */
641void exit_thread(void)
642{
643	/* Nothing */
644}
645
646void show_regs(struct pt_regs *regs)
647{
648	struct task_struct *tsk = validate_current();
649	int i;
650
651	pr_err("\n");
652	pr_err(" Pid: %d, comm: %20s, CPU: %d\n",
653	       tsk->pid, tsk->comm, smp_processor_id());
654#ifdef __tilegx__
655	for (i = 0; i < 51; i += 3)
656		pr_err(" r%-2d: "REGFMT" r%-2d: "REGFMT" r%-2d: "REGFMT"\n",
657		       i, regs->regs[i], i+1, regs->regs[i+1],
658		       i+2, regs->regs[i+2]);
659	pr_err(" r51: "REGFMT" r52: "REGFMT" tp : "REGFMT"\n",
660	       regs->regs[51], regs->regs[52], regs->tp);
661	pr_err(" sp : "REGFMT" lr : "REGFMT"\n", regs->sp, regs->lr);
662#else
663	for (i = 0; i < 52; i += 4)
664		pr_err(" r%-2d: "REGFMT" r%-2d: "REGFMT
665		       " r%-2d: "REGFMT" r%-2d: "REGFMT"\n",
666		       i, regs->regs[i], i+1, regs->regs[i+1],
667		       i+2, regs->regs[i+2], i+3, regs->regs[i+3]);
668	pr_err(" r52: "REGFMT" tp : "REGFMT" sp : "REGFMT" lr : "REGFMT"\n",
669	       regs->regs[52], regs->tp, regs->sp, regs->lr);
670#endif
671	pr_err(" pc : "REGFMT" ex1: %ld     faultnum: %ld\n",
672	       regs->pc, regs->ex1, regs->faultnum);
673
674	dump_stack_regs(regs);
675}
676