diff mbox

Regression with 4.7.2 on sun4u

Message ID 20161022095128.GA55483@Jamess-MacBook.local
State Changes Requested
Delegated to: David Miller
Headers show

Commit Message

Jessica Clarke Oct. 22, 2016, 9:51 a.m. UTC
On Fri, Oct 21, 2016 at 09:07:26PM -0400, David Miller wrote:
> From: James Clarke <jrtc27@jrtc27.com>
> Date: Fri, 21 Oct 2016 22:52:45 +0100
> 
> > This indeed was the case. The attached patch fixes the problem for me,
> > generating 0x106ffff2, which gdb can verify is sensible (of course, the
> > addresses have shifted slightly):
> 
> Please don't use attachments for patch submissions.
> 
> Patches must be inline so that they can be commented upon properly
> using simply email quoting mechanisms.
> 
> Thank you.

Ok; same patch inline:

From 27ecad347d19c613d4e85665e710f1bd6bd56117 Mon Sep 17 00:00:00 2001
From: James Clarke <jrtc27@jrtc27.com>
Date: Fri, 21 Oct 2016 19:11:10 +0100
Subject: [PATCH] sparc: Handle negative offsets in arch_jump_label_transform

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
---
 arch/sparc/kernel/jump_label.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/arch/sparc/kernel/jump_label.c b/arch/sparc/kernel/jump_label.c
index 59bbeff..dec09ce 100644
--- a/arch/sparc/kernel/jump_label.c
+++ b/arch/sparc/kernel/jump_label.c
@@ -19,12 +19,20 @@  void arch_jump_label_transform(struct jump_entry *entry,
 	if (type == JUMP_LABEL_JMP) {
 		s32 off = (s32)entry->target - (s32)entry->code;
 
+		BUG_ON(off & 3);
+
 #ifdef CONFIG_SPARC64
-		/* ba,pt %xcc, . + (off << 2) */
-		val = 0x10680000 | ((u32) off >> 2);
+		/* WDISP19 - target is . + (immed << 2) */
+		BUG_ON(off > 0xfffff);
+		BUG_ON(off < -0x100000);
+		/* ba,pt %xcc, . + off */
+		val = 0x10680000 | (((u32) off >> 2) & 0x7ffff);
 #else
-		/* ba . + (off << 2) */
-		val = 0x10800000 | ((u32) off >> 2);
+		/* WDISP22 - target is . + (immed << 2) */
+		BUG_ON(off > 0x7fffff);
+		BUG_ON(off < -0x800000);
+		/* ba . + off */
+		val = 0x10800000 | (((u32) off >> 2) & 0x3fffff);
 #endif
 	} else {
 		val = 0x01000000;