diff options
author | HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com> | 2013-07-03 18:02:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:30 -0400 |
commit | 7f614cd1e052ebbddee7ea49c725dc75fee74a5a (patch) | |
tree | 553d8a003e4aea52b6a163d45775953eead06325 | |
parent | f2bdacdd597d8d05c3d5f5d36273084f7ef7e6f5 (diff) |
vmcore: treat memory chunks referenced by PT_LOAD program header entries in page-size boundary in vmcore_list
Treat memory chunks referenced by PT_LOAD program header entries in
page-size boundary in vmcore_list. Formally, for each range [start,
end], we set up the corresponding vmcore object in vmcore_list to
[rounddown(start, PAGE_SIZE), roundup(end, PAGE_SIZE)].
This change affects layout of /proc/vmcore. The gaps generated by the
rearrangement are newly made visible to applications as holes.
Concretely, they are two ranges [rounddown(start, PAGE_SIZE), start] and
[end, roundup(end, PAGE_SIZE)].
Suppose variable m points at a vmcore object in vmcore_list, and
variable phdr points at the program header of PT_LOAD type the variable
m corresponds to. Then, pictorially:
m->offset +---------------+
| hole |
phdr->p_offset = +---------------+
m->offset + (paddr - start) | |\
| kernel memory | phdr->p_memsz
| |/
+---------------+
| hole |
m->offset + m->size +---------------+
where m->offset and m->offset + m->size are always page-size aligned.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Atsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>
Cc: Lisa Mitchell <lisa.mitchell@hp.com>
Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/proc/vmcore.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 0b1c04e5e2c5..78c87a1ac01a 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c | |||
@@ -407,20 +407,27 @@ static int __init process_ptload_program_headers_elf64(char *elfptr, | |||
407 | phdr_ptr->p_memsz; /* Note sections */ | 407 | phdr_ptr->p_memsz; /* Note sections */ |
408 | 408 | ||
409 | for (i = 0; i < ehdr_ptr->e_phnum; i++, phdr_ptr++) { | 409 | for (i = 0; i < ehdr_ptr->e_phnum; i++, phdr_ptr++) { |
410 | u64 paddr, start, end, size; | ||
411 | |||
410 | if (phdr_ptr->p_type != PT_LOAD) | 412 | if (phdr_ptr->p_type != PT_LOAD) |
411 | continue; | 413 | continue; |
412 | 414 | ||
415 | paddr = phdr_ptr->p_offset; | ||
416 | start = rounddown(paddr, PAGE_SIZE); | ||
417 | end = roundup(paddr + phdr_ptr->p_memsz, PAGE_SIZE); | ||
418 | size = end - start; | ||
419 | |||
413 | /* Add this contiguous chunk of memory to vmcore list.*/ | 420 | /* Add this contiguous chunk of memory to vmcore list.*/ |
414 | new = get_new_element(); | 421 | new = get_new_element(); |
415 | if (!new) | 422 | if (!new) |
416 | return -ENOMEM; | 423 | return -ENOMEM; |
417 | new->paddr = phdr_ptr->p_offset; | 424 | new->paddr = start; |
418 | new->size = phdr_ptr->p_memsz; | 425 | new->size = size; |
419 | list_add_tail(&new->list, vc_list); | 426 | list_add_tail(&new->list, vc_list); |
420 | 427 | ||
421 | /* Update the program header offset. */ | 428 | /* Update the program header offset. */ |
422 | phdr_ptr->p_offset = vmcore_off; | 429 | phdr_ptr->p_offset = vmcore_off + (paddr - start); |
423 | vmcore_off = vmcore_off + phdr_ptr->p_memsz; | 430 | vmcore_off = vmcore_off + size; |
424 | } | 431 | } |
425 | return 0; | 432 | return 0; |
426 | } | 433 | } |
@@ -443,20 +450,27 @@ static int __init process_ptload_program_headers_elf32(char *elfptr, | |||
443 | phdr_ptr->p_memsz; /* Note sections */ | 450 | phdr_ptr->p_memsz; /* Note sections */ |
444 | 451 | ||
445 | for (i = 0; i < ehdr_ptr->e_phnum; i++, phdr_ptr++) { | 452 | for (i = 0; i < ehdr_ptr->e_phnum; i++, phdr_ptr++) { |
453 | u64 paddr, start, end, size; | ||
454 | |||
446 | if (phdr_ptr->p_type != PT_LOAD) | 455 | if (phdr_ptr->p_type != PT_LOAD) |
447 | continue; | 456 | continue; |
448 | 457 | ||
458 | paddr = phdr_ptr->p_offset; | ||
459 | start = rounddown(paddr, PAGE_SIZE); | ||
460 | end = roundup(paddr + phdr_ptr->p_memsz, PAGE_SIZE); | ||
461 | size = end - start; | ||
462 | |||
449 | /* Add this contiguous chunk of memory to vmcore list.*/ | 463 | /* Add this contiguous chunk of memory to vmcore list.*/ |
450 | new = get_new_element(); | 464 | new = get_new_element(); |
451 | if (!new) | 465 | if (!new) |
452 | return -ENOMEM; | 466 | return -ENOMEM; |
453 | new->paddr = phdr_ptr->p_offset; | 467 | new->paddr = start; |
454 | new->size = phdr_ptr->p_memsz; | 468 | new->size = size; |
455 | list_add_tail(&new->list, vc_list); | 469 | list_add_tail(&new->list, vc_list); |
456 | 470 | ||
457 | /* Update the program header offset */ | 471 | /* Update the program header offset */ |
458 | phdr_ptr->p_offset = vmcore_off; | 472 | phdr_ptr->p_offset = vmcore_off + (paddr - start); |
459 | vmcore_off = vmcore_off + phdr_ptr->p_memsz; | 473 | vmcore_off = vmcore_off + size; |
460 | } | 474 | } |
461 | return 0; | 475 | return 0; |
462 | } | 476 | } |