All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Wang2 <wei.wang2@amd.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 2 of 5] amd iommu: Fix iommu page size encoding when page order > 0
Date: Thu, 3 Nov 2011 17:54:02 +0100	[thread overview]
Message-ID: <201111031754.02201.wei.wang2@amd.com> (raw)
In-Reply-To: <4EB2CD33020000780005ED24@nat28.tlf.novell.com>

[-- Attachment #1: Type: text/plain, Size: 3019 bytes --]

On Thursday 03 November 2011 17:19:47 Jan Beulich wrote:
> >>> On 03.11.11 at 16:48, Wei Wang <wei.wang2@amd.com> wrote:
> >
> > # HG changeset patch
> > # User Wei Wang <wei.wang2@amd.com>
> > # Date 1320334553 -3600
> > # Node ID 1bf06c8d2c70e9af610e12a7592c466a799b0de1
> > # Parent  ef46c471a11f83d07e256ad2e0b868828f45ef63
> > amd iommu: Fix iommu page size encoding when page order > 0.
> > Fix io address in invalid all pages command.
> >
> > Signed-off-by: Wei Wang <wei.wang2@amd.com>
> >
> > diff -r ef46c471a11f -r 1bf06c8d2c70
> > xen/drivers/passthrough/amd/iommu_map.c ---
> > a/xen/drivers/passthrough/amd/iommu_map.c	Thu Nov 03 16:35:51 2011 +0100
> > +++ b/xen/drivers/passthrough/amd/iommu_map.c	Thu Nov 03 16:35:53 2011
> > +0100 @@ -77,23 +77,24 @@ static void invalidate_iommu_pages(struc
> >  {
> >      u64 addr_lo, addr_hi;
> >      u32 cmd[4], entry;
> > -    u64 mask = 0;
> >      int sflag = 0, pde = 0;
> >
> > +    ASSERT ( order == 0 || order == 9 || order == 18 );
> > +
> > +    /* All pages associated with the domainID are invalidated */
> > +    if ( order || (io_addr == INV_IOMMU_ALL_PAGES_ADDRESS ) )
> > +    {
> > +        sflag = 1;
> > +        pde = 1;
> > +    }
> > +
> >      /* If sflag == 1, the size of the invalidate command is determined
> >       by the first zero bit in the address starting from Address[12] */
> > -    if ( order == 9 || order == 18 )
> > +    if ( order )
> >      {
> > -        mask = ((1ULL << (order - 1)) - 1) << PAGE_SHIFT;
> > -        io_addr |= mask;
> > -        sflag = 1;
> > -    }
> > -
> > -    /* All pages associated with the domainID are invalidated */
> > -    else if ( io_addr == 0x7FFFFFFFFFFFF000ULL )
> > -    {
> > -        sflag = 1;
> > -        pde = 1;
> > +        u64 mask = 1ULL << (order - 1 + PAGE_SHIFT);
> > +        io_addr &= ~mask;
> > +        io_addr |= mask - 1;
> >      }
> >
> >      addr_lo = io_addr & DMA_32BIT_MASK;
> > @@ -917,7 +918,7 @@ static void _amd_iommu_flush_pages(struc
> >
> >  void amd_iommu_flush_all_pages(struct domain *d)
> >  {
> > -    _amd_iommu_flush_pages(d, 0x7FFFFFFFFFFFFULL, 0);
> > +    _amd_iommu_flush_pages(d, INV_IOMMU_ALL_PAGES_ADDRESS, 0);
> >  }
> >
> >  void amd_iommu_flush_pages(struct domain *d,
> > diff -r ef46c471a11f -r 1bf06c8d2c70
> > xen/include/asm-x86/hvm/svm/amd-iommu-defs.h ---
> > a/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h	Thu Nov 03 16:35:51 2011
> > +0100 +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h	Thu Nov 03
> > 16:35:53 2011 +0100
> > @@ -407,4 +407,6 @@
> >  #define INT_REMAP_ENTRY_VECTOR_MASK     0x00FF0000
> >  #define INT_REMAP_ENTRY_VECTOR_SHIFT    16
> >
> > +#define INV_IOMMU_ALL_PAGES_ADDRESS      (1ULL << 63) - 1
>
> Please parenthesize this properly.

Fixed, please see attachment.
Thanks,
Wei


> > +
> >  #endif /* _ASM_X86_64_AMD_IOMMU_DEFS_H */
> >
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xensource.com
> > http://lists.xensource.com/xen-devel



[-- Attachment #2: ats_02.patch --]
[-- Type: text/x-diff, Size: 2264 bytes --]

# HG changeset patch
# Parent ef46c471a11f83d07e256ad2e0b868828f45ef63
# User Wei Wang <wei.wang2@amd.com>
amd iommu: Fix iommu page size encoding when page order > 0.
Fix io address in invalid all pages command.

Signed-off-by: Wei Wang <wei.wang2@amd.com>

diff -r ef46c471a11f xen/drivers/passthrough/amd/iommu_map.c
--- a/xen/drivers/passthrough/amd/iommu_map.c	Thu Nov 03 16:35:51 2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_map.c	Thu Nov 03 17:51:16 2011 +0100
@@ -77,23 +77,24 @@ static void invalidate_iommu_pages(struc
 {
     u64 addr_lo, addr_hi;
     u32 cmd[4], entry;
-    u64 mask = 0;
     int sflag = 0, pde = 0;
 
+    ASSERT ( order == 0 || order == 9 || order == 18 );
+
+    /* All pages associated with the domainID are invalidated */
+    if ( order || (io_addr == INV_IOMMU_ALL_PAGES_ADDRESS ) )
+    {
+        sflag = 1;
+        pde = 1;
+    }
+
     /* If sflag == 1, the size of the invalidate command is determined
      by the first zero bit in the address starting from Address[12] */
-    if ( order == 9 || order == 18 )
+    if ( order )
     {
-        mask = ((1ULL << (order - 1)) - 1) << PAGE_SHIFT;
-        io_addr |= mask;
-        sflag = 1;
-    }
-
-    /* All pages associated with the domainID are invalidated */
-    else if ( io_addr == 0x7FFFFFFFFFFFF000ULL )
-    {
-        sflag = 1;
-        pde = 1;
+        u64 mask = 1ULL << (order - 1 + PAGE_SHIFT);
+        io_addr &= ~mask;
+        io_addr |= mask - 1;
     }
 
     addr_lo = io_addr & DMA_32BIT_MASK;
@@ -917,7 +918,7 @@ static void _amd_iommu_flush_pages(struc
 
 void amd_iommu_flush_all_pages(struct domain *d)
 {
-    _amd_iommu_flush_pages(d, 0x7FFFFFFFFFFFFULL, 0);
+    _amd_iommu_flush_pages(d, INV_IOMMU_ALL_PAGES_ADDRESS, 0);
 }
 
 void amd_iommu_flush_pages(struct domain *d,
diff -r ef46c471a11f xen/include/asm-x86/hvm/svm/amd-iommu-defs.h
--- a/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h	Thu Nov 03 16:35:51 2011 +0100
+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-defs.h	Thu Nov 03 17:51:16 2011 +0100
@@ -407,4 +407,6 @@
 #define INT_REMAP_ENTRY_VECTOR_MASK     0x00FF0000
 #define INT_REMAP_ENTRY_VECTOR_SHIFT    16
 
+#define INV_IOMMU_ALL_PAGES_ADDRESS      ((1ULL << 63) - 1)
+
 #endif /* _ASM_X86_64_AMD_IOMMU_DEFS_H */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2011-11-03 16:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-03 15:48 [PATCH 0 of 5] amd iommu: Add ATS support (v4) Wei Wang
2011-11-03 15:48 ` [PATCH 1 of 5] ats: Move some ats functions to a new directory Wei Wang
2011-11-03 16:21   ` Jan Beulich
2011-11-03 15:48 ` [PATCH 2 of 5] amd iommu: Fix iommu page size encoding when page order > 0 Wei Wang
2011-11-03 16:19   ` Jan Beulich
2011-11-03 16:54     ` Wei Wang2 [this message]
2011-11-03 15:48 ` [PATCH 3 of 5] ats: Add new ATS helper functions Wei Wang
2011-11-03 16:22   ` Jan Beulich
2011-11-03 15:48 ` [PATCH 4 of 5] amd iommu: add iotlb invalidation command Wei Wang
2011-11-03 15:48 ` [PATCH 5 of 5] amd iommu: enable ats devices Wei Wang
  -- strict thread matches above, loose matches on Subject: below --
2011-11-03 10:13 [PATCH 0 of 5] amd iommu: Add ATS support (v3) Wei Wang
2011-11-03 10:13 ` [PATCH 2 of 5] amd iommu: Fix iommu page size encoding when page order > 0 Wei Wang
2011-11-03 12:49   ` Jan Beulich
2011-11-03 12:52     ` Jan Beulich
2011-11-03 13:26     ` Wei Wang2
2011-11-03 13:28       ` [PATCH 2 of 5] amd iommu: Fix iommu page size encoding when page order> 0 Jan Beulich

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=201111031754.02201.wei.wang2@amd.com \
    --to=wei.wang2@amd.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xensource.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.