Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752732AbeADSi3 (ORCPT + 1 other); Thu, 4 Jan 2018 13:38:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39724 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752011AbeADSi2 (ORCPT ); Thu, 4 Jan 2018 13:38:28 -0500 Date: Thu, 4 Jan 2018 19:38:26 +0100 From: Andrea Arcangeli To: Borislav Petkov Cc: Tim Chen , Thomas Gleixner , Andy Lutomirski , Linus Torvalds , Greg KH , Dave Hansen , Andi Kleen , Arjan Van De Ven , linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/7] x86/spec_ctrl: Add sysctl knobs to enable/disable SPEC_CTRL feature Message-ID: <20180104183826.GL13348@redhat.com> References: <4d4b3752e8e533201c6983d8473eea95c747ea33.1515086770.git.tim.c.chen@linux.intel.com> <20180104183345.od2o4hsfu2tv6nc4@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180104183345.od2o4hsfu2tv6nc4@pd.tnic> User-Agent: Mutt/1.9.2 (2017-12-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 04 Jan 2018 18:38:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Jan 04, 2018 at 07:33:45PM +0100, Borislav Petkov wrote: > On Thu, Jan 04, 2018 at 09:56:47AM -0800, Tim Chen wrote: > > There are 2 ways to control IBRS > > > > 1. At boot time > > noibrs kernel boot parameter will disable IBRS usage > > > > Otherwise if the above parameters are not specified, the system > > will enable ibrs and ibpb usage if the cpu supports it. > > > > 2. At run time > > echo 0 > /sys/kernel/debug/ibrs_enabled will turn off IBRS > > echo 1 > /sys/kernel/debug/ibrs_enabled will turn on IBRS in kernel > > echo 2 > /sys/kernel/debug/ibrs_enabled will turn on IBRS in both userspace and kernel > > I am not sure that tristate is really needed. What's wrong with on/off > only? well, tristate is to provide a new feature (which is also incidentally the mode new silicon will prefer to run). > Also, stuff like that: > > +/* mutex to serialize IBRS control changes */ > +DEFINE_MUTEX(spec_ctrl_mutex); > +EXPORT_SYMBOL(spec_ctrl_mutex); > > looks ugly. Consolidating in arch/x86/kernel/spec_ctrl.c would allow removing that export. Here I've got: static DEFINE_MUTEX(spec_ctrl_mutex); > Wrapper functions which everything calls and they hide internals are > much more preferrable. Agreed. > And then, if at all, this needs to be connected to the retpolines fun, > methinks, so that it can be decided at boot what to use. Turning this off at any time is very easy, making reptoline runtime disabled is more difficult. Thanks, Andrea