mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roberto Nibali <ratz@drugphish.ch>
To: linux-kernel@vger.kernel.org
Cc: ak@suse.de, discuss@x86-64.org
Subject: trap int3 problem while porting a user space application and small cleanup patch
Date: Sun, 12 Feb 2006 18:08:13 +0100	[thread overview]
Message-ID: <43EF6B7D.5080607@drugphish.ch> (raw)

[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]

Hello,

For a while I've been working on a little tool called mpt-status to be 
able to monitor LSI based controllers. The source can be found here:

     http://www.drugphish.ch/~ratz/mpt-status/

The issue I'm trying to track down now is why I cannot get it to work on 
a x86_64 kernel (Sun Fire V20z with AMD Opteron(tm) Processor 252 on 
SLES 9 PL3). I suspect 32/64 bit issues between in my ioctl message 
passing between user space and kernel space. Unfortunately when I strace 
the kernel spits out tons of following entries:

mpt-status[16045] trap int3 rip:400acf rsp:7fbfff70b0 error:0
mpt-status[16045] trap int3 rip:4008f1 rsp:7fbfff70a8 error:0
mpt-status[16045] trap int3 rip:400b86 rsp:7fbfff70b0 error:0

I can only remotely guess what happened because I'm not sound on x64 
trap handling, so my question is: How can I best debug and address this 
issue in my tool?

I'm pretty sure it has something to do with me including kernel headers 
in a user space tool, but noone has done the sanitizing for the LSI 
related headers residing in drivers/message/fusion. It works on all 
32-bit machines I've tested so far.

Attached is a small code style cleanup patch that resulted from my 
skimming through the arch/x86_64/kernel/traps.c code to figure out what 
went haywire. If Andi is ok with it, please consider applying.

Signed-off-by: Roberto Nibali <ratz@drugphish.ch>

Best regards,
Roberto Nibali, ratz
-- 
echo 
'[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq' | dc

[-- Attachment #2: x86_64_kernel_traps_cleanup-1.diff --]
[-- Type: text/x-patch, Size: 1862 bytes --]

diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index ee1b2da..3442a56 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -108,7 +108,7 @@ int printk_address(unsigned long address
 	if (!modname) 
 		modname = delim = ""; 		
         return printk("<%016lx>{%s%s%s%s%+ld}",
-		      address,delim,modname,delim,symname,offset); 
+		      address, delim, modname, delim, symname, offset); 
 } 
 #else
 int printk_address(unsigned long address)
@@ -320,13 +320,12 @@ void show_registers(struct pt_regs *regs
 		show_stack(NULL, (unsigned long*)rsp);
 
 		printk("\nCode: ");
-		if(regs->rip < PAGE_OFFSET)
+		if (regs->rip < PAGE_OFFSET)
 			goto bad;
 
-		for(i=0;i<20;i++)
-		{
+		for (i=0; i<20; i++) {
 			unsigned char c;
-			if(__get_user(c, &((unsigned char*)regs->rip)[i])) {
+			if (__get_user(c, &((unsigned char*)regs->rip)[i])) {
 bad:
 				printk(" Bad RIP value.");
 				break;
@@ -465,7 +464,7 @@ static void __kprobes do_trap(int trapnr
 			printk(KERN_INFO
 			       "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
 			       tsk->comm, tsk->pid, str,
-			       regs->rip,regs->rsp,error_code); 
+			       regs->rip, regs->rsp, error_code); 
 
 		if (info)
 			force_sig_info(signr, info, tsk);
@@ -479,9 +478,9 @@ static void __kprobes do_trap(int trapnr
 	{	     
 		const struct exception_table_entry *fixup;
 		fixup = search_exception_tables(regs->rip);
-		if (fixup) {
+		if (fixup)
 			regs->rip = fixup->fixup;
-		} else	
+		else	
 			die(str, regs, error_code);
 		return;
 	}
@@ -554,7 +553,7 @@ asmlinkage void __kprobes do_general_pro
 			printk(KERN_INFO
 		       "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
 			       tsk->comm, tsk->pid,
-			       regs->rip,regs->rsp,error_code); 
+			       regs->rip, regs->rsp, error_code); 
 
 		force_sig(SIGSEGV, tsk);
 		return;

             reply	other threads:[~2006-02-12 17:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-12 17:08 Roberto Nibali [this message]
2006-02-13  0:57 ` [discuss] " Andi Kleen
2006-02-13  7:55   ` Roberto Nibali
2006-02-13  9:25     ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43EF6B7D.5080607@drugphish.ch \
    --to=ratz@drugphish.ch \
    --cc=ak@suse.de \
    --cc=discuss@x86-64.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome