get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 813241,
    "url": "http://patchwork.ozlabs.org/api/patches/813241/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170913090522.4022-13-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": "<20170913090522.4022-13-Sergio.G.DelReal@gmail.com>",
    "list_archive_url": null,
    "date": "2017-09-13T09:05:20",
    "name": "[v4,12/14] hvf: implement vga dirty page tracking",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "6659621a8c5892f4947ee7c706d5567429f5f53b",
    "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/20170913090522.4022-13-Sergio.G.DelReal@gmail.com/mbox/",
    "series": [
        {
            "id": 2843,
            "url": "http://patchwork.ozlabs.org/api/series/2843/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2843",
            "date": "2017-09-13T09:05:08",
            "name": "add support for Hypervisor.framework in QEMU",
            "version": 4,
            "mbox": "http://patchwork.ozlabs.org/series/2843/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/813241/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/813241/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=\"Ct5Fs14f\"; 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 3xsbTM0qGtz9sMN\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 19:09:43 +1000 (AEST)",
            "from localhost ([::1]:41067 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 1ds3fx-0004jB-5a\n\tfor incoming@patchwork.ozlabs.org; Wed, 13 Sep 2017 05:09:41 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:34146)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <sergio.g.delreal@gmail.com>) id 1ds3cT-0001d2-Jv\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:06:11 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <sergio.g.delreal@gmail.com>) id 1ds3cQ-0007Zp-Bz\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:06:05 -0400",
            "from mail-vk0-x241.google.com ([2607:f8b0:400c:c05::241]:37927)\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 1ds3cQ-0007ZZ-73\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:06:02 -0400",
            "by mail-vk0-x241.google.com with SMTP id o22so3314276vke.5\n\tfor <qemu-devel@nongnu.org>; Wed, 13 Sep 2017 02:06:02 -0700 (PDT)",
            "from localhost.localdomain ([190.66.154.128])\n\tby smtp.gmail.com with ESMTPSA id\n\tr74sm2677601vkf.19.2017.09.13.02.06.00\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 13 Sep 2017 02:06:01 -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=KJt+yXyDCs+mmD+C9i/So0UQSaJMwhL06MIIrpsXejc=;\n\tb=Ct5Fs14fm/y5xI9pcMAycVRJRxxIu+H4f5zDr7bOLue+XgNbz4Zd90+ov9zxD4FFTm\n\tf2wv6lZRaOMQXgzy/FiMOSfSJxp+xhQ7FSY0ctTsEKbKZOqnNGTK+6Qi5Wx6mNxbRZTH\n\txESo1h0vTcPQAX/J9Ym2+o+0S8FTrM1FCeBZygOMVU0LbO/Z5bA21ZfmArfHzGIQoHGD\n\tYrpvhHdJcsSbpug7n72pk+sqyvbihZDu9E0FMq1y7PgBuOdb5llhnoTAdoQFPdOEumlJ\n\tI0hslUDiW1kgqZws4W8J9ag/N5KxyrnaDEGo+x2hjxsZd/lX93AEXKwhbbRe15Lg4djN\n\t5Xtg==",
        "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=KJt+yXyDCs+mmD+C9i/So0UQSaJMwhL06MIIrpsXejc=;\n\tb=ME6Sr5VCq75TzqiUt/xxnOMe2ZELh0v++OiuDZhZPEGH8/mfiAA+BFzS+CIYIgai5U\n\tmaKGOsKhsF80nwHr7ScR6sR7WWnWAb370dMqqZGSmSDaiH240VXyXwRN9YoQySEAQXKM\n\t66/g7jmXQ6wGmZaLt0bGi1v7+IzZmetKqcGBq8nuPlHuAIZ3MKR9aNzjUVn6T9vJi7+8\n\tfmoEL5/np94VKIHp4ARUedXHot6FJtQw5lWQVgBkVw9AlWSQkNEHU0KgPA5PT9a7Lb3E\n\t67+ZOfunsJhWhmVPTYSMXHgiD/Qyc8t5ZAz9h5KwRnG3xwOQep7pWjQo7l0OZy/+mE57\n\t3PWA==",
        "X-Gm-Message-State": "AHPjjUjOQI5yWElJjxqp8BYbrSsT2Pd1HooRLwNF7Qr9D9hPtsPvyosA\n\tMn2XPIYo5wqjONLr",
        "X-Google-Smtp-Source": "AOwi7QA8VS2N2uuiNTraPae7d4GolyCTkYISPmpHBUwVqKUFJcYF0zbeqcu6W8pL7gc0So+zWVbTVQ==",
        "X-Received": "by 10.31.14.203 with SMTP id 194mr12753682vko.77.1505293561495; \n\tWed, 13 Sep 2017 02:06:01 -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, 13 Sep 2017 04:05:20 -0500",
        "Message-Id": "<20170913090522.4022-13-Sergio.G.DelReal@gmail.com>",
        "X-Mailer": "git-send-email 2.11.0",
        "In-Reply-To": "<20170913090522.4022-1-Sergio.G.DelReal@gmail.com>",
        "References": "<20170913090522.4022-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::241",
        "Subject": "[Qemu-devel] [PATCH v4 12/14] hvf: implement vga dirty page tracking",
        "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>,\n\tpbonzini@redhat.com, stefanha@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 implements setting the tracking of dirty vga pages, using hvf's\ninterface to protect guest memory. It uses the MemoryListener callback\nmechanism through .log_start/stop/sync\n\nSigned-off-by: Sergio Andres Gomez Del Real <Sergio.G.DelReal@gmail.com>\n---\n include/sysemu/hvf.h  |  5 ++++\n target/i386/hvf-all.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++-----\n 2 files changed, 72 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h\nindex 9230c13851..f54e043955 100644\n--- a/include/sysemu/hvf.h\n+++ b/include/sysemu/hvf.h\n@@ -34,11 +34,16 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,\n #define hvf_get_supported_cpuid(func, idx, reg) 0\n #endif\n \n+/* hvf_slot flags */\n+#define HVF_SLOT_LOG (1 << 0)\n+\n typedef struct hvf_slot {\n     uint64_t start;\n     uint64_t size;\n     uint8_t *mem;\n     int slot_id;\n+    uint32_t flags;\n+    MemoryRegion *region;\n } hvf_slot;\n \n typedef struct hvf_vcpu_caps {\ndiff --git a/target/i386/hvf-all.c b/target/i386/hvf-all.c\nindex 97f4ded673..e8466e6f47 100644\n--- a/target/i386/hvf-all.c\n+++ b/target/i386/hvf-all.c\n@@ -195,6 +195,7 @@ void hvf_set_phys_mem(MemoryRegionSection *section, bool add)\n     mem->size = int128_get64(section->size);\n     mem->mem = memory_region_get_ram_ptr(area) + section->offset_within_region;\n     mem->start = section->offset_within_address_space;\n+    mem->region = area;\n \n     if (do_hvf_set_memory(mem)) {\n         error_report(\"Error registering new memory slot\\n\");\n@@ -291,8 +292,7 @@ void hvf_cpu_synchronize_post_init(CPUState *cpu_state)\n     run_on_cpu(cpu_state, _hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL);\n }\n \n-/* TODO: ept fault handlig */\n-static bool ept_emulation_fault(uint64_t ept_qual)\n+static bool ept_emulation_fault(hvf_slot *slot, addr_t gpa, uint64_t ept_qual)\n {\n     int read, write;\n \n@@ -308,6 +308,14 @@ static bool ept_emulation_fault(uint64_t ept_qual)\n         return false;\n     }\n \n+    if (write && slot) {\n+        if (slot->flags & HVF_SLOT_LOG) {\n+            memory_region_set_dirty(slot->region, gpa - slot->start, 1);\n+            hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size,\n+                          HV_MEMORY_READ | HV_MEMORY_WRITE);\n+        }\n+    }\n+\n     /*\n      * The EPT violation must have been caused by accessing a\n      * guest-physical address that is a translation of a guest-linear\n@@ -318,7 +326,59 @@ static bool ept_emulation_fault(uint64_t ept_qual)\n         return false;\n     }\n \n-    return true;\n+    return !slot;\n+}\n+\n+static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on)\n+{\n+    struct mac_slot *macslot;\n+    hvf_slot *slot;\n+\n+    slot = hvf_find_overlap_slot(\n+            section->offset_within_address_space,\n+            section->offset_within_address_space + int128_get64(section->size));\n+\n+    /* protect region against writes; begin tracking it */\n+    if (on) {\n+        slot->flags |= HVF_SLOT_LOG;\n+        hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size,\n+                      HV_MEMORY_READ);\n+    /* stop tracking region*/\n+    } else {\n+        slot->flags &= ~HVF_SLOT_LOG;\n+        hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size,\n+                      HV_MEMORY_READ | HV_MEMORY_WRITE);\n+    }\n+}\n+\n+static void hvf_log_start(MemoryListener *listener,\n+                          MemoryRegionSection *section, int old, int new)\n+{\n+    if (old != 0) {\n+        return;\n+    }\n+\n+    hvf_set_dirty_tracking(section, 1);\n+}\n+\n+static void hvf_log_stop(MemoryListener *listener,\n+                         MemoryRegionSection *section, int old, int new)\n+{\n+    if (new != 0) {\n+        return;\n+    }\n+\n+    hvf_set_dirty_tracking(section, 0);\n+}\n+\n+static void hvf_log_sync(MemoryListener *listener,\n+                         MemoryRegionSection *section)\n+{\n+    /*\n+     * sync of dirty pages is handled elsewhere; just make sure we keep\n+     * tracking the region.\n+     */\n+    hvf_set_dirty_tracking(section, 1);\n }\n \n static void hvf_region_add(MemoryListener *listener,\n@@ -337,6 +397,9 @@ static MemoryListener hvf_memory_listener = {\n     .priority = 10,\n     .region_add = hvf_region_add,\n     .region_del = hvf_region_del,\n+    .log_start = hvf_log_start,\n+    .log_stop = hvf_log_stop,\n+    .log_sync = hvf_log_sync,\n };\n \n void hvf_reset_vcpu(CPUState *cpu) {\n@@ -609,7 +672,7 @@ int hvf_vcpu_exec(CPUState *cpu)\n \n             slot = hvf_find_overlap_slot(gpa, gpa);\n             /* mmio */\n-            if (ept_emulation_fault(exit_qual) && !slot) {\n+            if (ept_emulation_fault(slot, gpa, exit_qual)) {\n                 struct x86_decode decode;\n \n                 load_regs(cpu);\n@@ -620,9 +683,6 @@ int hvf_vcpu_exec(CPUState *cpu)\n                 store_regs(cpu);\n                 break;\n             }\n-#ifdef DIRTY_VGA_TRACKING\n-            /* TODO: handle dirty page tracking */\n-#endif\n             break;\n         }\n         case EXIT_REASON_INOUT:\n",
    "prefixes": [
        "v4",
        "12/14"
    ]
}