blkfront change to support unmodified linux
PATCH 1/1 blkfront change to support unmodified linux
This patch is to make blkfront can work both in xen-linux and in unmodified guest which is shadow_model_translate enabled.
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +1 -1
@@ -511,7 +511,7 @@FRONT_RING_INIT (&info->ring, sring,PAGE_SIZE ); err =gnttab_grant_foreign_access (info->backend_id, -virt_to_mfn (info->ring.sring),0 ); +virt_to_xfn (info->ring.sring),0 );if (err == -ENOSPC ) {free_page ((unsigned long )info->ring.sring); info->ring.sring =0 ;
linux-2.6-xen-sparse/include/asm-xen/asm-i386/io.h +0 -0
@@ -101,7 +101,17 @@* Change "struct page" to physical address. */ #define page_to_pseudophys (page) ((dma_addr_t)page_to_pfn(page) <<
PAGE_SHIFT)
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE
#define page_to_phys(page) (phys_to_machine(page_to_pseudophys(page)))
+#else
+#define page_to_phys(page) (page_to_pseudophys(page))
+#endif
+
+#ifndef CONFIG_XEN_SHADOW_TRANSLATE
+#define virt_to_xfn(va) (virt_to_mfn(va))
+#else
+#define virt_to_xfn(va) (virt_to_phys(va) >> PAGE_SHIFT)
+#endif
#define bio_to_pseudophys(bio) (page_to_pseudophys(bio_page((bio))) + \
(unsigned long) bio_offset((bio)))
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +1 -1
@@ -511,7 +511,7 @@FRONT_RING_INIT (&info->ring, sring,PAGE_SIZE ); err =gnttab_grant_foreign_access (info->backend_id, -virt_to_mfn (info->ring.sring),0 ); +virt_to_xfn (info->ring.sring),0 );if (err == -ENOSPC ) {free_page ((unsigned long )info->ring.sring); info->ring.sring =0 ;
linux-2.6-xen-sparse/include/asm-xen/asm-i386/io.h +10 -0
@@ -101,7 +101,17 @@* Change "struct page" to physical address. */ #define page_to_pseudophys (page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) +#ifndef CONFIG_XEN_SHADOW_TRANSLATE #define page_to_phys (page) (phys_to_machine(page_to_pseudophys(page))) +#else +#define page_to_phys (page) (page_to_pseudophys(page)) +#endif + +#ifndef CONFIG_XEN_SHADOW_TRANSLATE +#define virt_to_xfn (va) (virt_to_mfn(va)) +#else +#define virt_to_xfn (va) (virt_to_phys(va) >> PAGE_SHIFT) +#endif #define bio_to_pseudophys (bio) (page_to_pseudophys(bio_page((bio))) + \ (unsigned long) bio_offset((bio)))
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Xiaofeng Ling
This patch is to make blkfront can work both in xen-linux and in unmodified guest which is
shadow_model_translateenabled.
phys == machine from the p.o.v. of a shadow-translated guest, so why not modify virt_to_mfn and friends appropriately?
-- Keir
Quoted 8 lines · Keir Fraser
Quoted 2 lines · Xiaofeng Ling
This patch is to make blkfront can work both in xen-linux and in unmodified guest which is
shadow_model_translateenabled.phys == machine from the p.o.v. of a shadow-translated guest, so why not modify
virt_to_mfnand friends appropriately?
Sorry, I don't catch your meaning.
vmx guest is in shadow-translate mode, and gpfn need to translate to mfn in hypervisor. see the macro:
#define __gpfn_to_mfn(_d, gpfn) \
({ \
ASSERT(current->domain == (_d)); \
(shadow_mode_translate(_d)) \
? get_mfn_from_pfn(gpfn) \
: (gpfn); \
})#define __gpfn_to_mfn_foreign(_d, gpfn) \
( (shadow_mode_translate(_d)) \
? gpfn_to_mfn_foreign(_d, gpfn) \
: (gpfn) )So I rename virt_to_mfn to virt_to_xfn which means if not in shadow translate mode, it will do translate in guest. for vmx guest, don't need the translation in guest. What is your suggestion?