From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 1A6D16B0006 for ; Sat, 20 Oct 2018 19:53:00 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id d63-v6so27478044pld.18 for ; Sat, 20 Oct 2018 16:53:00 -0700 (PDT) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-oln040092070081.outbound.protection.outlook.com. [40.92.70.81]) by mx.google.com with ESMTPS id q10-v6si31463843pli.202.2018.10.20.16.52.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 20 Oct 2018 16:52:58 -0700 (PDT) From: Shayan Doust Subject: [PATCH 06/10] x86/entry/32: Clear the CS high bits Date: Sat, 20 Oct 2018 23:52:54 +0000 Message-ID: References: <20181020235230.37324-1-shayan.doust@outlook.com> In-Reply-To: <20181020235230.37324-1-shayan.doust@outlook.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: owner-linux-mm@kvack.org List-ID: To: "hello@shayandoust.me" Cc: Jan Kiszka , Borislav Petkov , "H. Peter Anvin" , Andrea Arcangeli , Andy Lutomirski , Boris Ostrovsky , Brian Gerst , Dave Hansen , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Ingo Molnar , Jiri Kosina , Josh Poimboeuf , Juergen Gross , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Will Deacon , "aliguori@amazon.com" , "daniel.gruss@iaik.tugraz.at" , "hughd@google.com" , "keescook@google.com" , linux-mm , x86-ml From: Jan Kiszka Even if not on an entry stack, the CS's high bits must be initialized because they are unconditionally evaluated in PARANOID_EXIT_TO_KERNEL_MODE. Failing to do so broke the boot on Galileo Gen2 and IOT2000 boards. [ bp: Make the commit message tone passive and impartial. ] Fixes: b92a165df17e ("x86/entry/32: Handle Entry from Kernel-Mode on Entry-= Stack") Signed-off-by: Jan Kiszka Signed-off-by: Borislav Petkov Reviewed-by: Joerg Roedel Acked-by: Joerg Roedel CC: "H. Peter Anvin" CC: Andrea Arcangeli CC: Andy Lutomirski CC: Boris Ostrovsky CC: Brian Gerst CC: Dave Hansen CC: David Laight CC: Denys Vlasenko CC: Eduardo Valentin CC: Greg KH CC: Ingo Molnar CC: Jiri Kosina CC: Josh Poimboeuf CC: Juergen Gross CC: Linus Torvalds CC: Peter Zijlstra CC: Thomas Gleixner CC: Will Deacon CC: aliguori@amazon.com CC: daniel.gruss@iaik.tugraz.at CC: hughd@google.com CC: keescook@google.com CC: linux-mm CC: x86-ml Link: http://lkml.kernel.org/r/f271c747-1714-5a5b-a71f-ae189a093b8d@siemens= .com Signed-off-by: Ingo Molnar --- arch/x86/entry/entry_32.S | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 2767c625a52c..fbbf1ba57ec6 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -389,6 +389,13 @@ * that register for the time this macro runs */ =20 + /* + * The high bits of the CS dword (__csh) are used for + * CS_FROM_ENTRY_STACK and CS_FROM_USER_CR3. Clear them in case + * hardware didn't do this for us. + */ + andl $(0x0000ffff), PT_CS(%esp) + /* Are we on the entry stack? Bail out if not! */ movl PER_CPU_VAR(cpu_entry_area), %ecx addl $CPU_ENTRY_AREA_entry_stack + SIZEOF_entry_stack, %ecx @@ -407,12 +414,6 @@ /* Load top of task-stack into %edi */ movl TSS_entry2task_stack(%edi), %edi =20 - /* - * Clear unused upper bits of the dword containing the word-sized CS - * slot in pt_regs in case hardware didn't clear it for us. - */ - andl $(0x0000ffff), PT_CS(%esp) - /* Special case - entry from kernel mode via entry stack */ #ifdef CONFIG_VM86 movl PT_EFLAGS(%esp), %ecx # mix EFLAGS and CS --=20 2.17.1