From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50]) (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 0DD741F0991 for ; Fri, 10 Apr 2026 23:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775862180; cv=none; b=Ix5EaxgZK3q5GswUni7ori8uS6mFT/51M0Mz4npiWF+oi9mfPayUWaCiT/yG+PekZiqalXGVI80Nd/zGj7+mxHYe+JvRoVho40jBlTNcHkjRtUqhJiXZOZDF0cVsysHLKoETo19KwkyKDe2gIuxM687cRM+0xSTWwRB5k9fja/A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775862180; c=relaxed/simple; bh=DYTNLb98hZeGxyI5R92ohATyRHWcsN36bzgF2YeqRkw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ty7MxRhlVG9Ui0pbBKLX8BVmMLz1mT+At5kJyB1AeSso01hCKiYY2rpTn8BDu2g8pbj+3ndeidX0ZF78yZ29uLSAmLy1eFAq8xNRCjhT/IeujW5MLrHB/LGmQFHq7qDvcF8nHjL2V5Jf92NdtL/UFOII7NflFEPy8QWotnaMBTA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZvG5mDfo; arc=none smtp.client-ip=74.125.82.50 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.b="ZvG5mDfo" Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-126ea4e9697so25896c88.1 for ; Fri, 10 Apr 2026 16:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775862178; x=1776466978; 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=+sDo9cCb4JlomwDlOw2QqnoywLS/P6wn4vikeZZXB08=; b=ZvG5mDfohtU+wp3y4DQyx2twaIlpzyn/biAWXAl6NlYLRz+ylMDRYtwaUN5p0ZvWoB yKt5ytTMwyTkp4oVMdVaMvcqFfY90XxObt9Ek7sotwhHGlX+qi6yYs9IttrsAURIUz14 yPFbru3z7/Y2bgMwwGr6De+pt/wNTmasoMHc8RQ88bzIFgJY7eQ1GeBIfBXcxsrG8O7+ u18cm/vuegWnsCKrLdACdCeZSkh+gcDh96WxNxmjuxnigKx0mItjvN1lQachn5c0VLO+ wsZt5fkJkEdWjuF8vzOX9d/X8Oe4IyjTC3/qvFQBuCnTGaC8ARgjk2y8Q/i1kv2yfSsG lGOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775862178; x=1776466978; 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=+sDo9cCb4JlomwDlOw2QqnoywLS/P6wn4vikeZZXB08=; b=TzRRVCBw47saZbsAQCfXzbUpXitgC5o6/Kl6dk41/fJ5QJZprgXWnov/edvlMdDOgs 17TPfc919Fc+owymIzqVxMz4dM5jW8/K+sZRlbvf68OGFTXGEIePIIekYkFR2NwVfM9j toUNpmXp/tShY6gU9vZGAyXN/fBsDoyKhN4fFyXMHV0aQf/mI/kGynzrj0au0HbH2Fqf SefYLqhg73poaLIKrF6btKdo3pZ4Yw3ejSxN3J/QsuUXtez80Aip3XjskQRhtK8OiTYD 22CQGzJfcuWuRmZ9Gzb+IW7z+67RQzu1AKAbmgMuNI5JZr4qdJXEgYndRSs3F//8S7lN 740g== X-Forwarded-Encrypted: i=1; AJvYcCVbJjsbB0C1zrEEZ/LaHsJ+eGOPspP2VOE3OT5q5O4yvzC8q74Az6wmZ1Pdptn/+1pBsU1BIqTaYyZQWTY=@vger.kernel.org X-Gm-Message-State: AOJu0YxojdMa0H7kn4SU1qxqQB2RYOgPnjQwMCXxMIGVwRXUmqBHJFy5 Q73FVx0j1vgKLjsG7GxLPjV6DovCx+el6yPx1ylw4B+/41/XdZFaYqPrG8MajRXX8w== X-Gm-Gg: AeBDietOWONbfXhdAEgnz8HqvIIvktPOef0wnai1RMt2oIOAJOK36I+DTR7I03fLlQT jmk07re8mCbVNmOdVfcUXLt+xfq13f7qb2Eq7+BjBD7tGXZCVAKh0+PcdvyZRkrzFOg42FNyET/ LZ0ik05Z/jb6QCad94J5uQmkkf1BWyVEDAUlo956VuForS7qZoe6/aZGKFtDiOfuQx29JkdZ8h6 +FJ4gRD6RxOxuPFcZ2x/vWa7il//wtPGIk/CiCdjbTJ7nlyKT8/2qBbF2nVqisjAX+xMXGeM77j JGyUTn925UCwosXltGRSsqfP1ft8JUT6dAewS618Nsnh1JjBMMZ1J3/to8TShseCyiZRySmYEqh fH/X41F43nir1WlRBOiLkjqN8l21QJ/89oY4l/jhyIXri2F2DiSt5Abo0YGt8EiDj/48EU45zk0 4FeN+zjGZ3eT5disuQgPZRI+wYyA5tVYM3BM8MFtL56PrgAVmEWGAKOZMjEF8gl73qCG8KnG2C X-Received: by 2002:a05:7022:48e:b0:128:ba6e:f809 with SMTP id a92af1059eb24-12c28ea0f68mr430372c88.6.1775862177534; Fri, 10 Apr 2026 16:02:57 -0700 (PDT) Received: from google.com (195.236.83.34.bc.googleusercontent.com. [34.83.236.195]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2d561cd2c09sm7935702eec.18.2026.04.10.16.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 16:02:57 -0700 (PDT) Date: Fri, 10 Apr 2026 23:02:52 +0000 From: Samiullah Khawaja To: Jason Gunthorpe 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: References: <20260203220948.2176157-1-skhawaja@google.com> <20260203220948.2176157-6-skhawaja@google.com> <20260410141652.GV2551565@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; format=flowed Content-Disposition: inline In-Reply-To: <20260410141652.GV2551565@ziepe.ca> On Fri, Apr 10, 2026 at 11:16:52AM -0300, Jason Gunthorpe wrote: >On Fri, Mar 20, 2026 at 09:57:08PM +0000, Pranjal Shrivastava wrote: >> > +static int __restore_tables(struct pt_range *range, void *arg, >> > + unsigned int level, struct pt_table_p *table) >> > +{ >> > + struct pt_state pts = pt_init(range, level, table); >> > + int ret; >> > + >> > + for_each_pt_level_entry(&pts) { >> > + if (pts.type == PT_ENTRY_TABLE) { >> > + iommu_restore_page(virt_to_phys(pts.table_lower)); >> > + ret = pt_descend(&pts, arg, __restore_tables); >> > + if (ret) >> > + return ret; >> >> If pt_descend() returns an error, we immediately return ret. However, we >> have already successfully called iommu_restore_page() on pts.table_lower >> and potentially many other tables earlier in the loop or higher up in >> the tree.. > >It doesn't return an error, it just propogates errors from the >callbacks which this one never errors. So this is just dead code. > >> > +int DOMAIN_NS(restore)(struct iommu_domain *domain, struct iommu_domain_ser *ser) >> > +{ >> > + struct pt_iommu *iommu_table = >> > + container_of(domain, struct pt_iommu, domain); >> > + struct pt_common *common = common_from_iommu(iommu_table); >> > + struct pt_range range = pt_all_range(common); >> > + >> > + iommu_restore_page(ser->top_table); >> > + >> > + /* Free new table */ >> > + iommu_free_pages(range.top_table); >> > + >> > + /* Set the restored top table */ >> > + pt_top_set(common, phys_to_virt(ser->top_table), ser->top_level); >> > + >> > + /* Restore all pages*/ >> > + range = pt_all_range(common); >> > + return pt_walk_range(&range, __restore_tables, NULL); > >This should probably be doing something with the FEAT flags and >ias/oas too or do you imagine the calling driver has to deal with >that? During boot the iommu_domain is recreated in driver and it sets up the FEAT flags and ias/oas properly. Then this generic callback is used to restore the page tables. Currently the FEAT flags of a domain are not explicitly preserved, I will preserve them and error out here if there is a mismatch. > >Jason