From nobody Tue May 7 19:38:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1593079551; cv=none; d=zohomail.com; s=zohoarc; b=PucWwVejiziaTGe8QTmf2SlSkdzkdnNU/ZU0JrJEnnU3LI+8gu7ClQuNqAMsB4ugPnQoUvHC/cIeZJ5ZOvo0aLnUImpdq54uQYz/9ajlc+TNW3oEE37BfWHLFnRkvfR90Afv9a7KMdN3Fvq+x4IHf2Mycg9NZdfdOxdNwEtFgyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593079551; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JGPSXL6BFkc/+OHP/Nnv5hJctvkD6L5FEwU7YqEat9Q=; b=Yog9xKawt3t0wGTyRxONS/HcU2/snUI+6fkweRuyaYpvsCy7jlGSpEjGPQMNtqVqGQfQB/uyQN+j0C9EWhHd97tBQ9r0mKiu6PpukChDvWYVBWJLOpxVuga3iZv6aK7MYmXXobkec+VUKHxGd+crtj/XCfv+I5LG/LkWBRwGzJE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159307955095622.953458133693516; Thu, 25 Jun 2020 03:05:50 -0700 (PDT) Received: from localhost ([::1]:37744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joOlR-0000g3-O9 for importer@patchew.org; Thu, 25 Jun 2020 06:05:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joOkR-0007lL-KA for qemu-devel@nongnu.org; Thu, 25 Jun 2020 06:04:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49514 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joOkP-0001YK-Ff for qemu-devel@nongnu.org; Thu, 25 Jun 2020 06:04:47 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05PA1qBm115187 for ; Thu, 25 Jun 2020 06:04:42 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 31uwyvamn3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jun 2020 06:04:42 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05PA20h7116097 for ; Thu, 25 Jun 2020 06:04:42 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 31uwyvamma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 06:04:42 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05PA0qQJ009462; Thu, 25 Jun 2020 10:04:40 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04ams.nl.ibm.com with ESMTP id 31uus71nph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 10:04:40 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05PA3JQ460621196 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jun 2020 10:03:19 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 350634203F; Thu, 25 Jun 2020 10:04:38 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC60D42052; Thu, 25 Jun 2020 10:04:37 +0000 (GMT) Received: from marcibm.ibmuc.com (unknown [9.145.42.231]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 25 Jun 2020 10:04:37 +0000 (GMT) From: Marc Hartmayer To: Subject: [RFC 1/4] virtio: add vhost-user-fs-ccw device Date: Thu, 25 Jun 2020 12:04:27 +0200 Message-Id: <20200625100430.22407-2-mhartmay@linux.ibm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200625100430.22407-1-mhartmay@linux.ibm.com> References: <20200625100430.22407-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-25_04:2020-06-25, 2020-06-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 cotscore=-2147483648 suspectscore=1 mlxlogscore=999 lowpriorityscore=0 adultscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 mlxscore=0 phishscore=0 malwarescore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006250059 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=mhartmay@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 06:04:42 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Cornelia Huck , Halil Pasic , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Halil Pasic Wire up the CCW device for vhost-user-fs. Signed-off-by: Halil Pasic --- hw/s390x/Makefile.objs | 1 + hw/s390x/vhost-user-fs-ccw.c | 74 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 hw/s390x/vhost-user-fs-ccw.c diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs index a46a1c7894e0..c4086ec3171e 100644 --- a/hw/s390x/Makefile.objs +++ b/hw/s390x/Makefile.objs @@ -20,6 +20,7 @@ obj-$(CONFIG_VIRTIO_NET) +=3D virtio-ccw-net.o obj-$(CONFIG_VIRTIO_BLK) +=3D virtio-ccw-blk.o obj-$(call land,$(CONFIG_VIRTIO_9P),$(CONFIG_VIRTFS)) +=3D virtio-ccw-9p.o obj-$(CONFIG_VHOST_VSOCK) +=3D vhost-vsock-ccw.o +obj-$(CONFIG_VHOST_USER_FS) +=3D vhost-user-fs-ccw.o endif obj-y +=3D css-bridge.o obj-y +=3D ccw-device.o diff --git a/hw/s390x/vhost-user-fs-ccw.c b/hw/s390x/vhost-user-fs-ccw.c new file mode 100644 index 000000000000..0f11a77239a5 --- /dev/null +++ b/hw/s390x/vhost-user-fs-ccw.c @@ -0,0 +1,74 @@ +/* + * Ccw transport wiring for vhost-user-fs + * + * Copyright 2020 IBM Corp. + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "qapi/error.h" +#include "hw/virtio/vhost-user-fs.h" +#include "virtio-ccw.h" + +typedef struct VHostUserFSCcw { + VirtioCcwDevice parent_obj; + VHostUserFS vdev; +} VHostUserFSCcw; + +#define TYPE_VHOST_USER_FS_CCW "vhost-user-fs-ccw" +#define VHOST_USER_FS_CCW(obj) \ + OBJECT_CHECK(VHostUserFSCcw, (obj), TYPE_VHOST_USER_FS_CCW) + + +static Property vhost_user_fs_ccw_properties[] =3D { + DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, + VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), + DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, + VIRTIO_CCW_MAX_REV), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vhost_user_fs_ccw_realize(VirtioCcwDevice *ccw_dev, Error **er= rp) +{ + VHostUserFSCcw *dev =3D VHOST_USER_FS_CCW(ccw_dev); + DeviceState *vdev =3D DEVICE(&dev->vdev); + + qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); + object_property_set_bool(OBJECT(vdev), true, "realized", errp); +} + +static void vhost_user_fs_ccw_instance_init(Object *obj) +{ + VHostUserFSCcw *dev =3D VHOST_USER_FS_CCW(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_FS); +} + +static void vhost_user_fs_ccw_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtIOCCWDeviceClass *k =3D VIRTIO_CCW_DEVICE_CLASS(klass); + + k->realize =3D vhost_user_fs_ccw_realize; + device_class_set_props(dc,vhost_user_fs_ccw_properties); + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); +} + +static const TypeInfo vhost_user_fs_ccw =3D { + .name =3D TYPE_VHOST_USER_FS_CCW, + .parent =3D TYPE_VIRTIO_CCW_DEVICE, + .instance_size =3D sizeof(VHostUserFSCcw), + .instance_init =3D vhost_user_fs_ccw_instance_init, + .class_init =3D vhost_user_fs_ccw_class_init, +}; + +static void vhost_user_fs_ccw_register(void) +{ + type_register_static(&vhost_user_fs_ccw); +} + +type_init(vhost_user_fs_ccw_register) --=20 2.25.4 From nobody Tue May 7 19:38:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1593079708; cv=none; d=zohomail.com; s=zohoarc; b=SiFOFgEFzpvovZLQWXXTPJtDE3V4Mgy9/zZH3aw+n9OCBSbMGMRHQxPIjP9njsCNvU2x30p8W/9xRMAFAZCnMcO6a1DKghPQKHnq/JIJPVLuHIQ+wvPIJg54LI69MiD8+IZsZ/0bFTb7wp0nhnQNyXz3xikajktufW2GK1tdwE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593079708; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yfhqq+WLMn3OX7/Wug3Uw4d0Ml6xAWDo/yDewaTnq9U=; b=FRqkqO2JtYt0UXCpMzX8DIShLXjneD8WBOc9z7t6vMlXR7kvXwor7VaR6yyqPxw7A3RL+ClRrTVdX7uupCT51lAjhOh4HjpR71Z0rZXM+WD14MmUBVJYNNrjUs0tV6u8FDBuM7t0cbfXb7UVif4kzTs9t9uY1dO+LVaBY0WgI18= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593079708978440.4049827300207; Thu, 25 Jun 2020 03:08:28 -0700 (PDT) Received: from localhost ([::1]:46684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joOnz-0004TN-M6 for importer@patchew.org; Thu, 25 Jun 2020 06:08:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joOkW-0007ss-Tk for qemu-devel@nongnu.org; Thu, 25 Jun 2020 06:04:52 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:29180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joOkT-0001aE-Uq for qemu-devel@nongnu.org; Thu, 25 Jun 2020 06:04:52 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05PA3IwH126656 for ; Thu, 25 Jun 2020 06:04:48 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31ux00hj3n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jun 2020 06:04:48 -0400 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05PA3osh128603 for ; Thu, 25 Jun 2020 06:04:48 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 31ux00hhxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 06:04:47 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05PA1o4w025126; Thu, 25 Jun 2020 10:04:41 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06ams.nl.ibm.com with ESMTP id 31uusjhkda-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 10:04:40 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05PA3JD460555574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jun 2020 10:03:19 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA5144203F; Thu, 25 Jun 2020 10:04:38 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4F84F42042; Thu, 25 Jun 2020 10:04:38 +0000 (GMT) Received: from marcibm.ibmuc.com (unknown [9.145.42.231]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 25 Jun 2020 10:04:38 +0000 (GMT) From: Marc Hartmayer To: Subject: [RFC 2/4] libvhost-user: print invalid address on vu_panic Date: Thu, 25 Jun 2020 12:04:28 +0200 Message-Id: <20200625100430.22407-3-mhartmay@linux.ibm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200625100430.22407-1-mhartmay@linux.ibm.com> References: <20200625100430.22407-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-25_04:2020-06-25, 2020-06-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 cotscore=-2147483648 mlxscore=0 lowpriorityscore=0 suspectscore=1 adultscore=0 mlxlogscore=582 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006250062 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=mhartmay@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 06:04:43 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Cornelia Huck , Halil Pasic , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This can be helpful for debugging. Signed-off-by: Marc Hartmayer --- contrib/libvhost-user/libvhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index d315db139606..9e8750a9dabc 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -2432,7 +2432,7 @@ virtqueue_map_desc(VuDev *dev, =20 iov[num_sg].iov_base =3D vu_gpa_to_va(dev, &len, pa); if (iov[num_sg].iov_base =3D=3D NULL) { - vu_panic(dev, "virtio: invalid address for buffers"); + vu_panic(dev, "virtio: invalid address 0x%lx for buffers", pa); return; } iov[num_sg].iov_len =3D len; --=20 2.25.4 From nobody Tue May 7 19:38:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1593079629; cv=none; d=zohomail.com; s=zohoarc; b=ieERWQ7HBAAlXOzdD1l87NyAEJs6J4SL3imXq7oz70CQBwJhyOuutbWY1qmtjNGT93lpCsAE75+OHxC6r3E3Cnhu3nTNBurT61nZkkm7f7TJLXFcmVY+VcmEUiluqGPqKg6eh42JplYnDGkVpNbc2FKofixpA09B12KzzK9rod0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593079629; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4bgbFa+CodFxfNLyA0anhmtEsHP//9nSrBk36SxUIjc=; b=UggPq1Sv/kW4yuEYD/Jzo43DqeQJUbwV6n496dUtdYrgPkswS0RTsGwPZeHeaHzo76+S5i/f9hAHclXHG93TncZnQDbqBGdYqww0Mc0mChJ3EsHTF7RXd5zz3iPIiOvVcCsLfrbyqNJSK89Kbn4B7CKC9EXF3OhufWQIk6D2ROg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593079629877278.31638670643747; Thu, 25 Jun 2020 03:07:09 -0700 (PDT) Received: from localhost ([::1]:42472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joOmi-0002hg-DV for importer@patchew.org; Thu, 25 Jun 2020 06:07:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joOkV-0007q9-P0 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 06:04:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:21460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joOkS-0001ZT-Ut for qemu-devel@nongnu.org; Thu, 25 Jun 2020 06:04:51 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05PA2vps038022 for ; Thu, 25 Jun 2020 06:04:47 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31ux03ct0j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jun 2020 06:04:47 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05PA3Gvo038701 for ; Thu, 25 Jun 2020 06:04:46 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 31ux03csxe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 06:04:46 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05P9xMoB022779; Thu, 25 Jun 2020 10:04:41 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03fra.de.ibm.com with ESMTP id 31uusggsxc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 10:04:41 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05PA4daU57737364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jun 2020 10:04:39 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 356D64203F; Thu, 25 Jun 2020 10:04:39 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C631542052; Thu, 25 Jun 2020 10:04:38 +0000 (GMT) Received: from marcibm.ibmuc.com (unknown [9.145.42.231]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 25 Jun 2020 10:04:38 +0000 (GMT) From: Marc Hartmayer To: Subject: [RFC 3/4] libvhost-user: handle endianness as mandated by the spec Date: Thu, 25 Jun 2020 12:04:29 +0200 Message-Id: <20200625100430.22407-4-mhartmay@linux.ibm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200625100430.22407-1-mhartmay@linux.ibm.com> References: <20200625100430.22407-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-25_04:2020-06-25, 2020-06-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 impostorscore=0 cotscore=-2147483648 bulkscore=0 adultscore=0 mlxlogscore=962 mlxscore=0 priorityscore=1501 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006250062 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=mhartmay@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 06:04:43 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Cornelia Huck , Halil Pasic , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since virtio existed even before it got standardized, the virtio standard defines the following types of virtio devices: + legacy device (pre-virtio 1.0) + non-legacy or VIRTIO 1.0 device + transitional device (which can act both as legacy and non-legacy) Virtio 1.0 defines the fields of the virtqueues as little endian, while legacy uses guest's native endian [1]. Currently libvhost-user does not handle virtio endianness at all, i.e. it works only if the native endianness matches with whatever is actually needed. That means things break spectacularly on big-endian targets. Let us handle virtio endianness as required by the virtio specification [1]. [1] https://docs.oasis-open.org/virtio/virtio/v1.1/cs01/virtio-v1.1-cs01.ht= ml#x1-210003 Signed-off-by: Marc Hartmayer --- contrib/libvhost-user/libvhost-access.h | 88 +++++++++++++++++ contrib/libvhost-user/libvhost-user.c | 122 ++++++++++++------------ 2 files changed, 151 insertions(+), 59 deletions(-) create mode 100644 contrib/libvhost-user/libvhost-access.h diff --git a/contrib/libvhost-user/libvhost-access.h b/contrib/libvhost-use= r/libvhost-access.h new file mode 100644 index 000000000000..a4fc334fe134 --- /dev/null +++ b/contrib/libvhost-user/libvhost-access.h @@ -0,0 +1,88 @@ +#ifndef LIBVHOST_ACCESS_H + +#include "qemu/osdep.h" +#include "qemu/bswap.h" + +#include "libvhost-user.h" + +/* TODO attempt to use poisoned TARGET_PPC64/ARM */ +/* #if defined(TARGET_PPC64) || defined(TARGET_ARM) */ +/* #define LEGACY_VIRTIO_IS_BIENDIAN 1 */ +/* #endif */ + +static inline bool vu_is_big_endian(VuDev *dev) +{ + if (!vu_has_feature(dev, VIRTIO_F_VERSION_1)) { + /* TODO there is no `device_endian` attribute for VuDev */ + /* assert(vdev->device_endian !=3D VIRTIO_DEVICE_ENDIAN_UNKNOWN); = */ + /* return vdev->device_endian =3D=3D VIRTIO_DEVICE_ENDIAN_BIG; */ + } + + /* Devices conforming to VIRTIO 1.0 or later are always LE. */ + return false; +} + +static inline bool vu_access_is_big_endian(VuDev *dev) +{ +#if defined(LEGACY_VIRTIO_IS_BIENDIAN) + return vu_is_big_endian(dev); +#elif defined(TARGET_WORDS_BIGENDIAN) + if (vu_has_feature(dev, VIRTIO_F_VERSION_1)) { + /* Devices conforming to VIRTIO 1.0 or later are always LE. */ + return false; + } + return true; +#else + return false; +#endif +} + +static inline void vu_stw_p(VuDev *vdev, void *ptr, uint16_t v) +{ + if (vu_access_is_big_endian(vdev)) { + stw_be_p(ptr, v); + } else { + stw_le_p(ptr, v); + } +} + +static inline void vu_stl_p(VuDev *vdev, void *ptr, uint32_t v) +{ + if (vu_access_is_big_endian(vdev)) { + stl_be_p(ptr, v); + } else { + stl_le_p(ptr, v); + } +} + +static inline void vu_stq_p(VuDev *vdev, void *ptr, uint64_t v) +{ + if (vu_access_is_big_endian(vdev)) { + stq_be_p(ptr, v); + } else { + stq_le_p(ptr, v); + } +} + +static inline int vu_lduw_p(VuDev *vdev, const void *ptr) +{ + if (vu_access_is_big_endian(vdev)) + return lduw_be_p(ptr); + return lduw_le_p(ptr); +} + +static inline int vu_ldl_p(VuDev *vdev, const void *ptr) +{ + if (vu_access_is_big_endian(vdev)) + return ldl_be_p(ptr); + return ldl_le_p(ptr); +} + +static inline uint64_t vu_ldq_p(VuDev *vdev, const void *ptr) +{ + if (vu_access_is_big_endian(vdev)) + return ldq_be_p(ptr); + return ldq_le_p(ptr); +} + +#endif /* LIBVHOST_ACCESS_h */ diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index 9e8750a9dabc..200a90206ed2 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -45,6 +45,10 @@ #include "qemu/memfd.h" =20 #include "libvhost-user.h" +static inline bool has_feature(uint64_t features, unsigned int fbit); +static inline bool vu_has_feature(VuDev *dev, unsigned int fbit); + +#include "libvhost-access.h" =20 /* usually provided by GLib */ #ifndef MIN @@ -1074,7 +1078,7 @@ vu_set_vring_addr_exec(VuDev *dev, VhostUserMsg *vmsg) return false; } =20 - vq->used_idx =3D vq->vring.used->idx; + vq->used_idx =3D vu_lduw_p(dev, &vq->vring.used->idx); =20 if (vq->last_avail_idx !=3D vq->used_idx) { bool resume =3D dev->iface->queue_is_processed_in_order && @@ -1191,7 +1195,7 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq) return 0; } =20 - vq->used_idx =3D vq->vring.used->idx; + vq->used_idx =3D vu_lduw_p(dev, &vq->vring.used->idx); vq->resubmit_num =3D 0; vq->resubmit_list =3D NULL; vq->counter =3D 0; @@ -2019,35 +2023,35 @@ vu_queue_started(const VuDev *dev, const VuVirtq *v= q) } =20 static inline uint16_t -vring_avail_flags(VuVirtq *vq) +vring_avail_flags(VuDev *dev, VuVirtq *vq) { - return vq->vring.avail->flags; + return vu_lduw_p(dev, &vq->vring.avail->flags); } =20 static inline uint16_t -vring_avail_idx(VuVirtq *vq) +vring_avail_idx(VuDev *dev, VuVirtq *vq) { - vq->shadow_avail_idx =3D vq->vring.avail->idx; + vq->shadow_avail_idx =3D vu_lduw_p(dev, &vq->vring.avail->idx); =20 return vq->shadow_avail_idx; } =20 static inline uint16_t -vring_avail_ring(VuVirtq *vq, int i) +vring_avail_ring(VuDev *dev, VuVirtq *vq, int i) { - return vq->vring.avail->ring[i]; + return vu_lduw_p(dev, &vq->vring.avail->ring[i]); } =20 static inline uint16_t -vring_get_used_event(VuVirtq *vq) +vring_get_used_event(VuDev *dev, VuVirtq *vq) { - return vring_avail_ring(vq, vq->vring.num); + return vring_avail_ring(dev, vq, vq->vring.num); } =20 static int virtqueue_num_heads(VuDev *dev, VuVirtq *vq, unsigned int idx) { - uint16_t num_heads =3D vring_avail_idx(vq) - idx; + uint16_t num_heads =3D vring_avail_idx(dev, vq) - idx; =20 /* Check it isn't doing very strange things with descriptor numbers. */ if (num_heads > vq->vring.num) { @@ -2070,7 +2074,7 @@ virtqueue_get_head(VuDev *dev, VuVirtq *vq, { /* Grab the next descriptor number they're advertising, and increment * the index we've seen. */ - *head =3D vring_avail_ring(vq, idx % vq->vring.num); + *head =3D vring_avail_ring(dev, vq, idx % vq->vring.num); =20 /* If their number is silly, that's a fatal mistake. */ if (*head >=3D vq->vring.num) { @@ -2123,12 +2127,12 @@ virtqueue_read_next_desc(VuDev *dev, struct vring_d= esc *desc, int i, unsigned int max, unsigned int *next) { /* If this descriptor says it doesn't chain, we're done. */ - if (!(desc[i].flags & VRING_DESC_F_NEXT)) { + if (!(vu_lduw_p(dev, &desc[i].flags) & VRING_DESC_F_NEXT)) { return VIRTQUEUE_READ_DESC_DONE; } =20 /* Check they're not leading us off end of descriptors. */ - *next =3D desc[i].next; + *next =3D vu_lduw_p(dev, &desc[i].next); /* Make sure compiler knows to grab that: we don't want it changing! */ smp_wmb(); =20 @@ -2171,8 +2175,8 @@ vu_queue_get_avail_bytes(VuDev *dev, VuVirtq *vq, uns= igned int *in_bytes, } desc =3D vq->vring.desc; =20 - if (desc[i].flags & VRING_DESC_F_INDIRECT) { - if (desc[i].len % sizeof(struct vring_desc)) { + if (vu_lduw_p(dev, &desc[i].flags) & VRING_DESC_F_INDIRECT) { + if (vu_ldl_p(dev, &desc[i].len) % sizeof(struct vring_desc)) { vu_panic(dev, "Invalid size for indirect buffer table"); goto err; } @@ -2185,8 +2189,8 @@ vu_queue_get_avail_bytes(VuDev *dev, VuVirtq *vq, uns= igned int *in_bytes, =20 /* loop over the indirect descriptor table */ indirect =3D 1; - desc_addr =3D desc[i].addr; - desc_len =3D desc[i].len; + desc_addr =3D vu_ldq_p(dev, &desc[i].addr); + desc_len =3D vu_ldl_p(dev, &desc[i].len); max =3D desc_len / sizeof(struct vring_desc); read_len =3D desc_len; desc =3D vu_gpa_to_va(dev, &read_len, desc_addr); @@ -2213,10 +2217,10 @@ vu_queue_get_avail_bytes(VuDev *dev, VuVirtq *vq, u= nsigned int *in_bytes, goto err; } =20 - if (desc[i].flags & VRING_DESC_F_WRITE) { - in_total +=3D desc[i].len; + if (vu_lduw_p(dev, &desc[i].flags) & VRING_DESC_F_WRITE) { + in_total +=3D vu_ldl_p(dev, &desc[i].len); } else { - out_total +=3D desc[i].len; + out_total +=3D vu_ldl_p(dev, &desc[i].len); } if (in_total >=3D max_in_bytes && out_total >=3D max_out_bytes= ) { goto done; @@ -2277,7 +2281,7 @@ vu_queue_empty(VuDev *dev, VuVirtq *vq) return false; } =20 - return vring_avail_idx(vq) =3D=3D vq->last_avail_idx; + return vring_avail_idx(dev, vq) =3D=3D vq->last_avail_idx; } =20 static bool @@ -2296,14 +2300,14 @@ vring_notify(VuDev *dev, VuVirtq *vq) } =20 if (!vu_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { - return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT); + return !(vring_avail_flags(dev, vq) & VRING_AVAIL_F_NO_INTERRUPT); } =20 v =3D vq->signalled_used_valid; vq->signalled_used_valid =3D true; old =3D vq->signalled_used; new =3D vq->signalled_used =3D vq->used_idx; - return !v || vring_need_event(vring_get_used_event(vq), new, old); + return !v || vring_need_event(vring_get_used_event(dev, vq), new, old); } =20 static void _vu_queue_notify(VuDev *dev, VuVirtq *vq, bool sync) @@ -2361,33 +2365,33 @@ void vu_queue_notify_sync(VuDev *dev, VuVirtq *vq) } =20 static inline void -vring_used_flags_set_bit(VuVirtq *vq, int mask) +vring_used_flags_set_bit(VuDev *dev, VuVirtq *vq, int mask) +{ + uint16_t *flags; + + flags =3D (uint16_t *)(char*)vq->vring.used + + offsetof(struct vring_used, flags); + vu_stw_p(dev, flags, vu_lduw_p(dev, flags) | mask); +} + +static inline void +vring_used_flags_unset_bit(VuDev *dev, VuVirtq *vq, int mask) { uint16_t *flags; =20 flags =3D (uint16_t *)((char*)vq->vring.used + offsetof(struct vring_used, flags)); - *flags |=3D mask; + vu_stw_p(dev, flags, vu_lduw_p(dev, flags) & ~mask); } =20 static inline void -vring_used_flags_unset_bit(VuVirtq *vq, int mask) -{ - uint16_t *flags; - - flags =3D (uint16_t *)((char*)vq->vring.used + - offsetof(struct vring_used, flags)); - *flags &=3D ~mask; -} - -static inline void -vring_set_avail_event(VuVirtq *vq, uint16_t val) +vring_set_avail_event(VuDev *dev, VuVirtq *vq, uint16_t val) { if (!vq->notification) { return; } =20 - *((uint16_t *) &vq->vring.used->ring[vq->vring.num]) =3D val; + vu_stw_p(dev, &vq->vring.used->ring[vq->vring.num], val); } =20 void @@ -2395,11 +2399,11 @@ vu_queue_set_notification(VuDev *dev, VuVirtq *vq, = int enable) { vq->notification =3D enable; if (vu_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { - vring_set_avail_event(vq, vring_avail_idx(vq)); + vring_set_avail_event(dev, vq, vring_avail_idx(dev, vq)); } else if (enable) { - vring_used_flags_unset_bit(vq, VRING_USED_F_NO_NOTIFY); + vring_used_flags_unset_bit(dev, vq, VRING_USED_F_NO_NOTIFY); } else { - vring_used_flags_set_bit(vq, VRING_USED_F_NO_NOTIFY); + vring_used_flags_set_bit(dev, vq, VRING_USED_F_NO_NOTIFY); } if (enable) { /* Expose avail event/used flags before caller checks the avail id= x. */ @@ -2476,14 +2480,14 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned= int idx, size_t sz) struct vring_desc desc_buf[VIRTQUEUE_MAX_SIZE]; int rc; =20 - if (desc[i].flags & VRING_DESC_F_INDIRECT) { - if (desc[i].len % sizeof(struct vring_desc)) { + if (vu_lduw_p(dev, &desc[i].flags) & VRING_DESC_F_INDIRECT) { + if (vu_ldl_p(dev, &desc[i].len) % sizeof(struct vring_desc)) { vu_panic(dev, "Invalid size for indirect buffer table"); } =20 /* loop over the indirect descriptor table */ - desc_addr =3D desc[i].addr; - desc_len =3D desc[i].len; + desc_addr =3D vu_ldq_p(dev, &desc[i].addr); + desc_len =3D vu_ldl_p(dev, &desc[i].len); max =3D desc_len / sizeof(struct vring_desc); read_len =3D desc_len; desc =3D vu_gpa_to_va(dev, &read_len, desc_addr); @@ -2505,10 +2509,10 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned= int idx, size_t sz) =20 /* Collect all the descriptors */ do { - if (desc[i].flags & VRING_DESC_F_WRITE) { + if (vu_lduw_p(dev, &desc[i].flags) & VRING_DESC_F_WRITE) { virtqueue_map_desc(dev, &in_num, iov + out_num, VIRTQUEUE_MAX_SIZE - out_num, true, - desc[i].addr, desc[i].len); + vu_ldq_p(dev, &desc[i].addr), vu_ldl_p(dev,= &desc[i].len)); } else { if (in_num) { vu_panic(dev, "Incorrect order for descriptors"); @@ -2516,7 +2520,7 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned i= nt idx, size_t sz) } virtqueue_map_desc(dev, &out_num, iov, VIRTQUEUE_MAX_SIZE, false, - desc[i].addr, desc[i].len); + vu_ldq_p(dev, &desc[i].addr), vu_ldl_p(dev,= &desc[i].len)); } =20 /* If we've got too many, that implies a descriptor loop. */ @@ -2642,7 +2646,7 @@ vu_queue_pop(VuDev *dev, VuVirtq *vq, size_t sz) } =20 if (vu_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) { - vring_set_avail_event(vq, vq->last_avail_idx); + vring_set_avail_event(dev, vq, vq->last_avail_idx); } =20 elem =3D vu_queue_map_desc(dev, vq, head, sz); @@ -2712,14 +2716,14 @@ vu_log_queue_fill(VuDev *dev, VuVirtq *vq, max =3D vq->vring.num; i =3D elem->index; =20 - if (desc[i].flags & VRING_DESC_F_INDIRECT) { - if (desc[i].len % sizeof(struct vring_desc)) { + if (vu_lduw_p(dev, &desc[i].flags) & VRING_DESC_F_INDIRECT) { + if (vu_ldl_p(dev, &desc[i].len) % sizeof(struct vring_desc)) { vu_panic(dev, "Invalid size for indirect buffer table"); } =20 /* loop over the indirect descriptor table */ - desc_addr =3D desc[i].addr; - desc_len =3D desc[i].len; + desc_addr =3D vu_ldq_p(dev, &desc[i].addr); + desc_len =3D vu_ldl_p(dev, &desc[i].len); max =3D desc_len / sizeof(struct vring_desc); read_len =3D desc_len; desc =3D vu_gpa_to_va(dev, &read_len, desc_addr); @@ -2745,9 +2749,9 @@ vu_log_queue_fill(VuDev *dev, VuVirtq *vq, return; } =20 - if (desc[i].flags & VRING_DESC_F_WRITE) { - min =3D MIN(desc[i].len, len); - vu_log_write(dev, desc[i].addr, min); + if (vu_lduw_p(dev, &desc[i].flags) & VRING_DESC_F_WRITE) { + min =3D MIN(vu_ldl_p(dev, &desc[i].len), len); + vu_log_write(dev, vu_ldq_p(dev, &desc[i].addr), min); len -=3D min; } =20 @@ -2772,15 +2776,15 @@ vu_queue_fill(VuDev *dev, VuVirtq *vq, =20 idx =3D (idx + vq->used_idx) % vq->vring.num; =20 - uelem.id =3D elem->index; - uelem.len =3D len; + vu_stl_p(dev, &uelem.id, elem->index); + vu_stl_p(dev, &uelem.len, len); vring_used_write(dev, vq, &uelem, idx); } =20 static inline void vring_used_idx_set(VuDev *dev, VuVirtq *vq, uint16_t val) { - vq->vring.used->idx =3D val; + vu_stw_p(dev, &vq->vring.used->idx, val); vu_log_write(dev, vq->vring.log_guest_addr + offsetof(struct vring_used, id= x), sizeof(vq->vring.used->idx)); --=20 2.25.4 From nobody Tue May 7 19:38:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1593079556; cv=none; d=zohomail.com; s=zohoarc; b=k4zGrMdNrP4P0/RNGnXieEyL8OpyNbDBIUUmsSsvUDauSlJgrIfUF8wHTjXxICkmIP53up5mscsAQibRYz9BorlY16QdLNC9zmwy9tsB6/WOixVyZDmHD0cHhjqB1F+BvGeGdn3as9cB2QpY6BjoaMML32YYQdIu4uQ/Vb6WEvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593079556; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hA1OMzdNPdGivLAk6KfstsA9Bb9epO5w0PCZ8GK7jnw=; b=VjbPTpa/dKX+pFBxuFozAj2G+A7mEMTUEzeLpw18Q0k6QKyS/52scWVTMB+hcx4a52YXMfRcS+IHFQ7ZXOaPI+ZrAutGITm6QLmTizJ9hOzkqg2etC6cxS/RMXgcCWKjHn3z/HPhYSRAHdiRJ6wj6ixM1KgcKv23VbmBY2ESht0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593079556095453.56747673228415; Thu, 25 Jun 2020 03:05:56 -0700 (PDT) Received: from localhost ([::1]:37930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joOlV-0000mR-RL for importer@patchew.org; Thu, 25 Jun 2020 06:05:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joOkT-0007lr-3S for qemu-devel@nongnu.org; Thu, 25 Jun 2020 06:04:49 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joOkR-0001Z5-5c for qemu-devel@nongnu.org; Thu, 25 Jun 2020 06:04:48 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05PA2vdY038031 for ; Thu, 25 Jun 2020 06:04:46 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31ux03csyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jun 2020 06:04:45 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05PA3Jvu038903 for ; Thu, 25 Jun 2020 06:04:44 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 31ux03csxf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 06:04:44 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05PA0ZcW009919; Thu, 25 Jun 2020 10:04:42 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 31uus51nj5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 10:04:41 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05PA4dSL29294764 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jun 2020 10:04:39 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E4414203F; Thu, 25 Jun 2020 10:04:39 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5098D42049; Thu, 25 Jun 2020 10:04:39 +0000 (GMT) Received: from marcibm.ibmuc.com (unknown [9.145.42.231]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 25 Jun 2020 10:04:39 +0000 (GMT) From: Marc Hartmayer To: Subject: [RFC 4/4] HACK: Hard-code the libvhost-user.o-cflags for s390x Date: Thu, 25 Jun 2020 12:04:30 +0200 Message-Id: <20200625100430.22407-5-mhartmay@linux.ibm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200625100430.22407-1-mhartmay@linux.ibm.com> References: <20200625100430.22407-1-mhartmay@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-25_04:2020-06-25, 2020-06-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 impostorscore=0 cotscore=-2147483648 bulkscore=0 adultscore=0 mlxlogscore=799 mlxscore=0 priorityscore=1501 spamscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006250062 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=mhartmay@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 06:04:43 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Cornelia Huck , Halil Pasic , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This patch exists only to show the actual problem that libvhost-user and it's users are architecture dependent as soon as we're trying to support legacy virtio. Signed-off-by: Marc Hartmayer --- Makefile.objs | 1 + contrib/libvhost-user/libvhost-access.h | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index 7ce2588b89a3..abfb1912e456 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -111,6 +111,7 @@ elf2dmp-obj-y =3D contrib/elf2dmp/ ivshmem-client-obj-$(CONFIG_IVSHMEM) =3D contrib/ivshmem-client/ ivshmem-server-obj-$(CONFIG_IVSHMEM) =3D contrib/ivshmem-server/ libvhost-user-obj-y =3D contrib/libvhost-user/ +libvhost-user.o-cflags +=3D -iquote $(SRC_PATH)/s390x-softmmu -DNEED_CPU_H vhost-user-scsi.o-cflags :=3D $(LIBISCSI_CFLAGS) vhost-user-scsi.o-libs :=3D $(LIBISCSI_LIBS) vhost-user-scsi-obj-y =3D contrib/vhost-user-scsi/ diff --git a/contrib/libvhost-user/libvhost-access.h b/contrib/libvhost-use= r/libvhost-access.h index a4fc334fe134..e9451ae0fbc6 100644 --- a/contrib/libvhost-user/libvhost-access.h +++ b/contrib/libvhost-user/libvhost-access.h @@ -5,10 +5,9 @@ =20 #include "libvhost-user.h" =20 -/* TODO attempt to use poisoned TARGET_PPC64/ARM */ -/* #if defined(TARGET_PPC64) || defined(TARGET_ARM) */ -/* #define LEGACY_VIRTIO_IS_BIENDIAN 1 */ -/* #endif */ +#if defined(TARGET_PPC64) || defined(TARGET_ARM) +#define LEGACY_VIRTIO_IS_BIENDIAN 1 +#endif =20 static inline bool vu_is_big_endian(VuDev *dev) { --=20 2.25.4