From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796247254; b=Gl+k8POVj0km5QmS4wGwJm7X+kFCr+TwlxGzEkJJcjL4KVUi1voiI3k9OhsAfFC0HnQU 04P8VcqCEtL06LUECbyQMiFy1ybn/ythWoHpNDd71oXrRJHj4PnB5IRdo7J7Fna3nN5y2 8znE0iL0t8JMjx2EgLlKZ3SwDcvEQ6pSdB2wpuAwaS+FfzkD52cXyEafcyRGr3nijP7rl XDRvlb4KMO6DnK82AxM5SJnhBK8CV9O+JbbHp+dvtvYz5RMtE3bCDlhUXfeFFzaH3VHrp MBt5SAmRZC1co0Dlrhx6k9Tp2M4hi0d1ijp5GquffUHW8cxDXN4wybkc23UORmD+IKw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796247254; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=6oxhCPT4ViiKPVjtX6772aKWHe19N9CAnngHXKZvTAs=; b=5J1MuLQ1VKK5bLG5w/ykN1G+DnZKQ+2AajKxTrPZMhzctwhqQ6ybNi5RSYljr7K9fRXW 5FTaE/amvXrT7BWIY7wUlXSdaB4NYvpnz1EydOd0g6lThp5oz/S9YHP0NCSwdaA+YlxKU Krq54KGPUb75kzwhuyQXOHo8gG+FTtGq849kEbbGoHVWmo5UfAplbbB7kXOxhbOc+ntZv 1jEG7A4i/MvyUJ9EzlGYo1pt540pbcpwqUoR3ocT9Ptv8sRhVLePf+DhOD2C2TPFp3HWN XWRh7+rRz8COxsqVB1pEOLBZIkpIHmJUzJJ/FXg8MU657co1gb+QzCsSsSYXZTkEatA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=YmH4qHrz; arc=none smtp.remote-ip=209.85.214.170 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F8C5606A32D for ; Wed, 2 Dec 2026 21:34:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5F8C5606A32D 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.a=rsa-sha256 header.s=20260707 header.b=YmH4qHrz Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2f0e8bbc7a4so5925ad.1 for ; Wed, 02 Dec 2026 13:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796247254; x=1796852054; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=6oxhCPT4ViiKPVjtX6772aKWHe19N9CAnngHXKZvTAs=; b=YmH4qHrzZ/mWIC9QDZSGBSrkvsonwE3PcXbvZiXd5Fl6D49vSxPDzwpeE0qbwla9ef gUCPHFPRcNOIl7T85U4/vtsnr85rOGkgrVRAoZVEmw8+tNog1T5Pq+sDUAgpW4c09ddd RDoHB6MNSgBFmYd6gHvJIw9W0rkfwQWz7hlBk5JA+VCYes9KdGZx3ljYf5so9P9QMZq1 ZqTn94Gzd+9mOnZqQBcSOS0CBBkPIlAQuF1wagw+9LFLefeKaauk1XeHfxx442In6Xny MxENRMq4FnIpfMRN5jHh3kQCRGO+TdQjvQZzrVTtUbUH6qAPFNrPmWpQJlT4M9Ie79X6 DprQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796247254; x=1796852054; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=6oxhCPT4ViiKPVjtX6772aKWHe19N9CAnngHXKZvTAs=; b=WS4tfWpMGAIqNAWm+hjAqeXdK8+wIAggVFnGKzO0Eb5toA/0c807iDtX4r3CElqBHH 3wUxPFx9+o4XET/DQ5Pay840ND13cYYFoZ75pQ/EWnqAH/FncnCGjWzVXzOdB4WNTNb/ so5xgxKP+XTc//doF0rLOyi9jDMDMM3VxEEHuWmUzSMVWYhIcvVSelJyFf9e8l0VFgPv Gh9ZaZcvc9vb9PR6wDR4sbE303imrc4wLUmdeevVI2UsWdJnnBgvXgVTWHnTRv1nSXD4 HGgKqngLxZe8WxuM0GUcdOg7PGVB6+UfoeHG8dm9AN3m0MCFT2t9IUp68ewNd8VAPYzl NGNQ== X-Forwarded-Encrypted: i=1; AL+hErFmeW9Tw0RxltU4Cg/cJAqeuDeWxMdzu0adTLwPYVv5AcakOS7hny1Qc9mR9Dhec4KlolhDwY/uOURp22g=@vger.kernel.org X-Gm-Message-State: APuU4Z9YDIGbaX0GSfVcvWnb1hUL4NTacRadZWob/cyjh1kpmlribACe n5kjVDqLaU/bHhwLNvz+feMDp3Pb1jqrZKrjIeCiAyWHjb7rwjv7dmdZ+M8TNwOsyw== X-Gm-Gg: AZFdTZfGPiO1SFP/8dRCxXv86zQgVEp1BS6XbqDYt3falIFobzGRkO36sw3oj+KgsxC eUlN5/VY0GYICoSWaOndN51ATiQQnoiA859LoWSXv+PWmuuU9rxxm1OlgAWnco46tINFxv8uUgq VxrV1uKNSmVy6S57lpKmIC5QIDY4t/w1vynufU7tLWryudyZ7Mh8fw2NFlPIbLH4pcua38QkINZ y0B2VNdE4doa1SqTIONex4oTWjgZsI9lI5ILo/nhS8ArDWyqYBuSUoU+3gdFnWBQYpfbVfK7cOi DTJkyN9UOI6YNmXkNfBkVE0/eCW1YZ8o63TxD9cA+Yp0CHlQ642drbuVSqU0kjBdXy+NHgj1jZr MskX7LJSFEYPw0N3YtzafztBJC9sXPq/GV4vl4InWnhlOPtwwRwMTw+36e5v0Yd3TtfQkVULydP z2/NMZq1UXbmnDW7bKcwOXJx/tRl8IpWBqmFsqJSOXXRRFGEGUZxCBAzLCAzYuBSSN78pF9rYJa cTjmlZmIL+NPYBtyc2F1w0EJNDv76krzqMx1UesV8zpIZCkZxFr+A1l3HLZ+RtPGuu8+VMKPSdM 3QWjxs7pGRiPB2PuJMOZHADwqcxlwjiv029e5ziefCAJdDkDY1V4gJORNQvuMECF1CXMiRzigSI QRw5+owGdzOnReBI5UNPI X-Received: by 2002:a17:903:3503:b0:2e7:e742:8bb5 with SMTP id d9443c01a7336-2f19726f6f2mr76065ad.14.1796247253103; Wed, 02 Dec 2026 13:34:13 -0800 (PST) Received: from google.com (25.75.145.34.bc.googleusercontent.com. [34.145.75.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c7d10d06sm954970a91.3.2026.12.02.13.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 13:34:12 -0800 (PST) Date: Wed, 2 Dec 2026 21:34:09 +0000 From: Samiullah Khawaja To: Pranjal Shrivastava Cc: Joerg Roedel , Will Deacon , Lu Baolu , 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 , Vipin Sharma , Ankit Soni , Nicolin Chen , John Starks Subject: Re: [PATCH v8 02/18] iommu: Implement IOMMU Live update FLB callbacks Message-ID: References: <20261123044949.3610702-1-skhawaja@google.com> <20261123044949.3610702-3-skhawaja@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: On Mon, Nov 30, 2026 at 06:47:43PM +0000, Pranjal Shrivastava wrote: >On Mon, Nov 30, 2026 at 06:40:01PM +0000, Pranjal Shrivastava wrote: >> On Mon, Nov 23, 2026 at 04:49:33AM +0000, Samiullah Khawaja wrote: >> > Add liveupdate FLB for IOMMU state preservation. Use KHO preserve memory >> > alloc/free helper functions to allocate memory for the IOMMU Live update >> > FLB object and the serialization structs for device, domain and iommu. >> > >> > During retrieve, walk through the preserved obj array headers and >> > restore each folio. Also recreate the FLB obj. >> > >> > +/* >> > + * Restore a set of serialized objects from the previous kernel. The objects >> > + * are read using the size recorded by the previous kernel in their header. >> > + * >> > + * Failure to restore preserved IOMMU state is considered fatal. This is >> > + * because the IOMMU translations for preserved IOMMUs were kept enabled in the >> > + * previous kernel and the preserved devices have their IOMMU domains still >> > + * present. Not being able to restore means that the memory mapped into >> > + * preserved domains might be already corrupted by the preserved devices. >> > + */ >> > +static void iommu_ser_set_restore(struct iommu_ser_set *set, u64 head_pa) >> > +{ >> > + size_t entry_size = sizeof(struct iommu_hdr_ser); >> > + >> > + if (head_pa) { >> > + struct kho_block_header_ser *block = phys_to_virt(head_pa); >> > + struct iommu_hdr_ser *hdr = (void *)(block + 1); >> > + >> > + entry_size = hdr->size; >> > + } >> > + >> > + if (entry_size < sizeof(struct iommu_hdr_ser) || >> > + entry_size > KHO_BLOCK_SIZE - sizeof(struct kho_block_header_ser)) >> > + goto err_fatal; >> > + >> >> With the callers passing sizeof(struct iommu_domain_ser) etc. Or, if >> every layout change is supposed to bump IOMMU_LUO_FLB_VERSION (see the >> comment on the ABI doc below), simply require that entry_size matches >> sizeof() of the struct. >> > >Oops, I lost a part of the comment while trimming, what I meant was: >The lower bound here only guarantees that the common header is >readable, but the users of these sets dereference each entry as the >full iommu_{domain,device,hw}_ser. If the previous kernel recorded a >smaller size, we'd read past the end of each object into the next During restore we setup the block entry size according to the size specified by the previous kernel in the common header. If the previous kernel recorded a smaller size, the users of the _ser structs will only read that much. Note that the size can increase without breaking the compatibility, so a newer kernel with larger _ser structs will be able to read the older/smaller preserved state by using size/feature bits to decide which part of the structs are valid. I will update the documentation with all this. But I think a buggy previous kernel can still set the size to be smaller than the minimum _ser struct, so I will add checks for that. >entry. Should the lower bound be the size of the struct the set holds, >e.g.: > > static void iommu_ser_set_restore(struct iommu_ser_set *set, u64 head_pa, > size_t min_size) > [...] > if (entry_size < min_size || > entry_size > KHO_BLOCK_SIZE - sizeof(struct kho_block_header_ser)) > goto err_fatal; > >With the callers passing sizeof(struct iommu_domain_ser) etc.? Or, if >every layout change is supposed to bump IOMMU_LUO_FLB_VERSION, simply >require that entry_size matches sizeof() of the struct. > >Thanks, >Praan Thanks, Sami