get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 810757,
    "url": "http://patchwork.ozlabs.org/api/patches/810757/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150472268114.24907.6651243060428816063.stgit@frigg.lan/",
    "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": "<150472268114.24907.6651243060428816063.stgit@frigg.lan>",
    "list_archive_url": null,
    "date": "2017-09-06T18:31:21",
    "name": "[v4,17/20] instrument: Add event 'guest_mem_before_exec'",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "7d2a62cb12e952c69dbdf591d7c93146ef9b0bd6",
    "submitter": {
        "id": 9099,
        "url": "http://patchwork.ozlabs.org/api/people/9099/?format=api",
        "name": "Lluís Vilanova",
        "email": "vilanova@ac.upc.edu"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150472268114.24907.6651243060428816063.stgit@frigg.lan/mbox/",
    "series": [
        {
            "id": 1859,
            "url": "http://patchwork.ozlabs.org/api/series/1859/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1859",
            "date": "2017-09-06T17:22:41",
            "name": "instrument: Add basic event instrumentation",
            "version": 4,
            "mbox": "http://patchwork.ozlabs.org/series/1859/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/810757/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/810757/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>)",
        "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 3xnXHQ25XZz9sRY\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  7 Sep 2017 04:32:02 +1000 (AEST)",
            "from localhost ([::1]:37449 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 1dpf7I-0008Ri-Ey\n\tfor incoming@patchwork.ozlabs.org; Wed, 06 Sep 2017 14:32:00 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:54587)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpf6y-0008RG-QY\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:31:42 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpf6t-0002li-UB\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:31:40 -0400",
            "from roura.ac.upc.es ([147.83.33.10]:43208)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpf6t-0002lS-BE\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:31:35 -0400",
            "from correu-1.ac.upc.es (correu-1.ac.upc.es [147.83.30.91])\n\tby roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id v86IVSQt005348;\n\tWed, 6 Sep 2017 20:31:28 +0200",
            "from localhost (unknown [31.210.187.58])\n\tby correu-1.ac.upc.es (Postfix) with ESMTPSA id BC1D4355;\n\tWed,  6 Sep 2017 20:31:22 +0200 (CEST)"
        ],
        "From": "=?utf-8?b?TGx1w61z?= Vilanova <vilanova@ac.upc.edu>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Wed,  6 Sep 2017 21:31:21 +0300",
        "Message-Id": "<150472268114.24907.6651243060428816063.stgit@frigg.lan>",
        "X-Mailer": "git-send-email 2.14.1",
        "In-Reply-To": "<150471856141.24907.274176769201097378.stgit@frigg.lan>",
        "References": "<150471856141.24907.274176769201097378.stgit@frigg.lan>",
        "User-Agent": "StGit/0.17.1-dirty",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "quoted-printable",
        "X-MIME-Autoconverted": "from 8bit to quoted-printable by roura.ac.upc.es id\n\tv86IVSQt005348",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy]",
        "X-Received-From": "147.83.33.10",
        "Subject": "[Qemu-devel] [PATCH v4 17/20] instrument: Add event\n\t'guest_mem_before_exec'",
        "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": "Peter Crosthwaite <crosthwaite.peter@gmail.com>, \"Emilio G. Cota\"\n\t<cota@braap.org>, Stefan Hajnoczi <stefanha@redhat.com>, Paolo Bonzini\n\t<pbonzini@redhat.com>, =?utf-8?q?Llu=C3=ADs_Vilanova?=\n\t<vilanova@ac.upc.edu>, \tRichard Henderson <rth@twiddle.net>",
        "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: Lluís Vilanova <vilanova@ac.upc.edu>\n---\n include/exec/cpu_ldst_template.h          |    4 +++\n include/exec/cpu_ldst_useronly_template.h |    4 +++\n include/exec/helper-gen.h                 |    1 +\n include/exec/helper-proto.h               |    1 +\n include/exec/helper-tcg.h                 |    1 +\n instrument/control.c                      |   35 +++++++++++++++++++++++++++++\n instrument/control.h                      |   15 ++++++++++++\n instrument/events.h                       |    5 ++++\n instrument/events.inc.h                   |   18 ++++++++++++++-\n instrument/helpers.h                      |    1 +\n instrument/load.c                         |    1 +\n instrument/qemu-instr/control.h           |   21 +++++++++++++++++\n stubs/instrument.c                        |    2 ++\n 13 files changed, 108 insertions(+), 1 deletion(-)\n create mode 100644 instrument/helpers.h",
    "diff": "diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_template.h\nindex debbabcfb2..8018e8b16a 100644\n--- a/include/exec/cpu_ldst_template.h\n+++ b/include/exec/cpu_ldst_template.h\n@@ -28,6 +28,7 @@\n #include \"trace-root.h\"\n #endif\n \n+#include \"instrument/events.h\"\n #include \"trace/mem.h\"\n \n #if DATA_SIZE == 8\n@@ -89,6 +90,7 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,\n \n #if !defined(SOFTMMU_CODE_ACCESS)\n     TraceMemInfo meminfo = trace_mem_build_info(SHIFT, false, MO_TE, false);\n+    instr_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo);\n     trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo.raw);\n #endif\n \n@@ -126,6 +128,7 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,\n \n #if !defined(SOFTMMU_CODE_ACCESS)\n     TraceMemInfo meminfo = trace_mem_build_info(SHIFT, true, MO_TE, false);\n+    instr_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo);\n     trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo.raw);\n #endif\n \n@@ -167,6 +170,7 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env,\n \n #if !defined(SOFTMMU_CODE_ACCESS)\n     TraceMemInfo meminfo = trace_mem_build_info(SHIFT, false, MO_TE, true);\n+    instr_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo);\n     trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo.raw);\n #endif\n \ndiff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h\nindex b0b3fc1b8d..c36c50ae41 100644\n--- a/include/exec/cpu_ldst_useronly_template.h\n+++ b/include/exec/cpu_ldst_useronly_template.h\n@@ -27,6 +27,7 @@\n #include \"trace-root.h\"\n #endif\n \n+#include \"instrument/events.h\"\n #include \"trace/mem.h\"\n \n #if DATA_SIZE == 8\n@@ -62,6 +63,7 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)\n {\n #if !defined(CODE_ACCESS)\n     TraceMemInfo meminfo = trace_mem_build_info(DATA_SIZE, false, MO_TE, false);\n+    instr_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo);\n     trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo.raw);\n #endif\n     return glue(glue(ld, USUFFIX), _p)(g2h(ptr));\n@@ -81,6 +83,7 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)\n {\n #if !defined(CODE_ACCESS)\n     TraceMemInfo meminfo = trace_mem_build_info(DATA_SIZE, true, MO_TE, false);\n+    instr_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo);\n     trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo.raw);\n #endif\n     return glue(glue(lds, SUFFIX), _p)(g2h(ptr));\n@@ -102,6 +105,7 @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,\n {\n #if !defined(CODE_ACCESS)\n     TraceMemInfo meminfo = trace_mem_build_info(DATA_SIZE, false, MO_TE, true);\n+    instr_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo);\n     trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo.raw);\n #endif\n     glue(glue(st, SUFFIX), _p)(g2h(ptr), v);\ndiff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h\nindex 8239ffc77c..f351c3d050 100644\n--- a/include/exec/helper-gen.h\n+++ b/include/exec/helper-gen.h\n@@ -57,6 +57,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret)          \\\n }\n \n #include \"helper.h\"\n+#include \"instrument/helpers.h\"\n #include \"trace/generated-helpers.h\"\n #include \"trace/generated-helpers-wrappers.h\"\n #include \"tcg-runtime.h\"\ndiff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h\nindex 954bef85ce..8fdd02c132 100644\n--- a/include/exec/helper-proto.h\n+++ b/include/exec/helper-proto.h\n@@ -27,6 +27,7 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \\\n                             dh_ctype(t4), dh_ctype(t5));\n \n #include \"helper.h\"\n+#include \"instrument/helpers.h\"\n #include \"trace/generated-helpers.h\"\n #include \"tcg-runtime.h\"\n \ndiff --git a/include/exec/helper-tcg.h b/include/exec/helper-tcg.h\nindex b0c5bafa99..255e73c3e6 100644\n--- a/include/exec/helper-tcg.h\n+++ b/include/exec/helper-tcg.h\n@@ -40,6 +40,7 @@\n     | dh_sizemask(t5, 5) },\n \n #include \"helper.h\"\n+#include \"instrument/helpers.h\"\n #include \"trace/generated-helpers.h\"\n #include \"tcg-runtime.h\"\n \ndiff --git a/instrument/control.c b/instrument/control.c\nindex 3c3875dc99..f39e81d7c7 100644\n--- a/instrument/control.c\n+++ b/instrument/control.c\n@@ -14,6 +14,8 @@\n #include \"instrument/qemu-instr/control.h\"\n #include \"instrument/qemu-instr/visibility.h\"\n #include \"qom/cpu.h\"\n+#include \"exec/helper-proto.h\"\n+#include \"exec/helper-gen.h\"\n \n \n __thread InstrInfo instr_cur_info;\n@@ -86,3 +88,36 @@ QI_VPUBLIC void qi_event_set_guest_mem_before_trans(\n     ERROR_IF(!instr_get_state(), \"called outside instrumentation\");\n     instr_set_event(guest_mem_before_trans, fn);\n }\n+\n+\n+QI_VPUBLIC void qi_event_gen_guest_mem_before_exec(\n+    QITCGv_cpu vcpu, QITCGv vaddr, QIMemInfo info)\n+{\n+    ERROR_IF(instr_get_state() != INSTR_STATE_ENABLE_TCG,\n+             \"called outside instrumentation\");\n+    InstrInfo *iinfo = &instr_cur_info;\n+    TCGv_env vcpu_ = instr_tcg_get(iinfo, vcpu);\n+    TCGv vaddr_ = instr_tcg_get(iinfo, vaddr);\n+    TCGv_i32 info_ = tcg_const_i32(info.raw);\n+    gen_helper_instr_guest_mem_before_exec(vcpu_, vaddr_, info_);\n+    tcg_temp_free_i32(info_);\n+}\n+\n+void helper_instr_guest_mem_before_exec(\n+    CPUArchState * vcpu, target_ulong vaddr, uint32_t info)\n+{\n+    TraceMemInfo info_;\n+    info_.raw = info;\n+    instr_guest_mem_before_exec(ENV_GET_CPU(vcpu), vaddr, info_);\n+}\n+\n+\n+void (*instr_event__guest_mem_before_exec)(\n+    QICPU vcpu, uint64_t vaddr, QIMemInfo info);\n+\n+QI_VPUBLIC void qi_event_set_guest_mem_before_exec(\n+    void (*fn)(QICPU vcpu, uint64_t vaddr, QIMemInfo info))\n+{\n+    ERROR_IF(!instr_get_state(), \"called outside instrumentation\");\n+    instr_set_event(guest_mem_before_exec, fn);\n+}\ndiff --git a/instrument/control.h b/instrument/control.h\nindex d9e3dd3da6..19c9c9fb98 100644\n--- a/instrument/control.h\n+++ b/instrument/control.h\n@@ -54,6 +54,7 @@ static inline QICPU instr_cpu_set(CPUState *vcpu);\n typedef enum {\n     INSTR_STATE_DISABLE,\n     INSTR_STATE_ENABLE,\n+    INSTR_STATE_ENABLE_TCG,\n } InstrState;\n \n #define INSTR_MAX_TCG_REGS 16\n@@ -102,6 +103,20 @@ static inline InstrState instr_get_state(void);\n  */\n static inline void instr_tcg_count(InstrInfo *info, unsigned int count);\n \n+/**\n+ * instr_tcg_get:\n+ * @info: Pointer to #InstrInfo.\n+ * @arg: QITCG register.\n+ *\n+ * Get a suitable TCGv* from a QITCGv* value.\n+ */\n+#define instr_tcg_get(info, arg)                                \\\n+    ({                                                          \\\n+        unsigned int idx = (uintptr_t)arg;                      \\\n+        ERROR_IF(info->max <= idx, \"invalid QITCGv register\");  \\\n+        info->tcg_regs[idx];                                  \\\n+    })\n+\n \n #include \"instrument/control.inc.h\"\n \ndiff --git a/instrument/events.h b/instrument/events.h\nindex 1cc4dbb052..6507b26867 100644\n--- a/instrument/events.h\n+++ b/instrument/events.h\n@@ -63,6 +63,11 @@ extern void (*instr_event__guest_mem_before_trans)(\n static inline void instr_guest_mem_before_trans(\n     CPUState *vcpu_trans, TCGv_env vcpu_exec, TCGv vaddr, TraceMemInfo info);\n \n+extern void (*instr_event__guest_mem_before_exec)(\n+    QICPU vcpu, uint64_t vaddr, QIMemInfo info);\n+static inline void instr_guest_mem_before_exec(\n+    CPUState *vcpu, uint64_t vaddr, TraceMemInfo info);\n+\n \n #include \"instrument/events.inc.h\"\n \ndiff --git a/instrument/events.inc.h b/instrument/events.inc.h\nindex 2cb17049f7..d7a3065ac1 100644\n--- a/instrument/events.inc.h\n+++ b/instrument/events.inc.h\n@@ -50,7 +50,7 @@ static inline void instr_guest_mem_before_trans(\n     void (*cb)(QICPU vcpu_trans, QITCGv_cpu vcpu_exec, QITCGv vaddr, QIMemInfo info)\n         = instr_get_event(guest_mem_before_trans);\n     if (cb) {\n-        InstrInfo *iinfo = instr_set_state(INSTR_STATE_ENABLE);\n+        InstrInfo *iinfo = instr_set_state(INSTR_STATE_ENABLE_TCG);\n         QICPU vcpu_trans_ = instr_cpu_set(vcpu_trans);\n         QITCGv_cpu vcpu_exec_ = instr_tcg_set(iinfo, 0, vcpu_exec);\n         QITCGv vaddr_ = instr_tcg_set(iinfo, 1, vaddr);\n@@ -61,3 +61,19 @@ static inline void instr_guest_mem_before_trans(\n         instr_set_state(INSTR_STATE_DISABLE);\n     }\n }\n+\n+static inline void instr_guest_mem_before_exec(\n+    CPUState *vcpu, uint64_t vaddr, TraceMemInfo info)\n+{\n+    void (*cb)(QICPU vcpu, uint64_t vaddr, QIMemInfo info)\n+        = instr_get_event(guest_mem_before_exec);\n+    if (cb) {\n+        InstrInfo *iinfo = instr_set_state(INSTR_STATE_ENABLE);\n+        QICPU vcpu_ = instr_cpu_set(vcpu);\n+        QIMemInfo info_;\n+        info_.raw = info.raw;\n+        instr_tcg_count(iinfo, 2);\n+        (*cb)(vcpu_, vaddr, info_);\n+        instr_set_state(INSTR_STATE_DISABLE);\n+    }\n+}\ndiff --git a/instrument/helpers.h b/instrument/helpers.h\nnew file mode 100644\nindex 0000000000..957cdc0993\n--- /dev/null\n+++ b/instrument/helpers.h\n@@ -0,0 +1 @@\n+DEF_HELPER_FLAGS_3(instr_guest_mem_before_exec, TCG_CALL_NO_RWG, void, env, tl, i32)\ndiff --git a/instrument/load.c b/instrument/load.c\nindex d5612af452..1df660d5d1 100644\n--- a/instrument/load.c\n+++ b/instrument/load.c\n@@ -152,6 +152,7 @@ InstrUnloadError instr_unload(int64_t handle_id)\n     instr_set_event(guest_cpu_exit, NULL);\n     instr_set_event(guest_cpu_reset, NULL);\n     instr_set_event(guest_mem_before_trans, NULL);\n+    instr_set_event(guest_mem_before_exec, NULL);\n \n     /* this should never fail */\n     if (dlclose(handle->dlhandle) < 0) {\ndiff --git a/instrument/qemu-instr/control.h b/instrument/qemu-instr/control.h\nindex af4fda138e..4fa99a968d 100644\n--- a/instrument/qemu-instr/control.h\n+++ b/instrument/qemu-instr/control.h\n@@ -113,6 +113,27 @@ void qi_event_set_guest_cpu_reset(void (*fn)(QICPU vcpu));\n void qi_event_set_guest_mem_before_trans(\n     void (*fn)(QICPU vcpu_trans, QITCGv_cpu vcpu_exec, QITCGv vaddr, QIMemInfo info));\n \n+/*\n+ * Generate code to trigger a 'guest_mem_before_exec' from\n+ * 'guest_mem_before_trans'.\n+ *\n+ * Mode: user, softmmu\n+ * Targets: TCG(all)\n+ * Time: trans\n+ */\n+void qi_event_gen_guest_mem_before_exec(\n+    QITCGv_cpu vcpu, QITCGv vaddr, QIMemInfo info);\n+\n+/*\n+ * Execution-time equivalent of 'guest_mem_before_trans'.\n+ *\n+ * Mode: user, softmmu\n+ * Targets: TCG(all)\n+ * Time: exec\n+ */\n+void qi_event_set_guest_mem_before_exec(\n+    void (*fn)(QICPU vcpu, uint64_t vaddr, QIMemInfo info));\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/stubs/instrument.c b/stubs/instrument.c\nindex 5e0d5150b5..c6c279c85e 100644\n--- a/stubs/instrument.c\n+++ b/stubs/instrument.c\n@@ -16,3 +16,5 @@ void (*instr_event__guest_cpu_exit)(QICPU *vcpu);\n void (*instr_event__guest_cpu_reset)(QICPU *vcpu);\n void (*instr_event__guest_mem_before_trans)(\n     QICPU vcpu_trans, QITCGv_cpu vcpu_exec, QITCGv vaddr, QIMemInfo info);\n+void (*instr_event__guest_mem_before_exec)(\n+    QICPU vcpu_trans, QITCGv_cpu vcpu_exec, QITCGv vaddr, QIMemInfo info);\n",
    "prefixes": [
        "v4",
        "17/20"
    ]
}