From nobody Sun Feb 8 10:03:59 2026 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.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 A173D230D35 for ; Sun, 21 Dec 2025 12:35:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766320522; cv=none; b=huCkTrVLMAdza9zcpajaql0WHpgyRq57jju9Qw+6QjVGW3orepSJR9P9NDdEM9VPD9T2GiJYWPnabIMCXJxXOqdF6HSj5xA7wXdLLQzjDcThvYHpPAZWR550fFS+9QJGbd/E9OwcHbyuRvXbblYgIXpICn3iztjgQiw9RpuWXGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766320522; c=relaxed/simple; bh=imY9m+27lOPX/d2NlS3wpd62JpvY1Xeq/cUzqWIBgG0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eDObyeBNbjvgDsUFVaDEBrsE97A8M9dX/uzvYALaVGHguLDFbhU1zD7gD/doN9dsUrNQCzobM9ebgp1wFN1Whal4B04hnKKTUw5c8ZDByKzXlAkXnT5Fj89hSqe/PasN90AAiT8apoDGWUIMsCBiQQCJ7qGsp2/S0Jv+2DYfQnY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=J+oqM1+7; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="J+oqM1+7" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-b713c7096f9so514681266b.3 for ; Sun, 21 Dec 2025 04:35:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1766320519; x=1766925319; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KgMTUrq17GdZ6a6fk/pQ7/28KGon25vKkSeBtxD4m+M=; b=J+oqM1+7PLVKKtFP7L++OWn2CpDz+qq57cmLd3CV0t6GOplqs8uViw6Z8d7dpQxx64 sZLWUe5ugSjw7iQij5kV8zkalQWRx1dx7bZerAsu3/34Va3CR3cP3CzEYulKo3toA8Vn ELaC3iiLLTWof9SqJqD6ZOCPJvcDMMyL6Rz60= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766320519; x=1766925319; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KgMTUrq17GdZ6a6fk/pQ7/28KGon25vKkSeBtxD4m+M=; b=JtZjAzfO8+SwsnAtCx0OVZqKdw+m5SYh91jRphGguTCSsKDDxZJ6vqrJqtCp0qQ9Rm oNQhLA1x3eWRnIO9ZV6TxUnNK+oYYLsCrrppGZzlm0QcE/YVSLN9NSapzPLmGrePcEQt Je95ncdq8CtE5Ue5wnhBYWzJ5cvksNr94lwZVP1ryym7HUTArbykawYS4L2UTE1dz6iU MEJEDTYlS/dBp42bJMEQhTTy4cMw9vMdCuIQ/3uPo7/+vgjcCFisQXxeanH4ebknY4J1 DRampCTghDy1s620e4JqKhz+5HsDblk1hrqMtRUNNjUg7vmtJCCOIFAdPXhK1HP+TfNi ANTQ== X-Forwarded-Encrypted: i=1; AJvYcCUd2wittpJzw69w7wyVkruAWkSgBiXqfVnSqfd+mZwCnmkvctkfVjxbxg7L1Ip1xu5phC0S1jRfMeBIBSo=@vger.kernel.org X-Gm-Message-State: AOJu0YyA0SaJ405eszoyvcNKkcR3qUZzkeslBrPoKv1BVp/mMHITkrNi 1cwDruAtxKQcJKiThdeE8ZzI0TK6pTqiv9g2Ad9QNgIv//Cd2+dJH4HVtiu+D/wJWg== X-Gm-Gg: AY/fxX44Iyex8UoV13dUrT30loChG8gP0GmZsT1qj6Qfdm6L5Se48UjrdKn7IGKi/s7 g6UcmE9PO049NHX0sHlN3rhfA9Brei4YlRgZjxymjSW3MrZeJecBgsE9DPNb4Wt3psfxJUO8671 yU4BL65t67DBMARTa0pd9ErSJ/icz0n1v6lmhBhIeo7NYFJDTrKbktY0UoVm0lELxTagQJptqS0 VH9MhPVDtIMeMWJDqJyi+90E0SlN/TgaYlMUfCqRpjs+KM9WGFrik3/oY6PQ8R3+XMO66PckN5a vVTW+Pq7STSd9yhXhiZknGnV0Hs9Q/yCaNbYfKhCP7dY0jmDyezaz45ZEA3w5LCIIVoyMMiQxne JKEGcVDknTKnn/IbuoxL/lsrqCgIsRQNn45yiAc0nCtRsUTw9fM5nz86ZSOF2mMrT3MWZ3QZzxb evl8VZKRZH63X+n0/n3Bbaz3s3Y93jyg== X-Google-Smtp-Source: AGHT+IH/N+aVMoko0Ljwne1G9ZENkLSuGyOYI3i6mt3tOjPQLbGKcHMrOSVqM6rtfcLFr+1EcXdrUA== X-Received: by 2002:a17:907:3e0e:b0:b73:2b08:ac70 with SMTP id a640c23a62f3a-b80371ad2eamr767096266b.49.1766320518923; Sun, 21 Dec 2025 04:35:18 -0800 (PST) Received: from localhost.localdomain ([2a02:a31b:20c3:6680:4cc9:1698:dce5:4976]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8037f13847sm736591666b.57.2025.12.21.04.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Dec 2025 04:35:18 -0800 (PST) From: Dmytro Maluka To: David Woodhouse , Lu Baolu , iommu@lists.linux.dev Cc: Joerg Roedel , Will Deacon , Robin Murphy , linux-kernel@vger.kernel.org, "Vineeth Pillai (Google)" , Aashish Sharma , Grzegorz Jaszczyk , Chuanxiao Dong , Kevin Tian , Dmytro Maluka Subject: [PATCH v2] iommu/vt-d: Flush cache for PASID table before using it Date: Sun, 21 Dec 2025 13:35:08 +0100 Message-ID: <20251221123508.37495-1-dmaluka@chromium.org> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When writing the address of a freshly allocated zero-initialized PASID table to a PASID directory entry, do that after the CPU cache flush for this PASID table, not before it, to avoid the time window when this PASID table may be already used by non-coherent IOMMU hardware while its contents in RAM is still some random old data, not zero-initialized. v1 -> v2: Add Fixes: tag. Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency") Signed-off-by: Dmytro Maluka Reviewed-by: Kevin Tian --- drivers/iommu/intel/pasid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 3e2255057079..77b9b147ab50 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -153,6 +153,9 @@ static struct pasid_entry *intel_pasid_get_entry(struct= device *dev, u32 pasid) if (!entries) return NULL; =20 + if (!ecap_coherent(info->iommu->ecap)) + clflush_cache_range(entries, VTD_PAGE_SIZE); + /* * The pasid directory table entry won't be freed after * allocation. No worry about the race with free and @@ -165,10 +168,8 @@ static struct pasid_entry *intel_pasid_get_entry(struc= t device *dev, u32 pasid) iommu_free_pages(entries); goto retry; } - if (!ecap_coherent(info->iommu->ecap)) { - clflush_cache_range(entries, VTD_PAGE_SIZE); + if (!ecap_coherent(info->iommu->ecap)) clflush_cache_range(&dir[dir_index].val, sizeof(*dir)); - } } =20 return &entries[index]; --=20 2.47.3