From: Thomas Meyer <thomas@m3y3r.de>
To: Natale Patriciello <natale.patriciello@gmail.com>,
Richard Weinberger <richard@nod.at>
Cc: "open list:USER-MODE LINUX (UML)"
<user-mode-linux-devel@lists.sourceforge.net>
Subject: Re: [uml-devel] um: PTRACE_SETREGSET failure with XSTATE on Kabylake CPU
Date: Wed, 21 Jun 2017 11:44:25 +0200 [thread overview]
Message-ID: <1498038265.26879.2.camel@m3y3r.de> (raw)
In-Reply-To: <CAAyZ8nrQiu3w_SyCBWLbjjbsb+_KwhFnHkK7hFMpB7UcDsBCsQ@mail.gmail.com>
Am Mittwoch, den 21.06.2017, 10:39 +0200 schrieb Natale Patriciello:
> 2017-06-20 22:13 GMT+02:00 Thomas Meyer <thomas@m3y3r.de>:
> >
> > > Am 20.06.2017 um 21:53 schrieb Yu-cheng Yu <yu-cheng.yu@intel.com
> > > >:
> > >
> > > > On Tue, 2017-06-20 at 20:59 +0200, Richard Weinberger wrote:
> > > > Yu-cheng,
> > > >
> > > > > Am 20.06.2017 um 20:17 schrieb Richard Weinberger:
> > > > > Yu-cheng,
> > > > >
> > > > > Am 20.06.2017 um 20:04 schrieb Yu-cheng Yu:
> > > > > > > > So to summarize:
> > > > > > > >
> > > > > > > > - PTRACE_GETREGSET with NT_X86_XSTATE gets 832 and
> > > > > > > > return 832, with no
> > > > > > > > error.
> > > > > > > >
> > > > > > > > - PTRACE_SETREGSET get 832 (sizeof struct _xstate) but
> > > > > > > > wants at least
> > > > > > > > 1088, otherwise it will fail with -EFAULT (why not
> > > > > > > > -EINVAL?)
> > > > > > > >
> > > > > > > > Ideas?
>
> [cut text and CC'ed persons]
>
> 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 :)
>
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 :-(
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.
>
> HTH,
> Nat
>
> [1] https://sourceforge.net/p/user-mode-linux/mailman/message/3566337
> 4/
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2017-06-21 9:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 1:56 um: PTRACE_SETREGSET failure with XSTATE on Kabylake CPU Thomas Meyer
2017-06-20 6:58 ` Richard Weinberger
2017-06-20 8:49 ` [uml-devel] " Thomas Meyer
2017-06-20 9:05 ` Richard Weinberger
2017-06-20 18:04 ` Yu-cheng Yu
2017-06-20 18:17 ` [uml-devel] " Richard Weinberger
2017-06-20 18:59 ` Richard Weinberger
2017-06-20 19:53 ` Yu-cheng Yu
2017-06-20 20:13 ` [uml-devel] " Thomas Meyer
2017-06-21 8:39 ` Natale Patriciello
2017-06-21 9:44 ` Thomas Meyer [this message]
2017-06-21 12:47 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1498038265.26879.2.camel@m3y3r.de \
--to=thomas@m3y3r.de \
--cc=natale.patriciello@gmail.com \
--cc=richard@nod.at \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox