Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/809749/?format=api
{ "id": 809749, "url": "http://patchwork.ozlabs.org/api/patches/809749/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170904154316.4148-14-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": "<20170904154316.4148-14-david@redhat.com>", "list_archive_url": null, "date": "2017-09-04T15:43:10", "name": "[v2,13/19] target/s390x: use \"core-id\" for cpu number/address/id handling", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "3940aa7bd2a4faecfadbdc331871a31d804dd867", "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/20170904154316.4148-14-david@redhat.com/mbox/", "series": [ { "id": 1412, "url": "http://patchwork.ozlabs.org/api/series/1412/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1412", "date": "2017-09-04T15:42:57", "name": "s390x cleanups and CPU hotplug via device_add", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/1412/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/809749/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/809749/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-mx02.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx02.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 3xmDy23kKMz9sNq\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 5 Sep 2017 01:57:30 +1000 (AEST)", "from localhost ([::1]:54554 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 1dotke-0006lQ-LB\n\tfor incoming@patchwork.ozlabs.org; Mon, 04 Sep 2017 11:57:28 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:37815)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <david@redhat.com>) id 1dotXg-0004l3-RX\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 11:44:10 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <david@redhat.com>) id 1dotXb-0001DY-9h\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 11:44:04 -0400", "from mx1.redhat.com ([209.132.183.28]:52392)\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 1dotXa-0001CM-VN\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 11:43:59 -0400", "from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\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 ED39490E4F;\n\tMon, 4 Sep 2017 15:43:57 +0000 (UTC)", "from t460s.redhat.com (ovpn-116-139.ams2.redhat.com\n\t[10.36.116.139])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 5E3A0C14C4;\n\tMon, 4 Sep 2017 15:43:53 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com ED39490E4F", "From": "David Hildenbrand <david@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Mon, 4 Sep 2017 17:43:10 +0200", "Message-Id": "<20170904154316.4148-14-david@redhat.com>", "In-Reply-To": "<20170904154316.4148-1-david@redhat.com>", "References": "<20170904154316.4148-1-david@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.13", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tMon, 04 Sep 2017 15:43:58 +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 v2 13/19] target/s390x: use \"core-id\" for cpu\n\tnumber/address/id 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, Eduardo Habkost <ehabkost@redhat.com>, david@redhat.com,\n\tcohuck@redhat.com, Richard Henderson <richard.henderson@linaro.org>, \n\tAlexander Graf <agraf@suse.de>, borntraeger@de.ibm.com", "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 and\nwill not work with device_add.\n\nSwitch to the term \"core-id\" instead, and use it as an equivalent to\n\"CPU address\" mentioned in the PoP. There is no such thing as cpu number,\nso rename env.cpu_num to env.core_id. We use \"core-id\" as this is the\ncommon term to use for device_add later on (x86 and ppc).\n\nWe can get rid of cpu->id now. Keep cpu_index and env->core_id 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 \"core-id\" 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\ndevice_add will later need the reserved \"id\" property. Hotplugging a CPU\non s390x will then be: \"device_add host-s390-cpu,id=cpu2,core-id=2\".\n\nSigned-off-by: David Hildenbrand <david@redhat.com>\n---\n hw/s390x/s390-virtio-ccw.c | 2 +-\n target/s390x/cpu.c | 71 +++++++++++++---------------------------------\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, 29 insertions(+), 66 deletions(-)", "diff": "diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c\nindex f7ca20d77a..22a8a1b45d 100644\n--- a/hw/s390x/s390-virtio-ccw.c\n+++ b/hw/s390x/s390-virtio-ccw.c\n@@ -311,7 +311,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.core_id);\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 5f9315fb16..a2570bbc6b 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,28 +190,30 @@ 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.core_id >= max_cpus) {\n+ error_setg(&err, \"Unable to add CPU: %\" PRIu32 \", max allowed: %d\",\n+ cpu->env.core_id, max_cpus - 1);\n goto out;\n }\n #else\n /* implicitly set for linux-user only */\n- cpu->id = scc->next_cpu_id;\n+ cpu->env.core_id = scc->next_cpu_id;\n #endif\n \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.core_id)) {\n+ error_setg(&err, \"Unable to add CPU: %\" PRIu32 \", it already exists\",\n+ cpu->env.core_id);\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.core_id != scc->next_cpu_id) {\n+ error_setg(&err, \"Unable to add CPU: %\" PRIu32\n+ \", the next available nr is %\" PRIi64, cpu->env.core_id,\n scc->next_cpu_id);\n goto out;\n }\n \n+ /* sync cs->cpu_index and env->core_id. The latter is needed for TCG. */\n+ cs->cpu_index = env->core_id;\n cpu_exec_realizefn(cs, &err);\n if (err != NULL) {\n goto out;\n@@ -220,7 +223,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@@ -241,45 +243,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@@ -293,8 +256,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@@ -491,6 +452,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(\"core-id\", S390CPU, env.core_id, 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@@ -500,6 +466,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 dca6aa9aae..878b6cc83e 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 core_id; /* PoP \"CPU address\", same as cpu_index */\n uint64_t cpuid;\n \n uint64_t tod_offset;\n@@ -193,7 +193,6 @@ typedef struct S390CPU {\n /*< public >*/\n \n CPUS390XState env;\n- int64_t id;\n S390CPUModel *model;\n /* needed for live migration */\n void *irqstate;\n@@ -691,7 +690,7 @@ const char *s390_default_cpu_model_name(void);\n \n /* helper.c */\n #define cpu_init(cpu_model) cpu_generic_init(TYPE_S390_CPU, cpu_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 core_id, 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..8e20e7637b 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.core_id);\n }\n }\n \ndiff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c\nindex 14d3160e92..470cf8f5bc 100644\n--- a/target/s390x/excp_helper.c\n+++ b/target/s390x/excp_helper.c\n@@ -250,7 +250,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->core_id | 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 ba29504476..dfb24ef5b2 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 core_id, 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), core_id, \"core-id\", &err);\n if (err != NULL) {\n goto out;\n }\ndiff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c\nindex 5096286157..a3785a9c8d 100644\n--- a/target/s390x/misc_helper.c\n+++ b/target/s390x/misc_helper.c\n@@ -231,7 +231,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->core_id);\n cpu_physical_memory_write(a0, &sysib, sizeof(sysib));\n } else if ((sel1 == 2) && (sel2 == 2)) {\n /* Basic Machine CPUs */\n@@ -259,7 +259,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->core_id);\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..b8963f2fe2 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, core_id));\n return NO_EXIT;\n }\n \n", "prefixes": [ "v2", "13/19" ] }