Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp361952pxa; Tue, 4 Aug 2020 07:25:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/QWEEsmNXNM0NUhNFu3Ozl5QE4xTemk6iH+AtskQrnQwEBFZABtj53Ikj72UI7ZHATBAo X-Received: by 2002:a17:906:2e51:: with SMTP id r17mr21369498eji.308.1596551105849; Tue, 04 Aug 2020 07:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596551105; cv=none; d=google.com; s=arc-20160816; b=jpFN6KDUq6z/0Mrbit5d9cfJHRwmLx4xt4J5rS0WftxwN++e5tRy0F7nQfBKeyKV3G XE9mAI1Xw0vU0X6Zj2txDr0/A742rFilVY2hfnBZRby/N9ALKZu6MlfyHhRsp/w7FayL N171IVlTLvcUsfpIfuKdQQcoreskEnZbykcYaAoHUVWhcymsemVoARLnBsdFF7V2ctEE YH4XioK/0gc4GiTLLr0HmkPy/ThUoreE4wg/w9TbQDIx68WPBnOHUh/nFo2RIE/oyKWb aQw1uKytTX1g3cogISeYUEI3Rv4Z8MUHddlFB24vpiaAX+ITEIoncYCuLIQjU8lscsYQ YWpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=iy5rOiKvzn/ihf1AsNDgRAp385wBg2mwZBntnUSOdjY=; b=AtsS1p5rltJBwaL9e7GSW+RF63DyPXEutWwvBswfMHUW2avAmfbboOwZDPOFbNg2Ap WIo9rEZRYeSF8BTspweXNd9PL/WeLnPho3jWiRTBgOVA8hjQCOWI6HffH/hCBJ+V+hKg tKJCS9DBgGe5VcJtVX8szkzuxVpt3WSZYi/GyouCyaqg/wj2DzMu4To8Ml+s306Jxs/h Xb4Qbs2iN/ZmlNEHIeHsf7X/pyAPhqC6tUy1PA2sBRQeiroPGAdA57Hn1UIPlFYl1UtE smMct1hsHVjQkviHW2gJFUSWomS3VV+wCfA+2hK0vLZOu60fAA9Eqc5Lgx35XKUlZev1 Bnig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hT9HPjSF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id r7si9209615ejo.640.2020.08.04.07.24.43; Tue, 04 Aug 2020 07:25:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hT9HPjSF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728910AbgHDOYA (ORCPT + 99 others); Tue, 4 Aug 2020 10:24:00 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:53136 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728880AbgHDOXu (ORCPT ); Tue, 4 Aug 2020 10:23:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596551029; 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=iy5rOiKvzn/ihf1AsNDgRAp385wBg2mwZBntnUSOdjY=; b=hT9HPjSFt8YBB/MEENy1OTOaGfNleaf5V1zHXy3LdXT/alj70aF9CyQGLSD8iBaDTgXaej EcB5SazeQ1HSrXDXJbtbVCKuJ6E9DcBIyLKI2ab7nV97yrAwEiIholWrYLjPj4tVs74mm0 lYxvNL6C565snCCDQ4oQNPATIQ2YLQ0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-361-jw4ds942OKiTFM2bmKBI3A-1; Tue, 04 Aug 2020 10:23:47 -0400 X-MC-Unique: jw4ds942OKiTFM2bmKBI3A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 228AE800461; Tue, 4 Aug 2020 14:23:46 +0000 (UTC) Received: from gondolin (ovpn-112-169.ams2.redhat.com [10.36.112.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E13B7B90F; Tue, 4 Aug 2020 14:23:42 +0000 (UTC) Date: Tue, 4 Aug 2020 16:23:40 +0200 From: Cornelia Huck To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v2 03/24] virtio: allow __virtioXX, __leXX in config space Message-ID: <20200804162340.046b719b.cohuck@redhat.com> In-Reply-To: <20200803205814.540410-4-mst@redhat.com> References: <20200803205814.540410-1-mst@redhat.com> <20200803205814.540410-4-mst@redhat.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 3 Aug 2020 16:58:46 -0400 "Michael S. Tsirkin" wrote: > Currently all config space fields are of the type __uXX. > This confuses people and some drivers (notably vdpa) > access them using CPU endian-ness - which only > works well for legacy or LE platforms. > > Update virtio_cread/virtio_cwrite macros to allow __virtioXX > and __leXX field types. Follow-up patches will convert > config space to use these types. > > Signed-off-by: Michael S. Tsirkin > --- > include/linux/virtio_config.h | 50 +++++++++++++++++++++++++++++++++-- > 1 file changed, 48 insertions(+), 2 deletions(-) (...) > @@ -287,12 +288,57 @@ static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val) > return __cpu_to_virtio64(virtio_is_little_endian(vdev), val); > } > > +/* > + * Only the checker differentiates between __virtioXX and __uXX types. But we > + * try to share as much code as we can with the regular GCC build. > + */ > +#if !defined(CONFIG_CC_IS_GCC) && !defined(__CHECKER__) > + > +/* Not a checker - we can keep things simple */ > +#define __virtio_native_typeof(x) typeof(x) > + > +#else > + > +/* > + * We build this out of a couple of helper macros in a vain attempt to > + * help you keep your lunch down while reading it. > + */ It might help with the lunch, but it still gives a slight queasiness. No ideas for a better version, though. > +#define __virtio_pick_value(x, type, then, otherwise) \ > + __builtin_choose_expr(__same_type(x, type), then, otherwise) > + > +#define __virtio_pick_type(x, type, then, otherwise) \ > + __virtio_pick_value(x, type, (then)0, otherwise) > + > +#define __virtio_pick_endian(x, x16, x32, x64, otherwise) \ > + __virtio_pick_type(x, x16, __u16, \ > + __virtio_pick_type(x, x32, __u32, \ > + __virtio_pick_type(x, x64, __u64, \ > + otherwise))) > + > +#define __virtio_native_typeof(x) typeof( \ > + __virtio_pick_type(x, __u8, __u8, \ > + __virtio_pick_endian(x, __virtio16, __virtio32, __virtio64, \ > + __virtio_pick_endian(x, __le16, __le32, __le64, \ > + __virtio_pick_endian(x, __u16, __u32, __u64, \ > + /* No other type allowed */ \ > + (void)0))))) > + > +#endif > + > +#define __virtio_native_type(structname, member) \ > + __virtio_native_typeof(((structname*)0)->member) > + > +#define __virtio_typecheck(structname, member, val) \ > + /* Must match the member's type, and be integer */ \ > + typecheck(__virtio_native_type(structname, member), (val)) > + > + Acked-by: Cornelia Huck