From patchwork Wed Sep 5 01:08:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 181711 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 642E82C03AE for ; Wed, 5 Sep 2012 11:09:12 +1000 (EST) Received: by ozlabs.org (Postfix) id B53412C0098; Wed, 5 Sep 2012 11:08:48 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1C12A2C0095 for ; Wed, 5 Sep 2012 11:08:47 +1000 (EST) Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id q8518TdP032278; Tue, 4 Sep 2012 20:08:30 -0500 Message-ID: <1346807308.2257.14.camel@pasglop> Subject: Re: 3.5+: yaboot, Invalid memory access From: Benjamin Herrenschmidt To: Christian Kujau Date: Wed, 05 Sep 2012 11:08:28 +1000 In-Reply-To: References: <1346741491.7619.12.camel@concordia> X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Cc: linuxppc-dev@ozlabs.org, Steven Rostedt X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, 2012-09-04 at 02:32 -0700, Christian Kujau wrote: > On Tue, 4 Sep 2012 at 16:51, Michael Ellerman wrote: > > My guess would be we're calling that quite early and the __put_user() > > check is getting confused and failing. That means we'll have left some > > code unpatched, which then fails. > > > > Can you try with the patch applied, but instead of returning if the > > __put_user() fails, just continue on anyway. > > You mean, like this? Try this: powerpc: Don't use __put_user() in patch_instruction patch_instruction() can be called very early on ppc32, when the kernel isn't yet running at it's linked address. That can cause the ! is_kernel_addr() test in __put_user() to trip and call might_sleep() which is very bad at that point during boot. Use a lower level function instead for now, at least until we get to rework ppc32 boot process to do the code patching later, like ppc64 does. Signed-off-by: Benjamin Herrenschmidt diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index dd223b3..17e5b23 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c @@ -20,7 +20,7 @@ int patch_instruction(unsigned int *addr, unsigned int instr) { int err; - err = __put_user(instr, addr); + __put_user_size(instr, addr, 4, err); if (err) return err; asm ("dcbst 0, %0; sync; icbi 0,%0; sync; isync" : : "r" (addr));