Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp370405rdb; Mon, 18 Sep 2023 19:12:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHo0zFuE0JdxV8XjsuJryXI7g9ZSIzvuXrBtDTAFyF1ug9u2YyNfIaJddNZqwwIFOzPz8OG X-Received: by 2002:a05:6a21:7983:b0:13d:1d14:6693 with SMTP id bh3-20020a056a21798300b0013d1d146693mr8238859pzc.45.1695089559549; Mon, 18 Sep 2023 19:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695089559; cv=none; d=google.com; s=arc-20160816; b=wyFMSqEtw0HS1/gKBCP6UweYP1YCvZBtjpkOcBGSDq//m5XuuDFLzB9lnAmbWQDkBw bGejdrF1hB/8b6yyluRhc3PFiKwm20P4UClRpWugiEvY8dWMQ7jG4vbMY7U58/dW3B1P XB5+XtrLO8q3L+miZUhjfVa/dZVHKDSeevs2reLBYbm9DMdsc/uKtHOToLAVaRex+B/1 I9IeCarMh1qUQQnmzkjly9ogN/fj1il5XgEfudpqs48zCWrnR3vixQgItXh1zrykXecl VCyMJa2G3m7HAvX3FGRp9OOsjzDEqpjNFREmfiwcJ3GXlw40AHl6Ty1NIizXV321AgeW uvYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Xi9oKb7wFPrQQdMnj2W18GElU0mEnwlSVsbSjcB2VJk=; fh=96HO1jz3bXAXthw3m3qvE5TGYQUSL46uSNZrHCuZ2IM=; b=k8M05V7vrCnnvuMvU4X7cNDUOHzcp1M6/+fxbXjT4Z7RCVZcyuVfUXMKuWG67T8Ipo 5W/i3Na/vqDGtJwRkPzpmowe1Zq+0dO3pSpXhtKzCqZQSruVnsfsOAQI7NzixBF+lBe6 sICmD7yBbk3fpUzbnjYPKkx/+YTdiMMgXH3cgEFoUV3DlvqhB3+Cn+Hkg6V0H7aPbGc0 lUbf81UhC26/+OlJ6JVph++HT4dNS+b1a3D4lN+wZG9Svn227kfIIGty2a11kfjXSOMt vVqPtwaJ+lCL6wMsRz++k3pvE5ylzlKiKEkj+ooi4ve3OSGdRiLsgTW378SFRxaVYxAL bXlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V4M9JoRg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id w20-20020a63fb54000000b00577ac67a31dsi8589806pgj.757.2023.09.18.19.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 19:12:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V4M9JoRg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CDDD780A3675; Mon, 18 Sep 2023 13:57:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbjIRU5L (ORCPT + 99 others); Mon, 18 Sep 2023 16:57:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbjIRU5K (ORCPT ); Mon, 18 Sep 2023 16:57:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0B2B8E for ; Mon, 18 Sep 2023 13:56:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695070583; 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; bh=Xi9oKb7wFPrQQdMnj2W18GElU0mEnwlSVsbSjcB2VJk=; b=V4M9JoRg4DD8gVnC5/6Hy0wbQij7WpmJCp17c4XuaJYT8Qr0VazqfnedmHnsJRbBGzltqY oCFMHVnZItEfTZGdkN/KZivM3hDfC/q/BbY+QzHbtkyfMTxoLI31ePtrJX/CMOH+exZxl+ IxInhhKBFvZDBaytFVd1sW6J2sszpmA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-cBnr55QAP7yX35TbiBvzXA-1; Mon, 18 Sep 2023 16:56:20 -0400 X-MC-Unique: cBnr55QAP7yX35TbiBvzXA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BDDE585A5A8; Mon, 18 Sep 2023 20:56:19 +0000 (UTC) Received: from localhost (unknown [10.39.195.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39B7540C6EA8; Mon, 18 Sep 2023 20:56:18 +0000 (UTC) From: Stefan Hajnoczi To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jason Gunthorpe , Alex Williamson , David Laight , "Tian, Kevin" , Stefan Hajnoczi Subject: [PATCH v3 0/3] vfio: use __aligned_u64 for ioctl structs Date: Mon, 18 Sep 2023 16:56:14 -0400 Message-ID: <20230918205617.1478722-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 13:57:13 -0700 (PDT) v3: - Remove the output struct sizing code that copied out zeroed fields at the end of the struct. Alex pointed out that new fields (or repurposing a field that was previously reserved) must be guarded by a flag and this means userspace won't access those fields when they are absent. v2: - Rebased onto https://github.com/awilliam/linux-vfio.git next to get the vfio_iommu_type1_info pad field [Kevin] - Fixed min(minsz, sizeof(dmabuf)) -> min(dmabuf.argsz, sizeof(dmabuf)) [Jason, Kevin] - Squashed Patch 3 (vfio_iommu_type1_info) into Patch 1 since it is trivial now that the padding field is already there. Jason Gunthorpe pointed out that u64 VFIO ioctl struct fields have architecture-dependent alignment. iommufd already uses __aligned_u64 to avoid this problem. See the __aligned_u64 typedef in for details on why it is a good idea for kernel<->user interfaces. This series modifies the VFIO ioctl structs to use __aligned_u64. Some of the changes preserve the existing memory layout on all architectures, so I put them together into the first patch. The remaining patches are for structs where explanation is necessary about why changing the memory layout does not break the uapi. Stefan Hajnoczi (3): vfio: trivially use __aligned_u64 for ioctl structs vfio: use __aligned_u64 in struct vfio_device_gfx_plane_info vfio: use __aligned_u64 in struct vfio_device_ioeventfd include/uapi/linux/vfio.h | 26 ++++++++++++++------------ drivers/gpu/drm/i915/gvt/kvmgt.c | 2 +- samples/vfio-mdev/mbochs.c | 2 +- samples/vfio-mdev/mdpy.c | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) -- 2.41.0