patch-2.4.18 linux/arch/s390x/kernel/process.c
Next file: linux/arch/s390x/kernel/ptrace.c
Previous file: linux/arch/s390x/kernel/linux32.c
Back to the patch index
Back to the overall index
- Lines: 201
- Date:
Fri Dec 21 16:25:30 2001
- Orig file:
linux.orig/arch/s390x/kernel/process.c
- Orig date:
Mon Feb 18 20:18:39 2002
diff -Naur -X /home/marcelo/lib/dontdiff linux.orig/arch/s390x/kernel/process.c linux/arch/s390x/kernel/process.c
@@ -75,171 +75,22 @@
}
}
-/*
- As all the register will only be made displayable to the root
- user ( via printk ) or checking if the uid of the user is 0 from
- the /proc filesystem please god this will be secure enough DJB.
- The lines are given one at a time so as not to chew stack space in
- printk on a crash & also for the proc filesystem when you get
- 0 returned you know you've got all the lines
- */
-
-static int sprintf_regs(int line, char *buff, struct task_struct *task, struct pt_regs *regs)
-{
- int linelen=0;
- int regno,chaincnt;
- u64 backchain,prev_backchain,endchain;
- u64 ksp = 0;
- char *mode = "???";
-
- enum
- {
- sp_linefeed,
- sp_psw,
- sp_ksp,
- sp_gprs,
- sp_gprs1,
- sp_gprs2,
- sp_gprs3,
- sp_gprs4,
- sp_gprs5,
- sp_gprs6,
- sp_gprs7,
- sp_gprs8,
- sp_acrs,
- sp_acrs1,
- sp_acrs2,
- sp_acrs3,
- sp_acrs4,
- sp_kern_backchain,
- sp_kern_backchain1
- };
-
- if (task)
- ksp = task->thread.ksp;
- if (regs && !(regs->psw.mask & PSW_PROBLEM_STATE))
- ksp = regs->gprs[15];
-
- if (regs)
- mode = (regs->psw.mask & PSW_PROBLEM_STATE)?
- "User" : "Kernel";
-
- switch(line)
- {
- case sp_linefeed:
- linelen=sprintf(buff,"\n");
- break;
- case sp_psw:
- if(regs)
- linelen=sprintf(buff, "%s PSW: %016lx %016lx %s\n", mode,
- (unsigned long) regs->psw.mask,
- (unsigned long) regs->psw.addr,
- print_tainted());
- else
- linelen=sprintf(buff,"pt_regs=NULL some info unavailable\n");
- break;
- case sp_ksp:
- linelen=sprintf(&buff[linelen],
- "task: %016lx ksp: %016lx pt_regs: %016lx\n",
- (addr_t)task, (addr_t)ksp, (addr_t)regs);
- break;
- case sp_gprs:
- if(regs)
- linelen=sprintf(buff, "%s GPRS:\n", mode);
- break;
- case sp_gprs1 ... sp_gprs8:
- if(regs)
- {
- regno=(line-sp_gprs1)*2;
- linelen = sprintf(buff,"%016lx %016lx\n",
- regs->gprs[regno],
- regs->gprs[regno+1]);
- }
- break;
- case sp_acrs:
- if(regs)
- linelen=sprintf(buff, "%s ACRS:\n", mode);
- break;
- case sp_acrs1 ... sp_acrs4:
- if(regs)
- {
- regno=(line-sp_acrs1)*4;
- linelen=sprintf(buff,"%08x %08x %08x %08x\n",
- regs->acrs[regno],
- regs->acrs[regno+1],
- regs->acrs[regno+2],
- regs->acrs[regno+3]);
- }
- break;
- case sp_kern_backchain:
- if (regs && (regs->psw.mask & PSW_PROBLEM_STATE))
- break;
- if (ksp)
- linelen=sprintf(buff, "Kernel BackChain CallChain\n");
- break;
- default:
- if (ksp)
- {
-
- backchain=ksp&PSW_ADDR_MASK;
- endchain=((backchain&(-THREAD_SIZE))+THREAD_SIZE);
- prev_backchain=backchain-1;
- line-=sp_kern_backchain1;
- for(chaincnt=0;;chaincnt++)
- {
- if((backchain==0)||(backchain>=endchain)
- ||(chaincnt>=8)||(prev_backchain>=backchain))
- break;
- if(chaincnt==line)
- {
- linelen+=sprintf(&buff[linelen]," %016lx [<%016lx>]\n",
- backchain,
- *(u64 *)(backchain+112)&PSW_ADDR_MASK);
- break;
- }
- prev_backchain=backchain;
- backchain=(*((u64 *)backchain))&PSW_ADDR_MASK;
- }
- }
- }
- return(linelen);
-}
+extern void show_registers(struct pt_regs *regs);
+extern void show_trace(unsigned long *sp);
void show_regs(struct pt_regs *regs)
{
- char buff[80];
- int i, line;
-
- printk("CPU: %d\n",smp_processor_id());
- printk("Process %s (pid: %d, stackpage=%016lX)\n",
- current->comm, current->pid, 4096+(addr_t)current);
-
- for (line = 0; sprintf_regs(line, buff, current, regs); line++)
- printk(buff);
-
- if (regs->psw.mask & PSW_PROBLEM_STATE)
- {
- printk("User Code:\n");
- memset(buff, 0, 20);
- copy_from_user(buff,
- (char *) (regs->psw.addr & PSW_ADDR_MASK), 20);
- for (i = 0; i < 20; i++)
- printk("%02x ", buff[i]);
- printk("\n");
- }
-}
-
-char *task_show_regs(struct task_struct *task, char *buffer)
-{
- int line, len;
+ struct task_struct *tsk = current;
- for (line = 0; ; line++)
- {
- len = sprintf_regs(line, buffer, task, NULL);
- if (!len) break;
- buffer += len;
- }
- return buffer;
+ printk("CPU: %d %s\n", tsk->processor, print_tainted());
+ printk("Process %s (pid: %d, task: %016lx, ksp: %016lx)\n",
+ current->comm, current->pid, (unsigned long) tsk,
+ tsk->thread.ksp);
+
+ show_registers(regs);
+ /* Show stack backtrace if pt_regs is from kernel mode */
+ if (!(regs->psw.mask & PSW_PROBLEM_STATE))
+ show_trace((unsigned long *) regs->gprs[15]);
}
int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
@@ -301,16 +152,10 @@
unsigned long gprs[10]; /* gprs 6 -15 */
unsigned long fprs[2]; /* fpr 4 and 6 */
unsigned long empty[2];
-#if CONFIG_REMOTE_DEBUG
- struct gdb_pt_regs childregs;
-#else
struct pt_regs childregs;
-#endif
} *frame;
frame = (struct stack_frame *) (4*PAGE_SIZE + (unsigned long) p) -1;
- frame = (struct stack_frame *) (((unsigned long) frame)&-8L);
- p->thread.regs = &frame->childregs;
p->thread.ksp = (unsigned long) frame;
frame->childregs = *regs;
frame->childregs.gprs[15] = new_stackp;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)