|
From: Richard W. <ri...@no...> - 2017-06-21 12:47:31
|
Thomas, Natale,
Am 21.06.2017 um 11:44 schrieb Thomas Meyer:
>> It is funny to see that this problem was firstly reported here [1] in
>> February 2017 without being considered until someone else bought a
>> new
>> laptop :)
sometimes mails/issues get lost...
> Yes, I like my new laptop :-)
>
>> Anyway, thank you for digging into this; my temporary workaround at
>> the time was to use always the *_i387_registers functions.
>
> Oops, there is the complete thread with the same problem. But sorry I
> don't follow uml-user, just uml-devel :-(
We really should merge these lists. ;-\
> As a quick fix you can try this:
>
> diff --git a/arch/x86/um/os-Linux/registers.c b/arch/x86/um/os-Linux/registers.c
> index 00f54a91bb4b..6eac8220ab29 100644
> --- a/arch/x86/um/os-Linux/registers.c
> +++ b/arch/x86/um/os-Linux/registers.c
> @@ -30,7 +30,7 @@ int save_fp_registers(int pid, unsigned long *fp_regs)
>
> if (have_xstate_support) {
> iov.iov_base = fp_regs;
> - iov.iov_len = sizeof(struct _xstate);
> + iov.iov_len = HOST_FP_SIZE * sizeof(unsigned long);
> if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
> return -errno;
> return 0;
> @@ -49,10 +49,9 @@ int restore_i387_registers(int pid, unsigned long *fp_regs)
> int restore_fp_registers(int pid, unsigned long *fp_regs)
> {
> struct iovec iov;
> -
> if (have_xstate_support) {
> iov.iov_base = fp_regs;
> - iov.iov_len = sizeof(struct _xstate);
> + iov.iov_len = HOST_FP_SIZE * sizeof(unsigned long);
> if (ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
> return -errno;
> return 0;
> @@ -126,7 +125,7 @@ void arch_init_registers(int pid)
> struct iovec iov;
>
> iov.iov_base = &fp_regs;
> - iov.iov_len = sizeof(struct _xstate);
> + iov.iov_len = HOST_FP_SIZE * sizeof(unsigned long);
> if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) == 0)
> have_xstate_support = 1;
> }
> diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c
> index cb3c22370cf5..9dccbbbf2fd1 100644
> --- a/arch/x86/um/user-offsets.c
> +++ b/arch/x86/um/user-offsets.c
> @@ -50,7 +50,7 @@ void foo(void)
> DEFINE(HOST_GS, GS);
> DEFINE(HOST_ORIG_AX, ORIG_EAX);
> #else
> - DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
> + DEFINE_LONGS(HOST_FP_SIZE, 2688);
> DEFINE_LONGS(HOST_BX, RBX);
> DEFINE_LONGS(HOST_CX, RCX);
> DEFINE_LONGS(HOST_DI, RDI);
>
>
> a better fix would be to make the fp regs in struct uml_pt_regs dynamic
> depending on the current kernel idea of the xsave area size.
And we should consider a mechanism to save/restore the full regset only when needed.
Otherwise the context switch is even more slower.
Thanks,
//richard
|