All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	vasant.hegde@amd.com, jon.grimm@amd.com
Subject: Re: [PATCH v2] iommu/amd: Set translation valid bit only when IO page tables are in used
Date: Fri, 20 May 2022 10:09:33 +0200	[thread overview]
Message-ID: <YodMvV/8eii4KCLg@8bytes.org> (raw)
In-Reply-To: <1dfaf07e-040e-848b-db7c-86a107fd5cb3@amd.com>

Hi Suravee,

On Mon, May 16, 2022 at 07:27:51PM +0700, Suravee Suthikulpanit wrote:
> Due to the new restriction (please see the IOMMU spec Rev 3.06-PUB - Apr 2021
> https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf) where the use of
> DTE[Mode]=0 is not supported on systems that are SNP-enabled (i.e. EFR[SNPSup]=1),
> the IOMMU HW looks at the DTE[TV] bit to determine if it needs to handle the v1 page table.
> When the HW encounters DTE entry with TV=1, V=1, Mode=0, it would generate
> ILLEGAL_DEV_TABLE_ENTRY event.

Ah, that is the part I was missing, thanks.

> - I am still trying to see what is the best way to force Linux to not allow
> Mode=0 (i.e. iommu=pt mode). Any thoughts?

I think this needs a general approach. First start in the AMD IOMMU
driver:

	1) Do not set DTE.TV=1 bit iff SNP-Support is enabled
	2) Fail to allocate passthrough domains when SNP support is
	   enabled.

Then test how the IOMMU core layer handles that. In fact the IOMMU layer
needs to adjust its decisions so that:

	1) It uses translated-mode by default
	2) passthrough domains are disallowed and can not be chosen, not
	   on the kernel command line and not at runtime.

Ideally this needs some kind of arch-callback to set the appropriate
defaults.

> - Also, it seems that the current iommu v2 page table use case, where GVA->GPA=SPA
> will no longer be supported on system w/ SNPSup=1. Any thoughts?

Support for that is not upstream yet, it should be easy to disallow this
configuration and just use the v1 page-tables when SNP is active. This
can be handled entirely inside the AMD IOMMU driver.

Regards,

	Joerg

WARNING: multiple messages have this Message-ID (diff)
From: Joerg Roedel <joro@8bytes.org>
To: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Cc: iommu@lists.linux-foundation.org, jon.grimm@amd.com,
	linux-kernel@vger.kernel.org, vasant.hegde@amd.com
Subject: Re: [PATCH v2] iommu/amd: Set translation valid bit only when IO page tables are in used
Date: Fri, 20 May 2022 10:09:33 +0200	[thread overview]
Message-ID: <YodMvV/8eii4KCLg@8bytes.org> (raw)
In-Reply-To: <1dfaf07e-040e-848b-db7c-86a107fd5cb3@amd.com>

Hi Suravee,

On Mon, May 16, 2022 at 07:27:51PM +0700, Suravee Suthikulpanit wrote:
> Due to the new restriction (please see the IOMMU spec Rev 3.06-PUB - Apr 2021
> https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf) where the use of
> DTE[Mode]=0 is not supported on systems that are SNP-enabled (i.e. EFR[SNPSup]=1),
> the IOMMU HW looks at the DTE[TV] bit to determine if it needs to handle the v1 page table.
> When the HW encounters DTE entry with TV=1, V=1, Mode=0, it would generate
> ILLEGAL_DEV_TABLE_ENTRY event.

Ah, that is the part I was missing, thanks.

> - I am still trying to see what is the best way to force Linux to not allow
> Mode=0 (i.e. iommu=pt mode). Any thoughts?

I think this needs a general approach. First start in the AMD IOMMU
driver:

	1) Do not set DTE.TV=1 bit iff SNP-Support is enabled
	2) Fail to allocate passthrough domains when SNP support is
	   enabled.

Then test how the IOMMU core layer handles that. In fact the IOMMU layer
needs to adjust its decisions so that:

	1) It uses translated-mode by default
	2) passthrough domains are disallowed and can not be chosen, not
	   on the kernel command line and not at runtime.

Ideally this needs some kind of arch-callback to set the appropriate
defaults.

> - Also, it seems that the current iommu v2 page table use case, where GVA->GPA=SPA
> will no longer be supported on system w/ SNPSup=1. Any thoughts?

Support for that is not upstream yet, it should be easy to disallow this
configuration and just use the v1 page-tables when SNP is active. This
can be handled entirely inside the AMD IOMMU driver.

Regards,

	Joerg
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2022-05-20  8:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  7:48 [PATCH v2] iommu/amd: Set translation valid bit only when IO page tables are in used Suravee Suthikulpanit via iommu
2022-05-09  7:48 ` Suravee Suthikulpanit
2022-05-13 13:07 ` Joerg Roedel
2022-05-13 13:07   ` Joerg Roedel
2022-05-16 12:27   ` Suravee Suthikulpanit
2022-05-16 12:27     ` Suravee Suthikulpanit via iommu
2022-05-20  8:09     ` Joerg Roedel [this message]
2022-05-20  8:09       ` Joerg Roedel
2022-05-20  8:54       ` Robin Murphy
2022-05-20  8:54         ` Robin Murphy
2022-05-20  8:58         ` Joerg Roedel
2022-05-20  8:58           ` Joerg Roedel
2022-05-20  9:18           ` Robin Murphy
2022-05-20  9:18             ` Robin Murphy
2022-05-26  3:29       ` Suravee Suthikulpanit
2022-05-26  3:29         ` Suravee Suthikulpanit via iommu
2022-06-07  8:00         ` Joerg Roedel
2022-06-07  8:00           ` Joerg Roedel

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=YodMvV/8eii4KCLg@8bytes.org \
    --to=joro@8bytes.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jon.grimm@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.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.