From patchwork Fri Nov 12 14:57:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Halil Pasic X-Patchwork-Id: 12616925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF738C433F5 for ; Fri, 12 Nov 2021 15:07:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 64EE1604AC for ; Fri, 12 Nov 2021 15:07:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 64EE1604AC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:59040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlY9i-0002cR-Ij for qemu-devel@archiver.kernel.org; Fri, 12 Nov 2021 10:07:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlY0d-0000NL-GL; Fri, 12 Nov 2021 09:58:32 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlY0Y-0005kQ-MI; Fri, 12 Nov 2021 09:58:29 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1ACErj1S000875; Fri, 12 Nov 2021 14:58:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=4m4v72e8AhAYwdgBA/lw2nEG9f/fYSCLegX1PPSHzqA=; b=OxtCQkKaFq24f/+DPw11s+Rz5HyLdWs+JvSrh4MMIEfHLIKHMTyh/elYc3LlRaSssqT0 0HuSkGqvbH6BBLZeLuVpBd52Qxt0e32itG+CY3tV46j8SF4D3Y3TUck0veegiecUxcqY h1wi7G2ERRnVFxhwzmeyGnDuJI4ixfRirTv0abnwdF/sJvuykoBx4NIg/nWQytvY76Iz c36iHdKXxe1eZOjR2S9+hIVdLSgV3n8eZOZonXAGEVmj9EKRs3j0I9BnFNOFSB6Ziz2O JKEnnMapeEKtsbhibWe1mfRwYa6TXNuhIr2sPYGQeIG4yUznpIzdC4dG64JXkFe52bB5 8g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3c9tebg1tc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:16 +0000 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1ACEwGhv015294; Fri, 12 Nov 2021 14:58:16 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3c9tebg1sk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:16 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1ACErLhm003231; Fri, 12 Nov 2021 14:58:14 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 3c9t6sr4hq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:14 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1ACEwAF956426800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Nov 2021 14:58:10 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79C5EA4067; Fri, 12 Nov 2021 14:58:10 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3ACFFA4060; Fri, 12 Nov 2021 14:58:10 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Nov 2021 14:58:10 +0000 (GMT) From: Halil Pasic To: "Michael S. Tsirkin" , Cornelia Huck , Halil Pasic , qemu-s390x@nongnu.org, qemu-devel@nongnu.org Subject: [RFC PATCH v2 1/5] virtio: introduce virtio_force_modern() Date: Fri, 12 Nov 2021 15:57:45 +0100 Message-Id: <20211112145749.618157-2-pasic@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211112145749.618157-1-pasic@linux.ibm.com> References: <20211112145749.618157-1-pasic@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Iu4nadT6Pn-GT3NjmrNX1qsZim6wKQRs X-Proofpoint-ORIG-GUID: _jL4SVykprJ2VCV2t5RVd0HtAw2_hfC7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-12_05,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 clxscore=1015 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 adultscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111120083 Received-SPF: pass client-ip=148.163.156.1; envelope-from=pasic@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Thomas Huth , Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Legacy vs modern should be detected via transport specific means. We can't wait till feature negotiation is done. Let us introduce virtio_force_modern() as a means for the transport code to signal that the device should operate in modern mode (because a modern driver was detected). A new callback is added for the situations where the device needs to do more than just setting the VIRTIO_F_VERSION_1 feature bit. For example, when vhost is involved, we may need to propagate the features to the vhost device. Signed-off-by: Halil Pasic --- I'm still struggling with how to deal with vhost-user and co. The problem is that I'm not very familiar with the life-cycle of, let us say, a vhost_user device. Looks to me like the vhost part might be just an implementation detail, and could even become a hot swappable thing. Another thing is, that vhost processes set_features differently. It might or might not be a good idea to change this. Does anybody know why don't we propagate the features on features_set, but under a set of different conditions, one of which is the vhost device is started? --- hw/virtio/virtio.c | 13 +++++++++++++ include/hw/virtio/virtio.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 3a1f6c520c..26db1b31e6 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3281,6 +3281,19 @@ void virtio_init(VirtIODevice *vdev, const char *name, vdev->use_guest_notifier_mask = true; } +void virtio_force_modern(VirtIODevice *vdev) +{ + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); + + virtio_add_feature(&vdev->guest_features, VIRTIO_F_VERSION_1); + /* Let the device do it's normal thing. */ + virtio_set_features(vdev, vdev->guest_features); + /* For example for vhost-user we have to propagate to the vhost dev. */ + if (k->force_modern) { + k->force_modern(vdev); + } +} + /* * Only devices that have already been around prior to defining the virtio * standard support legacy mode; this includes devices not specified in the diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 8bab9cfb75..1bb1551865 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -126,6 +126,7 @@ struct VirtioDeviceClass { int (*validate_features)(VirtIODevice *vdev); void (*get_config)(VirtIODevice *vdev, uint8_t *config); void (*set_config)(VirtIODevice *vdev, const uint8_t *config); + void (*force_modern)(VirtIODevice *vdev); void (*reset)(VirtIODevice *vdev); void (*set_status)(VirtIODevice *vdev, uint8_t val); /* For transitional devices, this is a bitmap of features @@ -394,6 +395,7 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev) return unlikely(vdev->disabled || vdev->broken); } +void virtio_force_modern(VirtIODevice *vdev); bool virtio_legacy_allowed(VirtIODevice *vdev); bool virtio_legacy_check_disabled(VirtIODevice *vdev); From patchwork Fri Nov 12 14:57:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Halil Pasic X-Patchwork-Id: 12616911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A336C433EF for ; Fri, 12 Nov 2021 15:00:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98DBA60F46 for ; Fri, 12 Nov 2021 15:00:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 98DBA60F46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlY2t-00038l-Jb for qemu-devel@archiver.kernel.org; Fri, 12 Nov 2021 10:00:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlY0b-0000L6-Hv; Fri, 12 Nov 2021 09:58:29 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48176 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 1mlY0Y-0005kE-QI; Fri, 12 Nov 2021 09:58:29 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1ACEfEsf021400; Fri, 12 Nov 2021 14:58:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=JQeFMVaD6s2RpuiTGyeQT2YhwCE+unHut0t6RqQu0LY=; b=FAl2ntR/qPiMdd7e2JaRniUH0S0y7SGPn6yx9tCDW+YpWjoDu+B3yp0gQElOFtRScqwe GNmmpkNEp9M9XTy2Gklv+VbxJsxMzt07zlT6XFHSRVb6IAtkOzBJJbbzOV6CvsPeW77n S0Vq0am5M3CVsqlBAGepwMG3QDm4xtN9yYj68W+FNNux3o+lSW8JZjOzv16+Vsqb1vby ZSlyER4S4TMhxTKR4yYSu85y8WSry12nPk3vfqvCwyORlDtjNIvO/dHBm3/B43F0RWMI BShE3W+BNhtZ2TPMsklbhMDhgsIHGm435gA5gRNgWnn42WogV9fmOPicAobAdFTmtrA2 9g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3c9s7thn8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:16 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1ACEhBVE025930; Fri, 12 Nov 2021 14:58:16 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 3c9s7thn81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:15 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1ACEqLsI018718; Fri, 12 Nov 2021 14:58:14 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 3c5gykhexe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:13 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1ACEwBHK56426804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Nov 2021 14:58:11 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D7D11A4054; Fri, 12 Nov 2021 14:58:10 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FEA5A4069; Fri, 12 Nov 2021 14:58:10 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Nov 2021 14:58:10 +0000 (GMT) From: Halil Pasic To: "Michael S. Tsirkin" , Cornelia Huck , Halil Pasic , qemu-s390x@nongnu.org, qemu-devel@nongnu.org Subject: [RFC PATCH v2 2/5] virtio-ccw: use virtio_force_modern() Date: Fri, 12 Nov 2021 15:57:46 +0100 Message-Id: <20211112145749.618157-3-pasic@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211112145749.618157-1-pasic@linux.ibm.com> References: <20211112145749.618157-1-pasic@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: vWP9w_Hdp6AUxaRroKybwTEObZNT-Oz4 X-Proofpoint-GUID: CQCK0Wq70FtnVGW_mGA-pkwy3G8goONS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-12_05,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111120083 Received-SPF: pass client-ip=148.163.158.5; envelope-from=pasic@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Thomas Huth , Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The fact that revision > 0 was negotiated implies that VIRTIO_VERSION_1 aka modern must be used. This negotiation is done before the obligatory reset. Let us call virtio_force_modern() after the reset if revision > 0 was negotiated, so that the VIRTIO_VERSION_1 feature can be set, and endianness starts working as it should for devices that comply to the virtio spec. Signed-off-by: Halil Pasic --- hw/s390x/virtio-ccw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 6a2df1c1e9..88fbe87942 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -266,6 +266,9 @@ static void virtio_ccw_reset_virtio(VirtioCcwDevice *dev, VirtIODevice *vdev) dev->summary_indicator = NULL; } ccw_dev->sch->thinint_active = false; + if (dev->revision > 0) { + virtio_force_modern(vdev); + } } static int virtio_ccw_handle_set_vq(SubchDev *sch, CCW1 ccw, bool check_len, From patchwork Fri Nov 12 14:57:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Halil Pasic X-Patchwork-Id: 12616909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DCBEC433EF for ; Fri, 12 Nov 2021 15:00:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 004B16023F for ; Fri, 12 Nov 2021 15:00:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 004B16023F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlY2n-0002z7-UW for qemu-devel@archiver.kernel.org; Fri, 12 Nov 2021 10:00:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlY0a-0000Ju-Gk; Fri, 12 Nov 2021 09:58:29 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:31742 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 1mlY0W-0005kB-Bc; Fri, 12 Nov 2021 09:58:27 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1ACEfXD3021675; Fri, 12 Nov 2021 14:58:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=ZhRZsbqMV1pDRs5+mgJb3Ty7RNROaNLBkJJxRCtLesY=; b=ahxCWbLtAjq8Id2DK7eyQfVEWwWCj8YXoyfVxU/i/S3Y8Dsd+TmA/4J6ty3kIAr6K1ux BbJ/awwckbyBDjx5cyphApkvebMy0936t2xPR3M8F7bwFLx1vuJF0qNXKf4amfc7RnRZ kvq3sONY3rQ5zUiOX96qzfEFeMN+KQlcrwKuyEiUoDGm+xiX9TYGzshCcJxhPJpMTKzZ +wRQ66q4CultqtTtPBiLvbYxbEqUMqG60QNH/1Z1H3YxM4vd96nwz6f2wTNxfP7MQPhe 2pCPeMmhz5Bhz2BYnNKisdIDtw0jf2c6TYzIWxNE3/k/K3/JIIDh45ejG+aqSjeVkYfr XQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3c9s7thn92-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:17 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1ACEhFN1025987; Fri, 12 Nov 2021 14:58:16 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 3c9s7thn89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:16 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1ACEqMwp019763; Fri, 12 Nov 2021 14:58:14 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma05fra.de.ibm.com with ESMTP id 3c5hbaedw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:14 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1ACEpRdI64225598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Nov 2021 14:51:27 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 502E5A4064; Fri, 12 Nov 2021 14:58:11 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3C5CA4060; Fri, 12 Nov 2021 14:58:10 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Nov 2021 14:58:10 +0000 (GMT) From: Halil Pasic To: "Michael S. Tsirkin" , Cornelia Huck , Halil Pasic , qemu-s390x@nongnu.org, qemu-devel@nongnu.org Subject: [RFC PATCH v2 3/5] virtio-pci: use virtio_force_modern() Date: Fri, 12 Nov 2021 15:57:47 +0100 Message-Id: <20211112145749.618157-4-pasic@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211112145749.618157-1-pasic@linux.ibm.com> References: <20211112145749.618157-1-pasic@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: GXuHH5z8-2atYOl-fbnWdNoC3n5v0vo1 X-Proofpoint-GUID: 4z01vNNl_aTeuHi_EOxo1rjDKkOF3_pt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-12_05,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=948 spamscore=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111120083 Received-SPF: pass client-ip=148.163.158.5; envelope-from=pasic@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Thomas Huth , Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Let us detect usage via the modern interface by tapping into the place that implements the 'modern' reset. Signed-off-by: Halil Pasic --- hw/virtio/virtio-pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 6e16e2705c..8dd862da21 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1297,6 +1297,7 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr, if (vdev->status == 0) { virtio_pci_reset(DEVICE(proxy)); + virtio_force_modern(virtio_bus_get_device(&proxy->bus)); } break; From patchwork Fri Nov 12 14:57:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Halil Pasic X-Patchwork-Id: 12616919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E766CC433EF for ; Fri, 12 Nov 2021 15:05:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81F5360EE2 for ; Fri, 12 Nov 2021 15:05:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 81F5360EE2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:50696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlY77-00021V-Jx for qemu-devel@archiver.kernel.org; Fri, 12 Nov 2021 10:05:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlY0b-0000L3-HH; Fri, 12 Nov 2021 09:58:29 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlY0Y-0005kV-Lp; Fri, 12 Nov 2021 09:58:28 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1ACDe7do013786; Fri, 12 Nov 2021 14:58:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=BpsDwGspYmxNfw1Wc2Lav1ChYbAorcBYe0UJAiUmDNs=; b=NRWRzk7TfZD++FyrgJYZFY1Ae28mQh5MFkSoqTiRcUZeqI4prWSskro7y4+d2IITxV1I kE1GDJR3QvKQpTLspfybo9C7K52ucbFLp3Nqea10YIHk9ijrzrRfyiR4JBrxv4m6TsTI aGMdJVE/ktdZ2StDKNDZz9HyOG9RvUYltM18DxHhmBsBeQgnUp/Rv0YFe7JnvFF122oL TkERETiTUqT1syppkKZd+G/HekbKivIAa3av8wbaxK/CkIOh3gDJMzFQGW+wILWOXEC6 enRq8bOeWNOTl2n0/iPLTpI9Kk80K1k/B86qwpjr8+1EH/naTbWqtxjarCRNXOJsBB3x pg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3c9pu2d80m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:17 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1ACDem94015479; Fri, 12 Nov 2021 14:58:17 GMT 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 3c9pu2d7yv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:17 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1ACErRl9004380; Fri, 12 Nov 2021 14:58:14 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03fra.de.ibm.com with ESMTP id 3c5hbb6e7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:14 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1ACEpRBp61866302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Nov 2021 14:51:27 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4DC0A405B; Fri, 12 Nov 2021 14:58:11 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CEA8A405C; Fri, 12 Nov 2021 14:58:11 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Nov 2021 14:58:11 +0000 (GMT) From: Halil Pasic To: "Michael S. Tsirkin" , Cornelia Huck , Halil Pasic , qemu-s390x@nongnu.org, qemu-devel@nongnu.org Subject: [RFC PATCH v2 4/5] vhost: push features to backend on force_modern Date: Fri, 12 Nov 2021 15:57:48 +0100 Message-Id: <20211112145749.618157-5-pasic@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211112145749.618157-1-pasic@linux.ibm.com> References: <20211112145749.618157-1-pasic@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: NkMquReM09Rl4t-Fmydy3GdqZzUREXCy X-Proofpoint-ORIG-GUID: tjtXqWtY5m18X_S95jiSOEIpmlDR-3tJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-12_05,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 mlxlogscore=999 impostorscore=0 phishscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111120083 Received-SPF: pass client-ip=148.163.156.1; envelope-from=pasic@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Thomas Huth , Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In vhost we don't push the features to the vhost device when the features are set, but when the vhost device is started. This can lead to problems when config space is implemented in the vhost device, and the driver does some early config space reading (early in a sense that it precedes setting FEATURES_OK). Signed-off-by: Halil Pasic --- hw/virtio/vhost.c | 17 +++++++++++++++++ include/hw/virtio/vhost.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index b4b29413e6..5764970298 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1628,6 +1628,23 @@ void vhost_dev_free_inflight(struct vhost_inflight *inflight) } } +int vhost_dev_force_modern(struct vhost_dev *hdev) +{ + uint64_t features; + int r; + + assert(hdev->vhost_ops); + + hdev->acked_features |= (0x1ULL << VIRTIO_F_VERSION_1); + features = hdev->acked_features; + r = hdev->vhost_ops->vhost_set_features(hdev, features); + if (r < 0) { + VHOST_OPS_DEBUG("vhost_set_features failed"); + return -errno; + } + return 0; +} + static int vhost_dev_resize_inflight(struct vhost_inflight *inflight, uint64_t new_size) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 1a9fc65089..9ef784e2e9 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -138,6 +138,8 @@ int vhost_dev_get_config(struct vhost_dev *hdev, uint8_t *config, uint32_t config_len, Error **errp); int vhost_dev_set_config(struct vhost_dev *dev, const uint8_t *data, uint32_t offset, uint32_t size, uint32_t flags); + +int vhost_dev_force_modern(struct vhost_dev *vdev); /* notifier callback in case vhost device config space changed */ void vhost_dev_set_config_notifier(struct vhost_dev *dev, From patchwork Fri Nov 12 14:57:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Halil Pasic X-Patchwork-Id: 12616917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E17CC433F5 for ; Fri, 12 Nov 2021 15:04:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08DE360EE2 for ; Fri, 12 Nov 2021 15:04:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 08DE360EE2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:50398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlY6R-0001oq-UF for qemu-devel@archiver.kernel.org; Fri, 12 Nov 2021 10:04:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlY0b-0000L2-HH; Fri, 12 Nov 2021 09:58:29 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45102 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 1mlY0Y-0005kT-Mm; Fri, 12 Nov 2021 09:58:28 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1ACEuoP3000371; Fri, 12 Nov 2021 14:58:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=BApSWuuELc5pXk11TJVOLAF4aE5FMNPYwv9VI8IWetA=; b=EggA1uxULeQGzgClMsgyR92eTW49gn/U8ZgOgkfiVr4D7LulPpM7TAqbDqCNkZhxXEES +tKI7drgtVwJrwrvYEdNXJ6t1N2S+sp1nErCEt77wK/4lhIIIXC73qHnh+Q7FZr29Uhi ebLT2Yz4h6ArbiJEgK+BtV7EoYVRge+weapS/b3CjemqGFoLTIvSqTzaNbXTvWz35Chs iRCUkaQgFSV22zO1pf1DI4CKL06IxVT8FeTiZqgck48uFOkbarkQLXyns4940Xju5G3g deTBCztFrW0oszmmJhSeyJ6D9or5JXPVhF4HIm+gH2QvtxT3O84aXk2qFh6UVIwMTnVV rA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3c9r2sumpt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:18 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1ACEjWov007876; Fri, 12 Nov 2021 14:58:18 GMT 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 3c9r2sump9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:17 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1ACErLhI003230; Fri, 12 Nov 2021 14:58:15 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3c9t6sr4hy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 14:58:15 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1ACEwCpE63045916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Nov 2021 14:58:12 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05E1FA405B; Fri, 12 Nov 2021 14:58:12 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B2024A4064; Fri, 12 Nov 2021 14:58:11 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Nov 2021 14:58:11 +0000 (GMT) From: Halil Pasic To: "Michael S. Tsirkin" , Cornelia Huck , Halil Pasic , qemu-s390x@nongnu.org, qemu-devel@nongnu.org Subject: [RFC PATCH v2 5/5] virtio-net: handle force_modern for vhost Date: Fri, 12 Nov 2021 15:57:49 +0100 Message-Id: <20211112145749.618157-6-pasic@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211112145749.618157-1-pasic@linux.ibm.com> References: <20211112145749.618157-1-pasic@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: uvetPgwJ94QG_H275d_vjrcMM5vA20A3 X-Proofpoint-ORIG-GUID: JeJfQqpRqHmCFB-n8r00WM618Tfopzna X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-12_05,2021-11-12_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111120083 Received-SPF: pass client-ip=148.163.158.5; envelope-from=pasic@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Thomas Huth , Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Halil Pasic --- Inspired by virtio_net_set_features() which I don't quite understand. Why do we have to do vhost_net_ack_features() for each possible queue? --- hw/net/virtio-net.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f205331dcf..43ed9ef3ba 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -766,6 +766,25 @@ static uint64_t virtio_net_bad_features(VirtIODevice *vdev) return features; } +static void virtio_net_force_modern(VirtIODevice *vdev) +{ + VirtIONet *n = VIRTIO_NET(vdev); + int i; + + /* + * Why do we have to loop over all queues? Are not features a + * per-device thing? + */ + for (i = 0; i < n->max_queues; i++) { + NetClientState *nc = qemu_get_subqueue(n->nic, i); + + if (!get_vhost_net(nc->peer)) { + continue; + } + vhost_dev_force_modern(&get_vhost_net(nc->peer)->dev); + } +} + static void virtio_net_apply_guest_offloads(VirtIONet *n) { qemu_set_offload(qemu_get_queue(n->nic)->peer, @@ -3668,6 +3687,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) vdc->get_features = virtio_net_get_features; vdc->set_features = virtio_net_set_features; vdc->bad_features = virtio_net_bad_features; + vdc->force_modern = virtio_net_force_modern; vdc->reset = virtio_net_reset; vdc->set_status = virtio_net_set_status; vdc->guest_notifier_mask = virtio_net_guest_notifier_mask;