From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757791AbbDVSpI (ORCPT ); Wed, 22 Apr 2015 14:45:08 -0400 Received: from mga11.intel.com ([192.55.52.93]:17155 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757745AbbDVSpG (ORCPT ); Wed, 22 Apr 2015 14:45:06 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,625,1422950400"; d="scan'208";a="560194593" Message-ID: <5537EC31.7080808@intel.com> Date: Wed, 22 Apr 2015 11:45:05 -0700 From: Dave Hansen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Fenghua Yu , "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , Asit K Mallick , Glenn Williamson CC: linux-kernel , x86 Subject: Re: [PATCH Bugfix v2 2/4] x86/xsaves: Define and use user_xstate_size for xstate size in signal context References: <1429678319-61356-1-git-send-email-fenghua.yu@intel.com> <1429678319-61356-3-git-send-email-fenghua.yu@intel.com> In-Reply-To: <1429678319-61356-3-git-send-email-fenghua.yu@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/21/2015 09:51 PM, Fenghua Yu wrote: > + /* > + * Copy rest of xstates in compact format to user. > + */ > + for (i = 2; i < xstate_features; i++) { > + if (test_bit(i, (unsigned long *)&pcntxt_mask)) { > + int user_offset, kernel_offset; > + int size; > + > + user_offset = xstate_offsets[i]; > + kernel_offset = xstate_comp_offsets[i]; > + size = xstate_sizes[i]; > + > + if (__copy_to_user(buf_fx + user_offset, > + xsave + kernel_offset, size)) > + return -1; > + } > + } Is this checking the right bitmap? The 'xsaves' documentation says: "If RFBM[i] = 1, XSTATE_BV[i] is set to the value of XINUSE[i]". Where "XINUSE denotes the state-component bitmap corresponding to the init optimization". So shouldn't this be checking xsave->xsave_hdr.xstate_bv instead of pcntxt_mask? The will be equal unless the "init optimization" is in play.