Skip to contentSkip to conversation

PPC: Add FSL (e500) MMU emulation v4

PATCH In review Alexander Graf 3 participants 15 messages May 6, 2011 – May 9, 2011

lore
Share & tools
lore
#1 lore raw

PATCH 1/7 PPC: Make MPC8544DS obey -cpu switch

In reply to Alexander Graf

The MPC8544DS board emulation code ignored the user defined -cpu switch. This patch enables it to only provide a sane default, not force an e500v2 CPU inside.

---
 hw/ppce500_mpc8544ds.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
hw/ppce500_mpc8544ds.c +5 -1
index e111dda..1b8a1c4 100644
@@ -178,7 +178,11 @@ static void mpc8544ds_init(ram_addr_t ram_size,
     qemu_irq *irqs, *mpic, *pci_irqs;
 
     /* Setup CPU */
-    env = cpu_ppc_init("e500v2_v30");
+    if (cpu_model == NULL) {
+        cpu_model = "e500v2_v30";
+    }
+
+    env = cpu_ppc_init(cpu_model);
     if (!env) {
         fprintf(stderr, "Unable to initialize CPU!\n");
         exit(1);
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/7 PPC: Add GS MSR definition

In reply to Alexander Graf

The BookE specification defines MSR bit 28 as Guest State. Add it to the list of MSR macros.

---
 target-ppc/cpu.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
target-ppc/cpu.h +2 -0
index 303f8ce..c6b2255 100644
@@ -420,6 +420,7 @@ struct ppc_slb_t {
 #define MSR_CM   31 /* Computation mode for BookE                     hflags */
 #define MSR_ICM  30 /* Interrupt computation mode for BookE                  */
 #define MSR_THV  29 /* hypervisor state for 32 bits PowerPC           hflags */
+#define MSR_GS   28 /* guest state for BookE                                 */
 #define MSR_UCLE 26 /* User-mode cache lock enable for BookE                 */
 #define MSR_VR   25 /* altivec available                            x hflags */
 #define MSR_SPE  25 /* SPE enable for BookE                         x hflags */
@@ -457,6 +458,7 @@ struct ppc_slb_t {
 #define msr_cm   ((env->msr >> MSR_CM)   & 1)
 #define msr_icm  ((env->msr >> MSR_ICM)  & 1)
 #define msr_thv  ((env->msr >> MSR_THV)  & 1)
+#define msr_gs   ((env->msr >> MSR_GS)   & 1)
 #define msr_ucle ((env->msr >> MSR_UCLE) & 1)
 #define msr_vr   ((env->msr >> MSR_VR)   & 1)
 #define msr_spe  ((env->msr >> MSR_SPE)  & 1)
Signature · 1 line
1.6.0.2
#11 lore raw

PATCH 6/7 PPC MPC7544DS: Use new TLB helper function

In reply to Alexander Graf

Now that we have some nice helpers that can find us a TLB entry, let's use that on the machine initialization code, so we don't need to know about the internals of the TLB array.

---
 hw/ppce500_mpc8544ds.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/ppce500_mpc8544ds.c +1 -1
index 44d6440..4120977 100644
@@ -179,7 +179,7 @@ static void mmubooke_create_initial_mapping(CPUState *env,
                                      target_ulong va,
                                      target_phys_addr_t pa)
 {
-    ppcemb_tlb_t *tlb = &env->tlb[512].tlbe;
+    ppcemb_tlb_t *tlb = booke206_get_tlbe(env, 1, 0, 0);
 
     tlb->attr = 0;
     tlb->prot = PAGE_VALID | ((PAGE_READ | PAGE_WRITE | PAGE_EXEC) << 4);
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/7 PPC: Make MPC8544DS emulation work w/o KVM

In reply to Alexander Graf

The MPC8544DS board emulation was only used with KVM so far, so some parts of the code didn't provide proper values for non-KVM execution.

This patch makes the machine work without KVM enabled. To actually use this, you also need proper e500v2 MMU emulation.

---

v2 -> v3:

- fix mpc initial tlb size comment
- enable cpu reset

---
 hw/ppce500_mpc8544ds.c |   86 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 71 insertions(+), 15 deletions(-)
hw/ppce500_mpc8544ds.c +71 -15
index 1b8a1c4..44d6440 100644
@@ -28,6 +28,7 @@
 #include "kvm_ppc.h"
 #include "device_tree.h"
 #include "openpic.h"
+#include "ppc.h"
 #include "ppce500.h"
 #include "loader.h"
 #include "elf.h"
@@ -50,6 +51,12 @@
 #define MPC8544_PCI_IO             0xE1000000
 #define MPC8544_PCI_IOLEN          0x10000
 
+static struct boot_info
+{
+    uint32_t dt_base;
+    uint32_t entry;
+} boot_info;
+
 #ifdef CONFIG_FDT
 static int mpc8544_copy_soc_cell(void *fdt, const char *node, const char *prop)
 {
@@ -82,7 +89,7 @@ static int mpc8544_load_device_tree(target_phys_addr_t addr,
 {
     int ret = -1;
 #ifdef CONFIG_FDT
-    uint32_t mem_reg_property[] = {0, ramsize};
+    uint32_t mem_reg_property[] = {0, cpu_to_be32(ramsize)};
     char *filename;
     int fdt_size;
     void *fdt;
@@ -103,15 +110,19 @@ static int mpc8544_load_device_tree(target_phys_addr_t addr,
     if (ret < 0)
         fprintf(stderr, "couldn't set /memory/reg\n");
 
-    ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start",
-                                    initrd_base);
-    if (ret < 0)
-        fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
+    if (initrd_size) {
+        ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start",
+                                        initrd_base);
+        if (ret < 0) {
+            fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
+        }
 
-    ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end",
-                                    (initrd_base + initrd_size));
-    if (ret < 0)
-        fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
+        ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end",
+                                        (initrd_base + initrd_size));
+        if (ret < 0) {
+            fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
+        }
+    }
 
     ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs",
                                       kernel_cmdline);
@@ -145,6 +156,13 @@ static int mpc8544_load_device_tree(target_phys_addr_t addr,
 
         mpc8544_copy_soc_cell(fdt, buf, "clock-frequency");
         mpc8544_copy_soc_cell(fdt, buf, "timebase-frequency");
+    } else {
+        const uint32_t freq = 400000000;
+
+        qemu_devtree_setprop_cell(fdt, "/cpus/PowerPC,8544@0",
+                                  "clock-frequency", freq);
+        qemu_devtree_setprop_cell(fdt, "/cpus/PowerPC,8544@0",
+                                  "timebase-frequency", freq);
     }
 
     ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
@@ -156,6 +174,35 @@ out:
     return ret;
 }
 
+/* Create -kernel TLB entries for BookE, linearly spanning 256MB.  */
+static void mmubooke_create_initial_mapping(CPUState *env,
+                                     target_ulong va,
+                                     target_phys_addr_t pa)
+{
+    ppcemb_tlb_t *tlb = &env->tlb[512].tlbe;
+
+    tlb->attr = 0;
+    tlb->prot = PAGE_VALID | ((PAGE_READ | PAGE_WRITE | PAGE_EXEC) << 4);
+    tlb->size = 256 * 1024 * 1024;
+    tlb->EPN = va & TARGET_PAGE_MASK;
+    tlb->RPN = pa & TARGET_PAGE_MASK;
+    tlb->PID = 0;
+}
+
+static void mpc8544ds_cpu_reset(void *opaque)
+{
+    CPUState *env = opaque;
+    struct boot_info *bi = env->load_info;
+
+    cpu_reset(env);
+
+    /* Set initial guest state. */
+    env->gpr[1] = (16<<20) - 8;
+    env->gpr[3] = bi->dt_base;
+    env->nip = bi->entry;
+    mmubooke_create_initial_mapping(env, 0, 0);
+}
+
 static void mpc8544ds_init(ram_addr_t ram_size,
                          const char *boot_device,
                          const char *kernel_filename,
@@ -188,6 +235,13 @@ static void mpc8544ds_init(ram_addr_t ram_size,
         exit(1);
     }
 
+    /* XXX register timer? */
+    ppc_emb_timers_init(env, 400000000, PPC_INTERRUPT_DECR);
+    ppc_dcr_init(env, NULL, NULL);
+
+    /* Register reset handler */
+    qemu_register_reset(mpc8544ds_cpu_reset, env);
+
     /* Fixup Memory size on a alignment boundary */
     ram_size &= ~(RAM_SIZES_ALIGN - 1);
 
@@ -265,6 +319,9 @@ static void mpc8544ds_init(ram_addr_t ram_size,
 
     /* If we're loading a kernel directly, we must load the device tree too. */
     if (kernel_filename) {
+#ifndef CONFIG_FDT
+        cpu_abort(env, "Compiled without FDT support - can't load kernel\n");
+#endif
         dt_base = (kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
         if (mpc8544_load_device_tree(dt_base, ram_size,
                     initrd_base, initrd_size, kernel_cmdline) < 0) {
@@ -272,15 +329,14 @@ static void mpc8544ds_init(ram_addr_t ram_size,
             exit(1);
         }
 
-        /* Set initial guest state. */
-        env->gpr[1] = (16<<20) - 8;
-        env->gpr[3] = dt_base;
-        env->nip = entry;
-        /* XXX we currently depend on KVM to create some initial TLB entries. */
+        boot_info.entry = entry;
+        boot_info.dt_base = dt_base;
     }
+    env->load_info = &boot_info;
 
-    if (kvm_enabled())
+    if (kvm_enabled()) {
         kvmppc_init();
+    }
 
     return;
 }
Signature · 1 line
1.6.0.2
#0 lore raw

cover PPC: Add FSL (e500) MMU emulation v4

In a global effort to get rid of KVM-only targets, this is the next important piece of the puzzle: e500 emulation :).

We had support for running an e500 KVM guest for a while now, but the code could not be tested without a real e500 machine, because it required KVM to work. This patchset adds emulation for the e500 MMU, enabling anyone to use the MPC8544DS emulation.

v1 -> v2:

- fix linux-user build
- optimize tlb invalidate & search

v2 -> v3:

- add qdev patch (enables -drive if=virtio)
- fix mpc initial tlb size comment
- enable cpu reset

v3 -> v4:

- remove tlb_nbs
- rename BOOKE_FSL to BOOKE206
- generalize implementation to be extensible for future MMUs
- check if tsize should be set
- check if iprot should be set
- set RPN on tlb miss
- implement tlb_invalidate_all
- use specific helper to set PIDs
- create generic booke206 tlb flushing function
- drop base_addr
- new patch: MPC7544DS: Use new TLB helper function

Alexander Graf (7):
PPC: Make MPC8544DS obey -cpu switch
PPC: Make MPC8544DS emulation work w/o KVM
PPC: Add GS MSR definition
PPC: Add another 64 bits to instruction feature mask
PPC: Implement e500 (FSL) MMU
PPC MPC7544DS: Use new TLB helper function
PPC: Qdev'ify e500 pci

 hw/ppce500_mpc8544ds.c      |   92 +++++++++++---
 hw/ppce500_pci.c            |  111 ++++++++++------
 target-ppc/cpu.h            |  307 ++++++++++++++++++++++++++++++++++++++++++-
 target-ppc/helper.c         |  277 +++++++++++++++++++++++++++++++--------
 target-ppc/helper.h         |    6 +
 target-ppc/op_helper.c      |  296 +++++++++++++++++++++++++++++++++++++++++
 target-ppc/translate.c      |  116 +++++++++++++++--
 target-ppc/translate_init.c |  282 ++++++++++++++++++++++++++++-----------
 8 files changed, 1282 insertions(+), 205 deletions(-)
#12 lore raw

PATCH 7/7 PPC: Qdev'ify e500 pci

The e500 PCI controller isn't qdev'ified yet. This leads to severe issues when running with -drive.

To be able to use a virtio disk with an e500 VM, let's convert the PCI controller over to qdev.

---

v2 -> v3:

- rebase to current code base
- fix endian issue
- use sysbus helpers

v3 -> v4:

- drop base_addr

---
 hw/ppce500_pci.c |  111 +++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 72 insertions(+), 39 deletions(-)
hw/ppce500_pci.c +72 -39
index 83a20e4..f3db0a7 100644
@@ -73,11 +73,10 @@ struct pci_inbound {
 };
 
 struct PPCE500PCIState {
+    PCIHostState pci_state;
     struct pci_outbound pob[PPCE500_PCI_NR_POBS];
     struct pci_inbound pib[PPCE500_PCI_NR_PIBS];
     uint32_t gasket_time;
-    PCIHostState pci_state;
-    PCIDevice *pci_dev;
 };
 
 typedef struct PPCE500PCIState PPCE500PCIState;
@@ -250,7 +249,6 @@ static const VMStateDescription vmstate_ppce500_pci = {
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
     .fields      = (VMStateField[]) {
-        VMSTATE_PCI_DEVICE_POINTER(pci_dev, PPCE500PCIState),
         VMSTATE_STRUCT_ARRAY(pob, PPCE500PCIState, PPCE500_PCI_NR_POBS, 1,
                              vmstate_pci_outbound, struct pci_outbound),
         VMSTATE_STRUCT_ARRAY(pib, PPCE500PCIState, PPCE500_PCI_NR_PIBS, 1,
@@ -262,58 +260,93 @@ static const VMStateDescription vmstate_ppce500_pci = {
 
 PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers)
 {
-    PPCE500PCIState *controller;
+    DeviceState *dev;
+    PCIBus *b;
+    PCIHostState *h;
+    PPCE500PCIState *s;
     PCIDevice *d;
-    int index;
     static int ppce500_pci_id;
+    SysBusDevice *sb;
+
+    dev = qdev_create(NULL, "e500-pcihost");
+    sb = sysbus_from_qdev(dev);
+    h = FROM_SYSBUS(PCIHostState, sb);
+    s = DO_UPCAST(PPCE500PCIState, pci_state, h);
+
+    b = pci_register_bus(&s->pci_state.busdev.qdev, NULL, mpc85xx_pci_set_irq,
+                         mpc85xx_pci_map_irq, pci_irqs, PCI_DEVFN(0x11, 0), 4);
 
-    controller = qemu_mallocz(sizeof(PPCE500PCIState));
+    s->pci_state.bus = b;
+    qdev_init_nofail(dev);
+    d = pci_create_simple(b, 0, "e500-host-bridge");
 
-    controller->pci_state.bus = pci_register_bus(NULL, "pci",
-                                                 mpc85xx_pci_set_irq,
-                                                 mpc85xx_pci_map_irq,
-                                                 pci_irqs, PCI_DEVFN(0x11, 0),
-                                                 4);
-    d = pci_register_device(controller->pci_state.bus,
-                            "host bridge", sizeof(PCIDevice),
-                            0, NULL, NULL);
+    sysbus_mmio_map(sb, 0, registers + PCIE500_CFGADDR);
+    sysbus_mmio_map(sb, 1, registers + PCIE500_CFGDATA);
+    sysbus_mmio_map(sb, 2, registers + PCIE500_REG_BASE);
 
-    pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_FREESCALE);
-    pci_config_set_device_id(d->config, PCI_DEVICE_ID_MPC8533E);
-    pci_config_set_class(d->config, PCI_CLASS_PROCESSOR_POWERPC);
+    /* XXX load/save code not tested. */
+    vmstate_register(&d->qdev, ppce500_pci_id++, &vmstate_ppce500_pci, s);
+
+    return b;
+}
+
+static int e500_pcihost_initfn(SysBusDevice *dev)
+{
+    PCIHostState *h;
+    PPCE500PCIState *s;
+    /* XXX qdev var */
+    int index;
 
-    controller->pci_dev = d;
+    h = FROM_SYSBUS(PCIHostState, sysbus_from_qdev(dev));
+    s = DO_UPCAST(PPCE500PCIState, pci_state, h);
 
     /* CFGADDR */
-    index = pci_host_conf_register_mmio(&controller->pci_state,
-                                        DEVICE_BIG_ENDIAN);
+    index = pci_host_conf_register_mmio(&s->pci_state, DEVICE_BIG_ENDIAN);
     if (index < 0)
-        goto free;
-    cpu_register_physical_memory(registers + PCIE500_CFGADDR, 4, index);
+        return -1;
+    sysbus_init_mmio(dev, 4, index);
 
     /* CFGDATA */
-    index = pci_host_data_register_mmio(&controller->pci_state,
-                                        DEVICE_BIG_ENDIAN);
+    index = pci_host_data_register_mmio(&s->pci_state, DEVICE_LITTLE_ENDIAN);
     if (index < 0)
-        goto free;
-    cpu_register_physical_memory(registers + PCIE500_CFGDATA, 4, index);
+        return -1;
+    sysbus_init_mmio(dev, 4, index);
 
     index = cpu_register_io_memory(e500_pci_reg_read,
-                                   e500_pci_reg_write, controller,
-                                   DEVICE_NATIVE_ENDIAN);
+                                   e500_pci_reg_write, s, DEVICE_BIG_ENDIAN);
     if (index < 0)
-        goto free;
-    cpu_register_physical_memory(registers + PCIE500_REG_BASE,
-                                   PCIE500_REG_SIZE, index);
+        return -1;
+    sysbus_init_mmio(dev, PCIE500_REG_SIZE, index);
+    return 0;
+}
 
-    /* XXX load/save code not tested. */
-    vmstate_register(&d->qdev, ppce500_pci_id++, &vmstate_ppce500_pci,
-                     controller);
+static int e500_host_bridge_initfn(PCIDevice *dev)
+{
+    pci_config_set_vendor_id(dev->config, PCI_VENDOR_ID_FREESCALE);
+    pci_config_set_device_id(dev->config, PCI_DEVICE_ID_MPC8533E);
+    pci_config_set_class(dev->config, PCI_CLASS_PROCESSOR_POWERPC);
+
+    return 0;
+}
 
-    return controller->pci_state.bus;
+static PCIDeviceInfo e500_host_bridge_info = {
+    .qdev.name    = "e500-host-bridge",
+    .qdev.desc    = "Host bridge",
+    .qdev.size    = sizeof(PCIDevice),
+    .qdev.no_user = 1,
+    .init         = e500_host_bridge_initfn,
+};
 
-free:
-    printf("%s error\n", __func__);
-    qemu_free(controller);
-    return NULL;
+static SysBusDeviceInfo e500_pcihost_info = {
+    .init         = e500_pcihost_initfn,
+    .qdev.name    = "e500-pcihost",
+    .qdev.size    = sizeof(PPCE500PCIState),
+    .qdev.no_user = 1,
+};
+
+static void e500_pci_register(void)
+{
+    sysbus_register_withprop(&e500_pcihost_info);
+    pci_qdev_register(&e500_host_bridge_info);
 }
+device_init(e500_pci_register);
Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/7 PPC: Add another 64 bits to instruction feature mask

In reply to Alexander Graf

To enable quick runtime detection of instruction groups to the currently selected CPU emulation, we have a feature mask of what exactly the respective instruction supports.

This feature mask is 64 bits long and we just successfully exceeded those 64 bits. To add more features, we need to think of something.

The easiest solution that came to my mind was to simply add another 64 bits that we can also match on. Since the comparison is only done on start of the qemu process to generate an internal opcode calling table, we should be fine on any performance penalties here.

---
 target-ppc/cpu.h            |    1 +
 target-ppc/translate.c      |   25 +++++++--
 target-ppc/translate_init.c |  123 +++++++++++++++++++++++++++++++------------
 3 files changed, 110 insertions(+), 39 deletions(-)
target-ppc/cpu.h +1 -0
index c6b2255..2a7431c 100644
@@ -722,6 +722,7 @@ struct CPUPPCState {
     int bfd_mach;
     uint32_t flags;
     uint64_t insns_flags;
+    uint64_t insns_flags2;
 
 #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
     target_phys_addr_t vpa;
target-ppc/translate.c +19 -6
index 99f572a..95813f2 100644
@@ -201,6 +201,8 @@ struct opc_handler_t {
     uint32_t inval;
     /* instruction type */
     uint64_t type;
+    /* extended instruction type */
+    uint64_t type2;
     /* handler */
     void (*handler)(DisasContext *ctx);
 #if defined(DO_PPC_STATISTICS) || defined(PPC_DUMP_CPU)
@@ -314,10 +316,16 @@ static inline void gen_sync_exception(DisasContext *ctx)
 }
 
 #define GEN_HANDLER(name, opc1, opc2, opc3, inval, type)                      \
-GEN_OPCODE(name, opc1, opc2, opc3, inval, type)
+GEN_OPCODE(name, opc1, opc2, opc3, inval, type, PPC_NONE)
+
+#define GEN_HANDLER_E(name, opc1, opc2, opc3, inval, type, type2)             \
+GEN_OPCODE(name, opc1, opc2, opc3, inval, type, type2)
 
 #define GEN_HANDLER2(name, onam, opc1, opc2, opc3, inval, type)               \
-GEN_OPCODE2(name, onam, opc1, opc2, opc3, inval, type)
+GEN_OPCODE2(name, onam, opc1, opc2, opc3, inval, type, PPC_NONE)
+
+#define GEN_HANDLER2_E(name, onam, opc1, opc2, opc3, inval, type, type2)      \
+GEN_OPCODE2(name, onam, opc1, opc2, opc3, inval, type, type2)
 
 typedef struct opcode_t {
     unsigned char opc1, opc2, opc3;
@@ -457,7 +465,7 @@ static inline target_ulong MASK(uint32_t start, uint32_t end)
 /* PowerPC instructions table                                                */
 
 #if defined(DO_PPC_STATISTICS)
-#define GEN_OPCODE(name, op1, op2, op3, invl, _typ)                           \
+#define GEN_OPCODE(name, op1, op2, op3, invl, _typ, _typ2)                    \
 {                                                                             \
     .opc1 = op1,                                                              \
     .opc2 = op2,                                                              \
@@ -466,12 +474,13 @@ static inline target_ulong MASK(uint32_t start, uint32_t end)
     .handler = {                                                              \
         .inval   = invl,                                                      \
         .type = _typ,                                                         \
+        .type2 = _typ2,                                                       \
         .handler = &gen_##name,                                               \
         .oname = stringify(name),                                             \
     },                                                                        \
     .oname = stringify(name),                                                 \
 }
-#define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ)                    \
+#define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ, _typ2)             \
 {                                                                             \
     .opc1 = op1,                                                              \
     .opc2 = op2,                                                              \
@@ -480,13 +489,14 @@ static inline target_ulong MASK(uint32_t start, uint32_t end)
     .handler = {                                                              \
         .inval   = invl,                                                      \
         .type = _typ,                                                         \
+        .type2 = _typ2,                                                       \
         .handler = &gen_##name,                                               \
         .oname = onam,                                                        \
     },                                                                        \
     .oname = onam,                                                            \
 }
 #else
-#define GEN_OPCODE(name, op1, op2, op3, invl, _typ)                           \
+#define GEN_OPCODE(name, op1, op2, op3, invl, _typ, _typ2)                    \
 {                                                                             \
     .opc1 = op1,                                                              \
     .opc2 = op2,                                                              \
@@ -495,11 +505,12 @@ static inline target_ulong MASK(uint32_t start, uint32_t end)
     .handler = {                                                              \
         .inval   = invl,                                                      \
         .type = _typ,                                                         \
+        .type2 = _typ2,                                                       \
         .handler = &gen_##name,                                               \
     },                                                                        \
     .oname = stringify(name),                                                 \
 }
-#define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ)                    \
+#define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ, _typ2)             \
 {                                                                             \
     .opc1 = op1,                                                              \
     .opc2 = op2,                                                              \
@@ -508,6 +519,7 @@ static inline target_ulong MASK(uint32_t start, uint32_t end)
     .handler = {                                                              \
         .inval   = invl,                                                      \
         .type = _typ,                                                         \
+        .type2 = _typ2,                                                       \
         .handler = &gen_##name,                                               \
     },                                                                        \
     .oname = onam,                                                            \
@@ -534,6 +546,7 @@ static void gen_invalid(DisasContext *ctx)
 static opc_handler_t invalid_handler = {
     .inval   = 0xFFFFFFFF,
     .type    = PPC_NONE,
+    .type2   = PPC_NONE,
     .handler = gen_invalid,
 };
 
target-ppc/translate_init.c +90 -33

460 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#5 lore raw

PATCH 5/7 PPC: Implement e500 (FSL) MMU

In reply to Alexander Graf

Most of the code to support e500 style MMUs is already in place, but we're missing on some of the special TLB0-TLB1 handling code and slightly different TLB modification.

This patch adds support for the FSL style MMU.

---

v1 -> v2:

- fix linux-user build
- optimize tlb invalidate & search

v3 -> v4:

- remove tlb_nbs
- rename BOOKE_FSL to BOOKE206
- generalize implementation to be extensible for future MMUs
- check if tsize should be set
- check if iprot should be set
- set RPN on tlb miss
- implement tlb_invalidate_all
- use specific helper to set PIDs
- create generic booke206 tlb flushing function
- make e500 check more explicit
- rename functions to booke206
- rework page size finder

Special thanks go to Scott here for pointing out all the issues :)

---
 target-ppc/cpu.h            |  304 ++++++++++++++++++++++++++++++++++++++++++-
 target-ppc/helper.c         |  277 +++++++++++++++++++++++++++++++--------
 target-ppc/helper.h         |    6 +
 target-ppc/op_helper.c      |  296 +++++++++++++++++++++++++++++++++++++++++
 target-ppc/translate.c      |   91 ++++++++++++-
 target-ppc/translate_init.c |  163 ++++++++++++++++-------
 6 files changed, 1024 insertions(+), 113 deletions(-)
target-ppc/cpu.h +301 -3
index 2a7431c..20d995a 100644
@@ -108,8 +108,8 @@ enum powerpc_mmu_t {
     POWERPC_MMU_MPC8xx     = 0x00000007,
     /* BookE MMU model                                         */
     POWERPC_MMU_BOOKE      = 0x00000008,
-    /* BookE FSL MMU model                                     */
-    POWERPC_MMU_BOOKE_FSL  = 0x00000009,
+    /* BookE 2.06 MMU model                                    */
+    POWERPC_MMU_BOOKE206   = 0x00000009,
     /* PowerPC 601 MMU model (specific BATs format)            */
     POWERPC_MMU_601        = 0x0000000A,
 #if defined(TARGET_PPC64)
@@ -608,6 +608,224 @@ enum {
 #define vscr_sat	(((env->vscr) >> VSCR_SAT)	& 0x1)
 
 /*****************************************************************************/
+/* BookE e500 MMU registers */
+
+#define MAS0_NV_SHIFT      0
+#define MAS0_NV_MASK       (0xfff << MAS0_NV_SHIFT)
+
+#define MAS0_WQ_SHIFT      12
+#define MAS0_WQ_MASK       (3 << MAS0_WQ_SHIFT)
+/* Write TLB entry regardless of reservation */
+#define MAS0_WQ_ALWAYS     (0 << MAS0_WQ_SHIFT)
+/* Write TLB entry only already in use */
+#define MAS0_WQ_COND       (1 << MAS0_WQ_SHIFT)
+/* Clear TLB entry */
+#define MAS0_WQ_CLR_RSRV   (2 << MAS0_WQ_SHIFT)
+
+#define MAS0_HES_SHIFT     14
+#define MAS0_HES           (1 << MAS0_HES_SHIFT)
+
+#define MAS0_ESEL_SHIFT    16
+#define MAS0_ESEL_MASK     (0xfff << MAS0_ESEL_SHIFT)
+
+#define MAS0_TLBSEL_SHIFT  28
+#define MAS0_TLBSEL_MASK   (3 << MAS0_TLBSEL_SHIFT)
+#define MAS0_TLBSEL_TLB0   (0 << MAS0_TLBSEL_SHIFT)
+#define MAS0_TLBSEL_TLB1   (1 << MAS0_TLBSEL_SHIFT)
+#define MAS0_TLBSEL_TLB2   (2 << MAS0_TLBSEL_SHIFT)
+#define MAS0_TLBSEL_TLB3   (3 << MAS0_TLBSEL_SHIFT)
+
+#define MAS0_ATSEL_SHIFT   31
+#define MAS0_ATSEL         (1 << MAS0_ATSEL_SHIFT)
+#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_TS_SHIFT      12
+#define MAS1_TS            (1 << MAS1_TS_SHIFT)
+
+#define MAS1_IND_SHIFT     13
+#define MAS1_IND           (1 << MAS1_IND_SHIFT)
+
+#define MAS1_TID_SHIFT     16
+#define MAS1_TID_MASK      (0x3fff << MAS1_TID_SHIFT)
+
+#define MAS1_IPROT_SHIFT   30
+#define MAS1_IPROT         (1 << MAS1_IPROT_SHIFT)
+
+#define MAS1_VALID_SHIFT   31
+#define MAS1_VALID         0x80000000
+
+#define MAS2_EPN_SHIFT     12
+#define MAS2_EPN_MASK      (0xfffff << MAS2_EPN_SHIFT)
+
+#define MAS2_ACM_SHIFT     6
+#define MAS2_ACM           (1 << MAS2_ACM_SHIFT)
+
+#define MAS2_VLE_SHIFT     5
+#define MAS2_VLE           (1 << MAS2_VLE_SHIFT)
+
+#define MAS2_W_SHIFT       4
+#define MAS2_W             (1 << MAS2_W_SHIFT)
+
+#define MAS2_I_SHIFT       3
+#define MAS2_I             (1 << MAS2_I_SHIFT)
+
+#define MAS2_M_SHIFT       2
+#define MAS2_M             (1 << MAS2_M_SHIFT)
+
+#define MAS2_G_SHIFT       1
+#define MAS2_G             (1 << MAS2_G_SHIFT)
+
+#define MAS2_E_SHIFT       0
+#define MAS2_E             (1 << MAS2_E_SHIFT)
+
+#define MAS3_RPN_SHIFT     12
+#define MAS3_RPN_MASK      (0xfffff << MAS3_RPN_SHIFT)
+
+#define MAS3_U0                 0x00000200
+#define MAS3_U1                 0x00000100
+#define MAS3_U2                 0x00000080
+#define MAS3_U3                 0x00000040
+#define MAS3_UX                 0x00000020
+#define MAS3_SX                 0x00000010
+#define MAS3_UW                 0x00000008
+#define MAS3_SW                 0x00000004
+#define MAS3_UR                 0x00000002
+#define MAS3_SR                 0x00000001
+#define MAS3_SPSIZE_SHIFT       1
+#define MAS3_SPSIZE_MASK        (0x3e << MAS3_SPSIZE_SHIFT)
+
+#define MAS4_TLBSELD_SHIFT      MAS0_TLBSEL_SHIFT
+#define MAS4_TLBSELD_MASK       MAS0_TLBSEL_MASK
+#define MAS4_TIDSELD_MASK       0x00030000
+#define MAS4_TIDSELD_PID0       0x00000000
+#define MAS4_TIDSELD_PID1       0x00010000
+#define MAS4_TIDSELD_PID2       0x00020000
+#define MAS4_TIDSELD_PIDZ       0x00030000
+#define MAS4_INDD               0x00008000      /* Default IND */
+#define MAS4_TSIZED_SHIFT       MAS1_TSIZE_SHIFT
+#define MAS4_TSIZED_MASK        MAS1_TSIZE_MASK
+#define MAS4_ACMD               0x00000040
+#define MAS4_VLED               0x00000020
+#define MAS4_WD                 0x00000010
+#define MAS4_ID                 0x00000008
+#define MAS4_MD                 0x00000004
+#define MAS4_GD                 0x00000002
+#define MAS4_ED                 0x00000001
+#define MAS4_WIMGED_MASK        0x0000001f      /* Default WIMGE */
+#define MAS4_WIMGED_SHIFT       0
+
+#define MAS5_SGS                0x80000000
+#define MAS5_SLPID_MASK         0x00000fff
+
+#define MAS6_SPID0              0x3fff0000
+#define MAS6_SPID1              0x00007ffe
+#define MAS6_ISIZE(x)           MAS1_TSIZE(x)
+#define MAS6_SAS                0x00000001
+#define MAS6_SPID               MAS6_SPID0
+#define MAS6_SIND               0x00000002      /* Indirect page */
+#define MAS6_SIND_SHIFT         1
+#define MAS6_SPID_MASK          0x3fff0000
+#define MAS6_SPID_SHIFT         16
+#define MAS6_ISIZE_MASK         0x00000f80
+#define MAS6_ISIZE_SHIFT        7
+
+#define MAS7_RPN                0xffffffff
+
+#define MAS8_TGS                0x80000000
+#define MAS8_VF                 0x40000000
+#define MAS8_TLBPID             0x00000fff
+
+/* Bit definitions for MMUCFG */
+#define MMUCFG_MAVN     0x00000003      /* MMU Architecture Version Number */
+#define MMUCFG_MAVN_V1  0x00000000      /* v1.0 */
+#define MMUCFG_MAVN_V2  0x00000001      /* v2.0 */
+#define MMUCFG_NTLBS    0x0000000c      /* Number of TLBs */
+#define MMUCFG_PIDSIZE  0x000007c0      /* PID Reg Size */
+#define MMUCFG_TWC      0x00008000      /* TLB Write Conditional (v2.0) */
+#define MMUCFG_LRAT     0x00010000      /* LRAT Supported (v2.0) */
+#define MMUCFG_RASIZE   0x00fe0000      /* Real Addr Size */
+#define MMUCFG_LPIDSIZE 0x0f000000      /* LPID Reg Size */
+
+/* Bit definitions for MMUCSR0 */
+#define MMUCSR0_TLB1FI  0x00000002      /* TLB1 Flash invalidate */
+#define MMUCSR0_TLB0FI  0x00000004      /* TLB0 Flash invalidate */
+#define MMUCSR0_TLB2FI  0x00000040      /* TLB2 Flash invalidate */
+#define MMUCSR0_TLB3FI  0x00000020      /* TLB3 Flash invalidate */
+#define MMUCSR0_TLBFI   (MMUCSR0_TLB0FI | MMUCSR0_TLB1FI | \
+                         MMUCSR0_TLB2FI | MMUCSR0_TLB3FI)
+#define MMUCSR0_TLB0PS  0x00000780      /* TLB0 Page Size */
+#define MMUCSR0_TLB1PS  0x00007800      /* TLB1 Page Size */
+#define MMUCSR0_TLB2PS  0x00078000      /* TLB2 Page Size */
+#define MMUCSR0_TLB3PS  0x00780000      /* TLB3 Page Size */
+
+/* TLBnCFG encoding */
+#define TLBnCFG_N_ENTRY         0x00000fff      /* number of entries */
+#define TLBnCFG_HES             0x00002000      /* HW select supported */
+#define TLBnCFG_AVAIL           0x00004000      /* variable page size */
+#define TLBnCFG_IPROT           0x00008000      /* IPROT supported */
+#define TLBnCFG_GTWE            0x00010000      /* Guest can write */
+#define TLBnCFG_IND             0x00020000      /* IND entries supported */
+#define TLBnCFG_PT              0x00040000      /* Can load from page table */
+#define TLBnCFG_MINSIZE         0x00f00000      /* Minimum Page Size (v1.0) */
+#define TLBnCFG_MINSIZE_SHIFT   20
+#define TLBnCFG_MAXSIZE         0x000f0000      /* Maximum Page Size (v1.0) */
+#define TLBnCFG_MAXSIZE_SHIFT   16
+#define TLBnCFG_ASSOC           0xff000000      /* Associativity */
+#define TLBnCFG_ASSOC_SHIFT     24
+
+/* TLBnPS encoding */
+#define TLBnPS_4K               0x00000004
+#define TLBnPS_8K               0x00000008
+#define TLBnPS_16K              0x00000010
+#define TLBnPS_32K              0x00000020
+#define TLBnPS_64K              0x00000040
+#define TLBnPS_128K             0x00000080
+#define TLBnPS_256K             0x00000100
+#define TLBnPS_512K             0x00000200
+#define TLBnPS_1M               0x00000400
+#define TLBnPS_2M               0x00000800
+#define TLBnPS_4M               0x00001000
+#define TLBnPS_8M               0x00002000
+#define TLBnPS_16M              0x00004000
+#define TLBnPS_32M              0x00008000
+#define TLBnPS_64M              0x00010000
+#define TLBnPS_128M             0x00020000
+#define TLBnPS_256M             0x00040000
+#define TLBnPS_512M             0x00080000
+#define TLBnPS_1G               0x00100000
+#define TLBnPS_2G               0x00200000
+#define TLBnPS_4G               0x00400000
+#define TLBnPS_8G               0x00800000
+#define TLBnPS_16G              0x01000000
+#define TLBnPS_32G              0x02000000
+#define TLBnPS_64G              0x04000000
+#define TLBnPS_128G             0x08000000
+#define TLBnPS_256G             0x10000000
+
+/* tlbilx action encoding */
+#define TLBILX_T_ALL                    0
+#define TLBILX_T_TID                    1
+#define TLBILX_T_FULLMATCH              3
+#define TLBILX_T_CLASS0                 4
+#define TLBILX_T_CLASS1                 5
+#define TLBILX_T_CLASS2                 6
+#define TLBILX_T_CLASS3                 7
+
+/* BookE 2.06 helper defines */
+
+#define BOOKE206_FLUSH_TLB0    (1 << 0)
+#define BOOKE206_FLUSH_TLB1    (1 << 1)
+#define BOOKE206_FLUSH_TLB2    (1 << 2)
+#define BOOKE206_FLUSH_TLB3    (1 << 3)
+
+/* number of possible TLBs */
+#define BOOKE206_MAX_TLBN      4
+
+/*****************************************************************************/
 /* The whole PowerPC CPU context */
 #define NB_MMU_MODES 3
 
@@ -678,7 +896,7 @@ struct CPUPPCState {
     int nb_BATs;
     target_ulong DBAT[2][8];
     target_ulong IBAT[2][8];
-    /* PowerPC TLB registers (for 4xx and 60x software driven TLBs) */
+    /* PowerPC TLB registers (for 4xx, e500 and 60x software driven TLBs) */
     int nb_tlb;      /* Total number of TLB                                  */
     int tlb_per_way; /* Speed-up helper: used to avoid divisions at run time */
     int nb_ways;     /* Number of ways in the TLB set                        */
@@ -856,6 +1074,10 @@ void store_40x_dbcr0 (CPUPPCState *env, uint32_t val);
 void store_40x_sler (CPUPPCState *env, uint32_t val);
 void store_booke_tcr (CPUPPCState *env, target_ulong val);
 void store_booke_tsr (CPUPPCState *env, target_ulong val);
+void booke206_flush_tlb(CPUState *env, int flags);
+int ppcemb_tlb_check(CPUState *env, ppcemb_tlb_t *tlb,
+                     target_phys_addr_t *raddrp, target_ulong address,
+                     uint32_t pid, int ext, int i);
 void ppc_tlb_invalidate_all (CPUPPCState *env);
 void ppc_tlb_invalidate_one (CPUPPCState *env, target_ulong addr);
 #if defined(TARGET_PPC64)
@@ -1547,6 +1769,11 @@ enum {
     PPC_DCRUX          = 0x4000000000000000ULL,
     /* popcntw and popcntd instructions                                      */
     PPC_POPCNTWD       = 0x8000000000000000ULL,
+
+    /* extended type values */
+
+    /* BookE 2.06 PowerPC specification                                      */
+    PPC2_BOOKE206      = 0x0000000000000001ULL,
 };
 
 /*****************************************************************************/
@@ -1699,6 +1926,77 @@ static inline void cpu_set_tls(CPUState *env, target_ulong newtls)
 #endif
 }
 
+#if !defined(CONFIG_USER_ONLY)
+static inline int booke206_tlbe_id(CPUState *env, ppcemb_tlb_t *tlbe)
+{
+    ulong tlbel = (ulong)tlbe;
+    ulong tlbl = (ulong)env->tlb;
+
+    return (tlbel - tlbl) / sizeof(env->tlb[0]);
+}
+
+static inline int booke206_tlb_size(CPUState *env, int tlbn)
+{
+    uint32_t tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
+    int r = tlbncfg & TLBnCFG_N_ENTRY;
+    return r;
+}
+
+static inline int booke206_tlb_ways(CPUState *env, int tlbn)
+{
+    uint32_t tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
+    int r = tlbncfg >> TLBnCFG_ASSOC_SHIFT;
+    return r;
+}
+
+static inline int booke206_tlbe_to_tlbn(CPUState *env, ppcemb_tlb_t *tlbe)
+{
+    int id = booke206_tlbe_id(env, tlbe);
+    int end = 0;
+    int i;
+
+    for (i = 0; i < BOOKE206_MAX_TLBN; i++) {
+        end += booke206_tlb_size(env, i);
+        if (id < end) {
+            return i;
+        }
+    }
+
+    cpu_abort(env, "Unknown TLBe: %d\n", id);
+    return 0;
+}
+
+static inline int booke206_tlbe_to_way(CPUState *env, ppcemb_tlb_t *tlb)
+{
+    int tlbn = booke206_tlbe_to_tlbn(env, tlb);
+    int tlbid = booke206_tlbe_id(env, tlb);
+    return tlbid & (booke206_tlb_ways(env, tlbn) - 1);
+}
+
+static inline ppcemb_tlb_t *booke206_get_tlbe(CPUState *env, const int tlbn,
+                                              target_ulong ea, int way)
+{
+    int r;
+    uint32_t ways = booke206_tlb_ways(env, tlbn);
+    int ways_bits = ffs(ways) - 1;
+    int tlb_bits = ffs(booke206_tlb_size(env, tlbn)) - 1;
+    int i;
+
+    way &= ways - 1;
+    ea >>= MAS2_EPN_SHIFT;
+    ea &= (1 << (tlb_bits - ways_bits)) - 1;
+    r = (ea << ways_bits) | way;
+
+    /* bump up to tlbn index */
+    for (i = 0; i < tlbn; i++) {
+        r += booke206_tlb_size(env, i);
+    }
+
+    return &env->tlb[r].tlbe;
+}
+
+#endif
+
 extern void (*cpu_ppc_hypercall)(CPUState *);
 
 #endif /* !defined (__CPU_PPC_H__) */
target-ppc/helper.c +220 -57

392 lines not on this page · raw message

target-ppc/helper.h +6 -0
index 7c02be9..a528128 100644
@@ -334,6 +334,12 @@ DEF_HELPER_1(4xx_tlbsx, tl, tl)
 DEF_HELPER_2(440_tlbre, tl, i32, tl)
 DEF_HELPER_3(440_tlbwe, void, i32, tl, tl)
 DEF_HELPER_1(440_tlbsx, tl, tl)
+DEF_HELPER_0(booke206_tlbre, void)
+DEF_HELPER_0(booke206_tlbwe, void)
+DEF_HELPER_2(booke206_tlbsx, void, tl, tl)
+DEF_HELPER_1(booke206_tlbivax, void, tl)
+DEF_HELPER_1(booke206_tlbflush, void, i32)
+DEF_HELPER_2(booke_setpid, void, i32, tl)
 DEF_HELPER_1(6xx_tlbd, void, tl)
 DEF_HELPER_1(6xx_tlbi, void, tl)
 DEF_HELPER_1(74xx_tlbd, void, tl)
target-ppc/op_helper.c +296 -0

300 lines not on this page · raw message

target-ppc/translate.c +87 -4

112 lines not on this page · raw message

target-ppc/translate_init.c +114 -49

312 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#13 lore raw

Re: [Qemu-devel] [PATCH 7/7] PPC: Qdev'ify e500 pci

In reply to Alexander Graf
Quoted 8 lines

PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers) {

hw/ppce500_pci.c +4 -1
-    PPCE500PCIState *controller;
+    DeviceState *dev;
+    PCIBus *b;
+    PCIHostState *h;
+    PPCE500PCIState *s;
     PCIDevice *d;

hw/ppce500_pci.c static const VMStateDescription vmstate_ppce500_pci = {

Quoted 10 lines
hw/ppce500_pci.c +8 -1
-    int index;
     static int ppce500_pci_id;
+    SysBusDevice *sb;
+
+    dev = qdev_create(NULL, "e500-pcihost");
+    sb = sysbus_from_qdev(dev);
+    h = FROM_SYSBUS(PCIHostState, sb);
+    s = DO_UPCAST(PPCE500PCIState, pci_state, h);
+
+    b = pci_register_bus(&s->pci_state.busdev.qdev, NULL,

No. This function should not exist. All this should be done in e500_pcihost_initfn. Please do the qdev conversion properly.

See versatilepb.c/versatile_pci.c for an example of how this is supposed to be done.

Quoted 1 line

+ .qdev.no_user = 1,

There's no good reason for this. It indicates you did the qdev conversion incorrectly.

Paul

#14 lore raw

Re: [Qemu-devel] [PATCH 7/7] PPC: Qdev'ify e500 pci

Quoted 14 lines
Quoted 14 lines

PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers) {

hw/ppce500_pci.c +4 -2
-    PPCE500PCIState *controller;
+    DeviceState *dev;
+    PCIBus *b;
+    PCIHostState *h;
+    PPCE500PCIState *s;
 
     PCIDevice *d;
 
-    int index;
 
     static int ppce500_pci_id;
Quoted 11 lines

hw/ppce500_pci.c static const VMStateDescription vmstate_ppce500_pci = {

Quoted 8 lines
hw/ppce500_pci.c +8 -0
+    SysBusDevice *sb;
+
+    dev = qdev_create(NULL, "e500-pcihost");
+    sb = sysbus_from_qdev(dev);
+    h = FROM_SYSBUS(PCIHostState, sb);
+    s = DO_UPCAST(PPCE500PCIState, pci_state, h);
+
+    b = pci_register_bus(&s->pci_state.busdev.qdev, NULL,

No. This function should not exist. All this should be done in e500_pcihost_initfn. Please do the qdev conversion properly.

Or more precicely it should not depend on the internals of ppce500_pci.c. In principle the only public entry point in that file should be device_init(...). If used by multiple boards a simple helper function may be appropriate (e.g. smc91c111_init). Note that this helper function has no ties to the rest of that file, and could be trivially moved into a different file or replaced with a macro/inline funciton.

ppce500_pci_init definitely should not be creating the PCI bus.

Paul

#6 lore raw

Re: [Qemu-devel] [PATCH 5/7] PPC: Implement e500 (FSL) MMU

In reply to Alexander Graf

target-ppc/helper.c void store_40x_sler (CPUPPCState *env, uint32_t val) · line 1268

Quoted 11 lines · On Fri, 6 May 2011 14:00:35 +0200 Alexander Graf <[email protected]> wrote:
target-ppc/helper.c +11 -0
+static inline void booke206_flush_tlb_one(ppc_tlb_t *tlb, int num)
+{
+    int i;
+
+    for (i = 0; i < num; i++) {
+        if ((tlb[i].tlbe.prot & PAGE_VALID) &&
+           !(tlb[i].tlbe.attr & MAS1_IPROT)) {
+            tlb[i].tlbe.prot = 0;
+        }
+    }
+}

When this is called on reset, we want to ignore IPROT.

The valid check seems unnecessary.

Quoted 1 line

+void helper_booke206_tlbsx(target_ulong address_hi, target_ulong address_lo)

What is address_hi?

From gen_tlbsx_booke206() it looks like these two arguments correspond to the two operands, so shouldn't they be added together? I only see address_lo used.

-Scott

#7 lore raw

Re: [Qemu-devel] [PATCH 5/7] PPC: Implement e500 (FSL) MMU

Quoted 16 lines · Scott Wood

target-ppc/helper.c void store_40x_sler (CPUPPCState *env, uint32_t val) · line 1268

Quoted 11 lines · On Fri, 6 May 2011 14:00:35 +0200 Alexander Graf <[email protected]> wrote:
target-ppc/helper.c +11 -0
+static inline void booke206_flush_tlb_one(ppc_tlb_t *tlb, int num)
+{
+    int i;
+
+    for (i = 0; i < num; i++) {
+        if ((tlb[i].tlbe.prot & PAGE_VALID) &&
+           !(tlb[i].tlbe.attr & MAS1_IPROT)) {
+            tlb[i].tlbe.prot = 0;
+        }
+    }
+}

When this is called on reset, we want to ignore IPROT.

Ugh. Yes. This functions needs a constant parameter to know if it should check for IPROT - and not do so on reset :).

Quoted 1 line

The valid check seems unnecessary.

Yup, but it really helps to reduce debug output when putting in some in that line which I did :). It shouldn't really hurt, right?

Quoted 7 lines
Quoted 1 line

+void helper_booke206_tlbsx(target_ulong address_hi, target_ulong address_lo)

What is address_hi?

From gen_tlbsx_booke206() it looks like these two arguments correspond to the two operands, so shouldn't they be added together? I only see address_lo used.

Yup. According to the e500 spec:

Note that rA = 0 is the preferred form for tlbsx and that some Freescale implementations, such as the e500, take an illegal instruction exception program interrupt if rA!=0.

So I figured that we're architecturally close enough if we just ignore it for now :).

Alex

#8 lore raw

Re: [Qemu-devel] [PATCH 5/7] PPC: Implement e500 (FSL) MMU

Quoted 9 lines · On Sat, 7 May 2011 23:36:29 +0200 Alexander Graf <[email protected]> wrote:
Quoted 7 lines · Scott Wood
Quoted 1 line

+void helper_booke206_tlbsx(target_ulong address_hi, target_ulong address_lo)

What is address_hi?

From gen_tlbsx_booke206() it looks like these two arguments correspond to the two operands, so shouldn't they be added together? I only see address_lo used.

Quoted 5 lines

Yup. According to the e500 spec:

Note that rA = 0 is the preferred form for tlbsx and that some Freescale implementations, such as the e500, take an illegal instruction exception program interrupt if rA!=0.

So I figured that we're architecturally close enough if we just ignore it for now :).

Architecturally, ignoring it and taking a trap are significantly different. :-)

In practice it won't matter much, but it seems simple to handle it (why handle it in tlbivax but not here?), especially if this is to be general book3e code rather than e500. I'm still confused about the "address_hi/lo" naming.

-Scott

#9 lore raw

Re: [Qemu-devel] [PATCH 5/7] PPC: Implement e500 (FSL) MMU

Quoted 18 lines · Scott Wood
Quoted 9 lines · On Sat, 7 May 2011 23:36:29 +0200 Alexander Graf <[email protected]> wrote:
Quoted 7 lines · Scott Wood
Quoted 1 line

+void helper_booke206_tlbsx(target_ulong address_hi, target_ulong address_lo)

What is address_hi?

From gen_tlbsx_booke206() it looks like these two arguments correspond to the two operands, so shouldn't they be added together? I only see address_lo used.

Quoted 5 lines

Yup. According to the e500 spec:

Note that rA = 0 is the preferred form for tlbsx and that some Freescale implementations, such as the e500, take an illegal instruction exception program interrupt if rA!=0.

So I figured that we're architecturally close enough if we just ignore it for now :).

Quoted 7 lines

Architecturally, ignoring it and taking a trap are significantly different. :-)

In practice it won't matter much, but it seems simple to handle it (why handle it in tlbivax but not here?), especially if this is to be general book3e code rather than e500. I'm still confused about the "address_hi/lo" naming.

So what would you prefer? Just do whatever the 2.06 spec says and ignore e500 specifics? :) Or always do what the e500 spec says?

Alex

#10 lore raw

Re: [Qemu-devel] [PATCH 5/7] PPC: Implement e500 (FSL) MMU

Quoted 24 lines · On Mon, 9 May 2011 21:36:12 +0200 Alexander Graf <[email protected]> wrote:
Quoted 21 lines · Scott Wood
Quoted 9 lines · On Sat, 7 May 2011 23:36:29 +0200 Alexander Graf <[email protected]> wrote:
Quoted 7 lines · Scott Wood
Quoted 1 line

+void helper_booke206_tlbsx(target_ulong address_hi, target_ulong address_lo)

What is address_hi?

From gen_tlbsx_booke206() it looks like these two arguments correspond to the two operands, so shouldn't they be added together? I only see address_lo used.

Quoted 5 lines

Yup. According to the e500 spec:

Note that rA = 0 is the preferred form for tlbsx and that some Freescale implementations, such as the e500, take an illegal instruction exception program interrupt if rA!=0.

So I figured that we're architecturally close enough if we just ignore it for now :).

Architecturally, ignoring it and taking a trap are significantly different. :-)

Quoted 6 lines
Quoted 4 lines

In practice it won't matter much, but it seems simple to handle it (why handle it in tlbivax but not here?), especially if this is to be general book3e code rather than e500. I'm still confused about the "address_hi/lo" naming.

So what would you prefer? Just do whatever the 2.06 spec says and ignore e500 specifics? :) Or always do what the e500 spec says?

Do what the architecture says. I doubt any software is going to be worse off if this instruction form succeeds rather than traps -- if such a situation actually turns up, we can deal with it then.

-Scott