From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: ARC-Seal: i=1; a=rsa-sha256; t=1517061547; cv=none; d=google.com; s=arc-20160816; b=UVOAp1ETl7ZoekZITxOimQDJvXbszYzxRedDOv9Q1Sv8DOr0V2DgBoBkN3V4VyVb5A v8k9FVees0U27WCW7J6GKU/SC6p0KzR5aiNGHPxLfVCBUEA44XIr9sfPcksW3fsgG0cG Qfm1TWXF5d7m1wX34U5+iQDfY4zg1VDhw4vjNNspJZ8qebV+hRTBLc6FRtpWBUNRBA/N RfdfOM3+BtXnFjWljAyMq9TYnu+/9bMgG2/DKUM3rWg1aU0YAd79/3bP44V60HMffw7N Qccdn5joksVdWG4KWummDt03sFH2iWTmdLLZuiBX/SlBL7zSuNV7QQzog9cVpJBcRYI1 HKBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:sender:dkim-signature :arc-authentication-results; bh=EMz1V4jr42k9zzPsSwbyAq1PJKLk8nVS1YjwHaO9Op8=; b=fAlUo/LhPSp3CY0KgK4I0JlDbwPtQ5mWKMbmRRnpBGVo/LDbpHy+vztZ6bORM/QheI mlT7Ur/CDlTj4pvDDaCuGJ0XVkcvW4jokqoAxg2P8kWz6szOg6joPlF+AEGwwA53bgDp nrQaPXhuTuBHVqjOO+bLGyLeQddZvQ122rGneXCIECVYVf5tm8bn4gOBJjXip5avON8K HhHdO/jEEVOs3jPx0OEHw3WRYCQevuFoBiSNNSbhtL0oiLcZJcZYlYNtgea0pUnxmV2N pNJLFSLkN4kObpcvqiPISRcgOPYPhs90ADhurLSvPEE0VTQCj+rXvaBewuuo/zeigZnm lRKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Rqb7sro9; spf=pass (google.com: domain of konrad.r.wilk@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=konrad.r.wilk@gmail.com Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Rqb7sro9; spf=pass (google.com: domain of konrad.r.wilk@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=konrad.r.wilk@gmail.com X-Google-Smtp-Source: AH8x2279PYhUxQ+9K+PL4blL5pPfrproFx2Ub6aKXqm9jUTlyW577VyTIEYxBfT8WjCjAqtjDZNPaA== Sender: Konrad Rzeszutek Wilk Date: Sat, 27 Jan 2018 08:59:02 -0500 From: Konrad Rzeszutek Wilk To: Peter Zijlstra Cc: Dave Hansen , Tim Chen , Thomas Gleixner , Andy Lutomirski , Linus Torvalds , Greg KH , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , David Woodhouse , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4/8] x86/spec_ctrl: Add sysctl knobs to enable/disable SPEC_CTRL feature Message-ID: <20180127135859.GA25291@localhost.localdomain> References: <20180108124707.GH32035@hirez.programming.kicks-ass.net> <20180108161437.GN32035@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180108161437.GN32035@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.1 (2017-09-22) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1588686894511228771?= X-GMAIL-MSGID: =?utf-8?q?1590754328883295093?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Mon, Jan 08, 2018 at 05:14:37PM +0100, Peter Zijlstra wrote: > On Mon, Jan 08, 2018 at 01:47:07PM +0100, Peter Zijlstra wrote: > > > a good suggestion, but we encountered some issues with it either > > > crashing the kernel at boot or not properly turning on/off. > > The below boots, but I lack stuff to test the enabling. ..snip.. > --- a/arch/x86/entry/calling.h > +++ b/arch/x86/entry/calling.h > @@ -373,22 +373,17 @@ For 32-bit we have the following convent > .endm > > .macro ENABLE_IBRS > - testl $1, dynamic_ibrs > - jz .Lskip_\@ > + STATIC_JUMP_IF_FALSE .Lskip_\@, ibrs_key, def=0 > > PUSH_MSR_REGS > WRMSR_ASM $MSR_IA32_SPEC_CTRL, $SPEC_CTRL_FEATURE_ENABLE_IBRS > POP_MSR_REGS > - jmp .Ldone_\@ > > .Lskip_\@: > - lfence > -.Ldone_\@: > .endm I know that this particular patchset is now obsolete as the retpoline along with stuffing the RSB half or full is the preferred way. But I am wondering - why was the 'lfence' added in the first place if dynamic_ibrs was zero? It certainly is not putting the speculative execution on a wild ride like: "[tip:x86/pti] x86/retpoline: Use LFENCE instead of PAUSE in the retpoline/RSB filling RSB macros" https://git.kernel.org/tip/2eb9137c8744f9adf1670e9aa52850948a30112b So what was the intent behind this? Was it: "oh if we do not have IBRS let us at least add lfence on every system call, interrupt, nmi, exception, etc to do a poor man version of IBRS?" Thank you. P.S. My apologies if this was discussed in the prior versions of this thread. I must have missed it.