From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 387AF378833 for ; Fri, 29 May 2026 17:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780074215; cv=none; b=XuIlDRPDwkD/QRfvK+6oOCV8ugygSZlxEp6SWtNeZOc1bU5d3I8JKOf28V0p1rxo5W5xX60K6+KTta5wyFbenvDmW/GVQDXVnUH9zHN2I2Wy51LraxrNehZydC6YxrABJmzC2mhBWIDsCNwd8PBpsMhcBb5zzKuFCXOXCvoC02g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780074215; c=relaxed/simple; bh=uYdO0Zb0EMGnJnig6FT1XOpGRq5xI3F+BHn+7Ktj+UE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Hlc1/8yPrd0mJDPX2hGCXrWOjlCOVNHqI9nMVs0W3yg72HllzMkWmGgFhvzzx3mTkgYu0/2FQcV5w7rHKUs/fsfJ7pYxTQ6Q2jYfY0DrUJoWav4zoRx4uCtPhgpueqTBFHTrb+MUp5EXG0BGrFcLsemM+z0wrSXyHHwHRC5LnkI= 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=bbfxgCb4; arc=none smtp.client-ip=209.85.214.179 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="bbfxgCb4" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2bf2d865383so1675ad.1 for ; Fri, 29 May 2026 10:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780074213; x=1780679013; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IvcYM9yAFt1S3eUjneK8l3ddApYMEHlD7c1/gPxFFF8=; b=bbfxgCb4syHnfSlErVKpjuTZJFRDGn9xRhcE6hUv9NRUuI9/V4LG+4ySnHRB5/7YTv IkCy7mqkVrZQAdSHzg8IqmDpDJ/v0+utz4tb2meOfqQmNPvsUhQ9Sgl9bXZ0F7PrwXzr 4FIzqChv2AeWoapIu5zJzmYTSkuRDsgCJKOPeYsWgDilJuHzG1bZWCjlO9a3CYuIxcGO FAEpJGnb0xGoYedz8QEiAr6UqjFYfYj/RkEwgC911o/20m6G1Es38jc+3NArsWdMOfLG JOX2P82A23p2YstHHfaU41xECxIynKkiOdJd3R7jhKu2WfUqLfRPcIdAEIC/6uiG7Jp2 Mkbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780074213; x=1780679013; h=in-reply-to:content-disposition: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; bh=IvcYM9yAFt1S3eUjneK8l3ddApYMEHlD7c1/gPxFFF8=; b=T4gXhcUBebr9FeM8H7aabpmS3amNORPrh/8qllW6aaHNsMkTAE4K40zjS/xuJE1Hcs CJ0YROCB+8ZYRSoKuDbyfb4Pf9eGxnZ3EO6PKPhmliL1jBx+dAZsv9osaE3eqKQT6fdJ S3z+uPF/xDkGq1mkP52DDOZuyDF0TnteuK9vgM0kRq5BqnS6NcCyEoDSutEzQgmR2NUP 8///l/zWac3ic81HaZRsxvGUKGXpeo58uuKswmMOO4/78poSePN8xFCif+Rskl3NRy4O fYS0iyxuHBPwZjtlXJZ4bWwmParjQrM3fHO2J4BbmNNcZiEOfQ6eUH2ZrQzLESUWwP0I CeBA== X-Forwarded-Encrypted: i=1; AFNElJ96D0CVZ7HnBqYdwH9AoWLfQgE7r7DDga4QCUfe+SR1ctK74uhEblt1ZP3YhdjnHPEV/GjI6rZSWL0Xzfo=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8mcn0Oo761BGgbNLzHfsDOQ3mzSSSvU6NRFBFjyC7k9PIid57 4dsmARAMAbNsytadxBaES3tv9wDboyHHtpLLMQP6kU2PHQpeTgHGdv/ZLK69W1TayA== X-Gm-Gg: Acq92OF0duNMGlt3ru5gByonqF/7jsA1O8C5Q1gmKg8tS6cPdv8Uq5RV3JHb/fy0lI7 ctk1QqbLKdEJfofYY4m7v8ucf+pQQyAI8N3VPmvPdi2f7RQokOMT+LKVlMW47vH5ztMbZZ2qkQn HF1bEjvlau8c3jWIkVjNQijq8rQe+ejp9StG94haTKngB1KOiPk1V+tQxiPh/Gd48soHW8eIUVk AKikKOYZ1rTAWM7PoI73naq/NYQE/3fEzqVH0PPIKIjxxkiLdlEB3L1h+fGsCXinFKZUxB/fsGq fzv6Dl7WsUQuh8Qc/3I3Jxo4LvD2nvU2qIDxXWW+Mxw+s4lIpW+ohKYg2OCvPYbn6OMS/3uFTj5 uCoPDVr+5WN3Hp/jJaiKAvAwcV4VCs6tU6gPhbAv0OQuUI+PdSx7I0yEjdHT++UmSN0ieXe/0i+ BWR9aY8fsFrDWQ8k/rcJgUbT2Py9aRYVloRps6d0LB1V7lZoomeEGmyHIzJVLEi8d+g3v+lQ== X-Received: by 2002:a17:902:e889:b0:2ba:4749:c9a2 with SMTP id d9443c01a7336-2bf97507257mr30445ad.2.1780074212695; Fri, 29 May 2026 10:03:32 -0700 (PDT) Received: from google.com (153.46.83.34.bc.googleusercontent.com. [34.83.46.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bf23a10165sm24198555ad.31.2026.05.29.10.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 10:03:32 -0700 (PDT) Date: Fri, 29 May 2026 17:03:28 +0000 From: Samiullah Khawaja To: Ankit Soni Cc: David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Jason Gunthorpe , Robin Murphy , Kevin Tian , Alex Williamson , Shuah Khan , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Saeed Mahameed , Adithya Jayachandran , Parav Pandit , Leon Romanovsky , William Tu , Pratyush Yadav , Pasha Tatashin , David Matlack , Andrew Morton , Chris Li , Pranjal Shrivastava , Vipin Sharma , YiFei Zhu Subject: Re: [PATCH v2 10/16] iommu: Restore and reattach preserved domains to devices Message-ID: References: <20260427175633.1978233-1-skhawaja@google.com> <20260427175633.1978233-11-skhawaja@google.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: On Fri, May 29, 2026 at 04:43:42PM +0000, Ankit Soni wrote: >On Mon, Apr 27, 2026 at 05:56:27PM +0000, Samiullah Khawaja wrote: >> Restore the preserved domains by restoring the page tables using restore >> IOMMU domain op. Reattach the preserved domain to the device during >> default domain setup. While attaching, reuse the domain ID that was used >> in the previous kernel. The context entry setup is not needed as that is >> preserved during liveupdate. >> >> Signed-off-by: Samiullah Khawaja >> --- >> drivers/iommu/intel/iommu.c | 49 ++++++++++++++------ >> drivers/iommu/intel/iommu.h | 3 +- >> drivers/iommu/intel/nested.c | 2 +- >> drivers/iommu/iommu.c | 61 ++++++++++++++++++++++++- >> drivers/iommu/liveupdate.c | 78 ++++++++++++++++++++++++++++++++ >> include/linux/iommu-liveupdate.h | 50 ++++++++++++++++++++ >> 6 files changed, 224 insertions(+), 19 deletions(-) >> >> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c >> index 4118a0861f38..b90757164cd8 100644 >> --- a/drivers/iommu/intel/iommu.c >> +++ b/drivers/iommu/intel/iommu.c >> @@ -1031,7 +1031,8 @@ static bool first_level_by_default(struct intel_iommu *iommu) >> return true; >> } >> >> -int domain_attach_iommu(struct dmar_domain *domain, struct intel_iommu *iommu) >> +int domain_attach_iommu(struct dmar_domain *domain, struct intel_iommu *iommu, >> + int restore_did) >> { >> struct iommu_domain_info *info, *curr; >> int num, ret = -ENOSPC; >> @@ -1051,8 +1052,11 @@ int domain_attach_iommu(struct dmar_domain *domain, struct intel_iommu *iommu) >> return 0; >> } >> >> - num = ida_alloc_range(&iommu->domain_ida, IDA_START_DID, >> - cap_ndoms(iommu->cap) - 1, GFP_KERNEL); >> + if (restore_did >= IDA_START_DID) >> + num = restore_did; >> + else >> + num = ida_alloc_range(&iommu->domain_ida, IDA_START_DID, >> + cap_ndoms(iommu->cap) - 1, GFP_KERNEL); >> if (num < 0) { >> pr_err("%s: No free domain ids\n", iommu->name); >> goto err_unlock; >> @@ -1320,10 +1324,14 @@ static int dmar_domain_attach_device(struct dmar_domain *domain, >> { >> struct device_domain_info *info = dev_iommu_priv_get(dev); >> struct intel_iommu *iommu = info->iommu; >> + struct device_ser *device_ser = NULL; > >Typo here? iommu_device_ser. >compiles because dev_iommu_restored_state() returns void * and the >variable is only null-checked, never dereferenced. Agreed. Will update this. > >Ankit > >> unsigned long flags; >> int ret; >> >> - ret = domain_attach_iommu(domain, iommu); >> + device_ser = dev_iommu_restored_state(dev); >> + >> + ret = domain_attach_iommu(domain, iommu, >> + dev_iommu_restore_did(dev, &domain->domain)); >> if (ret) >> return ret; >> [snip] >> static inline struct iommu_hw_ser *iommu_get_preserved_data(u64 token, enum iommu_type_ser type) >> { >> return NULL; >> -- >> 2.54.0.545.g6539524ca2-goog >> Thanks, Sami