diff mbox series

[3/8] target/arm/cpu: Allow init-svtor property to be set after realize

Message ID 20190219125808.25174-4-peter.maydell@linaro.org
State Superseded
Headers show
Series ARMSSE: Implement MHUs and dual-core capability | expand

Commit Message

Peter Maydell Feb. 19, 2019, 12:58 p.m. UTC
Make the M-profile "init-svtor" property be settable after realize.
This matches the hardware, where this is a config signal which
is sampled on CPU reset and can thus be changed between one
reset and another. To do this we have to change the API we
use to add the property.

(We will need this capability for the SSE-200.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 target/arm/cpu.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

-- 
2.20.1

Comments

Richard Henderson Feb. 20, 2019, 6:15 p.m. UTC | #1
On 2/19/19 4:58 AM, Peter Maydell wrote:
> +static void arm_set_init_svtor(Object *obj, Visitor *v, const char *name,

> +                               void *opaque, Error **errp)

> +{

> +    ARMCPU *cpu = ARM_CPU(obj);

> +

> +    visit_type_uint32(v, name, &cpu->init_svtor, errp);

> +}


Since there's no validation needed, can this use object_property_add_uint32_ptr?

That said, this isn't wrong so,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>



r~
Peter Maydell Feb. 20, 2019, 7:13 p.m. UTC | #2
On Wed, 20 Feb 2019 at 18:16, Richard Henderson
<richard.henderson@linaro.org> wrote:
>

> On 2/19/19 4:58 AM, Peter Maydell wrote:

> > +static void arm_set_init_svtor(Object *obj, Visitor *v, const char *name,

> > +                               void *opaque, Error **errp)

> > +{

> > +    ARMCPU *cpu = ARM_CPU(obj);

> > +

> > +    visit_type_uint32(v, name, &cpu->init_svtor, errp);

> > +}

>

> Since there's no validation needed, can this use object_property_add_uint32_ptr?


I tried that first, but it doesn't let you set the property,
only read it...

thanks
-- PMM
diff mbox series

Patch

diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index edf6e0e1f1c..a418ac5cc32 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -22,6 +22,7 @@ 
 #include "target/arm/idau.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include "qapi/visitor.h"
 #include "cpu.h"
 #include "internals.h"
 #include "qemu-common.h"
@@ -771,9 +772,21 @@  static Property arm_cpu_pmsav7_dregion_property =
                                            pmsav7_dregion,
                                            qdev_prop_uint32, uint32_t);
 
-/* M profile: initial value of the Secure VTOR */
-static Property arm_cpu_initsvtor_property =
-            DEFINE_PROP_UINT32("init-svtor", ARMCPU, init_svtor, 0);
+static void arm_get_init_svtor(Object *obj, Visitor *v, const char *name,
+                               void *opaque, Error **errp)
+{
+    ARMCPU *cpu = ARM_CPU(obj);
+
+    visit_type_uint32(v, name, &cpu->init_svtor, errp);
+}
+
+static void arm_set_init_svtor(Object *obj, Visitor *v, const char *name,
+                               void *opaque, Error **errp)
+{
+    ARMCPU *cpu = ARM_CPU(obj);
+
+    visit_type_uint32(v, name, &cpu->init_svtor, errp);
+}
 
 void arm_cpu_post_init(Object *obj)
 {
@@ -845,8 +858,14 @@  void arm_cpu_post_init(Object *obj)
                                  qdev_prop_allow_set_link_before_realize,
                                  OBJ_PROP_LINK_STRONG,
                                  &error_abort);
-        qdev_property_add_static(DEVICE(obj), &arm_cpu_initsvtor_property,
-                                 &error_abort);
+        /*
+         * M profile: initial value of the Secure VTOR. We can't just use
+         * a simple DEFINE_PROP_UINT32 for this because we want to permit
+         * the property to be set after realize.
+         */
+        object_property_add(obj, "init-svtor", "uint32",
+                            arm_get_init_svtor, arm_set_init_svtor,
+                            NULL, NULL, &error_abort);
     }
 
     qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property,