Received: by 10.223.176.46 with SMTP id f43csp4356416wra; Tue, 23 Jan 2018 08:14:05 -0800 (PST) X-Google-Smtp-Source: AH8x224cPr8MCgXJyuIOyEtOQ3XFQaFJobWH8Owrnb4v3cCdY/P+HnhK+B3MAazSGujOXBdhW1Jy X-Received: by 10.107.180.146 with SMTP id d140mr4515477iof.166.1516724045228; Tue, 23 Jan 2018 08:14:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516724045; cv=none; d=google.com; s=arc-20160816; b=x7ECk0GzLQ7rC5MaLCWDKpoQrqu6TveiqbzllGLU1Xn+TKTDJsHyQ28QvC4uKUR9lM G8aViZhAeDdZVrhzNr0BXVBMBOYHj5x4+oQHmntkhn0xBe/z3tgc0PIXXt+j2R4FsZME TV1D0VIQg+lQntgWPUaIfl59/OW/LAtIOryquG6DFnbVLtXznQZxOtC1GSQIf4xWMwxv 8yiPeFVA36cqNW3jM24H27h5MCRfK336+62z+KwNeKMA6tg4xuXBduhpHCdgLUt0d1c/ ZhD4V8/REL3p+5xnGN86z1ZY8X210pfrXkiyd3iCapbRPuWUSRE8kLbwias3cse//ybg u3fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=C3EgWFFzzehnPJBo76QRVUP7YX8L5+W37EKr5OmcD0A=; b=Paap6aDdfmXJi8Yj7dkfaWaLtH4JF9wz2du+4UyAMVPeSPekNylKNGbB+nGs5e6CgA xhRt5Ru/hAIzI2SCOivMWLJu/Bii4RgkYGw1dK9isdoxwqfM3/tTLkXT65/Ywvrf4Pe+ KaLZQmrKvYDcJFcb3gCUjzBQZa/pRk+Mq0KmTx/I2tVkCx0zb5XIfN9fBsUr54esRIVE f7kpSFQXbu1LO1BMKf+PC6bkDNWTkJe//v0vAxXaJxCDqIJxm+bvwMYYb4uUc/GwIo5N AifKxZDOUFepzNoQKk1bgvqykKLJoo8YNQOhTzIvGWSOBF45/ORrkTeyJzYCv5DHOwlW mSEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=PImIkjtn; 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 l202si8288720ita.80.2018.01.23.08.13.51; Tue, 23 Jan 2018 08:14:05 -0800 (PST) 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; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=PImIkjtn; 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 S1751653AbeAWQNW (ORCPT + 99 others); Tue, 23 Jan 2018 11:13:22 -0500 Received: from mail-bl2nam02on0059.outbound.protection.outlook.com ([104.47.38.59]:49371 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750994AbeAWQNT (ORCPT ); Tue, 23 Jan 2018 11:13:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=C3EgWFFzzehnPJBo76QRVUP7YX8L5+W37EKr5OmcD0A=; b=PImIkjtnz6xFiuGnqICrEg0R29EIBa+zSi6xcVCKqrlfwKQ1gpHZ4i6iTZF19FZuQ453LuBIaobaEWU3ZoIT5o7oJqW4aTuXkwSkHbPm/5ESCEdwdJF7/A06vdDUonuQPXm3srdZlyggI+IkgrphhxeT5Yvx0Igg2C0DPN/hZ2I= Received: from [10.236.65.116] (165.204.78.1) by DM5PR12MB1146.namprd12.prod.outlook.com (10.168.236.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Tue, 23 Jan 2018 16:13:12 +0000 Subject: Re: [RFC 09/10] x86/enter: Create macros to restrict/unrestrict Indirect Branch Speculation To: Andy Lutomirski , KarimAllah Ahmed Cc: linux-kernel@vger.kernel.org, Andi Kleen , Andrea Arcangeli , Andy Lutomirski , Arjan van de Ven , Ashok Raj , Asit Mallick , Borislav Petkov , Dan Williams , Dave Hansen , David Woodhouse , Greg Kroah-Hartman , "H . Peter Anvin" , Ingo Molnar , Janakarajan Natarajan , Joerg Roedel , Jun Nakajima , Laura Abbott , Linus Torvalds , Masami Hiramatsu , Paolo Bonzini , Peter Zijlstra , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Tim Chen , kvm@vger.kernel.org, x86@kernel.org, Arjan Van De Ven References: <1516476182-5153-1-git-send-email-karahmed@amazon.de> <1516476182-5153-10-git-send-email-karahmed@amazon.de> <243BE571-AF73-44B3-8D17-193F9E07686A@amacapital.net> From: Tom Lendacky Message-ID: <4e01a7a9-29e4-adcc-3f53-550fb7f3d370@amd.com> Date: Tue, 23 Jan 2018 10:12:48 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <243BE571-AF73-44B3-8D17-193F9E07686A@amacapital.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CO1PR15CA0052.namprd15.prod.outlook.com (10.175.176.20) To DM5PR12MB1146.namprd12.prod.outlook.com (10.168.236.141) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 443fc1e6-7434-4e6a-0197-08d5627c3651 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(7193020);SRVR:DM5PR12MB1146; X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1146;3:jpAtwQjeHrSuLsZqalyyzAtx+B1AseMUdSBt/4tEVuQknbyxhYx+jZ6OcNp5NsMigypvgn525o6f0Pogc8REtP48pbQ9umiWEz8ixpmwnBt56rj6MK94p5uBk6DSpYj0AXvlqdYKdOpBUT4EXivodKhrGgXNZBR3Kf0h1/GYWEhO+ypSuhMMtYwvuB9QYdCjr2JBs2g/uWRxPeNr6cDWlLUQVWorTQUEBLDMAScMETeW63svUuw3fOWrSmmN+cg/;25:OpGXOFBQR0euwb7L4VhmQ8SfW0A4c6jy1KClwVZAjQMSs7cAFRA6JKAXsDL5ILIZjPWMTgnPnQuVCfvr3EzcC6XTlwZNUr1xUOEgi3Q17t9dg1a4mFMrT+v2nugOhUnwGRYCez1pxwA2LHWzWZTg0PynS7OZHzrzAU5DG0sfoNFncuM85jEt1Xvs5ThVR46zcmbeMP/zBYuP4o2X0ZuyE8Ow4u9xtnq5vMMdAkD5Mr9AdpqS5v+x21jWrGpbopmz/EO9H90fT3Zb64kmCK0xZSkBUABmsjGIRGBsgoCk4OFVrJPg/nexA8iqGcTiue++UuEV7qSN6DF0IwktI417SQ==;31:ssFtkicr8Lj4Ll49h5NnyptkmFT9mnkdSO3XZhhrJDwBumfF1R7y70cA62ZVLtA61MYVPJvHJ9ltrDaVIrz+vwDm1XNG7MxQcJ/1p22/AdNE6jgTFuR9gNkk9BOuljdVfII/4kimy9IPZ19CVOOyNJ5ywDvb2ztlOkHphgaWlW0cfpNXgdCK0ZfgN5PVkluC5am4txvvcvQr10gWSAIxrvApUxLBqzZXOvvoh4rU5JQ= X-MS-TrafficTypeDiagnostic: DM5PR12MB1146: X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1146;20:8zIYpnUuG4xwQvrCbjtk/sqKkGTr1OXPjzJwCFIs1bPBsCNyFbSH/4gmv8jIXzsFAN456TSgbPENBlyDGjHTijz47eJTcpUachjj2JuB+z0Cr4sDjalEPSjCFM0HVBltsryxWIPZmhCm29gVuLuxiOdFjqcVsQyet4dZKAXiJ6YNd510GMn76MO8pV5JDm/3kxRS5oCkblCobWR29/gMo2TwAePSlJdd+CbWTP+qWxgqQh2MspwjCxBc9sr6B9z35dxT6hzvmBX3BTC+pxZirEPAMD2nlFVUda1U7Zi5mPi4w0rR/AKZJ/JOQUJYqkZHdTDkXimWsLGwxPip74+sQHUnHBS1+5MYIUEJRv8VO80dfo7aL0sLPpbcTCfjuNJ2M8cTnt98eOQ6/AAMc6A51RF5pAZijEckXaigyQJR2HsI3sUALwgXhB4UsYmeUUMip+mlKM8JN6VU71riIMzXiQPrtjORkfSgkj8wPxfDq3cLzgQW+ZzmbzQmpyap1e2r;4:j3jug6QknJNwYGJNdUfMx2P9FC8ofW+T7zb0ve8yxRjzCv4jWLUlFywhg889m7g5B+Wq1MzEtII/SnZKUDISz0KyJMxLKi+LXhDX/NMsBwwRoB+Neir6uqMVlWKpRYTtdcpbPlzZFpXl/6pJv+3+iBYQ9ie4aqRJRJa/V0ZV/Fd3lssW+tfwF/fTCRFIAXQDHzp66YMyOPZVp7Yv8Od5xzJXkBkANzooINgp747WhFK2j2vB0foe0URdl4QTNOK22Bfo8wk4Y8rQ5K45qi/GxlsTn7LRDsPI4qJsa4+/71hbdhbR5pKHuwmUn0J1snwyao6slzd3EfHkDuMyjvCpOzEKJlauG0HxBI0Ib3h0U6bu4s/B0TIMHvX3Vkf1OGlP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42068640409301)(146755900322472)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231023)(2400081)(944501161)(6055026)(6041288)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR12MB1146;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:DM5PR12MB1146; X-Forefront-PRVS: 05610E64EE X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(366004)(39380400002)(376002)(39860400002)(396003)(346002)(54534003)(189003)(199004)(7736002)(6666003)(3260700006)(2950100002)(6246003)(65826007)(81166006)(81156014)(8676002)(105586002)(8936002)(68736007)(5660300001)(4326008)(305945005)(16576012)(316002)(58126008)(229853002)(25786009)(36756003)(83506002)(16526018)(31686004)(7416002)(110136005)(54906003)(2906002)(6116002)(3846002)(97736004)(106356001)(66066001)(77096007)(65806001)(65956001)(47776003)(478600001)(31696002)(72206003)(230700001)(26005)(64126003)(53936002)(966005)(86362001)(386003)(23676004)(2486003)(52146003)(52116002)(6306002)(6346003)(76176011)(50466002)(6486002)(90366009)(53546011);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB1146;H:[10.236.65.116];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjEyTUIxMTQ2OzIzOlB2dHBwdHpac01VdmRWTmlNcHA2RnFBVVhz?= =?utf-8?B?TGxMU2VWUXBOQitvSVYwZ0ZmVTdPNEZGMlNsV3c4SjBHZWRkK2xJbnhEdWRr?= =?utf-8?B?RmlYejE5MStMNngzYTkyYUFXVWkxd1ZrR1dYMXd5WFpNQ3dyKzJ1Y0JtMmhj?=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j5/z0dg9iGV0o3pjxz1ARbamjIJCFUO17 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1146;20:jIFvgWfEkl9KiERrsLpNUsvdz2NJVYDik3pvDtWNyG1cE2vUtF6f+frACzPIC4elZlv6suPYL8ShPbD84hHUpfFbXwGEjTUb/tjg6D9/azXcNeNIsemUGKxagtRManhXgKuqORuV/SrA8WLSADnYLe9koR2wt/NIakpRDEDPoHnx9/LQmPYNHYOH5flcgwBeilf/7VbM44HbWAKQbeB0bSKqP3KQVkkUKK/lsIcT+AfBGzSbIkZppvHEN2ag+TA/ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2018 16:13:12.4880 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 443fc1e6-7434-4e6a-0197-08d5627c3651 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1146 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/21/2018 1:14 PM, Andy Lutomirski wrote: > > >> On Jan 20, 2018, at 11:23 AM, KarimAllah Ahmed wrote: >> >> From: Tim Chen >> >> Create macros to control Indirect Branch Speculation. >> >> Name them so they reflect what they are actually doing. >> The macros are used to restrict and unrestrict the indirect branch speculation. >> They do not *disable* (or *enable*) indirect branch speculation. A trip back to >> user-space after *restricting* speculation would still affect the BTB. >> >> Quoting from a commit by Tim Chen: >> >> """ >> If IBRS is set, near returns and near indirect jumps/calls will not allow >> their predicted target address to be controlled by code that executed in a >> less privileged prediction mode *BEFORE* the IBRS mode was last written with >> a value of 1 or on another logical processor so long as all Return Stack >> Buffer (RSB) entries from the previous less privileged prediction mode are >> overwritten. >> >> Thus a near indirect jump/call/return may be affected by code in a less >> privileged prediction mode that executed *AFTER* IBRS mode was last written >> with a value of 1. >> """ >> >> [ tglx: Changed macro names and rewrote changelog ] >> [ karahmed: changed macro names *again* and rewrote changelog ] >> >> Signed-off-by: Tim Chen >> Signed-off-by: Thomas Gleixner >> Signed-off-by: KarimAllah Ahmed >> Cc: Andrea Arcangeli >> Cc: Andi Kleen >> Cc: Peter Zijlstra >> Cc: Greg KH >> Cc: Dave Hansen >> Cc: Andy Lutomirski >> Cc: Paolo Bonzini >> Cc: Dan Williams >> Cc: Arjan Van De Ven >> Cc: Linus Torvalds >> Cc: David Woodhouse >> Cc: Ashok Raj >> Link: https://lkml.kernel.org/r/3aab341725ee6a9aafd3141387453b45d788d61a.1515542293.git.tim.c.chen@linux.intel.com >> Signed-off-by: David Woodhouse >> --- >> arch/x86/entry/calling.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 73 insertions(+) >> >> diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h >> index 3f48f69..5aafb51 100644 >> --- a/arch/x86/entry/calling.h >> +++ b/arch/x86/entry/calling.h >> @@ -6,6 +6,8 @@ >> #include >> #include >> #include >> +#include >> +#include >> >> /* >> >> @@ -349,3 +351,74 @@ For 32-bit we have the following conventions - kernel is built with >> .Lafter_call_\@: >> #endif >> .endm >> + >> +/* >> + * IBRS related macros >> + */ >> +.macro PUSH_MSR_REGS >> + pushq %rax >> + pushq %rcx >> + pushq %rdx >> +.endm >> + >> +.macro POP_MSR_REGS >> + popq %rdx >> + popq %rcx >> + popq %rax >> +.endm >> + >> +.macro WRMSR_ASM msr_nr:req edx_val:req eax_val:req >> + movl \msr_nr, %ecx >> + movl \edx_val, %edx >> + movl \eax_val, %eax >> + wrmsr >> +.endm >> + >> +.macro RESTRICT_IB_SPEC >> + ALTERNATIVE "jmp .Lskip_\@", "", X86_FEATURE_IBRS >> + PUSH_MSR_REGS >> + WRMSR_ASM $MSR_IA32_SPEC_CTRL, $0, $SPEC_CTRL_IBRS >> + POP_MSR_REGS >> +.Lskip_\@: >> +.endm >> + >> +.macro UNRESTRICT_IB_SPEC >> + ALTERNATIVE "jmp .Lskip_\@", "", X86_FEATURE_IBRS >> + PUSH_MSR_REGS >> + WRMSR_ASM $MSR_IA32_SPEC_CTRL, $0, $0 > > I think you should be writing 2, not 0, since I'm reasonably confident that we want STIBP on. Can you explain why you're writing 0? Do we want to talk about STIBP in general? Should it be (yet another) boot option to enable or disable? If there is STIBP support without IBRS support, it could be a set and forget at boot time. Thanks, Tom > > Also, holy cow, there are so many macros here. > > And a meta question: why are there so many submitters of the same series? >