{"id":393,"date":"2008-10-20T09:45:00","date_gmt":"2008-10-20T01:45:00","guid":{"rendered":"http:\/\/www.akuadi.org\/?p=119"},"modified":"2008-10-20T09:45:00","modified_gmt":"2008-10-20T01:45:00","slug":"solution-for-e1000e","status":"publish","type":"post","link":"https:\/\/akuadi.org\/life\/blog\/2008\/10\/20\/solution-for-e1000e\/","title":{"rendered":"Solution for e1000e"},"content":{"rendered":"<p>Remember on my previous post regarding the <a href=\"http:\/\/hackers125.blogspot.com\/2008\/09\/warning-for-e1000e-driver.html\" target=\"_blank\" rel=\"noopener\">e1000e<\/a> driver on linux  the solution is disable the CONFIG_DYNAMIC_FTRACE. I got the info from <a href=\"http:\/\/lkml.org\/\" target=\"_blank\" rel=\"noopener\">LKML<\/a> i hope that later no more problem like this because it will break all the hardware.  Here i cut out the articles that post by Steven Rostedt<\/p>\n<p><\/p>\n<pre><blockquote>While debugging the e1000e corruption bug with Intel, we discovered<br \/>today that the dynamic ftrace code in mainline is the likely source of<br \/>this bug.<br \/><br \/>For the stable kernel we are providing the only viable fix patch: labeling<br \/>CONFIG_DYNAMIC_FTRACE as broken. (see the patch below)<br \/><br \/>We will follow up with a backport patch that contains the fixes. But since<br \/>the fixes are not a one liner, the safest approach for now is to<br \/>disable the code in question.<br \/><br \/>The cause of the bug is due to the way the current code in mainline<br \/>handles dynamic ftrace.  When dynamic ftrace is turned on, it also<br \/>turns on CONFIG_FTRACE which enables the -pg config in gcc that places<br \/>a call to mcount at every function call. With just CONFIG_FTRACE this<br \/>causes a noticeable overhead.  CONFIG_DYNAMIC_FTRACE works to ease this<br \/>overhead by dynamically updating the mcount call sites into nops.<br \/><br \/>The problem arises when we trace functions and modules are unloaded.<br \/>The first time a function is called, it will call mcount and the mcount<br \/>call will call ftrace_record_ip. This records the calling site and<br \/>stores it in a preallocated hash table. Later on a daemon will<br \/>wake up and call kstop_machine and convert any mcount callers into<br \/>nops.<br \/><br \/>The evolution of this code first tried to do this without the kstop_machine<br \/>and used cmpxchg to update the callers as they were called. But I<br \/>was informed that this is dangerous to do on SMP machines if another<br \/>CPU is running that same code. The solution was to do this with<br \/>kstop_machine.<br \/><br \/>We still used cmpxchg to test if the code that we are modifying is<br \/>indeed code that we expect to be before updating it - as a final<br \/>line of defense.<br \/><br \/>But on 32bit machines, ioremapped memory and modules share the same<br \/>address space. When a module would load its code into memory and execute<br \/>some code, that would register the function.<br \/><br \/>On module unload, ftrace incorrectly did not zap these functions from<br \/>its hash (this was the bug). The cmpxchg could have saved us in most<br \/>cases (via luck) - but with ioremap-ed memory that was exactly the wrong<br \/>thing to do - the results of cmpxchg on device memory are undefined.<br \/>(and will likely result in a write)<br \/><br \/>The pending .28 ftrace tree does not have this bug anymore, as a general push<br \/>towards more robustness of code patching, this is done differently: we do not<br \/>use cmpxchg and we do a WARN_ON and turn the tracer off if anything deviates<br \/>from its expected state. Furthermore, patch sites are statically identified<br \/>during build time so there's no runtime discovery of dynamic code areas<br \/>anymore, and no room for code unmaps to cause the hash to become out of date.<br \/><br \/>We believe the fragility of dynamic patching has been sufficiently<br \/>addressed in the development code via the static patching method, but further<br \/>suggestions to make it more robust are welcome.<br \/><br \/>Signed-off-by: Steven Rostedt <srostedt@goodmis.org><br \/>Acked-by: Ingo Molnar <mingo@elte.hu><br \/>Acked-by: Thomas Gleixner <tglx@linutronix.de><br \/>---<br \/>kernel\/trace\/Kconfig |    3 ++-<br \/>1 file changed, 2 insertions(+), 1 deletion(-)<br \/>Index: linux-compile.git\/kernel\/trace\/Kconfig<br \/>===================================================================<br \/>--- linux-compile.git.orig\/kernel\/trace\/Kconfig 2008-10-02 10:18:49.000000000 -0400<br \/>+++ linux-compile.git\/kernel\/trace\/Kconfig 2008-10-15 17:29:34.000000000 -0400<br \/>@@ -103,7 +103,8 @@ config CONTEXT_SWITCH_TRACER<br \/> all switching of tasks.<br \/><br \/>config DYNAMIC_FTRACE<br \/>- bool \"enable\/disable ftrace tracepoints dynamically\"<br \/>+ bool \"enable\/disable ftrace tracepoints dynamically (BROKEN)\"<br \/>+ depends on BROKEN<br \/>depends on FTRACE<br \/>depends on HAVE_DYNAMIC_FTRACE<br \/>default y<\/tglx@linutronix.de><\/mingo@elte.hu><\/srostedt@goodmis.org><\/blockquote><br \/><br \/><br \/><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Remember on my previous post regarding the e1000e driver on linux the solution is disable the CONFIG_DYNAMIC_FTRACE. I got the info from LKML i hope that later no more problem like this because it will break all the hardware. Here i cut out the articles that post by Steven Rostedt While debugging the e1000e corruption [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,27,34,12,43],"tags":[],"class_list":["post-393","post","type-post","status-publish","format-standard","hentry","category-hardware","category-hardware-server","category-intel","category-linux","category-unix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/akuadi.org\/life\/wp-json\/wp\/v2\/posts\/393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/akuadi.org\/life\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/akuadi.org\/life\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/akuadi.org\/life\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/akuadi.org\/life\/wp-json\/wp\/v2\/comments?post=393"}],"version-history":[{"count":0,"href":"https:\/\/akuadi.org\/life\/wp-json\/wp\/v2\/posts\/393\/revisions"}],"wp:attachment":[{"href":"https:\/\/akuadi.org\/life\/wp-json\/wp\/v2\/media?parent=393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/akuadi.org\/life\/wp-json\/wp\/v2\/categories?post=393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/akuadi.org\/life\/wp-json\/wp\/v2\/tags?post=393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}