From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.6 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796438709; b=cbs4kOsfmW1eL8MeyOAAOzMwzafSylRAn6zDc5U5PjA5EP2qv30pJKHrV/TJAN4PVShD bvAMFafX6ugpLOBU7ZLQVr6QtyXCm+q2PI1usT8fm+C78oybG3Po14Ks2bZlkm0ERxpPk 4+ayKOML8PbTLqkFHOrMTqq6afr53g79Av27qW2M04RZgaydCffh9HuQ6rzFuyXxQPwNO LPfmecLF6t9E14ePelJfqF9hH2J4MC1UMy4WWOBcjIZxRR6ztNh4Y2Pbtk2mTb6hoCueJ 9uUxM3eHpsFbvgIRBJ1ruQVguFCwzwyXzbNsinUhjEKRFcIKI/33K7+biEANr2rhldA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796438709; 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=wl0RFGWQBqrq/9YnYHADJdMb+NjBZ08aq21j10URN9E=; b=WpviZjSdbboIb9ikeDVICIcp+eeveMLcDLudAyebu1LqwOcJlB0I3jF5+voH2HP2rR16 jhgFHOFQjtQCL/3FbW/PA1VAhBJIPo28iIOw47UoSAlB8r6Uwjvnu6W3nPtwY1SASnXiB Xjv6mo5vTGKniPPf8oVu+75HqeH91wFN6RUbV49ka6mjWQEXabjkKtHCI09edaAbbIjQI Y28qg+Pzxix6s9ZuEtrOH2apbncTUCHjFoDsyyUYHqWzKhuIvTwIjKwZkTKG0ivCY1xax 3u30XbcmP/QPuFgQj+X6ighh9vJj5pndpQ2yj2bccR1lQsr3r++u6t0HcPpUu6t/rBw== 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=APPC9eql; arc=none smtp.remote-ip=192.198.163.6 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.6]) (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 D6B55606A332; Sat, 5 Dec 2026 02:45:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D6B55606A332 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) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=APPC9eql DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796438708; x=1827974708; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=Hy2JQ9lBYAaJKh/BEHw87afY8ns5uIw1c+9eIistQ3o=; b=APPC9eqlHbb4cvo89vQe9FtDpkujY73BmAzRR/le3ffKSQ+oLpp/1HYl EwDA+H9emEerbJg08tkJob+6/M8Sz1qhM7Jup6ji76BVC9FFsWorGKvnq UeQduay5qFUi732GR5Iz80bcT720JBHTgtKBIlY8keie/IUHzLft+fnIa N3WFPcz8pnpRrl4nJiArkGNWCMdjL0VS23UPdyaRDPcIIbP3OKehELQ9R jyF5MC1OdlcXTi3yalbDoWICPBorLszX7s/QFEFkHqh0eny6Mv9OfHPC0 +DG/e9ygaQ3siIfI/uzb4US9idqoz2UBeoxn3bs5ecuIZkDAWwgEDco9H g==; X-CSE-ConnectionGUID: T9PLuU4MTNCxbKLEj7J2sA== X-CSE-MsgGUID: T1i9j189TcODQ/atmVGe4Q== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="23932" X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="23932" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa116.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 18:45:07 -0800 X-CSE-ConnectionGUID: Rl+FBrYLRratLLCuX4K13Q== X-CSE-MsgGUID: Csu7gzCfTs+GCKNccPBT7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="14040628" 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; 04 Dec 2026 18:45:03 -0800 Message-ID: <833ec35b-e7c1-473c-a7b2-14ebda1f6aa5@linux.intel.com> Date: Sat, 5 Dec 2026 10:45:00 +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, Joerg Roedel , Will Deacon , Jason Gunthorpe , David Woodhouse , 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 v8 11/18] iommu/vt-d: Restore IOMMU state and reclaimed domain ids To: Samiullah Khawaja References: <20261123044949.3610702-1-skhawaja@google.com> <20261123044949.3610702-12-skhawaja@google.com> <8f1bb7da-9cca-422c-b046-b053c92ec9c5@linux.intel.com> Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/5/2026 8:03 AM, Samiullah Khawaja wrote: >>> @@ -2247,6 +2263,15 @@ static int intel_iommu_add(struct >>> dmar_drhd_unit *dmaru) >>>      struct intel_iommu *iommu = dmaru->iommu; >>>      int ret; >>> +    /* >>> +     * Hot-add of an IOMMU with preserved state is not supported. A >>> +     * preserved IOMMU is restored during boot, so it should never get >>> +     * here. >>> +     */ >>> +    if (WARN_ON(iommu_get_restored_state(iommu->reg_phys, >>> +                         IOMMU_SER_TYPE_INTEL))) >>> +        return -EBUSY; >>> + >>>      /* >>>       * Disable translation if already enabled prior to OS handover. >>>       */ >>> @@ -2689,6 +2714,33 @@ static __init void tboot_force_iommu(void) >>>      no_iommu = 0; >>>  } >>> +/* >>> + * Devices preserved across a live update keep doing DMA through the >>> preserved >>> + * translation tables, so the IOMMUs can't be turned off. Force them >>> on if the >>> + * previous kernel preserved any IOMMU state. >>> + */ >>> +static void __init liveupdate_force_iommu(void) >>> +{ >>> +    struct dmar_drhd_unit *drhd; >>> + >>> +    if (dmar_policy_on()) >>> +        return; >>> + >>> +    for_each_drhd_unit(drhd) { >>> +        if (!iommu_get_restored_state(drhd->reg_base_addr, >>> +                          IOMMU_SER_TYPE_INTEL)) >>> +            continue; >>> + >>> +        pr_warn("Forcing Intel-IOMMU to enabled for live update\n"); >>> + >>> +        /* No concurrent access to dmar_policy at this point. */ >>> +        dmar_policy = DMAR_FORCE_ON; >> >> This skips the precedence rules in dmar_can_force_on(). In particular, >> it overrides DMAR_FW_OFF, which no force_on may override. Please add a >> DMAR_FORCEON_LIVEUPDATE level to dmar_can_force_on(), document where it >> sits in the precedence, and panic if it can't be honored. > > See below. >> >>> +        no_iommu = 0; >>> +        pci_request_acs(); >> >> pci_request_acs() here comes too late for devices that have already been >> enumerated. > > Hmm.. the ACS configuration of the preserved devices should also be > preserved and pci_enable_acs() is called during driver probe so most > devices will get it. > > But this is still inconsistent and it can miss the non-preserved > devices/bridges that are probed before this point. > > Doing the force on properly needs the check in dmar_required(), so > pci_request_acs() is called early like it is done for tboot and platform > opt-in. That would require changing the point at which the KHO/LUO data > is available during boot. Basically this: > > https://lore.kernel.org/all/20261005064018.1558-3-Ankit.Soni@amd.com/ > > I think we can panic here if preserved state is found and the IOMMU is > not enabled, instead of doing force_on, and add separate patches later Sounds good to me. We only need to support it if a real use case arises in the future. > to add force on logic once the KHO/LUO stuff is moved early. This way > the pci_request_acs() will be done at the right time also. > > Note that doing a check here and doing a panic() is not too late as the > ACS configuration of the preserved devices (including their parent > bridges) is also preserved and the IOMMU state is also intact at this > point. Thanks, baolu