Skip to contentSkip to conversation

kmemcheck: support for x86_64

PATCH In review Vegard Nossum 2 participants 3 messages May 17, 2008 – May 18, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kmemcheck: support for x86_64

Hi,

Here comes a particularly difficult patch. I am not submitting it for application to any tree yet, but I have a small hope that somebody will put their head out to look at it :-)

I am fairly sure the REX handling bits themselves are okay -- the kernel gets to the point where it tries to mount the root partition. But before that, there is a torrent of error reports coming from kmemcheck.

Most of them look something like this:

kmemcheck: Caught 8-bit read from freed memory (ffff81000780a904) ifffffffifffffffifffffffifffffffifffffffifffffffifffffffifffffff

    ^

and my theory so far is that X86_64 uses some currently unhandled instruction set extensions like MMX, SSE, etc. (Not 3DNow! because we have a dependency for that), for a fairly common operation -- something like memset(), and where we decode the size of the instruction to being 8 bits when in fact it is 64 and thus only mark 8 bits of the shadow memory as being initialized.

(I guess the easiest way to catch this would be to make cases for those instructions and WARN(), but... Did I mention I hate this opcode decoding business? It's just too ugly.)

Do the #ifdef X86_64 parts look okay?

The patch applies to the 'current' branch of kmemcheck.git:
http://git.kernel.org/?p=linux/kernel/git/vegard/kmemcheck.git;a=shortlog;h=current

Note: kmemcheck reports from x86_64 are still not very good because of the stacktrace issues reported earlier; in short, we can't look further than the page fault stack entry, which makes it rather useless for debugging. We do still have the RIP of the crash, though. End of note.

Thanks.

Vegard

Quoted 1 line

From d7978af9df6e61b75f1d15a65cf455b89aafea08 Mon Sep 17 00:00:00 2001

From: Vegard Nossum <[email protected]>
Date: Sun, 11 May 2008 14:06:49 +0200
Subject: [PATCH] kmemcheck: support for x86_64

Add REX prefix handling to kmemcheck's opcode decoder.

---
 arch/x86/Kconfig.debug      |    2 +-
 arch/x86/kernel/kmemcheck.c |   67 ++++++++++++++++++++++++++++++++++--------
 2 files changed, 55 insertions(+), 14 deletions(-)
arch/x86/Kconfig.debug +1 -1
index af6c1b3..8f02410 100644
@@ -244,7 +244,7 @@ endif
 
 config KMEMCHECK
 	bool "kmemcheck: trap use of uninitialized memory"
-	depends on X86_32
+	depends on X86
 	depends on !X86_USE_3DNOW
 	depends on SLUB || SLAB
 	depends on !CC_OPTIMIZE_FOR_SIZE
arch/x86/kernel/kmemcheck.c +54 -13

113 lines not on this page · raw message

Signature · 1 line
1.5.4.1
#1 lore raw
Quoted 10 lines

Most of them look something like this:

kmemcheck: Caught 8-bit read from freed memory (ffff81000780a904) ifffffffifffffffifffffffifffffffifffffffifffffffifffffffifffffff

    ^

and my theory so far is that X86_64 uses some currently unhandled instruction set extensions like MMX, SSE, etc. (Not 3DNow! because we have a dependency for that), for a fairly common operation

No it shouldn't. Only SSE users are in the (broken) MD RAID code

Most likely you don't decode REX correctly in some cases.

[haven't read the patch sorry]

=Andi

#2 lore raw
Quoted 7 lines · Andi Kleen
Quoted 7 lines

Most of them look something like this:

kmemcheck: Caught 8-bit read from freed memory (ffff81000780a904) ifffffffifffffffifffffffifffffffifffffffifffffffifffffffifffffff

    ^
Quoted 7 lines
Quoted 3 lines

and my theory so far is that X86_64 uses some currently unhandled instruction set extensions like MMX, SSE, etc. (Not 3DNow! because we have a dependency for that), for a fairly common operation

No it shouldn't. Only SSE users are in the (broken) MD RAID code

Most likely you don't decode REX correctly in some cases.

Thanks. You are right, but you are wrong.

All those #ifdef X86_64 should of course be CONFIG_X86_64... So none of the 64-bit code was being compiled in. Good spotting, Vegard! :-(

Vegard

Signature · 4 lines
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036