On Thu, 2018-02-01 at 22:59 +0100, KarimAllah Ahmed wrote: > [ Based on a patch from Ashok Raj <ashok....@intel.com> ] > > Add direct access to MSR_IA32_SPEC_CTRL for guests. This is needed for > guests that will only mitigate Spectre V2 through IBRS+IBPB and will not > be using a retpoline+IBPB based approach. > > To avoid the overhead of saving and restoring the MSR_IA32_SPEC_CTRL for > guests that do not actually use the MSR, only start saving and restoring > when a non-zero is written to it. > > No attempt is made to handle STIBP here, intentionally. Filtering STIBP > may be added in a future patch, which may require trapping all writes > if we don't want to pass it through directly to the guest. > > [dwmw2: Clean up CPUID bits, save/restore manually, handle reset] > > Cc: Asit Mallick <asit.k.mall...@intel.com> > Cc: Arjan Van De Ven <arjan.van.de....@intel.com> > Cc: Dave Hansen <dave.han...@intel.com> > Cc: Andi Kleen <a...@linux.intel.com> > Cc: Andrea Arcangeli <aarca...@redhat.com> > Cc: Linus Torvalds <torva...@linux-foundation.org> > Cc: Tim Chen <tim.c.c...@linux.intel.com> > Cc: Thomas Gleixner <t...@linutronix.de> > Cc: Dan Williams <dan.j.willi...@intel.com> > Cc: Jun Nakajima <jun.nakaj...@intel.com> > Cc: Paolo Bonzini <pbonz...@redhat.com> > Cc: David Woodhouse <d...@amazon.co.uk> > Cc: Greg KH <gre...@linuxfoundation.org> > Cc: Andy Lutomirski <l...@kernel.org> > Cc: Ashok Raj <ashok....@intel.com> > Signed-off-by: KarimAllah Ahmed <karah...@amazon.de> > Signed-off-by: David Woodhouse <d...@amazon.co.uk> > --- > v6: > - got rid of save_spec_ctrl_on_exit > - introduce msr_write_intercepted > v5: > - Also check for X86_FEATURE_SPEC_CTRL for the msr reads/writes > v4: > - Add IBRS to kvm_cpuid_8000_0008_ebx_x86_features > - Handling nested guests > v3: > - Save/restore manually > - Fix CPUID handling > - Fix a copy & paste error in the name of SPEC_CTRL MSR in > disable_intercept. > - support !cpu_has_vmx_msr_bitmap() > v2: > - remove 'host_spec_ctrl' in favor of only a comment (dwmw@). > - special case writing '0' in SPEC_CTRL to avoid confusing live-migration > when the instance never used the MSR (dwmw@). > - depend on X86_FEATURE_IBRS instead of X86_FEATURE_SPEC_CTRL (dwmw@). > - add MSR_IA32_SPEC_CTRL to the list of MSRs to save (dropped it by accident).
This looks very good to me now, and the comments are helpful. Thank you for your persistence with getting the details right. If we make the SVM one look like this, as you mentioned, I think we ought finally be ready to merge it. Good work ;)
Description: S/MIME cryptographic signature