mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: Ray Lee <ray-lk@madrabbit.org>, Ingo Molnar <mingo@elte.hu>,
	Sam Ravnborg <sam@ravnborg.org>,
	linux-kernel@vger.kernel.org, Andrew Morton <akpm@zip.com.au>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jason Wessel <jason.wessel@windriver.com>
Subject: Re: [git pull] kgdb light, v5
Date: Sun, 10 Feb 2008 11:44:45 -0800 (PST)	[thread overview]
Message-ID: <alpine.LFD.1.00.0802101134470.2896@woody.linux-foundation.org> (raw)
In-Reply-To: <47AF483E.10905@web.de>



On Sun, 10 Feb 2008, Jan Kiszka wrote:
>
> +static int kgdb_get_mem(char *addr, unsigned char *buf, int count)
>  {
> +	if ((unsigned long)addr < TASK_SIZE)
> +		return -EFAULT;
>  
> +	return probe_kernel_read(buf, addr, count);
>  }

Ok, so this is a pretty function after all the cleanups, but I actually 
don't think that "if ((unsigned long)addr < TASK_SIZE)" is really even 
asked for.

Why not let kgdb look at user memory? I'd argue that in a lot of cases, it 
might be quite nice to do, to see what user arguments in memory are etc 
etc (think things like futexes, where user memory contents really do 
matter).

So I'd suggest getting rid of the whole "kgdb_{get|set}_mem()" functions, 
and just using "probe_kernel_{read|write}()" directly instead.

(Not that I necessarily love those names either, but whatever..)

The TASK_SIZE checks make more sense in kgdb_validate_break_address() and 
friends, where it actually does make sense to check that it's really a 
*kernel* address.

But even there, I'm not sure if the right check is to compare against 
TASK_SIZE, since kernel and user memory addresses can in theory be 
distinct (that's why we have "set_fs()" historically, and while it's no 
longer true on x86 and hasn't been in a long time, the kernel conceptually 
allows it - see my previous reply about that whole get_fs/set_fs thing in 
the definition of probe_kernel_read/write).

> +	if (count == 2 && ((long)mem & 1) == 0)
> +		err = probe_kernel_read(tmp, mem, 2);
> +	else if (count == 4 && ((long)mem & 3) == 0)
> +		err = probe_kernel_read(tmp, mem, 4);
> +	else if (count == 8 && ((long)mem & 7) == 0)
> +		err = probe_kernel_read(tmp, mem, 8);
> +	else
> +		err = probe_kernel_read(tmp, mem, count);

There's absolutely no reason to care about the alignment, since if you now 
use "probe_kernel_read()", the sane thing to do is to just do

	err = probe_kernel_read(tmp, mem, count);
	if (!err) {
		while (count > 0) {
			buf = pack_hex_byte(buf, *tmp);
			tmp++;
			count--;
	}

and you're all done. No?

		Linus

  parent reply	other threads:[~2008-02-10 19:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-10  7:13 [0/6] kgdb light Ingo Molnar
2008-02-10  7:37 ` David Miller
2008-02-10 10:47 ` Sam Ravnborg
2008-02-10 13:25   ` Jan Kiszka
2008-02-10 19:31     ` Sam Ravnborg
2008-02-10 20:23       ` Jan Kiszka
2008-02-10 21:16       ` Ingo Molnar
2008-02-10 21:30         ` Sam Ravnborg
2008-02-10 21:34           ` Ingo Molnar
2008-02-10 16:36   ` [git pull] kgdb light, v5 Ingo Molnar
2008-02-10 17:30     ` Ray Lee
2008-02-10 17:39       ` Jan Kiszka
2008-02-10 18:59         ` Ray Lee
2008-02-10 18:53       ` Jan Kiszka
2008-02-10 19:34         ` Ingo Molnar
2008-02-10 19:44         ` Linus Torvalds [this message]
2008-02-10 20:19           ` Ingo Molnar
2008-02-10 20:22           ` Jan Kiszka
2008-02-10 21:13             ` Ingo Molnar
2008-02-10 20:29           ` Ingo Molnar
2008-02-10 20:41             ` Ingo Molnar
2008-02-10 19:34     ` Sam Ravnborg

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=alpine.LFD.1.00.0802101134470.2896@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@zip.com.au \
    --cc=jan.kiszka@web.de \
    --cc=jason.wessel@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=ray-lk@madrabbit.org \
    --cc=sam@ravnborg.org \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®