mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 15:25:21 +00:00
compel/x86: Separate functions used to get fpu state
Mere cleanup. For Skylake workaround I'll call one after another, so it's better separate it in a small helpers. Signed-off-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
8a8717da5a
commit
0e609f8cab
@@ -225,12 +225,35 @@ int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe,
|
|||||||
((user_regs_native(pregs)) ? (int64_t)((pregs)->native.name) : \
|
((user_regs_native(pregs)) ? (int64_t)((pregs)->native.name) : \
|
||||||
(int32_t)((pregs)->compat.name))
|
(int32_t)((pregs)->compat.name))
|
||||||
|
|
||||||
|
static int get_task_xsave(pid_t pid, user_fpregs_struct_t *xsave)
|
||||||
|
{
|
||||||
|
struct iovec iov;
|
||||||
|
|
||||||
|
iov.iov_base = xsave;
|
||||||
|
iov.iov_len = sizeof(*xsave);
|
||||||
|
|
||||||
|
if (ptrace(PTRACE_GETREGSET, pid, (unsigned int)NT_X86_XSTATE, &iov) < 0) {
|
||||||
|
pr_perror("Can't obtain FPU registers for %d", pid);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_task_fpregs(pid_t pid, user_fpregs_struct_t *xsave)
|
||||||
|
{
|
||||||
|
if (ptrace(PTRACE_GETFPREGS, pid, NULL, xsave)) {
|
||||||
|
pr_perror("Can't obtain FPU registers for %d", pid);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int get_task_regs(pid_t pid, user_regs_struct_t *regs, save_regs_t save,
|
int get_task_regs(pid_t pid, user_regs_struct_t *regs, save_regs_t save,
|
||||||
void *arg, __maybe_unused unsigned long flags)
|
void *arg, __maybe_unused unsigned long flags)
|
||||||
{
|
{
|
||||||
user_fpregs_struct_t xsave = { }, *xs = NULL;
|
user_fpregs_struct_t xsave = { }, *xs = NULL;
|
||||||
|
|
||||||
struct iovec iov;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
pr_info("Dumping general registers for %d in %s mode\n", pid,
|
pr_info("Dumping general registers for %d in %s mode\n", pid,
|
||||||
@@ -264,19 +287,12 @@ int get_task_regs(pid_t pid, user_regs_struct_t *regs, save_regs_t save,
|
|||||||
pr_info("Dumping GP/FPU registers for %d\n", pid);
|
pr_info("Dumping GP/FPU registers for %d\n", pid);
|
||||||
|
|
||||||
if (compel_cpu_has_feature(X86_FEATURE_OSXSAVE)) {
|
if (compel_cpu_has_feature(X86_FEATURE_OSXSAVE)) {
|
||||||
iov.iov_base = &xsave;
|
if (get_task_xsave(pid, &xsave))
|
||||||
iov.iov_len = sizeof(xsave);
|
|
||||||
|
|
||||||
if (ptrace(PTRACE_GETREGSET, pid, (unsigned int)NT_X86_XSTATE, &iov) < 0) {
|
|
||||||
pr_perror("Can't obtain FPU registers for %d", pid);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (ptrace(PTRACE_GETFPREGS, pid, NULL, &xsave)) {
|
if (get_task_fpregs(pid, &xsave))
|
||||||
pr_perror("Can't obtain FPU registers for %d", pid);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
xs = &xsave;
|
xs = &xsave;
|
||||||
out:
|
out:
|
||||||
|
Reference in New Issue
Block a user