From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1518039DBC9 for ; Mon, 13 Apr 2026 22:33:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776119602; cv=none; b=irbCLMIrnNWxnDgeg2U7DeRyF8tbJZgst44OVa2p6+rqS+nPxiKGXUED+9HyH5VrrRU2El71cTz9fghQndX1ILmMgH0NaAWmM5T685gbqWw5roZIFNoz2OAJTM09Uqe1GqoLI1N26M9+ahw7jZlnSzD1DQPfijTMPgewXy2+XTA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776119602; c=relaxed/simple; bh=UwW/1XbIw/u2ktOpP85VLCvfvyEmOP4GLErArAy8gGw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rgkNIfTmwJ66XRWGpiFYwQPWzvM1umXfBHHGtonZ95gm8MPVLA+zrZn6TlEG7+kSxJDfX4tEWfGUD4I4p0LDXNNtqo2rtngrcArzjmBkhHI7MyWvhD+Xy0xBo6pbPeszMUKWfEPvreQUiPnB/QqIYt2eHM1Rc4EAaG6xpsHhhHk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=UhfLOUiP; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="UhfLOUiP" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-8a58057d7baso54015596d6.1 for ; Mon, 13 Apr 2026 15:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1776119600; x=1776724400; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=UwW/1XbIw/u2ktOpP85VLCvfvyEmOP4GLErArAy8gGw=; b=UhfLOUiPlRQqY06loItczVdfGR2eN7c719ZP1dIr7H/8jBbyRNPuVFGfJlCpNzIpCk 5XEAAS43++frG2nP6VS4l3S/iBS43a5puDK0gLoCvxVQVbJpl2cOq2a4Crx61Iq1jQFi SJHVIXrpJgSarHKwQUbNyPrM39YuLStKvOzmsKEmcGWIwyE1p8efZvxzc+FYGisjO7gs KLaqL8HY3gXA6GbFSIZKJwODbT29QV6m9+71SE6eUHY4EdwTKrg707WwCkP67nzIoz00 FYc9TvhOEz+s43eaRsoXPWl4I9kKl/M/amS9ns7tEnzxMbuKXBlOwIobSTzXtTVwScef YHhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776119600; x=1776724400; h=in-reply-to:content-disposition: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; bh=UwW/1XbIw/u2ktOpP85VLCvfvyEmOP4GLErArAy8gGw=; b=egDuSOoOZpxweI7BzVWcEZcOLCoIVFeCuQtw3KgnxO05zjjGp5HnrmhZwrCj/+t+Ga wNUYLPi1g33+3tBzD5Nb4IBsJBl6x1feDdRZFBsKcxEl6ouUZ5zE2ncOKqkYEtGqW8Oc dU9KBbA95y/AR3uxXgQCc0o+qpdZLzuprrQOcCeRfPGmMSFvPVkjGw3KjWhLsQBRo/Si 5B1cELVhs9vWLNVzkxz+6gPGvcvJqvP3+Pk2uHYxFdWWw+f77o6m3QrjBVPPx96fBb2z BQ/LimEQ1MVAlhhm/x1O/cHRVeDRJhbKAsqgxFpP1n72nKTI6jKMzHGqQ2HvntZqDIB6 YMUQ== X-Forwarded-Encrypted: i=1; AFNElJ9HbbyO1MyUD0SjVE63kSPXbKA71A8Oi0cgz4gGxzXnUcwl3xhaO7cC/sVPt2xwdhlRaGHJTF+5AZ9/B6E=@vger.kernel.org X-Gm-Message-State: AOJu0YwORi4/ZFFVa4SUpRuO87n4biSmPe9nsxkdSnhJ3ps22nWPCcLU bE1j8jIB8yK12QKcrZyw2vPtO232F6GqMEhiqzFutLE1lGyGIBw4HvT6JM5idXgZYcA= X-Gm-Gg: AeBDievKzTZyKDGu8EN5BjgKNY66QVJDl2Tdc/hfLPIPGtI+Zz2uMBu2uYQecr9e+PT wLCPiP8qdeToQNQnTZg6CCTvwyRLEogVZFQcSf4ALhA6Qrf92f0TSNQkynPrSezWPSmeFmA9IH8 Nip6PGr5m67FTElH2kJDflcOJ+ltKRPQqszDHILQts+KQps0KOGYUQH2fTmV2tZ+s+TFxJZo28B xjBFLjOh//t+EAR4667f5SMi6E4FjutUB8YeozfqL0Y1mSxyuRL0T5CcV9gXAYUoZWsvh+vS/9U 25vtAaZu5IJfgrm8YeUTpt+rq1EdY6KaSKrqBP+TQZ7hZQAWialmplV5qDC8Ucoz/JJRJKxwD3/ 1j9XcN1yPCXDwL/eTzsnD9AWdKT6JA8Ax1Ko0rdm6n9EA82isizro19Ij+gKFrwehr6xpSmJ2Ro NFNS1ad917ULZBTQ2Ga2fQnL7ue5e66KIGi+1F+azQG8hzzxHfNiOuSOIZN2OqnKCNck8PGibia jfh6g== X-Received: by 2002:a05:6214:e88:b0:8ac:8cbb:49bd with SMTP id 6a1803df08f44-8ac8cbb4d73mr219764146d6.38.1776119599895; Mon, 13 Apr 2026 15:33:19 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ac84a45552sm105040816d6.20.2026.04.13.15.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 15:33:19 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wCPqI-000000075qq-3S8b; Mon, 13 Apr 2026 19:33:18 -0300 Date: Mon, 13 Apr 2026 19:33:18 -0300 From: Jason Gunthorpe To: Samiullah Khawaja Cc: Pranjal Shrivastava , David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , Alex Williamson , Shuah Khan , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Saeed Mahameed , Adithya Jayachandran , Parav Pandit , Leon Romanovsky , William Tu , Pratyush Yadav , Pasha Tatashin , David Matlack , Andrew Morton , Chris Li , Vipin Sharma , YiFei Zhu Subject: Re: [PATCH 05/14] iommupt: Implement preserve/unpreserve/restore callbacks Message-ID: <20260413223318.GR3694781@ziepe.ca> References: <20260203220948.2176157-1-skhawaja@google.com> <20260203220948.2176157-6-skhawaja@google.com> <20260410141652.GV2551565@ziepe.ca> <20260410231650.GD3694781@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Apr 13, 2026 at 07:31:22PM +0000, Samiullah Khawaja wrote: > Yes, we use the collect walker during KHO restore of the preserved pages > and also during free. But if I understand correctly, the collect walker > behaviour changes based on some FEAT_ flags (like SIGN_EXTEND). So we > have to be careful if the previous kernel was using different FEAT flags > that affect the collect walker. To handle this, we can just preserve the > u32 features from struct pt_common and deduce everything using that. It is agressively not stable, and even new kernels might not support the features old ones were using, so this is a bit dicy. You probably need some, but I think I'd be very choosey about which some I preserve and which come from the new driver. > Thinking about it more, we do preserve the top_level, so that could > potentially be used to walk over the page tables of these free-only > domains if we just set up the pts->index and pts->end_index properly by > initializing the range based on the top_level. Are you thinking of a > similar approach to walk these free-only domains? Hmm, even the free walker requires computing the end_index, and that requires at least vasz. eg ARM will compute the number of items in the top level based on vasz to support concatenated pages. I don't think sign_extend is used in the free path though. So if that is the only purpose then yes you can probably get away with nothing, but you have to be very careful to contain the restored domain to only execute free and nothing else by removing the map/unmap/etc ops. And add some dedicated self tests (zero pt features and test free) to simulate it. Jason