From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756177AbcBVWxF (ORCPT ); Mon, 22 Feb 2016 17:53:05 -0500 Received: from mga03.intel.com ([134.134.136.65]:32084 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756008AbcBVWxD (ORCPT ); Mon, 22 Feb 2016 17:53:03 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,486,1449561600"; d="scan'208";a="918792363" Subject: Re: [PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES To: Andy Lutomirski , Yu-cheng Yu References: <1456167621-3974-1-git-send-email-yu-cheng.yu@intel.com> Cc: X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "linux-kernel@vger.kernel.org" , Andy Lutomirski , Borislav Petkov , Sai Praneeth Prakhya , "Ravi V. Shankar" , Fenghua Yu From: Dave Hansen Message-ID: <56CB914E.3040406@linux.intel.com> Date: Mon, 22 Feb 2016 14:53:02 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/22/2016 02:45 PM, Andy Lutomirski wrote: >> +/* >> > + * Convert from kernel XSAVES compacted format to standard format and copy >> > + * to a ptrace buffer. It supports partial copy but pos always starts from >> > + * zero. This is called from xstateregs_get() and there we check the cpu >> > + * has XSAVES. >> > + */ >> > +int copyout_from_xsaves(unsigned int pos, unsigned int count, void *kbuf, >> > + void __user *ubuf, const struct xregs_state *xsave) > Now that you've written this code, can it be shared with the signal > handling code? It could be. But the signal handler code has the advantage of already having the data in the registers since it's running on its *own* FPU state, so it can just call XSAVE(S) directly. This ptrace code *could* do a kernel_fpu_begin(), XRSTOR the user buffer into the registers, XRSTOR the ptracee's system state in to the registers, then XSAVES the whole thing to the kernel buffer, then kernel_fpu_end(). Or, we could remove the signal handler's ability to XSAVE directly to userspace. But it already *had* that and we know it works.