Skip to contentSkip to conversation

ppc: booke206: KVM MMU API and info tlb

PATCH Superseded Scott Wood 5 participants 15 messages Jun 17, 2011 – Jul 6, 2011

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Scott Wood

author
#0 lore raw

cover ppc: booke206: KVM MMU API and info tlb

This depends on these qemu patches:
http://patchwork.ozlabs.org/patch/100826/
(PPC: E500: Use MAS registers instead of internal TLB representation)
http://patchwork.ozlabs.org/patch/100821/
(PPC: move TLBs to their own arrays)

For this functionality to work with KVM, this kernel patch is required:
http://www.spinics.net/lists/kvm-ppc/msg02843.html

Scott Wood (3):
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 ++-
 monitor.c              |    5 ++-
 target-ppc/cpu.h       |    8 +++-
 target-ppc/helper.c    |   94 ++++++++++++++++++++++++++++++++++++++++++++++-
 target-ppc/kvm.c       |   85 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 190 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.4.1
author
#1 lore raw

PATCH 1/3 kvm: ppc: booke206: use MMU API

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.

---
 hw/ppce500_mpc8544ds.c |    2 +
 target-ppc/cpu.h       |    2 +
 target-ppc/kvm.c       |   85 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 0 deletions(-)
hw/ppce500_mpc8544ds.c +2 -0
index 5ac8843..3cdeb43 100644
@@ -192,6 +192,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 46d86be..8191ed2 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 +85 -0

109 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] kvm: ppc: booke206: use MMU API

Quoted 42 lines · 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.

---

hw/ppce500_mpc8544ds.c |    2 +
target-ppc/cpu.h       |    2 +
target-ppc/kvm.c       |   85 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 89 insertions(+), 0 deletions(-)
hw/ppce500_mpc8544ds.c +2 -0
index 5ac8843..3cdeb43 100644
@@ -192,6 +192,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 46d86be..8191ed2 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 +0 -0
index e7b1b10..9a88fc9 100644

target-ppc/kvm.c static int kvm_arch_sync_sregs(CPUState *cenv) · line 127

Quoted 6 lines
target-ppc/kvm.c +3 -0
@@ -122,6 +122,51 @@ static int kvm_arch_sync_sregs(CPUState *cenv)
    return kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs);
 }
 
+static int kvm_booke206_tlb_init(CPUState *env)
+{
+#if defined(KVM_CAP_SW_TLB) && defined(KVM_MMU_FSL_BOOKE_NOHV)

Those hopefully shouldn't be required anymore soon - when Jan's patches make it upstream. Jan, how's progress on that front?

target-ppc/kvm.c static int kvm_arch_sync_sregs(CPUState *cenv) · line 128

Quoted 1 line
target-ppc/kvm.c +1 -0
+    struct kvm_book3e_206_tlb_params params = {};

Hrm - I'm not familiar with that initialization. What exactly does it do? Set the struct contents to 0? Is this properly standardized? Usually, I see memset(0)s for that.

target-ppc/kvm.c static int kvm_arch_sync_sregs(CPUState *cenv) · line 139

Quoted 11 lines
target-ppc/kvm.c +11 -0
+    struct kvm_config_tlb cfg = {};
+    size_t array_len;
+    unsigned int entries = 0;
+    int ret, i;
+
+    if (!kvm_enabled() ||
+        !kvm_check_extension(env->kvm_state, KVM_CAP_SW_TLB)) {
+        return 0;
+    }
+
+    for (i = 0; i < ARRAY_SIZE(params.tlb_sizes); i++) {

Please make this MAX(..., BOOKE206_MAX_TLBN) - I'd hope the compiler is clever enough to figure out we're dealing with a constant here and that way the code looks more secure (even though it's the same in practice).

Alternatively, you could just do an assert(... == BOOKE206_MAX_TLBN); before.

target-ppc/kvm.c static int kvm_arch_sync_sregs(CPUState *cenv) · line 148

Quoted 9 lines
target-ppc/kvm.c +9 -0
+        params.tlb_sizes[i] = booke206_tlb_size(env, i);
+        params.tlb_ways[i] = booke206_tlb_ways(env, i);
+        entries += params.tlb_sizes[i];
+    }
+
+    if (entries != env->nb_tlb) {
+        cpu_abort(env, "%s: nb_tlb mismatch\n", __func__);
+    }
+

assert(sizeof(struct kvm_book3e_206_tlb_entry) == sizeof(ppcmas_tlb_t));

Quoted 25 lines
target-ppc/kvm.c +21 -0
+    array_len = sizeof(struct kvm_book3e_206_tlb_entry) * entries;
+    env->tlb_dirty = true;
+
+    cfg.array = (uintptr_t)env->tlb.tlbm;
+    cfg.array_len = sizeof(ppcmas_tlb_t) * entries;
+    cfg.params = (uintptr_t)&params;
+    cfg.mmu_type = KVM_MMU_FSL_BOOKE_NOHV;
+
+    ret = kvm_vcpu_ioctl(env, KVM_CONFIG_TLB, &cfg);
+    if (ret < 0) {
+        fprintf(stderr, "%s: couldn't KVM_CONFIG_TLB: %s\n",
+                __func__, strerror(-ret));
+        return ret;
+    }
+
+    env->kvm_sw_tlb = true;
+#endif
+
+    return 0;
+}
+
 int kvm_arch_init_vcpu(CPUState *cenv)
 {
    int ret;

target-ppc/kvm.c int kvm_arch_init_vcpu(CPUState *cenv) · line 180

Quoted 3 lines
target-ppc/kvm.c +0 -0
@@ -133,6 +178,14 @@ int kvm_arch_init_vcpu(CPUState *cenv)
 
    idle_timer = qemu_new_timer_ns(vm_clock, kvm_kick_env, cenv);
 

Please add a comment here, explaining the occasional reader what we're doing here

Quoted 12 lines
target-ppc/kvm.c +8 -0
+    switch (cenv->mmu_model) {
+    case POWERPC_MMU_BOOKE206:
+        ret = kvm_booke206_tlb_init(cenv);
+        break;
+    default:
+        break;
+    }
+
    return ret;
 }
 

target-ppc/kvm.c void kvm_arch_reset_vcpu(CPUState *env) · line 198

Quoted 6 lines
target-ppc/kvm.c +3 -0
@@ -140,6 +193,33 @@ void kvm_arch_reset_vcpu(CPUState *env)
 {
 }
 
+static void kvm_sw_tlb_put(CPUState *env)
+{
+#if defined(KVM_CAP_SW_TLB)

See above

target-ppc/kvm.c void kvm_arch_reset_vcpu(CPUState *env) · line 211

Quoted 13 lines
target-ppc/kvm.c +13 -0
+    struct kvm_dirty_tlb dirty_tlb;
+    unsigned char *bitmap;
+    int ret;
+
+    if (!env->kvm_sw_tlb) {
+        return;
+    }
+
+    bitmap = qemu_malloc((env->nb_tlb + 7) / 8);
+    memset(bitmap, 0xFF, (env->nb_tlb + 7) / 8);
+
+    dirty_tlb.bitmap = (uintptr_t)bitmap;
+    dirty_tlb.num_dirty = env->nb_tlb;

Pretty simple for now, but I like the idea of starting simple :). Would it make sense to keep the bitmap allocated throughout the lifetime of env?

Alex

#3 lore raw

Re: [Qemu-devel] [PATCH 1/3] kvm: ppc: booke206: use MMU API

Quoted 3 lines · Alexander Graf
Quoted 1 line
Quoted 1 line

+ struct kvm_book3e_206_tlb_params params = {};

Hrm - I'm not familiar with that initialization. What exactly does it do? Set the struct contents to 0? Is this properly standardized?

Yes and yes.

r~

#4 lore raw

Re: [Qemu-devel] [PATCH 1/3] kvm: ppc: booke206: use MMU API

Quoted 6 lines · Richard Henderson
Quoted 3 lines · Alexander Graf
Quoted 1 line
Quoted 1 line

+ struct kvm_book3e_206_tlb_params params = {};

Hrm - I'm not familiar with that initialization. What exactly does it do? Set the struct contents to 0? Is this properly standardized?

Yes and yes.

Ah, very nice. I wonder why I don't see it used more in code then :). Seems to be very handy to not clutter code with memset(0)s.

Alex

#5 lore raw

Re: [Qemu-devel] [PATCH 1/3] kvm: ppc: booke206: use MMU API

In reply to Alexander Graf
Quoted 48 lines · Alexander Graf
Quoted 45 lines · 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.

---

hw/ppce500_mpc8544ds.c |    2 +
target-ppc/cpu.h       |    2 +
target-ppc/kvm.c       |   85 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 89 insertions(+), 0 deletions(-)
hw/ppce500_mpc8544ds.c +2 -0
index 5ac8843..3cdeb43 100644
@@ -192,6 +192,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 46d86be..8191ed2 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 +0 -0
index e7b1b10..9a88fc9 100644
@@ -122,6 +122,51 @@ static int kvm_arch_sync_sregs(CPUState *cenv)
    return kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs);
 }
 
Quoted 5 lines

target-ppc/kvm.c static int kvm_arch_sync_sregs(CPUState *cenv) · line 127

Quoted 3 lines
target-ppc/kvm.c +3 -0
+static int kvm_booke206_tlb_init(CPUState *env)
+{
+#if defined(KVM_CAP_SW_TLB) && defined(KVM_MMU_FSL_BOOKE_NOHV)

Those hopefully shouldn't be required anymore soon - when Jan's patches make it upstream. Jan, how's progress on that front?

I can only forward this question: Avi, what are the plans for
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/73917?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#6 lore raw

Re: [Qemu-devel] [PATCH 1/3] kvm: ppc: booke206: use MMU API

Quoted 5 lines · Jan Kiszka
Quoted 2 lines

Those hopefully shouldn't be required anymore soon - when Jan's patches make it upstream. Jan, how's progress on that front?

I can only forward this question: Avi, what are the plans for
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/73917?

Will apply once all comments are addressed.

Signature · 1 line
error compiling committee.c: too many arguments to function
#7 lore raw

Re: [Qemu-devel] [PATCH 1/3] kvm: ppc: booke206: use MMU API

Quoted 8 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
Quoted 2 lines

Those hopefully shouldn't be required anymore soon - when Jan's patches make it upstream. Jan, how's progress on that front?

I can only forward this question: Avi, what are the plans for
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/73917?

Will apply once all comments are addressed.

Well, then go ahead :) - or did I miss a comment?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#8 lore raw

Re: [Qemu-devel] [PATCH 1/3] kvm: ppc: booke206: use MMU API

Quoted 11 lines · Jan Kiszka
Quoted 8 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
Quoted 2 lines

Those hopefully shouldn't be required anymore soon - when Jan's patches make it upstream. Jan, how's progress on that front?

I can only forward this question: Avi, what are the plans for
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/73917?

Will apply once all comments are addressed.

Well, then go ahead :) - or did I miss a comment?

If everyone's happy I (or rather Marcelo this week) will be happy to apply.

Signature · 1 line
error compiling committee.c: too many arguments to function
author
#9 lore raw

PATCH 2/3 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.

---
I ran into this when converting the info tlb patch to use the symbolic MAS defines -- figured it would be better to add support for this element of MAV=2.0 rather than remove it from "info tlb".

 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 3cdeb43..a5e9378 100644
@@ -177,7 +177,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 8191ed2..5d80b1b 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 4e9b98a..5d007c5 100644
@@ -1278,7 +1278,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];
 
@@ -1286,9 +1286,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
author
#10 lore raw

PATCH 3/3 ppc: booke206: add "info tlb" support

In reply to Scott Wood
---
 hmp-commands.hx     |    2 +-
 monitor.c           |    5 ++-
 target-ppc/cpu.h    |    2 +
 target-ppc/helper.c |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 95 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 6af6a4d..68e94af 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 5d80b1b..48f7e2c 100644
@@ -2020,4 +2020,6 @@ static inline ppcmas_tlb_t *booke206_get_tlbm(CPUState *env, const int tlbn,
 
 extern void (*cpu_ppc_hypercall)(CPUState *);
 
+void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUState *env);
+
 #endif /* !defined (__CPU_PPC_H__) */
target-ppc/helper.c +89 -0

95 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#11 lore raw

Re: [Qemu-devel] [PATCH 3/3] ppc: booke206: add "info tlb" support

Quoted 82 lines · Scott Wood

---

hmp-commands.hx     |    2 +-
monitor.c           |    5 ++-
target-ppc/cpu.h    |    2 +
target-ppc/helper.c |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 95 insertions(+), 3 deletions(-)
hmp-commands.hx +0 -0
index 6ad8806..014a4fb 100644
@@ -1306,7 +1306,7 @@ show i8259 (PIC) state

@item info pci
show emulated PCI device info
@item info tlb

hmp-commands.hx +1 -1
-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 6af6a4d..68e94af 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 5d80b1b..48f7e2c 100644
@@ -2020,4 +2020,6 @@ static inline ppcmas_tlb_t *booke206_get_tlbm(CPUState *env, const int tlbn,
 
 extern void (*cpu_ppc_hypercall)(CPUState *);
 
+void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUState *env);
+
 #endif /* !defined (__CPU_PPC_H__) */
target-ppc/helper.c +19 -0
index 5d007c5..e22b1cb 100644
@@ -1451,6 +1451,95 @@ found_tlb:
    return ret;
 }
 
+static const char *book3e_tsize_to_str[32] = {
+    "1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K",
+    "1M", "2M", "4M", "8M", "16M", "32M", "64M", "128M", "256M", "512M",
+    "1G", "2G", "4G", "8G", "16G", "32G", "64G", "128G", "256G", "512G",
+    "1T", "2T"
+};
+
+static void mmubooke206_dump_one_tlb(FILE *f, fprintf_function cpu_fprintf,
+                                     CPUState *env, int tlbn, int offset,
+                                     int tlbsize)
+{
+    ppcmas_tlb_t *entry;
+    int i;
+
+    cpu_fprintf(f, "\nTLB%d:\n", tlbn);
+    cpu_fprintf(f, "Effective          Physical           Size TID   TS SRWX URWX WIMGE U0123\n");
+
+    entry = &env->tlb.tlbm[offset];
+    for (i = 0; i < tlbsize; i++, entry++) {

target-ppc/helper.c found_tlb: · line 1482

Quoted 10 lines
target-ppc/helper.c +10 -0
+        target_phys_addr_t ea, pa, size;
+        int tsize;
+
+        /* valid? */
+        if (!(entry->mas1 & MAS1_VALID)) {
+            continue;
+        }
+
+        tsize = (entry->mas1 & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT;
+        size = 1024ULL << tsize;

Isn't that what booke206_tlb_to_page_size() is there for? Hrm - but you still need tsize. I see. Fair enough - I can't think of a cleaner way atm either.

Alex

#12 lore raw
In reply to Scott Wood
Quoted 8 lines · Scott Wood

This depends on these qemu patches:
http://patchwork.ozlabs.org/patch/100826/
(PPC: E500: Use MAS registers instead of internal TLB representation)
http://patchwork.ozlabs.org/patch/100821/
(PPC: move TLBs to their own arrays)

For this functionality to work with KVM, this kernel patch is required:
http://www.spinics.net/lists/kvm-ppc/msg02843.html

Could you please resend without the #ifdefs? Jan's patches that get rid of the host kernel header dependencies finally got merged :). Please also execute his header update script in scripts/ with the MMU API patch applied.

Alex

author
#13 lore raw
Quoted 9 lines · On Wed, 6 Jul 2011 18:38:04 +0200 Alexander Graf <[email protected]> wrote:
Quoted 6 lines · Scott Wood

This depends on these qemu patches:
http://patchwork.ozlabs.org/patch/100826/
(PPC: E500: Use MAS registers instead of internal TLB representation)
http://patchwork.ozlabs.org/patch/100821/
(PPC: move TLBs to their own arrays)

Quoted 4 lines
Quoted 2 lines

For this functionality to work with KVM, this kernel patch is required:
http://www.spinics.net/lists/kvm-ppc/msg02843.html

Could you please resend without the #ifdefs? Jan's patches that get rid of the host kernel header dependencies finally got merged :). Please also execute his header update script in scripts/ with the MMU API patch applied.

Yes, I'll try to respin today.

-Scott

author
#14 lore raw
Quoted 12 lines · On Wed, 6 Jul 2011 11:45:47 -0500 Scott Wood <[email protected]> wrote:
Quoted 9 lines · On Wed, 6 Jul 2011 18:38:04 +0200 Alexander Graf <[email protected]> wrote:
Quoted 6 lines · Scott Wood

This depends on these qemu patches:
http://patchwork.ozlabs.org/patch/100826/
(PPC: E500: Use MAS registers instead of internal TLB representation)
http://patchwork.ozlabs.org/patch/100821/
(PPC: move TLBs to their own arrays)

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

For this functionality to work with KVM, this kernel patch is required:
http://www.spinics.net/lists/kvm-ppc/msg02843.html

Could you please resend without the #ifdefs? Jan's patches that get rid of the host kernel header dependencies finally got merged :). Please also execute his header update script in scripts/ with the MMU API patch applied.

Yes, I'll try to respin today.

I got bogged down trying to fix some issues on the kernel side, relating to page reference tracking, that will get worse when qemu can change the geometry. Don't apply the current kernel patch. I'll have respins of both the kernel and qemu patches soon -- but not today. :-)

-Scott