From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796247254; b=N+FckKFKHsfrgvvKpQLejlAZKhkqwmA/WCSQiOsJjuO+Sdo1Y354Zhwesa0YDEhApxMb aG0p4FWzJzZUT88ptU2VUxGKftT8CnnDBltvwlw0YLUfJgUXcxcbkYNFRdL8KH3hbUlul gGEd/T10rdgOMMiWHCp2xl4QLKLf8vDc71HJnKHt0dDrDMS/fVXxyjyZgDY4gyQh/azwI KtqjoRpnhhMY15wqmKnEXin1dfQFU80obcd14S/uA/+nal6mggn+9jkm9FikUxzmPmNNq vyRn9DqyOWpGPg2/nFpjvZk3aZkv9urHXHvJXzAMzhkpuIG+/ZoDnAlUCtW/GyiGQWA== 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=NDl3MtY7YnMJuEdM+0y97pT8jRTfiyXzNV42O7wzHBV9tYIdUj5/Rv8foBbk1YN+9A7a bjoCJ+QW/oFJrfpqav+GRtdwbTJnEq8K72xzXRS27/n+n6eDKOGsI6KI/6QO/V+1JpnOj o6/5bB9LFfQ9Zj9056qVdEUvSfsjQ86oBiaSIVK1YOs0X42IPXJMdd5FjFC6QOdgu+Fg0 hIyN/XjMBBbgZ7d7xw6qA1UVVO1l8CBL+BS8Kp3raTk/Q3jvOqystBVI9IMCWW/SralvC GITF5F6fw0R7KEzPCeR0zwW4pe+8e5z/1kRq+FpAPYP2L2r1vyYAJnTGC4PQ/1Tij2Q== 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=GAxd2gNG; arc=none smtp.remote-ip=209.85.214.180 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 5D941606A32C for ; Wed, 2 Dec 2026 21:34:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5D941606A32C 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=GAxd2gNG Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2f0e8bbc7a4so5865ad.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=1796247253; x=1796852053; 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=GAxd2gNGJhFcl++ExIuMj6+pY3CVeAGosECs9XJ5cdQtDtEsGBURv9QqGO47n65M4a xBtTJyJB+2E0sgzaFwrICY8ASeA2dyZFEPHiwF5txsgKPos8YIlbsc/ggOMp/un6/GXb hrxRXIm3iZa83YuurPLVQOThHn0O+/QvgnqnvoLup89ORi2UpJfokehYrcc8wO9wAPYO LcSUWo68/NbGEmbDpojh9oHRgqgZglTBFIDHbCrkPfhikIwUR+f+1chJ1q2eXyXQj9Fl yNoRG5KEQw0AhSgJreYig9EqWXlCYPNLBy0GbuV7H2PvEPfaoZsDy4L3xrMSWqddwCcK 8v2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796247253; x=1796852053; 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=q1peqmzfueSNp9LMn8Fl/UfIdLeaip0sK4CpN06C3at4lV8rGxQqZEjgs1eAiwho7y tLE9ZeVgJbcAD0Ju4J9W1KtRvEdyCf2GE9oO6QSQ24gjlhIm+vT23uig+HC/aK9OU9AC EKIkf3q1cdJhFCXFbVNNPC+nINfmkAGMwaqMy5Pz5D99IYKs3IiFhOwQEiojpWDQ4pf7 A5DH46sP1TyjtqVC8GyKvSJ6jYedW2O0fo0sSDZtMRwbvIyKjZsubvNjT2wrsAgVNCY2 vVCe/7822aJp4YkkPEnWpMDdd2Y3FGbpsL3sLCt7J/ncoBTbuPxO2We533iYDIKxu0/t Z2Ow== X-Forwarded-Encrypted: i=1; AL+hErH5lYR6feVxQyj4lOqxiVJa7OxJzzDduSb5TCGoO7qEcPRN53tkF3cnGx2m2HrjTx/yA70=@vger.kernel.org X-Gm-Message-State: APuU4Z+RGQJOmDkC2BAic5LU7JL+MYfbNPmj41Pt+TNCGEbsoMFgKYtX x+CDpkjjgs8XlkmgDXk2YM2fcGLQ8+jVsVVqcICQDdqJfgUwJkYlde/IJKoeKCWGrA== X-Gm-Gg: AZFdTZcIKHafcOA3/QAENn9wtRLnxW7D9ETYxCAmb+NT3ygMuhSWzvN2DGOimpqtCR4 V+ij2GdzA6YBDNO/nA/AXAHM+gSBPbBg4TRB5csdEA+nKn0PXzKUnGNrdgmWQHxrHa6e7JfnTEx cZ+LR226u91a02DAGkbLpLHM0pCY5PSAOsRwhrni3GGULk3e7Kp3zsEevW+KKoGEtw97LQog8sw VHxKveNozrN7icrjR3G054Wb6G1dTXAfsMOISJg4OMhYEN16UWZACj5fa5Ofh74fCqRNTQYbyBG uNX8BtDkcYeKWiS3vadGw0MlHpcUp7BA23na1nZMLRBggqAQ/FWudA2m/mYbCx1SVEp6shu/pq5 EqOZiGE/IsT0FKEr184PFQEbaz4/6ovEeDTI2e362Dp/a7/ctJlPJHzWM+/GNafVdNb0mFCUePZ FPg42Kwl8hxDOC5uf8WNkXLlE+rUbsxeOv7GMm0u7pQe/bEn4181OMAiRow054u50S7H+ZCH18I uHIcGodPegMLLdHWgJsuo48ivgwj+tXsbVW3lwQ1KMYNy26XrcBnXurvHZHbpsOyFexMMewr+hG +tO/wEdBwA5Bld6CsJTWAb2fY5IigPO5r0Q01kiT4AUL5c2vtTgiTVkOckVE4WoXCcX8kjlidGm HnC/jkOIR6SsWEff30KEt 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: 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; 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