Skip to contentSkip to conversation

question about page_to_phys

DISCUSSION Xiaofeng Ling 2 participants 4 messages Sep 1, 2005 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

The page_to_phys is defined as
#define page_to_phys(page) (phys_to_machine(page_to_pseudophys(page)))
so it return machine addresss
while virt_to_phys return psedophys. include/asm-xen/asm-i386/io.h this is really confusing.
why not define page_to_machine?

#1 lore raw
Quoted 6 lines · Xiaofeng Ling

The page_to_phys is defined as
#define page_to_phys(page) (phys_to_machine(page_to_pseudophys(page)))
so it return machine addresss
while virt_to_phys return psedophys. include/asm-xen/asm-i386/io.h this is really confusing.
why not define page_to_machine?

page_to_phys() is used only in places where we want to compare machine addresses (e.g., in deciding when to merge I/O requests). It was easier to abuse the macro definition than fix every place that it is used.

-- Keir

#4 lore raw
In reply to a message not in the archive
Quoted 10 lines · Keir Fraser

On 1 Sep 2005, at 10:19, Xiaofeng Ling wrote:

If a guest is in translate mode it should have no concept of pseudophys vs machine. That translation is hidden from it. Hence there should be no need to hack the virtual drivers -- page_to_phys() should naturally translate to pseudophys if SHADOW_TRANSLATE is configured.

-- Keir

so we need such a patch? but how to deal with virt_to_mfn in blkfront.c?

linux-2.6-xen-sparse/include/asm-xen/asm-i386/io.h +0 -0
diff -r 9092486cc4b3 linux-2.6-xen-sparse/include/asm-xen/asm-i386/io.h
@@ -101,7 +101,11 @@
  * Change "struct page" to physical address.
  */
 #define page_to_pseudophys(page) ((dma_addr_t)page_to_pfn(page) << 

PAGE_SHIFT)
+#ifndef CONFIG_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

#define bio_to_pseudophys(bio) (page_to_pseudophys(bio_page((bio))) + \
(unsigned long) bio_offset((bio)))

#5 lore raw
Quoted 1 line · Xiaofeng Ling

so we need such a patch? but how to deal with virt_to_mfn in blkfront.c?

I guess the phys<->mach macros should all be no-ops.

-- Keir