Skip to contentSkip to conversation

kgdb, ppc: Corrected the address using of current->thread.evr register

PATCH In review Dongdong Deng 4 participants 7 messages Nov 16, 2010 – Nov 17, 2010 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kgdb, ppc: Corrected the address using of current->thread.evr register

Passing the address of current->thread.evr register to memcpy function.

---
 arch/powerpc/kernel/kgdb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/kgdb.c +2 -2
index 7a9db64..781acff 100644
@@ -337,7 +337,7 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
 		/* FP registers 32 -> 63 */
 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
 		if (current)
-			memcpy(mem, current->thread.evr[regno-32],
+			memcpy(mem, (void *)&current->thread.evr[regno-32],
 					dbg_reg_def[regno].size);
 #else
 		/* fp registers not used by kernel, leave zero */
@@ -362,7 +362,7 @@ int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
 	if (regno >= 32 && regno < 64) {
 		/* FP registers 32 -> 63 */
 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
-		memcpy(current->thread.evr[regno-32], mem,
+		memcpy((void *)&current->thread.evr[regno-32], mem,
 				dbg_reg_def[regno].size);
 #else
 		/* fp registers not used by kernel, leave zero */
Signature · 1 line
1.6.0.4
#1 lore raw

Hello.

Quoted 24 lines · Dongdong Deng

Passing the address of current->thread.evr register to memcpy function.

---
  arch/powerpc/kernel/kgdb.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/kgdb.c +1 -1
index 7a9db64..781acff 100644
@@ -337,7 +337,7 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
  		/* FP registers 32 ->  63 */
  #if defined(CONFIG_FSL_BOOKE)&&  defined(CONFIG_SPE)
  		if (current)
-			memcpy(mem, current->thread.evr[regno-32],
+			memcpy(mem, (void *)&current->thread.evr[regno-32],
  					dbg_reg_def[regno].size);
  #else
  		/* fp registers not used by kernel, leave zero */

arch/powerpc/kernel/kgdb.c int dbg_set_reg(int regno, void *mem, struct pt_regs *regs) · line 365

Quoted 5 lines
arch/powerpc/kernel/kgdb.c +1 -1
@@ -362,7 +362,7 @@ int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
  	if (regno>= 32&&  regno<  64) {
  		/* FP registers 32 ->  63 */
  #if defined(CONFIG_FSL_BOOKE)&&  defined(CONFIG_SPE)
-		memcpy(current->thread.evr[regno-32], mem,
+		memcpy((void *)&current->thread.evr[regno-32], mem,

Doesn't any pointer type get converted to 'void *' automatically? These
casts are not really needed...

WBR, Sergei

#2 lore raw
In reply to Dongdong Deng
Quoted 3 lines · Dongdong Deng

Passing the address of current->thread.evr register to memcpy function.

It turns out that out of all of my test configs and targets I did not have any that defined both CONFIG_FSL_BOOKE and CONFIG_SPE else this would have been caught in testing because will definitely crash dereferencing the contents of the evr registers.

Quoted 13 lines
---
 arch/powerpc/kernel/kgdb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/kgdb.c +0 -0
index 7a9db64..781acff 100644

arch/powerpc/kernel/kgdb.c char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs) · line 342

Quoted 7 lines
arch/powerpc/kernel/kgdb.c +1 -1
@@ -337,7 +337,7 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
 		/* FP registers 32 -> 63 */
 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
 		if (current)
-			memcpy(mem, current->thread.evr[regno-32],
+			memcpy(mem, (void *)&current->thread.evr[regno-32],
 					dbg_reg_def[regno].size);
 

As Sergei already pointed out, the (void *) casts should not be needed here.

This would have been fixed correctly had I seen the compile warnings
from the CONFIG_SPE at the test phase. Namely at the compile phase
doesn't even complete:

arch/powerpc/kernel/kgdb.c: In function 'dbg_get_reg':
arch/powerpc/kernel/kgdb.c:341: error: passing argument 2 of 'memcpy' makes pointer from integer without a cast arch/powerpc/include/asm/string.h:25: note: expected 'const void *' but argument is of type 'long unsigned int' arch/powerpc/kernel/kgdb.c: In function 'dbg_set_reg':
arch/powerpc/kernel/kgdb.c:366: error: passing argument 1 of 'memcpy' makes pointer from integer without a cast arch/powerpc/include/asm/string.h:25: note: expected 'void *' but argument is of type 'long unsigned int'

Moral of the story... I now have a board and config with the SPE turned on, and after boot testing confirmed the evr registers are working.

I plan to have a pull request out to Linus with this fix and several other accumulated regression fixes sometime in the next 48 hours.

Thanks,
Jason.

#3 lore raw
Quoted 2 lines · Jason Wessel
Quoted 1 line · Dongdong Deng

Passing the address of current->thread.evr register to memcpy =

function.

Quoted 8 lines
Quoted 2 lines

=20
=20

=20
It turns out that out of all of my test configs and targets I did not have any that defined both CONFIG_FSL_BOOKE and CONFIG_SPE else this would have been caught in testing because will definitely crash dereferencing the contents of the evr registers.
=20

Quoted 13 lines

arch/powerpc/kernel/kgdb.c char *dbg_get_reg(int regno, void *mem, struct =

Quoted 13 lines

---
arch/powerpc/kernel/kgdb.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)

=20

arch/powerpc/kernel/kgdb.c +0 -0
index 7a9db64..781acff 100644
@@ -337,7 +337,7 @@ char *dbg_get_reg(int regno, void *mem, struct =

pt_regs *regs)

Quoted 5 lines

arch/powerpc/kernel/kgdb.c char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)

Quoted 5 lines
arch/powerpc/kernel/kgdb.c +1 -1
 		/* FP registers 32 -> 63 */
 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
 		if (current)
-			memcpy(mem, current->thread.evr[regno-32],
+			memcpy(mem, (void =

*)&current->thread.evr[regno-32],

Quoted 4 lines
Quoted 2 lines
arch/powerpc/kernel/kgdb.c +0 -0
 					dbg_reg_def[regno].size);

=20

=20
As Sergei already pointed out, the (void *) casts should not be needed =

here.

Quoted 9 lines

=20
This would have been fixed correctly had I seen the compile warnings
from the CONFIG_SPE at the test phase. Namely at the compile phase
doesn't even complete:
=20
arch/powerpc/kernel/kgdb.c: In function 'dbg_get_reg':
arch/powerpc/kernel/kgdb.c:341: error: passing argument 2 of 'memcpy' makes pointer from integer without a cast arch/powerpc/include/asm/string.h:25: note: expected 'const void *' =

but

Quoted 9 lines

argument is of type 'long unsigned int' arch/powerpc/kernel/kgdb.c: In function 'dbg_set_reg':
arch/powerpc/kernel/kgdb.c:366: error: passing argument 1 of 'memcpy' makes pointer from integer without a cast arch/powerpc/include/asm/string.h:25: note: expected 'void *' but argument is of type 'long unsigned int'
=20
=20
Moral of the story... I now have a board and config with the SPE =

turned

Quoted 7 lines

on, and after boot testing confirmed the evr registers are working. =20
I plan to have a pull request out to Linus with this fix and several other accumulated regression fixes sometime in the next 48 hours. =20
Thanks,
Jason.

Repost a version with the casts and I'll pick it up.

- k=

#4 lore raw
Quoted 6 lines · Kumar Gala
Quoted 2 lines

Thanks,
Jason.

Repost a version with the casts and I'll pick it up.

- k

I have the final version ready for a pull request that I was going to make in the next hour or two that is fully regression tested.

If you would prefer to these changes in the PPC, let me know, or if you want to ack the patch, I'll add that before submitting the pull request.

Thanks,
Jason.

--

Quoted 1 line

From b47efa1d4fa4631ee0cc59f4fcd143464b910cdc Mon Sep 17 00:00:00 2001

From: Dongdong Deng <[email protected]>
Date: Tue, 16 Nov 2010 16:02:00 -0600
Subject: [PATCH 4/4] kgdb: Fix regression in evr register handling

Commit ff10b88b5a05c8f1646dd15fb9f6093c1384ff6d (kgdb,ppc: Individual register get/set for ppc) introduced a problem where memcpy was used incorrectly to read and write the evr registers with a kernel that has:

CONFIG_FSL_BOOKE=y
CONFIG_SPE=y
CONFIG_KGDB=y

This patch also fixes the following compilation problems:

arch/powerpc/kernel/kgdb.c: In function 'dbg_get_reg':
arch/powerpc/kernel/kgdb.c:341: error: passing argument 2 of 'memcpy' makes pointer from integer without a cast arch/powerpc/kernel/kgdb.c: In function 'dbg_set_reg':
arch/powerpc/kernel/kgdb.c:366: error: passing argument 1 of 'memcpy' makes pointer from integer without a cast

---
 arch/powerpc/kernel/kgdb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/kgdb.c +2 -2
index 7a9db64..42850ee 100644
@@ -337,7 +337,7 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
 		/* FP registers 32 -> 63 */
 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
 		if (current)
-			memcpy(mem, current->thread.evr[regno-32],
+			memcpy(mem, &current->thread.evr[regno-32],
 					dbg_reg_def[regno].size);
 #else
 		/* fp registers not used by kernel, leave zero */
@@ -362,7 +362,7 @@ int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
 	if (regno >= 32 && regno < 64) {
 		/* FP registers 32 -> 63 */
 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
-		memcpy(current->thread.evr[regno-32], mem,
+		memcpy(&current->thread.evr[regno-32], mem,
 				dbg_reg_def[regno].size);
 #else
 		/* fp registers not used by kernel, leave zero */
Signature · 1 line
1.7.0.4
#5 lore raw
Quoted 8 lines · Jason Wessel

On 11/17/2010 11:16 AM, Kumar Gala wrote:
=20

Quoted 6 lines
Quoted 2 lines

Thanks,
Jason.

=20
Repost a version with the casts and I'll pick it up. =20
- k

Quoted 12 lines

=20
I have the final version ready for a pull request that I was going to make in the next hour or two that is fully regression tested. =20
If you would prefer to these changes in the PPC, let me know, or if you want to ack the patch, I'll add that before submitting the pull request.
=20
Thanks,
Jason.
=20
--

If they'll get pulled in via another path that is fine. I'm happy to = ack a proper patch.

- k=

Acked-by
#6 lore raw
In reply to Jason Wessel
Quoted 9 lines

From: Dongdong Deng <[email protected]>
Date: Tue, 16 Nov 2010 16:02:00 -0600
Subject: [PATCH 4/4] kgdb: Fix regression in evr register handling =20
Commit ff10b88b5a05c8f1646dd15fb9f6093c1384ff6d (kgdb,ppc: Individual register get/set for ppc) introduced a problem where memcpy was used incorrectly to read and write the evr registers with a kernel that has:
=20

Quoted 8 lines

CONFIG_FSL_BOOKE=3Dy
CONFIG_SPE=3Dy
CONFIG_KGDB=3Dy
=20
This patch also fixes the following compilation problems:
=20
arch/powerpc/kernel/kgdb.c: In function 'dbg_get_reg':
arch/powerpc/kernel/kgdb.c:341: error: passing argument 2 of 'memcpy' =

makes pointer from integer without a cast

Quoted 2 lines

arch/powerpc/kernel/kgdb.c: In function 'dbg_set_reg':
arch/powerpc/kernel/kgdb.c:366: error: passing argument 1 of 'memcpy' =

makes pointer from integer without a cast

arch/powerpc/kernel/kgdb.c char *dbg_get_reg(int regno, void *mem, struct =

Quoted 15 lines

=20

---
arch/powerpc/kernel/kgdb.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)

=20

arch/powerpc/kernel/kgdb.c +0 -0
index 7a9db64..42850ee 100644
@@ -337,7 +337,7 @@ char *dbg_get_reg(int regno, void *mem, struct =

pt_regs *regs)

arch/powerpc/kernel/kgdb.c int dbg_set_reg(int regno, void *mem, struct =

Quoted 9 lines
arch/powerpc/kernel/kgdb.c +1 -1
 		/* FP registers 32 -> 63 */
 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
 		if (current)
-			memcpy(mem, current->thread.evr[regno-32],
+			memcpy(mem, &current->thread.evr[regno-32],
 					dbg_reg_def[regno].size);
 #else
 		/* fp registers not used by kernel, leave zero */
@@ -362,7 +362,7 @@ int dbg_set_reg(int regno, void *mem, struct =

pt_regs *regs)

Quoted 10 lines
arch/powerpc/kernel/kgdb.c +1 -2
 	if (regno >=3D 32 && regno < 64) {
 		/* FP registers 32 -> 63 */
 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
-		memcpy(current->thread.evr[regno-32], mem,
+		memcpy(&current->thread.evr[regno-32], mem,
 				dbg_reg_def[regno].size);
 #else
 		/* fp registers not used by kernel, leave zero */
--=20

1.7.0.4

- k