Skip to contentSkip to conversation

The init_maps bug which cause mem map error

uml-devel wang lianwei 3 participants 5 messages Jan 10, 2006 – Jan 12, 2006 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

There is a bug In file
linux/arch/um/kernel/physmem.c init_mem() functions:

*int* *init_maps*(*unsigned* *long* physmem, *unsigned* *long* iomem, *unsigned* *long* highmem)

{
	*struct* page *p, *map;
	*unsigned* *long* phys_len, phys_pages, highmem_len, highmem_pages;
	*unsigned* *long* iomem_len, iomem_pages, total_len, total_pages;
	*int* i;

	phys_pages = physmem >> PAGE_SHIFT;
	phys_len = phys_pages * *sizeof*(*struct* page);

	iomem_pages = iomem >> PAGE_SHIFT;
	iomem_len = iomem_pages * *sizeof*(*struct* page);

	highmem_pages = highmem >> PAGE_SHIFT;
	highmem_len = highmem_pages * *sizeof*(*struct* page);

	total_pages = phys_pages + iomem_pages + highmem_pages;
	total_len = phys_len + iomem_pages + highmem_len;

	*if*(kmalloc_ok){
		map = kmalloc(total_len, GFP_KERNEL);
		*if*(map == NULL)
			map = vmalloc(total_len);
	}
	*else* map = alloc_bootmem_low_pages(total_len);

	*if*(map == NULL)
		*return*(-ENOMEM);

	*for*(i = 0; i < total_pages; i++){
		p = &map[i];
		set_page_count(p, 0);
		SetPageReserved(p);
		INIT_LIST_HEAD(&p->list);
	}

	mem_map = map;
	max_mapnr = total_pages;
	*return*(0);
}

this line should be

total_len = phys_len + iomem_len + highmem_len;

<http://cvs.sourceforge.net/viewcvs.py/user-mode-linux/linux/#dirlist>

#1 lore raw
Quoted 2 lines · wang lianwei

There is a bug In file
linux/arch/um/kernel/physmem.c init_mem() functions:

Yep, right...

Quoted 7 lines

*int* *init_maps*(*unsigned* *long* physmem, *unsigned* *long* iomem, *unsigned* *long* highmem)

{
	*struct* page *p, *map;
	*unsigned* *long* phys_len, phys_pages, highmem_len, highmem_pages;
	*unsigned* *long* iomem_len, iomem_pages, total_len, total_pages;
	*int* i;

(What happened to these bad "*" guys ;-) ? )

Quoted 13 lines
	phys_pages = physmem >> PAGE_SHIFT;
	phys_len = phys_pages * *sizeof*(*struct* page);

	iomem_pages = iomem >> PAGE_SHIFT;
	iomem_len = iomem_pages * *sizeof*(*struct* page);

	highmem_pages = highmem >> PAGE_SHIFT;
	highmem_len = highmem_pages * *sizeof*(*struct* page);

	total_pages = phys_pages + iomem_pages + highmem_pages;

	total_len = phys_len + iomem_pages + highmem_len;
Quoted 1 line

this line should be

That line should be the below one, right (it wasn't clear the line you were correcting, I later grasped it)? I think you're fully right (and I've never seen iomem working very well, so I tend to agree).

Quoted 1 line

total_len = phys_len + iomem_len + highmem_len;

Remember people: never compare apples with bananas (or whatever). Thanks for the note. It's the first patch on my queue.

Quoted 1 line

<http://cvs.sourceforge.net/viewcvs.py/user-mode-linux/linux/#dirlist>

Signature · 22 lines
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade

	
	
		
___________________________________ 
Yahoo! Messenger with Voice: chiama da PC a telefono a tariffe esclusive 
http://it.messenger.yahoo.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#2 lore raw
Quoted 2 lines · Blaisorblade

On Tuesday 10 January 2006 15:14, wang lianwei wrote:
(What happened to these bad "*" guys ;-) ? )

Yeah, this would have been better expressed as a patch.

Quoted 3 lines
Quoted 1 line

total_len = phys_len + iomem_len + highmem_len;

Remember people: never compare apples with bananas (or whatever).

Yup, sometimes I wish we had strongly typed integers...

Quoted 2 lines

Thanks for
the note. It's the first patch on my queue.

OK, I was going to fix it here, but I'll just let you send it in.

Does this fix the 2M iomem problem?

Jeff

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#3 lore raw
Quoted 11 lines · Jeff Dike
Quoted 2 lines · Blaisorblade

On Tuesday 10 January 2006 15:14, wang lianwei wrote:
(What happened to these bad "*" guys ;-) ? )

Yeah, this would have been better expressed as a patch.

Quoted 3 lines
Quoted 1 line

total_len = phys_len + iomem_len + highmem_len;

Remember people: never compare apples with bananas (or whatever).

Yup, sometimes I wish we had strongly typed integers...

Yeah :-] ...

I think in Java APIs tend to do almost that... not at that point, but they use distinct classes for Point and Dimension and Rectangle and whatsoever... and I even have to study these things.

Quoted 4 lines
Quoted 2 lines

Thanks for
the note. It's the first patch on my queue.

OK, I was going to fix it here, but I'll just let you send it in.

Will be in my next queue flush...

Quoted 1 line

Does this fix the 2M iomem problem?

Ah, well, he's the reporter of that problem, and he also worked diagnosing it... compliments!

Signature · 22 lines
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade

	
	
		
___________________________________ 
Yahoo! Messenger with Voice: chiama da PC a telefono a tariffe esclusive 
http://it.messenger.yahoo.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#4 lore raw
Quoted 3 lines · Blaisorblade
Quoted 1 line

Yup, sometimes I wish we had strongly typed integers...

Yeah :-] ...

But, a nanosecond later, I think about the insanity of bytes_to_page(), foo_to_bar(), etc converters that would be needed...

Quoted 2 lines

Ah, well, he's the reporter of that problem, and he also worked diagnosing it... compliments!

Indeed, I just wanted to make sure that fixed it.

Jeff

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel