linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@in.ibm.com>
To: Michael Ellerman <michael@ellerman.id.au>
Cc: linuxppc-dev@ozlabs.org, paulus@samba.org,
	Fastboot mailing list <fastboot@lists.osdl.org>
Subject: Re: [Fastboot] [PATCH] kdump: don't call __ioremap() for pfn = 0
Date: Thu, 21 Sep 2006 10:10:49 -0400	[thread overview]
Message-ID: <20060921141049.GB1542@in.ibm.com> (raw)
In-Reply-To: <1158836557.7062.52.camel@localhost.localdomain>

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

  reply	other threads:[~2006-09-21 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-21  4:37 [PATCH] kdump: don't call __ioremap() for pfn = 0 Sachin P. Sant
2006-09-21 11:02 ` Michael Ellerman
2006-09-21 14:10   ` Vivek Goyal [this message]
2006-09-22  6:55     ` [Fastboot] " Michael Ellerman
2006-09-22  4:22   ` Sachin P. Sant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060921141049.GB1542@in.ibm.com \
    --to=vgoyal@in.ibm.com \
    --cc=fastboot@lists.osdl.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=michael@ellerman.id.au \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).