linux/arch/tile/kernel/process.c
<<
>>
Prefs
   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 <linux/tracehook.h>
  29#include <linux/signal.h>
  30#include <asm/stack.h>
  31#include <asm/switch_to.h>
  32#include <asm/homecache.h>
  33#include <asm/syscalls.h>
  34#include <asm/traps.h>
  35#include <asm/setup.h>
  36#ifdef CONFIG_HARDWALL
  37#include <asm/hardwall.h>
  38#endif
  39#include <arch/chip.h>
  40#include <arch/abi.h>
  41#include <arch/sim_def.h>
  42
  43/*
  44 * Use the (x86) "idle=poll" option to prefer low latency when leaving the
  45 * idle loop over low power while in the idle loop, e.g. if we have
  46 * one thread per core and we want to get threads out of futex waits fast.
  47 */
  48static int __init idle_setup(char *str)
  49{
  50        if (!str)
  51                return -EINVAL;
  52
  53        if (!strcmp(str, "poll")) {
  54                pr_info("using polling idle threads.\n");
  55                cpu_idle_poll_ctrl(true);
  56                return 0;
  57        } else if (!strcmp(str, "halt")) {
  58                return 0;
  59        }
  60        return -1;
  61}
  62early_param("idle", idle_setup);
  63
  64void arch_cpu_idle(void)
  65{
  66        __get_cpu_var(irq_stat).idle_timestamp = jiffies;
  67        _cpu_idle();
  68}
  69
  70/*
  71 * Release a thread_info structure
  72 */
  73void arch_release_thread_info(struct thread_info *info)
  74{
  75        struct single_step_state *step_state = info->step_state;
  76
  77#ifdef CONFIG_HARDWALL
  78        /*
  79         * We free a thread_info from the context of the task that has
  80         * been scheduled next, so the original task is already dead.
  81         * Calling deactivate here just frees up the data structures.
  82         * If the task we're freeing held the last reference to a
  83         * hardwall fd, it would have been released prior to this point
  84         * anyway via exit_files(), and the hardwall_task.info pointers
  85         * would be NULL by now.
  86         */
  87        hardwall_deactivate_all(info->task);
  88#endif
  89
  90        if (step_state) {
  91
  92                /*
  93                 * FIXME: we don't munmap step_state->buffer
  94                 * because the mm_struct for this process (info->task->mm)
  95                 * has already been zeroed in exit_mm().  Keeping a
  96                 * reference to it here seems like a bad move, so this
  97                 * means we can't munmap() the buffer, and therefore if we
  98                 * ptrace multiple threads in a process, we will slowly
  99                 * leak user memory.  (Note that as soon as the last
 100                 * thread in a process dies, we will reclaim all user
 101                 * memory including single-step buffers in the usual way.)
 102                 * We should either assign a kernel VA to this buffer
 103                 * somehow, or we should associate the buffer(s) with the
 104                 * mm itself so we can clean them up that way.
 105                 */
 106                kfree(step_state);
 107        }
 108}
 109
 110static void save_arch_state(struct thread_struct *t);
 111
 112int copy_thread(unsigned long clone_flags, unsigned long sp,
 113                unsigned long arg, struct task_struct *p)
 114{
 115        struct pt_regs *childregs = task_pt_regs(p);
 116        unsigned long ksp;
 117        unsigned long *callee_regs;
 118
 119        /*
 120         * Set up the stack and stack pointer appropriately for the
 121         * new child to find itself woken up in __switch_to().
 122         * The callee-saved registers must be on the stack to be read;
 123         * the new task will then jump to assembly support to handle
 124         * calling schedule_tail(), etc., and (for userspace tasks)
 125         * returning to the context set up in the pt_regs.
 126         */
 127        ksp = (unsigned long) childregs;
 128        ksp -= C_ABI_SAVE_AREA_SIZE;   /* interrupt-entry save area */
 129        ((long *)ksp)[0] = ((long *)ksp)[1] = 0;
 130        ksp -= CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long);
 131        callee_regs = (unsigned long *)ksp;
 132        ksp -= C_ABI_SAVE_AREA_SIZE;   /* __switch_to() save area */
 133        ((long *)ksp)[0] = ((long *)ksp)[1] = 0;
 134        p->thread.ksp = ksp;
 135
 136        /* Record the pid of the task that created this one. */
 137        p->thread.creator_pid = current->pid;
 138
 139        if (unlikely(p->flags & PF_KTHREAD)) {
 140                /* kernel thread */
 141                memset(childregs, 0, sizeof(struct pt_regs));
 142                memset(&callee_regs[2], 0,
 143                       (CALLEE_SAVED_REGS_COUNT - 2) * sizeof(unsigned long));
 144                callee_regs[0] = sp;   /* r30 = function */
 145                callee_regs[1] = arg;  /* r31 = arg */
 146                childregs->ex1 = PL_ICS_EX1(KERNEL_PL, 0);
 147                p->thread.pc = (unsigned long) ret_from_kernel_thread;
 148                return 0;
 149        }
 150
 151        /*
 152         * Start new thread in ret_from_fork so it schedules properly
 153         * and then return from interrupt like the parent.
 154         */
 155        p->thread.pc = (unsigned long) ret_from_fork;
 156
 157        /*
 158         * Do not clone step state from the parent; each thread
 159         * must make its own lazily.
 160         */
 161        task_thread_info(p)->step_state = NULL;
 162
 163        /*
 164         * Copy the registers onto the kernel stack so the
 165         * return-from-interrupt code will reload it into registers.
 166         */
 167        *childregs = *current_pt_regs();
 168        childregs->regs[0] = 0;         /* return value is zero */
 169        if (sp)
 170                childregs->sp = sp;  /* override with new user stack pointer */
 171        memcpy(callee_regs, &childregs->regs[CALLEE_SAVED_FIRST_REG],
 172               CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long));
 173
 174        /* Save user stack top pointer so we can ID the stack vm area later. */
 175        p->thread.usp0 = childregs->sp;
 176
 177        /*
 178         * If CLONE_SETTLS is set, set "tp" in the new task to "r4",
 179         * which is passed in as arg #5 to sys_clone().
 180         */
 181        if (clone_flags & CLONE_SETTLS)
 182                childregs->tp = childregs->regs[4];
 183
 184
 185#if CHIP_HAS_TILE_DMA()
 186        /*
 187         * No DMA in the new thread.  We model this on the fact that
 188         * fork() clears the pending signals, alarms, and aio for the child.
 189         */
 190        memset(&p->thread.tile_dma_state, 0, sizeof(struct tile_dma_state));
 191        memset(&p->thread.dma_async_tlb, 0, sizeof(struct async_tlb));
 192#endif
 193
 194#if CHIP_HAS_SN_PROC()
 195        /* Likewise, the new thread is not running static processor code. */
 196        p->thread.sn_proc_running = 0;
 197        memset(&p->thread.sn_async_tlb, 0, sizeof(struct async_tlb));
 198#endif
 199
 200#if CHIP_HAS_PROC_STATUS_SPR()
 201        /* New thread has its miscellaneous processor state bits clear. */
 202        p->thread.proc_status = 0;
 203#endif
 204
 205#ifdef CONFIG_HARDWALL
 206        /* New thread does not own any networks. */
 207        memset(&p->thread.hardwall[0], 0,
 208               sizeof(struct hardwall_task) * HARDWALL_TYPES);
 209#endif
 210
 211
 212        /*
 213         * Start the new thread with the current architecture state
 214         * (user interrupt masks, etc.).
 215         */
 216        save_arch_state(&p->thread);
 217
 218        return 0;
 219}
 220
 221/*
 222 * Return "current" if it looks plausible, or else a pointer to a dummy.
 223 * This can be helpful if we are just trying to emit a clean panic.
 224 */
 225struct task_struct *validate_current(void)
 226{
 227        static struct task_struct corrupt = { .comm = "<corrupt>" };
 228        struct task_struct *tsk = current;
 229        if (unlikely((unsigned long)tsk < PAGE_OFFSET ||
 230                     (high_memory && (void *)tsk > high_memory) ||
 231                     ((unsigned long)tsk & (__alignof__(*tsk) - 1)) != 0)) {
 232                pr_err("Corrupt 'current' %p (sp %#lx)\n", tsk, stack_pointer);
 233                tsk = &corrupt;
 234        }
 235        return tsk;
 236}
 237
 238/* Take and return the pointer to the previous task, for schedule_tail(). */
 239struct task_struct *sim_notify_fork(struct task_struct *prev)
 240{
 241        struct task_struct *tsk = current;
 242        __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_FORK_PARENT |
 243                     (tsk->thread.creator_pid << _SIM_CONTROL_OPERATOR_BITS));
 244        __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_FORK |
 245                     (tsk->pid << _SIM_CONTROL_OPERATOR_BITS));
 246        return prev;
 247}
 248
 249int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
 250{
 251        struct pt_regs *ptregs = task_pt_regs(tsk);
 252        elf_core_copy_regs(regs, ptregs);
 253        return 1;
 254}
 255
 256#if CHIP_HAS_TILE_DMA()
 257
 258/* Allow user processes to access the DMA SPRs */
 259void grant_dma_mpls(void)
 260{
 261#if CONFIG_KERNEL_PL == 2
 262        __insn_mtspr(SPR_MPL_DMA_CPL_SET_1, 1);
 263        __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_1, 1);
 264#else
 265        __insn_mtspr(SPR_MPL_DMA_CPL_SET_0, 1);
 266        __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_0, 1);
 267#endif
 268}
 269
 270/* Forbid user processes from accessing the DMA SPRs */
 271void restrict_dma_mpls(void)
 272{
 273#if CONFIG_KERNEL_PL == 2
 274        __insn_mtspr(SPR_MPL_DMA_CPL_SET_2, 1);
 275        __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_2, 1);
 276#else
 277        __insn_mtspr(SPR_MPL_DMA_CPL_SET_1, 1);
 278        __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_1, 1);
 279#endif
 280}
 281
 282/* Pause the DMA engine, then save off its state registers. */
 283static void save_tile_dma_state(struct tile_dma_state *dma)
 284{
 285        unsigned long state = __insn_mfspr(SPR_DMA_USER_STATUS);
 286        unsigned long post_suspend_state;
 287
 288        /* If we're running, suspend the engine. */
 289        if ((state & DMA_STATUS_MASK) == SPR_DMA_STATUS__RUNNING_MASK)
 290                __insn_mtspr(SPR_DMA_CTR, SPR_DMA_CTR__SUSPEND_MASK);
 291
 292        /*
 293         * Wait for the engine to idle, then save regs.  Note that we
 294         * want to record the "running" bit from before suspension,
 295         * and the "done" bit from after, so that we can properly
 296         * distinguish a case where the user suspended the engine from
 297         * the case where the kernel suspended as part of the context
 298         * swap.
 299         */
 300        do {
 301                post_suspend_state = __insn_mfspr(SPR_DMA_USER_STATUS);
 302        } while (post_suspend_state & SPR_DMA_STATUS__BUSY_MASK);
 303
 304        dma->src = __insn_mfspr(SPR_DMA_SRC_ADDR);
 305        dma->src_chunk = __insn_mfspr(SPR_DMA_SRC_CHUNK_ADDR);
 306        dma->dest = __insn_mfspr(SPR_DMA_DST_ADDR);
 307        dma->dest_chunk = __insn_mfspr(SPR_DMA_DST_CHUNK_ADDR);
 308        dma->strides = __insn_mfspr(SPR_DMA_STRIDE);
 309        dma->chunk_size = __insn_mfspr(SPR_DMA_CHUNK_SIZE);
 310        dma->byte = __insn_mfspr(SPR_DMA_BYTE);
 311        dma->status = (state & SPR_DMA_STATUS__RUNNING_MASK) |
 312                (post_suspend_state & SPR_DMA_STATUS__DONE_MASK);
 313}
 314
 315/* Restart a DMA that was running before we were context-switched out. */
 316static void restore_tile_dma_state(struct thread_struct *t)
 317{
 318        const struct tile_dma_state *dma = &t->tile_dma_state;
 319
 320        /*
 321         * The only way to restore the done bit is to run a zero
 322         * length transaction.
 323         */
 324        if ((dma->status & SPR_DMA_STATUS__DONE_MASK) &&
 325            !(__insn_mfspr(SPR_DMA_USER_STATUS) & SPR_DMA_STATUS__DONE_MASK)) {
 326                __insn_mtspr(SPR_DMA_BYTE, 0);
 327                __insn_mtspr(SPR_DMA_CTR, SPR_DMA_CTR__REQUEST_MASK);
 328                while (__insn_mfspr(SPR_DMA_USER_STATUS) &
 329                       SPR_DMA_STATUS__BUSY_MASK)
 330                        ;
 331        }
 332
 333        __insn_mtspr(SPR_DMA_SRC_ADDR, dma->src);
 334        __insn_mtspr(SPR_DMA_SRC_CHUNK_ADDR, dma->src_chunk);
 335        __insn_mtspr(SPR_DMA_DST_ADDR, dma->dest);
 336        __insn_mtspr(SPR_DMA_DST_CHUNK_ADDR, dma->dest_chunk);
 337        __insn_mtspr(SPR_DMA_STRIDE, dma->strides);
 338        __insn_mtspr(SPR_DMA_CHUNK_SIZE, dma->chunk_size);
 339        __insn_mtspr(SPR_DMA_BYTE, dma->byte);
 340
 341        /*
 342         * Restart the engine if we were running and not done.
 343         * Clear a pending async DMA fault that we were waiting on return
 344         * to user space to execute, since we expect the DMA engine
 345         * to regenerate those faults for us now.  Note that we don't
 346         * try to clear the TIF_ASYNC_TLB flag, since it's relatively
 347         * harmless if set, and it covers both DMA and the SN processor.
 348         */
 349        if ((dma->status & DMA_STATUS_MASK) == SPR_DMA_STATUS__RUNNING_MASK) {
 350                t->dma_async_tlb.fault_num = 0;
 351                __insn_mtspr(SPR_DMA_CTR, SPR_DMA_CTR__REQUEST_MASK);
 352        }
 353}
 354
 355#endif
 356
 357static void save_arch_state(struct thread_struct *t)
 358{
 359#if CHIP_HAS_SPLIT_INTR_MASK()
 360        t->interrupt_mask = __insn_mfspr(SPR_INTERRUPT_MASK_0_0) |
 361                ((u64)__insn_mfspr(SPR_INTERRUPT_MASK_0_1) << 32);
 362#else
 363        t->interrupt_mask = __insn_mfspr(SPR_INTERRUPT_MASK_0);
 364#endif
 365        t->ex_context[0] = __insn_mfspr(SPR_EX_CONTEXT_0_0);
 366        t->ex_context[1] = __insn_mfspr(SPR_EX_CONTEXT_0_1);
 367        t->system_save[0] = __insn_mfspr(SPR_SYSTEM_SAVE_0_0);
 368        t->system_save[1] = __insn_mfspr(SPR_SYSTEM_SAVE_0_1);
 369        t->system_save[2] = __insn_mfspr(SPR_SYSTEM_SAVE_0_2);
 370        t->system_save[3] = __insn_mfspr(SPR_SYSTEM_SAVE_0_3);
 371        t->intctrl_0 = __insn_mfspr(SPR_INTCTRL_0_STATUS);
 372#if CHIP_HAS_PROC_STATUS_SPR()
 373        t->proc_status = __insn_mfspr(SPR_PROC_STATUS);
 374#endif
 375#if !CHIP_HAS_FIXED_INTVEC_BASE()
 376        t->interrupt_vector_base = __insn_mfspr(SPR_INTERRUPT_VECTOR_BASE_0);
 377#endif
 378#if CHIP_HAS_TILE_RTF_HWM()
 379        t->tile_rtf_hwm = __insn_mfspr(SPR_TILE_RTF_HWM);
 380#endif
 381#if CHIP_HAS_DSTREAM_PF()
 382        t->dstream_pf = __insn_mfspr(SPR_DSTREAM_PF);
 383#endif
 384}
 385
 386static void restore_arch_state(const struct thread_struct *t)
 387{
 388#if CHIP_HAS_SPLIT_INTR_MASK()
 389        __insn_mtspr(SPR_INTERRUPT_MASK_0_0, (u32) t->interrupt_mask);
 390        __insn_mtspr(SPR_INTERRUPT_MASK_0_1, t->interrupt_mask >> 32);
 391#else
 392        __insn_mtspr(SPR_INTERRUPT_MASK_0, t->interrupt_mask);
 393#endif
 394        __insn_mtspr(SPR_EX_CONTEXT_0_0, t->ex_context[0]);
 395        __insn_mtspr(SPR_EX_CONTEXT_0_1, t->ex_context[1]);
 396        __insn_mtspr(SPR_SYSTEM_SAVE_0_0, t->system_save[0]);
 397        __insn_mtspr(SPR_SYSTEM_SAVE_0_1, t->system_save[1]);
 398        __insn_mtspr(SPR_SYSTEM_SAVE_0_2, t->system_save[2]);
 399        __insn_mtspr(SPR_SYSTEM_SAVE_0_3, t->system_save[3]);
 400        __insn_mtspr(SPR_INTCTRL_0_STATUS, t->intctrl_0);
 401#if CHIP_HAS_PROC_STATUS_SPR()
 402        __insn_mtspr(SPR_PROC_STATUS, t->proc_status);
 403#endif
 404#if !CHIP_HAS_FIXED_INTVEC_BASE()
 405        __insn_mtspr(SPR_INTERRUPT_VECTOR_BASE_0, t->interrupt_vector_base);
 406#endif
 407#if CHIP_HAS_TILE_RTF_HWM()
 408        __insn_mtspr(SPR_TILE_RTF_HWM, t->tile_rtf_hwm);
 409#endif
 410#if CHIP_HAS_DSTREAM_PF()
 411        __insn_mtspr(SPR_DSTREAM_PF, t->dstream_pf);
 412#endif
 413}
 414
 415
 416void _prepare_arch_switch(struct task_struct *next)
 417{
 418#if CHIP_HAS_SN_PROC()
 419        int snctl;
 420#endif
 421#if CHIP_HAS_TILE_DMA()
 422        struct tile_dma_state *dma = &current->thread.tile_dma_state;
 423        if (dma->enabled)
 424                save_tile_dma_state(dma);
 425#endif
 426#if CHIP_HAS_SN_PROC()
 427        /*
 428         * Suspend the static network processor if it was running.
 429         * We do not suspend the fabric itself, just like we don't
 430         * try to suspend the UDN.
 431         */
 432        snctl = __insn_mfspr(SPR_SNCTL);
 433        current->thread.sn_proc_running =
 434                (snctl & SPR_SNCTL__FRZPROC_MASK) == 0;
 435        if (current->thread.sn_proc_running)
 436                __insn_mtspr(SPR_SNCTL, snctl | SPR_SNCTL__FRZPROC_MASK);
 437#endif
 438}
 439
 440
 441struct task_struct *__sched _switch_to(struct task_struct *prev,
 442                                       struct task_struct *next)
 443{
 444        /* DMA state is already saved; save off other arch state. */
 445        save_arch_state(&prev->thread);
 446
 447#if CHIP_HAS_TILE_DMA()
 448        /*
 449         * Restore DMA in new task if desired.
 450         * Note that it is only safe to restart here since interrupts
 451         * are disabled, so we can't take any DMATLB miss or access
 452         * interrupts before we have finished switching stacks.
 453         */
 454        if (next->thread.tile_dma_state.enabled) {
 455                restore_tile_dma_state(&next->thread);
 456                grant_dma_mpls();
 457        } else {
 458                restrict_dma_mpls();
 459        }
 460#endif
 461
 462        /* Restore other arch state. */
 463        restore_arch_state(&next->thread);
 464
 465#if CHIP_HAS_SN_PROC()
 466        /*
 467         * Restart static network processor in the new process
 468         * if it was running before.
 469         */
 470        if (next->thread.sn_proc_running) {
 471                int snctl = __insn_mfspr(SPR_SNCTL);
 472                __insn_mtspr(SPR_SNCTL, snctl & ~SPR_SNCTL__FRZPROC_MASK);
 473        }
 474#endif
 475
 476#ifdef CONFIG_HARDWALL
 477        /* Enable or disable access to the network registers appropriately. */
 478        hardwall_switch_tasks(prev, next);
 479#endif
 480
 481        /*
 482         * Switch kernel SP, PC, and callee-saved registers.
 483         * In the context of the new task, return the old task pointer
 484         * (i.e. the task that actually called __switch_to).
 485         * Pass the value to use for SYSTEM_SAVE_K_0 when we reset our sp.
 486         */
 487        return __switch_to(prev, next, next_current_ksp0(next));
 488}
 489
 490/*
 491 * This routine is called on return from interrupt if any of the
 492 * TIF_WORK_MASK flags are set in thread_info->flags.  It is
 493 * entered with interrupts disabled so we don't miss an event
 494 * that modified the thread_info flags.  If any flag is set, we
 495 * handle it and return, and the calling assembly code will
 496 * re-disable interrupts, reload the thread flags, and call back
 497 * if more flags need to be handled.
 498 *
 499 * We return whether we need to check the thread_info flags again
 500 * or not.  Note that we don't clear TIF_SINGLESTEP here, so it's
 501 * important that it be tested last, and then claim that we don't
 502 * need to recheck the flags.
 503 */
 504int do_work_pending(struct pt_regs *regs, u32 thread_info_flags)
 505{
 506        /* If we enter in kernel mode, do nothing and exit the caller loop. */
 507        if (!user_mode(regs))
 508                return 0;
 509
 510        /* Enable interrupts; they are disabled again on return to caller. */
 511        local_irq_enable();
 512
 513        if (thread_info_flags & _TIF_NEED_RESCHED) {
 514                schedule();
 515                return 1;
 516        }
 517#if CHIP_HAS_TILE_DMA() || CHIP_HAS_SN_PROC()
 518        if (thread_info_flags & _TIF_ASYNC_TLB) {
 519                do_async_page_fault(regs);
 520                return 1;
 521        }
 522#endif
 523        if (thread_info_flags & _TIF_SIGPENDING) {
 524                do_signal(regs);
 525                return 1;
 526        }
 527        if (thread_info_flags & _TIF_NOTIFY_RESUME) {
 528                clear_thread_flag(TIF_NOTIFY_RESUME);
 529                tracehook_notify_resume(regs);
 530                return 1;
 531        }
 532        if (thread_info_flags & _TIF_SINGLESTEP) {
 533                single_step_once(regs);
 534                return 0;
 535        }
 536        panic("work_pending: bad flags %#x\n", thread_info_flags);
 537}
 538
 539unsigned long get_wchan(struct task_struct *p)
 540{
 541        struct KBacktraceIterator kbt;
 542
 543        if (!p || p == current || p->state == TASK_RUNNING)
 544                return 0;
 545
 546        for (KBacktraceIterator_init(&kbt, p, NULL);
 547             !KBacktraceIterator_end(&kbt);
 548             KBacktraceIterator_next(&kbt)) {
 549                if (!in_sched_functions(kbt.it.pc))
 550                        return kbt.it.pc;
 551        }
 552
 553        return 0;
 554}
 555
 556/* Flush thread state. */
 557void flush_thread(void)
 558{
 559        /* Nothing */
 560}
 561
 562/*
 563 * Free current thread data structures etc..
 564 */
 565void exit_thread(void)
 566{
 567        /* Nothing */
 568}
 569
 570void show_regs(struct pt_regs *regs)
 571{
 572        struct task_struct *tsk = validate_current();
 573        int i;
 574
 575        pr_err("\n");
 576        show_regs_print_info(KERN_ERR);
 577#ifdef __tilegx__
 578        for (i = 0; i < 51; i += 3)
 579                pr_err(" r%-2d: "REGFMT" r%-2d: "REGFMT" r%-2d: "REGFMT"\n",
 580                       i, regs->regs[i], i+1, regs->regs[i+1],
 581                       i+2, regs->regs[i+2]);
 582        pr_err(" r51: "REGFMT" r52: "REGFMT" tp : "REGFMT"\n",
 583               regs->regs[51], regs->regs[52], regs->tp);
 584        pr_err(" sp : "REGFMT" lr : "REGFMT"\n", regs->sp, regs->lr);
 585#else
 586        for (i = 0; i < 52; i += 4)
 587                pr_err(" r%-2d: "REGFMT" r%-2d: "REGFMT
 588                       " r%-2d: "REGFMT" r%-2d: "REGFMT"\n",
 589                       i, regs->regs[i], i+1, regs->regs[i+1],
 590                       i+2, regs->regs[i+2], i+3, regs->regs[i+3]);
 591        pr_err(" r52: "REGFMT" tp : "REGFMT" sp : "REGFMT" lr : "REGFMT"\n",
 592               regs->regs[52], regs->tp, regs->sp, regs->lr);
 593#endif
 594        pr_err(" pc : "REGFMT" ex1: %ld     faultnum: %ld\n",
 595               regs->pc, regs->ex1, regs->faultnum);
 596
 597        dump_stack_regs(regs);
 598}
 599