Skip to contentSkip to conversation

sparc: refactor code in fault_32.c

PATCH Applied Sam Ravnborg 3 participants 6 messages Jan 6, 2009 – Jan 8, 2009 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc: refactor code in fault_32.c

The sparc allmodconfig build broke due to enabling of the branch_tracer that does some very clever things with all if conditions. This caused my gcc 3.4.5 to be so confused that it emitted a warning:

arch/sparc/mm/fault_32.c: In function `do_sparc_fault':
arch/sparc/mm/fault_32.c:176: warning: 'fixup' might be used uninitialized in this function

And with -Werror this broke the build.

Refactor code so it:
1) becomes more readable
2) no longer emit a warning with the branch_tracer enabled

Cc Steven Rostedt <[email protected]>

---

arch/sparc/mm/fault_32.c +2 -1
index a507e11..12e447f 100644
@@ -283,7 +283,8 @@ bad_area_nosemaphore:
 	/* Is this in ex_table? */
 no_context:
 	g2 = regs->u_regs[UREG_G2];
-	if (!from_user && (fixup = search_extables_range(regs->pc, &g2))) {
+	if (!from_user) {
+		fixup = search_extables_range(regs->pc, &g2);
 		if (fixup > 10) { /* Values below are reserved for other things */
 			extern const unsigned __memset_start[];
 			extern const unsigned __memset_end[];
maintainer Applied
#1 lore raw

From: Sam Ravnborg <[email protected]>
Date: Tue, 6 Jan 2009 21:52:09 +0100

Quoted 8 lines

The sparc allmodconfig build broke due to enabling of the branch_tracer that does some very clever things with all if conditions. This caused my gcc 3.4.5 to be so confused that it emitted a warning:

arch/sparc/mm/fault_32.c: In function `do_sparc_fault':
arch/sparc/mm/fault_32.c:176: warning: 'fixup' might be used uninitialized in this function

Quoted 7 lines

And with -Werror this broke the build.

Refactor code so it:
1) becomes more readable
2) no longer emit a warning with the branch_tracer enabled

Applied, thanks Sam.

#2 lore raw
In reply to Sam Ravnborg
Quoted 13 lines · David Miller

From: Sam Ravnborg <[email protected]>
Date: Tue, 6 Jan 2009 21:52:09 +0100

Quoted 10 lines

The sparc allmodconfig build broke due to enabling of the branch_tracer that does some very clever things with all if conditions. This caused my gcc 3.4.5 to be so confused that it emitted a warning:

arch/sparc/mm/fault_32.c: In function `do_sparc_fault':
arch/sparc/mm/fault_32.c:176: warning: 'fixup' might be used uninitialized in this function

And with -Werror this broke the build.

Quoted 7 lines
Quoted 5 lines

Refactor code so it:
1) becomes more readable
2) no longer emit a warning with the branch_tracer enabled

Applied, thanks Sam.

It looks like this was the only one needed to build sparc32 vmlinux with allmodconfig.
Still building but all sparc specific bits are built.

So outstanding issues now are:

1) How to fix "warning" in unaligned_64.c (get_user() || get_user())
2) Fix build of sparc32 vmlinux with the new stripping patches

I will try to give 2) a shot tomorrow - too late here now.

Sam

maintainer
#3 lore raw
In reply to Sam Ravnborg

From: Sam Ravnborg <[email protected]>
Date: Tue, 6 Jan 2009 22:06:24 +0100

Quoted 3 lines

So outstanding issues now are:

1) How to fix "warning" in unaligned_64.c (get_user() || get_user())

I'm going to put a hack patch in, similar to your's, so people can get work done. We can try to cure this situation more cleanly later.

sparc64: Work around branch tracer warning.

As reported by Sam Ravnborg, Gcc-3.4.5 does not handle:

if (get_user() || get_user())

with the new branch tracer enabled.

Just seperate it out into seperate statements for now so people can get work done.

arch/sparc/kernel/unaligned_64.c +6 -2
index 203ddfa..f164d5a 100644
@@ -601,11 +601,15 @@ void handle_lddfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr
 		pc = (u32)pc;
 	if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
 		int asi = decode_asi(insn, regs);
+		int err;
+
 		if ((asi > ASI_SNFL) ||
 		    (asi < ASI_P))
 			goto daex;
-		if (get_user(first, (u32 __user *)sfar) ||
-		     get_user(second, (u32 __user *)(sfar + 4))) {
+		err = get_user(first, (u32 __user *)sfar);
+		if (!err)
+			err = get_user(second, (u32 __user *)(sfar + 4));
+		if (err) {
 			if (asi & 0x2) /* NF */ {
 				first = 0; second = 0;
 			} else
#4 lore raw
In reply to Sam Ravnborg
Quoted 12 lines · David Miller

From: Sam Ravnborg <[email protected]>
Date: Tue, 6 Jan 2009 22:06:24 +0100

Quoted 3 lines

So outstanding issues now are:

1) How to fix "warning" in unaligned_64.c (get_user() || get_user())

I'm going to put a hack patch in, similar to your's, so people can get work done. We can try to cure this situation more cleanly later.

sparc64: Work around branch tracer warning.

Quoted 8 lines

As reported by Sam Ravnborg, Gcc-3.4.5 does not handle:

if (get_user() || get_user())

with the new branch tracer enabled.

Just seperate it out into seperate statements for now so people can get work done.

Can you think of any way we could improve the branch-tracer instrumentation define in any way to prevent such trouble?

Ingo

maintainer
#5 lore raw
In reply to Sam Ravnborg

From: Ingo Molnar <[email protected]>
Date: Thu, 8 Jan 2009 13:02:34 +0100

Quoted 2 lines

Can you think of any way we could improve the branch-tracer instrumentation define in any way to prevent such trouble?

Steven was looking into this but every variant of the if() macro he tried wasn't able to eliminate all of the problems. We've been discussing this with him in another thread for several days. The S390 folks are running into these kinds of problems too.

It's basically an issue of how deeply older GCCs will search into the control flow of a very complex conditional. There really isn't anything we can do about that.