All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vasant Hegde <vasant.hegde@amd.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>, Jason Gunthorpe <jgg@ziepe.ca>
Cc: Robin Murphy <robin.murphy@arm.com>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"will@kernel.org" <will@kernel.org>,
	"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>
Subject: Re: [PATCH] iommu/amd: Add Secure ATS support
Date: Mon, 10 Mar 2025 22:37:07 +0530	[thread overview]
Message-ID: <f728d10e-97d0-44eb-ab2f-0e40d7d5f810@amd.com> (raw)
In-Reply-To: <BN9PR11MB5276786C4BF482199872BB2E8CCB2@BN9PR11MB5276.namprd11.prod.outlook.com>

Kevin,


On 3/5/2025 8:54 AM, Tian, Kevin wrote:
>> From: Vasant Hegde <vasant.hegde@amd.com>
>> Sent: Monday, March 3, 2025 7:42 PM
>>
>> Currently AMD driver enables device ATS and configures IOMMU DTE (per
>> device
>> setup) during attach_device() path. There was a discussion to move device
>> ATS
>> enablement to probe() path. We will move it to probe() path soon.
> 
> Based on discussion in this thread I'd expect doing it during
> attach is the long-term direction.

AMD does actual enablement of ATS per device (via DTE setting) in attach device
path. So I see this as default requirement. Of course some of policy enforcement
we can implement later.

May be we should document full flow in detail and make sure it takes care of all
HW requirements. Then decide when to do each part.

> 
>>
>>
>>>
>>> On the other hand, we may just define the knob as sats required or not.
>>> This is just a knob to let kernel know if the iommu driver needs to enable
>>> sats or not. While leave the ATS enabling policy unchanged. This means
>>> we need to probe the sats capability of iommu hw before creating the knob
>>> in sysfs.
>>
>> Right. Lets see if below flow covers all the requirement
>>   - Define new flags
>>     IOMMU_HWPT_FLAGS_SATS / IOMMU_HWPT_FLAGS_ATS
> 
> SATS policy should be managed by the sys admin, while ATS feature
> itself can be opted by the user.

"user" you mean like iommufd during domain allocation?

> 
>>
>>   - Enhance 'struct iommu_device' to include ATS flags (NO ATS, ATS, SECURE
>> ATS)
>>     iommu_device->ats_flag
> 
> as commented by Jason this needs to differentiate domain types,
> either due to hw lacking of support for certain types or the admin
> imposes different security levels across different types.

Right.

> 
>>
>>   - During probe() driver will update this field (similar to max_pasids)
>>     If (IOMMU needs Secure ATS always)
>> 	iommu_device->ats_flag = IOMMU_HWPT_FLAGS_SATS
>>     else if (device supports ATS and IOMMU supports Secure ATS)
>> 	iommu_device->ats_flag = IOMMU_HWPT_FLAGS_SATS |
>> IOMMU_HWPT_FLAGS_ATS
>>     else if (device supports ATS and IOMMU supports ATS)
>> 	iommu_device->ats_flag = IOMMU_HWPT_FLAGS_ATS
>>     else
>> 	iommu_device->ats_flag = <NO FLAGS> (May be have one more flag
>> IOMMU_HWPT_FLAGS_NO_ATS) ?
> 
> Here the device->ats_flag should be more an ats_policy thing? At
> probe time it's assigned with a default policy according to device
> type, platform requirement, etc. and later exposed via sysfs for
> admin opt.

Right. We can call it as ats_policy (expected/desired mode by HW driver).
So now core knows HW requirement. Also default and global policy enforcement
(via kernel command line).

During domain allocation, we can enforce required domain specific policy.


> 
> Actual ats enabling/enforcement is done at attach time, according
> to ats_policy.

Then during attach_dev() we pass those flags as argument?

> 
>>
>>
>>   - Based on default setting, kernel command line option and probe() data,
>> core
>> layer can adjust ATS capability. i. e.
>>      - If we have kernel command line (say iommu.ats=<x>), use that data for
>> all
>> ATS capable device.
>>      - If not, apply default
>>       untrusted device -> force secure ATS or no ats
>>       If HW needs Secure ATS always , enable Secure ATS
>>       For all other cases use ATS
> 
> this is an interesting one, i.e. whether we still want a global iommu
> option to enable sats for all applicable devices/domains. the pros
> is that it is simple and allows underlying driver to add sats support
> before a more flexible sysfs interface is ready. the downside is that
> it's unclear which device/domain types are affected by sats on
> different platforms w/o digging into the hw detail...

I preferred global option (that's why this patch added amd_iommu=sats) because
as you said its simple, can be enforced at global level. Also w/ sysfs interface
we have to update for each device/group indivisual. Another drawback is, w/
sysfs first we have to unbind the driver (which may not be possible always),
modify ATS setting, then bind driver again.

In Summary, I visualize it three level:
  - Default policy implemented in kernel
  - Global policy enforcement by admin via kernel command line
  - Per group/device level enforcement via sysfs

Do we need something for iommufd/vfio? Where user can tell desired mode while
allocating HWPT domains?

-Vasant








  reply	other threads:[~2025-03-10 17:07 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 10:58 [PATCH] iommu/amd: Add Secure ATS support Vasant Hegde
2025-02-25 12:30 ` Yi Liu
2025-02-25 13:18   ` Robin Murphy
2025-02-25 13:57     ` Yi Liu
2025-02-25 14:55     ` Jason Gunthorpe
2025-02-26  1:09       ` Yi Liu
2025-02-26  1:13         ` Jason Gunthorpe
2025-02-26  1:27           ` Yi Liu
2025-02-26  2:52           ` Tian, Kevin
2025-02-26  1:12       ` Tian, Kevin
2025-02-26  1:17         ` Jason Gunthorpe
2025-02-26  2:50           ` Tian, Kevin
2025-02-26 12:57             ` Jason Gunthorpe
2025-02-26  7:05           ` Tian, Kevin
2025-02-26 12:58             ` Jason Gunthorpe
2025-02-27 15:27             ` Vasant Hegde
2025-02-28  6:32               ` Tian, Kevin
2025-02-28  7:43                 ` Yi Liu
2025-02-28  8:30                   ` Vasant Hegde
2025-02-28  8:47                     ` Yi Liu
2025-02-28  8:47                       ` Vasant Hegde
2025-03-02  8:10                         ` Yi Liu
2025-03-03  3:00                           ` Tian, Kevin
2025-03-04  6:58                             ` Yi Liu
2025-03-03 11:42                           ` Vasant Hegde
2025-03-05  3:24                             ` Tian, Kevin
2025-03-10 17:07                               ` Vasant Hegde [this message]
2025-03-12  7:15                                 ` Tian, Kevin
2025-03-17  8:56                                   ` Vasant Hegde
2025-04-07  5:28                                     ` Tian, Kevin
2025-03-03 18:38                           ` Jason Gunthorpe
2025-03-04  2:16                             ` Baolu Lu
2025-03-04 14:18                               ` Jason Gunthorpe
2025-03-05  2:45                                 ` Baolu Lu
2025-03-05  2:46                                 ` Tian, Kevin
2025-03-04  6:50                             ` Yi Liu
2025-03-04 10:46                               ` Vasant Hegde
2025-03-04 14:20                               ` Jason Gunthorpe
2025-03-05  2:50                                 ` Tian, Kevin
2025-03-05 17:22                                   ` Jason Gunthorpe
2025-03-06  2:41                                     ` Tian, Kevin
2025-03-14 12:54                                 ` Yi Liu
2025-03-04 10:15                             ` Vasant Hegde
2025-03-04 14:24                               ` Jason Gunthorpe
2025-03-10 16:35                                 ` Vasant Hegde
2025-03-14 12:09                                 ` Yi Liu
2025-03-19 19:52                                   ` Jason Gunthorpe
2025-03-14 12:22                               ` Yi Liu
2025-02-28  8:26                 ` Vasant Hegde
2025-02-28 14:56               ` Jason Gunthorpe
2025-03-03  2:55                 ` Tian, Kevin
2025-03-10 14:13                   ` Vasant Hegde
2025-03-12  6:55                     ` Tian, Kevin
2025-03-03 11:56                 ` Vasant Hegde
2025-02-26  4:47       ` Vasant Hegde
2025-02-26  7:10         ` Tian, Kevin
2025-02-26 13:01           ` Jason Gunthorpe
2025-02-26 22:42           ` Jerry Snitselaar
2025-02-27 16:04           ` Vasant Hegde
2025-02-28  0:04             ` Jason Gunthorpe
2025-02-28  6:18               ` Tian, Kevin
2025-02-28  1:47             ` Baolu Lu
2025-02-28  6:15               ` Tian, Kevin
2025-02-28  8:53                 ` Vasant Hegde
2025-02-28 14:53                 ` Jason Gunthorpe
2025-03-03  2:43                   ` Tian, Kevin
2025-02-28  8:38               ` Vasant Hegde
2025-02-26  4:33   ` Vasant Hegde

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=f728d10e-97d0-44eb-ab2f-0e40d7d5f810@amd.com \
    --to=vasant.hegde@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=will@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.