From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B59B19CCF5 for ; Fri, 9 Jan 2026 00:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767919420; cv=none; b=FgRSXDahMGMfoo3CURh2kfFFTkeb3YPr06Zu+mkuXBT8LR83qZYp10dH2aFA5Ar2K2tG5JJ7JOXW8jd78+8Q7Tm81FswWXKIfXfPKgfCPkzE4SUmg2Lofy33D10w0CnywuPsMOY1LA/Y2JWwulchZEKyY/oISLcPYjJeHxywf34= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767919420; c=relaxed/simple; bh=ImDAJpc9ddBxn/RspOb1AGWqX/jNoxkwypOF+YVbFcs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WdlDIZongCosn0gQil5K9u70oKM66HtMyWYJ4TWznVMJV0RFomOt+Cnl9FWdt9me21gtJ5yjJgJGSwCOdau0qOCKPzl9KNs8rfQcwUuZ15TaO7nGf9EPdEpDWSF6CswukzH5WgM0oV/vFRZOpABBrcDECdstOtYl8EOYyJ1KeWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RpwsC0xk; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RpwsC0xk" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-34c565c3673so1214836a91.0 for ; Thu, 08 Jan 2026 16:43:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767919418; x=1768524218; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=51Qhk2QpnbWrPEp1VkKAc+tmXRgpBzJvdiLMKXqgx5g=; b=RpwsC0xkp9rLpmsg2bvNE/bSM6iEBV+x+zCWw3i5omEksd/vTmnE7JskK3S8K8yMOc is2ST26zXU08oVq5wL2bK5nNPuw4i9JV8VKFA8a4yKVoj88XnLKMc5rAhiklkFrK0DKy w4eFGgAuMPO8s5bnGIRseh2mSzgl0j9PZLsgj7+QfvqFJjUkX8aBbujy+J5VC046LCz2 bFN7WYBO6PqjO0JldjCqejOjpR8e5hpvlTN3lXRv7rxv0fLCrQ2Y7nRcEe5kPvaITcDg pozq7u72ZxWNspFh8pFYH9o3qICzvQ2JvFD1KeDiYjZna7nV3feFyA/Ppn58GMcptqX+ xlKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767919418; x=1768524218; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=51Qhk2QpnbWrPEp1VkKAc+tmXRgpBzJvdiLMKXqgx5g=; b=NDf8rgquwGKdlb6wFFcZ5rcQ+YEmCB9FHO02r0Cqt/T0gIk0QqARMvOFD5xa5ndoXU zHTJCbNL/9qbiG+fOb14Pd52o+G11HGu8K8HjAKLiyQxPF7Mreolx72/W6QULgJUgI8C LAm+UiHvOEYkwyW1X8eLPxPClkKsgf24r9lTNfRHy2O+wYI0OQj2IXF5YQSOqG8uCGIn RKms52OzxT0A4NBbJLmCc4Eo9zhZr/zTRimemTr51QKzKCYmYCa30Kx7W75B87mBvVQ3 5ZGa8KzJ9rNI5ZV0C1IOssPaipkJNAPidDZ2Du9d4hqnfjF4t/z2c1MtTLOLrXxcj1Kv wyLw== X-Forwarded-Encrypted: i=1; AJvYcCXnBR42v+I68aFObyWBaEgRK+k3qVCIZ9+Qc8CtYFptHBKGZIrzABSQmHKhDG95T7vOei9M6gAqapMzF3w=@vger.kernel.org X-Gm-Message-State: AOJu0Yxg8jl0eqKMGW6p77V7w+Jrx4NhUp4O2yCD4U2dOsVfb+Pn5da/ dgaKFy+XGoii3g5BLXhaJEWqSEiASKkmmmUCkKoGpDk8J8RTX8TzUQ68rDzsMIyCtoK2387Z5vi gOEH+GQ== X-Gm-Gg: AY/fxX4hP4cgMIcoxVWb6Dd1SEg9XQ14+BWgtfqegBuXnm9Boe9BF0Tihbyasn/cF0F mjiYcOYT3rSg/4gOFZDjIY+2rJNhuv+czC+Qklu88EAqlaYk3MNTLkUxlPbkgu8taK2pNXzU58Z gVt05hRSILnGB40EdR49tkuqJz8GMrHYtgpHgtLyMbyvB7ze8c95FUhFEOdYXwUTAP9jYlt87/P 0SufEjosSPx+D25EN4e+DDOhZuClUNfkOWqtm3JzanfdYEbh2A/yv+IDjYkawS01V7qpYz7VOVB JgwVNfCfDF3/p75R7CimWcf+jra+qW6KsutGeo87uFaO6cfIQIHe4kaSpI+dEfWlmbCMX1v1EO/ /ZKlA7JJiVHhU/fPj5g8D0fnk61vvpz6Lb85VPwtzVO8P92O8eqLDItfe4+S42GuuG4ResBslIP rujurce6ABqDXtqQD83zdF7jguuy9ngsXmsUB2k5FmiDXE X-Google-Smtp-Source: AGHT+IFY3AzA/hqaVzD+wKEUy1ckpWYyBi6bM8hjoLRfJLC75Sr8twLClEK01ALzwBO0jLOSqxhH8g== X-Received: by 2002:a17:90b:568d:b0:343:e692:f8d7 with SMTP id 98e67ed59e1d1-34f68c01825mr7895194a91.11.1767919418342; Thu, 08 Jan 2026 16:43:38 -0800 (PST) Received: from google.com (76.9.127.34.bc.googleusercontent.com. [34.127.9.76]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34f6b88d984sm2604341a91.3.2026.01.08.16.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 16:43:37 -0800 (PST) Date: Fri, 9 Jan 2026 00:43:32 +0000 From: David Matlack To: Jason Gunthorpe Cc: Alex Williamson , Alex Mastro , Shuah Khan , Peter Xu , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH] vfio: selftests: Add vfio_dma_mapping_mmio_test Message-ID: References: <20260107-scratch-amastro-vfio-dma-mapping-mmio-test-v1-1-0cec5e9ec89b@fb.com> <20260108005406.GA545276@ziepe.ca> <20260108141044.GC545276@ziepe.ca> <20260108084514.1d5e3ee3@shazbot.org> <20260108183339.GF545276@ziepe.ca> <20260109003621.GG545276@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260109003621.GG545276@ziepe.ca> On 2026-01-08 08:36 PM, Jason Gunthorpe wrote: > On Thu, Jan 08, 2026 at 09:29:29PM +0000, David Matlack wrote: > > On 2026-01-08 02:33 PM, Jason Gunthorpe wrote: > > > On Thu, Jan 08, 2026 at 10:24:19AM -0800, David Matlack wrote: > > > > > > Oh, I was thinking about a compatability only flow only in the type 1 > > > > > > emulation that internally magically converts a VMA to a dmabuf, but I > > > > > > haven't written anything.. It is a bit tricky and the type 1 emulation > > > > > > has not been as popular as I expected?? > > > > > > > > > > In part because of this gap, I'd guess. Thanks, > > > > > > > > Lack of huge mappings in the IOMMU when using VFIO_TYPE1_IOMMU is > > > > another gap I'm aware of. > > > > vfio_dma_mapping_test.vfio_type1_iommu_anonymous_hugetlb_1gb.dma_map_unmap > > > > fails when IOMMUFD_VFIO_CONTAINER is enabled. > > > > > > What is this? I'm not aware of it.. > > > > It's one of the test cases within > > tools/testing/selftests/vfio/vfio_dma_mapping_test.c. > > > > Here's the output when running with CONFIG_IOMMUFD_VFIO_CONTAINER=y: > > > > # RUN vfio_dma_mapping_test.vfio_type1_iommu_anonymous_hugetlb_1gb.dma_map_unmap ... > > Mapped HVA 0x7f0480000000 (size 0x40000000) at IOVA 0x0 > > Searching for IOVA 0x0 in /sys/kernel/debug/iommu/intel/0000:6a:01.0/domain_translation_struct > > Found IOMMU mappings for IOVA 0x0: > > PGD: 0x0000000203475027 > > P4D: 0x0000000203476027 > > PUD: 0x0000000203477027 > > PMD: 0x00000001e7562027 > > PTE: 0x00000041c0000067 > > # tools/testing/selftests/vfio/vfio_dma_mapping_test.c:188:dma_map_unmap:Expected 0 (0) == mapping.pte (282394099815) > > # dma_map_unmap: Test terminated by assertion > > # FAIL vfio_dma_mapping_test.vfio_type1_iommu_anonymous_hugetlb_1gb.dma_map_unmap > > I can't think of any reason this would fail, I think your tests have > found a real bug?? Can you check into it, what kernel call fails and > where does the kernel code come from? Oh I thought it was by design. This code in iommufd_vfio_set_iommu(): /* * The difference between TYPE1 and TYPE1v2 is the ability to unmap in * the middle of mapped ranges. This is complicated by huge page support * which creates single large IOPTEs that cannot be split by the iommu * driver. TYPE1 is very old at this point and likely nothing uses it, * however it is simple enough to emulate by simply disabling the * problematic large IOPTEs. Then we can safely unmap within any range. */ if (type == VFIO_TYPE1_IOMMU) rc = iopt_disable_large_pages(&ioas->iopt); git-blame says some guy named Jason Gunthorpe wrote it :P > > I don't think I can run these tests with the HW I have?? FWIW all you need any PCI device that can be bound to vfio-pci and mapped by VT-d. This test does not rely on any of the VFIO selftests drivers to trigger DMA.