Skip to contentSkip to conversation

pae: hypercall interface updates

PATCH New Gerd Knorr 1 participant 1 message Jul 5, 2005

Subsystems (2)
lore
Share & tools
lore

Gerd Knorr

author
#0 lore raw

PATCH 1/1 pae: hypercall interface updates

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

include/public/xen.h +2 -2
Index: xen/include/public/xen.h
===================================================================
@@ -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;
 
 /*
arch/x86/mm.c +7 -8
Index: xen/arch/x86/mm.c
===================================================================
@@ -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;
 }
include/asm-xen/asm-i386/hypercall.h +52 -6

89 lines not on this page · raw message

drivers/xen/netback/netback.c +9 -14
Index: linux-2.6.11/drivers/xen/netback/netback.c
===================================================================
@@ -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));
drivers/xen/usbback/usbback.c +10 -14
Index: linux-2.6.11/drivers/xen/usbback/usbback.c
===================================================================
@@ -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);
drivers/xen/netfront/netfront.c +4 -8
Index: linux-2.6.11/drivers/xen/netfront/netfront.c
===================================================================
@@ -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] = 
drivers/xen/blkback/blkback.c +6 -9
Index: linux-2.6.11/drivers/xen/blkback/blkback.c
===================================================================
@@ -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);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel