get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1850828,
    "url": "http://patchwork.ozlabs.org/api/patches/1850828/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20231018130716.286638-8-thuth@redhat.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": "<20231018130716.286638-8-thuth@redhat.com>",
    "list_archive_url": null,
    "date": "2023-10-18T13:06:58",
    "name": "[PULL,07/25] s390x/cpu topology: interception of PTF instruction",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "2d3d03ed5457d8232ac6825284e0287050bbcaf7",
    "submitter": {
        "id": 66152,
        "url": "http://patchwork.ozlabs.org/api/people/66152/?format=api",
        "name": "Thomas Huth",
        "email": "thuth@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20231018130716.286638-8-thuth@redhat.com/mbox/",
    "series": [
        {
            "id": 378180,
            "url": "http://patchwork.ozlabs.org/api/series/378180/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=378180",
            "date": "2023-10-18T13:06:52",
            "name": "[PULL,01/25] qapi: machine.json: change docs regarding CPU topology",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/378180/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1850828/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1850828/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@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=TDHkbycT;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4S9WZT6bTRz20cx\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 19 Oct 2023 00:16:17 +1100 (AEDT)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1qt6Gv-00044i-Fh; Wed, 18 Oct 2023 09:07:37 -0400",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <thuth@redhat.com>) id 1qt6Gu-00042p-Gt\n for qemu-devel@nongnu.org; Wed, 18 Oct 2023 09:07:36 -0400",
            "from us-smtp-delivery-124.mimecast.com ([170.10.129.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <thuth@redhat.com>) id 1qt6Gs-0007w8-S5\n for qemu-devel@nongnu.org; Wed, 18 Oct 2023 09:07:36 -0400",
            "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-395-5dstlInuNIy0YOBmYtKG0Q-1; Wed, 18 Oct 2023 09:07:31 -0400",
            "from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com\n [10.11.54.4])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A62EE10201F3;\n Wed, 18 Oct 2023 13:07:30 +0000 (UTC)",
            "from thuth-p1g4.redhat.com (unknown [10.39.192.109])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 5B64F20268CB;\n Wed, 18 Oct 2023 13:07:29 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1697634454;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=2bNam0apihlcg35S1AG5Yb/HJq4JOsTV3dOKCoiYLFI=;\n b=TDHkbycTXXsG7f8qRNDrww2N92DqlRClaly0n2KsVhzniJDobokwvVdFYKPSwZwdBwVPi6\n GTS8RnoF+m3+YuVKEV9UQT5KPB+v4MLJVLrTdgLTd+djWdqUv8lN9c5LvXHGDPOz6gZ+t7\n cxyK7h5Ttzzn+UhFAMVKzVWkZrQCFmw=",
        "X-MC-Unique": "5dstlInuNIy0YOBmYtKG0Q-1",
        "From": "Thomas Huth <thuth@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "Stefan Hajnoczi <stefanha@redhat.com>, qemu-s390x@nongnu.org,\n Nina Schoetterl-Glausch <nsg@linux.ibm.com>",
        "Subject": "[PULL 07/25] s390x/cpu topology: interception of PTF instruction",
        "Date": "Wed, 18 Oct 2023 15:06:58 +0200",
        "Message-ID": "<20231018130716.286638-8-thuth@redhat.com>",
        "In-Reply-To": "<20231018130716.286638-1-thuth@redhat.com>",
        "References": "<20231018130716.286638-1-thuth@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.4",
        "Received-SPF": "pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com",
        "X-Spam_score_int": "-20",
        "X-Spam_score": "-2.1",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no",
        "X-Spam_action": "no action",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://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 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"
    },
    "content": "From: Pierre Morel <pmorel@linux.ibm.com>\n\nWhen the host supports the CPU topology facility, the PTF\ninstruction with function code 2 is interpreted by the SIE,\nprovided that the userland hypervisor activates the interpretation\nby using the KVM_CAP_S390_CPU_TOPOLOGY KVM extension.\n\nThe PTF instructions with function code 0 and 1 are intercepted\nand must be emulated by the userland hypervisor.\n\nDuring RESET all CPU of the configuration are placed in\nhorizontal polarity.\n\nSigned-off-by: Pierre Morel <pmorel@linux.ibm.com>\nReviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>\nReviewed-by: Thomas Huth <thuth@redhat.com>\nCo-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>\nSigned-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>\nMessage-ID: <20231016183925.2384704-8-nsg@linux.ibm.com>\nSigned-off-by: Thomas Huth <thuth@redhat.com>\n---\n include/hw/s390x/s390-virtio-ccw.h |  6 ++++\n hw/s390x/cpu-topology.c            | 55 ++++++++++++++++++++++++++++++\n target/s390x/kvm/kvm.c             | 11 ++++++\n 3 files changed, 72 insertions(+)",
    "diff": "diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-virtio-ccw.h\nindex 9bba21a916..c1d46e78af 100644\n--- a/include/hw/s390x/s390-virtio-ccw.h\n+++ b/include/hw/s390x/s390-virtio-ccw.h\n@@ -30,6 +30,12 @@ struct S390CcwMachineState {\n     uint8_t loadparm[8];\n };\n \n+#define S390_PTF_REASON_NONE (0x00 << 8)\n+#define S390_PTF_REASON_DONE (0x01 << 8)\n+#define S390_PTF_REASON_BUSY (0x02 << 8)\n+#define S390_TOPO_FC_MASK 0xffUL\n+void s390_handle_ptf(S390CPU *cpu, uint8_t r1, uintptr_t ra);\n+\n struct S390CcwMachineClass {\n     /*< private >*/\n     MachineClass parent_class;\ndiff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c\nindex 7ec9319272..a00a4ce4df 100644\n--- a/hw/s390x/cpu-topology.c\n+++ b/hw/s390x/cpu-topology.c\n@@ -90,6 +90,60 @@ static void s390_topology_init(MachineState *ms)\n                                             smp->books * smp->drawers);\n }\n \n+/*\n+ * s390_handle_ptf:\n+ *\n+ * @register 1: contains the function code\n+ *\n+ * Function codes 0 (horizontal) and 1 (vertical) define the CPU\n+ * polarization requested by the guest.\n+ *\n+ * Function code 2 is handling topology changes and is interpreted\n+ * by the SIE.\n+ */\n+void s390_handle_ptf(S390CPU *cpu, uint8_t r1, uintptr_t ra)\n+{\n+    CpuS390Polarization polarization;\n+    CPUS390XState *env = &cpu->env;\n+    uint64_t reg = env->regs[r1];\n+    int fc = reg & S390_TOPO_FC_MASK;\n+\n+    if (!s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) {\n+        s390_program_interrupt(env, PGM_OPERATION, ra);\n+        return;\n+    }\n+\n+    if (env->psw.mask & PSW_MASK_PSTATE) {\n+        s390_program_interrupt(env, PGM_PRIVILEGED, ra);\n+        return;\n+    }\n+\n+    if (reg & ~S390_TOPO_FC_MASK) {\n+        s390_program_interrupt(env, PGM_SPECIFICATION, ra);\n+        return;\n+    }\n+\n+    polarization = S390_CPU_POLARIZATION_VERTICAL;\n+    switch (fc) {\n+    case 0:\n+        polarization = S390_CPU_POLARIZATION_HORIZONTAL;\n+        /* fallthrough */\n+    case 1:\n+        if (s390_topology.polarization == polarization) {\n+            env->regs[r1] |= S390_PTF_REASON_DONE;\n+            setcc(cpu, 2);\n+        } else {\n+            s390_topology.polarization = polarization;\n+            s390_cpu_topology_set_changed(true);\n+            setcc(cpu, 0);\n+        }\n+        break;\n+    default:\n+        /* Note that fc == 2 is interpreted by the SIE */\n+        s390_program_interrupt(env, PGM_SPECIFICATION, ra);\n+    }\n+}\n+\n /**\n  * s390_topology_reset:\n  *\n@@ -99,6 +153,7 @@ static void s390_topology_init(MachineState *ms)\n void s390_topology_reset(void)\n {\n     s390_cpu_topology_set_changed(false);\n+    s390_topology.polarization = S390_CPU_POLARIZATION_HORIZONTAL;\n }\n \n /**\ndiff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c\nindex d6bda3a2a8..4d84dcc018 100644\n--- a/target/s390x/kvm/kvm.c\n+++ b/target/s390x/kvm/kvm.c\n@@ -86,6 +86,7 @@\n \n #define PRIV_B9_EQBS                    0x9c\n #define PRIV_B9_CLP                     0xa0\n+#define PRIV_B9_PTF                     0xa2\n #define PRIV_B9_PCISTG                  0xd0\n #define PRIV_B9_PCILG                   0xd2\n #define PRIV_B9_RPCIT                   0xd3\n@@ -1457,6 +1458,13 @@ static int kvm_mpcifc_service_call(S390CPU *cpu, struct kvm_run *run)\n     }\n }\n \n+static void kvm_handle_ptf(S390CPU *cpu, struct kvm_run *run)\n+{\n+    uint8_t r1 = (run->s390_sieic.ipb >> 20) & 0x0f;\n+\n+    s390_handle_ptf(cpu, r1, RA_IGNORED);\n+}\n+\n static int handle_b9(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)\n {\n     int r = 0;\n@@ -1474,6 +1482,9 @@ static int handle_b9(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)\n     case PRIV_B9_RPCIT:\n         r = kvm_rpcit_service_call(cpu, run);\n         break;\n+    case PRIV_B9_PTF:\n+        kvm_handle_ptf(cpu, run);\n+        break;\n     case PRIV_B9_EQBS:\n         /* just inject exception */\n         r = -1;\n",
    "prefixes": [
        "PULL",
        "07/25"
    ]
}