Hi Dave
*
I have a question about the ptov command. Ptov only handles kernel virtual addresses and their corresponding physical addresses. However if you give ptov a physical address that does not correspond to a kernel virtual address it still answers with an address. Users might get confused and do not know when to trust ptov, especially as the inverse command vtop always works.
*
So I would like to restrict ptov to give a result only when it is valid. The idea I have is that if ptov returns a valid virtual address then vtop on that address should give the same physical address back again. True??
*
cmd_ptov() in memory.c
* ....
* vaddr = PTOV(paddr);
* kvtop(0, vaddr, &paddr_tst, 0);
* if (paddr != paddr_tst) ... invalid vaddr, do not print it ...
*
Any comments?
*
Jan
*
Jan Karlsson
Senior Software Engineer
MIB
*
Sony Mobile Communications
Tel: +46703062174
sonymobile.com
*
*
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
07-05-2012, 01:47 PM
Dave Anderson
ptov command
----- Original Message -----
>
> Hi Dave
>
> I have a question about the ptov command. Ptov only handles kernel
> virtual addresses and their corresponding physical addresses.
> However if you give ptov a physical address that does not correspond
> to a kernel virtual address it still answers with an address. Users
> might get confused and do not know when to trust ptov, especially as
> the inverse command vtop always works.
>
> So I would like to restrict ptov to give a result only when it is
> valid. The idea I have is that if ptov returns a valid virtual
> address then vtop on that address should give the same physical
> address back again. True??
>
> cmd_ptov() in memory.c
>
> ....
>
> vaddr = PTOV(paddr);
> kvtop(0, vaddr, &paddr_tst, 0);
> if (paddr != paddr_tst) ... invalid vaddr, do not print it ...
>
> Any comments?
>
> Jan
Sounds reasonable, at least for the 32-bit arches. I don't think it's
necessary for any 64-bit arch. And you'd also need to account for kvtop()
failing outright (and returning FALSE).
Dave
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
07-06-2012, 06:43 AM
"Karlsson, Jan"
ptov command
Below you find my version of the ptov function. I have just added a few lines and placed them under "#if defined(ARM)". The test is reasonable for ARM so I would appreciate if you include it. For other platforms please do whatever you like.
Jan
void
cmd_ptov(void)
{
int c;
ulong vaddr;
physaddr_t paddr;
#if defined(ARM)
physaddr_t paddr_tst;
#endif
char buf1[BUFSIZE];
char buf2[BUFSIZE];
int others;
Jan Karlsson
Senior Software Engineer
MIB
*
Sony Mobile Communications
Tel: +46703062174
sonymobile.com
*
-----Original Message-----
From: crash-utility-bounces@redhat.com [mailto:crash-utility-bounces@redhat.com] On Behalf Of Dave Anderson
Sent: torsdag den 5 juli 2012 15:48
To: Discussion list for crash utility usage, maintenance and development
Subject: Re: [Crash-utility] ptov command
----- Original Message -----
>
> Hi Dave
>
> I have a question about the ptov command. Ptov only handles kernel
> virtual addresses and their corresponding physical addresses.
> However if you give ptov a physical address that does not correspond
> to a kernel virtual address it still answers with an address. Users
> might get confused and do not know when to trust ptov, especially as
> the inverse command vtop always works.
>
> So I would like to restrict ptov to give a result only when it is
> valid. The idea I have is that if ptov returns a valid virtual
> address then vtop on that address should give the same physical
> address back again. True??
>
> cmd_ptov() in memory.c
>
> ....
>
> vaddr = PTOV(paddr);
> kvtop(0, vaddr, &paddr_tst, 0);
> if (paddr != paddr_tst) ... invalid vaddr, do not print it ...
>
> Any comments?
>
> Jan
Sounds reasonable, at least for the 32-bit arches. I don't think it's
necessary for any 64-bit arch. And you'd also need to account for kvtop()
failing outright (and returning FALSE).
Dave
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
07-06-2012, 03:39 PM
Dave Anderson
ptov command
----- Original Message -----
> Below you find my version of the ptov function. I have just added a
> few lines and placed them under "#if defined(ARM)". The test is
> reasonable for ARM so I would appreciate if you include it. For
> other platforms please do whatever you like.
>
> Jan
>
>
> void
> cmd_ptov(void)
> {
> int c;
> ulong vaddr;
> physaddr_t paddr;
> #if defined(ARM)
> physaddr_t paddr_tst;
> #endif
> char buf1[BUFSIZE];
> char buf2[BUFSIZE];
> int others;
>
> while ((c = getopt(argcnt, args, "")) != EOF) {
> switch(c)
> {
> default:
> argerrs++;
> break;
> }
> }
>
> if (argerrs || !args[optind])
> cmd_usage(pc->curcmd, SYNOPSIS);
>
> others = 0;
> while (args[optind]) {
> paddr = htoll(args[optind], FAULT_ON_ERROR, NULL);
> vaddr = PTOV(paddr);
>
> #if defined(ARM)
> if (kvtop(0, vaddr, &paddr_tst, 0) && paddr_tst==paddr) {
> #endif
> fprintf(fp, "%s%s %s
", others++ ? "
" : "",
> mkstring(buf1, VADDR_PRLEN, LJUST, "VIRTUAL"),
> mkstring(buf2, VADDR_PRLEN, LJUST, "PHYSICAL"));
> fprintf(fp, "%s %s
",
> mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, MKSTR(vaddr)),
> mkstring(buf2, VADDR_PRLEN, LJUST|LONGLONG_HEX,
> MKSTR(&paddr)));
> #if defined(ARM)
> } else {
> fprintf(fp, "Unknown virtual address for physical address
> 0x%08llx
", paddr);
> }
> #endif
>
> optind++;
> }
> }
I hate the "#ifdef ARM" sections and the error message doesn't fit
into multiple-argument usage. How's this work for you?
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
07-09-2012, 07:33 AM
"Karlsson, Jan"
ptov command
Hi Dave
I have tested your solution and it works fine and solves the problem I have seen. It is also in several ways better than my solution, so please include it in the next release.
Thanks
Jan
Jan Karlsson
Senior Software Engineer
MIB
*
Sony Mobile Communications
Tel: +46703062174
sonymobile.com
*
-----Original Message-----
From: crash-utility-bounces@redhat.com [mailto:crash-utility-bounces@redhat.com] On Behalf Of Dave Anderson
Sent: fredag den 6 juli 2012 17:40
To: Discussion list for crash utility usage, maintenance and development
Subject: Re: [Crash-utility] ptov command
----- Original Message -----
> Below you find my version of the ptov function. I have just added a
> few lines and placed them under "#if defined(ARM)". The test is
> reasonable for ARM so I would appreciate if you include it. For other
> platforms please do whatever you like.
>
> Jan
>
>
> void
> cmd_ptov(void)
> {
> int c;
> ulong vaddr;
> physaddr_t paddr;
> #if defined(ARM)
> physaddr_t paddr_tst;
> #endif
> char buf1[BUFSIZE];
> char buf2[BUFSIZE];
> int others;
>
> while ((c = getopt(argcnt, args, "")) != EOF) {
> switch(c)
> {
> default:
> argerrs++;
> break;
> }
> }
>
> if (argerrs || !args[optind])
> cmd_usage(pc->curcmd, SYNOPSIS);
>
> others = 0;
> while (args[optind]) {
> paddr = htoll(args[optind], FAULT_ON_ERROR, NULL);
> vaddr = PTOV(paddr);
>
> #if defined(ARM)
> if (kvtop(0, vaddr, &paddr_tst, 0) && paddr_tst==paddr) { #endif
> fprintf(fp, "%s%s %s
", others++ ? "
" : "",
> mkstring(buf1, VADDR_PRLEN, LJUST, "VIRTUAL"),
> mkstring(buf2, VADDR_PRLEN, LJUST, "PHYSICAL"));
> fprintf(fp, "%s %s
",
> mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX, MKSTR(vaddr)),
> mkstring(buf2, VADDR_PRLEN, LJUST|LONGLONG_HEX,
> MKSTR(&paddr)));
> #if defined(ARM)
> } else {
> fprintf(fp, "Unknown virtual address for physical address
> 0x%08llx
", paddr);
> }
> #endif
>
> optind++;
> }
> }
I hate the "#ifdef ARM" sections and the error message doesn't fit into multiple-argument usage. How's this work for you?