Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752166AbdFTUNs (ORCPT ); Tue, 20 Jun 2017 16:13:48 -0400 Received: from www17.your-server.de ([213.133.104.17]:47226 "EHLO www17.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751036AbdFTUNq (ORCPT ); Tue, 20 Jun 2017 16:13:46 -0400 References: <1497923806.7300.2.camel@m3y3r.de> <98803c66-4a36-a95f-5a1b-51a40de7a3e6@nod.at> <1497948550.7300.5.camel@m3y3r.de> <25066617-df15-6d21-713c-1ede1e953448@nod.at> <1497981874.22112.20.camel@test-lenovo> <4d431238-28c7-3680-42f2-f7cf32acbc86@nod.at> <2fc7383c-852a-be3c-f934-b125fe9bdba2@nod.at> <1497988398.22550.5.camel@test-lenovo> Mime-Version: 1.0 (1.0) In-Reply-To: <1497988398.22550.5.camel@test-lenovo> Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-2F10E768-2CC4-4FD2-8503-BCED45C7038E; protocol="application/pkcs7-signature" Content-Transfer-Encoding: 7bit Message-Id: Cc: Richard Weinberger , elicooper@gmx.com, linux-kernel@vger.kernel.org, "open list:USER-MODE LINUX (UML)" , linux-x86_64@vger.kernel.org, Dave Hansen , Ingo Molnar X-Mailer: iPhone Mail (13G36) From: Thomas Meyer Subject: Re: um: PTRACE_SETREGSET failure with XSTATE on Kabylake CPU Date: Tue, 20 Jun 2017 22:13:29 +0200 To: Yu-cheng Yu X-Authenticated-Sender: thomas@m3y3r.de Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9159 Lines: 163 --Apple-Mail-2F10E768-2CC4-4FD2-8503-BCED45C7038E Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable > Am 20.06.2017 um 21:53 schrieb Yu-cheng Yu : >=20 >> On Tue, 2017-06-20 at 20:59 +0200, Richard Weinberger wrote: >> Yu-cheng, >>=20 >>> Am 20.06.2017 um 20:17 schrieb Richard Weinberger: >>> Yu-cheng, >>>=20 >>> Am 20.06.2017 um 20:04 schrieb Yu-cheng Yu: >>>>>> So to summarize: >>>>>>=20 >>>>>> - PTRACE_GETREGSET with NT_X86_XSTATE gets 832 and return 832, with n= o >>>>>> error. >>>>>>=20 >>>>>> - PTRACE_SETREGSET get 832 (sizeof struct _xstate) but wants at least= >>>>>> 1088, otherwise it will fail with -EFAULT (why not -EINVAL?) >>>>>>=20 >>>>>> Ideas? >>>>=20 >>>> We considered allowing a partial XSAVE buffer for PTRACE_SETREGSET, but= >>>> it was that the XSAVE instruction requires a full-size buffer led to >>>> this choice. Using a smaller buffer for XSAVE causes a fault. >>>=20 >>> So, this code is not supposed to work? >>>=20 >>> iov.iov_base =3D fp_regs; >>> iov.iov_len =3D sizeof(struct _xstate); >>> ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov); >>> ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov); >>>=20 >>> This is what UML does and on Thomas's new Laptop PTRACE_SETREGSET is fai= ling. >>=20 >> Hmm, I think we need to do what gdb does, it uses a buffer of size X86_XS= TATE_MAX_SIZE. >=20 > Linux kernel determines XSAVE buffer size from CPUID: > http://elixir.free-electrons.com/linux/latest/source/arch/x86/kernel/fpu/x= state.c#L626 Hi, Is there a user space API to get this value? >=20 > GDB has a fixed X86_XSTATE_MAX_SIZE of 2688. That can become an issue. >=20 > Yu-cheng >=20 >=20 --Apple-Mail-2F10E768-2CC4-4FD2-8503-BCED45C7038E Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIR1TCCBYEw ggNpoAMCAQICCHH7MgS/+owXMA0GCSqGSIb3DQEBCwUAME4xJjAkBgNVBAMMHVZvbGtzdmVyc2No bHVlc3NlbHVuZyBSb290IENBMRcwF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