All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@kernel.org>, X86 ML <x86@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	 Josh Poimboeuf <jpoimboe@redhat.com>,
	Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	 KVM <kvm@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 3/4] x86/bugs: KVM: Add support for SRSO_MSR_FIX
Date: Wed, 8 Jan 2025 09:18:17 -0800	[thread overview]
Message-ID: <Z36zWVBOiBF4g-mW@google.com> (raw)
In-Reply-To: <20250108154901.GFZ36ebXAZMFZJ7D8t@fat_crate.local>

On Wed, Jan 08, 2025, Borislav Petkov wrote:
> > And do you know what 0xd23f corresponds to?
> 
> How's that:
> 
> $ objdump -D arch/x86/kvm/kvm.ko
> ...
> 000000000000d1a0 <kvm_vcpu_halt>:
>     d1a0:       e8 00 00 00 00          call   d1a5 <kvm_vcpu_halt+0x5>
>     d1a5:       55                      push   %rbp
>     ...
> 
>     d232:       e8 09 93 ff ff          call   6540 <kvm_vcpu_check_block>
>     d237:       85 c0                   test   %eax,%eax
>     d239:       0f 88 f6 01 00 00       js     d435 <kvm_vcpu_halt+0x295>
>     d23f:       f3 90                   pause
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
>     d241:       e8 00 00 00 00          call   d246 <kvm_vcpu_halt+0xa6>
>     d246:       48 89 c3                mov    %rax,%rbx
>     d249:       e8 00 00 00 00          call   d24e <kvm_vcpu_halt+0xae>
>     d24e:       84 c0                   test   %al,%al
> 
> 
> Which makes sense :-)

Ooh, it's just the MSR writes that increased.  I misinterpreted the profile
statement and thought that something in KVM was jumping from ~0% to 4.31%.  If
the cost really is just this:

   1.66%  qemu-system-x86  [kernel.kallsyms]        [k] native_write_msr
   1.50%  qemu-system-x86  [kernel.kallsyms]        [k] native_write_msr_safe

vs

   1.01%  qemu-system-x86  [kernel.kallsyms]        [k] native_write_msr
   0.81%  qemu-system-x86  [kernel.kallsyms]        [k] native_write_msr_safe

then my vote is to go with the user_return approach.  It's unfortunate that
restoring full speculation may be delayed until a CPU exits to userspace or KVM
is unloaded, but given that enable_virt_at_load is enabled by default, in practice
it's likely still far better than effectively always running the host with reduced
speculation.

> > Yeah, especially if this is all an improvement over the existing mitigation.
> > Though since it can impact non-virtualization workloads, maybe it should be a
> > separately selectable mitigation?  I.e. not piggybacked on top of ibpb-vmexit?
> 
> Well, ibpb-on-vmexit is your typical cloud provider scenario where you address
> the VM/VM attack vector by doing an IBPB on VMEXIT. 

No?  svm_vcpu_load() emits IBPB when switching VMCBs, i.e. when switching between
vCPUs that may live in separate security contexts.  That IBPB is skipped when
X86_FEATURE_IBPB_ON_VMEXIT is enabled, because the host is trusted to not attack
its guests.

> This SRSO_MSR_FIX thing protects the *host* from a malicious guest so you
> need both enabled for full protection on the guest/host vector.

If reducing speculation protects the host, why wouldn't that also protect other
guests?  The CPU needs to bounce through the host before enterring a different
guest.

And if for some reason reducing speculation doesn't suffice, wouldn't it be
better to fall back to doing IBPB only when switching VMCBs?

  reply	other threads:[~2025-01-08 17:18 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 12:04 [PATCH v2 0/4] x86/bugs: Adjust SRSO mitigation to new features Borislav Petkov
2024-12-02 12:04 ` [PATCH v2 1/4] x86/bugs: Add SRSO_USER_KERNEL_NO support Borislav Petkov
2024-12-10  6:53   ` Josh Poimboeuf
2024-12-10 15:37     ` Borislav Petkov
2024-12-11  7:53       ` Josh Poimboeuf
2024-12-11 20:38         ` Borislav Petkov
2024-12-11 22:35           ` Sean Christopherson
2024-12-16 17:21             ` Borislav Petkov
2024-12-30 17:02   ` [tip: x86/bugs] " tip-bot2 for Borislav Petkov (AMD)
2024-12-02 12:04 ` [PATCH v2 2/4] KVM: x86: Advertise SRSO_USER_KERNEL_NO to userspace Borislav Petkov
2024-12-30 17:02   ` [tip: x86/bugs] " tip-bot2 for Borislav Petkov (AMD)
2024-12-02 12:04 ` [PATCH v2 3/4] x86/bugs: KVM: Add support for SRSO_MSR_FIX Borislav Petkov
2024-12-11 22:27   ` Sean Christopherson
2024-12-16 17:31     ` Borislav Petkov
2024-12-16 18:51       ` Sean Christopherson
2024-12-17  9:34         ` Borislav Petkov
2024-12-30 11:14         ` Borislav Petkov
2025-01-08 13:38           ` Sean Christopherson
2025-01-08 15:49             ` Borislav Petkov
2025-01-08 17:18               ` Sean Christopherson [this message]
2025-01-08 18:14                 ` Borislav Petkov
2025-01-08 18:37                   ` Jim Mattson
2025-01-08 19:14                     ` Borislav Petkov
2025-01-08 19:43                       ` Jim Mattson
2025-01-08 19:45                         ` Borislav Petkov
2025-01-11 12:52                   ` [PATCH] " Borislav Petkov
2025-01-17 18:56                     ` Sean Christopherson
2025-01-18 15:26                       ` Borislav Petkov
2025-01-23 16:25                         ` Sean Christopherson
2025-01-23 17:01                           ` Borislav Petkov
2025-01-23 18:04                             ` Sean Christopherson
2025-01-24 12:58                               ` Borislav Petkov
2025-02-11 19:19                                 ` Jim Mattson
2025-02-11 20:51                                   ` Borislav Petkov
2025-02-13 10:53                             ` Patrick Bellasi
2025-02-13 13:44                               ` Patrick Bellasi
2025-02-13 14:28                                 ` Borislav Petkov
2025-02-13 17:50                                   ` Patrick Bellasi
2025-02-14 20:10                                     ` Borislav Petkov
2025-02-15  0:57                                       ` Yosry Ahmed
2025-02-15  9:15                                         ` Borislav Petkov
2025-02-17  5:47                                           ` Yosry Ahmed
2025-02-17 15:26                                             ` Borislav Petkov
2025-02-15 12:53                                       ` Borislav Petkov
2025-02-17  5:59                                         ` Yosry Ahmed
2025-02-17 16:07                                           ` Borislav Petkov
2025-02-17 19:56                                             ` Yosry Ahmed
2025-02-17 20:20                                               ` Borislav Petkov
2025-02-17 20:32                                                 ` Yosry Ahmed
2025-02-18 11:13                                                   ` [PATCH final?] " Borislav Petkov
2025-02-18 14:42                                                     ` Patrick Bellasi
2025-02-18 15:34                                                       ` Borislav Petkov
2025-04-29 13:25                                                     ` x86/bugs: KVM: Add support for SRSO_MSR_FIX, back for moar Borislav Petkov
2025-04-30 23:33                                                       ` Sean Christopherson
2025-05-01  0:42                                                         ` Michael Larabel
2025-05-01  8:19                                                         ` Borislav Petkov
2025-05-01 16:56                                                           ` Sean Christopherson
2025-05-05 15:25                                                             ` Borislav Petkov
2025-05-05 15:40                                                               ` Kaplan, David
2025-05-05 15:47                                                                 ` Borislav Petkov
2025-05-05 16:30                                                                 ` Sean Christopherson
2025-05-05 16:42                                                                   ` Kaplan, David
2025-05-05 18:03                                                                     ` Sean Christopherson
2025-05-05 18:25                                                                       ` Kaplan, David
2024-12-02 12:04 ` [PATCH v2 4/4] Documentation/kernel-parameters: Fix a typo in kvm.enable_virt_at_load text Borislav Petkov
2024-12-30 17:21   ` [tip: x86/cleanups] " tip-bot2 for Borislav Petkov (AMD)
2024-12-03 14:30 ` [PATCH v2 0/4] x86/bugs: Adjust SRSO mitigation to new features Nikolay Borisov
2025-02-26 14:32 ` [tip: x86/bugs] x86/bugs: KVM: Add support for SRSO_MSR_FIX tip-bot2 for Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z36zWVBOiBF4g-mW@google.com \
    --to=seanjc@google.com \
    --cc=bp@alien8.de \
    --cc=bp@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=pbonzini@redhat.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.