From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 A22963ED3B8 for ; Wed, 20 May 2026 18:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300160; cv=none; b=qQTdH/gdwUX0msPletRTq+9FYrXANvp9SdgAxHY4VswpMy2Sg0H6QNt4Hm9EYA027RTDkHVlUnfvyLmraVPLgC5xna63HQRZjsMDZJCBz/Fm2iGUgm63M/lFf/dNAi1vHMq58iDhN8r/Rddtt5Qn9LwWIPti80pK0Ym+prLU8ng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300160; c=relaxed/simple; bh=gSR9ZF8mEMkIrcPGA22VrdnTF1lx5yIEAf4xXGH2nlo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mytDQnnIUzF8vCBzp9tFVk0otFbfHJk9I1dcyeKdQ9NLCHB0MlX1WHfxMziuvzjXlCIit/lujCMnJEwo4toUvqzJNDU+XksPuGtJWcIwwe5XUpEJWgeZJQPd+WbRfn/B2xvZM3K/UDy2a+x8OuBQRvUHrzJdUJ0Ag+nCWZsJxVE= 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=Jlv/ydKo; arc=none smtp.client-ip=209.85.214.178 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="Jlv/ydKo" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2ba180a022dso4715ad.1 for ; Wed, 20 May 2026 11:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779300158; x=1779904958; 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=wKj2nsEFhwe3iqBMbsJt9SioFDYUGDCac39gv/hs+vE=; b=Jlv/ydKos+5C8eESq9DBs8tkE2stSoX5Yhg/En0j/ouRXkEPpPPe56b/CLg+eN8Zwl ZLy4w7smEfBmP2lnbDCEl0jp3m/hVai9G+HlbBY4Py9/yf7r/f8ROrZhwIeVHF3hYK4m 5n1+7sN7LlGWiDSa2SukyP4L8h39KZjDzvIlGB3t3QnpHVfRFgepNfcwc0wfM+XwP2Ik JpQHJ40FMddVhIMMH+QZ1kMv29n6mLlifvXUn22KRCep1uEccdcWywPEvC7aSiff6MXN NwQJAvZ3mwKwDZZ7LwiYYfkhgxHY+b/iw+4h2Fjyldzbxs8DY1mYta3LS2jASKeAjh0Z 7KLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779300158; x=1779904958; 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=wKj2nsEFhwe3iqBMbsJt9SioFDYUGDCac39gv/hs+vE=; b=g6zuTaDOUCYnqyq/oPFhbJ0Rmugds13LJw+0KNYdjAY7P2txodXITrT1fVm+A200oJ lbBB5SMstW2OmaUmWk4Uj8BQruuTs9Qa2Vr6Qo78WzmJl2bAs0PvTXDgUhyMEDMWy+oJ SVmhX17i7F4PQILvja6iRAU1YdawVxlhbtf15OCE1nFMNXGwOtPgACu35eIccl71jn50 wQKdWBug1M1VE0uZ0VRaBOWKmrdR3Z7qM44BdkaT/a+zTC+SeJzQbFSBWmIU/vr/iqrY nwuTxmR34o+N0Iuu5tMhZj/R4ddNsj1kxPPXzvWNZUMI3zrMFDWTetABxvPs1RAh9/6h W+wg== X-Forwarded-Encrypted: i=1; AFNElJ8o0Ahh2DcPEZ3gcAaZSMkbw0Tk9WOXk0HXMbpNp72VMehv/mbAz65ek/5s6yT1wqdBCHeH8WgSC6euKuo=@vger.kernel.org X-Gm-Message-State: AOJu0Yxa0ka92+cwLrpQhRyFcPri0TCHg/0qsF5aqUdRA3cEi3RX3pb7 CnoHR039uSQbFnCqt3ppNqmH23aTzg0nuPbY+5iMUm2SlBHkHp4IRiH/isyy4qogSA== X-Gm-Gg: Acq92OETn+SQXDHdzaQdiqRQWiR28WLNK7l2I3mT+Gwoz4gd7+SPVY9q6Ok4L01flje Ya3/N0dzCrFWgYBYcRHtAn76kN/rt4u9rcdBKz7RuEJIZlDqU0DA2mpzhg5iiAtlDBAYB+O86SU N+yvKcIC94p6RIc9MvsoHWlrcKKMRpbMh0GhJN//8qT8ETn/cvFlvWNHHtbptPK2vWvkINFVaA9 0ZrgSNTBIrSvLmUFkfMKHGGy+fF27j8QqBTgaOjMqIlFRBjQ4fGYF/KePLM4Sz4ufgVSSBkJKYG 3iXXU9dsYj4vdFOE5r+0TrG4yavGmcmGcuaZti8BL0mlbcR16Az3VX8omrH4CrIpaO1YXgu1HuQ Ty7OjDOtdpSgdlvINfR7R9e1dcXu2fFiam5PFmDZ+5eH+inYPOnpjmPRXmGgA7MyIH1ElCfoiMG eDoljLISmiriAhKovTSZmwYAwqBuBRqU3C558mzHaH1M4OOJ2kiQ1VTMwDTI/cG0AXzkSj X-Received: by 2002:a17:902:e749:b0:2bd:6dad:7cca with SMTP id d9443c01a7336-2be9f4474a0mr220335ad.22.1779300157257; Wed, 20 May 2026 11:02:37 -0700 (PDT) Received: from google.com (44.234.124.34.bc.googleusercontent.com. [34.124.234.44]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c82bb0ff0edsm20807015a12.20.2026.05.20.11.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 11:02:36 -0700 (PDT) Date: Wed, 20 May 2026 18:02:27 +0000 From: Pranjal Shrivastava To: Samiullah Khawaja 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 , Vipin Sharma , YiFei Zhu Subject: Re: [PATCH v2 09/16] iommu/vt-d: Restore IOMMU state and reclaimed domain ids Message-ID: References: <20260427175633.1978233-1-skhawaja@google.com> <20260427175633.1978233-10-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 Content-Disposition: inline In-Reply-To: On Tue, May 19, 2026 at 09:46:52PM +0000, Pranjal Shrivastava wrote: > On Mon, Apr 27, 2026 at 05:56:26PM +0000, Samiullah Khawaja wrote: > > During boot fetch the preserved state of IOMMU unit and if found then > > restore the state. > > > > - Reuse the root_table that was preserved in the previous kernel. > > - Reclaim the domain ids of the preserved domains for each preserved > > devices so these are not acquired by another domain. > > > > Signed-off-by: Samiullah Khawaja > > --- > > drivers/iommu/intel/iommu.c | 55 ++++++++++++++++++++++-------- > > drivers/iommu/intel/iommu.h | 7 ++++ > > drivers/iommu/intel/liveupdate.c | 57 ++++++++++++++++++++++++++++++++ > > 3 files changed, 105 insertions(+), 14 deletions(-) > > > > if (translation_pre_enabled(iommu) && !is_kdump_kernel()) { > > iommu_disable_translation(iommu); > > @@ -1648,7 +1661,7 @@ static int __init init_dmars(void) > > * we could share the same root & context tables > > * among all IOMMU's. Need to Split it later. > > */ > > - ret = iommu_alloc_root_entry(iommu); > > + ret = iommu_alloc_root_entry(iommu, iommu_ser); > > if (ret) > > goto free_iommu; > > > > @@ -1732,8 +1745,12 @@ static int __init init_dmars(void) > > > > free_iommu: > > for_each_active_iommu(iommu, drhd) { > > - disable_dmar_iommu(iommu); > > - free_dmar_iommu(iommu); > > + iommu_ser = iommu_get_preserved_data(iommu->reg_phys, IOMMU_INTEL); > > + > > + if (!iommu_ser) > > + disable_dmar_iommu(iommu); > > + > > + free_dmar_iommu(iommu, iommu_ser); > > } > > > > I'm wondering what happens if init_dmars fails for a preserved iommu? > Since we have non NULL iommu_ser, we'll skip disable_dmar_iommu and skip > free_context_table() inside free_dmar_iommu() as well. I'm concerned we > might leak some resources in this case. If the failure happens after we > set restored = 1, even a rmmod -> modprobe cycle won't help fix the leak > Re-visiting this, I think we don't need to worry as skipping restore is the intended behaviour.. we don't wanna attempt restore on things that have already been restored. Please ignore this Thanks, Praan