Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752905AbeAFSUa (ORCPT + 1 other); Sat, 6 Jan 2018 13:20:30 -0500 Received: from mga14.intel.com ([192.55.52.115]:20218 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750849AbeAFSU1 (ORCPT ); Sat, 6 Jan 2018 13:20:27 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,322,1511856000"; d="scan'208";a="164703037" Subject: Re: [PATCH v2 4/8] x86/spec_ctrl: Add sysctl knobs to enable/disable SPEC_CTRL feature To: Konrad Rzeszutek Wilk Cc: Thomas Gleixner , Andy Lutomirski , Linus Torvalds , Greg KH , Dave Hansen , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , David Woodhouse , linux-kernel@vger.kernel.org References: <20180106144110.GA2592@localhost.localdomain> From: Tim Chen Message-ID: Date: Sat, 6 Jan 2018 10:20:26 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20180106144110.GA2592@localhost.localdomain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 01/06/2018 06:41 AM, Konrad Rzeszutek Wilk wrote: > On Fri, Jan 05, 2018 at 06:12:19PM -0800, Tim Chen wrote: >> From: Tim Chen >> From: Andrea Arcangeli >> > >> >> .macro DISABLE_IBRS >> - ALTERNATIVE "jmp .Lskip_\@", "", X86_FEATURE_SPEC_CTRL >> + testl $1, dynamic_ibrs > > On every system call we end up hammering on this 'dynamic_ibrs' > variable. And it looks like it can be flipped via the IPI mechanism. On system call, we read dynamic_ibrs value (not change it) and flip the IBRS msr only if it dynamic_ibrs is true. We only do global change to all the IBRS msrs on all cpus during the admin request to change its value, serialized by spec_ctrl_mutex. Before we do that, we set dynamic_ibrs to 0, so each cpu no longer do any change to IBRS. Then the IPI happens to update the IBRS MSR values. > > Would it make sense for this to be per-cpu? >