Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/807825/?format=api
{ "id": 807825, "url": "http://patchwork.ozlabs.org/api/patches/807825/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170830170601.15855-7-david@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170830170601.15855-7-david@redhat.com>", "list_archive_url": null, "date": "2017-08-30T17:05:56", "name": "[v1,06/11] target/s390x: cleanup cpu number/address handling", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "78a5d5206bc6afec67a512d66fb9ca4da7a2ea00", "submitter": { "id": 70402, "url": "http://patchwork.ozlabs.org/api/people/70402/?format=api", "name": "David Hildenbrand", "email": "david@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170830170601.15855-7-david@redhat.com/mbox/", "series": [ { "id": 666, "url": "http://patchwork.ozlabs.org/api/series/666/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=666", "date": "2017-08-30T17:06:00", "name": "next round of s390x cleanups", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/666/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/807825/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/807825/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=david@redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjClC3ZlDz9s8w\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 03:52:39 +1000 (AEST)", "from localhost ([::1]:51927 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dn7AL-0006CW-75\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 13:52:37 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:33408)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <david@redhat.com>) id 1dn6Rn-0005kV-GK\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 13:06:37 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <david@redhat.com>) id 1dn6Rl-0002Tb-FT\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 13:06:35 -0400", "from mx1.redhat.com ([209.132.183.28]:46812)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <david@redhat.com>) id 1dn6Rl-0002Sd-79\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 13:06:33 -0400", "from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 48BE07E432;\n\tWed, 30 Aug 2017 17:06:32 +0000 (UTC)", "from t460s.redhat.com (ovpn-116-98.ams2.redhat.com [10.36.116.98])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 4A44480E72;\n\tWed, 30 Aug 2017 17:06:30 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 48BE07E432", "From": "David Hildenbrand <david@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Wed, 30 Aug 2017 19:05:56 +0200", "Message-Id": "<20170830170601.15855-7-david@redhat.com>", "In-Reply-To": "<20170830170601.15855-1-david@redhat.com>", "References": "<20170830170601.15855-1-david@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.12", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tWed, 30 Aug 2017 17:06:32 +0000 (UTC)", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "209.132.183.28", "Subject": "[Qemu-devel] [PATCH v1 06/11] target/s390x: cleanup cpu\n\tnumber/address handling", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "thuth@redhat.com, david@redhat.com, cohuck@redhat.com,\n\tRichard Henderson <richard.henderson@linaro.org>,\n\tAlexander Graf <agraf@suse.de>, borntraeger@de.ibm.com,\n\tAurelien Jarno <aurelien@aurel32.net>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "Some time ago we discussed that using \"id\" as property name is not the\nright thing to do, as it is a reserved property for other devices.\n\nSwitch to the term \"addr\" instead, which matches the definition in the\nPoP called \"CPU address\". There is no such thing as cpu number, so\nrename env.cpu_num to env.cpu_addr.\n\nWe can get rid of cpu->id now. Keep cpu->index and env->cpu_addr in sync.\ncpu->index was already implicitly used by e.g. cpu_exists(), so keeping\nboth in sync seems to be the right thing to do.\n\ncpu->index will now no longer automatically get set via\ncpu_exec_realizefn(). For now, we were lucky that both implicitly stayed\nin sync.\n\nOur new cpu property \"addr\" can be a static property. Range checks can\nbe avoided by using the correct type and the \"setting after realized\"\ncheck is done implicitly.\n\nAFAIK, s390x only supports cpu_add and not device_add for cpus. So we\nshould be able to safely rename that property (no the \"id\" property\ncould properly be used for device_add, which needs an artificial id for\nidentification purposes).\n\nSigned-off-by: David Hildenbrand <david@redhat.com>\n---\n hw/s390x/s390-virtio-ccw.c | 2 +-\n target/s390x/cpu.c | 69 ++++++++++++----------------------------------\n target/s390x/cpu.h | 5 ++--\n target/s390x/cpu_models.c | 2 +-\n target/s390x/excp_helper.c | 2 +-\n target/s390x/helper.c | 4 +--\n target/s390x/misc_helper.c | 4 +--\n target/s390x/translate.c | 5 +---\n 8 files changed, 28 insertions(+), 65 deletions(-)", "diff": "diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c\nindex 03c88a524b..7754e3eaf9 100644\n--- a/hw/s390x/s390-virtio-ccw.c\n+++ b/hw/s390x/s390-virtio-ccw.c\n@@ -306,7 +306,7 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev,\n S390CPU *cpu = S390_CPU(dev);\n CPUState *cs = CPU(dev);\n \n- name = g_strdup_printf(\"cpu[%i]\", cpu->env.cpu_num);\n+ name = g_strdup_printf(\"cpu[%i]\", cpu->env.cpu_addr);\n object_property_set_link(OBJECT(hotplug_dev), OBJECT(cs), name,\n errp);\n g_free(name);\ndiff --git a/target/s390x/cpu.c b/target/s390x/cpu.c\nindex 7267b60d41..156589e921 100644\n--- a/target/s390x/cpu.c\n+++ b/target/s390x/cpu.c\n@@ -36,6 +36,7 @@\n #include \"trace.h\"\n #include \"qapi/visitor.h\"\n #include \"exec/exec-all.h\"\n+#include \"hw/qdev-properties.h\"\n #ifndef CONFIG_USER_ONLY\n #include \"hw/hw.h\"\n #include \"sysemu/arch_init.h\"\n@@ -189,24 +190,26 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)\n }\n \n #if !defined(CONFIG_USER_ONLY)\n- if (cpu->id >= max_cpus) {\n- error_setg(&err, \"Unable to add CPU: %\" PRIi64\n- \", max allowed: %d\", cpu->id, max_cpus - 1);\n+ if (cpu->env.cpu_addr >= max_cpus) {\n+ error_setg(&err, \"Unable to add CPU: %\" PRIu32 \", max allowed: %d\",\n+ cpu->env.cpu_addr, max_cpus - 1);\n goto out;\n }\n #endif\n- if (cpu_exists(cpu->id)) {\n- error_setg(&err, \"Unable to add CPU: %\" PRIi64\n- \", it already exists\", cpu->id);\n+ if (cpu_exists(cpu->env.cpu_addr)) {\n+ error_setg(&err, \"Unable to add CPU: %\" PRIu32 \", it already exists\",\n+ cpu->env.cpu_addr);\n goto out;\n }\n- if (cpu->id != scc->next_cpu_id) {\n- error_setg(&err, \"Unable to add CPU: %\" PRIi64\n- \", The next available id is %\" PRIi64, cpu->id,\n+ if (cpu->env.cpu_addr != scc->next_cpu_id) {\n+ error_setg(&err, \"Unable to add CPU: %\" PRIu32\n+ \", the next available nr is %\" PRIi64, cpu->env.cpu_addr,\n scc->next_cpu_id);\n goto out;\n }\n \n+ /* sync cs->cpu_index and env->cpu_addr. The latter is needed for TCG. */\n+ cs->cpu_index = env->cpu_addr;\n cpu_exec_realizefn(cs, &err);\n if (err != NULL) {\n goto out;\n@@ -216,7 +219,6 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)\n #if !defined(CONFIG_USER_ONLY)\n qemu_register_reset(s390_cpu_machine_reset_cb, cpu);\n #endif\n- env->cpu_num = cpu->id;\n s390_cpu_gdb_init(cs);\n qemu_init_vcpu(cs);\n #if !defined(CONFIG_USER_ONLY)\n@@ -237,45 +239,6 @@ out:\n error_propagate(errp, err);\n }\n \n-static void s390x_cpu_get_id(Object *obj, Visitor *v, const char *name,\n- void *opaque, Error **errp)\n-{\n- S390CPU *cpu = S390_CPU(obj);\n- int64_t value = cpu->id;\n-\n- visit_type_int(v, name, &value, errp);\n-}\n-\n-static void s390x_cpu_set_id(Object *obj, Visitor *v, const char *name,\n- void *opaque, Error **errp)\n-{\n- S390CPU *cpu = S390_CPU(obj);\n- DeviceState *dev = DEVICE(obj);\n- const int64_t min = 0;\n- const int64_t max = UINT32_MAX;\n- Error *err = NULL;\n- int64_t value;\n-\n- if (dev->realized) {\n- error_setg(errp, \"Attempt to set property '%s' on '%s' after \"\n- \"it was realized\", name, object_get_typename(obj));\n- return;\n- }\n-\n- visit_type_int(v, name, &value, &err);\n- if (err) {\n- error_propagate(errp, err);\n- return;\n- }\n- if (value < min || value > max) {\n- error_setg(errp, \"Property %s.%s doesn't take value %\" PRId64\n- \" (minimum: %\" PRId64 \", maximum: %\" PRId64 \")\" ,\n- object_get_typename(obj), name, value, min, max);\n- return;\n- }\n- cpu->id = value;\n-}\n-\n static void s390_cpu_initfn(Object *obj)\n {\n CPUState *cs = CPU(obj);\n@@ -289,8 +252,6 @@ static void s390_cpu_initfn(Object *obj)\n cs->env_ptr = env;\n cs->halted = 1;\n cs->exception_index = EXCP_HLT;\n- object_property_add(OBJECT(cpu), \"id\", \"int64_t\", s390x_cpu_get_id,\n- s390x_cpu_set_id, NULL, NULL, NULL);\n s390_cpu_model_register_props(obj);\n #if !defined(CONFIG_USER_ONLY)\n qemu_get_timedate(&tm, 0);\n@@ -487,6 +448,11 @@ static gchar *s390_gdb_arch_name(CPUState *cs)\n return g_strdup(\"s390:64-bit\");\n }\n \n+static Property s390x_cpu_properties[] = {\n+ DEFINE_PROP_UINT32(\"addr\", S390CPU, env.cpu_addr, 0),\n+ DEFINE_PROP_END_OF_LIST()\n+};\n+\n static void s390_cpu_class_init(ObjectClass *oc, void *data)\n {\n S390CPUClass *scc = S390_CPU_CLASS(oc);\n@@ -496,6 +462,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)\n scc->next_cpu_id = 0;\n scc->parent_realize = dc->realize;\n dc->realize = s390_cpu_realizefn;\n+ dc->props = s390x_cpu_properties;\n \n scc->parent_reset = cc->reset;\n #if !defined(CONFIG_USER_ONLY)\ndiff --git a/target/s390x/cpu.h b/target/s390x/cpu.h\nindex 4ec338077e..6766dbb579 100644\n--- a/target/s390x/cpu.h\n+++ b/target/s390x/cpu.h\n@@ -149,7 +149,7 @@ typedef struct CPUS390XState {\n \n CPU_COMMON\n \n- uint32_t cpu_num;\n+ uint32_t cpu_addr; /* same as cpu->index */\n uint64_t cpuid;\n \n uint64_t tod_offset;\n@@ -193,7 +193,6 @@ struct S390CPU {\n /*< public >*/\n \n CPUS390XState env;\n- int64_t id;\n S390CPUModel *model;\n /* needed for live migration */\n void *irqstate;\n@@ -690,7 +689,7 @@ const char *s390_default_cpu_model_name(void);\n /* helper.c */\n S390CPU *cpu_s390x_init(const char *cpu_model);\n #define cpu_init(model) CPU(cpu_s390x_init(model))\n-S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp);\n+S390CPU *s390x_new_cpu(const char *cpu_model, uint32_t addr, Error **errp);\n /* you can call this signal handler from your SIGBUS and SIGSEGV\n signal handlers to inform the virtual CPU of exceptions. non zero\n is returned if the signal was handled by the virtual CPU. */\ndiff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c\nindex 18cbf91d9c..1954c64c86 100644\n--- a/target/s390x/cpu_models.c\n+++ b/target/s390x/cpu_models.c\n@@ -915,7 +915,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp)\n cpu->env.cpuid = s390_cpuid_from_cpu_model(cpu->model);\n if (tcg_enabled()) {\n /* basic mode, write the cpu address into the first 4 bit of the ID */\n- cpu->env.cpuid = deposit64(cpu->env.cpuid, 54, 4, cpu->env.cpu_num);\n+ cpu->env.cpuid = deposit64(cpu->env.cpuid, 54, 4, cpu->env.cpu_addr);\n }\n }\n \ndiff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c\nindex 361f970db3..2ac36535f7 100644\n--- a/target/s390x/excp_helper.c\n+++ b/target/s390x/excp_helper.c\n@@ -251,7 +251,7 @@ static void do_ext_interrupt(CPUS390XState *env)\n lowcore->ext_params2 = cpu_to_be64(q->param64);\n lowcore->external_old_psw.mask = cpu_to_be64(get_psw_mask(env));\n lowcore->external_old_psw.addr = cpu_to_be64(env->psw.addr);\n- lowcore->cpu_addr = cpu_to_be16(env->cpu_num | VIRTIO_SUBCODE_64);\n+ lowcore->cpu_addr = cpu_to_be16(env->cpu_addr | VIRTIO_SUBCODE_64);\n mask = be64_to_cpu(lowcore->external_new_psw.mask);\n addr = be64_to_cpu(lowcore->external_new_psw.addr);\n \ndiff --git a/target/s390x/helper.c b/target/s390x/helper.c\nindex 3adb9de122..70d1ea8cf6 100644\n--- a/target/s390x/helper.c\n+++ b/target/s390x/helper.c\n@@ -104,7 +104,7 @@ S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp)\n return S390_CPU(CPU(object_new(typename)));\n }\n \n-S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp)\n+S390CPU *s390x_new_cpu(const char *cpu_model, uint32_t addr, Error **errp)\n {\n S390CPU *cpu;\n Error *err = NULL;\n@@ -114,7 +114,7 @@ S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp)\n goto out;\n }\n \n- object_property_set_int(OBJECT(cpu), id, \"id\", &err);\n+ object_property_set_int(OBJECT(cpu), addr, \"addr\", &err);\n if (err != NULL) {\n goto out;\n }\ndiff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c\nindex 50cc046ca2..eb7accc0ce 100644\n--- a/target/s390x/misc_helper.c\n+++ b/target/s390x/misc_helper.c\n@@ -230,7 +230,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0,\n /* XXX make different for different CPUs? */\n ebcdic_put(sysib.sequence, \"QEMUQEMUQEMUQEMU\", 16);\n ebcdic_put(sysib.plant, \"QEMU\", 4);\n- stw_p(&sysib.cpu_addr, env->cpu_num);\n+ stw_p(&sysib.cpu_addr, env->cpu_addr);\n cpu_physical_memory_write(a0, &sysib, sizeof(sysib));\n } else if ((sel1 == 2) && (sel2 == 2)) {\n /* Basic Machine CPUs */\n@@ -258,7 +258,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0,\n /* XXX make different for different CPUs? */\n ebcdic_put(sysib.sequence, \"QEMUQEMUQEMUQEMU\", 16);\n ebcdic_put(sysib.plant, \"QEMU\", 4);\n- stw_p(&sysib.cpu_addr, env->cpu_num);\n+ stw_p(&sysib.cpu_addr, env->cpu_addr);\n stw_p(&sysib.cpu_id, 0);\n cpu_physical_memory_write(a0, &sysib, sizeof(sysib));\n } else if ((sel1 == 2) && (sel2 == 2)) {\ndiff --git a/target/s390x/translate.c b/target/s390x/translate.c\nindex 4b0db7b7bd..80455bf8f0 100644\n--- a/target/s390x/translate.c\n+++ b/target/s390x/translate.c\n@@ -3822,10 +3822,7 @@ static ExitStatus op_ssm(DisasContext *s, DisasOps *o)\n static ExitStatus op_stap(DisasContext *s, DisasOps *o)\n {\n check_privileged(s);\n- /* ??? Surely cpu address != cpu number. In any case the previous\n- version of this stored more than the required half-word, so it\n- is unlikely this has ever been tested. */\n- tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, cpu_num));\n+ tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, cpu_addr));\n return NO_EXIT;\n }\n \n", "prefixes": [ "v1", "06/11" ] }