{"id":807636,"url":"http://patchwork.ozlabs.org/api/1.0/patches/807636/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","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":""},"msgid":"<1504099475-241036-7-git-send-email-imammedo@redhat.com>","date":"2017-08-30T13:24:33","name":"[v2,6/8] ppc: simplify cpu model lookup by PVR","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"5f8ef02558f133f20886d5b1230d7ba4b5c1aeff","submitter":{"id":11305,"url":"http://patchwork.ozlabs.org/api/1.0/people/11305/?format=json","name":"Igor Mammedov","email":"imammedo@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1504099475-241036-7-git-send-email-imammedo@redhat.com/mbox/","series":[{"id":612,"url":"http://patchwork.ozlabs.org/api/1.0/series/612/?format=json","date":"2017-08-30T13:24:29","name":"ppc: cpu_model handling cleanups","version":2,"mbox":"http://patchwork.ozlabs.org/series/612/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807636/checks/","tags":{},"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-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=imammedo@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 3xj5wn0lSSz9sQl\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 23:30:31 +1000 (AEST)","from localhost ([::1]:50590 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 1dn34f-0006HQ-Ch\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 09:30:29 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:50969)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <imammedo@redhat.com>) id 1dn2z9-0001ow-TK\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 09:24:48 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <imammedo@redhat.com>) id 1dn2z8-0003Yw-Up\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 09:24:47 -0400","from mx1.redhat.com ([209.132.183.28]:36588)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <imammedo@redhat.com>)\n\tid 1dn2z8-0003YG-PQ; Wed, 30 Aug 2017 09:24:46 -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 C609C404302;\n\tWed, 30 Aug 2017 13:24:45 +0000 (UTC)","from dell-r430-03.lab.eng.brq.redhat.com\n\t(dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id C67FF77DEE;\n\tWed, 30 Aug 2017 13:24:44 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com C609C404302","From":"Igor Mammedov <imammedo@redhat.com>","To":"qemu-devel@nongnu.org","Date":"Wed, 30 Aug 2017 15:24:33 +0200","Message-Id":"<1504099475-241036-7-git-send-email-imammedo@redhat.com>","In-Reply-To":"<1504099475-241036-1-git-send-email-imammedo@redhat.com>","References":"<1504099475-241036-1-git-send-email-imammedo@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.38]);\n\tWed, 30 Aug 2017 13:24:45 +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 6/8] ppc: simplify cpu model lookup by PVR","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":"qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>,\n\tDavid Gibson <david@gibson.dropbear.id.au>","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":"Signed-off-by: Igor Mammedov <imammedo@redhat.com>\n---\nv2:\n  - if going PVR lookup routem check that cpu_model string consumed\n    completely, as PVR number shouldn't have any stray symbol in it.\n---\n target/ppc/translate_init.c | 27 +++++++++++----------------\n 1 file changed, 11 insertions(+), 16 deletions(-)","diff":"diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c\nindex cf0d795..a803a7f 100644\n--- a/target/ppc/translate_init.c\n+++ b/target/ppc/translate_init.c\n@@ -34,6 +34,7 @@\n #include \"hw/ppc/ppc.h\"\n #include \"mmu-book3s-v3.h\"\n #include \"sysemu/qtest.h\"\n+#include \"qemu/cutils.h\"\n \n //#define PPC_DUMP_CPU\n //#define PPC_DEBUG_SPR\n@@ -10203,22 +10204,16 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)\n     char *cpu_model, *typename;\n     ObjectClass *oc;\n     const char *p;\n-    int i, len;\n-\n-    /* Check if the given name is a PVR */\n-    len = strlen(name);\n-    if (len == 10 && name[0] == '0' && name[1] == 'x') {\n-        p = name + 2;\n-        goto check_pvr;\n-    } else if (len == 8) {\n-        p = name;\n-    check_pvr:\n-        for (i = 0; i < 8; i++) {\n-            if (!qemu_isxdigit(*p++))\n-                break;\n-        }\n-        if (i == 8) {\n-            return OBJECT_CLASS(ppc_cpu_class_by_pvr(strtoul(name, NULL, 16)));\n+    unsigned long pvr;\n+\n+    /* Lookup by PVR if cpu_model is valid 8 digit hex number\n+     * (excl: 0x prefix if present)\n+     */\n+    if (!qemu_strtoul(name, &p, 16, &pvr)) {\n+        int len = p - name;\n+        len = (len == 10) && (name[1] == 'x') ? len - 2 : len;\n+        if ((len == 8) && (*p == '\\0')) {\n+            return OBJECT_CLASS(ppc_cpu_class_by_pvr(pvr));\n         }\n     }\n \n","prefixes":["v2","6/8"]}