Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933493AbeAKKpa (ORCPT + 1 other); Thu, 11 Jan 2018 05:45:30 -0500 Received: from mail-ot0-f177.google.com ([74.125.82.177]:41912 "EHLO mail-ot0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933034AbeAKKp2 (ORCPT ); Thu, 11 Jan 2018 05:45:28 -0500 X-Google-Smtp-Source: ACJfBoum3S5AqjlIZFsY7AdLGTYre26cAfN8UF4Me1TseUz6Fk4gd0gDmCxjCRjSFo3TxGx9ITRxl35dnspEWGon9XY= MIME-Version: 1.0 In-Reply-To: <7d96bfb5-99c3-da31-0094-23097e3faec2@redhat.com> References: <20180109120311.27565-1-pbonzini@redhat.com> <20180109120311.27565-7-pbonzini@redhat.com> <20180109142242.GD18661@char.us.oracle.com> <7d96bfb5-99c3-da31-0094-23097e3faec2@redhat.com> From: Wanpeng Li Date: Thu, 11 Jan 2018 18:45:27 +0800 Message-ID: Subject: Re: [PATCH 6/8] kvm: svm: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to guest To: Paolo Bonzini Cc: Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org, kvm , Radim Krcmar , Liran Alon , Jim Mattson , Anthony Liguori , thomas.lendacky@amd.com, dwmw@amazon.co.uk, Borislav Petkov , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 2018-01-10 0:08 GMT+08:00 Paolo Bonzini : > Oops, I missed these. > > On 09/01/2018 15:22, Konrad Rzeszutek Wilk wrote: >>> + if (have_spec_ctrl) { >>> + rdmsrl(MSR_IA32_SPEC_CTRL, svm->spec_ctrl); >>> + if (svm->spec_ctrl != 0) >> Perhaps just : >> >> if (svm->spec_ctrl) ? >> >> And above too? > > These will become != SPEC_CTRL_ENABLE_IBRS or something like that. > >>> + wrmsrl(MSR_IA32_SPEC_CTRL, 0); >>> + } >>> + /* >>> + * Speculative execution past the above wrmsrl might encounter >>> + * an indirect branch and use guest-controlled contents of the >>> + * indirect branch predictor; block it. >>> + */ >>> + asm("lfence"); >> Don't you want this to be part of the if () .. else part? > > Not right now, because the processor could speculate that have_spec_ctrl > == 0 and skip the wrmsrl. After it becomes a static_cpu_has, it could > move inside, but only if the kernel is compiled with static keys enabled. > >> Meaning: >> >> if (have_spec_ctrl && svm->spec_ctrl) >> wrmsrl(MSR_IA32_SPEC_CTRL, 0); >> else >> asm("lfence"); >> >> But .. I am missing something - AMD don't expose 0x48. They expose only 0x49. >> >> That is only the IPBP is needed on AMD? (I haven't actually seen any official >> docs from AMD). > > AMD is not exposing 0x48 yet, but they plan to based on my information > from a few weeks ago. Haha, interesting, they announce officially there is no issue for variant 2. http://www.amd.com/en/corporate/speculative-execution Regards, Wanpeng Li