[CRIU] criu dump fails when using noxsave

Adrian Reber adrian at lisas.de
Thu Dec 15 00:17:23 PST 2016


On Thu, Dec 15, 2016 at 01:37:55AM +0300, Cyrill Gorcunov wrote:
> On Wed, Dec 14, 2016 at 11:07:24PM +0100, Adrian Reber wrote:
> > I have two systems. One has the CPU feature xsave the other host
> > doesn't.
> > 
> > To migrate processes between these systems I specified the kernel
> > command-line 'noxsave' to disable the xsave option. With this kernel
> > command-line criu fails to dump with:
> > 
> 
> Hi! Thanks for report! It's night here will take a look tomorrow, ok?

I looked a bit more at XSAVE and wrote a simple test program to read out
the features:

On a system where the CPU (KVM) has no XSAVE I get:

XSAVE: 0
OSXSAVE: 0

On a system where the CPU has XSAVE and it is not disabled I get:

XSAVE: 1
OSXSAVE: 1

On a system where the CPU has XSAVE but the kernel parameter noxsave is
specified I get:

XSAVE: 1
OSXSAVE: 0

Attached patch is what helps me to migrate a process from a XSAVE system
booted with 'noxsave' to system without XSAVE. I will submit a proper
patch soon.

		Adrian

diff --git a/compel/arch/x86/src/lib/infect.c b/compel/arch/x86/src/lib/infect.c
index bf8c43a..be04399 100644
--- a/compel/arch/x86/src/lib/infect.c
+++ b/compel/arch/x86/src/lib/infect.c
@@ -173,7 +173,7 @@ int get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *ar
 
        pr_info("Dumping GP/FPU registers for %d\n", pid);
 
-       if (cpu_has_feature(X86_FEATURE_XSAVE)) {
+       if (cpu_has_feature(X86_FEATURE_OSXSAVE)) {
                iov.iov_base = &xsave;
                iov.iov_len = sizeof(xsave);
 
diff --git a/criu/arch/x86/cpu.c b/criu/arch/x86/cpu.c
index 5113a29..9f8083d 100644
--- a/criu/arch/x86/cpu.c
+++ b/criu/arch/x86/cpu.c
@@ -51,7 +51,7 @@ int cpu_init(void)
        pr_debug("fpu:%d fxsr:%d xsave:%d\n",
                 !!cpu_has_feature(X86_FEATURE_FPU),
                 !!cpu_has_feature(X86_FEATURE_FXSR),
-                !!cpu_has_feature(X86_FEATURE_XSAVE));
+                !!cpu_has_feature(X86_FEATURE_OSXSAVE));
 
        return 0;
 }
@@ -225,7 +225,7 @@ static int cpu_validate_features(CpuinfoX86Entry *img_x86_entry)
                 !cpu_has_feature(__bit))
                if (__mismatch_fpu_bit(X86_FEATURE_FPU)         ||
                    __mismatch_fpu_bit(X86_FEATURE_FXSR)        ||
-                   __mismatch_fpu_bit(X86_FEATURE_XSAVE)) {
+                   __mismatch_fpu_bit(X86_FEATURE_OSXSAVE)) {
                        pr_err("FPU feature required by image "
                               "is not supported on host.\n");
                        return -1;
diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index c842258..ba0145b 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -128,7 +128,7 @@ int save_task_regs(void *x, user_regs_struct_t *regs, user_fpregs_struct_t *fpre
        assign_array(core->thread_info->fpregs, fpregs->i387, st_space);
        assign_array(core->thread_info->fpregs, fpregs->i387, xmm_space);
 
-       if (cpu_has_feature(X86_FEATURE_XSAVE)) {
+       if (cpu_has_feature(X86_FEATURE_OSXSAVE)) {
                BUG_ON(core->thread_info->fpregs->xsave->n_ymmh_space != ARRAY_SIZE(fpregs->ymmh.ymmh_space));
 
                assign_reg(core->thread_info->fpregs->xsave, fpregs->xsave_hdr, xstate_bv);
@@ -168,7 +168,7 @@ int arch_alloc_thread_info(CoreEntry *core)
                GDT_ENTRY_TLS_NUM*sizeof(UserDescT*);
        if (with_fpu) {
                sz += sizeof(UserX86FpregsEntry);
-               with_xsave = cpu_has_feature(X86_FEATURE_XSAVE);
+               with_xsave = cpu_has_feature(X86_FEATURE_OSXSAVE);
                if (with_xsave)
                        sz += sizeof(UserX86XsaveEntry);
        }
@@ -249,7 +249,7 @@ static bool valid_xsave_frame(CoreEntry *core)
                return false;
        }
 
-       if (cpu_has_feature(X86_FEATURE_XSAVE)) {
+       if (cpu_has_feature(X86_FEATURE_OSXSAVE)) {
                if (core->thread_info->fpregs->xsave &&
                    core->thread_info->fpregs->xsave->n_ymmh_space < ARRAY_SIZE(x->ymmh.ymmh_space)) {
                        pr_err("Corruption in FPU ymmh_space area "
@@ -261,7 +261,7 @@ static bool valid_xsave_frame(CoreEntry *core)
        } else {
                /*
                 * If the image has xsave area present then CPU we're restoring
-                * on must have X86_FEATURE_XSAVE feature until explicitly
+                * on must have X86_FEATURE_OSXSAVE feature until explicitly
                 * stated in options.
                 */
                if (core->thread_info->fpregs->xsave) {
@@ -335,7 +335,7 @@ int restore_fpu(struct rt_sigframe *sigframe, CoreEntry *core)
        assign_array(x->i387, core->thread_info->fpregs, st_space);
        assign_array(x->i387, core->thread_info->fpregs, xmm_space);
 
-       if (cpu_has_feature(X86_FEATURE_XSAVE)) {
+       if (cpu_has_feature(X86_FEATURE_OSXSAVE)) {
                struct fpx_sw_bytes *fpx_sw = (void *)&x->i387.sw_reserved;
                void *magic2;



More information about the CRIU mailing list