All of lore.kernel.org
 help / color / mirror / Atom feed
* [patches] pae: hypercall interface updates
@ 2005-07-05 14:30 Gerd Knorr
  0 siblings, 0 replies; only message in thread
From: Gerd Knorr @ 2005-07-05 14:30 UTC (permalink / raw)
  To: xen-devel

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

  Hi,

Here are two patches which update the hypercall interfaces to
use 64-bit values for both page table entries and physical
addresses.  These changes are needed to use more than 4GB with
PAE paging enabled.

The first patch is a pretty straightforward update for xen, it
simply makes the values 64-bit wide everythere.

The second patch adapts the linux kernel to the hypercall
interface changes.  It also introduces two MULTI_* functions
(for the update_va_mapping hypercalls) which have simliar
behavior like the HYPERVISOR_* counterparts but fill
multicall_entry_t instead of doing the call directly.

The tools don't need source code changes, but must be rebuilt
due to the change in the xen public header file.

Domain0 boots fine, unpriviliged domain boots fine with fully
functional networking.  Note this is non-PAE mode, tools don't
have support for PAE domU boots yet.

please apply,

  Gerd


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

Index: xen/include/public/xen.h
===================================================================
--- xen.orig/include/public/xen.h	2005-06-24 12:55:46.000000000 +0200
+++ xen/include/public/xen.h	2005-06-24 12:56:05.000000000 +0200
@@ -274,8 +274,8 @@ typedef u16 domid_t;
  */
 typedef struct
 {
-    memory_t ptr;       /* Machine address of PTE. */
-    memory_t val;       /* New contents of PTE.    */
+    u64 ptr;       /* Machine address of PTE. */
+    u64 val;       /* New contents of PTE.    */
 } mmu_update_t;
 
 /*
Index: xen/arch/x86/mm.c
===================================================================
--- xen.orig/arch/x86/mm.c	2005-06-24 12:55:46.000000000 +0200
+++ xen/arch/x86/mm.c	2005-06-24 12:56:05.000000000 +0200
@@ -2020,7 +2020,8 @@ int do_mmu_update(
             }
 
             va = map_domain_page_with_cache(mfn, &mapcache);
-            va = (void *)((unsigned long)va + (req.ptr & ~PAGE_MASK));
+            va = (void *)((unsigned long)va +
+                          (unsigned long)(req.ptr & ~PAGE_MASK));
             page = &frame_table[mfn];
 
             switch ( (type_info = page->u.inuse.type_info) & PGT_type_mask )
@@ -2164,7 +2165,7 @@ int do_mmu_update(
             break;
 
         default:
-            MEM_LOG("Invalid page update command %lx", req.ptr);
+            MEM_LOG("Invalid page update command %x", cmd);
             break;
         }
 
@@ -2251,11 +2252,10 @@ int update_grant_va_mapping(unsigned lon
 }
 
 
-int do_update_va_mapping(unsigned long va,
-                         unsigned long val32,
+int do_update_va_mapping(unsigned long va, u64 val64,
                          unsigned long flags)
 {
-    l1_pgentry_t   val = l1e_from_intpte(val32);
+    l1_pgentry_t   val = l1e_from_intpte(val64);
     struct vcpu   *v   = current;
     struct domain *d   = v->domain;
     unsigned int   cpu = v->processor;
@@ -2349,8 +2349,7 @@ int do_update_va_mapping(unsigned long v
     return rc;
 }
 
-int do_update_va_mapping_otherdomain(unsigned long va,
-                                     unsigned long val32,
+int do_update_va_mapping_otherdomain(unsigned long va, u64 val64,
                                      unsigned long flags,
                                      domid_t domid)
 {
@@ -2368,7 +2367,7 @@ int do_update_va_mapping_otherdomain(uns
         return -ESRCH;
     }
 
-    rc = do_update_va_mapping(va, val32, flags);
+    rc = do_update_va_mapping(va, val64, flags);
 
     return rc;
 }

[-- Attachment #3: hypercalls-linux --]
[-- Type: text/plain, Size: 9641 bytes --]

Index: linux-2.6.11/include/asm-xen/asm-i386/hypercall.h
===================================================================
--- linux-2.6.11.orig/include/asm-xen/asm-i386/hypercall.h	2005-07-05 11:21:38.000000000 +0200
+++ linux-2.6.11/include/asm-xen/asm-i386/hypercall.h	2005-07-05 16:00:03.000000000 +0200
@@ -371,13 +371,19 @@ HYPERVISOR_update_va_mapping(
     unsigned long va, pte_t new_val, unsigned long flags)
 {
     int ret;
-    unsigned long ign1, ign2, ign3;
+    unsigned long ign1, ign2, ign3, ign4;
 
     __asm__ __volatile__ (
         TRAP_INSTR
-        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
+        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
 	: "0" (__HYPERVISOR_update_va_mapping), 
-          "1" (va), "2" ((new_val).pte_low), "3" (flags)
+          "1" (va), "2" ((new_val).pte_low),
+#ifdef CONFIG_X86_PAE
+	  "3" ((new_val).pte_high),
+#else
+	  "3" (0),
+#endif
+	  "4" (flags)
 	: "memory" );
 
     if ( unlikely(ret < 0) )
@@ -390,6 +396,22 @@ HYPERVISOR_update_va_mapping(
     return ret;
 }
 
+static inline void
+MULTI_update_va_mapping(
+    multicall_entry_t *mcl, unsigned long va,
+    pte_t new_val, unsigned long flags)
+{
+    mcl->op = __HYPERVISOR_update_va_mapping;
+    mcl->args[0] = va;
+    mcl->args[1] = (new_val).pte_low;
+#ifdef CONFIG_X86_PAE
+    mcl->args[2] = (new_val).pte_high;
+#else
+    mcl->args[2] = 0;
+#endif
+    mcl->args[3] = flags;
+}
+
 static inline int
 HYPERVISOR_event_channel_op(
     void *op)
@@ -473,18 +495,42 @@ HYPERVISOR_update_va_mapping_otherdomain
     unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
 {
     int ret;
-    unsigned long ign1, ign2, ign3, ign4;
+    unsigned long ign1, ign2, ign3, ign4, ign5;
 
     __asm__ __volatile__ (
         TRAP_INSTR
-        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
+        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3),
+	  "=S" (ign4), "=D" (ign5)
 	: "0" (__HYPERVISOR_update_va_mapping_otherdomain),
-          "1" (va), "2" ((new_val).pte_low), "3" (flags), "4" (domid) :
+          "1" (va), "2" ((new_val).pte_low),
+#ifdef CONFIG_X86_PAE
+	  "3" ((new_val).pte_high),
+#else
+	  "3" (0),
+#endif
+	  "4" (flags), "5" (domid) :
         "memory" );
     
     return ret;
 }
 
+static inline void
+MULTI_update_va_mapping_otherdomain(
+    multicall_entry_t *mcl, unsigned long va,
+    pte_t new_val, unsigned long flags, domid_t domid)
+{
+    mcl->op = __HYPERVISOR_update_va_mapping_otherdomain;
+    mcl->args[0] = va;
+    mcl->args[1] = (new_val).pte_low;
+#ifdef CONFIG_X86_PAE
+    mcl->args[2] = (new_val).pte_high;
+#else
+    mcl->args[2] = 0;
+#endif
+    mcl->args[3] = flags;
+    mcl->args[4] = domid;
+}
+
 static inline int
 HYPERVISOR_vm_assist(
     unsigned int cmd, unsigned int type)
Index: linux-2.6.11/drivers/xen/netback/netback.c
===================================================================
--- linux-2.6.11.orig/drivers/xen/netback/netback.c	2005-07-05 11:21:38.000000000 +0200
+++ linux-2.6.11/drivers/xen/netback/netback.c	2005-07-05 15:27:27.000000000 +0200
@@ -234,11 +234,9 @@ static void net_rx_action(unsigned long 
          * Heed the comment in pgtable-2level.h:pte_page(). :-)
          */
         phys_to_machine_mapping[__pa(skb->data) >> PAGE_SHIFT] = new_mfn;
-        
-        mcl->op = __HYPERVISOR_update_va_mapping;
-        mcl->args[0] = vdata;
-        mcl->args[1] = (new_mfn << PAGE_SHIFT) | __PAGE_KERNEL;
-        mcl->args[2] = 0;
+
+        MULTI_update_va_mapping(mcl, vdata,
+				pfn_pte_ma(new_mfn, PAGE_KERNEL), 0);
         mcl++;
 
         mcl->op = __HYPERVISOR_mmuext_op;
@@ -425,10 +423,8 @@ static void net_tx_action(unsigned long 
     while ( dc != dp )
     {
         pending_idx = dealloc_ring[MASK_PEND_IDX(dc++)];
-        mcl[0].op = __HYPERVISOR_update_va_mapping;
-        mcl[0].args[0] = MMAP_VADDR(pending_idx);
-        mcl[0].args[1] = 0;
-        mcl[0].args[2] = 0;
+	MULTI_update_va_mapping(mcl, MMAP_VADDR(pending_idx),
+				__pte(0), 0);
         mcl++;     
     }
 
@@ -571,11 +567,10 @@ static void net_tx_action(unsigned long 
         /* Packets passed to netif_rx() must have some headroom. */
         skb_reserve(skb, 16);
 
-        mcl[0].op = __HYPERVISOR_update_va_mapping_otherdomain;
-        mcl[0].args[0] = MMAP_VADDR(pending_idx);
-        mcl[0].args[1] = (txreq.addr & PAGE_MASK) | __PAGE_KERNEL;
-        mcl[0].args[2] = 0;
-        mcl[0].args[3] = netif->domid;
+	MULTI_update_va_mapping_otherdomain(
+	    mcl, MMAP_VADDR(pending_idx),
+	    pfn_pte_ma(txreq.addr >> PAGE_SHIFT, PAGE_KERNEL),
+	    0, netif->domid);
         mcl++;
 
         memcpy(&pending_tx_info[pending_idx].req, &txreq, sizeof(txreq));
Index: linux-2.6.11/drivers/xen/usbback/usbback.c
===================================================================
--- linux-2.6.11.orig/drivers/xen/usbback/usbback.c	2005-07-05 11:21:38.000000000 +0200
+++ linux-2.6.11/drivers/xen/usbback/usbback.c	2005-07-05 15:49:55.000000000 +0200
@@ -189,10 +189,8 @@ static void fast_flush_area(int idx, int
 
     for ( i = 0; i < nr_pages; i++ )
     {
-        mcl[i].op = __HYPERVISOR_update_va_mapping;
-        mcl[i].args[0] = MMAP_VADDR(idx, i);
-        mcl[i].args[1] = 0;
-        mcl[i].args[2] = 0;
+	MULTI_update_va_mapping(mcl+i, MMAP_VADDR(idx, i),
+				__pte(0), 0);
     }
 
     mcl[nr_pages-1].args[2] = UVMF_TLB_FLUSH|UVMF_ALL;
@@ -651,11 +649,10 @@ static void dispatch_usb_io(usbif_priv_t
     for ( i = 0, offset = 0; offset < req->length;
           i++, offset += PAGE_SIZE )
     {
-	mcl[i].op = __HYPERVISOR_update_va_mapping_otherdomain;
-	mcl[i].args[0] = MMAP_VADDR(pending_idx, i);
-        mcl[i].args[1] = ((buffer_mach & PAGE_MASK) + offset) | remap_prot;
-        mcl[i].args[2] = 0;
-        mcl[i].args[3] = up->domid;
+	MULTI_update_va_mapping_otherdomain(
+	    mcl+i, MMAP_VADDR(pending_idx, i),
+	    pfn_pte_ma(buffer_mach >> PAGE_SHIFT, remap_prot),
+	    0, up->domid);
         
         phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
             FOREIGN_FRAME((buffer_mach + offset) >> PAGE_SHIFT);
@@ -667,11 +664,10 @@ static void dispatch_usb_io(usbif_priv_t
     if ( req->pipe_type == 0 && req->num_iso > 0 ) /* Maybe schedule ISO... */
     {
         /* Map in ISO schedule, if necessary. */
-        mcl[i].op = __HYPERVISOR_update_va_mapping_otherdomain;
-        mcl[i].args[0] = MMAP_VADDR(pending_idx, i);
-        mcl[i].args[1] = (req->iso_schedule & PAGE_MASK) | remap_prot;
-        mcl[i].args[2] = 0;
-        mcl[i].args[3] = up->domid;
+	MULTI_update_va_mapping_otherdomain(
+	    mcl+i, MMAP_VADDR(pending_idx, i),
+	    pfn_pte_ma(req->iso_schedule >> PAGE_SHIFT, remap_prot),
+	    0, up->domid);
 
         phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
             FOREIGN_FRAME(req->iso_schedule >> PAGE_SHIFT);
Index: linux-2.6.11/drivers/xen/netfront/netfront.c
===================================================================
--- linux-2.6.11.orig/drivers/xen/netfront/netfront.c	2005-07-05 11:21:38.000000000 +0200
+++ linux-2.6.11/drivers/xen/netfront/netfront.c	2005-07-05 15:27:49.000000000 +0200
@@ -395,10 +395,8 @@ static void network_alloc_rx_buffers(str
 	phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
 	    = INVALID_P2M_ENTRY;
 
-        rx_mcl[i].op = __HYPERVISOR_update_va_mapping;
-        rx_mcl[i].args[0] = (unsigned long)skb->head;
-        rx_mcl[i].args[1] = 0;
-        rx_mcl[i].args[2] = 0;
+	MULTI_update_va_mapping(rx_mcl+i, (unsigned long)skb->head,
+				__pte(0), 0);
     }
 
     /* After all PTEs have been zapped we blow away stale TLB entries. */
@@ -585,10 +583,8 @@ static int netif_poll(struct net_device 
         mmu->ptr  = (rx->addr & PAGE_MASK) | MMU_MACHPHYS_UPDATE;
         mmu->val  = __pa(skb->head) >> PAGE_SHIFT;
         mmu++;
-        mcl->op = __HYPERVISOR_update_va_mapping;
-        mcl->args[0] = (unsigned long)skb->head;
-        mcl->args[1] = (rx->addr & PAGE_MASK) | __PAGE_KERNEL;
-        mcl->args[2] = 0;
+	MULTI_update_va_mapping(mcl, (unsigned long)skb->head,
+				pfn_pte_ma(rx->addr >> PAGE_SHIFT, PAGE_KERNEL), 0);
         mcl++;
 
         phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = 
Index: linux-2.6.11/drivers/xen/blkback/blkback.c
===================================================================
--- linux-2.6.11.orig/drivers/xen/blkback/blkback.c	2005-07-05 11:21:38.000000000 +0200
+++ linux-2.6.11/drivers/xen/blkback/blkback.c	2005-07-05 15:47:57.000000000 +0200
@@ -141,10 +141,8 @@ static void fast_flush_area(int idx, int
 
     for ( i = 0; i < nr_pages; i++ )
     {
-        mcl[i].op = __HYPERVISOR_update_va_mapping;
-        mcl[i].args[0] = MMAP_VADDR(idx, i);
-        mcl[i].args[1] = 0;
-        mcl[i].args[2] = 0;
+	MULTI_update_va_mapping(mcl+i, MMAP_VADDR(idx, i),
+				__pte(0), 0);
     }
 
     mcl[nr_pages-1].args[2] = UVMF_TLB_FLUSH|UVMF_ALL;
@@ -545,11 +543,10 @@ static void dispatch_rw_block_io(blkif_t
 
     for ( i = 0; i < nseg; i++ )
     {
-        mcl[i].op = __HYPERVISOR_update_va_mapping_otherdomain;
-        mcl[i].args[0] = MMAP_VADDR(pending_idx, i);
-        mcl[i].args[1] = (seg[i].buf & PAGE_MASK) | remap_prot;
-        mcl[i].args[2] = 0;
-        mcl[i].args[3] = blkif->domid;
+	MULTI_update_va_mapping_otherdomain(
+	    mcl+i, MMAP_VADDR(pending_idx, i),
+	    pfn_pte_ma(seg[i].buf >> PAGE_SHIFT, remap_prot),
+	    0, blkif->domid);
 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
         if ( blkif->is_blktap )
             mcl[i].args[3] = ID_TO_DOM(req->id);

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

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-07-05 14:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-05 14:30 [patches] pae: hypercall interface updates Gerd Knorr

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.