From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19B48196438 for ; Wed, 10 Jul 2024 18:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720636835; cv=none; b=cJFgh7sk7m/JQuNSgA+I4zRaEhpqB/TXGoicMIUKVWP7CscNiTjysUmOm8uQKWFwTEuaCvXjpQdaxplZuoN178vIQtnKzM4Yk464Rol8EC0qKYzPYu3wuEEM3sh8XDgIrb890GKiVihqHd6e5rW3Wm5bQ3e4NsScTElZMW7JTc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720636835; c=relaxed/simple; bh=cpmhhhVhRKvhrC/g+4t7qnyh17qX5WLx6FJHCFwK3Ho=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Qmcdk0g/Wtarlk79BFA6WJNxyFsi5khIprpmUuDBcqXBj+fxkKLbHXO612ySFKQ5YfDJDYa/hbmY1O2TwDjvIVfmq5opRcOye7yaiFWclEaYbt6jf1p8bnqXB8J8cMexLyOpktJSLQyDKuhaRfItLvchqZEWaC0rARu3fBpXF1Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=S1dqXGcF; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="S1dqXGcF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720636833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nOMGW3S5XfF0umS0MhtMBuBfpR4wOzwlUDWp6i5Agkc=; b=S1dqXGcFrNUAc3Loe3JEl4k1Y7vyhY+UPN5ie4FoitohonKgL6YXgnFKwzp6Os94xzzylb HP4+CpXT9uB5jd7RJLTfjsTKmbI7SU6Xjtqi74OhxO3Xb2cmaweJTCF67GrT7QFKmraVNO W2dtrjlb3uqKNFabQsPRJ0o6vBvppM0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-CsWcrT0aM4K_fyT5FC5iFg-1; Wed, 10 Jul 2024 14:40:31 -0400 X-MC-Unique: CsWcrT0aM4K_fyT5FC5iFg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42674318a4eso657175e9.1 for ; Wed, 10 Jul 2024 11:40:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720636830; x=1721241630; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nOMGW3S5XfF0umS0MhtMBuBfpR4wOzwlUDWp6i5Agkc=; b=ZCnBAhV7BPKKVTTSaniAr5QlYTZLc43iwKfNsrjgE5f0ZrXGOQcE5a3X7QFyyB80hM nxx+h0XhcoProLrCqYujj3/eZWi+5wJZPuPXheLXfWAYRUEp0mdBkTAjM7yRUrgk2BcP qwQYhE3fdnasAOiJljRd+OKCd94mrqgPcGuagkLJqHl13wKYjcsgu6qEz4jnhKYyrPFh aS2RJQh5z53ZFcxBCkYNzNKdKTnt+9VSjoALP1EtiqoGr+jBEOXBuqqAfh7tLwsc18Xq CnZU4hO0qqhSfbYQ8eIHqt1WrUtoVfrHpLr1BXO0d5lIroErvsH2exB1lYanjog0YSRP aSDA== X-Forwarded-Encrypted: i=1; AJvYcCUS5aj31qFGljciMZDstOWBeXdgqck7XwZEHdYxjqAqQ67Cua9x3iGW2CgXoWy7TBzqJcxrFJJ3EzAEUSGeKPIXQY5THbwpyH2xRQ== X-Gm-Message-State: AOJu0YyBqVFO9YrxZd1qMVbZIsvKZPk/Os7jwJcE90ytuqUXZy7LGeU2 vrxwqHKsUbnbuQNrGl6LiD/ZAaLV9gpbW0bM3ipBHuTGZlq3h5RaY4vQN0k0onYU32YgzCu3xps +25qJRDrohgeFz3Wgzih8FsHFWRFG26ZwrNN2RnGbwN32zT29ig6HOdqx3h4= X-Received: by 2002:a1c:4b0e:0:b0:426:5b76:13bd with SMTP id 5b1f17b1804b1-426708f2127mr51924345e9.38.1720636830434; Wed, 10 Jul 2024 11:40:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHW6BXHt7TvysChZRc5l+/HKuwpL6Ky9xwFKNWqpa0ClAMfEvn97X0Cu0s4c3ufKnu0Y+84KA== X-Received: by 2002:a1c:4b0e:0:b0:426:5b76:13bd with SMTP id 5b1f17b1804b1-426708f2127mr51924105e9.38.1720636829731; Wed, 10 Jul 2024 11:40:29 -0700 (PDT) Received: from redhat.com ([2a02:14f:174:f6ae:a6e3:8cbc:2cbd:b8ff]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cde7e039sm5973934f8f.2.2024.07.10.11.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 11:40:29 -0700 (PDT) Date: Wed, 10 Jul 2024 14:40:24 -0400 From: "Michael S. Tsirkin" To: Daniel Verkamp Cc: linux-kernel@vger.kernel.org, Alexander Duyck , Xuan Zhuo , Andrew Morton , David Hildenbrand , Richard Weinberger , Anton Ivanov , Johannes Berg , Bjorn Andersson , Mathieu Poirier , Cornelia Huck , Halil Pasic , Eric Farman , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Jason Wang , Eugenio =?iso-8859-1?Q?P=E9rez?= , linux-um@lists.infradead.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org Subject: Re: [PATCH v2 2/2] virtio: fix vq # for balloon Message-ID: <20240710144012-mutt-send-email-mst@kernel.org> References: <3d655be73ce220f176b2c163839d83699f8faf43.1720611677.git.mst@redhat.com> Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Jul 10, 2024 at 11:12:34AM -0700, Daniel Verkamp wrote: > On Wed, Jul 10, 2024 at 4:43 AM Michael S. Tsirkin wrote: > > > > virtio balloon communicates to the core that in some > > configurations vq #s are non-contiguous by setting name > > pointer to NULL. > > > > Unfortunately, core then turned around and just made them > > contiguous again. Result is that driver is out of spec. > > Thanks for fixing this - I think the overall approach of the patch looks good. > > > Implement what the API was supposed to do > > in the 1st place. Compatibility with buggy hypervisors > > is handled inside virtio-balloon, which is the only driver > > making use of this facility, so far. > > In addition to virtio-balloon, I believe the same problem also affects > the virtio-fs device, since queue 1 is only supposed to be present if > VIRTIO_FS_F_NOTIFICATION is negotiated, and the request queues are > meant to be queue indexes 2 and up. From a look at the Linux driver > (virtio_fs.c), it appears like it never acks VIRTIO_FS_F_NOTIFICATION > and assumes that request queues start at index 1 rather than 2, which > looks out of spec to me, but the current device implementations (that > I am aware of, anyway) are also broken in the same way, so it ends up > working today. Queue numbering in a spec-compliant device and the > current Linux driver would mismatch; what the driver considers to be > the first request queue (index 1) would be ignored by the device since > queue index 1 has no function if F_NOTIFICATION isn't negotiated. > > [...] > > diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c > > index 7d82facafd75..fa606e7321ad 100644 > > --- a/drivers/virtio/virtio_pci_common.c > > +++ b/drivers/virtio/virtio_pci_common.c > > @@ -293,7 +293,7 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs, > > struct virtio_pci_device *vp_dev = to_vp_device(vdev); > > struct virtqueue_info *vqi; > > u16 msix_vec; > > - int i, err, nvectors, allocated_vectors, queue_idx = 0; > > + int i, err, nvectors, allocated_vectors; > > > > vp_dev->vqs = kcalloc(nvqs, sizeof(*vp_dev->vqs), GFP_KERNEL); > > if (!vp_dev->vqs) > > @@ -332,7 +332,7 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs, > > msix_vec = allocated_vectors++; > > else > > msix_vec = VP_MSIX_VQ_VECTOR; > > - vqs[i] = vp_setup_vq(vdev, queue_idx++, vqi->callback, > > + vqs[i] = vp_setup_vq(vdev, i, vqi->callback, > > vqi->name, vqi->ctx, msix_vec); > > if (IS_ERR(vqs[i])) { > > err = PTR_ERR(vqs[i]); > > @@ -368,7 +368,7 @@ static int vp_find_vqs_intx(struct virtio_device *vdev, unsigned int nvqs, > > struct virtqueue_info vqs_info[]) > > { > > struct virtio_pci_device *vp_dev = to_vp_device(vdev); > > - int i, err, queue_idx = 0; > > + int i, err; > > > > vp_dev->vqs = kcalloc(nvqs, sizeof(*vp_dev->vqs), GFP_KERNEL); > > if (!vp_dev->vqs) > > @@ -388,8 +388,13 @@ static int vp_find_vqs_intx(struct virtio_device *vdev, unsigned int nvqs, > > vqs[i] = NULL; > > continue; > > } > > +<<<<<<< HEAD > > vqs[i] = vp_setup_vq(vdev, queue_idx++, vqi->callback, > > vqi->name, vqi->ctx, > > +======= > > + vqs[i] = vp_setup_vq(vdev, i, callbacks[i], names[i], > > + ctx ? ctx[i] : false, > > +>>>>>>> f814759f80b7... virtio: fix vq # for balloon > > This still has merge markers in it. > > Thanks, > -- Daniel ouch forgot to commit ;)