From patchwork Thu Feb 8 08:23:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 198200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp21214dyd; Thu, 8 Feb 2024 00:25:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZZaSBoZqPu7ZWcsQzjbbAaJBX63Xi85/k5259v7crLjpiOYqGwdTmMsUQKyY9ZLEMJx99 X-Received: by 2002:a05:620a:450e:b0:784:bc4:ff8f with SMTP id t14-20020a05620a450e00b007840bc4ff8fmr10631971qkp.56.1707380757425; Thu, 08 Feb 2024 00:25:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707380757; cv=pass; d=google.com; s=arc-20160816; b=v82D/0S4UsIjfkIiSod0le8mECVrZv8OLhcd0b4Qo/M6qRdHxm36JoMeUu5IMJD6Px vn+Uwgq8NLv8i9OufpJijDrDtta8veYuYvzhg8mf1c54v/KPaXb/60wSwqcoB2Ekw8EQ Q9tS//9XnEFVdIARK7XsOCAtQKWWxxi5rqeNDrolLirk5m4pwvOBndp3REjRqNv3Kc5S nPpb0VYw5gRHdoDMUc12YyrxmhS5/KNc7UHmB/DL4IInMC5ij1AjzszRRWMUg1tQYOKX ZqLmYpIKiIWzzsl8Fd718ISgcdu2ksM8ayQ6TVS/u2IQlk7modPsCsQJ6ewW2nT1tzHr oG2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gkZScmukzMIIlZ8akkLfw2oxwV2MXTvC/ijpZdc/slU=; fh=ulASIXfObfiElgjSYTdp3b9cZLKU3DxxZmwJEYUYU7Y=; b=kL/S02/H5/Yhzf4vLppa4dhqHyqn32FSYIIjmzZ+rM58TcOO9yUvS9v0ddsXCN7KIO 5qEa8kgop8+1DfgUzUsZSKhWnRCgL2m3E9HxIK5QcHlwPZ9avU+FpHfUd6ifb284CYcP kXlADjH0jlYIQn5ai2FjOVRJq47jzDn53M7cy0dKN2Ju1LHoMJU9goXlpCcotLj2qWP8 yXzXt3XuMv4UpX0Qeh6+3llygEK/Ja86xDAhoXoLxV/1abI2hmibBkf5mnDfGr/hLbH4 vfo8NgFELyZ78HGkzNHPhO4wxoXkCroPNZGTCfmdHZbd+Eel0JMkah8bzh1qzVBo9+6G 7b4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iEoxwlqx; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-57608-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57608-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWA1Tc41ruwy0jdg4T2ZemYk/pHqPxHJXREnU/FgXqxhrrM0yHE6oA0Vzj0Y2GxezzoPhds6R2rk+MUcyUb+IRa1iROmw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h12-20020a05620a13ec00b007833d053697si2752247qkl.658.2024.02.08.00.25.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:25:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57608-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iEoxwlqx; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-57608-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57608-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F31201C214EE for ; Thu, 8 Feb 2024 08:25:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 374FA6EB44; Thu, 8 Feb 2024 08:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iEoxwlqx" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 D357F6A35C; Thu, 8 Feb 2024 08:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707380596; cv=none; b=JbcJEJYhZFNxA4hd/2OWs0oGYjBKCz0arwSuMcF8HtgD108RTrX4BawlGM1UZuab07xuua5bXhYJvjkajzmRmk9RQnLFgU5xd6o7oeWDFXghyD1yjcByD7p01KZ7e/sr1wwAZu4PUvJ73uNSun60W4CTjYyuju2pbE31fMti3zw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707380596; c=relaxed/simple; bh=WWbaez9ncxln4TMS8ZatinCzJo3/RSqN211StWyg4QA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q3FWOG1d7iy0XuJ6hWXIOB5ij6j4Tph02NsOWNXQTSvgVYWxDL2bIRRU3C0VSbICwXQvhgS3ofeJTdv1nPpfTFrI1oWXFKP9bWfDxiplr1S6fKwIF1Ah2V2aVevpiq78vp3fWKicsfoTMJ4eQ9YuhHFLtvaHdlT2BixRMGOhd58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iEoxwlqx; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707380594; x=1738916594; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WWbaez9ncxln4TMS8ZatinCzJo3/RSqN211StWyg4QA=; b=iEoxwlqxiq9sXumlxd80B1YfEd8WYzYJd6TOUgnRfiqpm6+kRDrz+u3i U6rFg1Tki/Srv3S/YlHMznA9nkb9QhLy1sRK24Fc57vfcKkYtOp4gwI2X UMolKbCBt7GkTUtWu9AoiN3DH+eRNGTLfCOOZJb6U6xNN0MaKVw1qclID enrLVWGLQfUHzncAD/gmfnnv839MhRqiUwGJ6evZJBhHQVfX//SVwxV1j gmCYDC30bcF4ZnkjI5xJJ0eC32vPMEdSGA9oZj/vXKF7/T3UJ6G0p9s8J 9DN8b7ar1Owwlab2IL9YyvFhOXSwMgUvWzMV9gpeeUiXhgKVSugsnIi4r A==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="5036327" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="5036327" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 00:23:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="6252118" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orviesa003.jf.intel.com with ESMTP; 08 Feb 2024 00:23:13 -0800 From: Yi Liu To: joro@8bytes.org, jgg@nvidia.com, kevin.tian@intel.com, baolu.lu@linux.intel.com Cc: alex.williamson@redhat.com, robin.murphy@arm.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, yi.y.sun@linux.intel.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, zhenzhong.duan@intel.com, joao.m.martins@oracle.com Subject: [PATCH rc 4/8] iommu/vt-d: Update iotlb in nested domain attach Date: Thu, 8 Feb 2024 00:23:03 -0800 Message-Id: <20240208082307.15759-5-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240208082307.15759-1-yi.l.liu@intel.com> References: <20240208082307.15759-1-yi.l.liu@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790318484659723106 X-GMAIL-MSGID: 1790318484659723106 Should call domain_update_iotlb() to update the has_iotlb_device flag of the domain after attaching device to nested domain. Without it, this flag is not set properly and would result in missing device TLB flush. Fixes: 9838f2bb6b6b ("iommu/vt-d: Set the nested domain to a device") Signed-off-by: Yi Liu Reviewed-by: Kevin Tian --- drivers/iommu/intel/iommu.c | 4 +--- drivers/iommu/intel/iommu.h | 1 + drivers/iommu/intel/nested.c | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 46174ff5ae22..b1ceebe13107 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -396,8 +396,6 @@ static int domain_update_device_node(struct dmar_domain *domain) return nid; } -static void domain_update_iotlb(struct dmar_domain *domain); - /* Return the super pagesize bitmap if supported. */ static unsigned long domain_super_pgsize_bitmap(struct dmar_domain *domain) { @@ -1218,7 +1216,7 @@ domain_lookup_dev_info(struct dmar_domain *domain, return NULL; } -static void domain_update_iotlb(struct dmar_domain *domain) +void domain_update_iotlb(struct dmar_domain *domain) { struct dev_pasid_info *dev_pasid; struct device_domain_info *info; diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h index 9b27edb73aa9..4145c04cb1c6 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -1066,6 +1066,7 @@ int qi_submit_sync(struct intel_iommu *iommu, struct qi_desc *desc, */ #define QI_OPT_WAIT_DRAIN BIT(0) +void domain_update_iotlb(struct dmar_domain *domain); int domain_attach_iommu(struct dmar_domain *domain, struct intel_iommu *iommu); void domain_detach_iommu(struct dmar_domain *domain, struct intel_iommu *iommu); void device_block_translation(struct device *dev); diff --git a/drivers/iommu/intel/nested.c b/drivers/iommu/intel/nested.c index 42d4d222e70f..f068ecf72f5a 100644 --- a/drivers/iommu/intel/nested.c +++ b/drivers/iommu/intel/nested.c @@ -65,6 +65,8 @@ static int intel_nested_attach_dev(struct iommu_domain *domain, list_add(&info->link, &dmar_domain->devices); spin_unlock_irqrestore(&dmar_domain->lock, flags); + domain_update_iotlb(dmar_domain); + return 0; }