Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2231979/?format=api
{ "id": 2231979, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2231979/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260501200026.22784-5-oelghoul@linux.ibm.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.2/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": "<20260501200026.22784-5-oelghoul@linux.ibm.com>", "list_archive_url": null, "date": "2026-05-01T20:00:25", "name": "[RFC,v1,4/5] hw/s390x: Internal support for FMB passthrough", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b4db0e95d1e710da9cd062b41f5396f6ee42d8cf", "submitter": { "id": 93299, "url": "http://patchwork.ozlabs.org/api/1.2/people/93299/?format=api", "name": "Omar Elghoul", "email": "oelghoul@linux.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260501200026.22784-5-oelghoul@linux.ibm.com/mbox/", "series": [ { "id": 502493, "url": "http://patchwork.ozlabs.org/api/1.2/series/502493/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502493", "date": "2026-05-01T20:00:21", "name": "s390x/pci: Improved zPCI Function Measurement Support", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/502493/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2231979/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2231979/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 (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=I/llce4R;\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=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists1p.gnu.org (lists1p.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 4g6hpX3jkwz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 02 May 2026 06:04:52 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wIu68-0001W2-0Y; Fri, 01 May 2026 16:04:28 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <oelghoul@linux.ibm.com>)\n id 1wIu5w-0001K4-E1; Fri, 01 May 2026 16:04:21 -0400", "from mx0a-001b2d01.pphosted.com ([148.163.156.1])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <oelghoul@linux.ibm.com>)\n id 1wIu5s-0001VB-Qq; Fri, 01 May 2026 16:04:16 -0400", "from pps.filterd (m0353729.ppops.net [127.0.0.1])\n by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 641F1BxZ3060766; Fri, 1 May 2026 20:04:07 GMT", "from ppma23.wdc07v.mail.ibm.com\n (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93])\n by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drn9rp5uj-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Fri, 01 May 2026 20:04:07 +0000 (GMT)", "from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1])\n by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id\n 641Jrs3G000757;\n Fri, 1 May 2026 20:04:06 GMT", "from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6])\n by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds9ehrucg-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Fri, 01 May 2026 20:04:06 +0000 (GMT)", "from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com\n [10.241.53.105])\n by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 641K438Z31916704\n (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Fri, 1 May 2026 20:04:03 GMT", "from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 4B23D58043;\n Fri, 1 May 2026 20:04:03 +0000 (GMT)", "from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 2DA7C58055;\n Fri, 1 May 2026 20:04:02 +0000 (GMT)", "from Mac.ibm.com (unknown [9.61.247.25])\n by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP;\n Fri, 1 May 2026 20:04:02 +0000 (GMT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n :content-transfer-encoding:date:from:in-reply-to:message-id\n :mime-version:references:subject:to; s=pp1; bh=KlGpvEC4RDK74fAGE\n yEIgsDl+lYkwifLPb2H0Dd9tLY=; b=I/llce4RLFMSnf0nfRinO6R9njgkgUNL2\n TXBv2EgTdHRBs8Qk08UyfeI7t5qUmS1Zxp4POLCZx7O4EGQ2poUUVEeymxhkm4fB\n 9wbSQ2J5QJkkWWhYtAGRrYCB3uOjl786CZ/LOLiCbyTw4sfvVqAnezyAz1jLmIuM\n IgyGViyjzjMLcPtEOCOlDaRy+jCCjZ14Tfg9LecHUYKcXMTZEsf6/tplj0NredSy\n YoYeueW/+DC0hOR44OF4Ro76sh3FNTGc7ulYEeqmQ64c5b5E1f1dSV480rJlOoJJ\n 28tD3Rri+RJ4W7oQnZ46f8mKX40dUoM2JtDvHmO8stL44xX3xpOOQ==", "From": "Omar Elghoul <oelghoul@linux.ibm.com>", "To": "qemu-devel@nongnu.org, qemu-s390x@nongnu.org", "Cc": "oelghoul@linux.ibm.com, mjrosato@linux.ibm.com, alifm@linux.ibm.com,\n farman@linux.ibm.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com,\n richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org,\n cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, clg@redhat.com", "Subject": "[RFC PATCH v1 4/5] hw/s390x: Internal support for FMB passthrough", "Date": "Fri, 1 May 2026 16:00:25 -0400", "Message-ID": "<20260501200026.22784-5-oelghoul@linux.ibm.com>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20260501200026.22784-1-oelghoul@linux.ibm.com>", "References": "<20260501200026.22784-1-oelghoul@linux.ibm.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-TM-AS-GCONF": "00", "X-Proofpoint-GUID": "QCgjdcwJE6JZFuXGzB2h9KzUVfNCWFze", "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwNTAxMDE5NSBTYWx0ZWRfX9RN79WnRGezD\n 3DERqgp+H6BOq3s/oTU+IFuWxyZ0c1kZ5fGmtEpW5DB/qIU7ajU0lRS6tq4/EkjZ3MBEhCxiwPv\n 2VwiCSlPScLWm64IJ18mgghxpgA8t+W5MMk0Yp6LL7JOch+tAtBQu/yd/ApYT7MI4G+MeXOn9ki\n M6Z3y5yTQ5bHuvqVBmSiTq+m7VJGYl9XVI/S723kmZ7gzMT6os3y5N2ghxzoke8CTJuEg+D/riN\n 372AYHOm4sO2A+JJ+jpBnA4aHkf3LWLj1l/GKVQdtg289XfsbrZim70jmqqx8O5QJC2/B0rNzrx\n Djku8wWTvAgwIlEZ/ANwIgoSsdmtrw0GZeTTNsHgzKFXyBHolNoJB2Bh3Ja+nCvDKmz2J5s5Ba+\n zqQyo4qVe+W0bKoYPWuXEcxi6T/GvuvMSLQsnZKYtvvD6Q9gPSoHZUx+iG8gT4qwGjeCZG6xGtv\n 1Ee1G3b6ewrKo4ew+Sg==", "X-Authority-Analysis": "v=2.4 cv=Kc7idwYD c=1 sm=1 tr=0 ts=69f50737 cx=c_pps\n a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17\n a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22\n a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=47rX_IKMaOKvU8u4J60A:9", "X-Proofpoint-ORIG-GUID": "QCgjdcwJE6JZFuXGzB2h9KzUVfNCWFze", "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-05-01_05,2026-04-30_02,2025-10-01_01", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 spamscore=0\n malwarescore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0\n suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000\n definitions=main-2605010195", "Received-SPF": "pass client-ip=148.163.156.1;\n envelope-from=oelghoul@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com", "X-Spam_score_int": "-26", "X-Spam_score": "-2.7", "X-Spam_bar": "--", "X-Spam_report": "(-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\n RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham 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 development <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": "Detect the FMB passthrough at runtime by probing for the VFIO FMB device\nfeature and setting a flag indicating its presence. If present, during an\nFMB update cycle, read the device feature and add the VFIO-provided\ncounters to QEMU's intercepted statistics, to account for operations that\nmay be run without interpretation.\n\nIf the device feature is not found, gracefully and silently fall back to\nQEMU's pre-existing intercepted FMB implementation.\n\nIntroduce helper functions to allow enabling or disabling the FMB of the\nhost device. These functions will allow QEMU to cascade FMB state and\nguarantee that the counters restart from zero when the guest expects them\nto after a new FMB (re-)enablement.\n\nFinally, remove the reduced aperture size for PCI ISM devices. This is\nnecessary due to the kernel working around a firmware bug and incrementing\nthe DMA limit by one full page when the PFT is reported correctly.\n\nSigned-off-by: Omar Elghoul <oelghoul@linux.ibm.com>\n---\n hw/s390x/s390-pci-bus.c | 2 +\n hw/s390x/s390-pci-inst.c | 7 ++\n hw/s390x/s390-pci-vfio-stubs.c | 16 ++++\n hw/s390x/s390-pci-vfio.c | 128 ++++++++++++++++++++++++++-----\n include/hw/s390x/s390-pci-bus.h | 27 ++++++-\n include/hw/s390x/s390-pci-vfio.h | 4 +\n 6 files changed, 165 insertions(+), 19 deletions(-)", "diff": "diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c\nindex 7eee1efeb7..88540a9eb6 100644\n--- a/hw/s390x/s390-pci-bus.c\n+++ b/hw/s390x/s390-pci-bus.c\n@@ -1185,6 +1185,8 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,\n pbdev->shutdown_notifier.notify = s390_pci_shutdown_notifier;\n qemu_register_shutdown_notifier(&pbdev->shutdown_notifier);\n }\n+ /* Detect VFIO FMB passthrough */\n+ s390_pci_get_fmb_info(pbdev);\n } else {\n pbdev->fh |= FH_SHM_EMUL;\n /* Always intercept emulated devices */\ndiff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c\nindex 10066ca618..b22144751e 100644\n--- a/hw/s390x/s390-pci-inst.c\n+++ b/hw/s390x/s390-pci-inst.c\n@@ -1313,9 +1313,16 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar,\n if (!fmb_addr) {\n /* Stop updating FMB. */\n fmb_timer_free(pbdev);\n+ if (pbdev->has_vfio_fmb) {\n+ s390_pci_disable_vfio_fmb(pbdev);\n+ }\n break;\n }\n \n+ if (pbdev->has_vfio_fmb) {\n+ s390_pci_enable_vfio_fmb(pbdev);\n+ }\n+\n if (!pbdev->fmb_timer) {\n pbdev->fmb_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL,\n fmb_update, pbdev);\ndiff --git a/hw/s390x/s390-pci-vfio-stubs.c b/hw/s390x/s390-pci-vfio-stubs.c\nindex d9882b7aad..774a6615c6 100644\n--- a/hw/s390x/s390-pci-vfio-stubs.c\n+++ b/hw/s390x/s390-pci-vfio-stubs.c\n@@ -30,3 +30,19 @@ bool s390_pci_get_host_fh(S390PCIBusDevice *pbdev, uint32_t *fh)\n void s390_pci_get_clp_info(S390PCIBusDevice *pbdev)\n {\n }\n+\n+void s390_pci_get_fmb_info(S390PCIBusDevice *pbdev)\n+{\n+}\n+\n+void s390_pci_update_vfio_fmb(S390PCIBusDevice *pbdev)\n+{\n+}\n+\n+void s390_pci_disable_vfio_fmb(S390PCIBusDevice *pbdev)\n+{\n+}\n+\n+void s390_pci_enable_vfio_fmb(S390PCIBusDevice *pbdev)\n+{\n+}\ndiff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c\nindex 7c754b656d..d749c8c80a 100644\n--- a/hw/s390x/s390-pci-vfio.c\n+++ b/hw/s390x/s390-pci-vfio.c\n@@ -10,6 +10,7 @@\n */\n \n #include \"qemu/osdep.h\"\n+#include \"qemu/error-report.h\"\n \n #include <sys/ioctl.h>\n #include <linux/vfio.h>\n@@ -110,7 +111,6 @@ static void s390_pci_read_base(S390PCIBusDevice *pbdev,\n struct vfio_info_cap_header *hdr;\n struct vfio_device_info_cap_zpci_base *cap;\n VFIOPCIDevice *vpci = VFIO_PCI_DEVICE(pbdev->pdev);\n- uint64_t vfio_size;\n \n hdr = vfio_get_device_info_cap(info, VFIO_DEVICE_INFO_CAP_ZPCI_BASE);\n \n@@ -140,22 +140,6 @@ static void s390_pci_read_base(S390PCIBusDevice *pbdev,\n if (pbdev->pft == ZPCI_PFT_ISM) {\n pbdev->rtr_avail = false;\n }\n-\n- /*\n- * If appropriate, reduce the size of the supported DMA aperture reported\n- * to the guest based upon the vfio DMA limit. This is applicable for\n- * devices that are guaranteed to not use relaxed translation. If the\n- * device is capable of relaxed translation then we must advertise the\n- * full aperture. In this case, if translation is used then we will\n- * rely on the vfio DMA limit counting and use RPCIT CC1 / status 16\n- * to request that the guest free DMA mappings as necessary.\n- */\n- if (!pbdev->rtr_avail) {\n- vfio_size = pbdev->iommu->max_dma_limit << qemu_target_page_bits();\n- if (vfio_size > 0 && vfio_size < cap->end_dma - cap->start_dma + 1) {\n- pbdev->zpci_fn.edma = cap->start_dma + vfio_size - 1;\n- }\n- }\n }\n \n static bool get_host_fh(S390PCIBusDevice *pbdev, struct vfio_device_info *info,\n@@ -248,7 +232,7 @@ static void s390_pci_read_group(S390PCIBusDevice *pbdev,\n }\n resgrp->dasm = cap->dasm;\n resgrp->msia = cap->msi_addr;\n- resgrp->mui = cap->mui;\n+ resgrp->mui = cap->mui > DEFAULT_MUI ? cap->mui : DEFAULT_MUI;\n resgrp->i = cap->noi;\n if (pbdev->interp && hdr->version >= 2) {\n resgrp->maxstbl = cap->imaxstbl;\n@@ -370,3 +354,111 @@ void s390_pci_get_clp_info(S390PCIBusDevice *pbdev)\n s390_pci_read_util(pbdev, info);\n s390_pci_read_pfip(pbdev, info);\n }\n+\n+void s390_pci_get_fmb_info(S390PCIBusDevice *pbdev)\n+{\n+ VFIOPCIDevice *vpdev = VFIO_PCI_DEVICE(pbdev->pdev);\n+ int fd = vpdev->vbasedev.fd;\n+ int ret;\n+ struct vfio_device_feature probe = {\n+ .argsz = sizeof(probe),\n+ .flags = VFIO_DEVICE_FEATURE_PROBE | VFIO_DEVICE_FEATURE_ZPCI_FMB\n+ };\n+\n+ ret = ioctl(fd, VFIO_DEVICE_FEATURE, &probe);\n+ pbdev->has_vfio_fmb = !ret;\n+}\n+\n+static void s390_pci_set_vfio_fmb(S390PCIBusDevice *pbdev, int enabled)\n+{\n+ VFIOPCIDevice *vpdev = VFIO_PCI_DEVICE(pbdev->pdev);\n+ size_t size = sizeof(struct vfio_device_feature_zpci_fmb)\n+ + sizeof(struct vfio_device_feature);\n+ g_autofree struct vfio_device_feature *set = g_malloc(size);\n+ struct vfio_device_feature_zpci_fmb *set_fmb;\n+\n+ set->argsz = size;\n+ set->flags = VFIO_DEVICE_FEATURE_SET | VFIO_DEVICE_FEATURE_ZPCI_FMB;\n+ set_fmb = (struct vfio_device_feature_zpci_fmb *) set->data;\n+ if (enabled) {\n+ set_fmb->flags |= VFIO_DEVICE_FEATURE_ZPCI_FMB_FLAGS_ENABLED;\n+ } else {\n+ set_fmb->flags &= ~VFIO_DEVICE_FEATURE_ZPCI_FMB_FLAGS_ENABLED;\n+ }\n+ ioctl(vpdev->vbasedev.fd, VFIO_DEVICE_FEATURE, set);\n+}\n+\n+void s390_pci_enable_vfio_fmb(S390PCIBusDevice *pbdev)\n+{\n+ s390_pci_set_vfio_fmb(pbdev, 1);\n+}\n+\n+void s390_pci_disable_vfio_fmb(S390PCIBusDevice *pbdev)\n+{\n+ s390_pci_set_vfio_fmb(pbdev, 0);\n+}\n+\n+void s390_pci_update_vfio_fmb(S390PCIBusDevice *pbdev)\n+{\n+ VFIOPCIDevice *vpdev = VFIO_PCI_DEVICE(pbdev->pdev);\n+ size_t size = sizeof(struct vfio_device_feature_zpci_fmb)\n+ + sizeof(struct vfio_device_feature);\n+ g_autofree struct vfio_device_feature *get = g_malloc(size);\n+ struct vfio_device_feature_zpci_fmb *get_fmb;\n+ ZpciFmb fmb;\n+ int ret;\n+ MemTxResult memtx_ret;\n+\n+ get->argsz = size;\n+ get->flags = VFIO_DEVICE_FEATURE_GET | VFIO_DEVICE_FEATURE_ZPCI_FMB;\n+ ret = ioctl(vpdev->vbasedev.fd, VFIO_DEVICE_FEATURE, get);\n+ if (ret < 0) {\n+ return;\n+ }\n+\n+ get_fmb = (struct vfio_device_feature_zpci_fmb *) get->data;\n+ if (!get_fmb->flags & VFIO_DEVICE_FEATURE_ZPCI_FMB_FLAGS_ENABLED) {\n+ error_report_once(\"s390-pci-vfio: FMB is disabled on the host device.\");\n+ return;\n+ }\n+ fmb.format = (get_fmb->format << 24) | get_fmb->fmt_ind;\n+ fmb.sample = get_fmb->samples;\n+ fmb.last_update = get_fmb->last_update;\n+ fmb.counter[ZPCI_FMB_CNT_LD] = get_fmb->ld_ops;\n+ fmb.counter[ZPCI_FMB_CNT_ST] = get_fmb->st_ops;\n+ fmb.counter[ZPCI_FMB_CNT_STB] = get_fmb->stb_ops;\n+ fmb.counter[ZPCI_FMB_CNT_RPCIT] = get_fmb->rpcit_ops;\n+\n+ switch (get_fmb->format) {\n+ case 0:\n+ fmb.fmt0.dma_rbytes = get_fmb->fmt0.dma_rbytes;\n+ fmb.fmt0.dma_wbytes = get_fmb->fmt0.dma_wbytes;\n+ break;\n+ case 1:\n+ fmb.fmt1.rx_bytes = get_fmb->fmt1.rx_bytes;\n+ fmb.fmt1.rx_packets = get_fmb->fmt1.rx_packets;\n+ fmb.fmt1.tx_bytes = get_fmb->fmt1.tx_bytes;\n+ fmb.fmt1.tx_packets = get_fmb->fmt1.tx_packets;\n+ break;\n+ case 2:\n+ fmb.fmt2.consumed_work_units = get_fmb->fmt2.consumed_work_units;\n+ fmb.fmt2.max_work_units = get_fmb->fmt2.max_work_units;\n+ break;\n+ case 3:\n+ fmb.fmt3.tx_bytes = get_fmb->fmt3.tx_bytes;\n+ break;\n+ }\n+\n+ for (int i = 0; i < ZPCI_FMB_CNT_MAX; i++) {\n+ fmb.counter[i] += pbdev->fmb.counter[i];\n+ }\n+\n+ for (int i = 0; i < pbdev->zpci_fn.fmbl >> 2; i++) {\n+ address_space_stl_be(&address_space_memory, pbdev->fmb_addr + (i << 2),\n+ ((uint32_t *) &fmb)[i], MEMTXATTRS_UNSPECIFIED, &memtx_ret);\n+\n+ if (memtx_ret != MEMTX_OK) {\n+ break;\n+ }\n+ }\n+}\ndiff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h\nindex feaf6d4863..050e7fda99 100644\n--- a/include/hw/s390x/s390-pci-bus.h\n+++ b/include/hw/s390x/s390-pci-bus.h\n@@ -302,6 +302,22 @@ typedef struct ZpciFmbFmt0 {\n uint64_t dma_wbytes;\n } ZpciFmbFmt0;\n \n+typedef struct ZpciFmbFmt1 {\n+ uint64_t rx_bytes;\n+ uint64_t rx_packets;\n+ uint64_t tx_bytes;\n+ uint64_t tx_packets;\n+} ZpciFmbFmt1;\n+\n+typedef struct ZpciFmbFmt2 {\n+ uint64_t consumed_work_units;\n+ uint64_t max_work_units;\n+} ZpciFmbFmt2;\n+\n+typedef struct ZpciFmbFmt3 {\n+ uint64_t tx_bytes;\n+} ZpciFmbFmt3;\n+\n #define ZPCI_FMB_CNT_LD 0\n #define ZPCI_FMB_CNT_ST 1\n #define ZPCI_FMB_CNT_STB 2\n@@ -309,13 +325,21 @@ typedef struct ZpciFmbFmt0 {\n #define ZPCI_FMB_CNT_MAX 4\n \n #define ZPCI_FMB_DEFAULT_FORMAT 0\n+#define ZPCI_FMB_COMMON_SIZE 48\n+#define ZPCI_FMB_FORMAT(f) ((f >> 24) & 0xFF)\n+#define ZPCI_FMB_DMA_COUNTER_VALID (1 << 23)\n \n typedef struct ZpciFmb {\n uint32_t format;\n uint32_t sample;\n uint64_t last_update;\n uint64_t counter[ZPCI_FMB_CNT_MAX];\n- ZpciFmbFmt0 fmt0;\n+ union {\n+ ZpciFmbFmt0 fmt0;\n+ ZpciFmbFmt1 fmt1;\n+ ZpciFmbFmt2 fmt2;\n+ ZpciFmbFmt3 fmt3;\n+ };\n } ZpciFmb;\n QEMU_BUILD_BUG_MSG(offsetof(ZpciFmb, fmt0) != 48, \"padding in ZpciFmb\");\n \n@@ -364,6 +388,7 @@ struct S390PCIBusDevice {\n bool forwarding_assist;\n bool aif;\n bool rtr_avail;\n+ bool has_vfio_fmb;\n QTAILQ_ENTRY(S390PCIBusDevice) link;\n };\n \ndiff --git a/include/hw/s390x/s390-pci-vfio.h b/include/hw/s390x/s390-pci-vfio.h\nindex f7d6149daf..4a19747d7c 100644\n--- a/include/hw/s390x/s390-pci-vfio.h\n+++ b/include/hw/s390x/s390-pci-vfio.h\n@@ -20,5 +20,9 @@ S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s,\n void s390_pci_end_dma_count(S390pciState *s, S390PCIDMACount *cnt);\n bool s390_pci_get_host_fh(S390PCIBusDevice *pbdev, uint32_t *fh);\n void s390_pci_get_clp_info(S390PCIBusDevice *pbdev);\n+void s390_pci_get_fmb_info(S390PCIBusDevice *pbdev);\n+void s390_pci_update_vfio_fmb(S390PCIBusDevice *pbdev);\n+void s390_pci_disable_vfio_fmb(S390PCIBusDevice *pbdev);\n+void s390_pci_enable_vfio_fmb(S390PCIBusDevice *pbdev);\n \n #endif\n", "prefixes": [ "RFC", "v1", "4/5" ] }