Skip to contentSkip to conversation

target-ppc: Eliminate redundant and incorrect function booke206_page_size_to_tlb

PATCH Superseded Aaron Larson 2 participants 6 messages Jun 24, 2016 – Jun 28, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-ppc: Eliminate redundant and incorrect function booke206_page_size_to_tlb

Eliminate redundant and incorrect booke206_page_size_to_tlb function from ppce500_spin.c in preference to previously existing but newly exported definition from e500.c

---
 hw/ppc/e500.c         | 2 +-
 hw/ppc/e500.h         | 2 ++
 hw/ppc/ppce500_spin.c | 7 +------
 3 files changed, 4 insertions(+), 7 deletions(-)
hw/ppc/e500.c +1 -1
index ee1c60b..0cd534d 100644
@@ -601,7 +601,7 @@ static int ppce500_prep_device_tree(MachineState *machine,
 }
 
 /* Create -kernel TLB entries for BookE.  */
-static inline hwaddr booke206_page_size_to_tlb(uint64_t size)
+hwaddr booke206_page_size_to_tlb(uint64_t size)
 {
     return 63 - clz64(size >> 10);
 }
hw/ppc/e500.h +2 -0
index ef224ea..70ba1d8 100644
@@ -26,4 +26,6 @@ typedef struct PPCE500Params {
 
 void ppce500_init(MachineState *machine, PPCE500Params *params);
 
+hwaddr booke206_page_size_to_tlb(uint64_t size);
+
 #endif
hw/ppc/ppce500_spin.c +1 -6
index 225177b..22c584e 100644
@@ -32,6 +32,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
 #include "sysemu/kvm.h"
+#include "e500.h"
 
 #define MAX_CPUS 32
 
@@ -72,12 +73,6 @@ static void spin_reset(void *opaque)
     }
 }
 
-/* Create -kernel TLB entries for BookE, linearly spanning 256MB.  */
-static inline hwaddr booke206_page_size_to_tlb(uint64_t size)
-{
-    return ctz32(size >> 10) >> 1;
-}
-
 static void mmubooke_create_initial_mapping(CPUPPCState *env,
                                      target_ulong va,
                                      hwaddr pa,
Signature · 1 line
2.7.4
#1 lore raw
Quoted 6 lines · Aaron Larson

Eliminate redundant and incorrect booke206_page_size_to_tlb function from ppce500_spin.c in preference to previously existing but newly exported definition from e500.c

Uh.. sorry.. can you provide a reference explaining why the removed version is wrong? Doesn't this depend on which MMU Architecture Version we're emulating?

Quoted 55 lines
---
 hw/ppc/e500.c         | 2 +-
 hw/ppc/e500.h         | 2 ++
 hw/ppc/ppce500_spin.c | 7 +------
 3 files changed, 4 insertions(+), 7 deletions(-)
hw/ppc/e500.c +1 -1
index ee1c60b..0cd534d 100644
@@ -601,7 +601,7 @@ static int ppce500_prep_device_tree(MachineState *machine,
 }
 
 /* Create -kernel TLB entries for BookE.  */
-static inline hwaddr booke206_page_size_to_tlb(uint64_t size)
+hwaddr booke206_page_size_to_tlb(uint64_t size)
 {
     return 63 - clz64(size >> 10);
 }
hw/ppc/e500.h +2 -0
index ef224ea..70ba1d8 100644
@@ -26,4 +26,6 @@ typedef struct PPCE500Params {
 
 void ppce500_init(MachineState *machine, PPCE500Params *params);
 
+hwaddr booke206_page_size_to_tlb(uint64_t size);
+
 #endif
hw/ppc/ppce500_spin.c +1 -6
index 225177b..22c584e 100644
@@ -32,6 +32,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
 #include "sysemu/kvm.h"
+#include "e500.h"
 
 #define MAX_CPUS 32
 
@@ -72,12 +73,6 @@ static void spin_reset(void *opaque)
     }
 }
 
-/* Create -kernel TLB entries for BookE, linearly spanning 256MB.  */
-static inline hwaddr booke206_page_size_to_tlb(uint64_t size)
-{
-    return ctz32(size >> 10) >> 1;
-}
-
 static void mmubooke_create_initial_mapping(CPUPPCState *env,
                                      target_ulong va,
                                      hwaddr pa,
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#2 lore raw

David Gibson <[email protected]> wrote on 06/26/2016 08:36:52 PM:

Quoted 5 lines

From: David Gibson <[email protected]>
To: Aaron Larson <[email protected]>
Cc: [email protected], [email protected], [email protected]
Date: 06/26/2016 08:58 PM
Subject: Re: [PATCH] target-ppc: Eliminate redundant and incorrect

function booke206_page_size_to_tlb

Quoted 7 lines · Aaron Larson
Quoted 5 lines

Eliminate redundant and incorrect booke206_page_size_to_tlb function from ppce500_spin.c in preference to previously existing but newly exported definition from e500.c

Quoted 5 lines
Quoted 1 line

Uh.. sorry.. can you provide a reference explaining why the removed version is wrong? Doesn't this depend on which MMU Architecture Version we're emulating?

Sure, the code is internally inconsistent (shift assumed didn't match shift defined). I will provide an update commit message, similar to the original posting I made a few days ago with the "direction" corrected.

I didn't verify what sub-architectures/platforms are affected. I've been assuming it was just ppce500. If it is important I can do a bit of research, but the way code is coupled to platforms is sometimes surprising to me, so I'm not sure I would trust my analysis. Let me know if you need this analysis as part of the updated comment.

#3 lore raw
Quoted 18 lines · On Sun, Jun 26, 2016 at 09:38:03PM -0500, [email protected] wrote:

David Gibson <[email protected]> wrote on 06/26/2016 08:36:52 PM:

Quoted 5 lines

From: David Gibson <[email protected]>
To: Aaron Larson <[email protected]>
Cc: [email protected], [email protected], [email protected]
Date: 06/26/2016 08:58 PM
Subject: Re: [PATCH] target-ppc: Eliminate redundant and incorrect

function booke206_page_size_to_tlb

Quoted 9 lines · Aaron Larson
Quoted 6 lines

Eliminate redundant and incorrect booke206_page_size_to_tlb function from ppce500_spin.c in preference to previously existing but newly exported definition from e500.c

Quoted 8 lines
Quoted 3 lines

Uh.. sorry.. can you provide a reference explaining why the removed version is wrong? Doesn't this depend on which MMU Architecture Version we're emulating?

Sure, the code is internally inconsistent (shift assumed didn't match shift defined). I will provide an update commit message, similar to the original posting I made a few days ago with the "direction" corrected.

Right, I can see that the two old versions were different, which was clearly wrong. What I'm looking for is an explanation of why the one you've picked is the right one, not the other one.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#4 lore raw

David Gibson <[email protected]> wrote on 06/27/2016 12:32:13 AM:

Quoted 5 lines

From: David Gibson <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Date: 06/27/2016 12:30 AM
Subject: Re: [PATCH] target-ppc: Eliminate redundant and incorrect

function booke206_page_size_to_tlb

Quoted 3 lines · On Sun, Jun 26, 2016 at 09:38:03PM -0500, [email protected] wrote:
Quoted 1 line

David Gibson <[email protected]> wrote on 06/26/2016

08:36:52

Quoted 7 lines
Quoted 7 lines

PM:

Quoted 5 lines

From: David Gibson <[email protected]>
To: Aaron Larson <[email protected]>
Cc: [email protected], [email protected], [email protected]
Date: 06/26/2016 08:58 PM
Subject: Re: [PATCH] target-ppc: Eliminate redundant and incorrect

Quoted 5 lines
Quoted 5 lines

function booke206_page_size_to_tlb

Quoted 4 lines · Aaron Larson
Quoted 2 lines

Eliminate redundant and incorrect booke206_page_size_to_tlb

function

Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

from ppce500_spin.c in preference to previously existing but newly exported definition from e500.c

Uh.. sorry.. can you provide a reference explaining why the removed version is wrong? Doesn't this depend on which MMU Architecture Version we're emulating?

Sure, the code is internally inconsistent (shift assumed didn't match shift defined). I will provide an update commit message, similar to

the

Quoted 6 lines
Quoted 2 lines

original posting I made a few days ago with the "direction" corrected.

Right, I can see that the two old versions were different, which was clearly wrong. What I'm looking for is an explanation of why the one you've picked is the right one, not the other one.

How's this?

Eliminate redundant and incorrect booke206_page_size_to_tlb function from ppce500_spin.c in preference to previously existing but newly exported definition from e500.c

The booke206_page_size_to_tlb function in e500.c was updated in commit 2bd9543cd303d9f6cbd37b7466bb03543035156b to reflect a change in the definition of MAS1_TSIZE_SHIFT from 8 (corresponding to a min TLB page size of 4kb) to a value of 7 (TLB page size 2k). The booke206_page_size_to_tlb() function defined in ppce500_spin.c was never updated to reflect the change in MAS1_TSIZE_SHIFT.

In http://lists.nongnu.org/archive/html/qemu-ppc/2016-06/msg00533.html,
Scott Wood suggested this "root cause" explanation:

SW> The patch that changed MAS1_TSIZE_SHIFT from 8 to 7 was around the SW> same time as the patch that added this code, which is probably why SW> adjusting it got missed. Commit 2bd9543cd3 did update the SW> equivalent code in ppce500_mpc8544ds.c, which now resides in SW> hw/ppc/e500.c and has been changed to not assume a power-of-2 SW> size. The ppce500_spin version should be eliminated.

#5 lore raw
Quoted 51 lines · On Mon, Jun 27, 2016 at 10:55:03AM -0500, [email protected] wrote:

David Gibson <[email protected]> wrote on 06/27/2016 12:32:13 AM:

Quoted 5 lines

From: David Gibson <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Date: 06/27/2016 12:30 AM
Subject: Re: [PATCH] target-ppc: Eliminate redundant and incorrect

function booke206_page_size_to_tlb

Quoted 3 lines · On Sun, Jun 26, 2016 at 09:38:03PM -0500, [email protected] wrote:
Quoted 1 line

David Gibson <[email protected]> wrote on 06/26/2016

08:36:52

Quoted 7 lines
Quoted 7 lines

PM:

Quoted 5 lines

From: David Gibson <[email protected]>
To: Aaron Larson <[email protected]>
Cc: [email protected], [email protected], [email protected]
Date: 06/26/2016 08:58 PM
Subject: Re: [PATCH] target-ppc: Eliminate redundant and incorrect

Quoted 5 lines
Quoted 5 lines

function booke206_page_size_to_tlb

Quoted 4 lines · Aaron Larson
Quoted 2 lines

Eliminate redundant and incorrect booke206_page_size_to_tlb

function

Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

from ppce500_spin.c in preference to previously existing but newly exported definition from e500.c

Uh.. sorry.. can you provide a reference explaining why the removed version is wrong? Doesn't this depend on which MMU Architecture Version we're emulating?

Sure, the code is internally inconsistent (shift assumed didn't match shift defined). I will provide an update commit message, similar to

the

Quoted 6 lines
Quoted 2 lines

original posting I made a few days ago with the "direction" corrected.

Right, I can see that the two old versions were different, which was clearly wrong. What I'm looking for is an explanation of why the one you've picked is the right one, not the other one.

How's this?

Eliminate redundant and incorrect booke206_page_size_to_tlb function from ppce500_spin.c in preference to previously existing but newly exported definition from e500.c

Quoted 6 lines

The booke206_page_size_to_tlb function in e500.c was updated in commit 2bd9543cd303d9f6cbd37b7466bb03543035156b to reflect a change in the definition of MAS1_TSIZE_SHIFT from 8 (corresponding to a min TLB page size of 4kb) to a value of 7 (TLB page size 2k). The booke206_page_size_to_tlb() function defined in ppce500_spin.c was never updated to reflect the change in MAS1_TSIZE_SHIFT.

Ah, yes, that looks good. Except that the convention when citing other commits is to just use the first 7 characters of the commit id, but to include the 1 line description. So:

...commit 2bd9543 "ppc: booke206: use MAV=2.0 TSIZE definition, fix
4G pages" to reflect...

Quoted 10 lines

In http://lists.nongnu.org/archive/html/qemu-ppc/2016-06/msg00533.html,
Scott Wood suggested this "root cause" explanation:

SW> The patch that changed MAS1_TSIZE_SHIFT from 8 to 7 was around the SW> same time as the patch that added this code, which is probably why SW> adjusting it got missed. Commit 2bd9543cd3 did update the SW> equivalent code in ppce500_mpc8544ds.c, which now resides in SW> hw/ppc/e500.c and has been changed to not assume a power-of-2 SW> size. The ppce500_spin version should be eliminated.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson