From nobody Mon Dec 1 22:07:22 2025 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 711D8229B12 for ; Sun, 30 Nov 2025 19:45:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764531924; cv=none; b=CZT2azLsS31gyH5cQU28ZAn3ETYU7zEkHorHgrUdfGOV5yrUUGXZjponampO2J5G4S3xaOXJCj1lCRLwc6JhmhChFzDY7BfYtQB6QEXrpeHIpVFctlU5OpM5snzeUVsyaAuTE/5681gMMrnSkMc0UAmZe88j4YlsFwSHTQf0pM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764531924; c=relaxed/simple; bh=WfVkj8pEntebpBsg4mVtXPLRxLG+3qfn6UXm3jIrd0U=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=tO6LB3g0ivMXbklha4Ova+Uu/1y1i6sJYdUK07D26IcLavWnweqWqtapxDz+VXLPOBq9Cvpp3KebbMPwOCYN+dCU/AVFQ+Gzsmu4cgf6tDkRratshy+VYRcCyvSuJPrmPeNaFc8fka0DFq5drADEvp/wUcKDdrjgPpor9bs0+Ek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--smostafa.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=AxHaVP3i; arc=none smtp.client-ip=209.85.128.74 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=flex--smostafa.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AxHaVP3i" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-47106720618so48764615e9.1 for ; Sun, 30 Nov 2025 11:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764531921; x=1765136721; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=VpKzwW+DrSxITLrqVUpcZpbwlWPuuva1N93VFVuU3gQ=; b=AxHaVP3iqVcmhh6KgOTsWMgXd7h5Wvi6e5vyBqoTmqxEymtkMxIVZdxYCPHJSWd2dy bt6yRoEYrTYkRcNgBWOy2D9TzF4xlTcOUjmEOoxEYC9efAp5wBJu38XTXp+0/UH7msg5 rmJYonIiCBNo5s3+pD+BnbEJt8FD4QGr7SopOOxKXYIT+7mmPDJ0Y0Bni5OVBrv40ApE 1gpuWeTI2xiUVpHHBUjDbIdp6nTQaFxR7ZJCb1vrd52Q0tcObm80Ylw3VBMxz61jy0My OTEfTF3u30WpNhmOBuImfTQVg17FEGNmAiLXK/AgvHEYg9w37uXOflIXn9P3xO6rK608 z7MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764531921; x=1765136721; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VpKzwW+DrSxITLrqVUpcZpbwlWPuuva1N93VFVuU3gQ=; b=Xwjcxp5waf191o8otS5fp2QLbhnzkTSF1tM0q5NntKF6FEpFbCbU1Ni8JEjAE/hXp2 +PW7kQI0IOPLqEdjGagKzrw1whpk4+OoQksLZ5rJh8ZtPm4QnjUyDIrZg7VeSBHcnb0V qWu5u66vt20EZJKmIgqJ6CSDvyVpvmyk2zOlycFzHBZHdUwM50ownk3nhWWG5RW65lPY Z6K74mb66R28F1hEhzThuZ1DVUdrm8Sg1zZOXv1tSYwqOx8V0Sb8X1AxkQj/macgGQnS GmIRVouS3eRGYEvzGCIlWfuBEgqQyE/Y9Kz8jSOhfBuEs1JaAf5hW3+inUGQYWzUeJaq 7vHQ== X-Forwarded-Encrypted: i=1; AJvYcCXw8/Dz9L8XcpF4YjZWt1DkVxUZ9wZN32ys88ms1Kvj5NZzJVxiWkMc0hW+az9n0xfOWT5Sy7ONEO0oPaU=@vger.kernel.org X-Gm-Message-State: AOJu0YwX/Dals7pi7mPoKFsfGbpBpe5HUZCSVXWZIy3nyAXPITEu44fg MG05wLPYQn6DjPcqBNix79Rvma7Muwnh3VTzJ3BGuv8aBoCesnlp8hZIHJtBr0U64Am7LJpnDpT mE2PA7KIDG8GMdg== X-Google-Smtp-Source: AGHT+IGX+La27FykkneboKedWl3FbPZ7fIp0DKL/wu8LaMWfDRdIsROXD63+Az5xZoHNsgdO2DB82IvlLgkaUQ== X-Received: from wmom17.prod.google.com ([2002:a05:600c:4611:b0:477:40c1:3e61]) (user=smostafa job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:354b:b0:46f:b327:ecfb with SMTP id 5b1f17b1804b1-477c0184c45mr341232415e9.9.1764531920917; Sun, 30 Nov 2025 11:45:20 -0800 (PST) Date: Sun, 30 Nov 2025 19:45:06 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.487.g5c8c507ade-goog Message-ID: <20251130194506.593700-1-smostafa@google.com> Subject: [PATCH] iommu/io-pgtable-arm: Add misisng concatenated PGD cases From: Mostafa Saleh To: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: robin.murphy@arm.com, will@kernel.org, joro@8bytes.org, Mostafa Saleh , Tomasz Nowicki Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" arm_lpae_concat_mandatory() assumes that OAS >=3D IAS which is not correct for SMMUs supporting AArch32, and have OAS =3D 32/36 bits, as IAS would be 40 bits. In that case, concatenation is mandatory in some cases. Document those and add the checks, this can be simplified; instead of adding extra checks we can say that concatenation is mandatory for: - 4K, start level =3D 0 and OAS <=3D 42 bits. - 16K, start level =3D 1 and OAS <=3D 40 bits. Which cover all the missing cases. Reported-by: Tomasz Nowicki Fixes: 4dcac8407fe1 ("iommu/io-pgtable-arm: Fix stage-2 concatenation with = 16K") Signed-off-by: Mostafa Saleh --- drivers/iommu/io-pgtable-arm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index e6626004b323..ecf27e86b429 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -223,6 +223,8 @@ static inline int arm_lpae_max_entries(int i, struct ar= m_lpae_io_pgtable *data) * b) 40 bits PA size with 16K: use level 2 instead of level 1 (16 table= s for ias =3D oas) * c) 42 bits PA size with 4K: use level 1 instead of level 0 (8 tables = for ias =3D oas) * d) 48 bits PA size with 16K: use level 1 instead of level 0 (2 tables= for ias =3D oas) + * f) 32/36 bits PA size with 4K and 40 bits IAS: use level 1 instead of= level 0 + * g) 32/36 bits PA size with 16K and 40 bits IAS: use level 2 instead o= f level 1 */ static inline bool arm_lpae_concat_mandatory(struct io_pgtable_cfg *cfg, struct arm_lpae_io_pgtable *data) @@ -234,13 +236,13 @@ static inline bool arm_lpae_concat_mandatory(struct i= o_pgtable_cfg *cfg, if ((ARM_LPAE_GRANULE(data) =3D=3D SZ_16K) && (data->start_level =3D=3D 0= )) return (oas =3D=3D 48) || (ias =3D=3D 48); =20 - /* Covers 2.a and 2.c */ + /* Covers 2.a, 2.c and 2.f */ if ((ARM_LPAE_GRANULE(data) =3D=3D SZ_4K) && (data->start_level =3D=3D 0)) - return (oas =3D=3D 40) || (oas =3D=3D 42); + return (oas <=3D 42); =20 - /* Case 2.b */ + /* Case 2.b and 2.g */ return (ARM_LPAE_GRANULE(data) =3D=3D SZ_16K) && - (data->start_level =3D=3D 1) && (oas =3D=3D 40); + (data->start_level =3D=3D 1) && (oas <=3D 40); } =20 static dma_addr_t __arm_lpae_dma_addr(void *pages) --=20 2.52.0.487.g5c8c507ade-goog