From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794814704; b=1y61uhIVvrMLvjjpu7vEPODMxIPMki1fn3AFL4iPjf+psNNAAphK3W0qwf/oSymkxBf6 mCnDiklI3B3p/PuM58orDB2Vik/c2InD2sWAlxjbLK9849gThXMG/bHqku/FUFD7ovJCo qLhkoOviIZ0y5x+jMSh7v2YwQfB8zHGD0P0m9SJq3trc3E+6z9CBQ29sZ+foBdMVWdo9u CkW9FH72ZrYFgnaM7EjlHkDis/wKHxsAZQJOlCkVZ//HN1N2PHZMi9wBp2T7Cc/TELME5 kobPAPleiszy8UCRcXVOtknn6nyTZNP+ibL4bs6hwWAysocVDTua5UA+Rlk0DbbEboA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794814704; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Message-ID:Date: MIME-Version:User-Agent:Cc:Subject:To:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=pI+qB/jORBsA8c6hsUYOeeDt5LaDuCmT+exW9sgyzwo=; b=vTN+utaggqu4OX0D5o5Eh6uwSkYmYGPBse+iUqGmefsk3ZfssqNHlwhzFi+Do7905PVs Eqdy8fiADwtAp0dAbVmhLq/go7N/4/2TS39V1imnE2+JwCBo4ljZo6eYWW7sbXSzZJwDD +AXlTCHQHaPUdpsUrNlEKAYyUWtmxQafWdAEOu+9HOdMrj3mi+rb7nnz69IzOtCAdckmv 0T91sMhheuSE/ewbNnD5bvCgiRXoF7lPHQCcM4t5PGNypLacvdiy5H5D2GR15fd7x3Axh ia0lUh0WqviIGny0Hccp+Mvb4bB1/qXdViyfTH5nth5Ul/JNA5LAmoSAqWzB4ixp4Qw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b="VjP92/Gl"; arc=none smtp.remote-ip=198.175.65.19 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4127606A329; Mon, 16 Nov 2026 07:38:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B4127606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VjP92/Gl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1794814703; x=1826350703; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=VCBdU3HmJwCtXAadN2uCRp5YZw+Cf4Kdztj+N3BY2z4=; b=VjP92/GljPoN8MOjryJBcKXQLhDwucxDUhnGJpDQdVxRwwwljIMoHmbx +bwGkow9H4wRxCnQAg2SIeutQO+VPVZKkIp4N6ljk9nvjn6h7HvrSwpls 8qfX5WaHFiqL/Ba9YKPgMC8CCD8CJBOxZJYjYaTOGzYdnOA+kwSRjekOI s2dgwbBq+yB1J21B/rGcNmpotYdmLtEpQIfNmTPZcukyIR/jppQkAnM4o z9UXfMVhPaPkzl8KY2xol+Ztq82wTD/QHIB/+aBtgE1NupQqxarU3i9nq hxAE50Yj3M8JpQjo62fYbpavuOUzlsZecVVe8Z010f02fIGHI4NBRxc06 g==; X-CSE-ConnectionGUID: PVr9x0ymTdCOcr0s6Sz+5A== X-CSE-MsgGUID: EPyOmTjGQDuh5kDlHljNVQ== X-IronPort-AV: E=McAfee;i="6800,10657,11967"; a="3582034" X-IronPort-AV: E=Sophos;i="6.27,216,1787036400"; d="scan'208";a="3582034" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2026 23:38:22 -0800 X-CSE-ConnectionGUID: zin4g8rdTdGww90ZxyGBNg== X-CSE-MsgGUID: ckScDyXfR6eMSDFDs7pkTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,216,1787036400"; d="scan'208";a="9798707" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.124.249.52]) ([10.124.249.52]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2026 23:38:17 -0800 Message-ID: <7ef6d626-4920-434f-bbd9-eda46e7ab780@linux.intel.com> Date: Mon, 16 Nov 2026 15:38:14 +0800 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, Robin Murphy , Kevin Tian , Alex Williamson , Shuah Khan , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Pratyush Yadav , Pasha Tatashin , David Matlack , Andrew Morton , Pranjal Shrivastava , Vipin Sharma , Ankit Soni , Nicolin Chen , John Starks Subject: Re: [PATCH v7 13/18] iommu/vt-d: Handle reattach of the restored domain To: Samiullah Khawaja , Joerg Roedel , Will Deacon , Jason Gunthorpe , David Woodhouse References: <20261110040828.1774343-1-skhawaja@google.com> <20261110040828.1774343-14-skhawaja@google.com> Content-Language: en-US From: Baolu Lu In-Reply-To: <20261110040828.1774343-14-skhawaja@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/10/2026 12:08 PM, Samiullah Khawaja wrote: > Reattach the restored domain to the preserved device using restored > domain ID. While reattaching do not setup the context and PASID entries > as those are preserved during liveupdate. > > Note that in this phase nothing clears IOMMU_SER_FLAG_INCOMING of the > restored domain or the restored state of the device, so the restored > domain cannot be replaced yet. Replacing it is left to a later phase. > > Signed-off-by: Samiullah Khawaja > --- > drivers/iommu/intel/iommu.c | 28 ++++-- > drivers/iommu/intel/iommu.h | 14 +++ > drivers/iommu/intel/liveupdate.c | 141 +++++++++++++++++++++++++++++++ > 3 files changed, 175 insertions(+), 8 deletions(-) > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > index b3402fd9fe75..95ec37554360 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -3296,6 +3296,9 @@ static int intel_iommu_attach_device(struct iommu_domain *domain, > { > int ret; > > + if (dev_iommu_restored_state(dev)) > + return intel_iommu_attach_restored_device(domain, dev); How is the restored domain's type and page table format selected? I don't see the allocation path using the preserved state to choose between different domain type and page table format. Could this result in a mismatch with the hardware configuration? > + > device_block_translation(dev); > > ret = paging_domain_compatible(domain, dev); > @@ -3426,7 +3429,8 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev) > info->iommu = iommu; > RB_CLEAR_NODE(&info->node); > if (dev_is_pci(dev)) { > - if (ecap_dev_iotlb_support(iommu->ecap) && > + if (!dev_iommu_restored_state(dev) && > + ecap_dev_iotlb_support(iommu->ecap) && > pci_ats_supported(pdev) && > dmar_ats_supported(pdev, iommu)) { > info->ats_supported = 1; > @@ -3531,12 +3535,16 @@ static void intel_iommu_release_device(struct device *dev) > struct device_domain_info *info = dev_iommu_priv_get(dev); > struct intel_iommu *iommu = info->iommu; > > - iommu_disable_pci_pri(info); > - iommu_disable_pci_ats(info); > + if (!dev_iommu_restored_state(dev)) { > + iommu_disable_pci_pri(info); > + iommu_disable_pci_ats(info); Above changes are not needed for domain reattachment, right? My understanding is that ATS and PRI are not supported for preserved devices in this phase. If so, could they be split into a separate patch? > > - if (info->pasid_enabled) { > - pci_disable_pasid(to_pci_dev(dev)); > - info->pasid_enabled = 0; > + if (info->pasid_enabled) { > + pci_disable_pasid(to_pci_dev(dev)); > + info->pasid_enabled = 0; > + } > + } else { > + intel_iommu_detach_restored_device(dev); > } > > mutex_lock(&iommu->iopf_lock); > @@ -3544,11 +3552,15 @@ static void intel_iommu_release_device(struct device *dev) > device_rbtree_remove(info); > mutex_unlock(&iommu->iopf_lock); > > - if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev) && > + if (!dev_iommu_restored_state(dev) && sm_supported(iommu) && > + !dev_is_real_dma_subdevice(dev) && > !context_copied(iommu, info->bus, info->devfn)) > intel_pasid_teardown_sm_context(dev); > > - intel_pasid_free_table(dev); > + if (!dev_iommu_restored_state(dev)) > + intel_pasid_free_table(dev); > + else > + kfree(info->pasid_table); > intel_iommu_debugfs_remove_dev(info); > kfree(info); > } Thanks, baolu