From: Jason Gunthorpe <jgg@nvidia.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: kevin.tian@intel.com, yi.l.liu@intel.com, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iommufd/device: Enforce reserved IOVA also when attached to hwpt_nested
Date: Tue, 27 Aug 2024 11:26:12 -0300 [thread overview]
Message-ID: <20240827142612.GN3773488@nvidia.com> (raw)
In-Reply-To: <20240807003446.3740368-1-nicolinc@nvidia.com>
On Tue, Aug 06, 2024 at 05:34:46PM -0700, Nicolin Chen wrote:
> Currently, device reserved regions are only enforced when the device is
> attached to an hwpt_paging. In other words, if the device gets attached
> to an hwpt_nested directly, the parent hwpt_paging of the hwpt_nested's
> would not enforce those reserved IOVAs. This works for most of reserved
> region types, but not for IOMMU_RESV_SW_MSI, which is a unique software
> defined window, required by a nesting case too to setup an MSI doorbell
> on the parent stage-2 hwpt/domain.
>
> Kevin pointed out that:
> 1) there is no usage using up closely the entire IOVA space yet,
> 2) guest may change the viommu mode to switch between nested
> and paging then VMM has to take all devices' reserved regions
> into consideration anyway, when composing the GPA space.
> Link: https://lore.kernel.org/all/BN9PR11MB5276497781C96415272E6FED8CB12@BN9PR11MB5276.namprd11.prod.outlook.com/
>
> So it would be actually convenient for us to also enforce reserved IOVA
> onto the parent hwpt_paging, when attaching a device to an hwpt_nested.
>
> Repurpose the existing attach/replace_paging helpers to attach device's
> reserved IOVAs exclusively.
>
> Add a new find_hwpt_paging helper, which is only used by these reserved
> IOVA functions, to allow an IOMMUFD_OBJ_HWPT_NESTED hwpt to redirect to
> its parent hwpt_paging. Return a NULL in these two helpers for any new
> HWPT type in the future.
>
> Suggested-by: Tian, Kevin <kevin.tian@intel.com>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
>
> Changelog
> v3:
> * Moved to_hwpt_paging logic back to the callers
> * Added a new find_hwpt_paging for reserved iova callers
> v2:
> https://lore.kernel.org/all/20240806050201.3717816-1-nicolinc@nvidia.com/
> * Corrected the ioas comparisons for future hwpt type that returns
> NULL by the to_hwpt_paging helper.
> v1:
> https://lore.kernel.org/all/20240802053458.2754673-1-nicolinc@nvidia.com/
>
> drivers/iommu/iommufd/device.c | 52 ++++++++++++-------------
> drivers/iommu/iommufd/iommufd_private.h | 19 +++++++++
> 2 files changed, 45 insertions(+), 26 deletions(-)
Applied to iommufd for-next
Thanks,
Jason
prev parent reply other threads:[~2024-08-27 14:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 0:34 [PATCH v3] iommufd/device: Enforce reserved IOVA also when attached to hwpt_nested Nicolin Chen
2024-08-09 2:00 ` Tian, Kevin
2024-08-09 20:23 ` Nicolin Chen
2024-08-14 22:38 ` Jason Gunthorpe
2024-08-14 23:31 ` Nicolin Chen
2024-08-15 17:37 ` Jason Gunthorpe
2024-08-27 14:26 ` Jason Gunthorpe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240827142612.GN3773488@nvidia.com \
--to=jgg@nvidia.com \
--cc=iommu@lists.linux.dev \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=yi.l.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox