Skip to contentSkip to conversation

ppc: booke206: KVM MMU API and info tlb

PATCH Superseded Scott Wood 4 participants 12 messages Jul 7, 2011 – May 15, 2012

lore
Share & tools
lore

Scott Wood

author
#0 lore raw

v2 cover ppc: booke206: KVM MMU API and info tlb

Scott Wood (4):
kvm: ppc: Update KVM headers for MMU API
kvm: ppc: booke206: use MMU API
ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages
ppc: booke206: add "info tlb" support

 hmp-commands.hx                 |    2 +-
 hw/ppce500_mpc8544ds.c          |    4 +-
 linux-headers/asm-powerpc/kvm.h |   39 +++++++++++++++-
 linux-headers/linux/kvm.h       |   27 ++++++++---
 monitor.c                       |    5 +-
 target-ppc/cpu.h                |    8 +++-
 target-ppc/helper.c             |   93 ++++++++++++++++++++++++++++++++++++++-
 target-ppc/kvm.c                |   83 ++++++++++++++++++++++++++++++++++
 8 files changed, 244 insertions(+), 17 deletions(-)
Signature · 1 line
1.7.4.1
author
#1 lore raw

PATCH v2 1/4 kvm: ppc: Update KVM headers for MMU API

---
 linux-headers/asm-powerpc/kvm.h |   39 +++++++++++++++++++++++++++++++++++++--
 linux-headers/linux/kvm.h       |   27 ++++++++++++++++++++-------
 2 files changed, 57 insertions(+), 9 deletions(-)
linux-headers/asm-powerpc/kvm.h +37 -2
index 777d307..1a6dedf 100644
@@ -166,8 +166,8 @@ struct kvm_sregs {
 			} ppc64;
 			struct {
 				__u32 sr[16];
-				__u64 ibat[8];
-				__u64 dbat[8];
+				__u64 ibat[8]; 
+				__u64 dbat[8]; 
 			} ppc32;
 		} s;
 		struct {
@@ -272,4 +272,39 @@ struct kvm_guest_debug_arch {
 #define KVM_INTERRUPT_UNSET	-2U
 #define KVM_INTERRUPT_SET_LEVEL	-3U
 
+struct kvm_book3e_206_tlb_entry {
+	__u32 mas8;
+	__u32 mas1;
+	__u64 mas2;
+	__u64 mas7_3;
+};
+
+struct kvm_book3e_206_tlb_params {
+	/*
+	 * For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
+	 *
+	 * - The number of ways of TLB0 must be a power of two between 2 and
+	 *   16.
+	 * - TLB1 must be fully associative.
+	 * - The size of TLB0 must be a multiple of the number of ways, and
+	 *   the number of sets must be a power of two.
+	 * - The size of TLB1 may not exceed 64 entries.
+	 * - TLB0 supports 4 KiB pages.
+	 * - The page sizes supported by TLB1 are as indicated by
+	 *   TLB1CFG (if MMUCFG[MAVN] = 0) or TLB1PS (if MMUCFG[MAVN] = 1)
+	 *   as returned by KVM_GET_SREGS.
+	 * - TLB2 and TLB3 are reserved, and their entries in tlb_sizes[]
+	 *   and tlb_ways[] must be zero.
+	 *
+	 * tlb_ways[n] = tlb_sizes[n] means the array is fully associative.
+	 *
+	 * KVM will adjust TLBnCFG based on the sizes configured here,
+	 * though arrays greater than 2048 entries will have TLBnCFG[NENTRY]
+	 * set to zero.
+	 */
+	__u32 tlb_sizes[4];
+	__u32 tlb_ways[4];
+	__u32 reserved[8];
+};
+
 #endif /* __LINUX_KVM_POWERPC_H */
linux-headers/linux/kvm.h +20 -7
index fc63b73..2228642 100644
@@ -544,6 +544,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_TSC_CONTROL 60
 #define KVM_CAP_GET_TSC_KHZ 61
 #define KVM_CAP_PPC_BOOKE_SREGS 62
+#define KVM_CAP_SW_TLB 63
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -623,6 +624,21 @@ struct kvm_clock_data {
 	__u32 pad[9];
 };
 
+#define KVM_MMU_FSL_BOOKE_NOHV		0
+#define KVM_MMU_FSL_BOOKE_HV		1
+
+struct kvm_config_tlb {
+	__u64 params;
+	__u64 array;
+	__u32 mmu_type;
+	__u32 array_len;
+};
+
+struct kvm_dirty_tlb {
+	__u64 bitmap;
+	__u32 num_dirty;
+};
+
 /*
  * ioctls for VM fds
  */
@@ -746,6 +762,9 @@ struct kvm_clock_data {
 /* Available with KVM_CAP_XCRS */
 #define KVM_GET_XCRS		  _IOR(KVMIO,  0xa6, struct kvm_xcrs)
 #define KVM_SET_XCRS		  _IOW(KVMIO,  0xa7, struct kvm_xcrs)
+/* Available with KVM_CAP_SW_TLB */
+#define KVM_CONFIG_TLB		  _IOW(KVMIO,  0xa8, struct kvm_config_tlb)
+#define KVM_DIRTY_TLB		  _IOW(KVMIO,  0xa9, struct kvm_dirty_tlb)
 
 #define KVM_DEV_ASSIGN_ENABLE_IOMMU	(1 << 0)
 
@@ -773,20 +792,14 @@ struct kvm_assigned_pci_dev {
 
 struct kvm_assigned_irq {
 	__u32 assigned_dev_id;
-	__u32 host_irq;
+	__u32 host_irq; /* ignored (legacy field) */
 	__u32 guest_irq;
 	__u32 flags;
 	union {
-		struct {
-			__u32 addr_lo;
-			__u32 addr_hi;
-			__u32 data;
-		} guest_msi;
 		__u32 reserved[12];
 	};
 };
 
-
 struct kvm_assigned_msix_nr {
 	__u32 assigned_dev_id;
 	__u16 entry_nr;
Signature · 1 line
1.7.4.1
author
#2 lore raw

PATCH v2 2/4 kvm: ppc: booke206: use MMU API

In reply to Scott Wood

Share the TLB array with KVM. This allows us to set the initial TLB both on initial boot and reset, is useful for debugging, and could eventually be used to support migration.

---
v2:
- rebase on top of current tree, remove now-unneeded ifdefs
- add some asserts and comments as requested

 hw/ppce500_mpc8544ds.c |    2 +
 target-ppc/cpu.h       |    2 +
 target-ppc/kvm.c       |   83 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+), 0 deletions(-)
hw/ppce500_mpc8544ds.c +2 -0
index b739ce2..3626e26 100644
@@ -202,6 +202,8 @@ static void mmubooke_create_initial_mapping(CPUState *env,
     tlb->mas2 = va & TARGET_PAGE_MASK;
     tlb->mas7_3 = pa & TARGET_PAGE_MASK;
     tlb->mas7_3 |= MAS3_UR | MAS3_UW | MAS3_UX | MAS3_SR | MAS3_SW | MAS3_SX;
+
+    env->tlb_dirty = true;
 }
 
 static void mpc8544ds_cpu_reset(void *opaque)
target-ppc/cpu.h +2 -0
index 84f8ff6..f8bf2b1 100644
@@ -921,6 +921,8 @@ struct CPUPPCState {
     ppc_tlb_t tlb;   /* TLB is optional. Allocate them only if needed        */
     /* 403 dedicated access protection registers */
     target_ulong pb[4];
+    bool tlb_dirty;   /* Set to non-zero when modifying TLB                  */
+    bool kvm_sw_tlb;  /* non-zero if KVM SW TLB API is active                */
 #endif
 
     /* Other registers */
target-ppc/kvm.c +83 -0

107 lines not on this page · raw message

Signature · 1 line
1.7.4.1
author
#3 lore raw

PATCH v2 3/4 ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages

In reply to Scott Wood

This definition is backward compatible with MAV=1.0 as long as the guest does not set reserved bits in MAS1/MAS4.

Also, fix the shift in booke206_tlb_to_page_size -- it's the base that should be able to hold a 4G page size, not the shift count.

---
Unchanged in patchset v2

 hw/ppce500_mpc8544ds.c |    2 +-
 target-ppc/cpu.h       |    4 ++--
 target-ppc/helper.c    |    5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
hw/ppce500_mpc8544ds.c +1 -1
index 3626e26..1aed612 100644
@@ -187,7 +187,7 @@ out:
 /* Create -kernel TLB entries for BookE, linearly spanning 256MB.  */
 static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size)
 {
-    return (ffs(size >> 10) - 1) >> 1;
+    return ffs(size >> 10) - 1;
 }
 
 static void mmubooke_create_initial_mapping(CPUState *env,
target-ppc/cpu.h +2 -2
index f8bf2b1..9cf8327 100644
@@ -654,8 +654,8 @@ enum {
 #define MAS0_ATSEL_TLB     0
 #define MAS0_ATSEL_LRAT    MAS0_ATSEL
 
-#define MAS1_TSIZE_SHIFT   8
-#define MAS1_TSIZE_MASK    (0xf << MAS1_TSIZE_SHIFT)
+#define MAS1_TSIZE_SHIFT   7
+#define MAS1_TSIZE_MASK    (0x1f << MAS1_TSIZE_SHIFT)
 
 #define MAS1_TS_SHIFT      12
 #define MAS1_TS            (1 << MAS1_TS_SHIFT)
target-ppc/helper.c +3 -2
index 176128a..892c6e3 100644
@@ -1293,7 +1293,7 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
 {
     uint32_t tlbncfg;
     int tlbn = booke206_tlbm_to_tlbn(env, tlb);
-    target_phys_addr_t tlbm_size;
+    int tlbm_size;
 
     tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
 
@@ -1301,9 +1301,10 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
         tlbm_size = (tlb->mas1 & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT;
     } else {
         tlbm_size = (tlbncfg & TLBnCFG_MINSIZE) >> TLBnCFG_MINSIZE_SHIFT;
+        tlbm_size <<= 1;
     }
 
-    return (1 << (tlbm_size << 1)) << 10;
+    return 1024ULL << tlbm_size;
 }
 
 /* TLB check function for MAS based SoftTLBs */
Signature · 1 line
1.7.4.1
#4 lore raw

Re: [Qemu-devel] [PATCH 3/4] ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages

Hi Scott,

I'm a little bit late, but this patch is not compatible with e500.

In fact all the modification breaks e500v2 MMU support. What kind PPC core are you working on?

Regards,

Quoted 68 lines · Scott Wood

This definition is backward compatible with MAV=1.0 as long as the guest does not set reserved bits in MAS1/MAS4.

Also, fix the shift in booke206_tlb_to_page_size -- it's the base that should be able to hold a 4G page size, not the shift count.

---
Unchanged in patchset v2

 hw/ppce500_mpc8544ds.c |    2 +-
 target-ppc/cpu.h       |    4 ++--
 target-ppc/helper.c    |    5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
hw/ppce500_mpc8544ds.c +1 -1
index 3626e26..1aed612 100644
@@ -187,7 +187,7 @@ out:
 /* Create -kernel TLB entries for BookE, linearly spanning 256MB.  */
 static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size)
 {
-    return (ffs(size >> 10) - 1) >> 1;
+    return ffs(size >> 10) - 1;
 }
 
 static void mmubooke_create_initial_mapping(CPUState *env,
target-ppc/cpu.h +2 -2
index f8bf2b1..9cf8327 100644
@@ -654,8 +654,8 @@ enum {
 #define MAS0_ATSEL_TLB     0
 #define MAS0_ATSEL_LRAT    MAS0_ATSEL
 
-#define MAS1_TSIZE_SHIFT   8
-#define MAS1_TSIZE_MASK    (0xf << MAS1_TSIZE_SHIFT)
+#define MAS1_TSIZE_SHIFT   7
+#define MAS1_TSIZE_MASK    (0x1f << MAS1_TSIZE_SHIFT)
 
 #define MAS1_TS_SHIFT      12
 #define MAS1_TS            (1 << MAS1_TS_SHIFT)
target-ppc/helper.c +3 -2
index 176128a..892c6e3 100644
@@ -1293,7 +1293,7 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
 {
     uint32_t tlbncfg;
     int tlbn = booke206_tlbm_to_tlbn(env, tlb);
-    target_phys_addr_t tlbm_size;
+    int tlbm_size;
 
     tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
 
@@ -1301,9 +1301,10 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
         tlbm_size = (tlb->mas1 & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT;
     } else {
         tlbm_size = (tlbncfg & TLBnCFG_MINSIZE) >> TLBnCFG_MINSIZE_SHIFT;
+        tlbm_size <<= 1;
     }
 
-    return (1 << (tlbm_size << 1)) << 10;
+    return 1024ULL << tlbm_size;
 }
 
 /* TLB check function for MAS based SoftTLBs */
Signature · 1 line
Fabien Chouteau
#5 lore raw

Re: [Qemu-devel] [PATCH 3/4] ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages

Hi Fabien,

Could you please elaborate a bit on the case that broke for you with these? The patches shouldn't change any guest facing behavior :o.

Alex

Quoted 82 lines · Fabien Chouteau

Hi Scott,

I'm a little bit late, but this patch is not compatible with e500.

In fact all the modification breaks e500v2 MMU support. What kind PPC core are you working on?

Regards,

Quoted 68 lines · Scott Wood

This definition is backward compatible with MAV=1.0 as long as the guest does not set reserved bits in MAS1/MAS4.

Also, fix the shift in booke206_tlb_to_page_size -- it's the base that should be able to hold a 4G page size, not the shift count.

---
Unchanged in patchset v2

hw/ppce500_mpc8544ds.c |    2 +-
target-ppc/cpu.h       |    4 ++--
target-ppc/helper.c    |    5 +++--
3 files changed, 6 insertions(+), 5 deletions(-)
hw/ppce500_mpc8544ds.c +1 -1
index 3626e26..1aed612 100644
@@ -187,7 +187,7 @@ out:
 /* Create -kernel TLB entries for BookE, linearly spanning 256MB.  */
 static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size)
 {
-    return (ffs(size >> 10) - 1) >> 1;
+    return ffs(size >> 10) - 1;
 }
 
 static void mmubooke_create_initial_mapping(CPUState *env,
target-ppc/cpu.h +2 -2
index f8bf2b1..9cf8327 100644
@@ -654,8 +654,8 @@ enum {
 #define MAS0_ATSEL_TLB     0
 #define MAS0_ATSEL_LRAT    MAS0_ATSEL
 
-#define MAS1_TSIZE_SHIFT   8
-#define MAS1_TSIZE_MASK    (0xf << MAS1_TSIZE_SHIFT)
+#define MAS1_TSIZE_SHIFT   7
+#define MAS1_TSIZE_MASK    (0x1f << MAS1_TSIZE_SHIFT)
 
 #define MAS1_TS_SHIFT      12
 #define MAS1_TS            (1 << MAS1_TS_SHIFT)
target-ppc/helper.c +3 -2
index 176128a..892c6e3 100644
@@ -1293,7 +1293,7 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
 {
    uint32_t tlbncfg;
    int tlbn = booke206_tlbm_to_tlbn(env, tlb);
-    target_phys_addr_t tlbm_size;
+    int tlbm_size;
 
    tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
 
@@ -1301,9 +1301,10 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
        tlbm_size = (tlb->mas1 & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT;
    } else {
        tlbm_size = (tlbncfg & TLBnCFG_MINSIZE) >> TLBnCFG_MINSIZE_SHIFT;
+        tlbm_size <<= 1;
    }
 
-    return (1 << (tlbm_size << 1)) << 10;
+    return 1024ULL << tlbm_size;
 }
 
 /* TLB check function for MAS based SoftTLBs */
Signature · 1 line
Fabien Chouteau
#6 lore raw

Re: [Qemu-devel] [PATCH 3/4] ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages

Am 07.05.2012 18:28, schrieb Alexander Graf:

Quoted 82 lines

Hi Fabien,

Could you please elaborate a bit on the case that broke for you with these? The patches shouldn't change any guest facing behavior :o.

Alex

Quoted 73 lines · Fabien Chouteau

Hi Scott,

I'm a little bit late, but this patch is not compatible with e500.

In fact all the modification breaks e500v2 MMU support. What kind PPC core are you working on?

Regards,

Quoted 63 lines · Scott Wood

This definition is backward compatible with MAV=1.0 as long as the guest does not set reserved bits in MAS1/MAS4.

Also, fix the shift in booke206_tlb_to_page_size -- it's the base that should be able to hold a 4G page size, not the shift count.

---
Unchanged in patchset v2

hw/ppce500_mpc8544ds.c |    2 +-
target-ppc/cpu.h       |    4 ++--
target-ppc/helper.c    |    5 +++--
3 files changed, 6 insertions(+), 5 deletions(-)
hw/ppce500_mpc8544ds.c +1 -1
index 3626e26..1aed612 100644
@@ -187,7 +187,7 @@ out:
 /* Create -kernel TLB entries for BookE, linearly spanning 256MB.  */
 static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size)
 {
-    return (ffs(size >> 10) - 1) >> 1;
+    return ffs(size >> 10) - 1;
 }
 
 static void mmubooke_create_initial_mapping(CPUState *env,
target-ppc/cpu.h +2 -2
index f8bf2b1..9cf8327 100644
@@ -654,8 +654,8 @@ enum {
 #define MAS0_ATSEL_TLB     0
 #define MAS0_ATSEL_LRAT    MAS0_ATSEL
 
-#define MAS1_TSIZE_SHIFT   8
-#define MAS1_TSIZE_MASK    (0xf << MAS1_TSIZE_SHIFT)
+#define MAS1_TSIZE_SHIFT   7
+#define MAS1_TSIZE_MASK    (0x1f << MAS1_TSIZE_SHIFT)
 
 #define MAS1_TS_SHIFT      12
 #define MAS1_TS            (1 << MAS1_TS_SHIFT)
target-ppc/helper.c +2 -1
index 176128a..892c6e3 100644
@@ -1293,7 +1293,7 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
 {
    uint32_t tlbncfg;
    int tlbn = booke206_tlbm_to_tlbn(env, tlb);
-    target_phys_addr_t tlbm_size;
+    int tlbm_size;
 
    tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
 
@@ -1301,9 +1301,10 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
        tlbm_size = (tlb->mas1 & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT;
    } else {
        tlbm_size = (tlbncfg & TLBnCFG_MINSIZE) >> TLBnCFG_MINSIZE_SHIFT;
+        tlbm_size <<= 1;
    }
 
Quoted 2 lines
Quoted 2 lines

target-ppc/helper.c target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb) · line 1307

Quoted 2 lines
target-ppc/helper.c +1 -1
-    return (1 << (tlbm_size << 1)) << 10;
+    return 1024ULL << tlbm_size;

Here the page size changes, doesn't it? The << 1 shift is only happening in the else branch whereas it was always done before.

Andreas

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
target-ppc/helper.c +0 -0
 }
 
 /* TLB check function for MAS based SoftTLBs */
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#7 lore raw

Re: [Qemu-devel] [PATCH 3/4] ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages

In reply to Alexander Graf
Quoted 5 lines · Alexander Graf

Hi Fabien,

Could you please elaborate a bit on the case that broke for you with these? The patches shouldn't change any guest facing behavior :o.

My bad,

The problem comes from my initialization of tlb entries at board reset. I use MAS1_TSIZE_SHIFT:

    size = 0x1 << MAS1_TSIZE_SHIFT; /* 4 KBytes */

but since the definition as changed, the value is incorrect. It should be:

    size = 0x10 << MAS1_TSIZE_SHIFT; /* 4 KBytes */

Sorry for the noise...

Quoted 87 lines

Alex

Quoted 82 lines · Fabien Chouteau

Hi Scott,

I'm a little bit late, but this patch is not compatible with e500.

In fact all the modification breaks e500v2 MMU support. What kind PPC core are you working on?

Regards,

Quoted 68 lines · Scott Wood

This definition is backward compatible with MAV=1.0 as long as the guest does not set reserved bits in MAS1/MAS4.

Also, fix the shift in booke206_tlb_to_page_size -- it's the base that should be able to hold a 4G page size, not the shift count.

---
Unchanged in patchset v2

hw/ppce500_mpc8544ds.c |    2 +-
target-ppc/cpu.h       |    4 ++--
target-ppc/helper.c    |    5 +++--
3 files changed, 6 insertions(+), 5 deletions(-)
hw/ppce500_mpc8544ds.c +1 -1
index 3626e26..1aed612 100644
@@ -187,7 +187,7 @@ out:
 /* Create -kernel TLB entries for BookE, linearly spanning 256MB.  */
 static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size)
 {
-    return (ffs(size >> 10) - 1) >> 1;
+    return ffs(size >> 10) - 1;
 }
 
 static void mmubooke_create_initial_mapping(CPUState *env,
target-ppc/cpu.h +2 -2
index f8bf2b1..9cf8327 100644
@@ -654,8 +654,8 @@ enum {
 #define MAS0_ATSEL_TLB     0
 #define MAS0_ATSEL_LRAT    MAS0_ATSEL
 
-#define MAS1_TSIZE_SHIFT   8
-#define MAS1_TSIZE_MASK    (0xf << MAS1_TSIZE_SHIFT)
+#define MAS1_TSIZE_SHIFT   7
+#define MAS1_TSIZE_MASK    (0x1f << MAS1_TSIZE_SHIFT)
 
 #define MAS1_TS_SHIFT      12
 #define MAS1_TS            (1 << MAS1_TS_SHIFT)
target-ppc/helper.c +3 -2
index 176128a..892c6e3 100644
@@ -1293,7 +1293,7 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
 {
    uint32_t tlbncfg;
    int tlbn = booke206_tlbm_to_tlbn(env, tlb);
-    target_phys_addr_t tlbm_size;
+    int tlbm_size;
 
    tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
 
@@ -1301,9 +1301,10 @@ target_phys_addr_t booke206_tlb_to_page_size(CPUState *env, ppcmas_tlb_t *tlb)
        tlbm_size = (tlb->mas1 & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT;
    } else {
        tlbm_size = (tlbncfg & TLBnCFG_MINSIZE) >> TLBnCFG_MINSIZE_SHIFT;
+        tlbm_size <<= 1;
    }
 
-    return (1 << (tlbm_size << 1)) << 10;
+    return 1024ULL << tlbm_size;
 }
 
 /* TLB check function for MAS based SoftTLBs */
Signature · 1 line
Fabien Chouteau
Signature · 1 line
Fabien Chouteau
author
#8 lore raw

Re: [Qemu-devel] [PATCH 3/4] ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages

Quoted 12 lines · Fabien Chouteau
Quoted 5 lines · Alexander Graf

Hi Fabien,

Could you please elaborate a bit on the case that broke for you with these? The patches shouldn't change any guest facing behavior :o.

My bad,

The problem comes from my initialization of tlb entries at board reset. I use MAS1_TSIZE_SHIFT:

Quoted 6 lines
    size = 0x1 << MAS1_TSIZE_SHIFT; /* 4 KBytes */

but since the definition as changed, the value is incorrect. It should be:

    size = 0x10 << MAS1_TSIZE_SHIFT; /* 4 KBytes */

You should be using booke206_bytes_to_tsize(), or perhaps create some #defines for the various tsizes.

-Scott

#9 lore raw

Re: [Qemu-devel] [PATCH 3/4] ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages

Quoted 15 lines · Scott Wood
Quoted 14 lines · Fabien Chouteau
Quoted 5 lines · Alexander Graf

Hi Fabien,

Could you please elaborate a bit on the case that broke for you with these? The patches shouldn't change any guest facing behavior :o.

My bad,

The problem comes from my initialization of tlb entries at board reset. I use MAS1_TSIZE_SHIFT:

    size = 0x1 << MAS1_TSIZE_SHIFT; /* 4 KBytes */
Quoted 8 lines
Quoted 4 lines

but since the definition as changed, the value is incorrect. It should be:

    size = 0x10 << MAS1_TSIZE_SHIFT; /* 4 KBytes */

You should be using booke206_bytes_to_tsize(), or perhaps create some #defines for the various tsizes.

Do you mean booke206_page_size_to_tlb()?

BTW, this function is defined locally twice and with different implementations.

hw/ppce500_mpc8544ds.c:176:static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size) hw/ppce500_mpc8544ds.c-177-{
hw/ppce500_mpc8544ds.c-178- return ffs(size >> 10) - 1;
hw/ppce500_mpc8544ds.c-179-}
--
hw/ppce500_spin.c:71:static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size) hw/ppce500_spin.c-72-{
hw/ppce500_spin.c-73- return (ffs(size >> 10) - 1) >> 1;
hw/ppce500_spin.c-74-}

Signature · 1 line
Fabien Chouteau
author
#10 lore raw

Re: [Qemu-devel] [PATCH 3/4] ppc: booke206: use MAV=2.0 TSIZE definition, fix 4G pages

Quoted 19 lines · Fabien Chouteau
Quoted 18 lines · Scott Wood
Quoted 17 lines · Fabien Chouteau
Quoted 5 lines · Alexander Graf

Hi Fabien,

Could you please elaborate a bit on the case that broke for you with these? The patches shouldn't change any guest facing behavior :o.

My bad,

The problem comes from my initialization of tlb entries at board reset. I use MAS1_TSIZE_SHIFT:

    size = 0x1 << MAS1_TSIZE_SHIFT; /* 4 KBytes */

but since the definition as changed, the value is incorrect. It should be:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line
    size = 0x10 << MAS1_TSIZE_SHIFT; /* 4 KBytes */

You should be using booke206_bytes_to_tsize(), or perhaps create some #defines for the various tsizes.

Do you mean booke206_page_size_to_tlb()?

No, I was referring to something on an internal branch, sorry.

-Scott

author
#11 lore raw

PATCH v2 4/4 ppc: booke206: add "info tlb" support

In reply to Scott Wood

---
v2: Remove redundant "valid?" comment

 hmp-commands.hx     |    2 +-
 monitor.c           |    5 ++-
 target-ppc/cpu.h    |    2 +
 target-ppc/helper.c |   88 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 94 insertions(+), 3 deletions(-)
hmp-commands.hx +1 -1
index 6ad8806..014a4fb 100644
@@ -1306,7 +1306,7 @@ show i8259 (PIC) state
 @item info pci
 show emulated PCI device info
 @item info tlb
-show virtual to physical memory mappings (i386, SH4 and SPARC only)
+show virtual to physical memory mappings (i386, SH4, SPARC, and PPC only)
 @item info mem
 show the active virtual memory mappings (i386 only)
 @item info jit
monitor.c +3 -2
index 67ceb46..7b9c2b1 100644
@@ -2408,7 +2408,7 @@ static void tlb_info(Monitor *mon)
 
 #endif
 
-#if defined(TARGET_SPARC)
+#if defined(TARGET_SPARC) || defined(TARGET_PPC)
 static void tlb_info(Monitor *mon)
 {
     CPUState *env1 = mon_get_cpu();
@@ -2901,7 +2901,8 @@ static const mon_cmd_t info_cmds[] = {
         .user_print = do_pci_info_print,
         .mhandler.info_new = do_pci_info,
     },
-#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC)
+#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
+    defined(TARGET_PPC)
     {
         .name       = "tlb",
         .args_type  = "",
target-ppc/cpu.h +2 -0
index 9cf8327..0d04779 100644
@@ -2032,4 +2032,6 @@ static inline void cpu_pc_from_tb(CPUState *env, TranslationBlock *tb)
     env->nip = tb->pc;
 }
 
+void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUState *env);
+
 #endif /* !defined (__CPU_PPC_H__) */
target-ppc/helper.c +88 -0

94 lines not on this page · raw message

Signature · 1 line
1.7.4.1