2019-09-30 11:15:46 -04:00
|
|
|
From ba1ca232cfa2ca273c610beda40bee2143f11964 Mon Sep 17 00:00:00 2001
|
2020-05-12 10:31:40 +08:00
|
|
|
From: Xu Yandong <xuyandong2@huawei.com>
|
2019-09-30 11:15:46 -04:00
|
|
|
Date: Tue, 3 Sep 2019 16:27:39 +0800
|
|
|
|
|
Subject: [PATCH] cpu: parse +/- feature to avoid failure
|
|
|
|
|
|
2020-05-12 10:31:40 +08:00
|
|
|
To avoid cpu feature parse failuer, +/- feature is added.
|
|
|
|
|
|
|
|
|
|
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
2019-09-30 11:15:46 -04:00
|
|
|
---
|
|
|
|
|
target/arm/cpu64.c | 38 ++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
1 file changed, 38 insertions(+)
|
|
|
|
|
|
|
|
|
|
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
|
|
|
|
|
index 0d492877..6ce87ce0 100644
|
|
|
|
|
--- a/target/arm/cpu64.c
|
|
|
|
|
+++ b/target/arm/cpu64.c
|
|
|
|
|
@@ -30,6 +30,7 @@
|
|
|
|
|
#include "sysemu/kvm.h"
|
|
|
|
|
#include "kvm_arm.h"
|
|
|
|
|
#include "qapi/visitor.h"
|
|
|
|
|
+#include "hw/qdev-properties.h"
|
|
|
|
|
|
|
|
|
|
static inline void set_feature(CPUARMState *env, int feature)
|
|
|
|
|
{
|
|
|
|
|
@@ -455,10 +456,47 @@ static gchar *aarch64_gdb_arch_name(CPUState *cs)
|
|
|
|
|
return g_strdup("aarch64");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* Parse "+feature,-feature,feature=foo" CPU feature string
|
|
|
|
|
+ */
|
|
|
|
|
+static void arm_cpu_parse_featurestr(const char *typename, char *features,
|
|
|
|
|
+ Error **errp)
|
|
|
|
|
+{
|
|
|
|
|
+ char *featurestr;
|
|
|
|
|
+ char *val;
|
|
|
|
|
+ static bool cpu_globals_initialized;
|
|
|
|
|
+
|
|
|
|
|
+ if (cpu_globals_initialized) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ cpu_globals_initialized = true;
|
|
|
|
|
+
|
|
|
|
|
+ featurestr = features ? strtok(features, ",") : NULL;
|
|
|
|
|
+ while (featurestr) {
|
|
|
|
|
+ val = strchr(featurestr, '=');
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ GlobalProperty *prop = g_new0(typeof(*prop), 1);
|
|
|
|
|
+ *val = 0;
|
|
|
|
|
+ val++;
|
|
|
|
|
+ prop->driver = typename;
|
|
|
|
|
+ prop->property = g_strdup(featurestr);
|
|
|
|
|
+ prop->value = g_strdup(val);
|
|
|
|
|
+ qdev_prop_register_global(prop);
|
|
|
|
|
+ } else if (featurestr[0] == '+' || featurestr[0] == '-') {
|
|
|
|
|
+ warn_report("Ignore %s feature\n", featurestr);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ error_setg(errp, "Expected key=value format, found %s.",
|
|
|
|
|
+ featurestr);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ featurestr = strtok(NULL, ",");
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
|
|
|
|
|
{
|
|
|
|
|
CPUClass *cc = CPU_CLASS(oc);
|
|
|
|
|
|
|
|
|
|
+ cc->parse_features = arm_cpu_parse_featurestr;
|
|
|
|
|
cc->cpu_exec_interrupt = arm_cpu_exec_interrupt;
|
|
|
|
|
cc->gdb_read_register = aarch64_cpu_gdb_read_register;
|
|
|
|
|
cc->gdb_write_register = aarch64_cpu_gdb_write_register;
|
|
|
|
|
--
|
|
|
|
|
2.19.1
|
|
|
|
|
|