[CRIU] [PATCH 26/44] cr-dump.c: moved thread core initialization into the function arch_alloc_thread_info().
Alexander Kartashov
alekskartashov at parallels.com
Mon Jan 7 10:04:55 EST 2013
Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
arch/x86/crtools.c | 61 +++++++++++++++++++++++++++++++++++++++++++
arch/x86/include/asm/dump.h | 1 +
cr-dump.c | 53 +------------------------------------
3 files changed, 63 insertions(+), 52 deletions(-)
diff --git a/arch/x86/crtools.c b/arch/x86/crtools.c
index be35aa8..eb9271c 100644
--- a/arch/x86/crtools.c
+++ b/arch/x86/crtools.c
@@ -200,3 +200,64 @@ out:
err:
return ret;
}
+
+int arch_alloc_thread_info(CoreEntry *core) {
+ ThreadInfoX86 *thread_info;
+ UserX86RegsEntry *gpregs;
+ UserX86FpregsEntry *fpregs;
+ ThreadCoreEntry *thread_core;
+
+ thread_info = xmalloc(sizeof(*thread_info));
+ if (!thread_info)
+ goto err;
+ thread_info_x86__init(thread_info);
+ core->thread_info = thread_info;
+
+ thread_core = xmalloc(sizeof(*thread_core));
+ if (!thread_core)
+ goto err;
+ thread_core_entry__init(thread_core);
+ core->thread_core = thread_core;
+
+ gpregs = xmalloc(sizeof(*gpregs));
+ if (!gpregs)
+ goto err;
+ user_x86_regs_entry__init(gpregs);
+ thread_info->gpregs = gpregs;
+
+ if (cpu_has_feature(X86_FEATURE_FPU)) {
+ fpregs = xmalloc(sizeof(*fpregs));
+ if (!fpregs)
+ goto err;
+ user_x86_fpregs_entry__init(fpregs);
+ thread_info->fpregs = fpregs;
+ /* These are numbers from kernel */
+ fpregs->n_st_space = 32;
+ fpregs->n_xmm_space = 64;
+
+ fpregs->st_space = xzalloc(pb_repeated_size(fpregs, st_space));
+ fpregs->xmm_space = xzalloc(pb_repeated_size(fpregs, xmm_space));
+
+ if (!fpregs->st_space || !fpregs->xmm_space)
+ goto err;
+
+ if (cpu_has_feature(X86_FEATURE_XSAVE)) {
+ UserX86XsaveEntry *xsave;
+ xsave = xmalloc(sizeof(*xsave));
+ if (!xsave)
+ goto err;
+ user_x86_xsave_entry__init(xsave);
+ thread_info->fpregs->xsave = xsave;
+
+ xsave->n_ymmh_space = 64;
+ xsave->ymmh_space = xzalloc(pb_repeated_size(xsave, ymmh_space));
+ if (!xsave->ymmh_space)
+ goto err;
+ }
+ }
+
+ return 0;
+
+err:
+ return 1;
+}
diff --git a/arch/x86/include/asm/dump.h b/arch/x86/include/asm/dump.h
index fb86f50..fafa214 100644
--- a/arch/x86/include/asm/dump.h
+++ b/arch/x86/include/asm/dump.h
@@ -2,5 +2,6 @@
#define __CR_ASM_DUMP_H__
extern int get_task_regs(pid_t pid, CoreEntry *core, const struct parasite_ctl *ctl);
+extern int arch_alloc_thread_info(CoreEntry *core);
#endif
diff --git a/cr-dump.c b/cr-dump.c
index 9a288d0..ff199fe 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -719,12 +719,8 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info,
int alloc_ids)
{
CoreEntry *core;
- ThreadInfoX86 *thread_info;
- UserX86RegsEntry *gpregs;
- UserX86FpregsEntry *fpregs;
TaskCoreEntry *tc;
TaskKobjIdsEntry *ids;
- ThreadCoreEntry *thread_core;
core = xmalloc(sizeof(*core));
if (!core)
@@ -734,55 +730,8 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info,
core->mtype = CORE_ENTRY__MARCH__X86_64;
if (alloc_thread_info) {
- thread_info = xmalloc(sizeof(*thread_info));
- if (!thread_info)
+ if (arch_alloc_thread_info(core))
goto err;
- thread_info_x86__init(thread_info);
- core->thread_info = thread_info;
-
- thread_core = xmalloc(sizeof(*thread_core));
- if (!thread_core)
- goto err;
- thread_core_entry__init(thread_core);
- core->thread_core = thread_core;
-
- gpregs = xmalloc(sizeof(*gpregs));
- if (!gpregs)
- goto err;
- user_x86_regs_entry__init(gpregs);
- thread_info->gpregs = gpregs;
-
- if (cpu_has_feature(X86_FEATURE_FPU)) {
- fpregs = xmalloc(sizeof(*fpregs));
- if (!fpregs)
- goto err;
- user_x86_fpregs_entry__init(fpregs);
- thread_info->fpregs = fpregs;
-
- /* These are numbers from kernel */
- fpregs->n_st_space = 32;
- fpregs->n_xmm_space = 64;
-
- fpregs->st_space = xzalloc(pb_repeated_size(fpregs, st_space));
- fpregs->xmm_space = xzalloc(pb_repeated_size(fpregs, xmm_space));
-
- if (!fpregs->st_space || !fpregs->xmm_space)
- goto err;
-
- if (cpu_has_feature(X86_FEATURE_XSAVE)) {
- UserX86XsaveEntry *xsave;
- xsave = xmalloc(sizeof(*xsave));
- if (!xsave)
- goto err;
- user_x86_xsave_entry__init(xsave);
- thread_info->fpregs->xsave = xsave;
-
- xsave->n_ymmh_space = 64;
- xsave->ymmh_space = xzalloc(pb_repeated_size(xsave, ymmh_space));
- if (!xsave->ymmh_space)
- goto err;
- }
- }
}
if (alloc_tc) {
--
1.7.10.4
More information about the CRIU
mailing list