From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 672FE53A7; Fri, 6 Dec 2024 15:04:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733497449; cv=none; b=FDPV4TY1hYWzDxet74u0tDhoRDUqTkESfdLAgLClQ8Ai9iVdqlL8jQ3hijwigWwjM35PBfZtM7j3lwYqkyASJ2JM46+r0oIqaNP2Z7xP0ietPrMyNfuZ3GBCvkB4164gzq2N/KabGNcXGApwY138R5NlPNlMw5391hVfPZzJHek= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733497449; c=relaxed/simple; bh=E+W0cwMls8mJjfR9lsEGGDe3Kia2zqz4mHT63LdokQA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sVAPHjUp/aY5ziQqVEIyAQIpEGUvRgjXuhbjKkGOGzcwGoplTUPilEGWFtwyRevaBPmznGDxZYw8Ngh5mdl1TuH5T3CA0g0GFJvqzYKuAEsCYEWqwekQ0qCfiiu7fsPggq/mgFr55vdxsR1uK60A88eqTwbgp9fIhiBaK/xFmHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GF7MSHP1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GF7MSHP1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB96BC4CED1; Fri, 6 Dec 2024 15:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733497449; bh=E+W0cwMls8mJjfR9lsEGGDe3Kia2zqz4mHT63LdokQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GF7MSHP1YiENtid2TDfzb8xJ3Iq/qypQdf/iTLL5tFDGMgWBl4FUCypbdp+13Q5je oywINNSI2wKq2siU0qqoOuoWKWYafQCr2pmmByp3cfSSIUjJhjZVbXWRReOLyd7CEH cfK+lgwHUSYDm3U+ipw4rgkWxsLZTmpPB6TpVbe4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhenzhong Duan , Lu Baolu , Joerg Roedel , Sasha Levin Subject: [PATCH 6.6 296/676] iommu/vt-d: Fix checks and print in pgtable_walk() Date: Fri, 6 Dec 2024 15:31:55 +0100 Message-ID: <20241206143704.902604690@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143653.344873888@linuxfoundation.org> References: <20241206143653.344873888@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhenzhong Duan [ Upstream commit f1645676f25d2c846798f0233c3a953efd62aafb ] There are some issues in pgtable_walk(): 1. Super page is dumped as non-present page 2. dma_pte_superpage() should not check against leaf page table entries 3. Pointer pte is never NULL so checking it is meaningless 4. When an entry is not present, it still makes sense to dump the entry content. Fix 1,2 by checking dma_pte_superpage()'s returned value after level check. Fix 3 by removing pte check. Fix 4 by checking present bit after printing. By this chance, change to print "page table not present" instead of "PTE not present" to be clearer. Fixes: 914ff7719e8a ("iommu/vt-d: Dump DMAR translation structure when DMA fault occurs") Signed-off-by: Zhenzhong Duan Link: https://lore.kernel.org/r/20241024092146.715063-3-zhenzhong.duan@intel.com Signed-off-by: Lu Baolu Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/intel/iommu.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 7d00e9cf7db02..d6381c00bb8dd 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -815,14 +815,15 @@ static void pgtable_walk(struct intel_iommu *iommu, unsigned long pfn, while (1) { offset = pfn_level_offset(pfn, level); pte = &parent[offset]; - if (!pte || (dma_pte_superpage(pte) || !dma_pte_present(pte))) { - pr_info("PTE not present at level %d\n", level); - break; - } pr_info("pte level: %d, pte value: 0x%016llx\n", level, pte->val); - if (level == 1) + if (!dma_pte_present(pte)) { + pr_info("page table not present at level %d\n", level - 1); + break; + } + + if (level == 1 || dma_pte_superpage(pte)) break; parent = phys_to_virt(dma_pte_addr(pte)); -- 2.43.0