The Conversion Relationship between various addresses in the xen Space

Source: Internet
Author: User

Xen/include/asm-x86/page. h

 

# Define mfn_valid (MFN) <max_page) // check whether MFN is valid. If it is greater than the maximum page number, an error occurs.

 

 

/* Convert Between xen-heap virtual addresses and machine addresses .*/
// The xen heap occupies the first 12 Mb of the physical address space of the machine. Therefore, there is a fixed difference between the linear address and the physical address of the corresponding machine.
// # Define pai_to_maddr (VA) (unsigned long) (VA)-directmap_virt_start)
# DEFINE _ Pa (x) (pai_to_maddr (x ))
# DEFINE _ VA (x) (maddr_to_virt (x ))

/* Convert Between xen-heap virtual addresses and machine frame numbers .*/
// The transformation between the xen heap linear address and MFN. First, convert the linear address to the machine address, and then shift 12 digits to the right.
# Define pai_to_mfn (VA) (pai_to_maddr (VA)> page_shift)
# Define mfn_to_virt (MFN) (maddr_to_virt (MFN <page_shift ))

/* Convert between machine frame numbers and page-Info structures .*/
// The correspondence between MFN and frame_table arrays. Use MFN as the index value of the array to obtain the corresponding page_info structure.
# Define mfn_to_page (MFN) (frame_table + (MFN ))
# Define page_to_mfn (PG) (unsigned long) (PG)-frame_table ))

/* Convert between machine addresses and page-Info structures .*/
// The relationship between the physical address of the machine and the frame_table array. First, move the machine address to the left to get MFN. Use MFN as the index value of the array to obtain the corresponding page_info structure.
# Define maddr_to_page (MA) (frame_table + (MA)> page_shift ))
# Define page_to_maddr (PG) (paddr_t) (PG)-frame_table) <page_shift)

/* Convert Between xen-heap virtual addresses and page-Info structures .*/
// Relationship between the xen heap linear address and the frame_table array. First, convert the linear address to the machine address and then to MFN. Then, index the corresponding page_info in frame_table.
# Define pai_to_page (VA) (frame_table + (_ Pa (VA)> page_shift ))
# Define page_to_virt (PG) (maddr_to_virt (page_to_maddr (PG )))

/* Convert between frame number and address formats .*/
// Relationship between the page number and the corresponding page address. The page address is shifted to 12 digits and converted to the page number. The page number is changed to the page address by 12 digits to the right.
# Define pfn_to_paddr (PFn) (paddr_t) (PFn) <page_shift)
# Define paddr_to_pfn (PA) (unsigned long) (PA)> page_shift ))

 

 

 

 

Appendix:

1. xen defines an additional structure page_info for the physical memory definition page of each machine to save tracking information. The size of the page_info struct is 24B.

2. The page_info structure of each memory page is saved in the frame_table array and corresponds to the frame-Info table area in the xen memory space.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.