From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753252AbbH1QCz (ORCPT ); Fri, 28 Aug 2015 12:02:55 -0400 Received: from www.sr71.net ([198.145.64.142]:50210 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751693AbbH1QCx (ORCPT ); Fri, 28 Aug 2015 12:02:53 -0400 Message-ID: <55E0862B.1030907@sr71.net> Date: Fri, 28 Aug 2015 09:02:51 -0700 From: Dave Hansen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Ingo Molnar CC: dave.hansen@linux.intel.com, mingo@redhat.com, x86@kernel.org, bp@alien8.de, fenghua.yu@intel.com, tim.c.chen@linux.intel.com, linux-kernel@vger.kernel.org, Linus Torvalds Subject: Re: [PATCH 11/11] x86, fpu: check CPU-provided sizes against struct declarations References: <20150827171102.1BDF27E5@viggo.jf.intel.com> <20150827171111.0552D053@viggo.jf.intel.com> <20150828052500.GH25556@gmail.com> In-Reply-To: <20150828052500.GH25556@gmail.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 08/27/2015 10:25 PM, Ingo Molnar wrote: > * Dave Hansen wrote: >> @@ -447,6 +492,14 @@ static void do_extra_xstate_size_checks( >> paranoid_xstate_size += xfeature_size(i); >> } >> XSTATE_WARN_ON(paranoid_xstate_size != xstate_size); >> + /* >> + * Basically, make sure that XSTATE_RESERVE has forced >> + * xregs_state to be large enough. This is not fatal >> + * because we reserve a *lot* of extra room in the init >> + * task struct, but we should at least know we got it >> + * wrong. >> + */ >> + XSTATE_WARN_ON(xstate_size > sizeof(struct xregs_state)); > > So do we need to warn about this? arch_task_struct_size is already dynamic today. I'm unsure what _actually_ blew up, but I missed adding protection keys and AVX-512 to XSTATE_RESERVE and the kernel crashed the first time I did a non-init-state-PKRU XSAVE. > The only problem would be the init task, which is allocated statically - can we > fix that? We could theoretically make it dynamic, but I'm really not sure it's worth the trouble. I just removed the init_task=INIT_TASK() initialization to see what would happen and something blew up early (last I saw on the console was the "early console in setup code"). The current size of the non-XSAVE data in task_struct is ~2k. The xsave data is 800-something bytes, so say ~1k. Our init_task ends up being ~6k, 3k of which is wasted. On an AVX-512 CPU, that means 1k of waste. >>From how early things died, I'm going to go out on a limb and say that we'll need to bootmem alloc our new dynamic init_task and probably can't practically wait for the slab to show up. Bootmem can only do full pages, so our 6k can be trimmed to 4k. On an AVX-512 CPU, the 6k goes *up* to 8k. It doesn't look like a fun exercise for 2k of memory savings.