From patchwork Sat Oct 20 23:52:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shayan Doust X-Patchwork-Id: 10650703 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 1945C1750 for ; Sat, 20 Oct 2018 23:53:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA8F92868D for ; Sat, 20 Oct 2018 23:53:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7EB9286B6; Sat, 20 Oct 2018 23:53:03 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 470582868D for ; Sat, 20 Oct 2018 23:53:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82DB46B0006; Sat, 20 Oct 2018 19:53:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7B7C16B0007; Sat, 20 Oct 2018 19:53:00 -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 6314B6B0008; Sat, 20 Oct 2018 19:53:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org 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) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:thread-topic :thread-index:date:message-id:references:in-reply-to:accept-language :content-language:content-transfer-encoding:mime-version; bh=VWoYqiQofnZ7tOtNmUK0C2/Ziymy1lm1PJrbf7YSK94=; b=m8Sd457UcUidA5aznW+xVFkzKeV90/w9DbQilVBM+9IWG5dWBecnzBIg706HFSiytb ksUHo4E3ODlbiZV71TWXBFyIQPCDrRXjou+SolINfbEqTWyCMaFKUj5LYyhKqBkfmlFl tcJizWE157vMYxcZR+m4ZpTyMb/94XhzJPsJ6A+n9d4nzMYb5qHAMlWUnw8KrJSRpasp zJKOnjiZQhj3t7+2dngxKUs0M3C9DvTIH4T0IqWkLcO8IcxZELH3D/UTKBY6QLHzLXuE BiezoPK/pxn/EZES1kuw03268JNzZ8ucLMT/6qvNSzFsatRyQj7f+QUCyix4cJQxTwWZ xHhg== X-Gm-Message-State: ABuFfoj9pbPEYc7h1IikB+wEIgU3txrGXa+sG1vyTpeO12RSpwQ0wpRF HB0BcAPcNetNZdZQm/Sjqh0lQ7HHI2esRaCKwvR/Aw7pRsaRnHzwXBKriSSILa9s1b7G23YABvX U39HkGMv6wmw1MPrqb/J58XyrBSuPU2/3chFL7q7f0an/eZWqwVdcSv2Os6+4jx4lEA== X-Received: by 2002:a63:2019:: with SMTP id g25-v6mr37888918pgg.235.1540079579558; Sat, 20 Oct 2018 16:52:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV624WJ8c7dc87zt0HQN8taOSa0JnRLuQ4anMEJ5t7k9vZUWegrih+XjiL6E0YB6b+j73Viec X-Received: by 2002:a63:2019:: with SMTP id g25-v6mr37888884pgg.235.1540079578236; Sat, 20 Oct 2018 16:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540079578; cv=none; d=google.com; s=arc-20160816; b=QDFWmU9SXx5HGWRxlKTlAAj7iatsUb+Q7cUVycH+fDHsB2PgVYfOCGVT75CTAgi3no quwPC2PwE8/rfYqN098qGBmuMX7hhVRPZyW4+MgOYKJ74LfiA3lWCt58tlfuwUlUp8j7 QgTpEO7bqlCmKEuooytIqdU1wTbilyFDGge75v3tBp0v4pLeVUHO95JdHuECzOGsEHST td0aZSVQC8IdvvYp8dqFlGI2qM1wEI6m1mdqp0NRT8nXtAGhhqzY71ti1bmG94+lCznD 9cwYKwHyAvrj9pKiqZV1TPZzhzU649a5dRXphtzazn9jmePfJUQ0Hh7jhVD18wTxYvpQ GKhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=VWoYqiQofnZ7tOtNmUK0C2/Ziymy1lm1PJrbf7YSK94=; b=dHbZOqxql20+8s06w0sEIpQjeAwF233iKg8rGlIZRwRTgKmhiN0UVY1g8k45zkAF57 IirTiH3P/jU/cvKbeRhzWaBwWuFU/Do00ubIjLlf2j4yCFoSg2DC7RIiEmBauYuoXCNC QmxR3mC5NLBu3FkI9cMWPI8sxKgumkx3gE9FyQNNhoqYTjiYsQ3EvGcINeICP/6eo25w 4bfQsND2aSGORAHoPuy5BsWQpUlaYuB2niU8ykNR+mjkITYVslFQbXKmlJAH4Mh6wy1M cuXOmOrK4SqhyljnqODLSMTbKWzm0Ys0NlLkmT22mSvb8J3cFvqCeA2jyAQEiR8Xus6a ccVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b="BY/Hnms6"; spf=pass (google.com: domain of shayan.doust@outlook.com designates 40.92.70.81 as permitted sender) smtp.mailfrom=shayan.doust@outlook.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com 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) Received-SPF: pass (google.com: domain of shayan.doust@outlook.com designates 40.92.70.81 as permitted sender) client-ip=40.92.70.81; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b="BY/Hnms6"; spf=pass (google.com: domain of shayan.doust@outlook.com designates 40.92.70.81 as permitted sender) smtp.mailfrom=shayan.doust@outlook.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VWoYqiQofnZ7tOtNmUK0C2/Ziymy1lm1PJrbf7YSK94=; b=BY/Hnms6LcfcyW4erK0sDbLVA5YruYzeRchi0p2dTgwhpLeYkeVAyzRiE6qUuFVLD058rA1zrKfrgHmrI+fao8qAG4wcqwhUo7BqXEWCCt2lqv7osV7ZrhbJf72YIypk3+rkcsEAlNLY0fuDdL2XZ3AkHKCuJnEuAChLA0IuLKyh/cSJdKB/1GDucltAAFys2AXHkDZLZTK/xZmasqg3ak6SPm6+se+nuGJkeeiSAFctGdqXbr5mwWfIHMUX7/p+uGjkfrPd5Js5+cPAQ7XFVC58fXsRIHMVS+d7l1LXZAGSKqG4oxEgdB4juSLhfpfR+q0rvWdaDOgaDCpvIeLOSw== Received: from VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com (10.152.18.60) by VE1EUR03HT080.eop-EUR03.prod.protection.outlook.com (10.152.19.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.12; Sat, 20 Oct 2018 23:52:54 +0000 Received: from AM2PR08MB0195.eurprd08.prod.outlook.com (10.152.18.56) by VE1EUR03FT025.mail.protection.outlook.com (10.152.18.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.12 via Frontend Transport; Sat, 20 Oct 2018 23:52:54 +0000 Received: from AM2PR08MB0195.eurprd08.prod.outlook.com ([fe80::c038:463a:8fc8:570a]) by AM2PR08MB0195.eurprd08.prod.outlook.com ([fe80::c038:463a:8fc8:570a%10]) with mapi id 15.20.1228.035; Sat, 20 Oct 2018 23:52:54 +0000 From: Shayan Doust 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 Subject: [PATCH 06/10] x86/entry/32: Clear the CS high bits Thread-Topic: [PATCH 06/10] x86/entry/32: Clear the CS high bits Thread-Index: AQHUaNAEF5hNjUmv8USMVso17fh6wg== 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> Accept-Language: en-TT, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LNXP265CA0063.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::27) To AM2PR08MB0195.eurprd08.prod.outlook.com (2a01:111:e400:8431::20) x-incomingtopheadermarker: OriginalChecksum:5ACD2685DA57DF34BAB140E3F03209F71F7FFFC87C1FAB20CCDCA88D33D50966;UpperCasedChecksum:CE58848EF422EFAF97CC8256E5A3AF078A256E7173A8D506A4D458E5CA3C0778;SizeAsReceived:8495;Count:50 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [mzvlahL0NSnm6w9Dji73znQbStWx4vrGiWIGJ3yVurw=] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VE1EUR03HT080;6:wVs5fMiNiDKCYuWkFrU93XM9qjWmXU7K29RiMmu1oRZorhtV6cZn+Hyu/sptANZ5xANKrAZ9/W3+z6kB0VFpGy4b2kSbe8stZBq4VA/fA2BFGOg1EifHXfOsNkb6D8bcq79YBiAsK7Z1kNRvqUXavgZias0T81F8FCyL03ri+zx1vu2zXuMhoKHGbn3PfmIGQvCizWr35zADt29OU1tC+lR4splpC5MfzAWzF1O0IAv9Ji79thn1DQwIAlB0Pvm+VzDpGJu9H3mu+OUsBP8zBhykRxLo/h/HY31ZVJET1lG/PPxSeGFKUhNSm0Tz/yooX5KAsvf+7XteXlDe3HEWobB70r+NdB9dHejO2U6pbFrFKvMkrpMFKqdSb6neqOYWzi9goGjQ+Uhx5iFBFHQLsB6C8QU4om8zfXA4aOImmCHjkzurw2UuHQ+tUIiDf6x0lJSqJDAUjL+lOUrXJXejcQ==;5:2rEqodY3fizav+gxsuZP4sKAh0MG+sBkfkgJdRJFUUZM8rQ4ObDrUCIHMov/e52AdhPZxkNfrbxJzUCY/6Re1c37QGWiaqdIFLi5sLnGT5709QZgVsyRGo+W8he/+xKf1+V+rDWOJQr7zRqRNdnW3hH3joK5DeDYShu0amVo3q8=;7:TLB21HcXLTQ4lXiSqVFJwHd5DB0dGVoxGfdKM9hiwAbph3UoTIIR8SnlpdS8qU86MqArsKi/DsVXkzHORNdiD+4klm0RXHDE8IpWKt3vaz12Us1lkm0QkG/SmnZu/aPCdAM+TsXJE/EpfPMCwXnCx0s/w+MdnQAUItBkKiuWh2yihCVmFRBVJWp71ny2CMacA4nMSIoJ2FN/+aZpVmvP/Evns6dDiqyp8zaKwk1SgSiAUSRtGBY1yT4MO89TThOt x-incomingheadercount: 50 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1601125500)(1603101475)(1701031045);SRVR:VE1EUR03HT080; x-ms-traffictypediagnostic: VE1EUR03HT080: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(4566010)(82015058);SRVR:VE1EUR03HT080;BCL:0;PCL:0;RULEID:;SRVR:VE1EUR03HT080; x-microsoft-antispam-message-info: QFLShkZIBKHbGBV9XEE6Y2IKife2ytsHmITHNxPyDIISpbgtMoaPHgbpPu5P4+ak MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 074d7d4d-72e2-4a0a-9d89-73b16535e4cd X-MS-Exchange-CrossTenant-Network-Message-Id: 969b2d59-9553-419c-3888-08d636e7273e X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 074d7d4d-72e2-4a0a-9d89-73b16535e4cd X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Oct 2018 23:52:54.8542 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR03HT080 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 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 */ + /* + * 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