Skip to contentSkip to conversation

Fix Support for ARM A9 CBAR

PATCH Superseded Peter Crosthwaite 3 participants 18 messages Nov 27, 2013 – Nov 28, 2013 Arm/Zynq architecture

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Fix Support for ARM A9 CBAR

Hi Peter,

This patch series fixed the Configuration base address init logic for ARM CPUs, most notably for A9. Fixes both Zynq and Highbank which both hade broken CBAR.

Regards,
Peter

Peter Crosthwaite (6):
target-arm: Define and use ARM_FEATURE_CBAR target-arm/cpu: Convert reset CBAR to a property arm/highbank: Use object_new() rather than cpu_arm_init() arm/highbank: Fix CBAR intialisation arm/xilinx_zynq: Use object_new() rather than cpu_arm_init() arm/xilinx_zynq: Implement CBAR intialisation

 hw/arm/highbank.c    | 21 +++++++++++++++------
 hw/arm/xilinx_zynq.c | 20 ++++++++++++++++----
 target-arm/cpu.c     | 18 +++++++++---------
 target-arm/cpu.h     |  1 +
 target-arm/helper.c  |  9 +++++++++
 5 files changed, 50 insertions(+), 19 deletions(-)
Signature · 1 line
1.8.4.4
#1 lore raw

PATCH 1/6 target-arm: Define and use ARM_FEATURE_CBAR

Some processors (notably A9 within Highbank) define and use the CP15 configuration base address (CBAR). This is vendor specific so its best implemented as a CPU property (otherwise we would need vendor specific child classes for every ARM implementation).

This patch prepares support for converting CBAR reset value to a CPU property by moving the CP registration out of the CPU init fn, as registration will need to happen at realize time to pick up any property updates. The easiest way to do this is vie definition of a new ARM_FEATURE to flag the existence of the register.

---

 target-arm/cpu.c    | 11 ++---------
 target-arm/cpu.h    |  1 +
 target-arm/helper.c |  9 +++++++++
 3 files changed, 12 insertions(+), 9 deletions(-)
target-arm/cpu.c +2 -9
index d40f2a7..a82fa61 100644
@@ -585,6 +585,7 @@ static void cortex_a9_initfn(Object *obj)
     set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
     set_feature(&cpu->env, ARM_FEATURE_NEON);
     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
+    set_feature(&cpu->env, ARM_FEATURE_CBAR);
     /* Note that A9 supports the MP extensions even for
      * A9UP and single-core A9MP (which are both different
      * and valid configurations; we don't model A9UP).
@@ -612,15 +613,7 @@ static void cortex_a9_initfn(Object *obj)
     cpu->clidr = (1 << 27) | (1 << 24) | 3;
     cpu->ccsidr[0] = 0xe00fe015; /* 16k L1 dcache. */
     cpu->ccsidr[1] = 0x200fe015; /* 16k L1 icache. */
-    {
-        ARMCPRegInfo cbar = {
-            .name = "CBAR", .cp = 15, .crn = 15,  .crm = 0, .opc1 = 4,
-            .opc2 = 0, .access = PL1_R|PL3_W, .resetvalue = cpu->reset_cbar,
-            .fieldoffset = offsetof(CPUARMState, cp15.c15_config_base_address)
-        };
-        define_one_arm_cp_reg(cpu, &cbar);
-        define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
-    }
+    define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
 }
 
 #ifndef CONFIG_USER_ONLY
target-arm/cpu.h +1 -0
index 9f110f1..859750a 100644
@@ -461,6 +461,7 @@ enum arm_features {
     ARM_FEATURE_CACHE_DIRTY_REG, /* 1136/1176 cache dirty status register */
     ARM_FEATURE_CACHE_BLOCK_OPS, /* v6 optional cache block operations */
     ARM_FEATURE_MPIDR, /* has cp15 MPIDR */
+    ARM_FEATURE_CBAR, /* has cp15 CBAR */
     ARM_FEATURE_PXN, /* has Privileged Execute Never bit */
     ARM_FEATURE_LPAE, /* has Large Physical Address Extension */
     ARM_FEATURE_V8,
target-arm/helper.c +9 -0
index 3445813..1bf0305 100644
@@ -1744,6 +1744,15 @@ void register_cp_regs_for_features(ARMCPU *cpu)
         define_one_arm_cp_reg(cpu, &auxcr);
     }
 
+    if (arm_feature(env, ARM_FEATURE_CBAR)) {
+        ARMCPRegInfo cbar = {
+            .name = "CBAR", .cp = 15, .crn = 15, .crm = 0, .opc1 = 4, .opc2 = 0,
+            .access = PL1_R|PL3_W, .resetvalue = cpu->reset_cbar,
+            .fieldoffset = offsetof(CPUARMState, cp15.c15_config_base_address)
+        };
+        define_one_arm_cp_reg(cpu, &cbar);
+    }
+
     /* Generic registers whose values depend on the implementation */
     {
         ARMCPRegInfo sctlr = {
Signature · 1 line
1.8.4.4
#2 lore raw

PATCH 2/6 target-arm/cpu: Convert reset CBAR to a property

In reply to Peter Crosthwaite

The reset Value of the CP15 CBAR is a vendor (machine) configurable property. Define arm_cpu_properties and add it.

---

 target-arm/cpu.c | 7 +++++++
 1 file changed, 7 insertions(+)
target-arm/cpu.c +7 -0
index a82fa61..f1c5f6b 100644
@@ -20,6 +20,7 @@
 
 #include "cpu.h"
 #include "qemu-common.h"
+#include "hw/qdev-properties.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/loader.h"
 #endif
@@ -847,6 +848,11 @@ typedef struct ARMCPUInfo {
     void (*class_init)(ObjectClass *oc, void *data);
 } ARMCPUInfo;
 
+static Property arm_cpu_properties[] = {
+    DEFINE_PROP_UINT32("cbar", ARMCPU, reset_cbar, 0),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static const ARMCPUInfo arm_cpus[] = {
 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
     { .name = "arm926",      .initfn = arm926_initfn },
@@ -895,6 +901,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
 
     acc->parent_realize = dc->realize;
     dc->realize = arm_cpu_realizefn;
+    dc->props = arm_cpu_properties;
 
     acc->parent_reset = cc->reset;
     cc->reset = arm_cpu_reset;
Signature · 1 line
1.8.4.4
#12 lore raw

PATCH 3/6 arm/highbank: Use object_new() rather than cpu_arm_init()

In reply to Peter Crosthwaite

To allow the machine model to set device properties before CPU realization.

---

 hw/arm/highbank.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
hw/arm/highbank.c +10 -3
index fe98ef1..70831ba 100644
@@ -228,11 +228,18 @@ static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine)
         }
     }
 
+    cpu_model = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
+
     for (n = 0; n < smp_cpus; n++) {
         ARMCPU *cpu;
-        cpu = cpu_arm_init(cpu_model);
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to find CPU definition\n");
+        Error *err = NULL;
+
+        cpu = ARM_CPU(object_new(cpu_model));
+        g_free((void *)cpu_model);
+
+        object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+        if (err) {
+            fprintf(stderr, "%s\n", error_get_pretty(err));
             exit(1);
         }
 
Signature · 1 line
1.8.4.4
#15 lore raw

PATCH 4/6 arm/highbank: Fix CBAR intialisation

In reply to Peter Crosthwaite

Fix the CBAR initialisation by using the newly defined static property. CBAR is now set before realization, so the intended value is now actually used.

So I have kinda tested this. I booted an ARM kernel on Highbank with the stock Highbank DTB. It doesnt boot (and I will be doing something wrong), but before this patch I got this:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at /workspaces/pcrost/public/linux2.git/arch/arm/mm/ioremap.c:301 __arm_ioremap_pfn_caller+0x180/0x198()
CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W 3.13.0-rc1-next-20131126-dirty #2
[<c0015164>] (unwind_backtrace) from [<c00118c0>] (show_stack+0x10/0x14)
[<c00118c0>] (show_stack) from [<c02bd5fc>] (dump_stack+0x78/0x90)
[<c02bd5fc>] (dump_stack) from [<c001f110>] (warn_slowpath_common+0x68/0x84)
[<c001f110>] (warn_slowpath_common) from [<c001f1f4>] (warn_slowpath_null+0x1c/0x24)
[<c001f1f4>] (warn_slowpath_null) from [<c0017c6c>] (__arm_ioremap_pfn_caller+0x180/0x198)
[<c0017c6c>] (__arm_ioremap_pfn_caller) from [<c0017cd8>] (__arm_ioremap_caller+0x54/0x5c)
[<c0017cd8>] (__arm_ioremap_caller) from [<c0017d10>] (__arm_ioremap+0x18/0x1c)
[<c0017d10>] (__arm_ioremap) from [<c03913c0>] (highbank_init_irq+0x34/0x8c)
[<c03913c0>] (highbank_init_irq) from [<c038c228>] (init_IRQ+0x28/0x2c)
[<c038c228>] (init_IRQ) from [<c03899ec>] (start_kernel+0x234/0x398)
[<c03899ec>] (start_kernel) from [<00008074>] (0x8074)
---[ end trace 3406ff24bd97382f ]---

Which dissappears with this patch.

---

 hw/arm/highbank.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
hw/arm/highbank.c +5 -3
index 70831ba..f0d7949 100644
@@ -237,14 +237,16 @@ static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine)
         cpu = ARM_CPU(object_new(cpu_model));
         g_free((void *)cpu_model);
 
+        object_property_set_int(OBJECT(cpu), GIC_BASE_ADDR, "cbar", &err);
+        if (err) {
+            fprintf(stderr, "%s\n", error_get_pretty(err));
+            exit(1);
+        }
         object_property_set_bool(OBJECT(cpu), true, "realized", &err);
         if (err) {
             fprintf(stderr, "%s\n", error_get_pretty(err));
             exit(1);
         }
-
-        /* This will become a QOM property eventually */
-        cpu->reset_cbar = GIC_BASE_ADDR;
         cpu_irq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ);
     }
 
Signature · 1 line
1.8.4.4
#16 lore raw

PATCH 5/6 arm/xilinx_zynq: Use object_new() rather than cpu_arm_init()

In reply to Peter Crosthwaite

To allow the machine model to set device properties before CPU realization.

---

 hw/arm/xilinx_zynq.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
hw/arm/xilinx_zynq.c +8 -3
index 46924a0..b4553e8 100644
@@ -110,15 +110,20 @@ static void zynq_init(QEMUMachineInitArgs *args)
     SysBusDevice *busdev;
     qemu_irq pic[64];
     NICInfo *nd;
+    Error *err = NULL;
     int n;
 
     if (!cpu_model) {
         cpu_model = "cortex-a9";
     }
+    cpu_model = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
 
-    cpu = cpu_arm_init(cpu_model);
-    if (!cpu) {
-        fprintf(stderr, "Unable to find CPU definition\n");
+    cpu = ARM_CPU(object_new(cpu_model));
+    g_free((void *)cpu_model);
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+    if (err) {
+        fprintf(stderr, "%s\n", error_get_pretty(err));
         exit(1);
     }
 
Signature · 1 line
1.8.4.4
#17 lore raw

PATCH 6/6 arm/xilinx_zynq: Implement CBAR intialisation

In reply to Peter Crosthwaite

Fix the CBAR initialisation by using the newly defined static property. Zynq will now correctly init the CBAR to the SCU base address.

Needed to boot Linux on the xilinx_zynq machine model.

---

 hw/arm/xilinx_zynq.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/arm/xilinx_zynq.c +8 -1
index b4553e8..e21a0ab 100644
@@ -35,6 +35,8 @@
 
 #define IRQ_OFFSET 32 /* pic interrupts start from index 32 */
 
+#define SCU_BASE_ADDR 0xF8F00000
+
 static const int dma_irqs[8] = {
     46, 47, 48, 49, 72, 73, 74, 75
 };
@@ -121,6 +123,11 @@ static void zynq_init(QEMUMachineInitArgs *args)
     cpu = ARM_CPU(object_new(cpu_model));
     g_free((void *)cpu_model);
 
+    object_property_set_int(OBJECT(cpu), SCU_BASE_ADDR, "cbar", &err);
+    if (err) {
+        fprintf(stderr, "%s\n", error_get_pretty(err));
+        exit(1);
+    }
     object_property_set_bool(OBJECT(cpu), true, "realized", &err);
     if (err) {
         fprintf(stderr, "%s\n", error_get_pretty(err));
@@ -159,7 +166,7 @@ static void zynq_init(QEMUMachineInitArgs *args)
     qdev_prop_set_uint32(dev, "num-cpu", 1);
     qdev_init_nofail(dev);
     busdev = SYS_BUS_DEVICE(dev);
-    sysbus_mmio_map(busdev, 0, 0xF8F00000);
+    sysbus_mmio_map(busdev, 0, SCU_BASE_ADDR);
     sysbus_connect_irq(busdev, 0,
                        qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
 
Signature · 1 line
1.8.4.4
#13 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 3/6] arm/highbank: Use object_new() rather than cpu_arm_init()

In reply to Peter Crosthwaite
Quoted 14 lines · Peter Crosthwaite

To allow the machine model to set device properties before CPU realization.

---

 hw/arm/highbank.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
hw/arm/highbank.c +0 -0
index fe98ef1..70831ba 100644

hw/arm/highbank.c static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine) · line 232

Quoted 5 lines
hw/arm/highbank.c +2 -0
@@ -228,11 +228,18 @@ static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine)
         }
     }
 
+    cpu_model = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
+

Please use cpu_class_by_name() rather than hand-constructing the classname. (see also the hw/arm/virt.c code I posted the other day, which needs to set a property for other reasons.)

Quoted 5 lines
hw/arm/highbank.c +0 -3
     for (n = 0; n < smp_cpus; n++) {
         ARMCPU *cpu;
-        cpu = cpu_arm_init(cpu_model);
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to find CPU definition\n");

hw/arm/highbank.c static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine) · line 244

Quoted 10 lines
hw/arm/highbank.c +8 -0
+        Error *err = NULL;
+
+        cpu = ARM_CPU(object_new(cpu_model));
+        g_free((void *)cpu_model);
+
+        object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+        if (err) {
+            fprintf(stderr, "%s\n", error_get_pretty(err));
             exit(1);
         }

thanks
-- PMM

#3 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 2/6] target-arm/cpu: Convert reset CBAR to a property

In reply to Peter Crosthwaite
Quoted 34 lines · Peter Crosthwaite

The reset Value of the CP15 CBAR is a vendor (machine) configurable property. Define arm_cpu_properties and add it.

---

 target-arm/cpu.c | 7 +++++++
 1 file changed, 7 insertions(+)
target-arm/cpu.c +6 -0
index a82fa61..f1c5f6b 100644
@@ -20,6 +20,7 @@
 
 #include "cpu.h"
 #include "qemu-common.h"
+#include "hw/qdev-properties.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/loader.h"
 #endif
@@ -847,6 +848,11 @@ typedef struct ARMCPUInfo {
     void (*class_init)(ObjectClass *oc, void *data);
 } ARMCPUInfo;
 
+static Property arm_cpu_properties[] = {
+    DEFINE_PROP_UINT32("cbar", ARMCPU, reset_cbar, 0),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static const ARMCPUInfo arm_cpus[] = {
 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
     { .name = "arm926",      .initfn = arm926_initfn },

target-arm/cpu.c static void arm_cpu_class_init(ObjectClass *oc, void *data) · line 907

Quoted 7 lines
target-arm/cpu.c +1 -0
@@ -895,6 +901,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
 
     acc->parent_realize = dc->realize;
     dc->realize = arm_cpu_realizefn;
+    dc->props = arm_cpu_properties;
 
     acc->parent_reset = cc->reset;
     cc->reset = arm_cpu_reset;

Hmm. This means we end up with a cbar property on every ARM CPU whether that ARM CPU has a cbar or not...

-- PMM

#4 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 2/6] target-arm/cpu: Convert reset CBAR to a property

Am 27.11.2013 10:14, schrieb Peter Maydell:

Quoted 41 lines
Quoted 39 lines · Peter Crosthwaite

The reset Value of the CP15 CBAR is a vendor (machine) configurable property. Define arm_cpu_properties and add it.

---

 target-arm/cpu.c | 7 +++++++
 1 file changed, 7 insertions(+)
target-arm/cpu.c +7 -0
index a82fa61..f1c5f6b 100644
@@ -20,6 +20,7 @@
 
 #include "cpu.h"
 #include "qemu-common.h"
+#include "hw/qdev-properties.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/loader.h"
 #endif
@@ -847,6 +848,11 @@ typedef struct ARMCPUInfo {
     void (*class_init)(ObjectClass *oc, void *data);
 } ARMCPUInfo;
 
+static Property arm_cpu_properties[] = {
+    DEFINE_PROP_UINT32("cbar", ARMCPU, reset_cbar, 0),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static const ARMCPUInfo arm_cpus[] = {
 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
     { .name = "arm926",      .initfn = arm926_initfn },
@@ -895,6 +901,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
 
     acc->parent_realize = dc->realize;
     dc->realize = arm_cpu_realizefn;
+    dc->props = arm_cpu_properties;
 
Quoted 5 lines

target-arm/cpu.c static void arm_cpu_class_init(ObjectClass *oc, void *data) · line 907

Quoted 2 lines
target-arm/cpu.c +0 -0
     acc->parent_reset = cc->reset;
     cc->reset = arm_cpu_reset;

Hmm. This means we end up with a cbar property on every ARM CPU whether that ARM CPU has a cbar or not...

If we turn it into a dynamic property, we could register it conditional to ARM_FEATURE_CBAR.

The overall idea of the series makes sense to me. I would caution to think about the naming scheme though - we might want to have a "cbar" property to access the current value whereas we'll likely end up having several reset values to configure over time.

Andreas

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
#14 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 3/6] arm/highbank: Use object_new() rather than cpu_arm_init()

In reply to Peter Maydell

Am 27.11.2013 10:10, schrieb Peter Maydell:

Quoted 26 lines
Quoted 14 lines · Peter Crosthwaite

To allow the machine model to set device properties before CPU realization.

---

 hw/arm/highbank.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
hw/arm/highbank.c +0 -0
index fe98ef1..70831ba 100644

hw/arm/highbank.c static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine) · line 232

Quoted 5 lines
hw/arm/highbank.c +2 -0
@@ -228,11 +228,18 @@ static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine)
         }
     }
 
+    cpu_model = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
+

Please use cpu_class_by_name() rather than hand-constructing the classname. (see also the hw/arm/virt.c code I posted the other day, which needs to set a property for other reasons.)

Quoted 13 lines

hw/arm/highbank.c static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine) · line 242

Quoted 13 lines
hw/arm/highbank.c +8 -3
     for (n = 0; n < smp_cpus; n++) {
         ARMCPU *cpu;
-        cpu = cpu_arm_init(cpu_model);
-        if (cpu == NULL) {
-            fprintf(stderr, "Unable to find CPU definition\n");
+        Error *err = NULL;
+
+        cpu = ARM_CPU(object_new(cpu_model));
+        g_free((void *)cpu_model);
+
+        object_property_set_bool(OBJECT(cpu), true, "realized", &err);
+        if (err) {
+            fprintf(stderr, "%s\n", error_get_pretty(err));

And use of error_report() (without \n) will be appreciated. :)

Cheers,
Andreas

Quoted 5 lines

hw/arm/highbank.c static void calxeda_init(QEMUMachineInitArgs *args, enum cxmachines machine) · line 244

Quoted 2 lines
hw/arm/highbank.c +0 -0
             exit(1);
         }

thanks
-- PMM

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
#5 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 2/6] target-arm/cpu: Convert reset CBAR to a property

In reply to Andreas Färber
Quoted 2 lines · Andreas Färber

If we turn it into a dynamic property, we could register it conditional to ARM_FEATURE_CBAR.

Unfortunately feature flags only get set at realize (in the per-cpu init function), so we don't know at the point where we're registering properties whether to have this one or not.

The other option would be to define an a9 cpu class init fn to put the property in.

Quoted 4 lines

The overall idea of the series makes sense to me. I would caution to think about the naming scheme though - we might want to have a "cbar" property to access the current value whereas we'll likely end up having several reset values to configure over time.

Mmm, maybe. The approach I think we've taken in some other places (eg the cache controller) is to have the property names match the silicon's config or control signal names (which in this case would be PERIPHBASE), but they are not always consistent from CPU to CPU, so that might be more confusing than helpful. I don't think I have a strong opinion here, so I'd be happy with any vaguely consistent-looking plan.

-- PMM

#6 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 2/6] target-arm/cpu: Convert reset CBAR to a property

Am 27.11.2013 11:15, schrieb Peter Maydell:

Quoted 7 lines · Andreas Färber
Quoted 2 lines

If we turn it into a dynamic property, we could register it conditional to ARM_FEATURE_CBAR.

Unfortunately feature flags only get set at realize (in the per-cpu init function), so we don't know at the point where we're registering properties whether to have this one or not.

1/6 sets it in instance_init actually. So instance_post_init might do.

Quoted 2 lines

The other option would be to define an a9 cpu class init fn to put the property in.

Is it A9-only or would A15, A7, A12, etc. also need it?

Quoted 5 lines
Quoted 4 lines

The overall idea of the series makes sense to me. I would caution to think about the naming scheme though - we might want to have a "cbar" property to access the current value whereas we'll likely end up having several reset values to configure over time.

Quoted 7 lines

Mmm, maybe. The approach I think we've taken in some other places (eg the cache controller) is to have the property names match the silicon's config or control signal names (which in this case would be PERIPHBASE), but they are not always consistent from CPU to CPU, so that might be more confusing than helpful. I don't think I have a strong opinion here, so I'd be happy with any vaguely consistent-looking plan.

Whatever name you choose, I was rather thinking of whether you may want to call it, e.g., "foo-reset" or "reset-foo" to distinguish from plain "foo". (Igor's x86 properties series uses "feat-foo" on Anthony's suggestion to group and parse feature properties.)

Andreas

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 arm-devs v1 2/6] target-arm/cpu: Convert reset CBAR to a property

Quoted 10 lines · Andreas Färber

Am 27.11.2013 11:15, schrieb Peter Maydell:

Quoted 7 lines · Andreas Färber
Quoted 2 lines

If we turn it into a dynamic property, we could register it conditional to ARM_FEATURE_CBAR.

Unfortunately feature flags only get set at realize (in the per-cpu init function), so we don't know at the point where we're registering properties whether to have this one or not.

1/6 sets it in instance_init actually. So instance_post_init might do.

Oh yes, was confusing init and realize.

Quoted 4 lines
Quoted 2 lines

The other option would be to define an a9 cpu class init fn to put the property in.

Is it A9-only or would A15, A7, A12, etc. also need it?

A5, A7, A9, and A15 all have this -- basically all the cores with memory-mapped peripherals. It is still technically an IMPDEF register and config signal, though.

-- PMM

#8 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 2/6] target-arm/cpu: Convert reset CBAR to a property

In reply to Andreas Färber

Hi Andreas,

Quoted 11 lines · Andreas Färber

Am 27.11.2013 11:15, schrieb Peter Maydell:

Quoted 7 lines · Andreas Färber
Quoted 2 lines

If we turn it into a dynamic property, we could register it conditional to ARM_FEATURE_CBAR.

Unfortunately feature flags only get set at realize (in the per-cpu init function), so we don't know at the point where we're registering properties whether to have this one or not.

1/6 sets it in instance_init actually. So instance_post_init might do.

Do you have a candidate example of this pattern that I can work off?

Quoted 18 lines
Quoted 2 lines

The other option would be to define an a9 cpu class init fn to put the property in.

Is it A9-only or would A15, A7, A12, etc. also need it?

Quoted 5 lines
Quoted 4 lines

The overall idea of the series makes sense to me. I would caution to think about the naming scheme though - we might want to have a "cbar" property to access the current value whereas we'll likely end up having several reset values to configure over time.

Quoted 7 lines

Mmm, maybe. The approach I think we've taken in some other places (eg the cache controller) is to have the property names match the silicon's config or control signal names (which in this case would be PERIPHBASE), but they are not always consistent from CPU to CPU, so that might be more confusing than helpful. I don't think I have a strong opinion here, so I'd be happy with any vaguely consistent-looking plan.

Quoted 5 lines

Whatever name you choose, I was rather thinking of whether you may want to call it, e.g., "foo-reset" or "reset-foo" to distinguish from plain "foo". (Igor's x86 properties series uses "feat-foo" on Anthony's suggestion to group and parse feature properties.)

Is the "periphbase" ever runtime configurable? If not I'm not sure we need the "reset".

Regards,
Peter

Quoted 6 lines

Andreas

--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

#9 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 2/6] target-arm/cpu: Convert reset CBAR to a property

Quoted 2 lines · Peter Crosthwaite

Is the "periphbase" ever runtime configurable? If not I'm not sure we need the "reset".

You can't runtime configure it (it's a bunch of signals into the core that determine where the decoder sits the peripherals in the memory map). However, the CBAR register which on reset starts out with the value of the base address is a writable register (writing it won't change where the peripherals live, it just reads-as-written).

-- PMM

#11 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 2/6] target-arm/cpu: Convert reset CBAR to a property

In reply to Peter Crosthwaite

Hi,

Am 27.11.2013 12:39, schrieb Peter Crosthwaite:

Quoted 6 lines · Andreas Färber
Quoted 5 lines

Am 27.11.2013 11:15, schrieb Peter Maydell:

Quoted 4 lines · Andreas Färber
Quoted 2 lines

If we turn it into a dynamic property, we could register it conditional to ARM_FEATURE_CBAR.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Unfortunately feature flags only get set at realize (in the per-cpu init function), so we don't know at the point where we're registering properties whether to have this one or not.

1/6 sets it in instance_init actually. So instance_post_init might do.

Do you have a candidate example of this pattern that I can work off?

For instance_post_init the only user so far will be in hw/core/qdev.c.

target-i386/cpu.c adds a few dynamic properties for the base X86CPU.

Cheers,
Andreas

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
#10 lore raw

Re: [Qemu-devel] [PATCH arm-devs v1 2/6] target-arm/cpu: Convert reset CBAR to a property

In reply to Peter Maydell
Quoted 8 lines · Peter Maydell
Quoted 2 lines · Peter Crosthwaite

Is the "periphbase" ever runtime configurable? If not I'm not sure we need the "reset".

You can't runtime configure it (it's a bunch of signals into the core that determine where the decoder sits the peripherals in the memory map).

So that is a top level signal of MPCore rather than A9 CPUs right? Assuming so, that name "PERIPHBASE" is a ideally property of the the mpcore container device. And in this ideal world that container contains the A9 CPUs themselves and propagates "periphbase" through to the CPU as "cbar" during its own init/realize. Looking at ARM docco, the definition of CBAR == PERIPHBASE is A9MPCore specific. From ARM infocentre:

----
Cortex-A9 Technical Reference ManualRevision: r4p1
Home > System Control > Register descriptions > Configuration Base Address Register

4.3.24. Configuration Base Address Registe

...
Configurations

In Cortex-A9 uniprocessor implementations the base address is set to zero.

In Cortex-A9 MPCore implementations, the base address is reset to PERIPHBASE[31:13] so that software can determine the location of the private memory region"
---

So the best name for this register AFAICT is simply CBAR and either MPCore container or whatever are responsible for setting it to an appropriate value.

Quoted 5 lines

However, the CBAR register which on reset
starts out with the value of the base address is a writable register (writing it won't change where the peripherals live, it just reads-as-written).

So with that in mind i think the "reset-" prefix is appropriate.

Regards,
Peter

Quoted 2 lines

-- PMM