get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 806343,
    "url": "http://patchwork.ozlabs.org/api/patches/806343/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170828015654.2530-4-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": "<20170828015654.2530-4-Sergio.G.DelReal@gmail.com>",
    "list_archive_url": null,
    "date": "2017-08-28T01:56:43",
    "name": "[03/14] hvf: add conditional macros around hvf code in cpus.c",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "779fa68f3f0c04ed818451a6f55f2ee9ab8e102a",
    "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/20170828015654.2530-4-Sergio.G.DelReal@gmail.com/mbox/",
    "series": [
        {
            "id": 56,
            "url": "http://patchwork.ozlabs.org/api/series/56/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=56",
            "date": "2017-08-28T01:56:40",
            "name": "add support for Hypervisor.framework in QEMU",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/56/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/806343/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/806343/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=\"ZBKB39NI\"; 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 3xgZnN4r6Sz9sNq\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 28 Aug 2017 12:03:51 +1000 (AEST)",
            "from localhost ([::1]:36522 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 1dm9P2-0000xb-Hv\n\tfor incoming@patchwork.ozlabs.org; Sun, 27 Aug 2017 22:03:48 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:41994)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <sergio.g.delreal@gmail.com>) id 1dm9Ix-0004rl-Mk\n\tfor qemu-devel@nongnu.org; Sun, 27 Aug 2017 21:57:33 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <sergio.g.delreal@gmail.com>) id 1dm9Iv-00010K-CJ\n\tfor qemu-devel@nongnu.org; Sun, 27 Aug 2017 21:57:31 -0400",
            "from mail-vk0-x244.google.com ([2607:f8b0:400c:c05::244]:37140)\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 1dm9Iv-0000zz-71\n\tfor qemu-devel@nongnu.org; Sun, 27 Aug 2017 21:57:29 -0400",
            "by mail-vk0-x244.google.com with SMTP id z187so1877393vkd.4\n\tfor <qemu-devel@nongnu.org>; Sun, 27 Aug 2017 18:57:29 -0700 (PDT)",
            "from localhost.localdomain ([191.109.6.191])\n\tby smtp.gmail.com with ESMTPSA id\n\ty12sm2696824uad.22.2017.08.27.18.57.25\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 27 Aug 2017 18:57:27 -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=dUYjTN7Ps1buW6kO/wtAAGgIV8YHZhsQ1gHWEtb8Wpc=;\n\tb=ZBKB39NIPjG+5z8ZXdrSQRqvzXSyAtXWTbnlAzgM3wlK6ZcvI4XCysLpV9n7kcwgzR\n\tb3RGjf1yKUxcp5CPHKfipmzDQCvzz3wTrKZb5gXjvRFVHZF5Yv2Niuw5cGXVIt+/OgLO\n\tOpXu17Tw21iABiDiM7eEJBGQCxlJ3PKEILV1MKB2nXGU8rg8hIteaeLXcppgewdzQozG\n\tyV6CbAc59isVItmWWV09LKZoXUzg++hYYX/nj3Y6kmz/wzl3BE59l+6lLe+cNlbNz3oF\n\tHTwPpwCkGWPrwVsLsK+m3ixPVfGR0AKkhdGZMuVNHUFcwLVN0CyToXk9xjhosUpmaKuh\n\tFwHA==",
        "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=dUYjTN7Ps1buW6kO/wtAAGgIV8YHZhsQ1gHWEtb8Wpc=;\n\tb=IjRDo+6b36h5ceFz+Ry9rhSalAC1P1tDlaEitiiaSgUWFHMMzD8XHpdcn63Sz7SriJ\n\t42eEQ16B98H6me2OOntgPXkiklKdziGLGI8OZlk6wsUwh/hMEYlsDsjuQK4jW1i1pIML\n\t4x2UWoMnNXktzLGDIrKdcGWdDf9orU1gdlHFCMMPLwlFMu66gftIYkn8xFTD9xX8eKz9\n\tGSV1Uschc0zFVy+UHshHh0imoe/LdmhW+Sf5URN8FCW3olGTbVxhGWCLQtXgjT6F1u0/\n\tmYWTVWQmCROx9LLmka3srYvp3iFcbmk3X366zf3Qp7lj7EyRuDdQbpRH6iw2Sx/M2s0E\n\tf98w==",
        "X-Gm-Message-State": "AHYfb5iQvxyJD6FP6JyprRWbMu1J1KQSPf3V6nr+xFRivi+cv+B60oO/\n\tKCETUk0/QHt/Y77J",
        "X-Received": "by 10.31.185.65 with SMTP id j62mr3213857vkf.192.1503885448295; \n\tSun, 27 Aug 2017 18:57:28 -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": "Sun, 27 Aug 2017 20:56:43 -0500",
        "Message-Id": "<20170828015654.2530-4-Sergio.G.DelReal@gmail.com>",
        "X-Mailer": "git-send-email 2.11.0",
        "In-Reply-To": "<20170828015654.2530-1-Sergio.G.DelReal@gmail.com>",
        "References": "<20170828015654.2530-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:c05::244",
        "Subject": "[Qemu-devel] [PATCH 03/14] hvf: add conditional macros around hvf\n\tcode in cpus.c",
        "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 commit surrounds the hvf parts of cpus.c with conditional macros so\nthat they are rightly ignored on other platforms.\n\nSigned-off-by: Sergio Andres Gomez Del Real <Sergio.G.DelReal@gmail.com>\n---\n cpus.c               | 147 +++++++++++++++++++++++++++++++++++----------------\n include/sysemu/hvf.h |   5 +-\n 2 files changed, 105 insertions(+), 47 deletions(-)",
    "diff": "diff --git a/cpus.c b/cpus.c\nindex a2cd9dfa5d..6754ce17cc 100644\n--- a/cpus.c\n+++ b/cpus.c\n@@ -37,6 +37,7 @@\n #include \"sysemu/hw_accel.h\"\n #include \"sysemu/kvm.h\"\n #include \"sysemu/hax.h\"\n+#include \"sysemu/hvf.h\"\n #include \"qmp-commands.h\"\n #include \"exec/exec-all.h\"\n \n@@ -81,6 +82,9 @@ static unsigned int throttle_percentage;\n #define CPU_THROTTLE_PCT_MAX 99\n #define CPU_THROTTLE_TIMESLICE_NS 10000000\n \n+/* For temporary buffers for forming a name */\n+#define VCPU_THREAD_NAME_SIZE 16\n+\n bool cpu_is_stopped(CPUState *cpu)\n {\n     return cpu->stopped || !runstate_is_running();\n@@ -900,6 +904,11 @@ void cpu_synchronize_all_states(void)\n \n     CPU_FOREACH(cpu) {\n         cpu_synchronize_state(cpu);\n+#ifdef CONFIG_HVF\n+        if (hvf_enabled()) {\n+            hvf_cpu_synchronize_state(cpu);\n+        }\n+#endif\n     }\n }\n \n@@ -909,6 +918,11 @@ void cpu_synchronize_all_post_reset(void)\n \n     CPU_FOREACH(cpu) {\n         cpu_synchronize_post_reset(cpu);\n+#ifdef CONFIG_HVF\n+        if (hvf_enabled()) {\n+            hvf_cpu_synchronize_post_reset(cpu);\n+        }\n+#endif\n     }\n }\n \n@@ -918,6 +932,11 @@ void cpu_synchronize_all_post_init(void)\n \n     CPU_FOREACH(cpu) {\n         cpu_synchronize_post_init(cpu);\n+#ifdef CONFIG_HVF\n+        if (hvf_enabled()) {\n+            hvf_cpu_synchronize_post_init(cpu);\n+        }\n+#endif\n     }\n }\n \n@@ -1098,6 +1117,80 @@ static void qemu_kvm_wait_io_event(CPUState *cpu)\n     qemu_wait_io_event_common(cpu);\n }\n \n+#ifdef CONFIG_HVF\n+static void qemu_hvf_wait_io_event(CPUState *cpu)\n+{\n+    while (cpu_thread_is_idle(cpu)) {\n+        qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);\n+    }\n+    qemu_wait_io_event_common(cpu);\n+}\n+\n+/* The HVF-specific vCPU thread function. This one should only run when the host\n+ * CPU supports the VMX \"unrestricted guest\" feature. */\n+static void *qemu_hvf_cpu_thread_fn(void *arg)\n+{\n+    CPUState *cpu = arg;\n+\n+    int r;\n+\n+    assert(hvf_enabled());\n+\n+    rcu_register_thread();\n+\n+    qemu_mutex_lock_iothread();\n+    qemu_thread_get_self(cpu->thread);\n+\n+    cpu->thread_id = qemu_get_thread_id();\n+    cpu->can_do_io = 1;\n+    current_cpu = cpu;\n+\n+    hvf_init_vcpu(cpu);\n+\n+    /* signal CPU creation */\n+    cpu->created = true;\n+    qemu_cond_signal(&qemu_cpu_cond);\n+\n+    do {\n+        if (cpu_can_run(cpu)) {\n+            r = hvf_vcpu_exec(cpu);\n+            if (r == EXCP_DEBUG) {\n+                cpu_handle_guest_debug(cpu);\n+            }\n+        }\n+        qemu_hvf_wait_io_event(cpu);\n+    } while (!cpu->unplug || cpu_can_run(cpu));\n+\n+    hvf_vcpu_destroy(cpu);\n+    cpu->created = false;\n+    qemu_cond_signal(&qemu_cpu_cond);\n+    qemu_mutex_unlock_iothread();\n+    return NULL;\n+}\n+\n+static void qemu_hvf_start_vcpu(CPUState *cpu)\n+{\n+    char thread_name[VCPU_THREAD_NAME_SIZE];\n+\n+    /* HVF currently does not support TCG, and only runs in\n+     * unrestricted-guest mode. */\n+    assert(hvf_enabled());\n+\n+    cpu->thread = g_malloc0(sizeof(QemuThread));\n+    cpu->halt_cond = g_malloc0(sizeof(QemuCond));\n+    qemu_cond_init(cpu->halt_cond);\n+\n+    snprintf(thread_name, VCPU_THREAD_NAME_SIZE, \"CPU %d/HVF\",\n+             cpu->cpu_index);\n+    qemu_thread_create(cpu->thread, thread_name, qemu_hvf_cpu_thread_fn,\n+                       cpu, QEMU_THREAD_JOINABLE);\n+    while (!cpu->created) {\n+        qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);\n+    }\n+}\n+\n+#endif\n+\n static void *qemu_kvm_cpu_thread_fn(void *arg)\n {\n     CPUState *cpu = arg;\n@@ -1434,48 +1527,6 @@ static void *qemu_hax_cpu_thread_fn(void *arg)\n     return NULL;\n }\n \n-/* The HVF-specific vCPU thread function. This one should only run when the host\n- * CPU supports the VMX \"unrestricted guest\" feature. */\n-static void *qemu_hvf_cpu_thread_fn(void *arg)\n-{\n-    CPUState *cpu = arg;\n-\n-    int r;\n-\n-    assert(hvf_enabled());\n-\n-    rcu_register_thread();\n-\n-    qemu_mutex_lock_iothread();\n-    qemu_thread_get_self(cpu->thread);\n-\n-    cpu->thread_id = qemu_get_thread_id();\n-    cpu->can_do_io = 1;\n-    current_cpu = cpu;\n-\n-    hvf_init_vcpu(cpu);\n-\n-    /* signal CPU creation */\n-    cpu->created = true;\n-    qemu_cond_signal(&qemu_cpu_cond);\n-\n-    do {\n-        if (cpu_can_run(cpu)) {\n-            r = hvf_vcpu_exec(cpu);\n-            if (r == EXCP_DEBUG) {\n-                cpu_handle_guest_debug(cpu);\n-            }\n-        }\n-        qemu_hvf_wait_io_event(cpu);\n-    } while (!cpu->unplug || cpu_can_run(cpu));\n-\n-    hvf_vcpu_destroy(cpu);\n-    cpu->created = false;\n-    qemu_cond_signal(&qemu_cpu_cond);\n-    qemu_mutex_unlock_iothread();\n-    return NULL;\n-}\n-\n #ifdef _WIN32\n static void CALLBACK dummy_apc_func(ULONG_PTR unused)\n {\n@@ -1564,6 +1615,11 @@ static void qemu_cpu_kick_thread(CPUState *cpu)\n         fprintf(stderr, \"qemu:%s: %s\", __func__, strerror(err));\n         exit(1);\n     }\n+#ifdef CONFIG_HVF\n+    if (hvf_enabled()) {\n+        cpu_exit(cpu);\n+    }\n+#endif\n #else /* _WIN32 */\n     if (!qemu_cpu_is_self(cpu)) {\n         if (!QueueUserAPC(dummy_apc_func, cpu->hThread, 0)) {\n@@ -1698,9 +1754,6 @@ void cpu_remove_sync(CPUState *cpu)\n     }\n }\n \n-/* For temporary buffers for forming a name */\n-#define VCPU_THREAD_NAME_SIZE 16\n-\n static void qemu_tcg_init_vcpu(CPUState *cpu)\n {\n     char thread_name[VCPU_THREAD_NAME_SIZE];\n@@ -1816,6 +1869,10 @@ void qemu_init_vcpu(CPUState *cpu)\n         qemu_kvm_start_vcpu(cpu);\n     } else if (hax_enabled()) {\n         qemu_hax_start_vcpu(cpu);\n+#ifdef CONFIG_HVF\n+    } else if (hvf_enabled()) {\n+        qemu_hvf_start_vcpu(cpu);\n+#endif\n     } else if (tcg_enabled()) {\n         qemu_tcg_init_vcpu(cpu);\n     } else {\ndiff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h\nindex b96bd5e8ba..5e2b5f8f76 100644\n--- a/include/sysemu/hvf.h\n+++ b/include/sysemu/hvf.h\n@@ -20,10 +20,12 @@\n #include \"qemu/bitops.h\"\n #include \"exec/memory.h\"\n #include \"sysemu/accel.h\"\n+\n+#ifdef CONFIG_HVF\n #include <Hypervisor/hv.h>\n #include <Hypervisor/hv_vmx.h>\n #include <Hypervisor/hv_error.h>\n-\n+#endif\n \n typedef struct hvf_slot {\n     uint64_t start;\n@@ -85,7 +87,6 @@ void __hvf_cpu_synchronize_state(CPUState *, run_on_cpu_data);\n void __hvf_cpu_synchronize_post_reset(CPUState *, run_on_cpu_data);\n void vmx_update_tpr(CPUState *);\n void update_apic_tpr(CPUState *);\n-int apic_get_highest_priority_irr(DeviceState *);\n int hvf_put_registers(CPUState *);\n \n #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME(\"hvf\")\n",
    "prefixes": [
        "03/14"
    ]
}