All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] VT-d: print_vtd_entries() should cope with superpages
@ 2015-02-27  9:52 Jan Beulich
  2015-02-27 10:03 ` Roger Pau Monné
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jan Beulich @ 2015-02-27  9:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Yang Z Zhang, Kevin Tian, Roger Pau Monne

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

Even if VT-d code alone (i.e. when not sharing tables with EPT) still
doesn't support superpages, this function - invoked upon DMA remapping
faults - needs to cope with such.

While at it also replace a few more plain numbers with suitable named
constants.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/drivers/passthrough/vtd/iommu.h
+++ b/xen/drivers/passthrough/vtd/iommu.h
@@ -268,18 +268,22 @@ struct dma_pte {
 };
 #define DMA_PTE_READ (1)
 #define DMA_PTE_WRITE (2)
+#define DMA_PTE_PROT (DMA_PTE_READ | DMA_PTE_WRITE)
+#define DMA_PTE_SP   (1 << 7)
 #define DMA_PTE_SNP  (1 << 11)
 #define dma_clear_pte(p)    do {(p).val = 0;} while(0)
 #define dma_set_pte_readable(p) do {(p).val |= DMA_PTE_READ;} while(0)
 #define dma_set_pte_writable(p) do {(p).val |= DMA_PTE_WRITE;} while(0)
-#define dma_set_pte_superpage(p) do {(p).val |= (1 << 7);} while(0)
+#define dma_set_pte_superpage(p) do {(p).val |= DMA_PTE_SP;} while(0)
 #define dma_set_pte_snp(p)  do {(p).val |= DMA_PTE_SNP;} while(0)
-#define dma_set_pte_prot(p, prot) \
-            do {(p).val = ((p).val & ~3) | ((prot) & 3); } while (0)
+#define dma_set_pte_prot(p, prot) do { \
+        (p).val = ((p).val & ~DMA_PTE_PROT) | ((prot) & DMA_PTE_PROT); \
+    } while (0)
 #define dma_pte_addr(p) ((p).val & PADDR_MASK & PAGE_MASK_4K)
 #define dma_set_pte_addr(p, addr) do {\
             (p).val |= ((addr) & PAGE_MASK_4K); } while (0)
-#define dma_pte_present(p) (((p).val & 3) != 0)
+#define dma_pte_present(p) (((p).val & DMA_PTE_PROT) != 0)
+#define dma_pte_superpage(p) (((p).val & DMA_PTE_SP) != 0)
 
 /* interrupt remap entry */
 struct iremap_entry {
--- a/xen/drivers/passthrough/vtd/utils.c
+++ b/xen/drivers/passthrough/vtd/utils.c
@@ -179,6 +179,8 @@ void print_vtd_entries(struct iommu *iom
             printk("    l%d[%x] not present\n", level, l_index);
             break;
         }
+        if ( dma_pte_superpage(pte) )
+            break;
         val = dma_pte_addr(pte);
     } while ( --level );
 }




[-- Attachment #2: VT-d-print-entries-SP.patch --]
[-- Type: text/plain, Size: 2108 bytes --]

VT-d: print_vtd_entries() should cope with superpages

Even if VT-d code alone (i.e. when not sharing tables with EPT) still
doesn't support superpages, this function - invoked upon DMA remapping
faults - needs to cope with such.

While at it also replace a few more plain numbers with suitable named
constants.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/drivers/passthrough/vtd/iommu.h
+++ b/xen/drivers/passthrough/vtd/iommu.h
@@ -268,18 +268,22 @@ struct dma_pte {
 };
 #define DMA_PTE_READ (1)
 #define DMA_PTE_WRITE (2)
+#define DMA_PTE_PROT (DMA_PTE_READ | DMA_PTE_WRITE)
+#define DMA_PTE_SP   (1 << 7)
 #define DMA_PTE_SNP  (1 << 11)
 #define dma_clear_pte(p)    do {(p).val = 0;} while(0)
 #define dma_set_pte_readable(p) do {(p).val |= DMA_PTE_READ;} while(0)
 #define dma_set_pte_writable(p) do {(p).val |= DMA_PTE_WRITE;} while(0)
-#define dma_set_pte_superpage(p) do {(p).val |= (1 << 7);} while(0)
+#define dma_set_pte_superpage(p) do {(p).val |= DMA_PTE_SP;} while(0)
 #define dma_set_pte_snp(p)  do {(p).val |= DMA_PTE_SNP;} while(0)
-#define dma_set_pte_prot(p, prot) \
-            do {(p).val = ((p).val & ~3) | ((prot) & 3); } while (0)
+#define dma_set_pte_prot(p, prot) do { \
+        (p).val = ((p).val & ~DMA_PTE_PROT) | ((prot) & DMA_PTE_PROT); \
+    } while (0)
 #define dma_pte_addr(p) ((p).val & PADDR_MASK & PAGE_MASK_4K)
 #define dma_set_pte_addr(p, addr) do {\
             (p).val |= ((addr) & PAGE_MASK_4K); } while (0)
-#define dma_pte_present(p) (((p).val & 3) != 0)
+#define dma_pte_present(p) (((p).val & DMA_PTE_PROT) != 0)
+#define dma_pte_superpage(p) (((p).val & DMA_PTE_SP) != 0)
 
 /* interrupt remap entry */
 struct iremap_entry {
--- a/xen/drivers/passthrough/vtd/utils.c
+++ b/xen/drivers/passthrough/vtd/utils.c
@@ -179,6 +179,8 @@ void print_vtd_entries(struct iommu *iom
             printk("    l%d[%x] not present\n", level, l_index);
             break;
         }
+        if ( dma_pte_superpage(pte) )
+            break;
         val = dma_pte_addr(pte);
     } while ( --level );
 }

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] VT-d: print_vtd_entries() should cope with superpages
  2015-02-27  9:52 [PATCH] VT-d: print_vtd_entries() should cope with superpages Jan Beulich
@ 2015-02-27 10:03 ` Roger Pau Monné
  2015-02-27 10:41 ` Andrew Cooper
  2015-03-09  3:10 ` Tian, Kevin
  2 siblings, 0 replies; 4+ messages in thread
From: Roger Pau Monné @ 2015-02-27 10:03 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Yang Z Zhang, Kevin Tian

El 27/02/15 a les 10.52, Jan Beulich ha escrit:
> Even if VT-d code alone (i.e. when not sharing tables with EPT) still
> doesn't support superpages, this function - invoked upon DMA remapping
> faults - needs to cope with such.
> 
> While at it also replace a few more plain numbers with suitable named
> constants.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Thanks for this, looks fine to me:

Acked-by: Roger Pau Monné <roger.pau@citrix.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] VT-d: print_vtd_entries() should cope with superpages
  2015-02-27  9:52 [PATCH] VT-d: print_vtd_entries() should cope with superpages Jan Beulich
  2015-02-27 10:03 ` Roger Pau Monné
@ 2015-02-27 10:41 ` Andrew Cooper
  2015-03-09  3:10 ` Tian, Kevin
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2015-02-27 10:41 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Yang Z Zhang, Kevin Tian, Roger Pau Monne


[-- Attachment #1.1: Type: text/plain, Size: 2337 bytes --]

On 27/02/15 09:52, Jan Beulich wrote:
> Even if VT-d code alone (i.e. when not sharing tables with EPT) still
> doesn't support superpages, this function - invoked upon DMA remapping
> faults - needs to cope with such.
>
> While at it also replace a few more plain numbers with suitable named
> constants.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

>
> --- a/xen/drivers/passthrough/vtd/iommu.h
> +++ b/xen/drivers/passthrough/vtd/iommu.h
> @@ -268,18 +268,22 @@ struct dma_pte {
>  };
>  #define DMA_PTE_READ (1)
>  #define DMA_PTE_WRITE (2)
> +#define DMA_PTE_PROT (DMA_PTE_READ | DMA_PTE_WRITE)
> +#define DMA_PTE_SP   (1 << 7)
>  #define DMA_PTE_SNP  (1 << 11)
>  #define dma_clear_pte(p)    do {(p).val = 0;} while(0)
>  #define dma_set_pte_readable(p) do {(p).val |= DMA_PTE_READ;} while(0)
>  #define dma_set_pte_writable(p) do {(p).val |= DMA_PTE_WRITE;} while(0)
> -#define dma_set_pte_superpage(p) do {(p).val |= (1 << 7);} while(0)
> +#define dma_set_pte_superpage(p) do {(p).val |= DMA_PTE_SP;} while(0)
>  #define dma_set_pte_snp(p)  do {(p).val |= DMA_PTE_SNP;} while(0)
> -#define dma_set_pte_prot(p, prot) \
> -            do {(p).val = ((p).val & ~3) | ((prot) & 3); } while (0)
> +#define dma_set_pte_prot(p, prot) do { \
> +        (p).val = ((p).val & ~DMA_PTE_PROT) | ((prot) & DMA_PTE_PROT); \
> +    } while (0)
>  #define dma_pte_addr(p) ((p).val & PADDR_MASK & PAGE_MASK_4K)
>  #define dma_set_pte_addr(p, addr) do {\
>              (p).val |= ((addr) & PAGE_MASK_4K); } while (0)
> -#define dma_pte_present(p) (((p).val & 3) != 0)
> +#define dma_pte_present(p) (((p).val & DMA_PTE_PROT) != 0)
> +#define dma_pte_superpage(p) (((p).val & DMA_PTE_SP) != 0)
>  
>  /* interrupt remap entry */
>  struct iremap_entry {
> --- a/xen/drivers/passthrough/vtd/utils.c
> +++ b/xen/drivers/passthrough/vtd/utils.c
> @@ -179,6 +179,8 @@ void print_vtd_entries(struct iommu *iom
>              printk("    l%d[%x] not present\n", level, l_index);
>              break;
>          }
> +        if ( dma_pte_superpage(pte) )
> +            break;
>          val = dma_pte_addr(pte);
>      } while ( --level );
>  }
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel


[-- Attachment #1.2: Type: text/html, Size: 3224 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] VT-d: print_vtd_entries() should cope with superpages
  2015-02-27  9:52 [PATCH] VT-d: print_vtd_entries() should cope with superpages Jan Beulich
  2015-02-27 10:03 ` Roger Pau Monné
  2015-02-27 10:41 ` Andrew Cooper
@ 2015-03-09  3:10 ` Tian, Kevin
  2 siblings, 0 replies; 4+ messages in thread
From: Tian, Kevin @ 2015-03-09  3:10 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Zhang, Yang Z, Roger Pau Monne

> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: Friday, February 27, 2015 5:52 PM
> 
> Even if VT-d code alone (i.e. when not sharing tables with EPT) still
> doesn't support superpages, this function - invoked upon DMA remapping
> faults - needs to cope with such.
> 
> While at it also replace a few more plain numbers with suitable named
> constants.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Kevin Tian <kevin.tian@intel.com>

> 
> --- a/xen/drivers/passthrough/vtd/iommu.h
> +++ b/xen/drivers/passthrough/vtd/iommu.h
> @@ -268,18 +268,22 @@ struct dma_pte {
>  };
>  #define DMA_PTE_READ (1)
>  #define DMA_PTE_WRITE (2)
> +#define DMA_PTE_PROT (DMA_PTE_READ | DMA_PTE_WRITE)
> +#define DMA_PTE_SP   (1 << 7)
>  #define DMA_PTE_SNP  (1 << 11)
>  #define dma_clear_pte(p)    do {(p).val = 0;} while(0)
>  #define dma_set_pte_readable(p) do {(p).val |= DMA_PTE_READ;} while(0)
>  #define dma_set_pte_writable(p) do {(p).val |= DMA_PTE_WRITE;} while(0)
> -#define dma_set_pte_superpage(p) do {(p).val |= (1 << 7);} while(0)
> +#define dma_set_pte_superpage(p) do {(p).val |= DMA_PTE_SP;} while(0)
>  #define dma_set_pte_snp(p)  do {(p).val |= DMA_PTE_SNP;} while(0)
> -#define dma_set_pte_prot(p, prot) \
> -            do {(p).val = ((p).val & ~3) | ((prot) & 3); } while (0)
> +#define dma_set_pte_prot(p, prot) do { \
> +        (p).val = ((p).val & ~DMA_PTE_PROT) | ((prot) & DMA_PTE_PROT);
> \
> +    } while (0)
>  #define dma_pte_addr(p) ((p).val & PADDR_MASK & PAGE_MASK_4K)
>  #define dma_set_pte_addr(p, addr) do {\
>              (p).val |= ((addr) & PAGE_MASK_4K); } while (0)
> -#define dma_pte_present(p) (((p).val & 3) != 0)
> +#define dma_pte_present(p) (((p).val & DMA_PTE_PROT) != 0)
> +#define dma_pte_superpage(p) (((p).val & DMA_PTE_SP) != 0)
> 
>  /* interrupt remap entry */
>  struct iremap_entry {
> --- a/xen/drivers/passthrough/vtd/utils.c
> +++ b/xen/drivers/passthrough/vtd/utils.c
> @@ -179,6 +179,8 @@ void print_vtd_entries(struct iommu *iom
>              printk("    l%d[%x] not present\n", level, l_index);
>              break;
>          }
> +        if ( dma_pte_superpage(pte) )
> +            break;
>          val = dma_pte_addr(pte);
>      } while ( --level );
>  }
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-09  3:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27  9:52 [PATCH] VT-d: print_vtd_entries() should cope with superpages Jan Beulich
2015-02-27 10:03 ` Roger Pau Monné
2015-02-27 10:41 ` Andrew Cooper
2015-03-09  3:10 ` Tian, Kevin

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.