From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 E4255370AC7 for ; Tue, 23 Jun 2026 01:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782179208; cv=none; b=c8ZjvxKYL3lT/6DPIUqzxP1wc3UGKTDysIkrywzw4KPb8JutbuAOROxdJ/R1+6XGcjkEHUhA7YB+c+68ixSRBy6n8IkOuqREAfpGmIwILEg3dCsxUrjH2MAU35oulUWNNkJJtLAjSaPYzZJa0nBWj6m5QJLzlokUGv/sPlW9+w8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782179208; c=relaxed/simple; bh=2apY+z0N2eT8oIYqkywxMesHZ3STxvb01hviFdFriTw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OA3WV2RJd48xS3u9QSQ9iyJP9eAWrxygBLiVqHNz404Qji9xz6DS8Kt0nXQSWdMzcNesC/sOnGGe3dR9q9l659m0hcryHkrLZi3dCNCUcFJVUWwdYY9Y+kX2yRSuhEZaXONkHd097nMHQWagV9v3pR2P1/Fecb7vNHt7f6kE0Fk= 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=NFhBJgXB; arc=none smtp.client-ip=209.85.214.174 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="NFhBJgXB" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2c73cefe192so13385ad.1 for ; Mon, 22 Jun 2026 18:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782179206; x=1782784006; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=W573SLR3fQ3LHn7BMqDZVpOE+yHqb2rgziXRTcKO9m0=; b=NFhBJgXBZKaoSIu3MQhuzAADP234qklEVlguuLp42HCDRjCopVdfDbJUr9RfJgTDNx SK01RjhsnEyRUivuQ1AQRtN3+8WhE0mkTiq7U/j1W40pUn5d4Mz55HOhS4m+C+M8SUjd DbZhVH2zOOnRw/05EbcEUBMwmKErPi39eSfAvAiOyC8Acxz1zd2h3UYWSf6gTmhq17AP 1Au6T1KGNiNFcLSOfjtN+GxSjHxye3/4f5oVY+PIpgBS+gHkwpQgX6VP3PaonUznfMgY 0SrZpyrj0ZYyKQg25/rLyueMz72oycq1NGSLG0x82IIvu2UnGBBWXXzFKLrIKd8H3I35 lNIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782179206; x=1782784006; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=W573SLR3fQ3LHn7BMqDZVpOE+yHqb2rgziXRTcKO9m0=; b=ieUujKCmjXZLiGMDeD2F/U4O9VYQFmmpY5Xd/gVTSq1AehnaISZGjvCWLe3IgIuYlH KYVzwSTyZ4plLrtOteg1r8qcNpTPFt7fdPsYdaSBOodB0vyV10NyaOVsTq9OjbwAX+fn zo8cEvT0xxDp51oFTqGzfcBesQn+8eSRbkwVrygruY3/pnm/yZFWWauRZzEqEWUDDsEP 2sz57GK/cq1wp5kRK9qZikMAbSiVymBKrOrbUJfbS3EvWj95yfZ8nMU+FyEKdPucC1Ox Gr4TFFlLfOPVQO431Hgc5DmEMp4tYdLUoNQoV5NgM1gNpfXeazJGX0YDvJY9Jg7eI1JM qhhA== X-Gm-Message-State: AOJu0YyyhwBdq/LNkiGdUUDh1yK82PZb2ncp4Mg27gfRyorKjqSWcB6W iZcP3Ffu1FKl8GiAVLPx36t9kNTSLqrbviXXgwh0BrUdPsem3bMv1cbgGx8P7nBBvA== X-Gm-Gg: AfdE7cmmaIwejLiez8A6UqApIUg0xpjYQ3rnY8bdMlS3gz1a+LVKbIrsTZJURF0/sDf IhvlcdORKVBD4MXGBOp1Z908cIPKZcSMotxP2HYHgIjwLi4qElZKZM4lv53Lth/7tRO6FMSswZ6 uBIAXYnZEK/zv3BKId7Q5TemZud6GxDNrUzCp/uCw38vL7kw+jpQFJZdX2eZWazT7b2aeV6cur8 JnS0p0NFsZMKlznIAyg8xb7LvXWtDFsV6DNZuJm1iM/PHw3Uf+H1X7TN2JClevmgxvoG93W9RuK Q9u93dnURhYv8jknrS7AayJ/wndJnVe/5afnEAlqRv0ouPVmgByBLBwN0j5cq5BmQuj/Ahaq5pX KdiNljW4vwm7R/yc0yMJXGvr0ccjomNMUqZTUTdXyc695QF3SKztaXXbG6d4Byq59CwFUcP+i4/ pBZFaRGIpho+/SL8/Vb1OUGTwT8uIZGNGk6tsKQ123vEQJS2kCu7gCkt923hbQ5MFzNugXtYwxJ GVEd4vm7zhh99CtxwM= X-Received: by 2002:a17:902:ec92:b0:2c6:afdd:e62e with SMTP id d9443c01a7336-2c7c5156f0emr1179185ad.14.1782179205657; Mon, 22 Jun 2026 18:46:45 -0700 (PDT) Received: from google.com (25.75.145.34.bc.googleusercontent.com. [34.145.75.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c7436af54dsm92530885ad.11.2026.06.22.18.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 18:46:45 -0700 (PDT) Date: Tue, 23 Jun 2026 01:46:41 +0000 From: Samiullah Khawaja To: Desnes Nunes Cc: linux-kernel@vger.kernel.org, iommu@lists.linux.dev, stable@vger.kernel.org, baolu.lu@linux.intel.com, dwmw2@infradead.org Subject: Re: [PATCH] iommu/vt-d: Fix UCTP context table slot when copying root entries Message-ID: References: <20260622133540.48591-1-desnesn@redhat.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; format=flowed Content-Disposition: inline In-Reply-To: <20260622133540.48591-1-desnesn@redhat.com> On Mon, Jun 22, 2026 at 10:35:40AM -0300, Desnes Nunes wrote: >When translation is already enabled at boot (e.g. kdump), the vt-d driver >copies context tables from the previous kernel's root table. In scalable >mode, buses that only populate the upper root half (UCTP, devfn >= 0x80) >should be written to ctxt_tbls[tbl_idx + 1] through copy_context_table(). >However, the current copy path always uses tbl[tbl_idx + 0] in this situa- >tion. Since idx wraps to 0 at devfn 0x80 due to a zeroed LCTP, new_ce for >LCTP will be NULL and keep pos equals to 0. Thus, UCTP entries will be co- >pied into tbl[tbl_idx + 0] instead of tbl[tbl_idx + 1], and written after- >wards to root_entry[bus].lo instead of .hi in copy_translation_tables(). > >As consequence, devices on bus 0x80 with devfn >= 0x80 fail DMA with >fault 0x39, which breaks drivers running in kernels with translation >pre-enabled. This fixes NO_PASID DMAR faults for UCTP-only buses such as: > >DMAR: [DMA Read NO_PASID] Request device [80:14.0] fault addr 0xe81759000 [fault reason 0x39] SM: Present bit in Root Entry is clear > >Fixes: 091d42e43d21 ("iommu/vt-d: Copy translation tables from old kernel") >Signed-off-by: Desnes Nunes >--- > drivers/iommu/intel/iommu.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > >diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c >index 4d0e65bc131d..737936f942a0 100644 >--- a/drivers/iommu/intel/iommu.c >+++ b/drivers/iommu/intel/iommu.c >@@ -1443,7 +1443,7 @@ static int copy_context_table(struct intel_iommu *iommu, > struct context_entry **tbl, > int bus, bool ext) > { >- int tbl_idx, pos = 0, idx, devfn, ret = 0, did; >+ int tbl_idx, tbl_slot = 0, idx, devfn, ret = 0, did; > struct context_entry *new_ce = NULL, ce; > struct context_entry *old_ce = NULL; > struct root_entry re; >@@ -1459,10 +1459,9 @@ static int copy_context_table(struct intel_iommu *iommu, > if (idx == 0) { > /* First save what we may have and clean up */ > if (new_ce) { >- tbl[tbl_idx] = new_ce; >+ tbl[tbl_idx + tbl_slot] = new_ce; > __iommu_flush_cache(iommu, new_ce, > VTD_PAGE_SIZE); >- pos = 1; > } > > if (old_ce) >@@ -1484,6 +1483,9 @@ static int copy_context_table(struct intel_iommu *iommu, > } > } > >+ /* Track if saving UCTP or LCTP entries in scalable mode */ >+ tbl_slot = ext && devfn >= 0x80 ? 1 : 0; >+ > ret = -ENOMEM; > old_ce = memremap(old_ce_phys, PAGE_SIZE, > MEMREMAP_WB); >@@ -1512,7 +1514,7 @@ static int copy_context_table(struct intel_iommu *iommu, > new_ce[idx] = ce; > } > >- tbl[tbl_idx + pos] = new_ce; >+ tbl[tbl_idx + tbl_slot] = new_ce; > > __iommu_flush_cache(iommu, new_ce, VTD_PAGE_SIZE); > >-- >2.54.0 > > Reviewed-by: Samiullah Khawaja