From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDKqX-0003AQ-BT for qemu-devel@nongnu.org; Mon, 19 Jan 2015 17:30:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDKqS-0003Qu-7b for qemu-devel@nongnu.org; Mon, 19 Jan 2015 17:30:57 -0500 Received: from mail-pd0-f171.google.com ([209.85.192.171]:56327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDKqS-0003Qf-25 for qemu-devel@nongnu.org; Mon, 19 Jan 2015 17:30:52 -0500 Received: by mail-pd0-f171.google.com with SMTP id fp1so17532336pdb.2 for ; Mon, 19 Jan 2015 14:30:51 -0800 (PST) From: Greg Bellows Date: Mon, 19 Jan 2015 16:30:18 -0600 Message-Id: <1421706621-23731-3-git-send-email-greg.bellows@linaro.org> In-Reply-To: <1421706621-23731-1-git-send-email-greg.bellows@linaro.org> References: <1421706621-23731-1-git-send-email-greg.bellows@linaro.org> Subject: [Qemu-devel] [PATCH 2/5] target-arm: Add feature parsing to virt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, peter.maydell@linaro.org, christoffer.dall@linaro.org Cc: Greg Bellows Added machvirt parsing of feature keywords added to the -cpu command line option. Parsing occurs during machine initialization. Signed-off-by: Greg Bellows --- hw/arm/virt.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 2353440..cd192ae 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -573,12 +573,19 @@ static void machvirt_init(MachineState *machine) MemoryRegion *ram = g_new(MemoryRegion, 1); const char *cpu_model = machine->cpu_model; VirtBoardInfo *vbi; + char *cpuname, *features; if (!cpu_model) { cpu_model = "cortex-a15"; } - vbi = find_machine_info(cpu_model); + /* Separate the actual CPU model name from any appended features */ + cpuname = g_strdup(cpu_model); + cpuname = strtok(cpuname, ","); + /* Keep track of the features for later parsing */ + features = strtok(NULL, ","); + + vbi = find_machine_info(cpuname); if (!vbi) { error_report("mach-virt: CPU %s not supported", cpu_model); @@ -595,8 +602,10 @@ static void machvirt_init(MachineState *machine) create_fdt(vbi); for (n = 0; n < smp_cpus; n++) { - ObjectClass *oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model); + ObjectClass *oc = cpu_class_by_name(TYPE_ARM_CPU, cpuname); + CPUClass *cc = CPU_CLASS(oc); Object *cpuobj; + Error *err = NULL; if (!oc) { fprintf(stderr, "Unable to find CPU definition\n"); @@ -604,6 +613,13 @@ static void machvirt_init(MachineState *machine) } cpuobj = object_new(object_class_get_name(oc)); + /* Handle any CPU options specfied by the user */ + cc->parse_features(CPU(cpuobj), features, &err); + if (err) { + error_report("%s", error_get_pretty(err)); + exit(1); + } + if (!vms->secure) { object_property_set_bool(cpuobj, false, "has_el3", NULL); } @@ -623,6 +639,7 @@ static void machvirt_init(MachineState *machine) object_property_set_bool(cpuobj, true, "realized", NULL); } + g_free(cpuname); fdt_add_timer_nodes(vbi); fdt_add_cpu_nodes(vbi); fdt_add_psci_node(vbi); -- 1.8.3.2