mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 13:41:30 +00:00
regset: Add support for dynamically sized regsets
Currently the regset API doesn't allow for the possibility that regsets (or at least, the amount of meaningful data in a regset) may change in size. In particular, this results in useless padding being added to coredumps if a regset's current size is smaller than its theoretical maximum size. This patch adds a get_size() function to struct user_regset. Individual regset implementations can implement this function to return the current size of the regset data. A regset_size() function is added to provide callers with an abstract interface for determining the size of a regset without needing to know whether the regset is dynamically sized or not. The only affected user of this interface is the ELF coredump code: This patch ports ELF coredump to dump regsets with their actual size in the coredump. This has no effect except for new regsets that are dynamically sized and provide a get_size() implementation. Signed-off-by: Dave Martin <Dave.Martin@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Dmitry Safonov <dsafonov@virtuozzo.com> Cc: H. J. Lu <hjl.tools@gmail.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
This commit is contained in:
parent
c7f5828bf7
commit
27e64b4be4
2 changed files with 65 additions and 12 deletions
|
@ -1699,7 +1699,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
|
|||
long signr, size_t *total)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int regset_size = view->regsets[0].n * view->regsets[0].size;
|
||||
unsigned int regset0_size = regset_size(t->task, &view->regsets[0]);
|
||||
|
||||
/*
|
||||
* NT_PRSTATUS is the one special case, because the regset data
|
||||
|
@ -1708,11 +1708,11 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
|
|||
* We assume that regset 0 is NT_PRSTATUS.
|
||||
*/
|
||||
fill_prstatus(&t->prstatus, t->task, signr);
|
||||
(void) view->regsets[0].get(t->task, &view->regsets[0], 0, regset_size,
|
||||
(void) view->regsets[0].get(t->task, &view->regsets[0], 0, regset0_size,
|
||||
&t->prstatus.pr_reg, NULL);
|
||||
|
||||
fill_note(&t->notes[0], "CORE", NT_PRSTATUS,
|
||||
PRSTATUS_SIZE(t->prstatus, regset_size), &t->prstatus);
|
||||
PRSTATUS_SIZE(t->prstatus, regset0_size), &t->prstatus);
|
||||
*total += notesize(&t->notes[0]);
|
||||
|
||||
do_thread_regset_writeback(t->task, &view->regsets[0]);
|
||||
|
@ -1728,7 +1728,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
|
|||
if (regset->core_note_type && regset->get &&
|
||||
(!regset->active || regset->active(t->task, regset))) {
|
||||
int ret;
|
||||
size_t size = regset->n * regset->size;
|
||||
size_t size = regset_size(t->task, regset);
|
||||
void *data = kmalloc(size, GFP_KERNEL);
|
||||
if (unlikely(!data))
|
||||
return 0;
|
||||
|
@ -1743,7 +1743,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
|
|||
size, data);
|
||||
else {
|
||||
SET_PR_FPVALID(&t->prstatus,
|
||||
1, regset_size);
|
||||
1, regset0_size);
|
||||
fill_note(&t->notes[i], "CORE",
|
||||
NT_PRFPREG, size, data);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue