Hi all, in arch_init_memory() we have the following code: ... /* Any areas not specified as RAM by the e820 map are considered I/O. */ for ( i = 0, pfn = 0; pfn < max_page; i++ ) { while ( (i < e820.nr_map) && (e820.map[i].type != E820_RAM) ) i++; if ( i >= e820.nr_map ) { /* No more RAM regions: mark as I/O right to end of memory map. */ rstart_pfn = rend_pfn = max_page; } else { /* Mark as I/O just up as far as next RAM region. */ rstart_pfn = min_t(unsigned long, max_page, PFN_UP(e820.map[i].addr)); rend_pfn = max_t(unsigned long, rstart_pfn, PFN_DOWN(e820.map[i].addr + e820.map[i].size)); } /* Mark as I/O up to next RAM region. */ for ( ; pfn < rstart_pfn; pfn++ ) { BUG_ON(!mfn_valid(pfn)); share_xen_page_with_guest( mfn_to_page(pfn), dom_io, XENSHARE_writable); } /* Skip the RAM region. */ pfn = rend_pfn; } ... it seems that the while loop skips all the areas that are not specified as RAM and the areas which are specified as RAM are considered I/O, which contradicts with the comment, or do I misunderstand this piece of code? _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
>From: 陈诚 >Sent: 2007年11月18日 22:20 > >Hi all, > in arch_init_memory() we have the following code: > > ... > > /* Any areas not specified as RAM by the e820 map are >considered I/O. */ > for ( i = 0, pfn = 0; pfn < max_page; i++ ) > { > while ( (i < e820.nr_map) && (e820.map[i].type != E820_RAM) ) > i++; > > if ( i >= e820.nr_map ) > { > /* No more RAM regions: mark as I/O right to end >of memory map. */ > rstart_pfn = rend_pfn = max_page; > } > else > { > /* Mark as I/O just up as far as next RAM region. */ > rstart_pfn = min_t(unsigned long, max_page, > PFN_UP(e820.map[i].addr)); > rend_pfn = max_t(unsigned long, rstart_pfn, > PFN_DOWN(e820.map[i].addr + >e820.map[i].size)); > } > > /* Mark as I/O up to next RAM region. */ > for ( ; pfn < rstart_pfn; pfn++ ) > { > BUG_ON(!mfn_valid(pfn)); > share_xen_page_with_guest( > mfn_to_page(pfn), dom_io, XENSHARE_writable); > } > > /* Skip the RAM region. */ > pfn = rend_pfn; > } > > ... > > it seems that the while loop skips all the areas that are not >specified as RAM and the areas which are specified as RAM are >considered I/O, which contradicts with the comment, or do I >misunderstand this piece of code? >It matches. Above code just adds frames from end of last RAM entry to start of next RAM entry. Not all non-RAM ranges are described in E820 table, which is why you need instead anchor RAM entries and get the reverse. Thanks, Kevin _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
2007/11/19, Tian, Kevin <kevin.tian@intel.com>:> > >From: 陈诚 > >Sent: 2007年11月18日 22:20 > > > >Hi all, > > in arch_init_memory() we have the following code: > > > > ... > > > > /* Any areas not specified as RAM by the e820 map are > >considered I/O. */ > > for ( i = 0, pfn = 0; pfn < max_page; i++ ) > > { > > while ( (i < e820.nr_map) && (e820.map[i].type != E820_RAM) ) > > i++; > > > > if ( i >= e820.nr_map ) > > { > > /* No more RAM regions: mark as I/O right to end > >of memory map. */ > > rstart_pfn = rend_pfn = max_page; > > } > > else > > { > > /* Mark as I/O just up as far as next RAM region. */ > > rstart_pfn = min_t(unsigned long, max_page, > > PFN_UP(e820.map[i].addr)); > > rend_pfn = max_t(unsigned long, rstart_pfn, > > PFN_DOWN(e820.map[i].addr + > >e820.map[i].size)); > > } > > > > /* Mark as I/O up to next RAM region. */ > > for ( ; pfn < rstart_pfn; pfn++ ) > > { > > BUG_ON(!mfn_valid(pfn)); > > share_xen_page_with_guest( > > mfn_to_page(pfn), dom_io, XENSHARE_writable); > > } > > > > /* Skip the RAM region. */ > > pfn = rend_pfn; > > } > > > > ... > > > > it seems that the while loop skips all the areas that are not > >specified as RAM and the areas which are specified as RAM are > >considered I/O, which contradicts with the comment, or do I > >misunderstand this piece of code? > > > > It matches. Above code just adds frames from end of last RAM entry > to start of next RAM entry. Not all non-RAM ranges are described in > E820 table, which is why you need instead anchor RAM entries and > get the reverse. > > Thanks, > Kevin >I see it, thank you. Cheers _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel