From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796247254; b=s6YLV5OTHpKasJHXTeBrWfHAztwhsb895NaY/cQolQ5Cbd8zSD/e6pGY01gsVUELYAMM TmJGbRFKdTWvizy8xaO4RNTfX3BrYyyOQhUD/0tnnPPokbg1h+3nypt2qWhGHHxwiP7Yw NvUbrNST8Tg8Uf64jU6RCE9ILx7zFIx0BD/M/AnJvr9vSLrfHPAdz91jkcbcjD5rsURZQ CXIZUCwQuKmusmHSLMVgQwb4nWcxj650VfE5NBA8prvNWMXhBkkd9XO/zbb29IgMlYixv E7+YdeUpH6WUY6h87Vl6GLie+knsidCIwPoHJNbQg4jBeztFLBQz+gUKu2+blzQEFkg== 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=BAdRpTbfssnfkHxGXQyE8mK6LdPbJnPuJiQEo6EzCgCXaf2b1Hlj7mjQ1x1ASKEuZ0l4 nduxEdrUfq//5WCbMYmH+gLE9upa0mhJAGeahRnOkopUBQz5THkA/tn84G1YuucgrnWXR Z2x1h2tUG7CDkWd5hJD8k6R6SZox9rW9P0K95e5db1+31+jsJ3GSn27/MlehCPhA3uWF7 JjMl2Z7mT136ajDeMe5U+z+m0RRMYDNFWuFYbxa21dOUuXrIJ6NH5TY/dFK7wwqyNLkqG lNInzdu+BhjHVU/P34HwkFkIMrjlr/zqF0eu/B2uV57oBdIrgvWmmqBtxzjr5651Qnw== 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=WjucANUO; arc=none smtp.remote-ip=209.85.214.182 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 59374606A322 for ; Wed, 2 Dec 2026 21:34:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 59374606A322 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, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WjucANUO Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2f0e8bbc7a4so5915ad.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=lists.linux.dev; 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=WjucANUON2ZKLvtU6FDIXg8kLT2bREK5Zh5fpNeT9ZGw0V8Pv06aYKSpEXVg0Qmg9e KANwRKpIAzhabEyB5TADfggb4YTJ74UlpTZeIgd8RxihEG6zrGEKHkVs4xxlyW/QLcHi 3amnJE0Qf7YjvyPGiwvh9OrpObLFrtIa8r7G1wUoev1zuEW37XqDTmvcVHJ0motjQo4K K7964yRJf0PjBT8PfXn3mT/rD+KtGWiNB8DnZ4ysbLEXpUzOt1CFoTbpIUdYUowo3fL0 PASpX/u7An7I45ZDvi+WsSs7h9++LvaT0Xr2HK4eM2VT0zuImm1I5JzFFzCMcT6/Qt1A Mi9Q== 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=QGmiNHnAp/lwkqTSLIB5I7qBv8EOeH57MfdYzLD4OdTdxALkY2BUvNmv6RjDeylIFy 6kuimCf1gTB3mgLIcb24Gz8GNKEglpnIxwEGW4JtSplZsTwI0H16Hxg6Mv6/ENBR4PmH MK/sNFo+tRK3LDh6dQXMQwkVn4jXuYYjJo0+ft1YzboUzDqG2Ijd7N5chac5NKRMvRqH rKgpvvYhaw0Ph9TRfePeiLv/qnmB+qLxVZLdsIPKUOCD0ljP0ee2yiIqXiVMcbQyrhVz 4baMiQlaZMN3kscjeRjTFwS1sB1/1cgCq9ZqYs46855H33+0LVp9wubenCC6On640HqU MrTQ== X-Forwarded-Encrypted: i=1; AL+hErEQQ7idhx74BwQJ6dcn+znFLf/Ixo3XLjEvNIS1q2zwex18AHweH3uhBHVyW5ygSTVQFSLGNQ==@lists.linux.dev X-Gm-Message-State: APuU4Z/Vpl6xOdhGbpV7qrq17wlyXZIdxE9DGnP9e7vuNlUNKuNn+dEU AzS0WpHZnMpw8eJTArCj4YowJcwtSzUfYQWJCun51Mzy6en+yLIAqjC8T1Wrns9nsg== X-Gm-Gg: AZFdTZdhy+4WHfHYjDRfKYl4dMkILWFlomX1WZSAFJUSUEnh85djspcjmMyWvQQc7CT y15AkLWr7loDvBHmryb52oPKgHY82UbPuPBu60XZYeeDQiXcYD1LaoP8E6DIdIPGByegOsqOLfR qg/P58WXyY/UEID8hkBRE9EFPrmUoeEpXT+43vKcLWqGI5e3gXMDxPYZFGAA+vKCxlf0yxEidCD h6mjzMNPcwGKEF5j61uOuhfTw23z9pf8ZiG7ZTWf6j9pZnanLGlxAugVaDPZSn+R0/B/3i5dGw1 quVrdBcw2VDOvY+6JpV4n8gsbJacPBEaDURpvDxRro5XoncRj7p4lSj+TRtMOXCGglYfHyHOKKX saspg01G8pc8rzS3yjpJMjsobhB6c+FthUkgj+OMwzQNQVyCGAGnP7JQfR2nJ719rb+FonQWy6G MdOigvGterdE34vDcHa8f5PuKpDm4XT3yPOrgJGn2MxgoZ0ipzHJyDgpMN9Zamy05iqH8ZLZMNc w4+l4NLHlca6jOwB/jXC0UlBXVmTbaWTH5tnmY4PYZ+LI3h5cnioena31Pnqi3vycTd3Tj8WCfm fY274M3f21rg+kFLYQ9BXriC2Val3dOIjRGhTMHjJP4KoLnOvPqiQLShIhSw2NWOe2ZKBmoav4C 4JMyHF9mghAgpUCBV8Lja 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: iommu@lists.linux.dev 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