From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: ACJfBova55o5xgW45LIcTQDv7zQfTYl1cWkBeZ8yeyO7BfPzvSo4sqnKb3JqayTvM35W8OZhkv4W ARC-Seal: i=1; a=rsa-sha256; t=1515399874; cv=none; d=google.com; s=arc-20160816; b=Nb5c8vEUMIyQXUZtHs/tA26P8zu5E5c9YCzKiZlPzN7KfgaMlNYVBnjPvpuxbS2SBQ TssEnPakFHRdv38brX7j7WftM2tNise/NNH4JKR4rcg5EtPO1V2Ou2HVJKbJv48v1FNU nHesMSnmRa4VfqvpWRRHPE2EdCU8iSRlkVdYP6YW89UGAx0J05DmvXqLvcodqkcrsdAf VX5Rqj+j1IAtea3WvMXSMZUWy84evvKP/h1g1rxnvQjQ4xiRXAmnbAhQinvESrxpFm/5 CXXfdC5odhV4bCdrJ+wVcptcRo0kryRfyeYwwIOObwXer3IRK7knCtS/lk6hhF9qh5IB yH6A== 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:dkim-signature :arc-authentication-results; bh=5AmhUUQN1215C6NpTPCYNqp67KG1Peg+nJ4X51aw/iA=; b=Rz2vaewYAPY4YmapaRuifp1Hnngbv8BxzNvUqHk4j7rqVZNcWHstWY0LCEqZ8H5YQk iI0RS6ZnmaOj6l3fknWlZdpbw2XJf2+jzADtoofEDRd8iGcxZMlBe5EUirZU/HAK9UqV VzmQAf5rXa5heZhrCKSIX5G0rUI2DIxoVWv0pNlcysDn9haRpHRv8JBkfCQXfZHR5Rvl 3K1bzYrbpYIUyMdU53IkQki4de1ZjdeXDWeAR+rsyQOnzyLHJ30pv65xs795081RXiHF 0VKIi49mJBC2bQo+uaTtDqTLv9YpIOBKHy+qc8c+jRMwSYTiUd2owH5wTsFv1gwgjUMc ZEkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=KSsq+yF4; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=peterz@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=KSsq+yF4; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=peterz@infradead.org Date: Mon, 8 Jan 2018 09:24:25 +0100 From: Peter Zijlstra To: Tim Chen Cc: Thomas Gleixner , Andy Lutomirski , Linus Torvalds , Greg KH , Dave Hansen , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , linux-kernel@vger.kernel.orgy Subject: Re: [PATCH 4/7] x86/idle: Disable IBRS entering idle and enable it on wakeup Message-ID: <20180108082425.GC3040@hirez.programming.kicks-ass.net> References: <50b92931dd3cd403d60e69533f5583bbdbbb88d0.1515086770.git.tim.c.chen@linux.intel.com> <20180104224731.GE32035@hirez.programming.kicks-ass.net> <0ebb1848-c3ab-f636-f6f9-67716e814915@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0ebb1848-c3ab-f636-f6f9-67716e814915@linux.intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1588686892568644513?= X-GMAIL-MSGID: =?utf-8?q?1589011939359712723?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Thu, Jan 04, 2018 at 03:22:09PM -0800, Tim Chen wrote: > >> +static inline void unprotected_speculation_end(void) > >> +{ > >> + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) > >> + __disable_indirect_speculation(); > >> + else > >> + /* > >> + * If we intended to disable indirect speculation > >> + * but come here due to mis-speculation, we need > >> + * to stop the mis-speculation with rmb. > >> + */ > >> + rmb(); > > > > Code is lacking {}, also the comment doesn't make sense. If we don't > > have the MSR, why are we doing an LFENCE? > > The reason for lfence is because we intend to put up IBRS and disable > speculation. But if the CPU mis-speculates into the else portion, > we could be speculating without IBRS. The lfence stop the mis-speculation. With static_cpu_has() there's nothing for the CPU to speculate wrongly. And you _really_ want to get rid of that lfence, because currently you pay that price even if you don't have to (!FEATURE_SPEC_CTRL). > > And why are these boot_cpu_has() and not static_cpu_has() ? > > > > It probably doesn't matter as we will be switching the check > to the spec_ctrl_ibrs a couple of patches later. Doesn't really matter does it, you can still use jump labels.