Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2242615imm; Thu, 7 Jun 2018 07:35:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLkB5CXVT9peKPFZddpueoW4ZDRPM6kZeZ/fiElbbc2Nt+oojVtrmSPC9YY+vLkoCwFQgIX X-Received: by 2002:a17:902:868b:: with SMTP id g11-v6mr2249322plo.305.1528382140338; Thu, 07 Jun 2018 07:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528382140; cv=none; d=google.com; s=arc-20160816; b=ThrRlltq8VXyBLih3IG6crtiSDMa4EVqMGd6dR6vlgICVds6U146DbX6FodwHb/laL DRPsi1vQ9saF3Edqrdgtu2xWt2ez5/WAGDgqnuEA6ThjzxognCGYZ6cJPVNVXHSTSvSh MZ4QFPslUVvSkfm6vnqhDaESvVFcEHHHPw05g9jlNS4B0dxBmm11BjaVWgZDrnZqEANw IG0U/ozRS7LiuqXz9TXs75MJv/CBbfCm8L8a4HV0bUiAko8vShrGgba1qNCxK5YKzTr9 Sw7sj37nGCbGrTS3MR5B3rWE6RrzS+W0vPta2jX/gz1rFzfNWtkJydesiCSgycbP8Yv0 k14w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=P7tKrZA4EOf9gHrwSoYzeunhK0Q4LHWgv85usmm06Ck=; b=fQ74RGRNojGWipGH5k6Y9dbNQ96pf3g+kMLbRCCPjW1kMs7rI8Azl+oawsNZZUkWWB SnrPsIkbVxBykwFIJBUkm7ho8YujBUVzG0l6NKKPkh6z6Rsbl7B0flEfPyamBni0QYPh gmk57bM3Y9K9Rgp9PBWy5LukFzdpTg0Y4RQlnecNG0nRrX/PNSWbDNypx+NswHOt1g8q n0x0uiZ9+k0qglF/8cq+fLMH4SBqaHjCGHg2PlVd4RWFYX84H5T7yw5EY0XiHYaZ6iRO 6lJat6HMa30RF1r/nZpbxNx4AIfTjm2x6Hro60TXSNNko2Q/eioA12+dbux7oYrNWKZN gNjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e72-v6si10149692pfd.352.2018.06.07.07.35.25; Thu, 07 Jun 2018 07:35:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933985AbeFGOeU (ORCPT + 99 others); Thu, 7 Jun 2018 10:34:20 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40347 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933629AbeFGOeS (ORCPT ); Thu, 7 Jun 2018 10:34:18 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbw-0005Zv-TE; Thu, 07 Jun 2018 15:09:57 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvaz-0002kr-Eu; Thu, 07 Jun 2018 15:08:57 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David Woodhouse" , "Jim Mattson" , "Peter Zijlstra" , "Paolo Bonzini" , "Ingo Molnar" , "Greg Kroah-Hartman" , kvm@vger.kernel.org, "KarimAllah Ahmed" , "Linus Torvalds" , "Thomas Gleixner" , "Radim =?UTF-8?Q?Kr=C4=8Dm=C3=A1=C5=99?=" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 059/410] KVM/x86: Remove indirect MSR op calls from SPEC_CTRL In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Paolo Bonzini commit ecb586bd29c99fb4de599dec388658e74388daad upstream. Having a paravirt indirect call in the IBRS restore path is not a good idea, since we are trying to protect from speculative execution of bogus indirect branch targets. It is also slower, so use native_wrmsrl() on the vmentry path too. Signed-off-by: Paolo Bonzini Reviewed-by: Jim Mattson Cc: David Woodhouse Cc: KarimAllah Ahmed Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Radim Krčmář Cc: Thomas Gleixner Cc: kvm@vger.kernel.org Fixes: d28b387fb74da95d69d2615732f50cceb38e9a4d Link: http://lkml.kernel.org/r/20180222154318.20361-2-pbonzini@redhat.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- arch/x86/kvm/svm.c | 7 ++++--- arch/x86/kvm/vmx.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -3967,7 +3968,7 @@ static void svm_vcpu_run(struct kvm_vcpu * being speculatively taken. */ if (svm->spec_ctrl) - wrmsrl(MSR_IA32_SPEC_CTRL, svm->spec_ctrl); + native_wrmsrl(MSR_IA32_SPEC_CTRL, svm->spec_ctrl); asm volatile ( "push %%" _ASM_BP "; \n\t" @@ -4077,10 +4078,10 @@ static void svm_vcpu_run(struct kvm_vcpu * save it. */ if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)) - rdmsrl(MSR_IA32_SPEC_CTRL, svm->spec_ctrl); + svm->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL); if (svm->spec_ctrl) - wrmsrl(MSR_IA32_SPEC_CTRL, 0); + native_wrmsrl(MSR_IA32_SPEC_CTRL, 0); /* Eliminate branch target predictions from guest mode */ vmexit_fill_RSB(); --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include "trace.h" @@ -7542,7 +7543,7 @@ static void __noclone vmx_vcpu_run(struc * being speculatively taken. */ if (vmx->spec_ctrl) - wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); + native_wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); vmx->__launched = vmx->loaded_vmcs->launched; asm( @@ -7673,10 +7674,10 @@ static void __noclone vmx_vcpu_run(struc * save it. */ if (!msr_write_intercepted_l01(vcpu, MSR_IA32_SPEC_CTRL)) - rdmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); + vmx->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL); if (vmx->spec_ctrl) - wrmsrl(MSR_IA32_SPEC_CTRL, 0); + native_wrmsrl(MSR_IA32_SPEC_CTRL, 0); /* Eliminate branch target predictions from guest mode */ vmexit_fill_RSB();