From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (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 534FE3859D3 for ; Fri, 1 May 2026 12:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777638268; cv=none; b=hlrNIlscnhxCnMRBu1cbkrjyE8PP89v9VeAYCd5eCJAuUaiqOQgPdcA9/nNNP+leGsnN1nsJ2Nmr89onKJUn7l/3jBpfyNibVKCMCUJfAG9VSMHsUXz8FkrvVkNCWpD6psU/0ouur+kJ4idRx1DPDGvk5Vp1/ajzaA3uGh1tXr4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777638268; c=relaxed/simple; bh=luClRKdKtr+gw6gaUUzzdrRT4LDrSrv4Cxo3nK/hb5s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R+cZ4fPMhdNKJ/fMDGZ0X3WesMw5fCebl9iLInzaAR6AXn4n4y86edgZVqXz7o/r4XVglw5Kh/SSiPRU8n0TkU1uTAcgFlvQm2xuj0jGDKGvQNa2lG98eTm//aDcRhnuwz/U2xjFcHs8Y/LwAw3WkQwsJX4oEStXyA/sEEO32PI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=mIUXMcXS; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="mIUXMcXS" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-50e97863425so17581491cf.0 for ; Fri, 01 May 2026 05:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1777638266; x=1778243066; 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=SxL2PZx/4KiAYlM/BSrsH2KIM4aSQy8bJWmezhmWpbU=; b=mIUXMcXSSmO1Eshilk74zrvJRU/SgPk7vd42ZCL3MUcl0anv1gcJ9X4peoAo25msEN qNxoCT+hMAitKsDAJXmhWtQzaIZlqllwjA0Dd3cJzmOvaCogcPKZQ9ZpCn1IJ89dOga2 fND90P5Q2HHH3sRpQaOBEZPIEN+Sqnwl+HnH2Ze3vR34G+EX6aotIsKoo4haFC835JA3 tBY1Hdf31g+wQ3QTzcasdSm5EUJPb4EsQk+6/qkDCqvQvlQtS5QtSQAGH/L1sJr0X1CX zWCr28XMIPFXonC+Ljunx3+OkNgeJDcrFwIh5AStTFy+PmDYkizvBuSTzA9TUztcuwC4 zNrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777638266; x=1778243066; 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=SxL2PZx/4KiAYlM/BSrsH2KIM4aSQy8bJWmezhmWpbU=; b=nBKTtc50ie7j+5C6rOZrqBl+NXLI//qEOT3vY2uSQUr0Gvg4sI0ZoObG+HyBF1Adr6 23D6OkPqojkcSYPjWjUoJ9CUJhtaNZ5w7nrvXFGoOKOy8jEIBMK1wVqwFVE2eL3D1kS7 74johY/uRsZ9u4aIxa5ahiTFBlYLXDzooRrXCLXqY023+Q1W9K+s75wrOx4zIEkBkMui 7LuJJAyXt2P5aMyIwyr0bDQK8WLyVFXOcGIeTWOBdBkgbB3TyHVPP8EgyWw9+22K0tWV J7gRQi6Rp1qbyEbontdiE21dQr6hMTmKVH3eKQcxnzlwYUQpmLqIKlUDYbeQ7JZoJHlw q1AA== X-Forwarded-Encrypted: i=1; AFNElJ/oSCq30MfhSxcfufs1nf5nXauGJtVPIjHBV7Wnwgxhl7nIoBDD/wloPTJbedyFnnhExsno95Tp3AJ08I8=@vger.kernel.org X-Gm-Message-State: AOJu0YwUp6/iYyxhbQMGOrdNg9JQ3cyfbgtGeiMsrp1nNYBt+6v+hyGs ETUKoFpm20vG2aTA7yCp9cnR+WBtYTnz36iIfRrD2OmLj9jRx51wcL3XM7RmcWg0weA= X-Gm-Gg: AeBDieuMSPYK99aksgQ9jWFjiot5EgDeTOnB/KetvuekjmL4+ROJGTbVV50GsBIMg9G x+X045fuH3O26Vv2XZeuX7AOqqKc+3lJqvrpO/LbT2F/1KKiWrfmJndzEnaet0QWFIKKnPV06oY KzYIAvGEClt285yEo2T/sU/BvAgiT9jeCjYDKu/bssH9dC9MB+qf+cVjAmlrct9F8HxXTBTBxOq hmOLQ6vcTvVGB8YpU56SCceqQFZyhQSyARAq68eWHzECKqsAZxWGCU6LH5iZOsnYbdn8lbcjDGD m2AL5rqJ/WDF6YmHMpnqFw2Cs4fH8UZ/O5Ta/WcB/mswZ8nKJObv2PgNssa1pYCaYBU0cmFmE1R 9EJzXISsLFTTG6XjmBbrX08A7eyZdrgx9SRITsydAI5IVHbAt268zsMHpfT6D8T42XfH9Gx/Y8i s2ZrXxD3X30QSYnjWEbeS2zUUkF7UZr1jfAIhBkrrFcFP//84SVlzP896mZwI+tG5hcMCJE4GiE djfUc8/BuC59wdBDX9IdP+eD/g= X-Received: by 2002:a05:622a:1354:b0:50d:5f34:9a with SMTP id d75a77b69052e-5102add7284mr102979121cf.28.1777638266137; Fri, 01 May 2026 05:24:26 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b538c14514sm22998866d6.8.2026.05.01.05.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2026 05:24:25 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wImuu-000000053e9-3BRf; Fri, 01 May 2026 09:24:24 -0300 Date: Fri, 1 May 2026 09:24:24 -0300 From: Jason Gunthorpe To: Mostafa Saleh Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, iommu@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, joro@8bytes.org, jean-philippe@linaro.org, mark.rutland@arm.com, qperret@google.com, tabba@google.com, vdonnefort@google.com, sebastianene@google.com, keirf@google.com Subject: Re: [PATCH v6 06/25] iommu/io-pgtable-arm: Rework to use the iommu-pages API Message-ID: <20260501122424.GA6912@ziepe.ca> References: <20260501111928.259252-1-smostafa@google.com> <20260501111928.259252-7-smostafa@google.com> 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: <20260501111928.259252-7-smostafa@google.com> On Fri, May 01, 2026 at 11:19:08AM +0000, Mostafa Saleh wrote: > To prepare for supporting io-pgtable-arm in the pKVM hypervisor, > we need to abstract away standard kernel allocations, frees, virt/phys > conversions, and DMA API mapping. > > This patch introduces a set of generic wrappers in iommu-pages.h: > - iommu_alloc_data > - iommu_free_data > - iommu_virt_to_phys > - iommu_phys_to_virt > - iommu_pages_dma_map > - iommu_pages_dma_mapping_error > - iommu_pages_dma_unmap Wah? This has nothing to do with iommu pages? This just leaking everything iommu pages abstracted out :( When I said to use iommu-pages, I meant to use the existing API, not a completely different one. >From an iommu-pages perspective the issue is this code open codes dma_map_single()/etc instead of using the API surface iommu_pages_start_incoherent() This is annoying to fix beacuse the external allocator messes it up, but I think with some #ifdef you can probably fix it up. So.. I suggest you update it to use the iommu_pages API, #ifdef out the allocator so the pkvm pkvm doesn't need to deal with it. Then compile a special iommu-pages for the pkvm side presenting the same API. You should have a pkvm shim header that provides kmalloc/kfree/virt_to_phys in the normal way and just #include that in io-pgtable when doing a pkvm build instead of hacking up all the code. Jason