Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/807470/?format=api
{ "id": 807470, "url": "http://patchwork.ozlabs.org/api/patches/807470/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170830082702.3011-11-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-11-Sergio.G.DelReal@gmail.com>", "list_archive_url": null, "date": "2017-08-30T08:26:59", "name": "[v2,10/13] hvf: implement vga dirty page tracking", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "350cf3cf39788b4edaa8d7119eceb9789284beb0", "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-11-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/807470/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/807470/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=\"ULKrccsS\"; 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 3xhzH529kNz9t0M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 18:30:57 +1000 (AEST)", "from localhost ([::1]:48993 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 1dmyOl-0004fj-1k\n\tfor incoming@patchwork.ozlabs.org; Wed, 30 Aug 2017 04:30:55 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:60560)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <sergio.g.delreal@gmail.com>) id 1dmyLl-0002Wr-6B\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 1dmyLj-0000PZ-QW\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:27:49 -0400", "from mail-ua0-x244.google.com ([2607:f8b0:400c:c08::244]:38585)\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 1dmyLj-0000PM-Ly\n\tfor qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:27:47 -0400", "by mail-ua0-x244.google.com with SMTP id j46so2338110uag.5\n\tfor <qemu-devel@nongnu.org>; Wed, 30 Aug 2017 01:27:47 -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.45\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 30 Aug 2017 01:27:46 -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=CTNM5L4Xmh4dVTa4NSNHLTcPN4ovl+cy/TjtiQQxXIQ=;\n\tb=ULKrccsSCB7s41IccBwwdpjrnKuaafMZivgl9Fjr7F3j+45tiHvdML+waMIKb1Hun2\n\tvj8NWCi5Og0uC8u/DxNX8h6J9UWzCONpSa4R9ao5PxA2niYJAbWh+Qt2OzhGvPiJzv3C\n\teHImFO2jjf7t/HysNTMZ794Jvilvr27ucH4g0Ug7G4ZxId308gPPrKIG9wkBZwWg9/W3\n\tL1rL427B21mSvuvAyTQACcKlZTVX/3Gh3J8K9+Xnr5gQBkuawKU9eOqm3zD3Vr5VL+FV\n\tgeu4aqTjCx/zd1ZY01vlwmcI3KXGJjxd+S7JlSE0DvyxsogFY3/DXpAjLaWFGmtH2Yl0\n\tR9NQ==", "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=CTNM5L4Xmh4dVTa4NSNHLTcPN4ovl+cy/TjtiQQxXIQ=;\n\tb=Qh6Xc2Gq9fr8TYC8sxf80YOE3f+BKSHTL4AbAsxJ9NJeMY9mF+r/9Xz2eRH6RMOKNY\n\txFQsGMy+ivrtN9UQs98JM1uZRPH98ydCLD1lpJDeX24/yEd304KY2zktUeGKtOXZgCBc\n\t+ludIMOQUMLXMVlGjK/HJpOBQ6Q/JFdpxlyZcxwt3aIgkanI5ICZ9vysEo17fE64MXgy\n\tuLgJoJ7JFU0Fc6bFAtgawnFv1pID/bGeVr1zAbJ2OSE/mDrG6NI0nk72JiI3gJRdHmqa\n\ttLIfnnF8MWQZYaFBSfe+mtHFUM6/MXoMuyPwKOEHlR4qDSvkdv+lIWTh9A2cy9tzwyZO\n\t5PKQ==", "X-Gm-Message-State": "AHYfb5jZKik6cPD+cTyw5qiGjNo2My48OaufqtSF+VMIexZK2uACbY+f\n\tO0BoZ51uHkfVY/Y+", "X-Received": "by 10.176.16.66 with SMTP id g2mr444203uab.17.1504081666943;\n\tWed, 30 Aug 2017 01:27:46 -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:59 -0500", "Message-Id": "<20170830082702.3011-11-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::244", "Subject": "[Qemu-devel] [PATCH v2 10/13] 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>", "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 implements setting the tracking of dirty 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 | 72 ++++++++++++++++++++++++++++++++++++++++++++++-----\n 2 files changed, 70 insertions(+), 7 deletions(-)", "diff": "diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h\nindex 944b014596..43b02be63c 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 struct hvf_vcpu_caps {\ndiff --git a/target/i386/hvf-all.c b/target/i386/hvf-all.c\nindex 6aba6b4eea..4b213d7f76 100644\n--- a/target/i386/hvf-all.c\n+++ b/target/i386/hvf-all.c\n@@ -189,6 +189,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@@ -458,8 +459,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@@ -475,6 +475,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@@ -485,7 +493,57 @@ 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+ 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+ 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@@ -504,6 +562,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 vmx_reset_vcpu(CPUState *cpu) {\n@@ -775,7 +836,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@@ -786,9 +847,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": [ "v2", "10/13" ] }