Skip to contentSkip to conversation

Lguest32 print hex on bad reads and writes

PATCH In review Steven Rostedt 4 participants 7 messages Apr 4, 2007 – Apr 5, 2007 virtio core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Lguest32 print hex on bad reads and writes

Currently the lguest32 error messages from bad reads and writes prints a decimal integer for addresses. This is pretty annoying. So this patch changes those to be hex outputs.

This is applied on top of my debug patch.

drivers/lguest/core.c +6 -6
Index: linux-2.6.21-rc5-mm2/drivers/lguest/core.c
===================================================================
@@ -220,7 +220,7 @@ u8 lgread_u8(struct lguest *lg, u32 addr
 	/* Don't let them access lguest binary */
 	if (!lguest_address_ok(lg, addr)
 	    || get_user(val, (u32 __user *)addr) != 0)
-		kill_guest(lg, "bad read address %u", addr);
+		kill_guest(lg, "bad read address %x", addr);
 	return val;
 }
 
@@ -231,7 +231,7 @@ u16 lgread_u16(struct lguest *lg, u32 ad
 	/* Don't let them access lguest binary */
 	if (!lguest_address_ok(lg, addr)
 	    || get_user(val, (u32 __user *)addr) != 0)
-		kill_guest(lg, "bad read address %u", addr);
+		kill_guest(lg, "bad read address %x", addr);
 	return val;
 }
 
@@ -242,7 +242,7 @@ u32 lgread_u32(struct lguest *lg, u32 ad
 	/* Don't let them access lguest binary */
 	if (!lguest_address_ok(lg, addr)
 	    || get_user(val, (u32 __user *)addr) != 0)
-		kill_guest(lg, "bad read address %u", addr);
+		kill_guest(lg, "bad read address %x", addr);
 	return val;
 }
 
@@ -250,7 +250,7 @@ void lgwrite_u32(struct lguest *lg, u32 
 {
 	if (!lguest_address_ok(lg, addr)
 	    || put_user(val, (u32 __user *)addr) != 0)
-		kill_guest(lg, "bad write address %u", addr);
+		kill_guest(lg, "bad write address %x", addr);
 }
 
 void lgread(struct lguest *lg, void *b, u32 addr, unsigned bytes)
@@ -259,7 +259,7 @@ void lgread(struct lguest *lg, void *b, 
 	    || copy_from_user(b, (void __user *)addr, bytes) != 0) {
 		/* copy_from_user should do this, but as we rely on it... */
 		memset(b, 0, bytes);
-		kill_guest(lg, "bad read address %u len %u", addr, bytes);
+		kill_guest(lg, "bad read address %x len %u", addr, bytes);
 	}
 }
 
@@ -268,7 +268,7 @@ void lgwrite(struct lguest *lg, u32 addr
 	if (addr + bytes < addr
 	    || !lguest_address_ok(lg, addr+bytes)
 	    || copy_to_user((void __user *)addr, b, bytes) != 0)
-		kill_guest(lg, "bad write address %u len %u", addr, bytes);
+		kill_guest(lg, "bad write address %x len %u", addr, bytes);
 }
 
 static void set_ts(unsigned int guest_ts)
#1 lore raw
Quoted 3 lines · Steven Rostedt

Currently the lguest32 error messages from bad reads and writes prints a decimal integer for addresses. This is pretty annoying. So this patch changes those to be hex outputs.

(Erk, I wonder what I was thinking when I wrote that?)

Can I ask for %#x (or 0x%x)? I'm easily confused.

Thanks!
Rusty.

#2 lore raw
Quoted 7 lines · Rusty Russell
Quoted 3 lines · Steven Rostedt

Currently the lguest32 error messages from bad reads and writes prints a decimal integer for addresses. This is pretty annoying. So this patch changes those to be hex outputs.

(Erk, I wonder what I was thinking when I wrote that?) Can I ask for %#x (or 0x%x)? I'm easily confused.

How about "%p" for pointers?

Cheers,
Kyle Moffett

#3 lore raw
Quoted 4 lines · Kyle Moffett
Quoted 2 lines

(Erk, I wonder what I was thinking when I wrote that?) Can I ask for %#x (or 0x%x)? I'm easily confused.

How about "%p" for pointers?

But that would require casting the numbers to pointers.

-- Steve

#4 lore raw
Quoted 8 lines · Steven Rostedt
Quoted 4 lines · Kyle Moffett
Quoted 2 lines

(Erk, I wonder what I was thinking when I wrote that?) Can I ask for %#x (or 0x%x)? I'm easily confused.

How about "%p" for pointers?

But that would require casting the numbers to pointers.

And the kernel's printk doesn't put 0x on pointers anyway, last I checked 8(

Rusty.

#5 lore raw
Quoted 10 lines · Rusty Russell
Quoted 5 lines · Steven Rostedt
Quoted 2 lines · Kyle Moffett
Quoted 1 line

(Erk, I wonder what I was thinking when I wrote that?) Can I ask for %#x (or 0x%x)? I'm easily confused.

How about "%p" for pointers?

But that would require casting the numbers to pointers.

And the kernel's printk doesn't put 0x on pointers anyway, last I checked 8(

That's really the bug. Let's fix it.

-hpa

#6 lore raw
Quoted 8 lines · H. Peter Anvin
Quoted 7 lines · Rusty Russell
Quoted 5 lines · Steven Rostedt
Quoted 2 lines · Kyle Moffett
Quoted 1 line

(Erk, I wonder what I was thinking when I wrote that?) Can I ask for %#x (or 0x%x)? I'm easily confused.

How about "%p" for pointers?

But that would require casting the numbers to pointers.

Quoted 7 lines
Quoted 3 lines

And the kernel's printk doesn't put 0x on pointers anyway, last I checked 8(

That's really the bug. Let's fix it.

-hpa

Okay, git tree at:

http://git.kernel.org/?p=linux/kernel/git/hpa/linux-2.6-printk.git;a=summary
git://git.kernel.org/pub/scm/linux/kernel/git/hpa/linux-2.6-printk.git

... will do actual testing and post it to LKML tomorrow.

-hpa