Skip to contentSkip to conversation

xen: allow guests to set caching attributes for MMIOs

PATCH New Stefano Stabellini 1 participant 1 message Apr 7, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: allow guests to set caching attributes for MMIOs

Hi all,
this patch allows guests that have directly mapped MMIO regions to set the caching attributes for them, and only for them. Currently we have just an on\off check for a directly assigned device instead of looking for directly mapped MMIO regions.

---

xen/arch/x86/hvm/hvm.c +1 -1
diff -r 28e5409e3fb3 xen/arch/x86/hvm/hvm.c
@@ -1126,7 +1126,7 @@
         }
     }
 
-    if ( has_arch_pdevs(v->domain) )
+    if ( has_arch_mmios(v->domain) )
     {
         if ( (value & X86_CR0_CD) && !(value & X86_CR0_NW) )
         {
xen/arch/x86/hvm/svm/svm.c +1 -1
diff -r 28e5409e3fb3 xen/arch/x86/hvm/svm/svm.c
@@ -1228,7 +1228,7 @@
 
 static void svm_wbinvd_intercept(void)
 {
-    if ( has_arch_pdevs(current->domain) )
+    if ( has_arch_mmios(current->domain) )
         on_each_cpu(wbinvd_ipi, NULL, 1);
 }
 
xen/arch/x86/hvm/vmx/vmx.c +1 -1
diff -r 28e5409e3fb3 xen/arch/x86/hvm/vmx/vmx.c
@@ -2109,7 +2109,7 @@
 
 static void vmx_wbinvd_intercept(void)
 {
-    if ( !has_arch_pdevs(current->domain) )
+    if ( !has_arch_mmios(current->domain) )
         return;
 
     if ( cpu_has_wbinvd_exiting )
xen/arch/x86/mm/shadow/multi.c +3 -1
diff -r 28e5409e3fb3 xen/arch/x86/mm/shadow/multi.c
@@ -28,6 +28,7 @@
 #include <xen/sched.h>
 #include <xen/perfc.h>
 #include <xen/domain_page.h>
+#include <xen/iocap.h>
 #include <asm/page.h>
 #include <asm/current.h>
 #include <asm/shadow.h>
@@ -546,7 +547,8 @@
      * For HVM domains with direct access to MMIO areas, set the correct
      * caching attributes in the shadows to match what was asked for.
      */
-    if ( (level == 1) && is_hvm_domain(d) && has_arch_pdevs(d) &&
+    if ( (level == 1) && is_hvm_domain(d) &&
+         iomem_access_permitted(d, mfn_x(target_mfn), mfn_x(target_mfn) + 1) &&
          !is_xen_heap_mfn(mfn_x(target_mfn)) )
     {
         unsigned int type;
xen/include/asm-ia64/domain.h +1 -0
diff -r 28e5409e3fb3 xen/include/asm-ia64/domain.h
@@ -45,6 +45,7 @@
      __attribute__ ((noreturn, format (printf, 2, 3)));
 
 #define has_arch_pdevs(d)    (!list_empty(&(d)->arch.pdev_list))
+#define has_arch_mmios(d)    (!rangeset_is_empty((d)->iomem_caps))
 
 struct mm_struct {
 	volatile pgd_t * pgd;
xen/include/asm-x86/domain.h +1 -0
diff -r 28e5409e3fb3 xen/include/asm-x86/domain.h
@@ -329,6 +329,7 @@
 } __cacheline_aligned;
 
 #define has_arch_pdevs(d)    (!list_empty(&(d)->arch.pdev_list))
+#define has_arch_mmios(d)    (!rangeset_is_empty((d)->iomem_caps))
 
 #ifdef CONFIG_X86_64
 #define perdomain_pt_pgidx(v) \