Message ID | 1417637167-20640-6-git-send-email-greg.bellows@linaro.org |
---|---|
State | New |
Headers | show |
On 3 December 2014 at 20:05, Greg Bellows <greg.bellows@linaro.org> wrote: > Add "secure" Vexpress machine specific property to allow override of the > default secure state configuration. By default, when using the QEMU > -kernel command line argument, Vexpress machines boot into NS/SVC. When using > the QEMU -bios command line argument, Vexpress machines boot into S/SVC. > > The secure state can be changed from the default specifying the secure > state as a machine property. For example, the below command line would enable > secure state on a -linux boot: > > aarch64-softmmu/qemu-system-aarch64 > -machine type=vexpress-a15,secure=on > -kernel ... > +static void vexpress_instance_init(Object *obj) > +{ > + VexpressMachineState *vms = VEXPRESS_MACHINE(obj); > + > + /* All Vexpress machine instances have a secure property > + * Determine whether to start in a secure state or non-secure state based > + * on whether we are directly booting a kernel ("-kernel" option). If we > + * are, then we default to booting into non-secure state. Otherwise, we > + * default to the machine default which is secure EL1/SVC. > + * This may be overridden by the "secure" machine property. > + */ > + if (qemu_opt_get(qemu_get_machine_opts(), "kernel")) { > + vms->secure = false; > + } else { > + vms->secure = true; > + } > + > + object_property_add_bool(obj, "secure", vexpress_get_secure, > + vexpress_set_secure, NULL); > +} What I had in mind when we were discussing this was that whether you used -kernel or not wouldn't affect the configuration of the CPU, but would affect what we started the CPU in (ie hw/arm/boot.c code would put the CPU in some sensible initial state as required by the kernel booting API). Sorry for the confusion. -- PMM
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 4a38a82..6dc5d3b 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -164,6 +164,7 @@ typedef struct { typedef struct { MachineState parent; + bool secure; } VexpressMachineState; #define TYPE_VEXPRESS_MACHINE "vexpress" @@ -701,6 +702,41 @@ static void vexpress_common_init(MachineState *machine) arm_load_kernel(ARM_CPU(first_cpu), &daughterboard->bootinfo); } +static bool vexpress_get_secure(Object *obj, Error **errp) +{ + VexpressMachineState *vms = VEXPRESS_MACHINE(obj); + + return vms->secure; +} + +static void vexpress_set_secure(Object *obj, bool value, Error **errp) +{ + VexpressMachineState *vms = VEXPRESS_MACHINE(obj); + + vms->secure = value; +} + +static void vexpress_instance_init(Object *obj) +{ + VexpressMachineState *vms = VEXPRESS_MACHINE(obj); + + /* All Vexpress machine instances have a secure property + * Determine whether to start in a secure state or non-secure state based + * on whether we are directly booting a kernel ("-kernel" option). If we + * are, then we default to booting into non-secure state. Otherwise, we + * default to the machine default which is secure EL1/SVC. + * This may be overridden by the "secure" machine property. + */ + if (qemu_opt_get(qemu_get_machine_opts(), "kernel")) { + vms->secure = false; + } else { + vms->secure = true; + } + + object_property_add_bool(obj, "secure", vexpress_get_secure, + vexpress_set_secure, NULL); +} + static void vexpress_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); @@ -738,6 +774,7 @@ static const TypeInfo vexpress_info = { .name = TYPE_VEXPRESS_MACHINE, .parent = TYPE_MACHINE, .instance_size = sizeof(VexpressMachineState), + .instance_init = vexpress_instance_init, .class_size = sizeof(VexpressMachineClass), .class_init = vexpress_class_init, };
Add "secure" Vexpress machine specific property to allow override of the default secure state configuration. By default, when using the QEMU -kernel command line argument, Vexpress machines boot into NS/SVC. When using the QEMU -bios command line argument, Vexpress machines boot into S/SVC. The secure state can be changed from the default specifying the secure state as a machine property. For example, the below command line would enable secure state on a -linux boot: aarch64-softmmu/qemu-system-aarch64 -machine type=vexpress-a15,secure=on -kernel ... Signed-off-by: Greg Bellows <greg.bellows@linaro.org> --- hw/arm/vexpress.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)