From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796064473; b=0xxErRw7atzcIzd9aATkHEfYebaYY9EVAImr+W/httrJGccgx8LkgQubA5XylxBYKyah hrVMroQ3gcHCLKoA0sYJWr0f1EpbVvRDQjWBGOelauzEz0b+un2OrJOljJk+y8PZ20LRO x/COEU7Au6oDmbh9Fh7VdtHFN/TCmNLRumWp/QAfUhn2KgMe+vTYHznZ8dy4SMbRlTi1S VtF/q0IhGfbZUDqHz54JJAZctxb4g4w4I9gz0nMn5foD8POVwTA+/5+VaZmNadFguluKi Umq5AgZEKDC+3nBmMaX0+xWWJMUwb9vYIjBCupTVPJAXhJIaabhRDA8+1sAUcGnml6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796064473; 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=e8bpa+8l/fAPmAt8/ZWLKZvVa0bnWlwdQGAMdQINVbs=; b=DEBTMxHnGg8riXFlEDQvY8I9dIAdggR7jqvq1dE7+c2F/BPhrG1UdAqakih1qs10fmtq q5BmCMx4IgrkAQLZ0AcbfW2o1seO1HY30E+yDBnjqYff5N75k0eJFaEnxCV2XhyEslpnl F6z4cTt7xwvgW2a3LGxbCkZ0KSA6n4dokI9I6syOXrxOw9LEkabL/b0McjDnDZ5Dvf6G+ q0bJp5UJhEKLtgb97ZaIQ7q5JWc8sC4jx8fljBXXD44VvfL/sN0yVVKmzo5Be3b3Mp3Kr VGHWqqLb5HQYx1pwxNXoOfVj/u+O3CwzWgnvFbWuPqG0iwz77z84xrkAck9fULBSxNw== 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=XaDzRoG8; arc=none smtp.remote-ip=209.85.214.171 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 D62FA606A320 for ; Mon, 30 Nov 2026 18:47:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D62FA606A320 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=XaDzRoG8 Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2f146d5607aso67635ad.0 for ; Mon, 30 Nov 2026 10:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796064472; x=1796669272; 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=e8bpa+8l/fAPmAt8/ZWLKZvVa0bnWlwdQGAMdQINVbs=; b=XaDzRoG8vSZrQ06Q7XcAUK1mgdXx+o3zzFVcP71dc/IabOEG9BUWPtOy8pj7fuCYCw m+m5V6cbZwfckhBdOyP4PdUBNd9yC0NC1HsIPTYxIKv9vo6NpSM3CsPYw9Ov6ncI/nDn IVpMr4BxEBdzeNsD6LRNqP6L8mP1pRqLTtPcdv+XkoiXfc9ozNz/PyotZ9Veo5bQ5OUe jJ8B0b7Xc9w1o5v07UJ8J5OXvcTurjeTYOKeels61NUobVQQWriEKlzqYX+2Q6V3eXmu K9bwUu4hIyULUbH4YMKFRa4NImEfe56Ef3Q4ABi43gSqsTR45xgMcAn/AyUoiiy8+I9G SQqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796064472; x=1796669272; 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=e8bpa+8l/fAPmAt8/ZWLKZvVa0bnWlwdQGAMdQINVbs=; b=qM+vPnFhRw5SXRod7t4rfEHnwWOj/uHzkpWeGrOYoMRn1M8x0RkF0zDcRIZuzyfMdw +TVhtS1VsLG9fRBfL7LFUdlllPKiKUgPB527wUooBoMBfnUFCLNntkRYFJxMWKTAtFYL 3YUPLxozQV8j01mHYKdmY0gzhxZWcP+/VfdEw1wbCJ/dU//hoAYgH4GtyTHLMGxy3IcN HM8ocHDgBJ0+bCt2x4zNc++YsnJCqdOtjU7JsQTrg/jz8lfVtJBz1po3/jWlA8TxNaSd DFDC7ImXoFqTwR0hCin9li9pDztPfBYqd7/hHlC8hT/l0py3dXc9E9Xjg5hF+6vlljMz UaUg== X-Forwarded-Encrypted: i=1; AL+hErFuEV+/KsNr+YycOLWqC8mTEiZ9UiadVG0XzNa9aXNIHrJ1ojCagRkfESpZAOYGaJAh0+g=@vger.kernel.org X-Gm-Message-State: APuU4Z+Ygi2CvV7eGcTFXcDT8WKoYUorNTyeb+kIfQjuXMAeH+X8DJZ3 w1rCgD6vRaoEg/Qfo28y/gpPfIJvuBORHOZVAgTAntxFvnm1a7Ybw8AAwtR/vn1Ebg== X-Gm-Gg: AZFdTZdCAzs9Sze5n1Q4b2gHTK5Qht+AsNUKwIHYArTjIp2KYBtOEYlhZH722N5D0lz y18jzmr2HsT5UDCucuMeTOjWmMhxspFApu0lZ2i1ZmaitBdw8FjqNkVAyaZ/EHn7ZursiC7aEZH nacV9fYU9H3+qwu/dSflkJaxM7EJUZ9vA35GbDUjQ4rszJLRKFhqHm7spJZPuYemTS2zLwYyRYj qt0LqwZjpnxaCb11+1qq7m+sWtdXnZCbxVhrQmtg9/QmfjYJMkwrt7Kwq5C/FQ3ZeFxIrNu/wE8 klvKb127zcPhKQ15OcjkanSxhI+7F73l6hmHnRTVXEtCgGvz3yuKZWC/Qge84PyVWT5Q1OLvqgz mWoj/sSbkVGsqhU9ZQKOT/hhP+gE3AkE+0gtxOXOf57XlD28oYb6SFazU8NgUpfWhSvlWD3t4qk gXZR0mpYmAyMhwmrf92pAv5BHITzxA9cYZax1KOcpo23otINkcack8eW671USZARP2A0IoXfjHF 4BNdgBFIhJ8LoEOL0C0hZTRnLDu/3lKMKK3lr422dpHoDKjjL9mW5q3QxPEMUe804vnoZLWbswN deP7RV9HOznhIu1mk/ltxffaeMNN2XH0MYFHhKGCdCDwd1fo7t5OqLquT9+YgAUYKuE= X-Received: by 2002:a17:903:350b:b0:2ec:f228:764d with SMTP id d9443c01a7336-2f06670a01emr32661185ad.18.1796064471674; Mon, 30 Nov 2026 10:47:51 -0800 (PST) Received: from google.com (105.211.142.34.bc.googleusercontent.com. [34.142.211.105]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87077babfsm18554386b3a.5.2026.11.30.10.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 10:47:50 -0800 (PST) Date: Mon, 30 Nov 2026 18:47:43 +0000 From: Pranjal Shrivastava To: Samiullah Khawaja 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: kvm@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 Content-Disposition: inline In-Reply-To: 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 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