From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796064473; b=It6HjtXCtMtaI74lgMnEZWgjNBxUTgLZHmr5Au+RafrNtTOG2DSq/HAqk0oUTs4dGV6m g4AhXABXbEnsPuVPFRYyZbpygIolSYOQ5mMHwKMavPjNaNKEYS5PzTaojUuvkE5xVZL+Q 4Aodm1gM31MSDGQ/U0k4CKXVmtw05QKhqjeaP/eBPKgvHqKFuReP9yz9y4m1ag9ZnX9s4 +le8GMOCiy8emXtK5BYWVO/95XDcZ1BEbbvv59N8ULuyUyV2aQ/+qQlluWrFrN33oxmJo 4qt9d5bCuL5rBNp8IMIE5qmw8SKQqenbdeNRpBaScTW6bwXlF3/8dLSEFO08vNpK1Cw== 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=fPGap8SUUlP5oano0DbvjsfF91wCeys199cKNp3iTnUXzQeyhpIUcmffk8XEudbciXes SKEUSipW/04HIRptBHSVwu5GP0ZIHT4HHPPKU7JmenfuTOuQ6pQiBz4JGiBv0NKfq8rjG zVZEETv1lDSjbbYZkIZ0aJ/cMtWi9xzgnPLF6ECyfKwQk3evnpTyejYeBUuMmCspGkY4S KEaG713TUaKb6GMBUC6unDmapID3TQqnOYQkD7e/orJn+AsFUPfaQN8AF1k+VaJFJmCuq 4OsxutYGK9na5B3z4s45ekv+/XHYwvIL+tLKTAH0rhY8T2Ltzh9mdjlJAWo4pPIwgCw== 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.173 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 DA2A0606A325 for ; Mon, 30 Nov 2026 18:47:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DA2A0606A325 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-f173.google.com with SMTP id d9443c01a7336-2f146d5607aso67655ad.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=NlOAjj3APXJikGRKn58RqmjA/3e/MoOhof9BugEWgEoSKx/YSat+4B2qgjnYociphh Td099z144Xa9eqLpWhvThSZoLRWiBuQlUb82O75SyUk3M385o6IlBLUSh8E3PGHXv/Ic 9lZbDBSoMPIu147SxHztb/dX0P8nGUwY8Eb82uOuNxxJvWc82bbeXktd9PjAeMMHGRvv dDASmJyaJwoLyVgFk0qYcZb3khugWl8uvoVz5NGVZRhDYEUZeeHYz1cMK1d+3vEuLmZZ xpHhC0j2T42yi+v7W9C0v0bh58dDd7JsVpSo/4quLwBtOOq8aABU5lPJw69BY65F4F4h jG+w== X-Forwarded-Encrypted: i=1; AL+hErFyN3aYM1PtWtf8OuA70BvGBKdNOrunglPCk7mkQt+UHVlSsTHC4sKkvTonHGOHjLuSY6X8TSJrXBW2vTo=@vger.kernel.org X-Gm-Message-State: APuU4Z/Whse4djmq+n4qsFtWWwx8p1krFkmqkLyxTBn4nCMhPTV+CrNQ m8yGqVWhSTNaRNXjAN5JUbZBnk82Yx92Vn6qBHGyarGYURlxi5rxmCw7icQTMlZwxw== X-Gm-Gg: AZFdTZfxbBYVOv9llM2SFwOKABsLo7OIZDl2hLNHa6KAc3/jVwvsU1ubsyy0sEQAv7W xIzv3dqC7tOmXzbvEDtxEqPKwc4JhC8le0U/4+aZ/ZqGzs82EYjlL8kJ30FMow5asWk7VsOcZMr dFFPG1fUDtUYytDoYh7t4C1sM2rSc2OiZGGezq3rGFQl5Cti56HmBpnYFiaNmjfhdE3yr7NyitE uB07e3PltqOBfXRZ3cNpfSwNqNQBniE5COHC+QEcov4KQVlvisOxyau32KrBHlqHXUTdvjDyM3I hZqv/xKZSL8rd4+xZZGTGFgzSTtocDRbjGi3q3WUE2NJK6e1VEHC4Md0NkSJ9+Pda9G1bfS7y7x Kl3nRWletIEAie3qasjL5r+GAksrEvdwlCyFWLrdtjO8QchCGi+v3/ha9P5O9jKpoMmT2tIicXm i8F1m3rLG9PkyRHS4d+31mumYvqKgCA1RPZOtcFBIrp+tG8u2lrCl8lwwui8yMtluYwBJA9z27y opLEWoxhI6qYmlelVSe/fXiw58TNvbUh3aVEFgR+noyf7N1jhNgtnO1hMO/kvOl5xG1KTe/Ay37 fHAw3rQLvjNHwj85npZMueaGQ9UAcHriCwrD9jrOba9x9uuv1WD3JwcBiXPh1eDjmto= 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: 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 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