ia64/xen-unstable

changeset 16839:898ce9341e6b

minios: permit blkfront to write from mapped memory
by adding a virtual_to_mfn macro

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jan 22 14:20:37 2008 +0000 (2008-01-22)
parents 945820bfedb6
children d57a94546911
files extras/mini-os/blkfront.c extras/mini-os/include/ia64/arch_mm.h extras/mini-os/include/x86/arch_mm.h
line diff
     1.1 --- a/extras/mini-os/blkfront.c	Tue Jan 22 14:20:22 2008 +0000
     1.2 +++ b/extras/mini-os/blkfront.c	Tue Jan 22 14:20:37 2008 +0000
     1.3 @@ -88,7 +88,7 @@ struct blkfront_dev *init_blkfront(char 
     1.4      SHARED_RING_INIT(s);
     1.5      FRONT_RING_INIT(&dev->ring, s, PAGE_SIZE);
     1.6  
     1.7 -    dev->ring_ref = gnttab_grant_access(0,virt_to_mfn(s),0);
     1.8 +    dev->ring_ref = gnttab_grant_access(0,virtual_to_mfn(s),0);
     1.9  
    1.10      evtchn_alloc_unbound_t op;
    1.11      op.dom = DOMID_SELF;
     2.1 --- a/extras/mini-os/include/ia64/arch_mm.h	Tue Jan 22 14:20:22 2008 +0000
     2.2 +++ b/extras/mini-os/include/ia64/arch_mm.h	Tue Jan 22 14:20:37 2008 +0000
     2.3 @@ -25,6 +25,7 @@
     2.4  #define __ARCH_MM_H__
     2.5  
     2.6  #include "page.h"
     2.7 +#include "ia64_cpu.h"
     2.8  
     2.9  #define PFN_PHYS(x)	(pfn_to_page(x))
    2.10  #define PHYS_PFN(x)	(page_to_pfn(x))
    2.11 @@ -32,6 +33,7 @@
    2.12  #define to_phys(x)	__pa(x)
    2.13  
    2.14  #define virt_to_mfn(x)	virt_to_pfn(x)
    2.15 +#define virtual_to_mfn(x)      (ia64_tpa((uint64_t)(x)) >> PAGE_SHIFT)
    2.16  
    2.17  #define STACK_SIZE_PAGE_ORDER   1
    2.18  #define STACK_SIZE              (PAGE_SIZE * (1 << STACK_SIZE_PAGE_ORDER))
     3.1 --- a/extras/mini-os/include/x86/arch_mm.h	Tue Jan 22 14:20:22 2008 +0000
     3.2 +++ b/extras/mini-os/include/x86/arch_mm.h	Tue Jan 22 14:20:37 2008 +0000
     3.3 @@ -226,6 +226,35 @@ static __inline__ paddr_t machine_to_phy
     3.4  #define pte_to_mfn(_pte)           (((_pte) & (PADDR_MASK&PAGE_MASK)) >> L1_PAGETABLE_SHIFT)
     3.5  #define pte_to_virt(_pte)          to_virt(mfn_to_pfn(pte_to_mfn(_pte)) << PAGE_SHIFT)
     3.6  
     3.7 +
     3.8 +#define PT_BASE			   ((pgentry_t *)start_info.pt_base)
     3.9 +
    3.10 +#ifdef __x86_64__
    3.11 +#define virtual_to_l3(_virt)	   ((pgentry_t *)pte_to_virt(PT_BASE[l4_table_offset(_virt)]))
    3.12 +#else
    3.13 +#define virtual_to_l3(_virt)	   PT_BASE
    3.14 +#endif
    3.15 +
    3.16 +#if defined(__x86_64__) || defined(CONFIG_X86_PAE)
    3.17 +#define virtual_to_l2(_virt)	   ({ \
    3.18 +	unsigned long __virt2 = (_virt); \
    3.19 +	(pgentry_t *) pte_to_virt(virtual_to_l3(__virt2)[l3_table_offset(__virt2)]); \
    3.20 +})
    3.21 +#else
    3.22 +#define virtual_to_l2(_virt)	   PT_BASE
    3.23 +#endif
    3.24 +
    3.25 +#define virtual_to_l1(_virt)	   ({ \
    3.26 +	unsigned long __virt1 = (_virt); \
    3.27 +	(pgentry_t *) pte_to_virt(virtual_to_l2(__virt1)[l2_table_offset(__virt1)]); \
    3.28 +})
    3.29 +
    3.30 +#define virtual_to_pte(_virt)	   ({ \
    3.31 +	unsigned long __virt0 = (unsigned long) (_virt); \
    3.32 +	virtual_to_l1(__virt0)[l1_table_offset(__virt0)]; \
    3.33 +})
    3.34 +#define virtual_to_mfn(_virt)	   pte_to_mfn(virtual_to_pte(_virt))
    3.35 +
    3.36  #define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, 0, L1_PROT)
    3.37  #define map_zero(n, a) map_frames_ex(&mfn_zero, n, 0, 0, a, DOMID_SELF, 0, L1_PROT_RO)
    3.38