From: Lu Baolu <baolu.lu@linux.intel.com>
To: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
Cc: Camille Lu <camille.lu@hpe.com>,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v5.4 1/1] iommu/vt-d: Fix agaw for a supported 48 bit guest address width
Date: Wed, 7 Apr 2021 09:43:50 +0800 [thread overview]
Message-ID: <c525cdda-2286-c8db-bae4-e0092e5c830a@linux.intel.com> (raw)
In-Reply-To: <20210406163534.40735-1-saeed.mirzamohammadi@oracle.com>
Hi Saeed,
On 4/7/21 12:35 AM, Saeed Mirzamohammadi wrote:
> The IOMMU driver calculates the guest addressability for a DMA request
> based on the value of the mgaw reported from the IOMMU. However, this
> is a fused value and as mentioned in the spec, the guest width
> should be calculated based on the supported adjusted guest address width
> (SAGAW).
>
> This is from specification:
> "Guest addressability for a given DMA request is limited to the
> minimum of the value reported through this field and the adjusted
> guest address width of the corresponding page-table structure.
> (Adjusted guest address widths supported by hardware are reported
> through the SAGAW field)."
>
> This causes domain initialization to fail and following
> errors appear for EHCI PCI driver:
>
> [ 2.486393] ehci-pci 0000:01:00.4: EHCI Host Controller
> [ 2.486624] ehci-pci 0000:01:00.4: new USB bus registered, assigned bus
> number 1
> [ 2.489127] ehci-pci 0000:01:00.4: DMAR: Allocating domain failed
> [ 2.489350] ehci-pci 0000:01:00.4: DMAR: 32bit DMA uses non-identity
> mapping
> [ 2.489359] ehci-pci 0000:01:00.4: can't setup: -12
> [ 2.489531] ehci-pci 0000:01:00.4: USB bus 1 deregistered
> [ 2.490023] ehci-pci 0000:01:00.4: init 0000:01:00.4 fail, -12
> [ 2.490358] ehci-pci: probe of 0000:01:00.4 failed with error -12
>
> This issue happens when the value of the sagaw corresponds to a
> 48-bit agaw. This fix updates the calculation of the agaw based on
> the IOMMU's sagaw value.
>
> Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
> Tested-by: Camille Lu <camille.lu@hpe.com>
> ---
> drivers/iommu/intel-iommu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 953d86ca6d2b..396e14fad54b 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -1867,8 +1867,8 @@ static int domain_init(struct dmar_domain *domain, struct intel_iommu *iommu,
> domain_reserve_special_ranges(domain);
>
> /* calculate AGAW */
> - if (guest_width > cap_mgaw(iommu->cap))
> - guest_width = cap_mgaw(iommu->cap);
> + if (guest_width > agaw_to_width(iommu->agaw))
> + guest_width = agaw_to_width(iommu->agaw);
The spec requires to use a minimum of MGAW and AGAW, so why not,
cap_width = min_t(int, cap_mgaw(iommu->cap), agaw_to_width(iommu->agaw));
if (guest_width > cap_width)
guest_width = cap_width;
Best regards,
baolu
> domain->gaw = guest_width;
> adjust_width = guestwidth_to_adjustwidth(guest_width);
> agaw = width_to_agaw(adjust_width);
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
Cc: baolu.lu@linux.intel.com, Camille Lu <camille.lu@hpe.com>,
David Woodhouse <dwmw2@infradead.org>,
Joerg Roedel <joro@8bytes.org>,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5.4 1/1] iommu/vt-d: Fix agaw for a supported 48 bit guest address width
Date: Wed, 7 Apr 2021 09:43:50 +0800 [thread overview]
Message-ID: <c525cdda-2286-c8db-bae4-e0092e5c830a@linux.intel.com> (raw)
In-Reply-To: <20210406163534.40735-1-saeed.mirzamohammadi@oracle.com>
Hi Saeed,
On 4/7/21 12:35 AM, Saeed Mirzamohammadi wrote:
> The IOMMU driver calculates the guest addressability for a DMA request
> based on the value of the mgaw reported from the IOMMU. However, this
> is a fused value and as mentioned in the spec, the guest width
> should be calculated based on the supported adjusted guest address width
> (SAGAW).
>
> This is from specification:
> "Guest addressability for a given DMA request is limited to the
> minimum of the value reported through this field and the adjusted
> guest address width of the corresponding page-table structure.
> (Adjusted guest address widths supported by hardware are reported
> through the SAGAW field)."
>
> This causes domain initialization to fail and following
> errors appear for EHCI PCI driver:
>
> [ 2.486393] ehci-pci 0000:01:00.4: EHCI Host Controller
> [ 2.486624] ehci-pci 0000:01:00.4: new USB bus registered, assigned bus
> number 1
> [ 2.489127] ehci-pci 0000:01:00.4: DMAR: Allocating domain failed
> [ 2.489350] ehci-pci 0000:01:00.4: DMAR: 32bit DMA uses non-identity
> mapping
> [ 2.489359] ehci-pci 0000:01:00.4: can't setup: -12
> [ 2.489531] ehci-pci 0000:01:00.4: USB bus 1 deregistered
> [ 2.490023] ehci-pci 0000:01:00.4: init 0000:01:00.4 fail, -12
> [ 2.490358] ehci-pci: probe of 0000:01:00.4 failed with error -12
>
> This issue happens when the value of the sagaw corresponds to a
> 48-bit agaw. This fix updates the calculation of the agaw based on
> the IOMMU's sagaw value.
>
> Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
> Tested-by: Camille Lu <camille.lu@hpe.com>
> ---
> drivers/iommu/intel-iommu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 953d86ca6d2b..396e14fad54b 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -1867,8 +1867,8 @@ static int domain_init(struct dmar_domain *domain, struct intel_iommu *iommu,
> domain_reserve_special_ranges(domain);
>
> /* calculate AGAW */
> - if (guest_width > cap_mgaw(iommu->cap))
> - guest_width = cap_mgaw(iommu->cap);
> + if (guest_width > agaw_to_width(iommu->agaw))
> + guest_width = agaw_to_width(iommu->agaw);
The spec requires to use a minimum of MGAW and AGAW, so why not,
cap_width = min_t(int, cap_mgaw(iommu->cap), agaw_to_width(iommu->agaw));
if (guest_width > cap_width)
guest_width = cap_width;
Best regards,
baolu
> domain->gaw = guest_width;
> adjust_width = guestwidth_to_adjustwidth(guest_width);
> agaw = width_to_agaw(adjust_width);
>
next prev parent reply other threads:[~2021-04-07 1:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 16:35 [PATCH v5.4 1/1] iommu/vt-d: Fix agaw for a supported 48 bit guest address width Saeed Mirzamohammadi
2021-04-06 16:35 ` Saeed Mirzamohammadi
2021-04-07 1:43 ` Lu Baolu [this message]
2021-04-07 1:43 ` Lu Baolu
2021-04-07 18:41 ` Saeed Mirzamohammadi
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=c525cdda-2286-c8db-bae4-e0092e5c830a@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=camille.lu@hpe.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=saeed.mirzamohammadi@oracle.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.