From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDbJO-0007k0-8u for qemu-devel@nongnu.org; Tue, 20 Jan 2015 11:05:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDbJL-0004CK-BG for qemu-devel@nongnu.org; Tue, 20 Jan 2015 11:05:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48607) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDbJL-0004C6-3h for qemu-devel@nongnu.org; Tue, 20 Jan 2015 11:05:47 -0500 Date: Tue, 20 Jan 2015 17:05:40 +0100 From: Igor Mammedov Message-ID: <20150120170540.18c7f845@nial.brq.redhat.com> In-Reply-To: References: <1421706621-23731-1-git-send-email-greg.bellows@linaro.org> <1421706621-23731-2-git-send-email-greg.bellows@linaro.org> <20150120162212.4e6f5277@nial.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/5] target-arm: Add ARM CPU feature parsing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Bellows Cc: Peter Maydell , Eduardo Habkost , QEMU Developers , Christoffer Dall , Andreas =?UTF-8?B?RsOkcmJlcg==?= On Tue, 20 Jan 2015 09:34:39 -0600 Greg Bellows wrote: > On Tue, Jan 20, 2015 at 9:22 AM, Igor Mammedov wrot= e: >=20 > > On Mon, 19 Jan 2015 16:30:17 -0600 > > Greg Bellows wrote: > > > > > Adds a CPU feature parsing function and assigns to the CPU class. The > > only > > > feature added was "-aarch64" which disabled the AArch64 execution sta= te > > on a > > > 64-bit ARM CPU. > > > > > > Also adds stripping of features from CPU model string in acquiring the > > ARM CPU > > > by name. > > > > > > Signed-off-by: Greg Bellows > > > --- > > > target-arm/cpu.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- > > > 1 file changed, 44 insertions(+), 1 deletion(-) > > > > > > diff --git a/target-arm/cpu.c b/target-arm/cpu.c > > > index 285947f..f327dd7 100644 > > > --- a/target-arm/cpu.c > > > +++ b/target-arm/cpu.c > > > @@ -514,13 +514,17 @@ static ObjectClass *arm_cpu_class_by_name(const > > char *cpu_model) > > > { > > > ObjectClass *oc; > > > char *typename; > > > + char *cpuname; > > > > > > if (!cpu_model) { > > > return NULL; > > > } > > > > > > - typename =3D g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model); > > > + cpuname =3D g_strdup(cpu_model); > > > + cpuname =3D strtok(cpuname, ","); > > > + typename =3D g_strdup_printf("%s-" TYPE_ARM_CPU, cpuname); > > > oc =3D object_class_by_name(typename); > > > + g_free(cpuname); > > > g_free(typename); > > > if (!oc || !object_class_dynamic_cast(oc, TYPE_ARM_CPU) || > > > object_class_is_abstract(oc)) { > > > @@ -1163,6 +1167,44 @@ static Property arm_cpu_properties[] =3D { > > > DEFINE_PROP_END_OF_LIST() > > > }; > > > > > > +static void arm_cpu_parse_features(CPUState *cs, char *features, > > > + Error **errp) > > > +{ > > > + ARMCPU *cpu =3D ARM_CPU(cs); > > > + char *featurestr; > > > + > > > + featurestr =3D features ? strtok(features, ",") : NULL; > > > + while (featurestr) { > > > + if (featurestr[0] =3D=3D '-') { > > ... > > > + } else if (featurestr[0] =3D=3D '+') { > > Please do not use legacy +-feature format and support only foo=3Dval fo= rmat. > > Other targets have it only for to being able support legacy setups > > which use +- format. > > > > > =E2=80=8BThanks Igor. I was under the impression that the +/- notation wa= s still > relevant. Perhaps it makes the most sense to convert to using object > properties similar to how machine options are specified? =E2=80=8BWhat do= you think > Peter? Yep make features as object properties and reuse generic property parsing. Since you do not have to support legacy format, you actually do not need to define arm_cpu_parse_features() callback because foo=3Dval format can be parsed by generic property parsing infrastructure. >=20 >=20 > > > + /* Everything else is a bad format */ > > > + error_setg(errp, "CPU property string '%s' not in format= " > > > + "(+feature|-feature|feature=3Dxyz)", > > featurestr); > > > > > > > + return; > > > + } > > > + featurestr =3D strtok(NULL, ","); > > > + } > > > +} > > > + > > > static void arm_cpu_class_init(ObjectClass *oc, void *data) > > > { > > > ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); > > > @@ -1183,6 +1225,7 @@ static void arm_cpu_class_init(ObjectClass *oc, > > void *data) > > > cc->set_pc =3D arm_cpu_set_pc; > > > cc->gdb_read_register =3D arm_cpu_gdb_read_register; > > > cc->gdb_write_register =3D arm_cpu_gdb_write_register; > > > + cc->parse_features =3D arm_cpu_parse_features; > > > #ifdef CONFIG_USER_ONLY > > > cc->handle_mmu_fault =3D arm_cpu_handle_mmu_fault; > > > #else > > > >