Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1566321 > unrolled thread
| Started by | Pratyush Anand <panand@redhat.com> |
|---|---|
| First post | 2017-01-25 05:50 +0100 |
| Last post | 2017-01-25 08:00 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] /proc/kcore: Update physical address for kcore ram and text Pratyush Anand <panand@redhat.com> - 2017-01-25 05:50 +0100
Re: [PATCH] /proc/kcore: Update physical address for kcore ram and text Dave Young <dyoung@redhat.com> - 2017-01-25 07:40 +0100
Re: [PATCH] /proc/kcore: Update physical address for kcore ram and text Pratyush Anand <panand@redhat.com> - 2017-01-25 08:00 +0100
| From | Pratyush Anand <panand@redhat.com> |
|---|---|
| Date | 2017-01-25 05:50 +0100 |
| Subject | [PATCH] /proc/kcore: Update physical address for kcore ram and text |
| Message-ID | <t3nGV-5xU-1@gated-at.bofh.it> |
Currently all the p_paddr of PT_LOAD headers are assigned to 0, which is not true and could be misleading, since 0 is a valid physical address. User space tools like makedumpfile needs to know physical address for PT_LOAD segments of direct mapped regions. Therefore this patch updates paddr for such regions. It also sets an invalid paddr (-1) for other regions, so that user space tool can know whether a physical address provided in PT_LOAD is correct or not. Signed-off-by: Pratyush Anand <panand@redhat.com> --- fs/proc/kcore.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 0b80ad87b4d6..ea9f3d1ae830 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -373,7 +373,10 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff) phdr->p_flags = PF_R|PF_W|PF_X; phdr->p_offset = kc_vaddr_to_offset(m->addr) + dataoff; phdr->p_vaddr = (size_t)m->addr; - phdr->p_paddr = 0; + if (m->type == KCORE_RAM || m->type == KCORE_TEXT) + phdr->p_paddr = __pa(m->addr); + else + phdr->p_paddr = (elf_addr_t)-1; phdr->p_filesz = phdr->p_memsz = m->size; phdr->p_align = PAGE_SIZE; } -- 2.9.3
[toc] | [next] | [standalone]
| From | Dave Young <dyoung@redhat.com> |
|---|---|
| Date | 2017-01-25 07:40 +0100 |
| Subject | Re: [PATCH] /proc/kcore: Update physical address for kcore ram and text |
| Message-ID | <t3ppn-6GV-9@gated-at.bofh.it> |
| In reply to | #1566321 |
Hi Pratyush On 01/25/17 at 10:14am, Pratyush Anand wrote: > Currently all the p_paddr of PT_LOAD headers are assigned to 0, which is > not true and could be misleading, since 0 is a valid physical address. I do not know the history of /proc/kcore, so a question is why the p_addr was set as 0, if there were some reasons and if this could cause some risk or breakage. > > User space tools like makedumpfile needs to know physical address for > PT_LOAD segments of direct mapped regions. Therefore this patch updates > paddr for such regions. It also sets an invalid paddr (-1) for other > regions, so that user space tool can know whether a physical address > provided in PT_LOAD is correct or not. > > Signed-off-by: Pratyush Anand <panand@redhat.com> > --- > fs/proc/kcore.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c > index 0b80ad87b4d6..ea9f3d1ae830 100644 > --- a/fs/proc/kcore.c > +++ b/fs/proc/kcore.c > @@ -373,7 +373,10 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff) > phdr->p_flags = PF_R|PF_W|PF_X; > phdr->p_offset = kc_vaddr_to_offset(m->addr) + dataoff; > phdr->p_vaddr = (size_t)m->addr; > - phdr->p_paddr = 0; > + if (m->type == KCORE_RAM || m->type == KCORE_TEXT) > + phdr->p_paddr = __pa(m->addr); > + else > + phdr->p_paddr = (elf_addr_t)-1; > phdr->p_filesz = phdr->p_memsz = m->size; > phdr->p_align = PAGE_SIZE; > } > -- > 2.9.3 > Thanks Dave
[toc] | [prev] | [next] | [standalone]
| From | Pratyush Anand <panand@redhat.com> |
|---|---|
| Date | 2017-01-25 08:00 +0100 |
| Subject | Re: [PATCH] /proc/kcore: Update physical address for kcore ram and text |
| Message-ID | <t3pIK-6NO-7@gated-at.bofh.it> |
| In reply to | #1566339 |
Hi Dave,
On Wednesday 25 January 2017 11:59 AM, Dave Young wrote:
> Hi Pratyush
> On 01/25/17 at 10:14am, Pratyush Anand wrote:
>> Currently all the p_paddr of PT_LOAD headers are assigned to 0, which is
>> not true and could be misleading, since 0 is a valid physical address.
> I do not know the history of /proc/kcore, so a question is why the
> p_addr was set as 0, if there were some reasons and if this could cause
> some risk or breakage.
>
I do not know why it was 0, which is a valid physical address. But
certainly, it might break some user space tools, and those need to be
fixed. For example, see following code from kexec-tools
kexec/kexec-elf.c:build_mem_phdrs()
435 if ((phdr->p_paddr + phdr->p_memsz) < phdr->p_paddr) {
436 /* The memory address wraps */
437 if (probe_debug) {
438 fprintf(stderr, "ELF address wrap
around\n");
439 }
440 return -1;
441 }
We do not need to perform above check for an invalid physical address.
I think, kexec-tools and makedumpfile will need fixup. I already have
those fixup which will be sent upstream once this patch makes through.
Pro with this approach is that, it will help to calculate variable like
page_offset, phys_base from PT_LOAD even when they are randomized and
therefore will reduce many variable and version specific values in user
space tools.
~Pratyush
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web