From patchwork Mon Oct 15 14:09:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 10641921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9D9713AD for ; Mon, 15 Oct 2018 14:10:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF67B29953 for ; Mon, 15 Oct 2018 14:10:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF4A729A27; Mon, 15 Oct 2018 14:10:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55C2E29953 for ; Mon, 15 Oct 2018 14:10:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24C456B0005; Mon, 15 Oct 2018 10:10:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1FCEE6B000A; Mon, 15 Oct 2018 10:10:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EC4F6B000C; Mon, 15 Oct 2018 10:10:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by kanga.kvack.org (Postfix) with ESMTP id A75BA6B0005 for ; Mon, 15 Oct 2018 10:10:15 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id 189-v6so12775957wme.0 for ; Mon, 15 Oct 2018 07:10:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=pIW/Q5wWC0X7Te0S7YmXVq5ZEKU/FAXxAURc8Gn22uA=; b=BD34Ryc9S+RVnaAApekPcLZnQT53Sn4zECYvkGRB33nJh7Vndrbd2nfUlVJ/nWnGFe LY3yESdcSKMGlsLpBpe5HQAiCiPGuPgITW+pXEMCNeflJlqSaFuBpamdR0J+kL5uZdeB VoL7BmObjC8WTThp7Al8pqGxTru/cCr9KXc1/nu7wK3MYlCMoMddQZ9wU9hmwGtf5kYn zIcaTgrmMetXwyYydHQRwY4iCoYqUwsXnGgX2jSnnLgK5n3GFE+Svg/t9FzChdQiSdk4 cA4EGUlWWSTZbcE3mQB5ExTx1gXnd1cYOYM3ZMxtpz7Kue8hxQpkt5AraiYmKsrw3A1K feDw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com X-Gm-Message-State: ABuFfohKou7AHr2cNbEUYzp0ksEQvovpQyihBXGS/mGhJDaL6dWp8Juu 53R6hCmMijt4phX30yCD0JyHBRRlnulHRaJuShyzRDnw03N/82wpqJEEJNglJW/lIvhRftZxaJm sb9y8W2dFbEhUwpUkIwS3BRFRxYT2LmsGRQa+0nVPemPuNxZPC8MWVMmpZGZWV1uduw== X-Received: by 2002:a1c:a90:: with SMTP id 138-v6mr13854018wmk.49.1539612615211; Mon, 15 Oct 2018 07:10:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV63hwmF/hq9h3Yrh93gCTY1aNTQCYjESLlQfdflsesJ0S/TKXQ13JWcjQy2mRq2OwBNCbKS0 X-Received: by 2002:a1c:a90:: with SMTP id 138-v6mr13853961wmk.49.1539612614263; Mon, 15 Oct 2018 07:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539612614; cv=none; d=google.com; s=arc-20160816; b=xDqyLRGfbztAKeErLyT79gKjTCt11ggbZxnyf8J2Cjj3h+/cWbiaCB07E9dM7kkMZD C+ekoPQCOMKIhH9xhpZSTAl3YnBso2Y4+HSvmKFKZE34HzO4tyI2A1Y8/02dKIerfS60 aL3FHZ0jEZLMfUtxForcOyOm5zxsSjXauAormNfyheY7DOPtaOyZUx9MPBOiuyWY5Xyz FwA+27rQ/8SZ6SSqCMuRIk+DphponWeCPAGAiCBNXF/gVilq1CG2lIjbmnwoFfhGLctZ fQFloRm0/g6TfVcPUcQTFY2GFAj28VNRr6+cXxTKtNruXB5jQ0jfB9rfrnqebAwKG/Lb iOLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject; bh=pIW/Q5wWC0X7Te0S7YmXVq5ZEKU/FAXxAURc8Gn22uA=; b=E9qVmMJDedA/BV+eG1ZOBf38/oVAixvzMr3q9E//pQaMMtjY6e90PcJsU8ymKutuIh RhddU3Kz4yD41xbE1l77Y10tD7ibI7yOw+ATzO3jL6FFNiSgsijsh7wHgIvUicVoQLAF vEoqLQhA9LpsVKUVnWuyVC7cq3t+SvYrYevPhlm0WN/Jba79g1fMEQ1avZvjwUl5NBJt RTaf6hAyGHOrIDyiDU/JGTuo01Y0FsG+Rcx2XAdJqKzTyeDnthva0GGAfRRJ12DBVYPx ujdOYvQCBJAVKmfLZxzDL0ptEkJagf2qxfQ8AqYVmDE+F/P+f1cOy5+07qcXSApwjVmr 4A3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by mx.google.com with ESMTPS id i131-v6si7640324wma.86.2018.10.15.07.10.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 07:10:14 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id w9FE9Vlt021258 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 16:09:31 +0200 Received: from [139.25.68.37] (md1q0hnc.ad001.siemens.net [139.25.68.37] (may be forged)) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id w9FE9U3m007075; Mon, 15 Oct 2018 16:09:30 +0200 Subject: [PATCH v2] x86/entry/32: Fix setup of CS high bits From: Jan Kiszka To: Joerg Roedel , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli References: <1531906876-13451-1-git-send-email-joro@8bytes.org> <1531906876-13451-11-git-send-email-joro@8bytes.org> <97421241-2bc4-c3f1-4128-95b3e8a230d1@siemens.com> <35a24feb-5970-aa03-acbf-53428a159ace@web.de> Message-ID: Date: Mon, 15 Oct 2018 16:09:29 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: <35a24feb-5970-aa03-acbf-53428a159ace@web.de> Content-Language: en-US X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Even if we are not on an entry stack, we have to initialize the CS high bits because we are unconditionally evaluating them PARANOID_EXIT_TO_KERNEL_MODE. Failing to do so broke the boot on Galileo Gen2 and IOT2000 boards. Fixes: b92a165df17e ("x86/entry/32: Handle Entry from Kernel-Mode on Entry-Stack") Signed-off-by: Jan Kiszka Acked-by: Joerg Roedel Reviewed-by: Joerg Roedel --- Changes in v2: - adjust comment according to Andy's feedback - added Jörg's ack/review (assuming the comment change does not affect it) 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