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] minios: permit blkfront to write from mapped memory

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] minios: permit blkfront to write from mapped memory
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Date: Tue, 22 Jan 2008 14:08:53 +0000
Delivery-date: Tue, 22 Jan 2008 06:10:26 -0800
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>
Mail-followup-to: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
minios: permit blkfront to write from mapped memory
by adding a virtual_to_mfn macro

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>

diff -r 2c95a75433e4 extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Tue Jan 22 11:39:34 2008 +0000
+++ b/extras/mini-os/blkfront.c Tue Jan 22 14:07:07 2008 +0000
@@ -88,7 +88,7 @@ struct blkfront_dev *init_blkfront(char 
     SHARED_RING_INIT(s);
     FRONT_RING_INIT(&dev->ring, s, PAGE_SIZE);
 
-    dev->ring_ref = gnttab_grant_access(0,virt_to_mfn(s),0);
+    dev->ring_ref = gnttab_grant_access(0,virtual_to_mfn(s),0);
 
     evtchn_alloc_unbound_t op;
     op.dom = DOMID_SELF;
diff -r 2c95a75433e4 extras/mini-os/include/ia64/arch_mm.h
--- a/extras/mini-os/include/ia64/arch_mm.h     Tue Jan 22 11:39:34 2008 +0000
+++ b/extras/mini-os/include/ia64/arch_mm.h     Tue Jan 22 14:07:07 2008 +0000
@@ -25,6 +25,7 @@
 #define __ARCH_MM_H__
 
 #include "page.h"
+#include "ia64_cpu.h"
 
 #define PFN_PHYS(x)    (pfn_to_page(x))
 #define PHYS_PFN(x)    (page_to_pfn(x))
@@ -32,6 +33,7 @@
 #define to_phys(x)     __pa(x)
 
 #define virt_to_mfn(x) virt_to_pfn(x)
+#define virtual_to_mfn(x)      (ia64_tpa((uint64_t)(x)) >> PAGE_SHIFT)
 
 #define STACK_SIZE_PAGE_ORDER   1
 #define STACK_SIZE              (PAGE_SIZE * (1 << STACK_SIZE_PAGE_ORDER))
diff -r 2c95a75433e4 extras/mini-os/include/x86/arch_mm.h
--- a/extras/mini-os/include/x86/arch_mm.h      Tue Jan 22 11:39:34 2008 +0000
+++ b/extras/mini-os/include/x86/arch_mm.h      Tue Jan 22 14:07:07 2008 +0000
@@ -226,6 +226,35 @@ static __inline__ paddr_t machine_to_phy
 #define pte_to_mfn(_pte)           (((_pte) & (PADDR_MASK&PAGE_MASK)) >> 
L1_PAGETABLE_SHIFT)
 #define pte_to_virt(_pte)          to_virt(mfn_to_pfn(pte_to_mfn(_pte)) << 
PAGE_SHIFT)
 
+
+#define PT_BASE                           ((pgentry_t *)start_info.pt_base)
+
+#ifdef __x86_64__
+#define virtual_to_l3(_virt)      ((pgentry_t 
*)pte_to_virt(PT_BASE[l4_table_offset(_virt)]))
+#else
+#define virtual_to_l3(_virt)      PT_BASE
+#endif
+
+#if defined(__x86_64__) || defined(CONFIG_X86_PAE)
+#define virtual_to_l2(_virt)      ({ \
+       unsigned long __virt2 = (_virt); \
+       (pgentry_t *) 
pte_to_virt(virtual_to_l3(__virt2)[l3_table_offset(__virt2)]); \
+})
+#else
+#define virtual_to_l2(_virt)      PT_BASE
+#endif
+
+#define virtual_to_l1(_virt)      ({ \
+       unsigned long __virt1 = (_virt); \
+       (pgentry_t *) 
pte_to_virt(virtual_to_l2(__virt1)[l2_table_offset(__virt1)]); \
+})
+
+#define virtual_to_pte(_virt)     ({ \
+       unsigned long __virt0 = (unsigned long) (_virt); \
+       virtual_to_l1(__virt0)[l1_table_offset(__virt0)]; \
+})
+#define virtual_to_mfn(_virt)     pte_to_mfn(virtual_to_pte(_virt))
+
 #define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, 0, L1_PROT)
 #define map_zero(n, a) map_frames_ex(&mfn_zero, n, 0, 0, a, DOMID_SELF, 0, 
L1_PROT_RO)
 

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

<Prev in Thread] Current Thread [Next in Thread>