2.6 PPC64 Re: rtas_call uses kmalloc before the memory subsystem is up
A message that is not in the archive (sent off-list or not yet received): 20040815221951.GK5637@krispykreme
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 2.6 PPC64 Re: rtas_call uses kmalloc before the memory subsystem is up
Hi Paul,
Can you approve & forward one of the two the patches to AKPM for inclusion
in the next kernel as soon as possible? This is now the fifth or sixth
report of someone getting bitten by this, and this *really* should be in the mainline tree. (We really need a way of expediting patches when they're critical & everyone hits them.)
On Mon, Aug 16, 2004 at 03:18:19PM +1000, Paul Mackerras was heard to remark:
Quoted 7 lines
Quoted 2 lines · Anton Blanchard
rtas_callis doing a kmalloc before the memory subsystem is up, but only when we hit an error.This is a quick-n-dirty hack to fix the problem. It's not completely obvious what the proper solution looks like, unfortunately.
Actually, I think the patch below *is* the proper solution. Its nearly identical to the old patches, with one important improvement: it also works when mem subsytem is not yet up. Here's why:
-- the kmalloc is needed in the full multi-tasking environment, because
the rtas code can be triggered at any time (on any cpu).
-- if mem subsystem is not yet up (no kmalloc yet) then the kernel won't
be running multi-tasked yet, anyway, so races that clobber the buffer won't occur.
So I think we're free & clear here; this is not only a solution, its the best solution.
--linas
Quoted 30 lines
diff -urN
linux-2.5/arch/ppc64/kernel/rtas.ctest25/arch/ppc64/kernel/rtas.carch/ppc64/kernel/rtas.c +8
-4@@ -165,9 +165,12 @@/* Log the error in the unlikely case that there was one. */ if (unlikely (logit)) { - buff_copy =kmalloc (RTAS_ERROR_LOG_MAX ,GFP_ATOMIC ); -if (buff_copy) { -memcpy (buff_copy, rtas_err_buf,RTAS_ERROR_LOG_MAX ); + buff_copy = rtas_err_buf; +if (mem_init_done) { + buff_copy =kmalloc (RTAS_ERROR_LOG_MAX ,GFP_ATOMIC ); +if (buff_copy) +memcpy (buff_copy, rtas_err_buf, +RTAS_ERROR_LOG_MAX ); } }@@ -176,7 +179,8 @@if (buff_copy) {log_error (buff_copy,ERR_TYPE_RTAS_LOG ,0 ); -kfree (buff_copy); +if (mem_init_done) +kfree (buff_copy); }return ret; }