Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1543961imm; Wed, 17 Oct 2018 23:23:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV60kUNzoFUdviD9veZ/kNMNqISy/LIwX9yC4HkniEFADE4Ri1qFyVUUa7FFcRCTsGVuLi+OY X-Received: by 2002:a63:e442:: with SMTP id i2-v6mr27526502pgk.381.1539843789371; Wed, 17 Oct 2018 23:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539843789; cv=none; d=google.com; s=arc-20160816; b=Y0dQOmBb3jnJOV2QQGFuGFAao/l4rt5xmH+p9z2FglFbA2ogf8FUde2/lyKmbuDtxq 2bxT7rf/XeWHrhltSZxkeWFZb8WpTGsIcsNMNccuBSHKwwusIbXKhpE1a2Z89MOPcdNm B1hlzH6bqsQZW1zgY7/vXrrmMrqiaRJZ0WMM/Fghr1REfoAnBOD70LBdFEf8TeuBPeq6 fvMBMPXzc4knbb0f2OV7RxGzzc3FzMvNMjR+2Pdy5LxGJHjXO1HQJGxl7mrLN4r4eQM6 0LK2b3FiXfQjwFHe/yyeeFr/5ZR9KPsl98ga2BVsPLCubPfCqPSfu0xUKNRTucOIoyWh +gvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=sfkTTHzyhvJ7vbTjK3w1jOXaEalk2E698o4QsMDSjq4=; b=qxvll07PRsEqaU+LFbL8u8wxdm40mO1Bbr+Qj+wRobg2tWSM/Fob9kUXzjJjvMmTPK IBMo2gHLWJ4N2yG8/fIKIdjHH4HiOZ53szovgKpLrhKhExkGDslcot7zoVuR2cl5LyxN phS5lv9sovSuFvOm+1T5qgFn42SrwTM4Zxqat8SoCj9YylGU0rDarpomM9X6s316uyJE C7Dcrjig9JTmbUWgfXL0lNx4Y+62irUSKTrUBZIZwGNLmADmaSmQTxKyB58EYeHBCjRV 6pJrmEZEuYJpn6ubzc9A0Pfaah3kmA4YsfrNuRxbbuoGbJZc5kCkL7XDp4igzdZT+jqP u2VQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn7si19103440plb.264.2018.10.17.23.22.53; Wed, 17 Oct 2018 23:23:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727503AbeJROVq (ORCPT + 99 others); Thu, 18 Oct 2018 10:21:46 -0400 Received: from terminus.zytor.com ([198.137.202.136]:33249 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727328AbeJROVp (ORCPT ); Thu, 18 Oct 2018 10:21:45 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w9I6LHoE708313 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 17 Oct 2018 23:21:17 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w9I6LFT7708302; Wed, 17 Oct 2018 23:21:15 -0700 Date: Wed, 17 Oct 2018 23:21:15 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jan Kiszka Message-ID: Cc: jkosina@suse.cz, jpoimboe@redhat.com, x86@kernel.org, jgross@suse.com, aarcange@redhat.com, linux-kernel@vger.kernel.org, jroedel@suse.de, gregkh@linuxfoundation.org, mingo@kernel.org, luto@kernel.org, boris.ostrovsky@oracle.com, linux-mm@kvack.org, torvalds@linux-foundation.org, dave.hansen@intel.com, jan.kiszka@siemens.com, eduval@amazon.com, hpa@zytor.com, dvlasenk@redhat.com, tglx@linutronix.de, brgerst@gmail.com, David.Laight@aculab.com, peterz@infradead.org, bp@suse.de, will.deacon@arm.com Reply-To: jgross@suse.com, jpoimboe@redhat.com, jkosina@suse.cz, x86@kernel.org, gregkh@linuxfoundation.org, luto@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org, aarcange@redhat.com, jroedel@suse.de, hpa@zytor.com, dvlasenk@redhat.com, boris.ostrovsky@oracle.com, torvalds@linux-foundation.org, linux-mm@kvack.org, dave.hansen@intel.com, jan.kiszka@siemens.com, eduval@amazon.com, bp@suse.de, will.deacon@arm.com, tglx@linutronix.de, David.Laight@aculab.com, brgerst@gmail.com, peterz@infradead.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/entry/32: Clear the CS high bits Git-Commit-ID: 04f4f954b69526d7af8ffb8e5780f08b8a6cda2d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,BAYES_00, FREEMAIL_FORGED_REPLYTO,T_DATE_IN_FUTURE_96_Q autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 04f4f954b69526d7af8ffb8e5780f08b8a6cda2d Gitweb: https://git.kernel.org/tip/04f4f954b69526d7af8ffb8e5780f08b8a6cda2d Author: Jan Kiszka AuthorDate: Mon, 15 Oct 2018 16:09:29 +0200 Committer: Ingo Molnar CommitDate: Wed, 17 Oct 2018 12:30:20 +0200 x86/entry/32: Clear the CS high bits 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 */ + /* + * 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 - /* - * 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