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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 044C2C001B0 for ; Wed, 9 Aug 2023 21:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230218AbjHIVEI (ORCPT ); Wed, 9 Aug 2023 17:04:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbjHIVEF (ORCPT ); Wed, 9 Aug 2023 17:04:05 -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 80CE0B3 for ; Wed, 9 Aug 2023 14:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691614999; 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=JpA3RFdMht7iBEs06qI33SwAayiTbeDZD4PgWl3Pj98=; b=LlhWwa8v8mQxSf+PJPSnO54AFFqTQ9k7OHr7n1TOhghLFpjlKH3CPJ0zvxaTy2nbB3f987 yv2hPZ4EKvdLWr7IJqFNGx8X0HSrQUHhLaq+BSRe18pq8V3dQcdz8oSPK10iEiJUn4MWNq fyNPbD/+tzlCpleAam5zNpW/SeveiUg= 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-391-iZaueV4sNduKqMdVnyN6EQ-1; Wed, 09 Aug 2023 17:03:16 -0400 X-MC-Unique: iZaueV4sNduKqMdVnyN6EQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2619A101A59A; Wed, 9 Aug 2023 21:03:16 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E7065CBFF; Wed, 9 Aug 2023 21:02:50 +0000 (UTC) From: Stefan Hajnoczi To: kvm@vger.kernel.org Cc: Jason Gunthorpe , "Tian, Kevin" , linux-kernel@vger.kernel.org, Alex Williamson , Stefan Hajnoczi Subject: [PATCH 0/4] vfio: use __aligned_u64 for ioctl structs Date: Wed, 9 Aug 2023 17:02:44 -0400 Message-ID: <20230809210248.2898981-1-stefanha@redhat.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jason Gunthorpe pointed out that u64 VFIO ioctl struct fields have architecture-dependent alignment. iommufd already uses __aligned_u64 to avoid this problem. Reasons for using __aligned_u64 include avoiding potential information leaks due to architecture-specific holes in structs and 32-bit userspace on 64-bit kernel ioctl compatibility issues. See the __aligned_u64 typedef in for details. 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 (4): 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_iommu_type1_info vfio: use __aligned_u64 in struct vfio_device_ioeventfd include/uapi/linux/vfio.h | 27 +++++++++++++++------------ drivers/gpu/drm/i915/gvt/kvmgt.c | 4 +++- drivers/vfio/vfio_iommu_type1.c | 11 ++--------- samples/vfio-mdev/mbochs.c | 6 ++++-- samples/vfio-mdev/mdpy.c | 4 +++- 5 files changed, 27 insertions(+), 25 deletions(-) -- 2.41.0