Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73] helo=mx1.redhat.com) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1f9ZUp-0001Pe-Ju for speck@linutronix.de; Fri, 20 Apr 2018 19:06:52 +0200 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A7E18D685 for ; Fri, 20 Apr 2018 17:06:45 +0000 (UTC) Received: from washington.bos.jonmasters.org (ovpn-124-165.rdu2.redhat.com [10.10.124.165]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 34C9211701C4 for ; Fri, 20 Apr 2018 17:06:45 +0000 (UTC) Subject: [MODERATED] Re: [patch 04/11] [PATCH v2 04/10] Linux Patch #4 References: <20180420022613.057637144@localhost.localdomain> <20180420161533.GK13977@pd.tnic> <20180420163936.GA4615@localhost.localdomain> From: Jon Masters Message-ID: Date: Fri, 20 Apr 2018 13:06:44 -0400 MIME-Version: 1.0 In-Reply-To: <20180420163936.GA4615@localhost.localdomain> Content-Type: multipart/mixed; boundary="4viuyqv7XYk2rnD7I8XtW08ziFJnkMUif"; protected-headers="v1" To: speck@linutronix.de List-ID: This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156) --4viuyqv7XYk2rnD7I8XtW08ziFJnkMUif Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 04/20/2018 12:39 PM, speck for Konrad Rzeszutek Wilk wrote: > On Fri, Apr 20, 2018 at 06:15:33PM +0200, speck for Borislav Petkov wro= te: >> On Thu, Apr 19, 2018 at 10:25:44PM -0400, speck for konrad.wilk_at_ora= cle.com wrote: >>> KVM/SVM/VMX/x86/spectre_v2: Support the combination of guest IBRS and= ours. >>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c >>> index be9c839e2c89..f666b4c21559 100644 >>> --- a/arch/x86/kvm/svm.c >>> +++ b/arch/x86/kvm/svm.c >>> @@ -5401,7 +5401,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)= >>> * is no need to worry about the conditional branch over the wrmsr >>> * being speculatively taken. >>> */ >>> - if (svm->spec_ctrl) >>> + if (svm->spec_ctrl || need_spec_ctrl_acc()) >>> native_wrmsrl(MSR_IA32_SPEC_CTRL, svm->spec_ctrl); >> >> Instead of those silly set/clear helpers, why not do this: >> >> if (svm->spec_ctrl) >> x86_enable_ibrs(); >=20 > Wouldn't we leak our MD state to the guest? That is the guest > may have cleared everything (svm->spec_ctrl is zero when we VMEXIT), > and now we would be running it with MD bit set? Indeed, we would. And we should only do that if we mean to intentionally override whatever the guest is doing. Longer term, as more bits are added to SPEC_CTRL you're going to end up wanting Konrad's original version because there's bound to be more bits. btw, I do think there's value in being able to force a guest to run with e.g. MD on but not much until Intel come back to us about masking. As it stands, once we give SPEC_CTRL to a guest, it can just clobber it. Jon. --=20 Computer Architect | Sent from my Fedora powered laptop --4viuyqv7XYk2rnD7I8XtW08ziFJnkMUif--