From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754512AbdKMTT2 (ORCPT ); Mon, 13 Nov 2017 14:19:28 -0500 Received: from mga07.intel.com ([134.134.136.100]:3183 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753127AbdKMTT1 (ORCPT ); Mon, 13 Nov 2017 14:19:27 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,389,1505804400"; d="scan'208";a="173070237" Subject: Re: [RFC 5/7] x86/asm: Rearrange struct cpu_tss to enlarge SYSENTER_stack and fix alignment To: Andy Lutomirski , X86 ML References: <2a675c72e35f737156c98ccad5cc3c73c3aa9d72.1510371795.git.luto@kernel.org> Cc: Borislav Petkov , "linux-kernel@vger.kernel.org" , Brian Gerst , Linus Torvalds From: Dave Hansen Message-ID: Date: Mon, 13 Nov 2017 11:19:25 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <2a675c72e35f737156c98ccad5cc3c73c3aa9d72.1510371795.git.luto@kernel.org> 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 On 11/10/2017 08:05 PM, Andy Lutomirski wrote: > struct tss_struct { > /* > + * Space for the temporary SYSENTER stack. Used for the entry > + * trampoline as well. Size it such that tss_struct ends up > + * as a multiple of PAGE_SIZE. This calculation assumes that > + * io_bitmap is a multiple of PAGE_SIZE (8192 bytes) plus one > + * long. > + */ > + unsigned long SYSENTER_stack_canary; > + unsigned long SYSENTER_stack[(PAGE_SIZE - sizeof(struct x86_hw_tss)) / sizeof(unsigned long) - 2]; > + > + /* > * The hardware state: > */ > struct x86_hw_tss x86_tss; > @@ -337,15 +347,9 @@ struct tss_struct { > * be within the limit. > */ > unsigned long io_bitmap[IO_BITMAP_LONGS + 1]; > - > - /* > - * Space for the temporary SYSENTER stack. > - */ > - unsigned long SYSENTER_stack_canary; > - unsigned long SYSENTER_stack[64]; > } ____cacheline_aligned; If io_bitmap[] is already page-size-aligned, how does it help us to move SYSENTER_stack[]? It seems like it would be easier to just leave SYSENTER_stack[] where it is, make it SYSENTER_stack[0], and just find somewhere else to choose how much to bloat the tss_struct *allocation* instead of trying to make sure that sizeof(tss_struct) matches the allocation. That SYSENTER_stack[] size calculation is pretty hideous. :)