From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 8139831AAB4 for ; Fri, 12 Dec 2025 15:37:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765553871; cv=none; b=TWognezhY/drySN5CROZtGSMDdgaj9PSKFQ16A2zqztyGhk8oinzAPAOfAc6oreG1ERHUd+u9cD2WObH5R4nLPv2dleZAR1en3kmAxGd4wgBCP0xTU0JC/75ajoRR5uAhekmf8iPP52N4LKVp03LEcbM5tEbO/G4NtF7fACowYo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765553871; c=relaxed/simple; bh=vCxTVQ2cbqhlx8SAakkeafvVNMeYr9pSGx92r+SIXhs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MRe/DPpYGaq5/u8vckNJXGhJ/NyBngQ/KRPTs2T0ZX34BzMzUxPSN900TTTnuxVbi9unPJMiQlkFM84UboI97nHaBFLOMhfERgLdEX6oCupRK4JsH6cjw8kxzH2wOrpW7ENjJPGHJpkDBGQLZUzseISCedVKRfJ46Wmk6E121OM= 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=YZpuW8aq; arc=none smtp.client-ip=209.85.128.48 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="YZpuW8aq" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-477a1c8cc47so168485e9.0 for ; Fri, 12 Dec 2025 07:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765553868; x=1766158668; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=t8RokAtosDkKW20ZPmF7jI+1D1J1h8RY8U91CVgDMOA=; b=YZpuW8aquPwbC88ONYg+24ZwOhPN3W3NWFf6W7KeRHeZfFd5fmpJs6c/NnMfmf332j Uc2FLpDU50aOXG9hzYeyq0yityXiRmJpOLhD1nGzjRL/AlG1rgMfYbGct6g571Wq4X7s T8VcAAREYIfxodqNV4QTtt6obQ6ZFCOCsqjHZMPxJwv8tmcckSmszAnyUu6aMHTdTCwD Jql6i2NeKC4R5bRrBKkkEdCKeS8NSrl3LIaLOmvr1HGY8UhNOd+mRbcada0Dlw0t/lum KC/3hpL+VRgbDeNQ+salHoGO61/N9AZ0rnW6EWWMNiNpNbxZdEKS4JkfN+jz/4wyyDWE XhMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765553868; x=1766158668; h=in-reply-to:content-transfer-encoding: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=t8RokAtosDkKW20ZPmF7jI+1D1J1h8RY8U91CVgDMOA=; b=upkWNp1g+kvNWVWAXDWnyV+0B2uS4rAwP828ly3s2qq82+KWf7vNP9iILu35TKD4u2 p8ENz0H819AG+KYX7YfsjEyxRKWGD1HgQkkIPiJZetI3EmwgnMQYOjqAQGTiPYR9KIpw 9xpcJmktbsYhPRThrnqQJtguyiaeVY6/hwnQxqFS5V6mR4HzyyPToSt4qNGtQmsV0vxr XzI2vZYp5FS5/duWJs2RItl89soNzQV3+FkSmJ8dsQZPAhZ0CfIJCflw5oxv5rrkjvpM Z1ZCBR05kjdxfFufMVlVZdG4vpwPqRKMMzRxqCdEtFMzD98iGuD2tKhXi7fv2+9EMiIH aJ1Q== X-Forwarded-Encrypted: i=1; AJvYcCWo4sE+w90WbTvxfqrfq4Q/LA1Fur4eO8qHZAzehgGNvb88PRmi+2EfVt0+e/kcKdcYxxKqKBg0gZIUpws=@vger.kernel.org X-Gm-Message-State: AOJu0Yzbb26XhIRjJIXDQqMi/5rEzKDJdrtRiiOXDkRBzkfH7C7KdM+n Ts5VN5KvCV8jbu+yCbvC5PjQizZHSsh5zMoFqxfAtCb0l5zqYvuqStxxujceNwiJBA== X-Gm-Gg: AY/fxX7VK94mlcoaKlsOEmFpFIh0+AjDfTh0+h7BgT7EKDV/L0MFGI6wMchzsgIFTnk xQU5CtoQGUv0xkpvHTsmsm9h4MPcp2xlUGD+Oxl5l4Yb1bAc8wyop3xWsvNk9xocKFqBHCFxopq CaAroeNRwRJHI4nPoxw7DmKf76n7OGl+8H4a/q3MU46FmZ09K0cUM99QPAv3Odqyic22PW47BHO DNG8XRh6jp4P8WQpei7H30JxxOsHp42bsicv1Fc+stNHz7jyKNgHmRECssp1vmqCWSK5kCbJ1FA dazZIepciRHq9RsZPR5yz7ROFFGOAd82exCqAbo5+o+70zLuCDYtl1WD7ig9U2cNw1mfrzflaio LlbOsrlNId4D7omOgVq3LvwWtec4fmAqDFtK9BeTUhwsZUnFJ3N8teTDLzXSvKnRmNqG4sYbu6h IyqJhTOKEQY0PQRpyYYqj7JPpBg3npsk7f9NyPO8kh5AIfPFUjag== X-Google-Smtp-Source: AGHT+IFXfc3AC76G1YFLQm1Se+be8N8XTO6jICn0jtn4xJXqL4zg2CykiJrG0pTcXZHbluGygYoeaA== X-Received: by 2002:a05:600c:4f16:b0:477:974e:2b34 with SMTP id 5b1f17b1804b1-47a88c6d52amr1996775e9.16.1765553867672; Fri, 12 Dec 2025 07:37:47 -0800 (PST) Received: from google.com (54.140.140.34.bc.googleusercontent.com. [34.140.140.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8b8a97esm15306057f8f.31.2025.12.12.07.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Dec 2025 07:37:46 -0800 (PST) Date: Fri, 12 Dec 2025 15:37:43 +0000 From: Mostafa Saleh To: Jason Gunthorpe 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, praan@google.com, danielmentz@google.com, mark.rutland@arm.com, qperret@google.com, tabba@google.com Subject: Re: [PATCH v5 04/27] iommu/io-pgtable-arm: Factor kernel specific code out Message-ID: References: <20251117184815.1027271-1-smostafa@google.com> <20251117184815.1027271-5-smostafa@google.com> <20251128164541.GA812105@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20251128164541.GA812105@ziepe.ca> On Fri, Nov 28, 2025 at 12:45:41PM -0400, Jason Gunthorpe wrote: > On Mon, Nov 17, 2025 at 06:47:51PM +0000, Mostafa Saleh wrote: > > Some of the used APIs are only part of the kernel and are not > > available in the hypervisor, factor those out: > > - alloc/free memory > > Why not provide the iommu-pages API for the hypervisor environment? > > Same for virt_to_phys, that could be moved into an iommu-pages wrapper > too.. I guess that's possible, but then we would have to stub dma_map/unmap, which might a bit ugly. I will look more into it. > > I want to change other parts of the driver to use iommu-pages in the > long run as well, so putting the abstraction there is probably more > valuable than this. > > Also the genericpt stuff is merged, should you (eventually?) be making > a pKVM hypervisor specific set of page table functions? Eg if all you > are doing is mirroring the host stage 2 I think you can build > something much more efficient... Most of the code is re-used from the io-pgtable-arm, so when that is converted to genericpt, it should get to the hypervisor also. The only hypervisor specific logic is the memory allocation, virt/phys conversion and CMOs, I can look more into painting those, we don’t have to change much. I have some plans to add support for sharing the CPU stage-2 page table, which is going to be complicated as it requires changes to the core hypervisor hyp/pgtable.c code, which will be in a subsequent series. However, I reckon that we would keep the shadowing logic as not all SMMUv3/platforms are capable of sharing page tables. Thanks, Mostafa > > Jason >