WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] linux: fix agp address handling, namely intel-agp

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] linux: fix agp address handling, namely intel-agp
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Wed, 04 Apr 2007 16:54:18 +0100
Delivery-date: Wed, 04 Apr 2007 08:52:17 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Make sure machine addresses are in fact constrained to 32 bits, and assumptions
about multi-page extents being contiguous are being met.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

Index: sle10sp1-2007-03-28/arch/i386/mm/hypervisor.c
===================================================================
--- sle10sp1-2007-03-28.orig/arch/i386/mm/hypervisor.c  2007-03-28 
09:26:03.000000000 +0200
+++ sle10sp1-2007-03-28/arch/i386/mm/hypervisor.c       2007-04-04 
16:49:20.000000000 +0200
@@ -353,6 +353,7 @@ int xen_create_contiguous_region(
 
        return success ? 0 : -ENOMEM;
 }
+EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
 
 void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
 {
@@ -437,6 +438,7 @@ void xen_destroy_contiguous_region(unsig
 
        balloon_unlock(flags);
 }
+EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
 
 #ifdef __i386__
 int write_ldt_entry(void *ldt, int entry, __u32 entry_a, __u32 entry_b)
Index: sle10sp1-2007-03-28/drivers/char/agp/generic.c
===================================================================
--- sle10sp1-2007-03-28.orig/drivers/char/agp/generic.c 2007-03-28 
08:47:04.000000000 +0200
+++ sle10sp1-2007-03-28/drivers/char/agp/generic.c      2007-04-04 
16:49:20.000000000 +0200
@@ -51,7 +51,7 @@ int agp_memory_reserved;
  */
 EXPORT_SYMBOL_GPL(agp_memory_reserved);
 
-#if defined(CONFIG_X86)
+#if defined(CONFIG_X86) && !defined(CONFIG_XEN)
 int map_page_into_agp(struct page *page)
 {
        int i;
Index: sle10sp1-2007-03-28/drivers/char/agp/intel-agp.c
===================================================================
--- sle10sp1-2007-03-28.orig/drivers/char/agp/intel-agp.c       2007-03-28 
08:47:04.000000000 +0200
+++ sle10sp1-2007-03-28/drivers/char/agp/intel-agp.c    2007-04-04 
16:49:20.000000000 +0200
@@ -164,6 +164,13 @@ static void *i8xx_alloc_pages(void)
        if (page == NULL)
                return NULL;
 
+#ifdef CONFIG_XEN
+       if (xen_create_contiguous_region((unsigned long)page_address(page), 2, 
32)) {
+               __free_pages(page, 2);
+               return NULL;
+       }
+#endif
+
        if (change_page_attr(page, 4, PAGE_KERNEL_NOCACHE) < 0) {
                global_flush_tlb();
                __free_page(page);
@@ -186,6 +193,9 @@ static void i8xx_destroy_pages(void *add
        page = virt_to_page(addr);
        change_page_attr(page, 4, PAGE_KERNEL);
        global_flush_tlb();
+#ifdef CONFIG_XEN
+       xen_destroy_contiguous_region((unsigned long)page_address(page), 2);
+#endif
        put_page(page);
        unlock_page(page);
        free_pages((unsigned long)addr, 2);
Index: sle10sp1-2007-03-28/include/asm-i386/mach-xen/asm/agp.h
===================================================================
--- sle10sp1-2007-03-28.orig/include/asm-i386/mach-xen/asm/agp.h        
2007-03-28 08:48:23.000000000 +0200
+++ sle10sp1-2007-03-28/include/asm-i386/mach-xen/asm/agp.h     2007-04-04 
16:49:20.000000000 +0200
@@ -13,8 +13,15 @@
  * data corruption on some CPUs.
  */
 
-int map_page_into_agp(struct page *page);
-int unmap_page_from_agp(struct page *page);
+/* Caller's responsibility to call global_flush_tlb() for
+ * performance reasons */
+#define map_page_into_agp(page) ( \
+       xen_create_contiguous_region((unsigned long)page_address(page), 0, 32) \
+       ?: change_page_attr(page, 1, PAGE_KERNEL_NOCACHE))
+#define unmap_page_from_agp(page) ( \
+       xen_destroy_contiguous_region((unsigned long)page_address(page), 0), \
+       /* only a fallback: xen_destroy_contiguous_region uses PAGE_KERNEL */ \
+       change_page_attr(page, 1, PAGE_KERNEL))
 #define flush_agp_mappings() global_flush_tlb()
 
 /* Could use CLFLUSH here if the cpu supports it. But then it would
Index: sle10sp1-2007-03-28/include/asm-x86_64/mach-xen/asm/agp.h
===================================================================
--- sle10sp1-2007-03-28.orig/include/asm-x86_64/mach-xen/asm/agp.h      
2007-03-28 08:48:23.000000000 +0200
+++ sle10sp1-2007-03-28/include/asm-x86_64/mach-xen/asm/agp.h   2007-04-04 
16:49:20.000000000 +0200
@@ -11,8 +11,13 @@
  * with different cachability attributes for the same page.
  */
 
-int map_page_into_agp(struct page *page);
-int unmap_page_from_agp(struct page *page);
+#define map_page_into_agp(page) ( \
+       xen_create_contiguous_region((unsigned long)page_address(page), 0, 32) \
+       ?: change_page_attr(page, 1, PAGE_KERNEL_NOCACHE))
+#define unmap_page_from_agp(page) ( \
+       xen_destroy_contiguous_region((unsigned long)page_address(page), 0), \
+       /* only a fallback: xen_destroy_contiguous_region uses PAGE_KERNEL */ \
+       change_page_attr(page, 1, PAGE_KERNEL))
 #define flush_agp_mappings() global_flush_tlb()
 
 /* Could use CLFLUSH here if the cpu supports it. But then it would



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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] linux: fix agp address handling, namely intel-agp, Jan Beulich <=