Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1043269pxa; Wed, 5 Aug 2020 20:38:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+l5tt1GOOqbYVEoWfYAQmTLcd29vzKyJRVQZO83N0XZzmqfIIVgGv/V7TkzZS+2GONBN+ X-Received: by 2002:aa7:c383:: with SMTP id k3mr2172599edq.164.1596685100843; Wed, 05 Aug 2020 20:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596685100; cv=none; d=google.com; s=arc-20160816; b=tkgQCsLieJbumOGMZhmruGLyv7/doAZJCLmguvMRs8McekjhioizM1OVWpRNiqgk/v 53f4xa13l7opFVYElELp6h9U3GVM09TOikYKNGIuqrdl2m9Hd2D7OgJR7guluQToxUNI pEiUCwz0m/9xLqrDjLcRBvo7Yj2e4vdEbB9Wrg2MBPqELVHq433NecJtkL3cESgJqVCS ZjBedCBSMtvQa3jMj9eQTicFEu7ofeKW+GY2OhJIaR+ltzLxEk0ieQLatzhQeWeK4loZ X4bo47bPrlfmafHLEJo04IcESwcGHU4/3RVL0ao8jF4Qc8Wm1EGLohJbaB1qiqlL+/yl 7xpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=y0/VXs+49Tf/58Sjz8LOy4NeNinqvStP7kb/YaGK0P8=; b=EWOkWlwFbfa+mpjPlAz/eF8KRTD6Fx9E5En7URlAo4OVeeLro0TxvrYJCwV1QBw0vT EPLMFt6iJqGDjg5OaKWgMTlhs8ZMkNH/oCdeSKUc0vGde3C4GAp7qs+fqSLUmAVe6U1q NMGGNHI8oAy6zWDDYV9ATQqMVusz99+Ad34nTsMWPU/NilXs/IrMAlEd8EgnHVmmnq7Q Ddw0mnFj8vhyBxI5scQ1AbeV1e//WabneQ3zbey9HrrJHCZisQoSvqa63IrGSZy9dCBL iWhvz54eLLBk0MZwJmhY0z3tW3DpOOFKwMzRn+REnb1HsFNjxia4r56O2av7laOoCxbs CeAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Oh+3rFcX; 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 u27si2454776ejj.716.2020.08.05.20.37.58; Wed, 05 Aug 2020 20:38:20 -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=Oh+3rFcX; 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 S1731822AbgHFDht (ORCPT + 99 others); Wed, 5 Aug 2020 23:37:49 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:35717 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731694AbgHFDhs (ORCPT ); Wed, 5 Aug 2020 23:37:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596685066; 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=y0/VXs+49Tf/58Sjz8LOy4NeNinqvStP7kb/YaGK0P8=; b=Oh+3rFcXKl3/aq6Q7vUJsfKOGpD6nn980qNj/yiK/UprZv6AqzjyPql1lUgQTsXWs+oGjI kYwqYogVdDSRf3W2jGHPRuBMCvKTamkD6Mxl1pFsp16ZslVqlj6pT0B8yAQKqqJB9IBITj AMjC4xk6brWAM/k2hnbz2gRum7/yhu0= 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-414-Jy2ewWUWMiOChdw0cmnpfw-1; Wed, 05 Aug 2020 23:37:45 -0400 X-MC-Unique: Jy2ewWUWMiOChdw0cmnpfw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 517661005510; Thu, 6 Aug 2020 03:37:44 +0000 (UTC) Received: from [10.72.13.140] (ovpn-13-140.pek2.redhat.com [10.72.13.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38BBC65C6D; Thu, 6 Aug 2020 03:37:39 +0000 (UTC) Subject: Re: [PATCH v2 03/24] virtio: allow __virtioXX, __leXX in config space To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org References: <20200803205814.540410-1-mst@redhat.com> <20200803205814.540410-4-mst@redhat.com> <20200805074434-mutt-send-email-mst@kernel.org> From: Jason Wang Message-ID: <4aa65ad6-5324-0a8c-0fa6-0d8e680f0706@redhat.com> Date: Thu, 6 Aug 2020 11:37:38 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200805074434-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/8/5 下午7:45, Michael S. Tsirkin wrote: >>> #define virtio_cread(vdev, structname, member, ptr) \ >>> do { \ >>> might_sleep(); \ >>> /* Must match the member's type, and be integer */ \ >>> - if (!typecheck(typeof((((structname*)0)->member)), *(ptr))) \ >>> + if (!__virtio_typecheck(structname, member, *(ptr))) \ >>> (*ptr) = 1; \ >> A silly question,  compare to using set()/get() directly, what's the value >> of the accessors macro here? >> >> Thanks > get/set don't convert to the native endian, I guess that's why > drivers use cread/cwrite. It is also nice that there's type > safety, checking the correct integer width is used. Yes, but this is simply because a macro is used here, how about just doing things similar like virtio_cread_bytes(): static inline void virtio_cread(struct virtio_device *vdev,                       unsigned int offset,                       void *buf, size_t len) And do the endian conversion inside? Thanks >