Received: by 10.223.176.5 with SMTP id f5csp702831wra; Wed, 7 Feb 2018 06:13:55 -0800 (PST) X-Google-Smtp-Source: AH8x226m5hdoE1NAdra59aIU4oSKnX3lWC8zI0Qw02b/bJ4WC+icivXxeQV30u2YCjEdPRtoDRgH X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr6198756plb.278.1518012835699; Wed, 07 Feb 2018 06:13:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518012835; cv=none; d=google.com; s=arc-20160816; b=eXbJiA3rfpW3YSrLGaaaQL+pRllO6UMFatsUdflZ1NTZtXVETCLzHla7EKFtqQ652K BT05JK49lBDmsDGvonG6gutvhCnDAFseB93SOvMsHfMYkjb/AXPaZqs6qaV0Vrb9C8ZZ ACEOMUk3hrS4Bjshj1q3l+ebR1Rg+bJv90SuSz/SdmQFOerTrtz8ljEVWvx2FDwVmzrV uJyVWJAddfliTWOqsSwdvrlLDlzut7M23LzyKrg1QS6XThW3MfsTyqiUSbrZLr1eE2YH BQWPEpvLL15nw+TP2+H3LUNqWEc8nYkYmHLXGdviWS8L0RLyRv5hV8E132fHL4nDksHG SCfg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=2juphzCQNBAT+BeI7BljtSbREj/Mp/C/4HDebhpKkDM=; b=Ihlh/qRSZs2sSq0fyDbEuzE6Jlc0C1oIBNqFl/UZy+BtGC/jb+E6jsjIJTH4P5R/rM 4/p/NhI35ethy9bE/Hu3f/8idsCqYNg6c6nnmV1A+tVoFVfoO2EysekGAAIZ87Sll/3y pEPQIMHJ9VXK4pwucjMqU4sY+HO0yeiuWHTqo194HLE29QJiDiadDUVX9E+5SuzLDKjE iqS78k2gwfXg5XL8otLe35TJe5OJc65aO6CWLxynqWAnduljk23xlkD5723Wr0//1o7b sIemQizK+KA6x5v6J18Iv5f7/hNgS9qkqJR1nRJki0m/wp/mHZpsFPvwtXeAxQ/Y0GKo UaRg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 t15si978028pgf.370.2018.02.07.06.13.39; Wed, 07 Feb 2018 06:13:55 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754065AbeBGOMz (ORCPT + 99 others); Wed, 7 Feb 2018 09:12:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36552 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753763AbeBGOMy (ORCPT ); Wed, 7 Feb 2018 09:12:54 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A2202821F; Wed, 7 Feb 2018 14:12:54 +0000 (UTC) Received: from w520.home (ovpn-117-203.phx2.redhat.com [10.3.117.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1E75600CC; Wed, 7 Feb 2018 14:12:53 +0000 (UTC) Date: Wed, 7 Feb 2018 07:12:53 -0700 From: Alex Williamson To: Alexey Kardashevskiy Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org Subject: Re: [RFC PATCH] vfio/pci: Add ioeventfd support Message-ID: <20180207071253.7c606594@w520.home> In-Reply-To: <6014d60c-9bdb-4dc0-7cd7-9299005d9c5a@ozlabs.ru> References: <20180207000731.32764.95992.stgit@gimli.home> <20180206212538.50ef0e13@w520.home> <6014d60c-9bdb-4dc0-7cd7-9299005d9c5a@ozlabs.ru> 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 07 Feb 2018 14:12:54 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 7 Feb 2018 15:48:26 +1100 Alexey Kardashevskiy wrote: > On 07/02/18 15:25, Alex Williamson wrote: > > On Wed, 7 Feb 2018 15:09:22 +1100 > > Alexey Kardashevskiy wrote: > >> On 07/02/18 11:08, Alex Williamson wrote: > >>> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h > >>> index e3301dbd27d4..07966a5f0832 100644 > >>> --- a/include/uapi/linux/vfio.h > >>> +++ b/include/uapi/linux/vfio.h > >>> @@ -503,6 +503,30 @@ struct vfio_pci_hot_reset { > >>> > >>> #define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) > >>> > >>> +/** > >>> + * VFIO_DEVICE_IOEVENTFD - _IOW(VFIO_TYPE, VFIO_BASE + 14, > >>> + * struct vfio_device_ioeventfd) > >>> + * > >>> + * Perform a write to the device at the specified device fd offset, with > >>> + * the specified data and width when the provided eventfd is triggered. > >>> + * > >>> + * Return: 0 on success, -errno on failure. > >>> + */ > >>> +struct vfio_device_ioeventfd { > >>> + __u32 argsz; > >>> + __u32 flags; > >>> +#define VFIO_DEVICE_IOEVENTFD_8 (1 << 0) /* 1-byte write */ > >>> +#define VFIO_DEVICE_IOEVENTFD_16 (1 << 1) /* 2-byte write */ > >>> +#define VFIO_DEVICE_IOEVENTFD_32 (1 << 2) /* 4-byte write */ > >>> +#define VFIO_DEVICE_IOEVENTFD_64 (1 << 3) /* 8-byte write */ > >>> +#define VFIO_DEVICE_IOEVENTFD_SIZE_MASK (0xf) > >>> + __u64 offset; /* device fd offset of write */ > >>> + __u64 data; /* data to be written */ > >>> + __s32 fd; /* -1 for de-assignment */ > >>> +}; > >>> + > >>> +#define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 14) > >> > >> > >> Is this a first ioctl with endianness fixed to little-endian? I'd suggest > >> to comment on that as things like vfio_info_cap_header do use the host > >> endianness. > > > > Look at our current read and write interface, we call leXX_to_cpu > > before calling iowriteXX there and I think a user would logically > > expect to use the same data format here as they would there. > > If the data is "char data[8]" (i.e. bytestream), then it can be expected to > be device/bus endian (i.e. PCI == little endian), but if it is u64 - then I > am not so sure really, and this made me look around. It could be "__le64 > data" too. > > > Also note > > that iowriteXX does a cpu_to_leXX, so are we really defining the > > interface as little-endian or are we just trying to make ourselves > > endian neutral and counter that implicit conversion? Thanks, > > Defining it LE is fine, I just find it a bit confusing when > vfio_info_cap_header is host endian but vfio_device_ioeventfd is not. But I don't think we are defining the interface as little-endian. iowriteXX does a cpu_to_leXX byteswap. Therefore in order to maintain endian neutrality, if the data does a cpu->le swap on the way out, I need to do a le->cpu swap on the way in, right? Please defend the assertion that we're creating a little-endian interface. Thanks, Alex