Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751839AbdFTSR6 (ORCPT ); Tue, 20 Jun 2017 14:17:58 -0400 Received: from b.ns.miles-group.at ([95.130.255.144]:44724 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750823AbdFTSR4 (ORCPT ); Tue, 20 Jun 2017 14:17:56 -0400 Subject: Re: um: PTRACE_SETREGSET failure with XSTATE on Kabylake CPU To: Yu-cheng Yu Cc: Thomas Meyer , elicooper@gmx.com, linux-kernel@vger.kernel.org, "open list:USER-MODE LINUX (UML)" , linux-x86_64@vger.kernel.org, Dave Hansen , Ingo Molnar 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> From: Richard Weinberger Message-ID: <4d431238-28c7-3680-42f2-f7cf32acbc86@nod.at> Date: Tue, 20 Jun 2017 20:17:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <1497981874.22112.20.camel@test-lenovo> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 842 Lines: 28 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? > > 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. So, this code is not supposed to work? iov.iov_base = fp_regs; iov.iov_len = sizeof(struct _xstate); ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov); ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov); This is what UML does and on Thomas's new Laptop PTRACE_SETREGSET is failing. Thanks, //richard