Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3765226ybb; Mon, 6 Apr 2020 15:27:36 -0700 (PDT) X-Google-Smtp-Source: APiQypICzxkI/rVW5aJGG7FIU2ctBB8fqx93+iETCfaqU6bf5PNy03KnHFKjmLmByjFL9HlGM7pV X-Received: by 2002:a9d:567:: with SMTP id 94mr17726351otw.201.1586212056525; Mon, 06 Apr 2020 15:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586212056; cv=none; d=google.com; s=arc-20160816; b=JudHn+UTnNOZbRCNzooj9rFGSYl3pOYa5iAsKkJwSSm1HjyTVia2QnuaTZK/MX2Iaj /FAYyMEEHxPqTgzj+eAdwbDADYk/DMZ6Tbcm+o8pz3Zstb25g2PBFP82g/HLnvk46nmj MQh/9/HfcQRdkjjlMqIPMBKcSxCmKspK6+XL/A/rOcU/HvuzVAi5LKYhirhL70R+M++U n6b/2qDZDWEEp0RtJwOoNok2SNnek5N0mef8PWZ9pueZ3FeVMbXRgI/A/DkhWG0jzRY1 7EuzFjGM4JC+Fo4p/qxQJMp++7qucOVRcdJCHrEIo9a6bWaN+b1qA4fXYqOtI+IaUDuu OkVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=s9Mom4OhtTxtDHxzUnnXxvRU3zaONixqwgs5hBxczCA=; b=SfwsUujYBXR2W9LAlleeEznhHRzJdT5qkGsnqXJC7mHIdwUjF/yUw9Dx4O+P75C3rn ++YAKQf/q/IWR8YxnI/EUPUGH9wBRbIjIiKOksYrICWvDLT6syaDqpPPNsxyqF/pi8xs yDuy8fQlZwDqjrXohAsdfGCrMvhGqwrtN9P/6e2LoYc6dM8NpCFWLD4jVDpLV62f6K2H dg5fYkN3OlY1gcJYgIf0mCMIz+ULw0V7tm4zr9djlflo65taE+6S25IHQea8ORg+ewh1 Q1GFpiC5y2TutRT3yQ4z6DVpxQpfo5AQPLikqFYut5lIqx/Yrn7X2GhdHLsOgwe5j5af 6/9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZLhRDPi6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h27si416898ots.293.2020.04.06.15.27.24; Mon, 06 Apr 2020 15:27:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZLhRDPi6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726467AbgDFW0p (ORCPT + 99 others); Mon, 6 Apr 2020 18:26:45 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22245 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726130AbgDFW0o (ORCPT ); Mon, 6 Apr 2020 18:26:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586212003; 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: in-reply-to:in-reply-to:references:references; bh=s9Mom4OhtTxtDHxzUnnXxvRU3zaONixqwgs5hBxczCA=; b=ZLhRDPi6DCuspOdTX5mc3IhUvq4GWT9Bhqr2+bFFroBzDPuh8EPB2Fybpm8QdaXKUcSRxj 2VWRYSZtgfDJiBCvdUrglRh+vkwtvIbpjT52lldUh1lY5yAMupjfkcU6YcKlcm7JlRltrV 57rmfiZgpRIXHlJzGJPM+iCFfQ6C5lc= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-501-5Lk_jMK1NIesD_Ui2DQlQQ-1; Mon, 06 Apr 2020 18:26:41 -0400 X-MC-Unique: 5Lk_jMK1NIesD_Ui2DQlQQ-1 Received: by mail-wr1-f69.google.com with SMTP id u16so644718wrp.14 for ; Mon, 06 Apr 2020 15:26:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=s9Mom4OhtTxtDHxzUnnXxvRU3zaONixqwgs5hBxczCA=; b=K+HXiICsl6iRgwAgfTmEfQA8/fTOmfp8usw3LTH4I5EJwxoFO2NCvj8GN4QDpHU7e0 pjLQVEn2WkFA85Gbs8npq2AdWyaL9uUKI12zdtOrqPXP3Fn4Bv4U1fqS/2wTpDNly/On vtJZ06XHIHbK0GaUInucBgb+uCRT5mSP9/irxSfsYsCgni0vCXPxZQEnAspCG9R28MU3 ba4qyWbTWVz9YT8gvcH7Pa2ihj4ZLJlDx7Oewzq7n/mNPy3zLzyvdxurKe2RlNFwckJ0 ylg4TDUuY/IM6Frxz9Cm8iq+z8p8jkGllp1OJa6RKF2ht8fJt/G0gLfeLNRyaudD1CWZ E2WQ== X-Gm-Message-State: AGi0Pub4RAazSzjZI5Gaav0zaT2s5bz3WCq/AV7/Zy012Dmw7ih3h+WK zvT4pyxpnXc4DnU3j/Ga5kQITkfw+nbS/c9a4RsUU8Q870NmbgBhoObFvzDyqRiMYc93C1ldyBN V179ForEK+H7LE45X7vWJ5ms/ X-Received: by 2002:a5d:408d:: with SMTP id o13mr1409537wrp.44.1586212000372; Mon, 06 Apr 2020 15:26:40 -0700 (PDT) X-Received: by 2002:a5d:408d:: with SMTP id o13mr1409523wrp.44.1586212000086; Mon, 06 Apr 2020 15:26:40 -0700 (PDT) Received: from redhat.com (bzq-79-176-51-222.red.bezeqint.net. [79.176.51.222]) by smtp.gmail.com with ESMTPSA id u17sm31760120wra.63.2020.04.06.15.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 15:26:39 -0700 (PDT) Date: Mon, 6 Apr 2020 18:26:38 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Jason Wang , Paolo Bonzini , Stefan Hajnoczi , Jens Axboe , virtualization@lists.linux-foundation.org, linux-block@vger.kernel.org Subject: [PATCH v6 05/12] virtio: stop using legacy struct vring in kernel Message-ID: <20200406222507.281867-6-mst@redhat.com> References: <20200406222507.281867-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200406222507.281867-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org struct vring (in the uapi directory) and supporting APIs are kept around to solely avoid breaking old userspace builds. It's not actually part of the UAPI - it was kept in the UAPI header by mistake, and using it in kernel isn't necessary and prevents us from making changes safely. In particular, the APIs actually assume the legacy layout. Add an internal kernel-only struct vring and switch everyone to use that. Signed-off-by: Michael S. Tsirkin --- drivers/block/virtio_blk.c | 1 + include/linux/virtio.h | 1 - include/linux/virtio_ring.h | 10 ++++++++++ include/linux/vringh.h | 1 + include/uapi/linux/virtio_ring.h | 26 ++++++++++++++++---------- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 0736248999b0..dd5732dc4b07 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -15,6 +15,7 @@ #include #include #include +#include #define PART_BITS 4 #define VQ_NAME_LEN 16 diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 15f906e4a748..a493eac08393 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -9,7 +9,6 @@ #include #include #include -#include /** * virtqueue - a queue to register buffers for sending or receiving. diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index 3dc70adfe5f5..11680e74761a 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h @@ -60,6 +60,16 @@ static inline void virtio_store_mb(bool weak_barriers, struct virtio_device; struct virtqueue; +struct vring { + unsigned int num; + + struct vring_desc *desc; + + struct vring_avail *avail; + + struct vring_used *used; +}; + /* * Creates a virtqueue and allocates the descriptor ring. If * may_reduce_num is set, then this may allocate a smaller ring than diff --git a/include/linux/vringh.h b/include/linux/vringh.h index 9e2763d7c159..d71b3710f58e 100644 --- a/include/linux/vringh.h +++ b/include/linux/vringh.h @@ -11,6 +11,7 @@ #ifndef _LINUX_VRINGH_H #define _LINUX_VRINGH_H #include +#include #include #include #include diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h index 9223c3a5c46a..8961a4adda5c 100644 --- a/include/uapi/linux/virtio_ring.h +++ b/include/uapi/linux/virtio_ring.h @@ -118,16 +118,6 @@ struct vring_used { struct vring_used_elem ring[]; }; -struct vring { - unsigned int num; - - struct vring_desc *desc; - - struct vring_avail *avail; - - struct vring_used *used; -}; - /* Alignment requirements for vring elements. * When using pre-virtio 1.0 layout, these fall out naturally. */ @@ -166,6 +156,21 @@ struct vring { #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) #define vring_avail_event(vr) (*(__virtio16 *)&(vr)->used->ring[(vr)->num]) +#ifndef __KERNEL__ +/* + * The following definitions have been put in the UAPI header by mistake. We + * keep them around to avoid breaking old userspace builds. + */ +struct vring { + unsigned int num; + + struct vring_desc *desc; + + struct vring_avail *avail; + + struct vring_used *used; +}; + static inline void vring_init(struct vring *vr, unsigned int num, void *p, unsigned long align) { @@ -182,6 +187,7 @@ static inline unsigned vring_size(unsigned int num, unsigned long align) + align - 1) & ~(align - 1)) + sizeof(__virtio16) * 3 + sizeof(struct vring_used_elem) * num; } +#endif #endif /* VIRTIO_RING_NO_LEGACY */ -- MST