[Fastboot] [PATCH] kdump: don't call __ioremap() for pfn = 0

Vivek Goyal vgoyal at in.ibm.com
Fri Sep 22 00:10:49 EST 2006


On Thu, Sep 21, 2006 at 09:02:37PM +1000, Michael Ellerman wrote:
> On Thu, 2006-09-21 at 10:07 +0530, Sachin P. Sant wrote:
> > Hi
> > 
> > While using dd command to retrive the dump from /dev/oldmem, there comes
> > a rare case where pfn value is zero. In this case the __ioremap() call 
> > returns
> > NULL and hence copying fails.
> > 
> > # dd if=/dev/oldmem of=/dev/null
> > dd: reading `/dev/oldmem': Bad address
> > 0+0 records in
> > 0+0 records out
> > 0 bytes (0 B) copied, 0.000121 seconds, 0.0 kB/s
> > 
> > Attached is a patch to fix this problem. During such rare cases don't call
> > __ioremap() to do the address translation, instead use __va() .
> 
> It's not really rare, it's just when we're reading /dev/oldmem directly.
> 
> We can actually use the __va() trick for the whole linear mapping rather
> than just pfn 0, which saves the ioremap. We also shouldn't really be
> trying to iounmap(__va(0)).
> 

Makes sense. We can take advantage of linear mappings mapped till max_pfn
and avoid ioremap().

> +
> +static size_t copy_oldmem_vaddr(void *vaddr, char *buf, size_t csize,
> +				unsigned long offset, int userbuf)
> +{
> +	if (userbuf) {
> +		if (copy_to_user((char __user *)buf, (vaddr + offset), csize)) {
> +			return -EFAULT;
> +		}

Probably you can get rid of above pair of braces as there is only single
statement under if.

>  
> -	if (userbuf) {
> -		if (copy_to_user((char __user *)buf, (vaddr + offset), csize)) {
> -			iounmap(vaddr);
> -			return -EFAULT;
> -		}
> -	} else
> -		memcpy(buf, (vaddr + offset), csize);
> +	if (pfn < max_pfn) {

Should this be (pfn <= max_pfn) ?

-Vivek



More information about the Linuxppc-dev mailing list