get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/807479/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 807479,
    "url": "http://patchwork.ozlabs.org/api/patches/807479/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170830082702.3011-10-Sergio.G.DelReal@gmail.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": "<20170830082702.3011-10-Sergio.G.DelReal@gmail.com>",
    "list_archive_url": null,
    "date": "2017-08-30T08:26:58",
    "name": "[v2,09/13] hvf: refactor cpuid code",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "267e47e692444ed9b1542aa9064253985fcabcbf",
    "submitter": {
        "id": 70675,
        "url": "http://patchwork.ozlabs.org/api/people/70675/?format=api",
        "name": "Sergio Andres Gomez Del Real",
        "email": "sergio.g.delreal@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170830082702.3011-10-Sergio.G.DelReal@gmail.com/mbox/",
    "series": [
        {
            "id": 548,
            "url": "http://patchwork.ozlabs.org/api/series/548/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=548",
            "date": "2017-08-30T08:26:49",
            "name": "add support for Hypervisor.framework in QEMU",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/548/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/807479/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/807479/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>)",
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"RHGzI30O\"; dkim-atps=neutral"
        ],
        "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 3xhzL26kYMz9sRq\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 18:33:30 +1000 (AEST)",
            "from localhost ([::1]:49004 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 1dmyRE-0006fm-Lj\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 04:33:28 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:60556)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <sergio.g.delreal@gmail.com>) id 1dmyLk-0002WC-Lk\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:27:50 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <sergio.g.delreal@gmail.com>) id 1dmyLi-0000P4-Pc\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:27:48 -0400",
            "from mail-ua0-x241.google.com ([2607:f8b0:400c:c08::241]:35776)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <sergio.g.delreal@gmail.com>)\n\tid 1dmyLi-0000Od-HA\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:27:46 -0400",
            "by mail-ua0-x241.google.com with SMTP id 37so2348811ual.2\n\tfor <qemu-devel@nongnu.org>; Wed, 30 Aug 2017 01:27:46 -0700 (PDT)",
            "from localhost.localdomain ([191.109.6.85])\n\tby smtp.gmail.com with ESMTPSA id\n\th74sm1079197vka.8.2017.08.30.01.27.44\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 30 Aug 2017 01:27:45 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=QrOsrxESDwKE+7st9WZuIhYk9CDAUHQqx+T4+zdOsLw=;\n\tb=RHGzI30OQ+u82W+Rq6jHZ5tejVmxCZOrf0uWTgfCMawSad9lM370OahuWn44a3UCdJ\n\tgnDJFJH2nlEyHOW4rl3DziZeWJDiULEkk8Ajr2iDxePyNiQhh9uEogTOXmGWz826EaCY\n\tbLaIrDXjE73PKty0QGMM086QhQcYVLrK73LRVCmlChKcAGf6/92fO5l57/KHlo9tMqdP\n\t4Wf/RFvJv+f5NOY8FU1rqLCAORr3IKxQqb8lHre89pL66W2ido9dy+05WvPaaLReD8np\n\tafglHW/FVaEjDabvNIQF3mJSi+liceEgCAoQYUNlq+3LYWC5fFZTL/TM/NwneW7dQqUD\n\tgXUQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=QrOsrxESDwKE+7st9WZuIhYk9CDAUHQqx+T4+zdOsLw=;\n\tb=LWftKSDCVxpHs54czIusnsdYQCyArBKOLdbCHNIgg1HUkoKhzdt0V0dQ3J0T7Wy6+d\n\tRvr4I/o6ON0Ou0SSLTpKYp0ab3kIwpLDJjMgbjYylzGJUT0EJR0KB4vzJq3TKsUfyzJt\n\tJcfz6fFo3v0VY4kitoNe0wy0HmWU4yI+QQmRHX5NNhJjofg6f3n3uKxMizdXAgDa9pzt\n\tfHMUCCbie9+4jEUE4J2/2d0LhAnkglJUCqemRVA8GT+RLKYcRDJc7yYir+hRw8m2zM4a\n\t0oULRtWc1e+Byte4fMp0W0/17OQ4UVIERKrKhIIHToaSRgi4fTf2UAuYR1crDLsrg/3p\n\t7dgw==",
        "X-Gm-Message-State": "AHPjjUi80I6+EK0awPS+S8OqDiN0KBRP8+Okyt7ZBWhwN7byVdFI+thC\n\tGF6bUdUjapUA51Q9",
        "X-Received": "by 10.176.3.143 with SMTP id 15mr403859uau.85.1504081665735;\n\tWed, 30 Aug 2017 01:27:45 -0700 (PDT)",
        "From": "Sergio Andres Gomez Del Real <sergio.g.delreal@gmail.com>",
        "X-Google-Original-From": "Sergio Andres Gomez Del Real\n\t<Sergio.G.DelReal@gmail.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Wed, 30 Aug 2017 03:26:58 -0500",
        "Message-Id": "<20170830082702.3011-10-Sergio.G.DelReal@gmail.com>",
        "X-Mailer": "git-send-email 2.11.0",
        "In-Reply-To": "<20170830082702.3011-1-Sergio.G.DelReal@gmail.com>",
        "References": "<20170830082702.3011-1-Sergio.G.DelReal@gmail.com>",
        "X-detected-operating-system": "by eggs.gnu.org: Genre and OS details not\n\trecognized.",
        "X-Received-From": "2607:f8b0:400c:c08::241",
        "Subject": "[Qemu-devel] [PATCH v2 09/13] hvf: refactor cpuid code",
        "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": "Sergio Andres Gomez Del Real <Sergio.G.DelReal@gmail.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": "This patch generalizes some code in cpu.c, sharing code and data between\nhvf and kvm. It also beings calling the new hvf_get_supported_cpuid\nwhere appropriate.\n\nSigned-off-by: Sergio Andres Gomez Del Real <Sergio.G.DelReal@gmail.com>\n---\n target/i386/cpu-qom.h |  4 +--\n target/i386/cpu.c     | 80 ++++++++++++++++++++++++++++++++++++++-------------\n 2 files changed, 62 insertions(+), 22 deletions(-)",
    "diff": "diff --git a/target/i386/cpu-qom.h b/target/i386/cpu-qom.h\nindex c2205e6077..22f95eb3a4 100644\n--- a/target/i386/cpu-qom.h\n+++ b/target/i386/cpu-qom.h\n@@ -47,7 +47,7 @@ typedef struct X86CPUDefinition X86CPUDefinition;\n /**\n  * X86CPUClass:\n  * @cpu_def: CPU model definition\n- * @kvm_required: Whether CPU model requires KVM to be enabled.\n+ * @host_cpuid_required: Whether CPU model requires cpuid from host.\n  * @ordering: Ordering on the \"-cpu help\" CPU model list.\n  * @migration_safe: See CpuDefinitionInfo::migration_safe\n  * @static_model: See CpuDefinitionInfo::static\n@@ -66,7 +66,7 @@ typedef struct X86CPUClass {\n      */\n     X86CPUDefinition *cpu_def;\n \n-    bool kvm_required;\n+    bool host_cpuid_required;\n     int ordering;\n     bool migration_safe;\n     bool static_model;\ndiff --git a/target/i386/cpu.c b/target/i386/cpu.c\nindex ddc45abd70..01957411bd 100644\n--- a/target/i386/cpu.c\n+++ b/target/i386/cpu.c\n@@ -22,6 +22,7 @@\n #include \"cpu.h\"\n #include \"exec/exec-all.h\"\n #include \"sysemu/kvm.h\"\n+#include \"sysemu/hvf.h\"\n #include \"sysemu/cpus.h\"\n #include \"kvm_i386.h\"\n \n@@ -613,6 +614,15 @@ static uint32_t xsave_area_size(uint64_t mask)\n     return ret;\n }\n \n+static inline bool accel_uses_host_cpuid(void)\n+{\n+    if (kvm_enabled() || hvf_enabled()) {\n+        return true;\n+    } else {\n+        return false;\n+    }\n+}\n+\n static inline uint64_t x86_cpu_xsave_components(X86CPU *cpu)\n {\n     return ((uint64_t)cpu->env.features[FEAT_XSAVE_COMP_HI]) << 32 |\n@@ -1643,10 +1653,15 @@ static void max_x86_cpu_initfn(Object *obj)\n      */\n     cpu->max_features = true;\n \n-    if (kvm_enabled()) {\n+    if (accel_uses_host_cpuid()) {\n         char vendor[CPUID_VENDOR_SZ + 1] = { 0 };\n         char model_id[CPUID_MODEL_ID_SZ + 1] = { 0 };\n         int family, model, stepping;\n+        X86CPUDefinition host_cpudef = { };\n+        uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;\n+\n+        host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx);\n+        x86_cpu_vendor_words2str(host_cpudef.vendor, ebx, edx, ecx);\n \n         host_vendor_fms(vendor, &family, &model, &stepping);\n \n@@ -1660,12 +1675,21 @@ static void max_x86_cpu_initfn(Object *obj)\n         object_property_set_str(OBJECT(cpu), model_id, \"model-id\",\n                                 &error_abort);\n \n-        env->cpuid_min_level =\n-            kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);\n-        env->cpuid_min_xlevel =\n-            kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);\n-        env->cpuid_min_xlevel2 =\n-            kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);\n+        if (kvm_enabled()) {\n+            env->cpuid_min_level =\n+                kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);\n+            env->cpuid_min_xlevel =\n+                kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);\n+            env->cpuid_min_xlevel2 =\n+                kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);\n+        } else {\n+            env->cpuid_min_level =\n+                hvf_get_supported_cpuid(0x0, 0, R_EAX);\n+            env->cpuid_min_xlevel =\n+                hvf_get_supported_cpuid(0x80000000, 0, R_EAX);\n+            env->cpuid_min_xlevel2 =\n+                hvf_get_supported_cpuid(0xC0000000, 0, R_EAX);\n+        }\n \n         if (lmce_supported()) {\n             object_property_set_bool(OBJECT(cpu), true, \"lmce\", &error_abort);\n@@ -1691,18 +1715,21 @@ static const TypeInfo max_x86_cpu_type_info = {\n     .class_init = max_x86_cpu_class_init,\n };\n \n-#ifdef CONFIG_KVM\n-\n+#if defined(CONFIG_KVM) || defined(CONFIG_HVF)\n static void host_x86_cpu_class_init(ObjectClass *oc, void *data)\n {\n     X86CPUClass *xcc = X86_CPU_CLASS(oc);\n \n-    xcc->kvm_required = true;\n+    xcc->host_cpuid_required = true;\n     xcc->ordering = 8;\n \n-    xcc->model_description =\n-        \"KVM processor with all supported host features \"\n-        \"(only available in KVM mode)\";\n+    if (kvm_enabled()) {\n+        xcc->model_description =\n+            \"KVM processor with all supported host features \";\n+    } else if (hvf_enabled()) {\n+        xcc->model_description =\n+            \"HVF processor with all supported host features \";\n+    }\n }\n \n static const TypeInfo host_x86_cpu_type_info = {\n@@ -1724,7 +1751,7 @@ static void report_unavailable_features(FeatureWord w, uint32_t mask)\n             assert(reg);\n             fprintf(stderr, \"warning: %s doesn't support requested feature: \"\n                 \"CPUID.%02XH:%s%s%s [bit %d]\\n\",\n-                kvm_enabled() ? \"host\" : \"TCG\",\n+                accel_uses_host_cpuid() ? \"host\" : \"TCG\",\n                 f->cpuid_eax, reg,\n                 f->feat_names[i] ? \".\" : \"\",\n                 f->feat_names[i] ? f->feat_names[i] : \"\", i);\n@@ -2175,7 +2202,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,\n     Error *err = NULL;\n     strList **next = missing_feats;\n \n-    if (xcc->kvm_required && !kvm_enabled()) {\n+    if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {\n         strList *new = g_new0(strList, 1);\n         new->value = g_strdup(\"kvm\");;\n         *missing_feats = new;\n@@ -2337,6 +2364,10 @@ static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,\n         r = kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid_eax,\n                                                     wi->cpuid_ecx,\n                                                     wi->cpuid_reg);\n+    } else if (hvf_enabled()) {\n+        r = hvf_get_supported_cpuid(wi->cpuid_eax,\n+                                    wi->cpuid_ecx,\n+                                    wi->cpuid_reg);\n     } else if (tcg_enabled()) {\n         r = wi->tcg_features;\n     } else {\n@@ -2396,6 +2427,7 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp)\n     }\n \n     /* Special cases not set in the X86CPUDefinition structs: */\n+    /* TODO: implement for hvf */\n     if (kvm_enabled()) {\n         if (!kvm_irqchip_in_kernel()) {\n             x86_cpu_change_kvm_default(\"x2apic\", \"off\");\n@@ -2416,7 +2448,7 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp)\n      * when doing cross vendor migration\n      */\n     vendor = def->vendor;\n-    if (kvm_enabled()) {\n+    if (accel_uses_host_cpuid()) {\n         uint32_t  ebx = 0, ecx = 0, edx = 0;\n         host_cpuid(0, 0, NULL, &ebx, &ecx, &edx);\n         x86_cpu_vendor_words2str(host_vendor, ebx, edx, ecx);\n@@ -2872,6 +2904,11 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,\n             *ebx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX);\n             *ecx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_ECX);\n             *edx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EDX);\n+        } else if (hvf_enabled() && cpu->enable_pmu) {\n+            *eax = hvf_get_supported_cpuid(0xA, count, R_EAX);\n+            *ebx = hvf_get_supported_cpuid(0xA, count, R_EBX);\n+            *ecx = hvf_get_supported_cpuid(0xA, count, R_ECX);\n+            *edx = hvf_get_supported_cpuid(0xA, count, R_EDX);\n         } else {\n             *eax = 0;\n             *ebx = 0;\n@@ -3220,6 +3257,7 @@ static void x86_cpu_reset(CPUState *s)\n \n     s->halted = !cpu_is_bsp(cpu);\n \n+    /* TODO: implement for hvf */\n     if (kvm_enabled()) {\n         kvm_arch_reset_vcpu(cpu);\n     }\n@@ -3262,6 +3300,7 @@ APICCommonClass *apic_get_class(void)\n {\n     const char *apic_type = \"apic\";\n \n+    /* TODO: implement for hvf */\n     if (kvm_apic_in_kernel()) {\n         apic_type = \"kvm-apic\";\n     } else if (xen_enabled()) {\n@@ -3492,6 +3531,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)\n         }\n     }\n \n+    /* TODO: implement for hvf */\n     if (!kvm_enabled() || !cpu->expose_kvm) {\n         env->features[FEAT_KVM] = 0;\n     }\n@@ -3575,7 +3615,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)\n     Error *local_err = NULL;\n     static bool ht_warned;\n \n-    if (xcc->kvm_required && !kvm_enabled()) {\n+    if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {\n         char *name = x86_cpu_class_get_model_name(xcc);\n         error_setg(&local_err, \"CPU model '%s' requires KVM\", name);\n         g_free(name);\n@@ -3597,7 +3637,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)\n         x86_cpu_report_filtered_features(cpu);\n         if (cpu->enforce_cpuid) {\n             error_setg(&local_err,\n-                       kvm_enabled() ?\n+                       accel_uses_host_cpuid() ?\n                            \"Host doesn't support requested features\" :\n                            \"TCG doesn't support requested features\");\n             goto out;\n@@ -3620,7 +3660,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)\n      * consumer AMD devices but nothing else.\n      */\n     if (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) {\n-        if (kvm_enabled()) {\n+        if (accel_uses_host_cpuid()) {\n             uint32_t host_phys_bits = x86_host_phys_bits();\n             static bool warned;\n \n@@ -4207,7 +4247,7 @@ static void x86_cpu_register_types(void)\n     }\n     type_register_static(&max_x86_cpu_type_info);\n     type_register_static(&x86_base_cpu_type_info);\n-#ifdef CONFIG_KVM\n+#if defined(CONFIG_KVM) || defined(CONFIG_HVF)\n     type_register_static(&host_x86_cpu_type_info);\n #endif\n }\n",
    "prefixes": [
        "v2",
        "09/13"
    ]
}