From: Patrick Bellasi <derkling@google.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Patrick Bellasi <derkling@matbug.net>,
Brendan Jackman <jackmanb@google.com>,
Yosry Ahmed <yosry.ahmed@linux.dev>
Subject: Re: Re: Re: Re: [PATCH] x86/bugs: KVM: Add support for SRSO_MSR_FIX
Date: Thu, 13 Feb 2025 17:50:57 +0000 [thread overview]
Message-ID: <20250213175057.3108031-1-derkling@google.com> (raw)
In-Reply-To: <20250213142815.GBZ64Bf3zPIay9nGza@fat_crate.local>
> On Thu, Feb 13, 2025 at 01:44:08PM +0000, Patrick Bellasi wrote:
> > Following (yet another) updated versions accounting for this.
> >
> Here's a tested one. You could've simply waited as I told you I'm working on
> it.
Thanks Borislav, no problems for me, I'm just looking into these SRSO fixes and
what I did was mostly a way to ramp up.
> I'm going to queue this one next week into tip once Patrick's fix becomes part
> of -rc3.
Thanks for all the efforts.
Meanwhile I've a couple of questions about the approach proposed here.
> + * 'Mitigation: Reduced Speculation':
> +
> + This mitigation gets automatically enabled when the above one "IBPB on
> + VMEXIT" has been selected and the CPU supports the BpSpecReduce bit.
> +
> + It gets automatically enabled on machines which have the
> + SRSO_USER_KERNEL_NO=1 CPUID bit. In that case, the code logic is to switch
> + to the above =ibpb-vmexit mitigation because the user/kernel boundary is
> + not affected anymore and thus "safe RET" is not needed.
> +
> + After enabling the IBPB on VMEXIT mitigation option, the BpSpecReduce bit
> + is detected (functionality present on all such machines) and that
> + practically overrides IBPB on VMEXIT as it has a lot less performance
> + impact and takes care of the guest->host attack vector too.
> +
> + Currently, the mitigation uses KVM's user_return approach
> + (kvm_set_user_return_msr()) to set the BpSpecReduce bit when a vCPU runs
> + a guest and reset it upon return to host userspace or when the KVM module
> + is unloaded. The intent being, the small perf impact of BpSpecReduce should
> + be incurred only when really necessary.
According to [1], the AMD Whitepaper on SRSO says:
Processors which set SRSO_MSR_FIX=1 support an MSR bit which mitigates SRSO
across guest/host boundaries. Software may enable this by setting bit 4
(BpSpecReduce) of MSR C001_102E. This bit can be set once during boot and
should be set identically across all processors in the system.
The "should be set identically across all processors in the system" makes me
wondering if using the "KVM's user_return approach" proposed here is robust
enough. Could this not lead to the bit being possibly set only on some CPU
but not others?
Am I missing something? Is the MSR used something "shared" across all the cores
of a CPU, i.e. as long a vCPU is running the entire system is still protected?
Maybe there is even just a more recent whitepaper (I did not find) online with
a different recommendation?
Also, setting the MSR bit only while the guest is running, is it sufficient to
prevent both speculation and training?
Think about this scenario:
(a) Guest runs with BpSpecReduce MSR set by KVM and performs training.
(b) We exit into userspace and clear BpSpecReduce.
(c) We go back into the kernel with BpSpecReduce cleared and the guest
training intact.
If (a) can be done (i.e. the MSR does not prevent training), don't we end up in
a vulnerable state in (c)?
If BpSpecReduce does not prevent training, but only the training from being
used, should not we keep it consistently set after a guest has run, or until an
IBPB is executed?
Best,
Patrick
[1] https://www.amd.com/content/dam/amd/en/documents/corporate/cr/speculative-return-stack-overflow-whitepaper.pdf
next prev parent reply other threads:[~2025-02-13 17:51 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
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 [this message]
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=20250213175057.3108031-1-derkling@google.com \
--to=derkling@google.com \
--cc=bp@alien8.de \
--cc=derkling@matbug.net \
--cc=jackmanb@google.com \
--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=seanjc@google.com \
--cc=x86@kernel.org \
--cc=yosry.ahmed@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®