From patchwork Tue Dec 4 03:05:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jimi Xenidis X-Patchwork-Id: 203539 X-Patchwork-Delegate: benh@kernel.crashing.org 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 8E7172C034C for ; Tue, 4 Dec 2012 14:06:16 +1100 (EST) Received: from mail-ob0-f179.google.com (mail-ob0-f179.google.com [209.85.214.179]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 67B1E2C008F for ; Tue, 4 Dec 2012 14:05:52 +1100 (EST) Received: by mail-ob0-f179.google.com with SMTP id x4so3101935obh.38 for ; Mon, 03 Dec 2012 19:05:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:content-type:content-transfer-encoding:subject:date :message-id:cc:to:mime-version:x-mailer; bh=BJ9A+mUl+czOpEt9MDlhKZJAwWLeDWN78Cxn/dZfUzs=; b=u/RMhah6ywT7h2MbVPkMlmHQbtZEQ87LmAKF8xX30oLdZdsJel/fOzozf2qKPZ/53I 9DN7PEujT5hAgajj6ivia5BCgWIjLNBQ1bFEXhT5f+QdZ/jFp4R8LffjtgcNopOywdPL 9IAGj8XQPxhKoD4ox8luXft6+Z1KiEFc33nqgXCZatu6T5+/kqQotYqg9qkBegBwp96p aUBNZxYkA+3e7n1ogPy+i4AMYuSzodawBrYKw18eJBOd/kIXACglmp2C5Es2Shx/seH8 +QoPvF0c++jtQIoywzjpGZ/plxW93brGa0Wb+ufE2RL3ktaCw1iTkQdpkctlvgpoYkGd 4Meg== Received: by 10.182.18.142 with SMTP id w14mr6482280obd.65.1354590349258; Mon, 03 Dec 2012 19:05:49 -0800 (PST) Received: from [192.168.1.102] (99-58-56-194.lightspeed.austtx.sbcglobal.net. [99.58.56.194]) by mx.google.com with ESMTPS id os18sm15624246obb.6.2012.12.03.19.05.48 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Dec 2012 19:05:48 -0800 (PST) From: Jimi Xenidis Subject: [RFC PATCH] powerpc/kexec: Add kexec "hold" support for Book3e processors Date: Mon, 3 Dec 2012 21:05:47 -0600 Message-Id: To: Benjamin Herrenschmidt , Kumar Gala Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) X-Mailer: Apple Mail (2.1499) Cc: linuxppc-dev 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" Motivation: IBM Blue Gene/Q comes with some very strange firmware that I'm trying to get out of using in the kernel. So instead I spin all the threads in the boot wrapper (using the firmware) and have them enter the kexec stub, pre-translated at the virtual "linear" address, never touching firmware again. This works strategy works wonderfully, but I need the following patch in the kexec stub. I believe it should not effect Book3S and Book3E does not appear to be here yet so I'd love to get any criticisms up front. This patch adds two items: 1) Book3e requires that GPR4 survive the "hold" process, so we make sure that happens. 2) Book3e has no real mode, and the hold code exploits this. Since these processors ares always translated, we arrange for the kexeced threads to enter the hold code using the normal kernel linear mapping. Signed-off-by: Jimi Xenidis --- arch/powerpc/kernel/head_64.S | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S index 58bddee..1b00e95 100644 --- a/arch/powerpc/kernel/head_64.S +++ b/arch/powerpc/kernel/head_64.S @@ -122,6 +122,8 @@ __secondary_hold: #endif /* Grab our physical cpu number */ mr r24,r3 + /* stash r4 for book3e */ + mr r25,r4 /* Tell the master cpu we're here */ /* Relocation is off & we are located at an address less */ @@ -129,16 +131,31 @@ __secondary_hold: std r24,__secondary_hold_acknowledge-_stext(0) sync + li r26,0 +#ifdef CONFIG_PPC_BOOK3E + tovirt(r26,r26) +#endif /* All secondary cpus wait here until told to start. */ -100: ld r4,__secondary_hold_spinloop-_stext(0) +100: ld r4,__secondary_hold_spinloop-_stext(r26) cmpdi 0,r4,0 beq 100b #if defined(CONFIG_SMP) || defined(CONFIG_KEXEC) +#ifdef CONFIG_PPC_BOOK3E + tovirt(r4,r4) +#endif ld r4,0(r4) /* deref function descriptor */ mtctr r4 mr r3,r24 + /* + * it may be the case that other platforms have r4 right to + * begin with, this gives us some safety in case it is not + */ +#ifdef CONFIG_PPC_BOOK3E + mr r4,r25 +#else li r4,0 +#endif /* Make sure that patched code is visible */ isync bctr