Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751861AbeAIIfw (ORCPT + 1 other); Tue, 9 Jan 2018 03:35:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35490 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750831AbeAIIfu (ORCPT ); Tue, 9 Jan 2018 03:35:50 -0500 Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest To: Liran Alon Cc: jmattson@google.com, bp@alien8.de, thomas.lendacky@amd.com, aliguori@amazon.com, linux-kernel@vger.kernel.org, dwmw2@infradead.org, kvm@vger.kernel.org References: <751eaab5-1cc1-4913-b3c7-379255140cd1@default> From: Paolo Bonzini Message-ID: <28c42666-4403-578b-a0c5-d9ccd111f028@redhat.com> Date: Tue, 9 Jan 2018 09:35:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <751eaab5-1cc1-4913-b3c7-379255140cd1@default> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 09 Jan 2018 08:35:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 09/01/2018 00:58, Liran Alon wrote: > > ----- pbonzini@redhat.com wrote: > >> ----- Original Message ----- >>> From: "David Woodhouse" >>> To: "Paolo Bonzini" , >> linux-kernel@vger.kernel.org, kvm@vger.kernel.org >>> Cc: jmattson@google.com, aliguori@amazon.com, "thomas lendacky" >> , bp@alien8.de >>> Sent: Monday, January 8, 2018 8:41:07 PM >>> Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and >> MSR_IA32_PRED_CMD down to the guest >>> >>> On Mon, 2018-01-08 at 19:08 +0100, Paolo Bonzini wrote: >>>> >>>> +       if (have_spec_ctrl && vmx->spec_ctrl != 0) >>>> +               wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); >>>> + >>> >>> I think this one probably *is* safe even without an 'else lfence', >>> which means that the CPU can speculate around it, but it wants a >>> comment explaining that someone has properly analysed it and saying >>> precisely why. >> >> This one is okay as long as there are no indirect jumps until >> vmresume. But the one on vmexit is only okay because right now >> it's *disabling* IBRS. Once IBRS is used by Linux, we'll need an >> lfence there. I'll add a comment. >> >> Paolo > > That is true but from what I understand, there is an indirect branch from this point until vmresume. > That indirect branch resides in atomic_switch_perf_msrs() immediately called after this WRMSR: > atomic_switch_perf_msrs() -> perf_guest_get_msrs() -> x86_pmu.guest_get_msrs(). Sure, it has to move later as pointed out by other reviewers. Paolo