From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87C00C2BA80 for ; Mon, 6 Apr 2020 21:35:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5473F2076E for ; Mon, 6 Apr 2020 21:35:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DziiEOZF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726365AbgDFVfP (ORCPT ); Mon, 6 Apr 2020 17:35:15 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:22194 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726733AbgDFVfL (ORCPT ); Mon, 6 Apr 2020 17:35:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586208909; 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=DziiEOZFNKc8SLY9UK7BT/xTOHBzJ4cWKJaNeUKhXz42+tSmUPIuura6XQaLaaV5UTV60F pH2S50OZHhxWBSv6x8mEya2vdAg8W+Xk3KlbDMudUzQh4lhwTpm9qvPq+/FIz4hg/p8zPH qzawhnPFwTDTrQvWH6YDGBfS8UUsA4E= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-qPE9QKwCOZef1xGuqmaGlQ-1; Mon, 06 Apr 2020 17:35:06 -0400 X-MC-Unique: qPE9QKwCOZef1xGuqmaGlQ-1 Received: by mail-wm1-f71.google.com with SMTP id u6so412260wmm.6 for ; Mon, 06 Apr 2020 14:35:05 -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=KLFgoxybZPA2oy3TM3ZkXhM+b/ljb+GqOnWYmH5VAw5IrY1U5tBg30+nILJWfxh+ey LGWQU2mQ4Qj5iAAcsZlFDj11RlYrpD42yU07zOL2KS1WUh/5RqVB4adlHj2jEpLBaAcS K0v9UxDl9PLT8uzUpo9LE/+fqRRPyalMA3abeeV4/LzOKl+ixjdhv4oa/H9oUA7nEMaI B2fSjbzooRI2kj+Uy6hOhzWx7kDNs2Av/nJWfmDGn5R1we0pww9UO8TX8d/jWyvAZUeN AzRY91JkiswlhfMiF+ydLAO/CAmU5VgrIdloLnqarakM8p6wHyj3mSZLB1svhKObZRv8 ngZQ== X-Gm-Message-State: AGi0PuYvMgDROtZdMZlfbKYdrhmMRjJianlq2dZHmANEEkfwIKCi3RPF hM15c1tvjwMFQT1U4AW+kt4zMeM4/h6UyD+4Xw+uEcxGDesNw2aZNtfnwYEYzs5Mwsuf08lBwVF ZqnGJC4AQTKiJ5XWY2/B6cdVJ X-Received: by 2002:a1c:a344:: with SMTP id m65mr1085021wme.20.1586208904590; Mon, 06 Apr 2020 14:35:04 -0700 (PDT) X-Google-Smtp-Source: APiQypKQS8eELGxP1CiHyVt8zaFr65G004GNObWifgUCCYuDSdGnBqNiBsJWh3gS5NLmtJObwlGW/A== X-Received: by 2002:a1c:a344:: with SMTP id m65mr1084996wme.20.1586208904336; Mon, 06 Apr 2020 14:35:04 -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 h2sm1041241wmb.16.2020.04.06.14.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 14:35:03 -0700 (PDT) Date: Mon, 6 Apr 2020 17:35:02 -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 v5 05/12] virtio: stop using legacy struct vring in kernel Message-ID: <20200406213314.248038-6-mst@redhat.com> References: <20200406213314.248038-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200406213314.248038-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