From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751116AbdAWPgX (ORCPT ); Mon, 23 Jan 2017 10:36:23 -0500 Received: from mga07.intel.com ([134.134.136.100]:3445 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750705AbdAWPgW (ORCPT ); Mon, 23 Jan 2017 10:36:22 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,274,1477983600"; d="scan'208";a="1116636855" Subject: Re: [tip:x86/urgent] x86/fpu: Set the xcomp_bv when we fake up a XSAVES area To: fenghua.yu@intel.com, dvlasenk@redhat.com, peterz@infradead.org, oleg@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, brgerst@gmail.com, yu-cheng.yu@intel.com, luto@kernel.org, bp@alien8.de, jpoimboe@redhat.com, haokexin@gmail.com, hpa@zytor.com, quentin.casasnovas@oracle.com, tglx@linutronix.de, torvalds@linux-foundation.org, riel@redhat.com, linux-tip-commits@vger.kernel.org References: <1485075023-30161-1-git-send-email-haokexin@gmail.com> From: Dave Hansen Message-ID: Date: Mon, 23 Jan 2017 07:36:20 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.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 01/23/2017 12:28 AM, tip-bot for Kevin Hao wrote: > x86/fpu: Set the xcomp_bv when we fake up a XSAVES area > > I got the following calltrace on a Apollo Lake SoC with 32-bit kernel: ... > --- a/arch/x86/kernel/fpu/xstate.c > +++ b/arch/x86/kernel/fpu/xstate.c > @@ -1070,6 +1070,7 @@ int copyin_to_xsaves(const void *kbuf, const void __user *ubuf, > * Add back in the features that came in from userspace: > */ > xsave->header.xfeatures |= xfeatures; > + xsave->header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT | xsave->header.xfeatures; > > return 0; > } First of all, thanks for finding this! As you found, the 32-bit XSAVES code is a bit light on testing. I don't doubt that we have a code path that was screwed up like this, but I don't think this is the right fix. The kernel xsave buffer should *ALWAYS* have the XCOMP_BV_COMPACTED_FORMAT bit set. It should have been set before the copyin and it should be set when it's finished. The best fix here would be not to paper over the issue in the copy function but find where it got clobbered, or where some initialization code failed to set it.