Blob Blame History Raw
Return-Path: benh@au1.ibm.com
Received: from zmta03.collab.prod.int.phx2.redhat.com (LHLO
 zmta03.collab.prod.int.phx2.redhat.com) (10.5.5.33) by
 zmail14.collab.prod.int.phx2.redhat.com with LMTP; Sun, 13 May 2012
 23:43:23 -0400 (EDT)
Received: from localhost (localhost.localdomain [127.0.0.1])
	by zmta03.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id A92D5F0BC1
	for <pjones@redhat.com>; Sun, 13 May 2012 23:43:23 -0400 (EDT)
Received: from zmta03.collab.prod.int.phx2.redhat.com ([127.0.0.1])
	by localhost (zmta03.collab.prod.int.phx2.redhat.com [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id KDt5yD-zSoXe for <pjones@redhat.com>;
	Sun, 13 May 2012 23:43:23 -0400 (EDT)
Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])
	by zmta03.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 951A2F0843
	for <pjones@mail.corp.redhat.com>; Sun, 13 May 2012 23:43:23 -0400 (EDT)
Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.17])
	by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q4E3hNWo019302
	for <pjones@redhat.com>; Sun, 13 May 2012 23:43:23 -0400
Received: from bastion.fedoraproject.org (bastion02.phx2.fedoraproject.org [10.5.126.11])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4E3hLtl006033
	for <pjones@redhat.com>; Sun, 13 May 2012 23:43:21 -0400
Received: by bastion02.phx2.fedoraproject.org (Postfix)
	id 1B8B34040D; Mon, 14 May 2012 03:43:21 +0000 (UTC)
Delivered-To: pjones@fedoraproject.org
Received: from mx2.redhat.com (ext-mx01.rdu.redhat.com [10.11.45.6])
	by bastion02.phx2.fedoraproject.org (Postfix) with ESMTP id AF73B402BC
	for <pjones@fedoraproject.org>; Mon, 14 May 2012 03:43:20 +0000 (UTC)
Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148])
	by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id q4E3h5JZ014320
	for <pjones@fedoraproject.org>; Sun, 13 May 2012 23:43:11 -0400
Received: from /spool/local
	by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted
	for <pjones@fedoraproject.org> from <benh@au1.ibm.com>;
	Mon, 14 May 2012 03:37:12 +1000
Received: from d23relay03.au.ibm.com (202.81.31.245)
	by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted;
	Mon, 14 May 2012 03:37:09 +1000
Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139])
	by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q4E3gcbg60358704
	for <pjones@fedoraproject.org>; Mon, 14 May 2012 13:42:38 +1000
Received: from d23av04.au.ibm.com (loopback [127.0.0.1])
	by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q4E3gb1m003356
	for <pjones@fedoraproject.org>; Mon, 14 May 2012 13:42:37 +1000
Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.190.163.12])
	by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q4E3gbsI003349;
	Mon, 14 May 2012 13:42:37 +1000
Received: from [10.61.2.137] (haven.au.ibm.com [9.190.164.82])
	(using SSLv3 with cipher AES256-SHA (256/256 bits))
	(Client did not present a certificate)
	by ozlabs.au.ibm.com (Postfix) with ESMTPSA id B60A073A09;
	Mon, 14 May 2012 13:42:37 +1000 (EST)
Message-ID: <1336966957.6727.15.camel@pasglop>
Subject: [PATCH] grub: Fix module trampoline for powerpc
From: Benjamin Herrenschmidt <benh@au1.ibm.com>
To: Brent Baude <baude@us.ibm.com>, pjones@fedoraproject.org
Cc: hamzy@us.ibm.com, Josh Boyer <jwboyer@gmail.com>
Date: Mon, 14 May 2012 13:42:37 +1000
Organization: IBM Australia
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0
x-cbid: 12051317-7014-0000-0000-0000011BC8AA
X-RedHat-Spam-Score: -5.01  (RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD)
X-RedHat-Spam-Score: -5.011  (RCVD_IN_DNSWL_HI,SPF_PASS,T_RP_MATCHES_RCVD)
X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12
X-Scanned-By: MIMEDefang 2.68 on 10.5.110.17
X-Scanned-By: MIMEDefang 2.67 on 10.11.45.6

[ --- snip --- ]

Not sure who to send that to, I picked Peter as he's in
the rpm log as author of the of the powerpc patches,
feel free to do whatever with that one, it should ultimately
go to upstream grub I suppose ...

Without this, grub doesn't work for me at all with fc17 beta

[ --- snip --- ]

The trampoline generated by grub powerpc's dl.c to call from
modules into the main grub code uses r0 as a scratch register.

However, nowadays, gcc can (and will) generate function calls
to spill registers to the stack (well, it's even stupid enough
to do it when there's only one register to save ! go figure....)

Those calls happen during the function prolog, before the
return address has been saved on the stack, typically it's held
in r0 at this stage. Since those calls will hit the trampoline
in grub, which clobbers r0, this will clobber the return address
and cause a crash.

This patch changes the trampolines to use r12 instead which
is safe to use in our case.

Note: It might be better to actually link those low level gcc
support functions statically into the modules but that's beyond
the level of grub hacking I'm prepared to do today.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
diff --git a/grub-core/kern/powerpc/dl.c b/grub-core/kern/powerpc/dl.c
index b8a2b50..0a8ec85 100644
--- a/grub-core/kern/powerpc/dl.c
+++ b/grub-core/kern/powerpc/dl.c
@@ -89,9 +89,9 @@ struct trampoline
 
 static const struct trampoline trampoline_template = 
   {
-    0x3c000000,
-    0x60000000,
-    0x7c0903a6,
+    0x3d800000,
+    0x618c0000,
+    0x7d8903a6,
     0x4e800420,
   };